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>
using namespace std;

struct tEmploy{
	int num;
	int sold;
	tEmploy(){
		num = -1;
		sold = 0;
	}
};

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

		emp = new tEmploy[n];
		for( int i=0; i<n; i++ ){
			int num, val, amo;
			cin >> num >> val >> amo;
			int j=0;
			for( ; j<n; j++ ){
				if( emp[j].num == num )	break;
			}
			if( j == n ){
				for( j=0; j<n; j++ ){
					if( emp[j].num == -1 ){
						emp[j].num = num;
						break;
					}
				}
			}
			emp[j].sold += val * amo;
		}

		bool exist = false;
		for( int i=0; (emp[i].num!=-1)&&(i<n); i++ ){
			if( emp[i].sold >= 1000000 ){
				cout << emp[i].num << endl;
				exist = true;
			}
		}
		if( !exist ){
			cout << "NA" << endl;
		}

		delete[] emp;
		emp = 0;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int ans[100000];
int main(void)
{
    int n; cin >> n;
    int count = 0;
    do {
        int e[n], p[n], q[n];
        ll tmp[4010] = {};
        int flag = 0;
        rep(i, n) cin >> e[i] >> p[i] >> q[i];
        for (int i = 0; i < n; i++) {
            tmp[e[i]] += p[i] * q[i];
        }
        for (int i = 0; i < 4010; i++) {
            if (tmp[i] >= 1000000) {
                ans[count++] = i;
                flag = 1;
            }
        }
        if (flag == 0) ans[count++] = -1;
        cin >> n;
    } while(n != 0);
    for (int i = 0; i < count; i++) {
        if( ans[i] != -1) {
            cout << ans[i] << endl; 
        } else {
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: #include <stdio.h>


int n;
int num[4000];
int tanka[4000],sale_num[4000];
int sale_all[4001],judge[4000];

int main(void)
{
int i,j,k;
	
while((scanf("%d",&n),n!=0)){
	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&tanka[i],&sale_num[i]);
		sale_all[num[i]]=0;
	}
	k=0;
	for(j=0;j<4001;j++)	judge[j]=0;
	for(i=0;i<n;i++){
		sale_all[num[i]] += tanka[i]*sale_num[i];
	}
	for(i =0; i < n; i++){
		if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
			printf("%d\n",num[i]);
			judge[num[i]]=1;
			k=1;
		}
	}
	if(k!=1)printf("NA\n");


}

	return 0;
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memcpy(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[i].Saled >= 1000000)
		{
			cout << sl[i].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
end_scope:
    return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


int n;
int id[5000];

int main(){
	while(cin>>n,n!=0){
		vector<int> a;
		rep(i,n){
			int t1,t2,t3;
			a.push_back(t1);
			cin>>t1>>t2>>t3;
			id[t1]+=t2*t3;
		}
		bool f=true;
		rep(i,a.size()){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
}

C++: #include<iostream>
#include<vector>
int main() {
	std::vector<int> a;
	while (true) {
		int n;
		int c = 0;
		std::cin >> n;
		if (n == 0) {
			break;
		}
		std::vector<int> v(n), w(n);
		int t, u;
		for (int i = 0; i < n; ++i) {
			std::cin >> w[i] >> t >> u;
			v[i] = t*u;
		}
		for (int i = 0; i < n; ++i) {
			for (int l = 0; l < n; ++l) {
				if ((v[i] == v[l]) && (i != l)) {
					v[i] += v[l];
					v.erase(v.begin() + l);
					n -= 1;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			if (v[i] >= 1000000) {
				a.push_back(w[i]);
				++c;
			}
			if ((c==0)&&(i==n-1)) {
				a.push_back(0);
			}
		}
		v.clear();
		w.clear();
	}
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] == 0)std::cout << "NA" << std::endl;
		else std::cout << a[i] << std::endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	bool tf = 0;
	int n,e,p,q;
	while(cin >> n){
		if(n == 0){
			return 0;
		}
		int r[4001]={0};
		tf = 0;
		for(int i = 0; i < n; i++){
			cin >> e >> p >> q;
			r[e] += p * q;
			//r[e] = r[e] + p*q;
		}
		for(int i = 1; i <= 4000; i++){
			if(r[i] >= 1000000){
				cout << i << endl;
				tf = 1;
			}
		}
		if(tf != 1){
				cout << "NA" << endl;
			}
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long value[4001];
	vector<int> v;

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));
		v.clear();

		rep(i,n)
		{
			cin >> num >> k >> m;
			value[num] += k*m;

			vector<int>::iterator ite = find(v.begin(),v.end(),num);
			if(ite == v.end())
			{
				v.push_back(num);
			}
		}

		bool flag = true;
		rep(i,v.size())
		{
			if(value[v[i]] >= 1000000)
			{
				flag = false;
				cout << v[i] << endl;
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
  int n;

  while(cin >> n, n) {
    vector<int> ans;
    int e, p, m;

    for(int i = 0; i < n; i++) {
      cin >> e >> p >> m;
      if(p*m >= 1000000) {
	bool b = true;
	auto it = ans.begin(); 
	while(it != ans.end()) {
	  if(*it == e) b = false;;
	  it++;
	}
	if(b) ans.push_back(e);
      }
    }
    

    if(ans.empty()) {
      cout << "NA" << endl;
    } else {
      auto it = ans.begin();
      while(it != ans.end()) {
	cout << *it << endl;
	it++;
      }
    }
  }
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n,x,y,z;
	int a = 0;
	int g[4000];

	while(true){
	    int b=0;
		cin >> n;

		if(n==0){
			break;
		}
		for(int i=0 ;i<n ;i++){

	       cin >> x >> y >> z;

		   a = y*z;
		   if(a>=1000000){
			
			 g[i] = x;
			 b++;  
		     }
		}
	
		
	if(b>0){
	     	for(int i=0 ;i<n ;i++){
			cout << g[i] << endl;			
		}	
	}	
	else	
		cout << "NA" << endl;
	}

	return 0;
}