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

int main(){
  int n,i,p,q,f;
  for(;scanf("%d",&n),n;){
    map<int,int>m;
    for(;n--;)
      scanf("%d%d%d",&i,&p,&q),m[i]+=p*q;
    map<int,int>::iterator it=m.begin();
    for(f=0;it!=m.end();it++){
      if((*it).second>=1000000)printf("%d\n",(*it).first),f=1;
    }
    if(!f)puts("NA");
  }
}

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

typedef long long int ll;

ll solve(ll N);

int main(void) {

	ll N = 1;
	while(true) {
		cin >> N;
		if( N == 0 ) { break; }
		solve(N);
	}

	return 0;
}

ll solve( ll N ) {

	map<int, ll> m;
	set<int> s;

	for( int i = 0; i < N; i++ ) {
		int id;
		ll ps, q;
		cin >> id >> ps >> q;
		if( m.find(id) == m.end() ) {
			m[id] = ps*q;
		} else {
			m[id] += ps*q;
		}
		if( m[id] >= 1000000 ) 
			s.insert(id);
			
	}

	if( s.size() == 0 ) {
		cout << "NA" << endl;
	} else {
		for( auto it = s.begin(); it != s.end(); ++it ) {
			cout << (*it) << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#define M map<int,int>
using namespace std;
int main()
{
  int n, i, id, a, b;
  while(cin >> n,n){
    M m;
    vector<int> v;
    vector<int>::iterator p;
    for(i=0;i<n;i++){
      cin >> id >> a >> b;
      m[id] += a * b;
      for(p = v.begin(); p != v.end(); p++){
	if(*p == id) break;
      }
      if(p == v.end()) v.push_back(id);
    }
    bool f = false;
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
      if(m[(*it)] >= 1000000){
	cout << *it << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b,c,bc;
	int i;
	int flg;
	bc=0;
	flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		bc=b*c;
		if(bc<1000000){
			printf("%d\n",a);
			flg=1;
		}
	}
	if(flg==0){
		printf("NA");
	}
	return 0;
}

C++: #include <cstdio>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;

int n;

int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		rep(i,n){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			ll tmp = it->second;
			if(tmp >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> a;
	vector<double> b;
	vector<double> c;
	int x,y,z;
	int n;
	while(cin>>n){
	      if(n==0) break;
	      map <int,double> sum;
	      for(int i=0;i<n;i++){
		cin>>x>>y>>z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
		sum[x]+=y*z;
	       }
	       int cnt=0;
	       sort(a.begin(),a.end());
	       for(int i=0;i<n;i++){
                     if(sum[a[i]]>=1000000 &&a[i]!=a[i-1]){
				cout<<a[i]<<endl;
				cnt++;
		     }
		}
		if(cnt==0) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

 int main(void)
{
	int data;
	int m,n;
	int number;
	long prise,value;

	float money[4000];



	while(1){
		
		for(n=0;n<4000;n++){
			money[n] = 0;
		}

		scanf("%d",&data);
		if(data == 0) break;

		for(n=0;n<data;n++){
			scanf("%d%d%d",&number,&prise,&value);
			money[number] += (float)prise * value;
		}
		
		m = 0;
		for(n=0;n<4000;n++){
			if(money[n] >= 1000000){
				m = 1;
				printf("%d\n",n);
			}
		}

		if(m == 0){
			printf("NA\n");
		}
	}


	

	return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		rep(i, 4001) { a[i] = 0; }
		rep(i, n) {
			ll d, p, q;
			cin >>  d >> p >> q;
			if (a[d] < 1000000) {
				if (p*q >= 1000000) {
					a[d] = 1000000;
				}
				else {
					a[d] += p*q;
				}
			}
		}
		bool flag = false;
		for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef long long ll;

vector<int> hoge;
map<int,int> sums;

bool input(){
  hoge.clear();
  sums.clear();
  int n;
  cin>>n;
  if(n==0)return false;
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    sums[a] += b*c;

  }

  for(auto i:sums){
    if(i.second>=1000000)hoge.push_back(i.first);
  }
  return true;
}

void solve(){

  if(hoge.size()==0)puts("NA");
  else{
    rep(i,hoge.size()){
      printf("%d\n",hoge[i]);
    }
  }
}

int main(){
  while(input()){
    //cout<<solve()<<endl;
    solve();
  }
}

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

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector< pair<int, long long> > members;
        for (int i = 0; i < n; i++) {
            pair<int, long long> member;
            int id;
            long long cost, count;
            cin >> id >> cost >> count;
            bool exist = false;
            for (int i = 0; i < members.size(); i++) {
                if (members[i].first == id) {
                    members[i].second += cost * count;
                    exist = true;
                }
            }
            if (!exist) {
                member.first = id;
                member.second = cost * count;
                members.push_back(member);
            }
        }
        bool exist = false;
        for (vector< pair<int, long long> >::iterator m_i = members.begin();
                m_i != members.end(); m_i++) {
            if (m_i->second >= 1000000) {
                cout << m_i->first << endl;
                exist = true;
            }
        }
        if (!exist) {
            cout << "NA" << endl;
        }
    }
    return 0;
}