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++: //AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
if(f==0)ta.push_back(pair<int,__int64>(a,b*c));
else ta[index].second+=b*c;
}
bool f=0;
for(int i=0;i<ta.size();i++){
	//cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}

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

int n;
int a[3];
int x[4001];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		int count = 0;

		std::memset(x, 0, sizeof(x));

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j)
				std::cin >> a[j];
			x[a[0]] += a[1] * a[2];
		}
		for (int i = 1; i <= 4000; ++i) {
			if (x[i] >= 1000000) {
				std::cout << i << std::endl;
				++count;
			}
		}
		if (count==0)
			std::cout << "NA" << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main()
{
  while(1){
    int n;
    cin>>n;
    if(n == 0){
      break;
    }

    vector<pair<int,int>> data;
    vector<int> nanum;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      int sum = sa * ko;

      if(i == 0){
        nanum.push_back(num);
        data.push_back(make_pair(num,sum));
      }
      else{
        auto a = find(nanum.begin(),nanum.end(),num);
        int b = *a
        if(b == 0){
          nanum.push_back(num);
          data.push_back(make_pair(num,sum));
        }
      }
    }

    int check = 0;
    for(pair<int,int> e : data){
      if(e.second >= 1000000){
        check = 1;
        cout<<e.first<<endl;
      }
    }
    if(check == 0){
      cout<<"NA"<<endl;
    }
  }

  return 0;
}

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

int main(){
	int n;
	int table[4001];

	while(cin>>n,n){
		int printed=0;
		for(int i=0;i<n;i++){
			int b,t,k;
			cin>>b>>t>>k;
			if(table[b]<1000000){
				table[b]+=t*k;
				if(table[b]>=1000000){
					cout<<b<<endl;
					printed=1;
				}
			}
		}
		if(printed==0){
			cout<<"NA"<<endl;
		}
	}

	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{
	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 <iostream>
#include <vector>
using namespace std;

int main() {
	int max,n;
	vector<int> id;
	vector<int> sum;
	vector<int> table;
	
	id.resize(4000);
	sum.resize(4000);
	table.resize(4000);
	
	while(cin>>n,n){
		int i,a,b,f;
		max = 0;
		
		for(int j=0;j<4000;++j){
			id[j] = 0;
			sum[j] = 0;
			table[j] = 0;
		}
		
		for(;n;--n){
			cin>>i>>a>>b;
			
			if(table[i-1]){
				sum[table[i-1]-1] += a*b;
			}else{
				id[max]=i;
				table[i-1] = max+1;
				sum[table[i-1]-1] += a*b;
				++max;
			}
		}
		f=0;
		for(int j=0;j<max;++j){
			if(sum[j]>=1000000){
				cout<<id[j]<<endl;
				f=1;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}

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 100000000
#define MAXN 4096
typedef long long ll;
bool done[MAXN];

int main(void) {
    int n;
    while (1) {
        cin >> n;
        int flag = 0;
        if (n == 0) break;
        map<int, ll> m;
        m.clear();
        for (int i = 0; i < MAXN; i++) done[i] = false;
        for (int i = 0; i < n; i++) {
            int bango, tanka, num;
            cin >> bango >> tanka >> num;
            if (!done[bango]) {
                m[bango] += tanka * num;
                if (m[bango] >= 1000000) {
                    cout << bango << endl;
                    done[bango] = true;
                    flag = 1;
                }
            }
        }
        if (flag == 0) cout << "NA" << endl;
    }
    return 0;
}

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

int n,num,flag;
long int shine[4000],tannka,kosu;

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>num>>tannka>>kosu;
			shine[num]+=tannka*kosu;
			if(shine[num]>=1000000){
				cout<<num<<endl;
				flag++;
			}
		}
		if(flag==0){cout<<"NA"<<endl;}
		else{flag=0;}
		for(int i=0;i<4000;i++){
			shine[i]=0;
		}
	}
	
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf_s("%d", &data);
		if (data == 0)break;
		vector<pair<int,int>> company;
		pair<int, int> sells;
		bool hero = false;
		int num, sell, cnt;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			bool search = false;
			for (int j = 0; j < company.size(); j++)
			{
				if (company[j].first == num){
					search = true;
					company[j].second += sell*cnt;
					break;
				}
			}
			if (search == false)
			{
				sells.first = num;
				sells.second = sell*cnt;
				company.push_back(sells);
			}
		}
		for (int i = 0; i < company.size(); i++)
		{
			if (company[i].second >= target)
			{
				hero = true;
				printf("%d\n", company[i].first);
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

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

int main() {
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		long long number[4001];
		for (int i = 0; i < 4001; i++) {
			number[i] = 0;
		}

		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e] += p*q;
		}

		int x = 0;
		for (int i = 1; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << endl; }
	}
	return 0;
}

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

int main(){

	int N,Q;
	while(1){
	cin>>N;if(N==0)break;
	long long int n[4001][2]={};
	for(int i=0;i<N;i++){
		int x,y,z;
		cin>>x>>y>>z;
		n[x][0]+=y*z;
		if(n[x][1]==0)n[x][1]=i;
	
	}
	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-1][0];n[j-1][0]=t;
				int T=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;
}