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>

using namespace std;

int main(){
	int n;
	
	while(1){
		int e, p, q;
		int x[4001] = {0};
		int m[4001] = {0};
		
		cin >> n;
		if(n == 0) break;
		
		bool flag = true;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			m[i] = e;
			x[e] += p * q;
			}
		
		for(int i = 1; i <= n; i++){
			if(x[m[i]] >= 1000000){
				cout << m[i] << endl;
				x[m[i]] = 0;
				flag = false;
			}
		}
		if(flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main(){
	long long int total[4000];
int n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(total,0,sizeof(total));
		while(n--){
			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=1;
				printf("%d\n",i+1);
			}
		}
		if(res) continue;
		else printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		map<int,int> name;
		int list[4001]={0};
		int a,b,c,j=0;
		for(int i=0;i<n ;i++){
			cin >> a >> b >> c;
			name[j]=a,j++;
			list[a]+=b*c;
		}
		bool check=true;
		for(int i=0;i<4000;i++)
			if(list[name[i]]>=1000000)
				cout << (name[i]) << endl,check=false,list[name[i]]=0;
		if(check)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int ct,num[4001],tanka[4001],kosu[4001],many[4001];
	while(scanf("%d",&ct)){
		if(ct==0){
			return 0;
		}
		for(int f1=0;f1<ct;f1++){
			scanf("%d %d %d",&num[f1],&tanka[f1],&kosu[f1]);
			many[f1]=tanka[f1]*kosu[f1];
		}
		for(int f1=0;f1<ct;f1++){
			for(int f2=0;f2<ct;f2++){
				if((num[f1]==num[f2])&&f1!=f2){
					many[f1]=many[f1]+many[f2];
					num[f2]=-1;
				}
			}
		}
		int flg=0;
		for(int f1=0;f1<ct;f1++){
			if(many[f1]>=1000000){
				printf("%d\n",num[f1]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

void outString(void *);

int main(void){
	int i = 65;
	double d = 10.101;
	outString(&i);
	outString(&d);


	return 0;
}


void outString(void *text){

	string *str =(string *)text;
	cout <<"str = "<<*str<<endl;
}

C++: #include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int n;
int main(){
	while((cin >> n) != 0){
		int num = 0;
		vector<pair<int, int> > pairs(n);

		for(int i = 0; i < n; i++){
			int p, q;
			cin >> pairs[i].first >> p >> q;
			pairs[i].second = p * q;
		}

		sort(pairs.begin(), pairs.end());

		int sum = 0;
		sum = pairs[0].second;
		for(int i = 1; i < n; i++){
			if(pairs[i].first == pairs[i-1].first){
				sum += pairs[i].second;
			}else{
				if(sum >= 1000000){
					cout << pairs[i].first << "\n";
					num++;
				}
				sum = pairs[i].second;
			}
		}

		if(num == 0){
			cout << "NA\n";
		}
	}
	
    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){
	bool flag = true;

	FOR(i, 0, bangouList.size()){
		if (data[bangouList[i]] >= 1000000){
			cout << bangouList[i] << endl;
			flag = false;
		}
	}
	if (flag)
		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;
			long long int bangou = 0, tanka = 0, suu = 0;
			cin >> bangou >> tanka >> suu;
			if(data[bangou] == 0)
				bangouList.push_back(bangou);
			// tankaとsuuがintだと、両方の値が大きいときにオーバーフローする
			data[bangou] += (tanka * suu);
		}
		solveAndOutput(data, bangouList);
	}
	return 0;
}

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

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num=0;
std::string str="";
std::vector<std::string> ref;
std::vector<std::string> res;

std::cin >> str;
if(str!="") it_num=std::stoi(str);

while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str,' ');
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
if(res.size()==0){
std::cout << "NA" << std::endl;
}else{
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}
}
}
res.clear();
std::cin >> it_num;
}

return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int n;
	while (cin >> n && n) {
		vector<int> v;
		map<int, int> m;
		int no, price, amount;
		int na = 1;
		for (int i = 0; i < n; i++) {
			cin >> no >> price >> amount;
			if (m.find(no) != m.end())
				m[no] += price * amount;
			else {
				m[no] = price * amount;
				v.push_back(no);
			}
		}
		vector<int>::iterator it = v.begin();
		while (it != v.end()) {
			if (m[*it] >= 1000000) {
				cout << *it << endl;
				na = 0;
			}
			it++;
		}
		if (na)
			cout << "NA" << endl;
	}
	return 0;
}

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

typedef long long int lli;

map<int,lli> mp;

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