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<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;
void shoki();
void henkan(string);
int tansaku(int);
pair<string,long long> num[4001];
int n,ban,tanka,kazu,i,j,memo;
bool dp[4001]={false};
int main(){
	int al=0;
	bool y=false;
	while(1){
		shoki();
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>num[i].first>>tanka>>kazu;
			henkan(num[i].first);
			if(dp[memo]==true){
				num[tansaku(i)].second+=tanka*kazu;
			}
			else{
			num[i].second+=tanka*kazu;
			}
			dp[memo]=true;
			memo=0;
		}
		for(int k=0;k<=i;k++){
			if(num[k].second==0){
				continue;
			}
			if(num[k].second>=1000000){
				y=true;
				cout<<num[k].first<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
		memset(dp,false,sizeof(dp));
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4001;i++){
		num[i].first="0";
		num[i].second=0;
	}
	return;
}
void henkan(string str1){
	long long kake=1;
	for(int i=0;i<str1.size();i++){
		memo+=str1[i]*i;
		i*=10;
	}
	return;
}
int tansaku(int rec){
	int res;
	for(int l=0;l<rec;l++){
		if(num[rec].first==num[l].first){
			return res=l;
		}
	}
}

C++: #include<cstdio>
#include<map>
#include<vector>
std::map<int, int> mp;
std::vector<int> v;
int main() {
	int n, i, e, p, q;
	while (true) {
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &e, &p, &q);
			if (mp.count(e) == 0) mp[e] = p*q;
			else mp[e] += p*q;
		}
		for (std::map<int, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
			if (itr->second >= 1000000)v.push_back(itr->first);
		}
		if (v.size() == 0)printf("NA\n");
		else {
			for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
				printf("%d\n", *itr);
			}
		}
		mp.clear();
		v.clear();
	}
	return 0;
}

C++: #include <iostream>

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number, price, amount;
  int numbers[4000];
  long long sales[4000];

  for(;;) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < 4000; i++) {
      numbers[i] = 0;
      sales[i] = 0;
    }
    for (i = 0, f = false; i < n; i++) {
      cin >> number >> price >> amount;
      for (j = 0; j < i; j++) {
        if (numbers[j] == number) {
          f = true;
          sales[j] = (long long)price * (long long)amount;
        }
      }
      if(!f) {
        numbers[i] = number;
        sales[i] = (long long)price * (long long)amount;
      }
    }
    for (i = 0, f = false; i < n; i++) {
      if (sales[i] > BORDER) {
        f = true;
        cout << numbers[i] << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}

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

int main(){
  double n ,flag=0 ,num[4001] ,price[4001] ,earnings[4001] ,total[4001] ,overlap;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    for( int i=0 ; i<n ; i++ ){ // 入力と合計を計算
      cin >> num[i] >> price[i] >> earnings[i];
      total[i] = price[i] * earnings[i];
    }

    for( int i=0 ; i<n ; i++ ){ // 重複を無くす
      overlap = num[i]; // 重複したかの判定
      for( int j=0 ; j<n ; j++ ){
	if( num[j] == overlap && i != j ){ // 重複したか
	  total[i] += total[j];
	  num[j] = -1;
	  total[j] = 0;
	}
      }
    }

    for( int i=0 ; i<n ; i++ ){ // 出力
      if( total[i] >= 1000000 ){
	cout << num[i] << endl;
	flag = 1;
      }
    }

    if( flag == 0 ){ // いなかったら
      cout << "NA" << endl;
    }
    flag = 0;
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n,f;
  //mlÛ¶vÛ¶
  long long int a,b,c;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(m[a]+=b*c)v.push_back(a);
      //m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<map>
#include<set>
#define LIM 1000000
using namespace std;
map<int,long long>data;
set<int>used;
int main(){
	int n;
	while(cin>>n && n){
		used.clear();
		data.clear();
		bool update=false;
		for(int i=0;i<n;i++){
			int id;
			cin>>id;
			long long  ans;
			cin>>ans;
			int tmp;
			cin>>tmp;
			ans*=tmp;
			data[id]+=ans;
			if(data[id]>=LIM &&used.find(id)==used.end()){
				update=true;
				cout<<id<<endl;
				used.insert(id);
			}
		}
		if(!update)cout<<"NA"<<endl;
	}
}

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

int main()
{
	int n;

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

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int company[4000] = { 0 };
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
			if (company[num - 1] >= target)
			{
				printf("%d\n", num);
				company[num - 1] = -1000000000;
			}
		}

		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
long long s[4000];int i;int w;int j;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	int g = 1000000 - s[a-1];
	if(g%b==0){j = g/b;}
	else{j = (g/b)+1;}
	if(j<c){s[a-1]=1000001;}
	else{s[a-1]=s[a-1]+b*c;}
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n != 0){
    for(int i = 0;i < n;i++){
       cin >> a >> b >> c;
       com[a] += b * c;
      }
    for(int j = 1;j < 4001;j++){
       if(com[j] >= 1000000){
       cout << com[j] << endl;
       d++;
       }  
      }    
    if(d == 0) cout << "NA" << endl;
     }
    return 0;
   }

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

int main()
{
	int n;
	string ans[4000];
	double a,b;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			string num;
			int flag=1;
			cin >> num >> a >> b ;
			if(a/10000.0*b>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num)
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num;
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}