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>
#include <queue>

int main()
{
    int n, no;
    long long yen, num;
    bool update = false;
    long long total[4001];
    std::queue<int> que;
    
    for (int i = 0; i < 4001; ++i) {
        total[i] = 0;
    }

    std::cin >> n;
    
    while (n != 0) {
        
        /*input*/
        for (int i = 0; i < n; ++i) {
            scanf("%d %lld %lld", &no, &yen, &num);
            total[no] += yen * num;
            que.push(no);
        }
        /*output*/
        while (!que.empty()) {
            if (total[que.front()] >= 1000000) {
                std::cout << que.front() << std::endl;
                update = true;
            }
            total[que.front()] = 0;
            que.pop();
        }
        if (!update) {
            std::cout << "NA" << std::endl;
        }
        std::cin >> n;
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    map<int,long long int>m;
    vector<int>l;
    rep(i,n){
      long long int a,b,c;
      cin>>a>>b>>c;
      bool h=true;
      rep(i,l.size())if(a==l[i])h=false;
      if(h)l.pb(a);
      m[a]+=b*c;
    }
    //cout<<l.size()<<endl;
    int co=0;
    rep(i,l.size())if(m[l[i]]>=1000000){cout<<l[i]<<endl;co++;}
    if(!co)cout<<"NA"<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int i=0;
        int na=0;
        cin>>i;
        if(i==0)
            break;
        else
        {
            int h[4000];
            for(int k=1;k<4000;k++)
            {
                h[k]=0;
            }
            for(int k=1;k<=i;k++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=l*m;

            }
            for(int k=1;k<=4000;k++)
            {
                if(h[k]>=1000000)
                {
                    cout<<k<<endl;
                    na=1;
                }

            }
            if(na==0)
            {
                cout<<"NA"<<endl;
            }

        }
    }

    return 0;
}

C++: #include <stdio.h>
int main(){
  int list[64][4],n=1,i,j;
  bool flg[4100];
  for (i = 0; i < 4100; i++) flg[i] = false;
  while(n){
    scanf("%d",&n);
    if(!n) break;
    int cnt = 0;
    for (i = 0; i < n; i++){ 
      for (j = 0; j < 3; j++) scanf("%d",&list[i][j]);
      list[i][3] = list[i][2] * list[i][1];
      for (j= 0; j< i; j++) if(list[i][0] == list[j][0]) {list[i][3] += list[j][3];list[j][3] =0;}
      //printf("list[%d][3]:%d\n",list[i][0],list[i][3]);
      if(list[i][3] >= 1000000) {if(!flg[list[i][0]]) {printf("%d\n",list[i][0]);flg[list[i][0]] = true;cnt++;}}
    }
    if(n) if(!cnt) printf("NA\n");
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
long long s[4000];int i;int w;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	s[a-1]=s[a-1]+b*c;
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==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 = 0; i < 4001; 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;

int main(){
	int n,a,b,c,flag,f[4005];
	map<int, long long int> m;
	while (cin >> n, n){
		for (int i = 0; i < 4005; i++) f[i] = 0;
		m.clear();
		flag = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			f[a] = 1;
			m[a] += (long long int)b * (long long int)c;
		}
		for (int i = 0; i < 4005; i++){
			if (f[i] && m[i] >= 1000000ll) {
				cout << i << endl;
				flag = 1;
			}
		}
		if (!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main(){
	while (1){
		queue<int> q;
		map<int,lint> m;
		int n;
		cin >> n;
		if (n == 0) break;
		int a, b, c;
		rep(i, 0, n){
			cin >> a >> b >> c;
			if (m[a] == 0){
				q.push(a);
			}
			m[a] += b*c;
		}
		int ct = 0;
		while (!q.empty()){
			int x = q.front(); q.pop();
			if (m[x] >= 1000000){
				o(x); ct++;
			}
		}
		if (ct == 0){
			o("NA");
		}
	}

}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        int id, p, q;
        vector<int> ord;
        bool flag = false;
        map<int, long long> worker;
        
        for (int i = 0; i < n; i++) {
            cin >> id >> p >> q;
            if (worker.find(id) == worker.end())
                ord.push_back(id);
            worker[id] += (long long)p * q;
        }

        for (int i = 0; i < ord.size(); i++) {
            if (worker[ord[i]] >= 1000000) {
                cout << ord[i] << endl;
                flag = true;
            }
        }
        if (!flag)
            cout << "NA" << endl;
    }

    return 0;
}