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 <string>
#include <vector>

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str," ");
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n,n){
long long ta[5000]={0};int x[5000]={0};
int cnt=0,a,b,c;
	for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	ta[a]+=b*c;
	bool f=1;
	for(int j=0;j<i;j++)if(x[j]==a)f=0;
	if(f)x[cnt++]=a;
	}
	bool f=1;
	for(int i=0;i<n-1;i++){
	//cout<<x[i]<<" "<<ta[x[i]]<<endl;
	if(ta[x[i]]>=1000000){cout<<x[i]<<endl;f=0;}
	}
	if(f)cout<<"NA"<<endl;
}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {break;};
    int  price[4000], value[4000];
    for (int i = 0; i < 4000; i++) {
      price[i] = 0;
      value[i] = 0;
    }
    
    for (int i = 0; i < n; i++) {
      int a,b,c;
      cin >> a >> b >> c;
      price[a-1] += b;
      value[a-1] += c;
    }
    
    int NA;
    for (int i = 0; i < 4000; i++) {
      if ( price[i] * value[i] >= 1000000) {
	cout << i+1 << endl;
	NA = 1;
      }
    }
    if (NA != 1) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	bool a[4001], f;
	long long int s, t, u;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(a, a+4001, false);
		f = true;
		for(int i = 0; i < n; i++){
			cin >> s >> t >> u;
			if(a[s]){
				continue;
			}
			a[s] = true;
			
			if(t*u >= 1000000){
				cout << s << endl;
				f = false;
			}
		}
		if(f){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4005,M=1000000;
map<int,int> m;
signed main(void){
	int n,flag;
	ios::sync_with_stdio(false);
	while(cin>>n&&n){
		m.clear();
		flag=1;
		for(int i=1,x,y,z;i<=n;i++){
			cin>>x>>y>>z;
			m[x]+=y*z;
		}
		for(map<int,int>::iterator it=m.begin();it!=m.end();++it)
			if(it->second>=M)
				cout<<it->first<<endl,flag=0;
		if(flag)
			cout<<"NA"<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(void)
{
    int n,A,sult[4001],sell[4001],suu[4001];
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>sult[i]>>sell[i]>>suu[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j&&sult[i]==sult[j]){
                    sell[j]=sell[i]*suu[i]+sell[j]*suu[j];
                    suu[j]=1;
                    sell[i]=0;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(sell[i]*suu[i]>=1000000){
                    cout<<sult[i]<<"\n";
                    A=1;
            }
        }
        if(A==0)cout<<"NA\n";
        A=0;
    }
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> m;
        vector<int> v;
        for(int i=0; i < n; i++){
            long long  p, q, r;
            cin >> p >> q >> r;

            if(m[p] == 0) v.pb(p);
            m[p] += q*r;
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= m[v[i]]){
                isExist = true;
                cout << v[i] << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

C++: #include <iostream>
#include <map>
#include <vector>
#define M map<int,long long>
using namespace std;
int main()
{
  int n, i, id, a, b;
  while(cin >> n,n){
    M m;
    vector<int> v;
    vector<int>::iterator p;
    for(i=0;i<n;i++){
      cin >> id >> a >> b;
      m[id] += a * b;
      for(p = v.begin(); p != v.end(); p++){
	if(*p == id) break;
      }
      if(p == v.end()) v.push_back(id);
    }
    bool f = false;
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
      if(m[(*it)] >= 1000000){
	cout << *it << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;

int n,num,cost,mon;

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		bool tmp=false;
		for(int i=0;i<n;i++){
			cin>>num>>cost>>mon;
			if((long long int)cost*mon>=1000000){
				cout<<num<<endl;
				tmp=true;
			}
		}
		if(!tmp) cout<<"NA"<<endl;
	}
}

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

int main() {
    int N;
    while (cin >> N) {
        if (N == 0) { break; }
        cin.get();
        string result, i;
        map<string, long long> sales;
 	long long p, q;
        for (int n = 0; n != N; ++n) {
            cin >> i >> p >> q;
            sales[i] += p * q;
        }

        for (map<string, long long>::iterator it=sales.begin(); it!=sales.end(); ++it) {
            if (it->second >= 1000000) {
                result += it->first + '\n';
            }
        }

        if (result.size() != 0) {
            cout << result;
        }
        else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int flg=0;
	int bangou[4001]={0};
	int tanka[4001]={0};
	int kosuu[4001]={0};
	int goukei[4001]={0};
	int ccc=0;
	int i=0,j=0;
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		else
		{
			for (i=1;i<=n;i++)
			{
				ccc++;
				scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&kosuu[ccc]);
				goukei[ccc]=tanka[ccc]*kosuu[ccc];
				for (j=1;j<ccc;j++)
				{
					if (bangou[j]==bangou[ccc])
					{
						goukei[j]+=goukei[ccc];
						ccc--;
					}
				}
			}
			for (i=1;i<=ccc;i++)
			{
				if (goukei[i]>=1000000)
				{
					printf("%d\n",bangou[i]);
					flg=1;
				}
			}
			if (flg==0)
			{
				printf("NA\n");
			}
		}
	}
	return 0;
}