Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

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;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,h,h2;
  while(cin>>n){
    if(n==0) break;
    h = 0;
    int b[n],p[n],q[n],ansb[n],ans[n];
    for(int i=0;i<n;i++){
      cin >> b[i] >> p[i] >> q[i];
      h2 = 0;
      for(int j=0;j<i;j++){
	if(ansb[j]==b[i]){
	  ans[j] += p[i] * q[i]; 
	  ans[i] = 0;  
	  ansb[i] = 0;
	  h2 = 1;
	  break;
	}
      }
      if(h2==0){
	ans[i] = p[i] * q[i];
	ansb[i] = b[i];
      }
    } 
    for(int i=0;i<n;i++){
      if(ans[i]>=1000000){
	cout << ansb[i] << endl;
	if(h==0) h = 1;
      }
    }
    if(h==0) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  while(cin >> n, n){
    int id, x, y;
    ll sum[5000];
    memset(sum, 0, sizeof(sum));
    vector<int> in;
    for(int i = 0; i < n ; i++){
      cin >> id >> x >> y;
      sum[id] += x*y;
      if(find(in.begin(), in.end(),id)==in.end()){
	in.push_back(id);
      }
    }
    bool f = false;
    for(int i = 0; i < in.size(); i++){
      if(sum[in[i]] >= 1000000){
	f = true;
	cout << in[i] << endl;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}