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>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
 
typedef complex<double> P;

typedef long long int li;

int main(){
	int n;

	while(cin >> n, n){
		vector<li> sales(4001);
		queue<int> in;
		int num;
		li tanka, kazu;
		for(int i = 0; i < n; i++){
			cin >> num >> tanka >> kazu;
			if(!sales[num]){
				in.push(num);
			}
			sales[num] += tanka*kazu;
		}

		bool NA = true;
		while(in.size()){
			if(sales[in.front()] >= 1000000){
				cout << in.front() << endl;
				NA = false;
			}
			in.pop();
		}
		if(NA){
			cout << "NA" << endl;
		}
	}

    return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;
#define ahaha push_back
#define hohoho make_pair 
int main(){
  int n,num,flag=0,flag2=0;
  long long tanka,sell;
  while(cin>>n,n!=0){
    vector<int> nu;
    vector<int> vi;
    vector<pair<int,int> > pii;
    for(int i=0;i<n;i++){
      cin>>num>>tanka>>sell;
      
      for(int j=0;j<vi.size();j++){
	if(num==vi[j]){
	  flag2=1;
	  break;
	}
      }
      if(flag2==0){
	for(int j=0;j<pii.size();j++){
	if(pii[j].first==num){
	  flag=1;
	  pii.ahaha(hohoho(num,((tanka*sell)+pii[j].second)));
	  if(((tanka*sell)+pii[i].second)>=1000000)
	    vi.ahaha(num);
	  break;
	}
      }
      if(flag==0){
	nu.ahaha(num);
	pii.ahaha(hohoho(num,tanka*sell));
	if(tanka*sell>=1000000)
	  vi.ahaha(num);
      }
    }
    }
    if(vi.empty())
      cout<<"NA"<<endl;
    else{
    for(int k=0;k<nu.size();k++){
      for(int l=0;l<vi.size();l++){
	if(nu[k]==vi[l])
	  cout<<nu[k]<<endl;
      }
    }
    }
  }
  return 0;
}

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

static const int invalid_order = 1000000;
struct data {
	int ID;
	long long total;
	int order;

	data() {
		ID = -1;
		total = 0;
		order = invalid_order;
	}

	bool operator<(const data d) const {
		return order < d.order;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		data table[4096];
		bool flag = false;
		int order_count = 0;

		for(int i = 0; i < 4096; i++) {
			table[i].ID = i;
		}

		for(int i = 0; i < n; i++) {
			char in[128];
			char ID_s[32], price_s[32], sale_s[32];
			int j, k;

			// input
			/*
			fgets(in, 120, stdin);
			for(j = 0,k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				ID_s[k] = in[j + k];
			ID_s[k] = '\0';
			j = k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				price_s[k] = in[j + k];
			price_s[k] = '\0';
			j += k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';' && in[j + k] && in[j + k] != '\n'; k++)
				sale_s[k] = in[j + k];
			sale_s[k] = '\0';

			ID = atoi(ID_s);
			price = atoi(price_s);
			sale = atoi(sale_s);
			// */ cin >> ID >> price >> sale;
			
			if(table[ID].order == invalid_order) {
				table[ID].order = order_count;
				order_count++;
			}
			table[ID].total += price * sale;
		}

		sort(table, table + 4096);

		for(int i = 0; i < order_count; i++) {
			if(table[i].order == invalid_order)
				exit(1);
			if(table[i].total >= 1000000) {
				cout << table[i].ID << endl;
				flag = true;
			}
		}

		if(!flag)
			cout << "NA" << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    map<int,long long> m;
    bool isNA = false;

    while( n-- ){

      int id,price,num;
      cin >> id >> price >> num;

      if( m[id] < 1000000 && 1000000 <= m[id] + (long long)price*num ){
	cout << id << endl;
	isNA = true;
      }
      m[id] += (long long)price*num;
    }

    if(!isNA) cout << "NA" << endl;
  }
  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;


ll n;
map <ll,ll> id;

int main(){
	while(cin>>n,n!=0){
		vector<ll> a;
		rep(i,n){
			ll t1,t2,t3;
			a.push_back(t1);
			cin>>t1>>t2>>t3;
			if(id[t1]>0){
				id[t1]+=t2*t3;
			}
			else{
				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 <string.h>
#include <queue>

using namespace std;

int N, M;

int main() {
	long long  goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long  v[4000];
		queue<int> que;
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long  e, p, q;
			cin >> e >> p >> q;
			que.push(e-1);
			v[e - 1] += p*q;
		}
		bool flag = false;
		while(!que.empty()){
			if (v[que.front()] >= goal) {
				flag = true;
				v[que.front()] = 0;
				cout << que.front() + 1 << endl;
			}
			que.pop();
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

C++: #include<stdio.h>
long long int t[4000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int b,c,d;
			scanf("%d%d%d",&b,&c,&d);
			t[b-1]+=(long long)c*d;
		}
		bool ok=false;
		for(int i=0;i<4000;i++){
			if(t[i]>=1000000){
				printf("%d\n",i+1);
				ok=true;
			}
			t[i]=0;
		}
		if(!ok)printf("NA\n");
	}
}

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

        int* officer_num_old = new int[dataset_num];


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

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

            for (int j = 0;j < i; j++) {
                if (officer_num_old[j] == officer_num) {
                    flag = 1;
                }
            }


            if (price * figure >= 1000000 && flag == 0) {
                std::cout << officer_num << std::endl;
                count += 1;
            }

            officer_num_old[i] = officer_num;

        }


        if (count == 0) {
            std::cout << "NA" << std::endl;

        }

    }

    return 0;
}