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<iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * (n + 1));
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		//cout << "Saled " << j << ":" << sl[j].Saled << endl;
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<map>
#include<utility>
#include<queue>

using namespace std;




int main(){
	static int n;
	while (cin >> n&&n != 0)
	{
		map< int, long long int> staff;
		queue< int> Queue;
		bool cnt = false;

		for (size_t i = 0; i < n; i++)
		{
			int num;
			long long b, c;
			cin >> num >> b >> c;

			staff[num] += (long long int) (b*c);
		}
		for (static map< int, long long int>::iterator itr = staff.begin(); itr != staff.end(); itr++){
			if (itr->second >= 1000000)
				Queue.push(itr->first);

		}
		if (Queue.size() == 0){
			cout << "NA" << endl;
		}
		else
		{
			while (Queue.size() > 0){

				cout << Queue.front() << endl;
				Queue.pop();

			}

		}

	}

	return 0;
}

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

int main()
{
	int n;

	while (cin >> n, n){
		int e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 1; i <= 4000; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		//cout << "Saled " << j << ":" << sl[j].Saled << endl;
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int n;
   while(cin>>n&&n)
   {
     long long int arr[1000000+5]={0};
     bool flag=false;
     for(int i=0;i<n;i++)
     {
       int id,p,q;
       cin>>id>>p>>q;
       arr[id]+=(p*q);        
     }           
     for(int i=1;i<=1000000;i++)
     {
       if(arr[i]>=1000000)
       {
         cout<<i<<endl;
         flag=true;
       }        
     }       
     if(!flag) cout<<"NA"<<endl;
   }
   //while(1);
   return 0;
 }

C++: int main(void)
{	
	employee person[4000];
	int a,b,c,d;
	for(b=0;;b=0)
	{
		scanf("%d",&c);
		for(a=0;a<c;a++)
		{
			scanf("%d %lld %lld",&person[a].N,&person[a].P,&person[a].A);
			person[a].M=person[a].P*person[a].A;
			for(d=0;d<a;d++)
				if(person[a].N==person[d].N)
				{
					person[a].M+=person[d].M;
					person[d].M=0;
				}
		}
		for(a=0;a<c;a++)
			if(person[a].M>=1000000 )
			{
				printf("%d\n",person[a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <map>
#define STA 1000000
using namespace std;

int main(){
    int n;
    long long num,price,value;
    bool judge;
    while(1){
        cin >> n;
        if(n == 0) break;
        map <int,long long> data;
        map <long long,long long> data1;
        map <long long,long long>::iterator itr;
        data.clear();
        data1.clear();
        for(int i=1;i<=n;i++){
            cin >> num >> price >> value;
            itr = data1.find(num);
            if(itr != data1.end()) data1[num] += price * value;
            else {
                data.insert(map<int,long long>::value_type(i,num));
                data1.insert(map<long long,long long>::value_type(num,price*value));
            }
        }
        judge = false;
        for(int i=1;i<=n;i++){
            if(data1[data[i]] >= STA){
                cout << data[i] << endl;;
                judge = true;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<string> result;

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

    bool hoge = true;
    for (int i = 0; i < n; i++) {
      string id;
      long long a, b;
      cin >> id >> a >> b;
      if (a * b >= 1000000) {
        result.push_back(id);
        hoge = false;
      }
    }
    if (hoge)
      result.push_back("NA");
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,int> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			sk[bg] += tn * su;
			bool adsw=true;
			rep(j,i) if(jun[j]==bg) adsw=false;
			if(adsw) jun.push_back(bg);
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) 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};
        int ans_n[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            ans_n[i]=a;
            ans[a]+=b*c;
        }
        
        for(int i=0; i<n; i++){
            if(ans[ans_n[i]]>=1000000){
                cout<<ans_n[i]<<endl;
                ans[ans_n[i]]=0;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}