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;
class MAN{
public:
	long long uriage;
	short number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			int a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			num[a]=0;
			tan[a]=0;
		}
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> b >> c >> d;
			num[b]+=c,tan[b]+=d;
		}
		for(a=1;a<4000;a++){
			if(num[a]*tan[a]>=1000000)printf("%d\n",a),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<stdio.h>
struct su{
	int num;
	int sum;
}p[1001];
using namespace std;
int main()
{
	int n,i2;
	int sn,x, y,l=0;
	while (1){
		l = 0;
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			for (i2 = 0; i2 < l; i2++){
				if (p[i2].num == sn){
					p[i2].sum += x*y;
					break;
				}
			}
			if (i2 == l){
				p[l].sum = 0;
				p[l].num = sn;
				p[l].sum += x*y;
				l++;
			}
		}
		int maxn = 0;
		int maxc = 0;
		for (int i = 0; i < l; i++){
			if (maxn < p[i].sum){
				swap(maxn, p[i].sum);
				maxc = p[i].num;
			}
		}
		if (maxn >= 1000000){
			cout << maxc << endl;
		}
		else
			cout << "NA" << endl;
	}
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4001,0),pre(n,0),data(4001,0);
        for (int i=0; i<n; i++) {
            int a,b,c;
            cin >>a >>b >>c;
            data[a]+=b*c;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0; k< 4001; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        ll ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

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

int main()
{
	int n;
	int No;
	long long int value, num;
	long long int mas;

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

		int x = 0;
		for(int i=0; i<n; i++){
			cin >> No >> value >> num;
			mas = value*num;
			if(mas >= 1000000){
				a[x] = No;
				x++;
			}
		}

		if(x == 0)
			cout << "NA" << '\n';
		else
			for(int i=0; i<x; i++)
				cout << a[i] << '\n';
	}
	return 0;
}

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

int main(){
    int n, id, p, q;
    std::map<int, int> workers;
    std::map<int, int>::iterator it;
    
    while(std::cin >> n){
        if(!n)
            break;
            
        for(int i=0; i<n; i++){
            std::cin >> id >> p >> q;
            workers[id] += p * q;
        }
        
        bool found = false;
        for(it = workers.begin(); it != workers.end(); it++){
            if(it->second >= 1000000){
                if(found)
                    std::cout << ' ' << it->first;
                else{
                    std::cout << it->first;
                    found = true;
                }
            }
        }
        
        if(found)           
            std::cout << std::endl;
        else
            std::cout << "NA" << std::endl;
        workers.clear();
    }
    
    return 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++){
            int 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 <cstdio>
#include <algorithm>

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

using namespace std;

typedef long long ll;

int n;
int s[4000];
int sn;
int index[4001];
int id[4000];

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		fill(index, index + 4001, -1);

		rep(i, n){
			int a, x, y;
			scanf("%d%d%d", &a, &x, &y);

			if(index[a] == -1){
				index[a] = sn;
				id[sn] = a;
				s[sn++] = 0;
			}
			s[index[a]] = min(ll(1e6), s[index[a]] + ll(x) * y);
		}

		bool none = true;
		rep(i, sn){
			if(s[i] >= int(1e6)){
				printf("%d\n", id[i]);
				none = false;
			}
		}
		if(none){
			puts("NA");
		}

		sn = 0;
	}
	return 0;
}