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

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

typedef std::pair<std::string,int> sale;

int main()
{
	
	
	while (true) {
		int n;
		std::vector<sale> sale_vec;
		
		std::cin >> n;
		
		if (n==0) break;
		
		std::string id;
		int unit_price;
		int quantity;
		
		for (int i=0; i<n; i++) {
			std::cin >> id >> unit_price >> quantity;
			bool id_exists = false;
			for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
				if (it->first == id) {
					id_exists = true; it->second += unit_price * quantity; break;
				}
			}
			if (!id_exists) {
				sale_vec.push_back( sale(id, unit_price * quantity) );
			}
		}
		
		bool output = false;
		for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
			if (it->second >= 1000000) {
				std::cout << it->first << std::endl;
				output = true;
			}
		}
		if (!output) std::cout << "NA" << std::endl;
	}
	
	return 0;
}