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

class meb{
public:
	int num;
	int tanka;
	int count;
	int sum;
};

int main(){
	int n,m,t,c;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
			cout<<st[k].sum<<endl;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int b=0;b<n;b++){
			cout<<st[b].num<<" "<<st[b].sum<<endl;
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include <vector>
using namespace std;

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
//        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
//            if(it->second>=1000000){
//                s=1;
//                cout<<it->first<<endl;
//            }
//        }
        for (int i=0;i<vec.size();i++){
            if(m[vec[i]]>=1000000){
                s=1;
                cout<<vec[i]<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	std::cin >> n;
	std::vector<int> A;
	while (n != 0) {
		std::vector<int> m(n);
		std::vector<std::vector<int>> V(n, std::vector<int>(3));
		for (int i = 0;i < n;++i) {
			for (int j = 0;j < 3;++j) {
				std::cin >> V[i][j];
			}
		}
		for (int i = 0;i < n;++i) {
			m[i] = V[i][1] * V[i][2];
		}
		sort(V.begin(), V.end());
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;++j) {
				if (i < j) {
					if (V[i][0] == V[j][0]) {
						m[i] += m[j];
						m[j] = 0;
					}
				}
			}
		}
		for (int i = 0;i < n;++i) {
			if (m[i] >= 1000000) {
				A.push_back(V[i][0]);
			}
		}
		std::cin >> n;
	}
	return 0;
}

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

#define BUF 4000

typedef struct syaing
{
	int bango[BUF];
	int ne[BUF];
	int kazu[BUF];
} deta;

int main()
{
	deta f;
	int a,i,check[BUF],lek,kof[100000],nl=0;
	while(1)
	{
		memset(check,0,sizeof(int)*BUF);
		memset(f.bango,0,sizeof(int)*BUF);
		memset(f.kazu,0,sizeof(int)*BUF);
		memset(f.ne,0,sizeof(int)*BUF);
		lek=0;
		scanf("%d",&a);
		if(a==0)
			break;
		for(i=0;i<a;i++)
		{
			scanf("%d%d%d",&f.bango[i],&f.kazu[i],&f.ne[i]);
			if(f.kazu[i]*f.ne[i]>=1000000)
				check[i]=f.bango[i];
		}
		for(i=0;i<a;i++)
		{
			if(check[i]!=0)
			{
				lek++;
				kof[nl]=check[i];
				nl++;
			}
		}
		if(lek==0)
		{
			kof[nl]=0;
			nl++;
		}
	}
	for(i=0;i<nl;i++)
	{
		if(kof[i]==0)
			printf("NA\n");
		else
			printf("%d\n",kof[i]);
	}
	return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>	// istringstream
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(); it!=c.end(); ++it)

// #defineの初利用にあたって参考にした http://peroon.hatenablog.com/entry/20091123/1258966199
// iteratorのforLoop                   http://bokko.hatenablog.com/entry/20090320/1237494217
// fastIO                              https://gist.github.com/rigibun/7905920

void solveAndOutput(map<int, long long> data, VI bangouList){
	int outputCount = 0;

	FOR(i, 0, bangouList.size()){
		if (data[bangouList[i]] >= 1000000){
			cout << bangouList[i] << endl;
			outputCount++;
		}
	}
	if (outputCount == 0)
		cout << "NA" << endl;
}

int main(){
	// sankou http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=97994#1

	long long n;
	// 重複なし、自動ソート
	map<int, long long> data;
	// 重複あり、ソートなし -> 重複するものは格納しないようにしたい.
	VI bangouList;
	//fastIO;

	while (cin >> n, n){
		data.clear();
		bangouList.clear();
		while (n--){
			int bangou = 0, tanka = 0, suu = 0;
			cin >> bangou >> tanka >> suu;
			if(!data[bangou])
				bangouList.push_back(bangou);
			data[bangou] += tanka * suu;
		}
		solveAndOutput(data, bangouList);
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> info;
        map<int, long long>::iterator it;
        rep(i,n){
            int a, b, c;
            cin >> a >> b >> c;
            info[a] += b * c;
        }
        bool c = true;
        for(it = info.begin(); it != info.end(); it++){
            if(it->second >= 1000000){
                cout << it->first << endl;
                c = false;
            }
        }
        if(c) cout << "NA" << endl;
    }
}

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

int main() {
	int i, n, no[4000], tanka[4000], num[4000];
	bool flg=false;
	while (1) {
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>=1000000)
				flg=true, cout<<no[i]<<endl;
		}
		if (flg==false) cout<<"NA"<<endl;
	}
	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 >= 1000000 && officer_num != officer_num_old) {
                std::cout << officer_num << std::endl;
                count += 1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}