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++: using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000llu		// ?£?????????????

int main()
{
	int n = 0;										// ???????????°
	int no = 0;										// ????????????
	unsigned long long price = 0;					// ????£???????
	unsigned long long saleNum = 0;					// ?£??????°???
	bool flg = false;								// ????????????????????¨??????????????????
	map<int, unsigned long long> proceed;			// ?£??????????map
	map<int, unsigned long long>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %llu %llu", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}

C++: #include <stdio.h>
  
int n,num[4000];
long long int tanka,sale_num,sale_sum[4000],sale_all[4001];
short judge[4001];
  
int main(void){
	int i,j,k;
	
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka,&sale_num);
			sale_sum[i]=tanka*sale_num;
		}
		k=0;
		for(j=0;j<4001;j++){
			judge[j]=0;
			sale_all[i]=0;
		}
		for(i=0;i<n;i++){
			sale_all[num[i]] += sale_sum[i];
		}
		for(i=0; i < n; i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		if(k!=1)printf("NA\n");
	}

    return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id,price,num;
	bool f=false;
	int i;
	while(scanf("%d",&n),n){

		for(i=0;i<n;i++){
			scanf("%d %d %d",id,price,num);
			if(price*num>1000000){
				printf("%d\n",id);
				f=true;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

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;
    while(cin >> n && n)
    {   
        exist=false;
        for(int i=1;i<4001;++i) ids[i] = 0;
        for(int i=0;i<n;++i)
        {   
            cin >> id >> price >> amount;
            ids[id] += price * amount;
        }
        for(int i=1;i<4001;++i)
        {   
            if(ids[i] >= 1000000)
            {   
                exist = true;
                cout << i << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}

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

#define TOTAL_SALES_TH (1000000)

struct SALES_INFO {
  int employeeID;
  int totalSales;
};

void updataSalesInfos(std::vector<SALES_INFO>& salesInfos, 
                      int ID,
                      int unitPrice,
                      int amount)
{
  for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
    it != salesInfos.end();
    ++it) {
    if (it->employeeID == ID) {
      it->totalSales += unitPrice * amount;
      return;
    }
  }
  SALES_INFO newInfo;
  newInfo.employeeID = ID;
  newInfo.totalSales = unitPrice * amount;
  salesInfos.push_back(newInfo);
}

int main(void)
{
  while (true) {
    int numOfInput;
    std::cin >> numOfInput;

    if (numOfInput == 0) {
      break;
    }

    int ID, unitPrice, amount;
    char deli;

    std::vector<SALES_INFO> salesInfos;

    for (int i = 0; i < numOfInput; i++) {
      scanf_s("%d %d %d", &ID, &unitPrice, &amount);
      updataSalesInfos(salesInfos, ID, unitPrice, amount);
    }

    std::vector<int> achieveList;

    for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
      it != salesInfos.end();
      ++it) {
      if (it->totalSales >= TOTAL_SALES_TH) {
        achieveList.push_back(it->employeeID);
      }
    }

    if (achieveList.size() == 0) {
      std::cout << "NA" << std::endl;
    }
    else {
      for (std::vector<int>::iterator it = achieveList.begin();
        it != achieveList.end();
        ++it) {
        std::cout << *it << std::endl;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
	for(;;){
		int n;
		cin >> n;
		if(n == 0) break;
		map<string, int> mpa;
		for(int i = 0; i < n; i++){
			string e;
			int p, q;
			cin >> e;
			cin >> p >> q;
			mpa[e] += p * q;
		}
		map<string, int>::iterator itr;
		bool flag = false;
		for(itr = mpa.begin(); itr != mpa.end(); itr++){
			if(itr->second >= 1e6){
				cout << itr->first << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long int lint;
typedef long long int llint;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  
  while (cin >> n, n){
    int p, q;
    llint e[1010] = {0}, res[4010] = {0};
    bool judge = false;
    REP(i, n){
      cin >> e[i] >> p >> q;
      res[e[i]] += p * q;
    }
    sort(e, e + n);
    REP(i, n){
      if (res[e[i]] >= 1000000 && e[i] != e[i + 1]){
        cout << e[i] << endl;
        judge = true;
      }
    }
    if (!judge) 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(4000,0),pre(n,0),data(4000,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< 4000; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        int 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;
    }
}