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<cstdio>
#include<cstring>

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		while(n--){
			memset(total,0,sizeof(total));
			scanf("%d%d%d",&a,&b,&c);
			total[a+1]=total[a+1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res++;
			}
		}
		if(res)printf("%d\n",res);
		else printf("NA\n");
	}
}

C++: 
using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000		// ?£?????????????

int main()
{
	int n = 0;							// ???????????°
	int no = 0;							// ????????????
	int price = 0;						// ????£???????
	int saleNum = 0;					// ?£??????°???
	bool flg = false;					// ????????????????????¨??????????????????
	map<int, int> proceed;				// ?£??????????map
	map<int, int>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %d %d", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
using namespace std;
int main() {
	int n;
	while (true) {
		map<int,int> dp;
		scanf("%d", &n);
		if (n == 0) break;
		bool neko = false;
		for (int i = 0;i < n;++i) {
			long long a, b, c;
			scanf("%lld%lld%lld", &a, &b, &c);
			if (b*c+dp[a] >= 1000000&&dp[a] < 99999999) {
				printf("%d\n", a);
				neko = true;
				dp[a] = 9999999999;
			}
			else {
				dp[a] += b*c;
			}
		}
		if (neko == false)printf("NA\n");
	}
}

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

using namespace std;
int main(void)
{
	int n;
	while(scanf("%d",&n))
	{
		if(n == 0) break;
		long long int flag[4001] = {0},shain[4001] = {0},junban[4000] = {0};
		long long int shains,tanka,kosu,j = 0;
		long long int flags = 0;
		for(int i = 0;i < n;i++)
		{
			scanf("%lld%lld%lld",&shains,&tanka,&kosu);
			if(flag[shains] == 0)
			{
				flag[shains] = 1;
				junban[j] = shains;
				shain[shains] = tanka * kosu;
				j++;
			}
			else
			{
				shain[shains] += tanka * kosu;
			}
		}

		for(int i = 0;i < n;i++)
		{
			if(shain[junban[i]] >= 1000000)
			{
				printf("%lld\n",junban[i]);
				flags = 1;
			}
		}
		if(flags == 0) printf("NA\n");
	}
	return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    map<int,long long> emps;
    vector<int> ids;
    int id,cost,amount,n;
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(emps.find(id)!=emps.end()){
                emps[id]+=cost*amount;
            }else{
                emps[id]=cost*amount;
                ids.push_back(id);
            }
        }
        if(ids.empty()) cout << "NA" << endl;
        for(int i=0;i<ids.size();i++){
            if(emps.at(ids[i])>=1000000) cout << ids[i] << endl;
        }
    }
    return 0;
}

C++: #include <stdio.h>

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

	long int  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 <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		bool f = false;
		rep(i,N) {
			int num, a, b;
			cin >> num >> a >> b;
			if(a * b >= 1000000) {
				cout << num << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

void Swap(int&, int&);

int main(){
  int i, j, n, id, x, y, sum;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> id >> x >> y;
      if(x < y) Swap(x, y);

      for(j=0, sum=0; j<y; ++j){
	sum += x;
	if(sum >= 1000000){
	  data.push_back(id);
	  break;
	}
      }
    }

    if(data.size() == 0){
      cout << "NA" << endl;
    }else{
      for(i=0; i<data.size(); ++i)
	cout << data[i] << endl;
    }

    data.clear();
  }
  return 0;
}

void Swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

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

typedef struct {
  int employee_num;
  int sales_price;
  int sales_value;
}employee_list;

int main(){
  int data_num;
  int i_cnt = 0;
  employee_list employee_list_buff;
  employee_list employee[1000];

  cin >> data_num;

  while(data_num > 0){
    cin >> employee_list_buff.employee_num >> employee_list_buff.sales_price >> employee_list_buff.sales_value;

    if(employee_list_buff.sales_price * employee_list_buff.sales_value >=  1000000){
      employee[i_cnt].employee_num = employee_list_buff.employee_num;
      employee[i_cnt].sales_price = employee_list_buff.sales_price;
      employee[i_cnt].sales_value = employee_list_buff.sales_value;
      i_cnt++;
    }
    data_num--;
  }

  if(i_cnt > 0){
    for(int i_array = 0 ; i_array < i_cnt ; i_array++){
      cout << employee[i_array].employee_num << endl;
    }

  }else{
    cout << "NA" << endl;
  }
}