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

main(){
 int n,m=0;
 int id[4000],tanka[4000],suryou[4000];

cin>>n;
while(n!=0){
 for(int i=0;i<n;i++){
  cin>>id[i]>>tanka[i]>>suryou[i];
 }

 for(int i=0;i<n;i++){
  if(tanka[i]*suryou[i]>=1000000){
   cout<<id[i]<<endl;
   m++;
  }
 if(m==0) cout<<"NA"<<endl;
 cin>>n;
}
}

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

using namespace std;

long long employees[4001];
bool checked[4001];

int main()
{
	int n;
	while (cin >> n, n) {
		for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<int> ans;

		for (int i = 0; i < n; ++i) {
			int num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.empty()) cout << "NA" << endl;

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

C++: #include<bits/stdc++.h>
using namespace std;

int main(){

  int n;

  while(cin>>n,n){

	long long e,p,q;
	map<long long,long long> total;
	bool flag = false;

	for(int i=0;i<n;++i){
	  cin>>e>>p>>q;

	  if(total[e] <1000000){
		total[e]+=p*q;
		if(total[e] >= 1000000){
		  cout<<e<<endl;
		  flag = true;	  
		}
	  }

	}
	
	if(flag == false)
	  cout<<"NA"<<endl;
	
  }

  return 0;
  
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	long long int g[1001],s[1001],d[1001],f[1001];
	int j,i,k,a,h[1001];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			h[i]=0;
			g[i]=0;
		}
		for(i=0;i<a;i++){
			scanf("%lld %lld %lld",&s[i],&d[i],&f[i]);
		//	if(d[i]*f[i]>=1000000) h[i]=1;
			if(h[i]==0) g[i]=d[i]*f[i];
			else g[i]=0;
		}
		for(i=0;i<a;i++){
			for(j=i+1;j<a;j++){
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
				if(s[i]==s[j]){
					if(h[i]==0){
						g[i]+=g[j];
						g[j]=0;
					}
					else g[j]=0;
				}
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
			}
		}
		k=0;
		for(i=0;i<a;i++){
			if(h[i]==1){
				printf("%lld\n",s[i]);
				k=1;
			}
		}
		if(k==0) printf("NA\n");
	}
	return 0;
}

C++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool same(vector<pair<int, ll> >& t, int num, ll p)
{
  bool ok = true;
  REP(i, t.size()){
    if (num == t[i].Fi){
      ok = false;
      t[i].Se += p;
      break;
    }
  }

  return ok;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n, n){
    vector<pair<int, ll> > table;
    REP(i, n){
      int num; ll price, cnt;
      cin >> num >> price >> cnt;
      if (same(table, num, price * cnt)){
        table.pb(mp(num, price * cnt));
      }
    }
    bool only = true;
    REP(i, table.size()){
      if (table[i].Se >= 1e6){
        print(table[i].Fi);
        only = false;
      }
      //cout << table[i].Fi << " " << table[i].Se << endl;
    }
    if (only) print("NA");
  }

  return (0);
}

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

struct staff {
	unsigned long long int num;
	unsigned long long int price;
	unsigned long long int quan;
	unsigned long long int total;
};

int main()
{
	int num, i, k, j, datas;
	unsigned long long int sn, sp, sq;
	map<int, staff> staffs[4000];
	map<int, staff>::iterator staffs_it;

	datas = 0;
	while(1)
	{
		cin >> num; if(num == 0) break;

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[datas][sn].num = sn;
			staffs[datas][sn].price = sp;
			staffs[datas][sn].quan = sq;
			staffs[datas][sn].total += staffs[datas][sn].price * staffs[datas][sn].quan;
		}
		datas++;
	}

	for(i = 0; i < datas; i++)
	{
		staffs_it = staffs[i].begin();
		int over = 0;

		while(staffs_it != staffs[i].end())
		{
			if(staffs[i][(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[i][(*staffs_it).first].num << endl;
				over++;
			}
			staffs_it++;
		}
		if(over == 0) cout << "NA" << endl;
	}
}

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

using namespace std;

int main(){
    vector<pair<int, long long> > data;

    int n;
    while(cin >> n, n){
        for(int i=0; i < n; i++){
            int num, cost, goodsNum;
            cin >> num >> cost >> goodsNum;

            bool exist = false;
            for(int j=0; j < data.size(); j++){
                if(data[j].first == num){
                    data[j].second += cost * goodsNum;
                    exist = true;
                    break;
                }
            }
            if(!exist){
                data.push_back(pair<int, long long int>(num, cost*goodsNum));
            }
        }
        bool exist = false;
        for(int i=0; i < data.size(); i++){
            if(1000000 <= data[i].second){
                cout << data[i].first << endl;
                exist = true;
            }
        }
        if(!exist)cout << "NA" << endl;
        data.clear();
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define GOOD 1000000

long total[4005];

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, id, p, q, cnt;
	cin >> n;
	while (n != 0) {
		for (int i = 0; i < 4005; i++) {
			total[i] = 0;
		}
		cnt = 1;
		for (int i = 0; i < n; i++) {
			cin >> id >> p >> q;
			long before = total[id];
			total[id] += p * q;
			if (before < GOOD && total[id] >= GOOD) {
				cout << id << endl;
				cnt = 0;
			}
		}
		if  (cnt) {
			cout << "NA" << endl;
		}
		cin >> n;
	}
}