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 <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define INF 10000000
#define MAX_N 4001

int n;
int meibo[MAX_N];

struct kanri{

	int number;
	int sum;

}syain[MAX_N];

void shoki();

int main(){

	while(true){
	
		scanf("%d", &n);

		if(n == 0)
			break;

		shoki();

		int num = 0;
		int kari;

		for(int i = 0; i < n; i++){
			scanf("%d", &kari);
			bool flag = false;
			for(int j = 0; j < num; j++){
				if(syain[j].number == kari){
					int kari1, kari2;
					scanf("%d%d", &kari1, &kari2);
					syain[j].sum += kari1*kari2;
					flag = true;
					break;
				}
			}

			if(!flag){
				int kari1, kari2;
				syain[num].number = kari;
				scanf("%d%d", &kari1, &kari2);
				syain[num].sum += kari1 * kari2;
				num++;
			}

		}

		bool flag2 = false;

		for(int i = 0; i < n; i++){
			if(syain[i].sum >= 1000000){
				printf("%d\n", syain[i].number);
				flag2 = true;
			}
		}

		if(!flag2){
			printf("NA\n");
		}

	
	}


	return 0;

}

void shoki(){
	for(int i = 0; i < MAX_N; i++){
		syain[i].number = 0;
		syain[i].sum = 0;
	}
}

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

int main()
{
	array<long long, 4000> ar;
	vector<long long> ans;
	long long n;
	int e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				auto it = ans.begin();
				it = find(it, ans.end(), i);
				if (it == ans.end()) {
					ans.push_back(i);
				}
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
long long sum[4000][10000];
bool used[4000][5000];
int main(){
    int a[10000];
    long long int n, b, c;
    for(int m=0; ; m++){
        scanf("%lld", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%d%lld%lld", &a[i], &b, &c);
            sum[m][a[i]] += b*c;
            /*if(b*c>=1000000){
                na = false;
                printf("%lld\n", a);
            }*/
        }
        for(int i = 0; i < n; i++){
            if(used[m][a[i]]==false&&sum[m][a[i]] >= 1000000){
                na = false;
              used[m][a[i]]=true;
                printf("%d\n", a[i]);
            }
        }
        
        if(na) puts("NA");
    }
}

C++: #include<stdio.h>
int n,i,b;
int a,suu;
long long int syain[4001];
int flg=0;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%.4d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    vector<int> num;
    set<int> used;
    map<int, long long> sales;
    int a, b, c;
    for(int i = 0;i < n;i++){
      cin >> a >> b >> c;
      num.push_back(a);
      sales[a] += b * c;
    }
    bool ok = false;
    for(int i = 0;i < n;i++){
      int p = num[i];
      if(used.count(p))continue;
      used.insert(p);
      if(sales[p] >= 1000000){
	cout << p << endl;
	ok = true;
      }
    }
    if(!ok)cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		long long no;
		long long price;
		long long deal;

		vector <long long> V;
		map <long long, long long> P;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;

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

			P[no] = max( P[no], price * deal );

			if ( P[no] >= 1000000 )
			{
				f = false;
			}
		}

		if ( f )
		{
			cout << "NA" << endl;
		}
		else
		{
			for ( vector <long long>::iterator it = V.begin(); it != V.end(); it++ )
			{
				if ( P[*it] >= 1000000 )
				{
					cout << *it << endl;
				}
			}
		}

	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void) {
  int n, flag=0;
  int man[4000], num, sale, good[4000];
  
  while(1) {
    flag = 0;
    for(int i = 0 ; i < 4000 ; i++) {
      man[i] = 0;
      good[i] = 0;
    }
    cin >> n;
    if(n == 0) break;
    for(int i = 0 ; i < n ; i++) {
      cin >> man[i] >> num >> sale;
      if(num * sale >= 1000000) { good[i] = man[i]; flag = 1; }
    }
    if(flag == 1) {
      for(int i = 0 ; i < n ; i++) {
	if(good[i] > 0) cout << good[i] << endl;
      }
    }
    else cout << "NA" << endl;
  }
  return 0;
}

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 = false;
        }
      }
    }

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int bangou,tanka,kosuu;
    int number; cin >> number;
    do{
        int man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1 << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

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

int main(){
 int id,price,num,count;
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   if(price*num>=100000){
    cout<<id<<'\n';
    isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
 }
 return 0;
}

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

int main()
{
	int em[4000];
	int num,i,id,p,q,flag;
	cin>>num;

	while(num!=0){
    flag =0;

	for(i=0;i<4000;i++){
		em[i]=0;
	}

	for(i=0;i<=num-1;i++){
	    cin>>id >>p >>q;
		em[id]+=p*q;
	}

	for(i=0;i<4000;i++){
		if(em[i]>=1000000){
			cout<<i<<"\n";
		    flag =1;
		}
	}
	if(flag!=1)
		cout<<"NA\n";
	cin >>num;

	}
	return 0;
		
}