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<stdio.h>

struct staff_data{
	int num,price,volume,total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	while(scanf("%d",&n)!=EOF){
	
		if(n==0){
			break;
		}
		
		hantei=0;	

		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			
			for(j=0;j<n;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].price=price;
					dt[j].volume=volume;
					
					dt[j].total=(dt[j].price)*(dt[j].volume)+dt[j].total;
					
					break;
				}
				
			}
		}

		
		for(i=0;i<n;i++){
		
			if(dt[i].total>=1000000){
				printf("%4d\n",dt[i].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(n==0)return 0;
        int count=0;
        multimap<int,int> sl;
        for(int i=0;i<n;++i){
            int sn,t,v;
            cin>>sn>>t>>v;
            sl.insert(pair<int,int>(sn,t*v));
        }
        map<int,int>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if((*it).second>=1000000){cout<<(*it).first<<endl;++count;}
            ++it;
        }
        if(count==0)cout<<"NA"<<endl;
    }
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(list.find(id) == list.end() && a * b >= c) {
                list.insert(id);
                cout << id << endl;
            }
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}

C++: #include<cstdio>
#include<cstring>

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		while(n--){
			memset(total,0,sizeof(total));
			scanf("%d%d%d",&a,&b,&c);
			total[a+1]=total[a+1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res++;
			}
		}
		if(res)printf("%d\n",res);
		else printf("NA\n");
	}
}

C++: 
using namespace std;

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

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

int main()
{
	int n = 0;							// ???????????°
	int no = 0;							// ????????????
	int price = 0;						// ????£???????
	int saleNum = 0;					// ?£??????°???
	bool flg = false;					// ????????????????????¨??????????????????
	map<int, int> proceed;				// ?£??????????map
	map<int, int>::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 %d %d", &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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
using namespace std;
int main() {
	int n;
	while (true) {
		map<int,int> dp;
		scanf("%d", &n);
		if (n == 0) break;
		bool neko = false;
		for (int i = 0;i < n;++i) {
			long long a, b, c;
			scanf("%lld%lld%lld", &a, &b, &c);
			if (b*c+dp[a] >= 1000000&&dp[a] < 99999999) {
				printf("%d\n", a);
				neko = true;
				dp[a] = 9999999999;
			}
			else {
				dp[a] += b*c;
			}
		}
		if (neko == false)printf("NA\n");
	}
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
	int n;
	while(scanf("%d",&n))
	{
		if(n == 0) break;
		long long int flag[4001] = {0},shain[4001] = {0},junban[4000] = {0};
		long long int shains,tanka,kosu,j = 0;
		long long int flags = 0;
		for(int i = 0;i < n;i++)
		{
			scanf("%lld%lld%lld",&shains,&tanka,&kosu);
			if(flag[shains] == 0)
			{
				flag[shains] = 1;
				junban[j] = shains;
				shain[shains] = tanka * kosu;
				j++;
			}
			else
			{
				shain[shains] += tanka * kosu;
			}
		}

		for(int i = 0;i < n;i++)
		{
			if(shain[junban[i]] >= 1000000)
			{
				printf("%lld\n",junban[i]);
				flags = 1;
			}
		}
		if(flags == 0) printf("NA\n");
	}
	return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    map<int,long long> emps;
    vector<int> ids;
    int id,cost,amount,n;
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(emps.find(id)!=emps.end()){
                emps[id]+=cost*amount;
            }else{
                emps[id]=cost*amount;
                ids.push_back(id);
            }
        }
        if(ids.empty()) cout << "NA" << endl;
        for(int i=0;i<ids.size();i++){
            if(emps.at(ids[i])>=1000000) cout << ids[i] << endl;
        }
    }
    return 0;
}

C++: #include <stdio.h>

 int main(void)
{
	int data;
	int m,n;
	int number;
	long prise,value;

	long int  money[4000];



	while(1){
		
		for(n=0;n<4000;n++){
			money[n] = 0;
		}

		scanf("%d",&data);
		if(data == 0) break;

		for(n=0;n<data;n++){
			scanf("%d%d%d",&number,&prise,&value);
			money[number] += (float)prise * value;
		}
		
		m = 0;
		for(n=0;n<4000;n++){
			if(money[n] >= 1000000){
				m = 1;
				printf("%d\n",n);
			}
		}

		if(m == 0){
			printf("NA\n");
		}
	}


	

	return 0;
}