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 <bits/stdc++.h>
#define HIGH 1000000
#define MEMBER_NUM 4000
#define INF -1
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        int data[MEMBER_NUM];
        memset(data, INF, sizeof(data));
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no] != INF) {
                data[no] += tanka*quantity;
            } else {
                data[no] = tanka*quantity;
            }
        }
        bool update = false;
        for(int r = 0; r < MEMBER_NUM; r++) {
            if(data[r] >= HIGH) {
                cout << r << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    return(0);
}

C++: #include <stdio.h> 

int main()
{
    int n;

    scanf("%d", &n);
    while (n != 0)  
    {   
        int i;
        bool flag = false;

        for (i=0; i<n; i++) 
        {   
            int id, price, num;
            scanf("%d %d %d", &id, &price, &num);
            //printf("%d %d %d\n", id, price, num);
    
            int quota = int(1000000 / price + 0.999999999);
            if (num >= quota)
            {   
                printf("%d\n", id);
                flag = true;
            }   
        }   
        if (flag == false) printf("%s\n", "NA");
    
        scanf("%d", &n);
    }   

    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct salary{
	int no;
	long sell;
};

int main() {
	
	int n;
	while(cin>>n,n){
		vector<salary> vs;

		REP(i, n){
			int no, sell_n, value;
			cin >> no >> sell_n >> value;
			bool b = false;
			REP(j, vs.size()){
				if (vs[j].no == no){
					b = true;
					vs[j].sell += sell_n*value;
				}
			}
			if (!b)vs.push_back({ no, sell_n*value });
		}
		bool b2 = false;
		REP(i, vs.size()){
			if (vs[i].sell >= 1000000){
				cout <<vs[i].no << endl;
				b2 = true;
			}
		}
		if (!b2)cout << "NA"<< endl;
	}
}

C++: #include<stdio.h>

int main(){

	int n=1, i, x[4000] = {}, xx[4000] = {}, xxx[4000] = {}, r, y;

	while (n > 0){
		scanf("%d", &n);

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[i],&xx[i],&xxx[i]);
		}

		for (r = 0; r < 4000; r++){
			
			if (xx[r] * xxx[r] > 1000000){
				printf("%d\n", x[r]);
			}	
		}
		if (y == 0){ printf("NA\n"); (y = 0); }		
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> ids;
        map<int, ll> sales;
        int i;
        ll p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            if ( ! sales.count(i)) ids.push_back(i);
            sales[i] += p * q;
        }
        bool na = true;
        for (int k=0; k<(int)ids.size(); ++k) {
            if (1000000 <= sales[ids[k]]) {
                cout << ids[k] << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
}

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

int main(){
    int n;
    while(cin>>n,n){
        map<long,long>m;
        int i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(m.find(i)==m.end())
                m.insert(make_pair(i,p*q));
            else m[i]+=p*q;
        }
        for (map<long,long>::iterator it=m.begin(); it!=m.end(); ++it){
            if(it->second>999999){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include <cstdio>
#include <algorithm>

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

using namespace std;

typedef long long ll;

int n;
int s[4000];

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		rep(i, n){
			int a, x, y;
			scanf("%d%d%d", &a, &x, &y);
			s[--a] = (int)min(s[a] + ll(x) * y, ll(1e6));
		}

		bool none = true;
		rep(i, 4000){
			if(s[i] >= (int)1e6){
				printf("%d\n", i + 1);
				none = false;
			}
			s[i] = 0;
		}
		if(none){
			puts("NA");
		}
	}
	return 0;
}

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

using namespace std;

struct person
{
	int id;
	int price;
	int number;
};

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<person> P(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> P[i].id >> P[i].price >> P[i].number;
		}
		bool flag = true;
		for(int i = 0; i < n; ++i)
		{
			unsigned long long int amount = P[i].price * P[i].number;
			if(amount >= 1000000)
			{
				cout << P[i].id << endl;
				flag = false;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

typedef struct{
	int pid;
	long long sell;
}people;

int main(){
	while(1){
		long n;
		people p[4000];
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		int now=0;
		
		for(long i=0; i<n; ++i){
			int num;
			long t, u;
			scanf(" %d %ld %ld", &num, &t, &u);
			
			bool find=false;
			for(int j=0; j<now; ++j){
				if(p[j].pid==num){
					p[j].sell+=t*u;	
					find=true;
				}
			}
			if(!find){
				p[now].pid=num;
				p[now].sell=t*u;
				now++;
			}
		}		
		
		int count=0;
		for(int i=0; i<now; ++i){
			if(p[i].sell>=1000000){
				printf("%d\n", p[i].pid);
				++count;
			}		
		}
		
		if(count==0) printf("NA\n");
	}	
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n,x,y,z;
	int a = 0,b=0,c=0,d=0;
	int g[4000];

	while(true){
        int d=0;
		cin >> n;

		if(n==0){
			break;
		}
		for(int i=0 ;i<n ;i++){

	       cin >> x >> y >> z;

		   a = y*z;
		   if(a>=1000000){
			
			 g[b] = x;
			 b++;  
		     d++;
		   }
		}
		  if(d==0){
			c++;
		  }
		
	   
	}	
	if(b>0){
	     	for(int i=0 ;i<b ;i++){
			cout << g[i] << endl;			
		   }	
	}	
    if(c>0){
		for(int i=0 ;i<c ;i++){
			cout << "NA" << endl;
		}
	}
	
	
	return 0;
}