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>
#define  N    4000
using namespace std;

struct sale{
	int price;
	int num;
};

int main(){

	while(1){
		int n, cost, piece, num, count = 0;
		cin>>n;
		if(n == 0)
			break;

		sale a[N];
		for(int i=0;i<N;i++){
			a[i].price = 0;
			a[i].num = 0;
		}

		for(int i=0;i<n;i++){
			cin>>num>>cost>>piece;
			a[num-1].price += cost;
			a[num-1].num   += piece;
		}

		for(int i=0;i<N;i++){
			if(a[i].price * a[i].num >= 1000000){
				cout<<i+1<<endl;
				count++;
			}
		}

		if(count == 0)
			cout<<"NA"<<endl;
	}

	return 0;
}

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

struct data{
    int id;
    long long int sales;
    data(int a, long long int b) : id(a), sales(b) {}
    bool operator<( const data& o ) const{
        return id < o.id;
    }
};

bool invec(int id, vector<int> v){
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
        if( *it == id ) return true;
    }
    return false;
}

int main(){
    int n;
    while( cin >> n, n ){
        vector< data > ls;
        vector<int> good;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            vector<data>::iterator it = ls.begin();
            for(; it != ls.end(); it++){
                if( it->id == a ){
                    it->sales += b*c;
                    if( it->sales >= 1000000 &&
                        !invec(it->id, good)){
                        good.push_back( it->id );
                    }
                    break;
                }
            }
            if( it == ls.end() ){
                ls.push_back( data(a, b*c) );
                if( b*c >= 1000000 &&
                    !invec(a, good)){
                    good.push_back( a );
                }
            }
        }
        if( !good.size() ){
            cout << "NA" << endl;
        }else{
            for(vector<int>::iterator it = good.begin(); it != good.end(); it++){
                cout << *it << endl;
            }
        }
    }
    return 0;
}

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

typedef long long Int;

int main(){
    map<int,Int> table;
    int n;
    bool flug;

    while(cin >> n, n != 0){
        flug = false;
        table.clear();

        for(int i=1; i<=n; i++){
            int id;
            int tanka;
            int number;
            cin >> id >> tanka >> number;
            table[id] += (tanka*number);
        }

        for(map<int,Int>::iterator itpair = table.begin(); itpair != table.end(); itpair++){
            if(itpair->second >= 1000000){
                cout << itpair->first << endl;
                flug = true;
            }
        }
        if(flug != true){
            cout << "NA" << endl;
        }
    }

    return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[n];
    long long int total[4000];
    for (int i = 0; i < n; i++) {
      number[n] = 0;
      useN[n] = true;
    }
    for (int i = 0; i < 4000; i++) total[i] = 0;
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      number[i] = a;
      for (int j = 0; j < i; j++) {
	if (number[j] == a) {
	  useN[i] = false;
	  break;
	}
      }
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[i] && total[number[i]-1] >= 1000000) {
	cout << number[i]+1 << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	long goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			if(buf[1] * buf[2] >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: /* -- 0100:Sale Result -- */
#include	<iostream>
#include	<map>

using namespace std;

typedef unsigned long long ull;

int main(void) {
	int n, buf_n, buf_c, buf_p;
	bool flag;
	ull buf_t;
	map<int, ull> List;

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

		flag = true;
		List.clear();
		for(int i=0; i<n; i++) {
			cin >> buf_n >> buf_p >> buf_c;
			buf_t = buf_p * buf_c;
			if(List.find(buf_n) == List.end()) {
				List[buf_n] = buf_t;
			} else {
				List[buf_n] += buf_t;
			}
		}
		map<int, ull>::iterator it = List.begin();
		while( it != List.end() ) {
			if(it->second >= 1000000) { flag = false; cout << it->first << endl; }
			it++;
		}
		if(flag) { cout << "NA" << endl; }
	}
	return 0;
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			if(m.find(x) == m.end()) m[x] = p*q;
			else m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n, sum;
	
	while(1)
	{
		sum = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++)
		{
			int no, x, y;
			cin >> no >> x >> y;
			if(x * y >= 1000000)
			{
				cout << no << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void shoki();
	vector<long long> num(4001,0);
	int n,ban,tanka,kazu,i,j;
int main(){
	bool y=false;
	for(j=0;j<50;j++){
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>ban>>tanka>>kazu;
			num[ban]+=tanka*kazu;
		}
		for(int k=0;k<4001;k++){
			if(num[k]==0){
				continue;
			}
			if(num[k]>=1000000){
				y=true;
				cout<<k<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4000;i++){
		num[i]=0;
	}
}

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

int main(){

  long long int n;
  long long int a[10000];
  long long int r,p,k;


  while(cin >> n, n){

    memset(a,0,sizeof(a));
    bool d = false;

    for(int i=0;i<n;i++){
      cin >> k >> r >> p;
      a[k] += r*p;
    }

    for(int i=1;i<=4000;i++){
      if(a[i] >= 1000000){
	cout << i << endl;
	d = true;
      }
    }
  
    if(!d) cout << "NA" << endl;

  }
}