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<stdio.h>
#include<iostream>
using namespace std;

int main(){

	int N,Q;
	while(1){int c=0;
	cin>>N;if(N==0)break;
	long long int n[4002][2]={};
	for(int i=0;i<4001;i++)
		n[i][1]=0;

	for(int i=0;i<N;i++){
		long long int x,y,z;
		cin>>x>>y>>z;
		if(n[x][0]+y*z<=1000000)n[x][0]+=y*z;
		else if(n[x][0]+y*z>1000000)n[x][0]=1000000;
		if(n[x][1]==0){c++;n[x][1]=c;}
	
	}
	for(int i=0;i<4001;i++){
		for(int j=i;j>i;j--){
			if(n[j][1]<n[j-1][1]){
				int t=n[j][0];n[j][0]=n[j-1][0];n[j-1][0]=t;
				int T=n[j][1];n[j][1]=n[j-1][1];n[j-1][1]=T;
			}
		}
	}
	bool f=false;
	for(int i=0;i<4001;i++){
		if(n[i][0]>=1000000){cout<<i<<endl;f=true;}
	}
	if(f==false)cout<<"NA"<<endl;
	
	}
	return 0;
}

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

int main() {
	long long int i, n, no[4000], tanka[4000], num[4000];
	bool flg=false;
	while (1) {
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>1000000)
				flg=true, cout<<no[i]<<endl;
		}
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

string int_to_str(int n) {
	stringstream ss;
	string ret;

	ss << n;
	ss >> ret;

	return ret;
}


int keta(int n) {
	string str = int_to_str(n);

	return str.size();
}

int main() {
	int n;
	while (cin >> n, n) {
		bool f = false;
		map<int, ll> datas;
		vector<int> noes;
		for (int i = 0; i < n; ++i) {
			int no, a, b; cin >> no >> a >> b;

			if ( find( noes.begin(), noes.end(), no) == noes.end() )
				noes.push_back(no);

			if (datas[no] < 1000000) {
				if (keta(a) + keta(b) - 2 >= 6)
					f = true;

				else if ((datas[no] += a * b) >= 1000000)
					f = true;
			}
		}
		for (int i = 0; i < noes.size(); ++i)
			if (datas[noes[i]] >= 1000000)
				cout << noes[i] << endl;

		if (!f) 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 <iostream>
using namespace std;
typedef long long ll;

ll em[4000];
int flag[4000];

int main(){
	int n;
	while(true){
		int id,p,q;
		cin >> n;
		if(!n) return 0;
		for(int i = 0; i < n; i++){
			cin>>id>>p>>q;
			em[id-1] += (ll)p * q;
			flag[i] = id;
		}
		int f = 1;
		for(int i = 0; i < n; i++){
			if(em[flag[i]-1] >= 1000000){
				cout << flag[i] << endl;
				f = 0;
			}
			em[flag[i]-1] = 0;
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		int c[4001]={} , id[100000];
		for (int i=0; i<n; i++){
			int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
			}
		}
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define MAX_MEMBER 4000
#define HIGH 1000000
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        map<int, int> data;
        bool update = false;
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no]) {
                data[no] += tanka*quantity;
            } else data[no] = tanka*quantity;
        }
        map<int, int>::iterator it;
        for(it = data.begin(); it != data.end(); it++) {
            if(it->second >= HIGH) {
                cout << it->first << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    
    return(0);
}

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

int main(){
 int id,price,num,count,SaleResult[4000],idOrder[4000],orderCount=1;
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   SaleResult[id]+=price*num;
   if(SaleResult[id]>=1000000){
    for(int i=0;i<orderCount;i++){
     if(id==idOrder[i]){
      break;
     }
     if(i==orderCount-1){
      idOrder[orderCount]=id;
     }
    }
   }
  }
  for(int i=0;i<4000;i++){
   if(SaleResult[idOrder[i]]>=1000000){
     cout<<i<<'\n';
     isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[i]=0;
  }
  }
 return 0;
}

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

std::vector<int> staff;
bool search(int number);

int main()
{
	int n;
	while(1)
	{
		int number,price,amount;
		staff.clear();
		std::cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			std::cin>>number>>price>>amount;
			if((long long)price*amount>=1000000)
			{
				if(search(number)==false)
				{
					staff.push_back(number);
				}
			}
		}
		if(staff.empty())
		{
			std::cout<<"NA"<<std::endl;
		}
		else
		{
			for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
			{
				std::cout<<*p<<std::endl;
			}
		}
	}
	return 0;
}

bool search(int number)
{
	for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
	{
		if(*p==number)return true;
	}
	return false;
}

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

int main(){
 int id,price,num,count;
 int sameid[4000];
 bool isBe=false,isSame=false;

 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   sameid[i]=id;
   for(int j=1;j<i;j++){
    if(id==sameid[j]){
      isSame=true;
      break;
    }
   }
   if(price*num>=100000&&!isSame){
    cout<<id<<'\n';
    isBe=true;
   }
   isSame=false;
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<count;i++){
   sameid[i]=0;
  }
 }
 return 0;
}

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

using namespace std;
#define mp make_pair
int main(){
  int n,a,b;
  long long c;
  map<int,long> data;
  vector<int> id;
  while(true){
    id.clear();
    data.clear();
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      c*=b;
      if(data.find(a)==data.end()){
	data.insert(mp(a,c));
	id.push_back(a);
      }
      else{
	data[a]+=c;
      }
    }
    bool empty = true;
    for(int i=0;i<id.size();i++){
      if(data[id[i]]>=1000000){
	cout<<id[i]<<endl;
	empty = false;
      }
    }
    if (empty)
      cout<<"NA"<<endl;

  }
  return 0;
}

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

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check;
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      sales[ID] += price * quantity;
    }
    check = 0;
    for(int i=1;i<4001;i++) {
      if(sales[i] >= 1000000) {
        cout << i << endl;
        check = 1;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}