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 <vector>

typedef std::pair<std::string,int> sale;

int main()
{
	
	
	while (true) {
		int n;
		std::vector<sale> sale_vec;
		
		std::cin >> n;
		
		if (n==0) break;
		
		std::string id;
		int unit_price;
		int quantity;
		
		for (int i=0; i<n; i++) {
			std::cin >> id >> unit_price >> quantity;
			bool id_exists = false;
			for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
				if (it->first == id) {
					id_exists = true; it->second += unit_price * quantity; break;
				}
			}
			if (!id_exists) {
				sale_vec.push_back( sale(id, unit_price * quantity) );
			}
		}
		
		bool output = false;
		for (std::vector<sale>::iterator it = sale_vec.begin(); it != sale_vec.end(); ++it) {
			if (it->second >= 1000000) {
				std::cout << it->first << std::endl;
				output = true;
			}
		}
		if (!output) std::cout << "NA" << std::endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	cin >> n;
	if(n) {
		vector<pair<int, ll>> v;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			vector<pair<int, ll>>::iterator it = v.begin();
			for(; it != v.end(); ++it) {
				if((*it).first == id.at(i)) {
					(*it).second += p.at(i) * q.at(i);
					break;
				}
			}
			if(it == v.end()) {
				v.push_back(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
				}
		}
		bool flag = false;
		for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
    int n,a[5000],m,p,q;
    bool b[5000],f;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        for(int i=0;i<5000;i++)a[i]=b[i]=0;
        f=false;
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&m,&p,&q);
        if(!b[m]){
            a[m]+=p*q;
            if(a[m]>=1000000){
                b[m]=true;
                f=true;
                printf("%d\n",m);
            }
        }
    }
        if(!f)printf("NA\n");
    }
}

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

using namespace std;

struct data{
  int id;
  int price;
  int amount;
  int rate;
};

int main(){
  int n=0;
  while(1){
    cin>>n;
    if(n==0){return 0;}
    vector<struct data> data(n);
    int c=0;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&data[i].id,&data[i].price,&data[i].amount);
      data[i].rate=data[i].price*data[i].amount;
    }
    vector<struct data> res(n);
    for(int i=0;i<n;i++){
      res[i].id=0;
    }
    for(int i=0;i<n;i++){
      int find=0;
      for(int j=0;j<i;j++){
	if(data[i].id==res[j].id){
	  res[j].rate+=data[i].rate;
	  find=1;
	  break;
	}
      }
      if(find==0){
	res[i].id=data[i].id;
	res[i].rate=data[i].rate;
      }
    }
    for(int i=0;i<n;i++){
      if(res[i].id!=0&&res[i].rate>=1000000){
	cout<<data[i].id<<"\n";
	c++;
      }
    }
    if(c==0){
      cout<<"NA\n";
    }
  }
  return 0;
}

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

class meb{
public:
	int num;
	int tanka;
	int count;
};

int main(){
	int n,m,t,c;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int j=0;j<n;j++){
			if((st[j].tanka)*(st[j].count)>=1000000)cout<<st[j].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][10000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<10000; i++) data[0][i]=0,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=a*b,f=-1;
	  break;
	}else if(data[0][f]==0){
	  data[0][f]=id;
	  data[1][f]=a*b;
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        long long int mem[4500][3] = {{0}};
        int a,x,y;
        int cnt = 0;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            for(int j = 0;j < i; j++){
                if(mem[j][1] != a){
                   cnt++;
                }
                else {
                    mem[j][0] += x*y;
                    break;
                }
            }
            if(cnt == i){
                mem[i][0] += x*y;
                mem[i][1] = a;
                cnt = 0;
            }
        }
        //for(int i = 0;i < n; i++)printf("%lld: %lld\n",mem[i][0],mem[i][1]);
        bool flg = 0;
        for(int i = 0;i < n; i++){
            if(mem[i][0] >= 1000000){
                printf("%lld\n",mem[i][1]);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n, m;

    while(cin >> n, n){
        long long v[4010];
        rep(j, 4010) v[j] = 0;
        rep(p, n){
            int a, b, c;
            cin >> a >> b >> c;
            v[a] += b*c;
        }
        bool isP = false;
        rep(i, 4010) if(1000000 <= v[i]){isP = true; cout << i << endl;}
        if(!isP) cout << "NA" << endl;
}
}

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

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str,' ');
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}