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 <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, i, buf[3], *idlist, index_idlist = 0, milcount = 0;
	unsigned long long int *sale;

	scanf("%d", &n);

	sale = (unsigned long long int *)calloc(4000, sizeof(unsigned long long int));
	idlist = (int *)calloc(n, sizeof(int));

	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &buf[0], &buf[1], &buf[2]);
			sale[buf[0] - 1] += buf[1] * buf[2];
			idlist[index_idlist++] = buf[0];
		}

		for (i = 0; i < n; i++){
			if (sale[idlist[index_idlist]] >= 1000000){
				printf("%d\n", idlist[index_idlist]);
				sale[idlist[index_idlist--]] = 0;
			}
			milcount++;
		}

		if (milcount == 0){
			puts("NA");
		}
		milcount = 0;
		scanf("%d", &n);
	}
	return 0;
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]<=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }
    if(count==0) cout<<"NA\n";
}

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

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		typedef std::pair<long, long> elemType;
		typedef std::vector<elemType> dataType;
		dataType data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			bool found = false;
			for (unsigned int i = 0; i < data.size(); ++i) {
				if (data[i].first == id) {
					data[i].second += g;
					found = true;
				}
			}
			if (!found) data.push_back(elemType(id, g));
		}
		bool bHitted = false;
		for (dataType::iterator it = data.begin(); it != data.end(); ++it) {
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}

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

int main()
{
  int N;
  for (;;) {
    cin >> N;
    if (N == 0) {
      break;
    }
    int n[4000];
    for (int i = 0; i < 4000; i++) n[i] = 0;
    for (int i = 0; i < N; i++) {
      int ID, p, q;
      cin >> ID >> p >> q;
      n[ID] += p*q;
    }

    int j = 1;
    for (int i = 0; i < 4000; i++) {
      if (n[i] >= 1000000) {
        cout << i << endl;
        j = 0;
      }
    }
    if (j) {
      cout << "NA" << endl;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,num,mon,cont,a[4001],nacount;
  while(scanf("%d",&n)!=EOF){
    if(n==0){break;}
    for(int i=0;i<4001;i++){
      a[i]=0;
    }
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>num>>mon>>cont;
      a[num]+=mon*cont;
    }
    for(int i=1;i<4001;i++){
      if(a[i]>=1000000){
	cout<<i<<endl;
	nacount++;
      }
    }if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()


int main(void){
	int n;	
	while(cin>>n,n){
		vvi num(n,vi(3,0));
		rep(i,n){
			//cout<<num[i][0]<<" "<<num[i][1]<<endl;
			cin>>num[i][0];
			int item,code;
			rep(j,i){
				if(num[i][0]==num[j][0]){
					num[j][1]+=item*code;
					num[i][2]=1;
				}
			}
			cin>>item>>code;
			if(!num[i][2])num[i][1]+=item*code;
			//cout<<num[i][0]<<" "<<num[i][1]<<endl;
		}
		//cout<<"star"<<endl;
		int cnt=0;
		rep(i,n){
			if(num[i][1]>=1000000){cout<<num[i][0]<<endl;cnt++;}
		}
		if(!cnt)cout<<"NA"<<endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{   
    int n;
    long long int ids[4001];
    int id, price, amount;
    bool exist;
    bool used[4001];
    vector<int> rank;
    while(cin >> n && n)
    {   
        exist=false;
        for(int i=1;i<4001;++i)
        {   
            ids[i] = 0;
            used[i] = false;
        }
        rank.clear();
        for(int i=0;i<n;++i)
        {   
            cin >> id >> price >> amount;
            if(!used[id])
            {   
                rank.push_back(id);
                used[id] = true;
            }
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {   
            if(ids[rank[i]] >= 1000000)
            {   
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
	int n;
	while(scanf("%d\n", &n), n){
		vector<pair<int, long long>> v;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			bool f = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == x) {
					v[j].second += (long long) y * z;
					f = true;
					break;
				}
			}
			if(!f) {
				v.push_back(make_pair(x, (long long)(y * z)));
			}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int>  number;
	int d,num,item,ko;
	while(cin>>d){
		if(d==0) break;
		for(int i=0;i<d;i++){
			cin>>num>>item>>ko;
			item *= ko;
			//cout<<item<<endl;
			if(item>=1000000){
				number.push_back(num);
			}
		}
		if(number.size()==0) cout<<"NA"<<endl;
		else{
				for(int j=0;j<number.size();j++){
				cout<<number[j]<<endl;
			}
			number.clear();
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b,c,bc;
	int i;
	int flg;
	flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		bc=b*c;
		if(bc<1000000){
			printf("%d\n",a);
			flg=1;
		}
	}
	if(flg==0){
		printf("NA");
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        int count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;
            int officer_num_old;

            officer_num_old = officer_num;
            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            if (price * figure >= 100000 && officer_num != officer_num_old) {
                std::cout << officer_num << std::endl;
                count += 1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}