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++: while (n = gets().to_i()) != 0
  staff = Array.new(4e3, 0);
  flag = false
  n.times() do
    str = gets().split()
    id = str[0].to_i()
    price = str[1].to_i()
    num = str[2].to_i()
    staff[id - 1] += price * num
  end
  staff.each_with_index() do |total, id|
    if total >= 1e6
      puts(id + 1)
      flag = true
    end
  end
  puts("NA") if !flag
end

C++: #include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	int x = 0;
	while (std::cin >> n, n != 0) {
		int z = 0;
		++x;
		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];
		}
		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) {
				std::cout << V[i][0] << std::endl;
				z = 1;
			}
		}
		if (z == 0) {
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

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

int main(){
	int n,a,b;
	bool flag;
	int number;
	map<int,int> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number);
			while(b-- && info[number]<1000000){
				info[number] += a;
			}
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

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

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // 既出だったら表示順記録配列に入れない。単価0円ケースを考慮してません。
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX];
long int shineU[SHINE_MAX];

int dataN,num,tanka,suryo;
int i,j;

int main(){
while(1){
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  long long x,emp[4001],val[4001];
  long long emp1,val1,con,flag;

  while(1){
    cin >> x;
    if(x==0)break;

    for(int i=0;i<4001;i++){
      emp[i]=0;
      val[i]=0;
    }
    for(int i=0;i<x;i++){
      cin >> emp1 >> val1 >> con;

      flag=0;
      for(int j=0;j<x;j++){
	if(emp[j]==emp1){
	  flag=1;
	  val[j]+=val1*con;
	  break;
	}
      }
      if(flag==0){
	for(int j=0;j<4001;j++){
	  if(emp[j]==0){
	    emp[j]=emp1;
	    val[j]=val1*con;
	    break;
	  }  
	}
      }
    }
      flag=0;
    for(int j=0;j<4001;j++){
      if(val[j]>=1000000){
	cout << emp[j] << endl;
	flag=1;
      }
    }
    if(flag==0)cout << "NA" << endl;
  }
  return 0;
}

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

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number;
  long long price, amount;

  while(cin >> n) {
    if (n == 0) break;
    
    map<int, long long> sales;
    map<int, long long>::iterator it;

    for (i = 0; i < n; i++) {
      cin >> number >> price >> amount;
      it = sales.find(number);
      if (it != sales.end())
        it->second += price * amount;
      else
        sales.insert(pair<int, long long>(number, price * amount));
    }

    for (it = sales.begin(), f = false; it != sales.end(); it++) {
      if (it->second >= BORDER) {
        f = true;
        cout << it->first << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}

C++: #include<iostream>

int main(){
	int n,num[4001];
	while(std::cin>>n){
		int count=0;
		memset(num,0,sizeof(num));
		if(n==0)break;
		for(int a,b,c,i=0;i<n;i++){
			std::cin>>a>>b>>c;
			num[a]+=b*c;
		}
		for(int i=0;i<4001;i++){
			if(num[i]>=1000000)count++,std::cout<<i<<std::endl;
		}
		if(count==0)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

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++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

long long int nums[10000];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < 10000; i++){
			nums[i] = 0;
		}
		
		for(int i = 0; i < n; i++){
			long long int e, p, q;
			cin >> e >> p >> q;
			nums[e] += p * q;
		}
		
		bool check = false;
		
		for(int i = 0; i <= 4000; i++){
			if(nums[i] >= 1000000){
				cout << i << endl;
				check = true;
			}
		}
		
		if(!check){
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    std::vector<int> v;
    long int team,price,number;
    for(;n;n--){
      std::cin>>team>>price>>number;
      if(price*number>=1000000)v.push_back(team);
    }
    if(v.empty())std::cout<<"NA"<<std::endl;
    else{
      std::vector<int>::iterator it = v.begin();
      while(it!=v.end()){
        std::cout<<*it<<std::endl;
        it++;
      }
    }
  }
}