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;
int main(){
    int bangou,tanka,kosuu;
    int number; cin >> number;
    do{
        int man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

C++: #include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> m(4001);
    vector<int> order;
    set<int> already;
    REP(i,n){
      int no, p, num;
      cin>>no>>p>>num;
      if (!already.count(no)) {
        order.push_back(no);
        already.insert(no);
      }
      m[no] += p * num;
    }
    int cnt = 0;
    for(int no:order) {
      if (m[no] >= 1000000) {
        ++cnt;
        cout << no << endl;
      }
    }
    if (!cnt)
      cout << "NA" << endl;
  }
  return 0;
}

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

#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  vector<int> data;
  vector<int>::iterator vc_it;
  while(cin>>n,n){
    int tof = 1;
    int num,price,qua;
    map<int,int> staff;
    map<int,int>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] = staff[num]? staff[num]+price*qua : price*qua;
    }
    for(itr = staff.begin(); itr != staff.end(); itr++){
      if(itr->second >= SALES_GOAL){
        data.push_back(itr->first);
        tof = 0;
      }
    }
    if(tof)data.push_back(0);
  }
  for(vc_it = data.begin(); vc_it != data.end(); vc_it++){
    if(*vc_it)cout << *vc_it << endl;
    else cout << "NA" << endl;
  }

}

C++: #include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1 << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

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

using namespace std;

int main()
{
	
	while(1)
	{
		int sum = 0;
		int n;
		cin >> n;
		if(n == 0) break;
		
		queue<int> q;
		bool checked[4000];
		int list[4000];
		for(int i = 0;i < 4000;i++)
		{
			checked[i] = false;
			list[i] = 0;
		}
		for(int i = 0;i < n;i++)
		{
			int no, x, y;
			cin >> no >> x >> y;
			list[no] += x * y;
			if(!checked[no])
			{
				q.push(no);
				checked[no] = true;
			}
		}
		
		while(!q.empty())
		{
			int no = q.front();
			q.pop();
			if(list[no] >= 1000000)
			{
				cout << no << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(void){
	int N;
	int id,p,q;
	while(cin >> N){
		queue<int> que;
		map<int, int> map;
		int check = 0;
		if(!N) break;
		for(int i=0; i<N; ++i){
			cin >> id >> p >> q;
			if(map.find(id) == map.end()){
				map[id] = p*q;
				que.push(id);
			} else {
				map[id] += p*q;
			}
		}
		while(que.size()){
			if(map[que.front()] >= 1000000){
				cout << que.front() << endl;
				check = 1;
			}
			que.pop();
		}
		if(check == 0) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define MAXN 4096
typedef long long ll;
bool done[MAXN];
vector<int> syain;
int main(void) {
    int n;
    while (1) {
        cin >> n;
        int flag = 0;
        if (n == 0) break;
        map<ll, ll> m;
        m.clear();
        syain.clear();
        for (int i = 0; i < MAXN; i++) done[i] = false;
        for (int i = 0; i < n; i++) {
            ll bango, tanka, num;
            cin >> bango >> tanka >> num;
            if (!done[bango]) {
                done[bango] = true;
                syain.push_back(bango);
            }
            m[bango] += (m[bango] >= 1000000) ? 0 : tanka * num;
        }
        for (int i = 0; i < syain.size(); i++) {
            if (m[syain[i]] >= 1000000) {
                cout << syain[i] << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <stdio.h>
int main()
{
  int n,sn,tann,un,to,cou,i;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    cou=0;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&sn,&tann,&un);
      to=tann*un;
      if(to>=1000000){
	printf("%d\n",sn);
	cou++;
      }
    }
    if(cou==0)printf("NA\n");
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

 
int main(){
	int n;
	while(cin>>n,n){
		vector<int> a;
		vector<ll> x;
		for (int i = 0; i < n; i++){
			int d; ll b,c; cin>>d>>b>>c;
			int id = find(a.begin(),a.end(),d) - a.begin();
			if(id == (int)a.size()){
				a.push_back(d);
				x.push_back(0L);
			}
			x[id] += b*c;
		}

		vector<int> ans;
		for (int i = 0; i < (int)a.size(); i++){
			if(x[i] >= 1000000L) ans.push_back(a[i]);
		}
		
		if(ans.size() == 0){ cout << "NA" << endl; continue; }

		for (int i = 0; i < (int)ans.size(); i++)
			cout << ans[i] << endl;
	}
    return 0;
}