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>
#include <map>
#include <list>
#include <cmath>
using namespace std;

struct staff {
	int num;
	int price;
	int quan;
	int total;
};

int main()
{
	int num, i, k, j;
	int sn, sp, sq;
	map<int, staff> staffs;

	while(1)
	{
		cin >> num; if(!num) break;
		staffs.clear();

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[sn].num = sn;
			staffs[sn].price = sp;
			staffs[sn].quan = sq;
			staffs[sn].total += staffs[sn].price * staffs[sn].quan;
		}
		map<int, staff>::iterator staffs_it = staffs.begin();
		int over1000000 = 0;
		while(staffs_it != staffs.end())
		{
			if(staffs[(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[(*staffs_it).first].num << endl;
				over1000000++;
			}
			staffs_it++;
		}
		if(over1000000 == 0) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

long long n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,long long> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			if(sk[bg]==0) jun.push_back(bg);
			sk[bg] += tn * su;
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<string.h>

int main()
{
	int n;
	long long v[4001];
	std::vector<int> vec;
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
		
		memset( v, 0, sizeof( v ) );
		vec.clear();
		
		while( n-- ){
			int num;
			int a, b;
		 	std::cin >> num >> a >> b;
			
			v[num] += (long long)( a * b );
			vec.push_back( num );
		}
		
		for( int i = 1; i <= 4000; i++ ){
			if( v[i] < 1000000 ) v[i] = 0;
			else v[i] = 1;
		}
		
		if( std::count( v + 1, v + 4001, 1 ) == 0 ){
		 	std::cout << "NA" << std::endl;
		}
		else{
			std::set<int> s;
		
			for( std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++ ){
				if( v[*it] && s.find( *it ) == s.end() ){
				 	std::cout << *it << std::endl;
				}
				
				s.insert( *it );
			}
		}
	}

 	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n;
  while(cin >> n, n){
    map<ll, ll> info;
    for(int i = 0; i < n; i++){
      int id, x, y;
      cin >> id >> x >> y;
      info[id] += x*y;
    }
    bool isAns = false;
    for(map<ll,ll>::iterator it = info.begin(); it != info.end(); it++){
      if(it->second >= 1000000){
	isAns = true;
	cout << it->first << endl;
      }
    }
    if(!isAns)cout << "NA" << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
 
using namespace std;
 
int main(void){
 
    int n,flag,number;
    long double money,sum;
    int data[4001]={0},dataF[4001]={0};
    queue<int> ok;
 
    while(1){
 
        for(int i=0;i<4001;i++) data[i]=0,dataF[i]=0;
        flag=0;
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<n;i++){
            cin>>number>>money>>sum;
            data[number]+=money*sum;
            if(dataF[number]==0){
                dataF[number]=1;
                ok.push(number);
            }
        }
            while(!ok.empty()){
                if(data[ok.front()]>=1000000){
                    cout<<ok.front()<<endl;
                    flag=1;
                }
                ok.pop();
            }
            if(flag==0) cout<<"NA"<<endl;
    }
 
    return 0;
}

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

long long member[4000];
bool ached[4000];
vector<int> ach;

int main(void){
  int n;
  while(true){
    cin >> n;
    if(n == 0)  break;
    fill(member, member + 4000, 0);
    fill(ached, ached + 4000, false);
    ach.clear();
    for(int i = 0; i < n; i++){
      int id, tanka, suryo;
      cin >> id >> tanka >> suryo;
      member[id] += tanka * suryo;
      if(member[id] >= 1000000 && ached[id] == false){
        ach.push_back(id);
        ached[id] = true;
      }
    }

    if(ach.empty()){
      cout << "NA" << endl;
    }else{
      for(int i = 0; i < ach.size(); i++){
        cout << ach[i] << endl;
      }
    }
  }
  return 0;
}

C++: //Name: Sale Reult
//Level: 1
//Category: やるだけ
//Note:

#include <iostream>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    bool exist = false;
    for(int i = 0; i < N; ++i) {
        int id, v, c;
        cin >> id >> v >> c;
        if(v*c >= 1000000) {
            cout << id << endl;
            exist = true;
        }
    }
    if(!exist) cout << "NA" << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    while(solve()) ;
    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 << sum << \n;
					num++;
				}
				sum == pairs[i].second;
			}
		}

		if(num == 0){
			cout << "NA\n";
		}
	}
	
    return 0;
}