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>
using namespace std; 
#define pb push_back
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef vector<int> Vi;

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    Vi v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      if( m[a] == 0 ) {
	v.pb( a );
      }
      m[a] += b * c;
    }
    
    Rep(i, v.size()) {
      if( m[v[i]] >= 1000000 ) {
	cout << v[i] << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}

C++: #include <iostream>
#include <set>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n != 0 )
	{
		set <int> T;

		bool exist = false;
		for ( int i = 0; i < n; i++ )
		{
			int no, price, items;
			cin >> no >> price >> items;

			if ( no < 4000 && price <= 1000000 && items <= 100000 )
			{
				long long profit = (long long)price * items;
				if ( T.find( no ) == T.end() && profit >= 1000000L )
				{
					exist = true;
					cout << no << endl;
					T.insert( no );
				}
			}
		}

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

	return 0;
}

C++: #include<stdio.h>

int main(void) {
	long long int a, b, count = 1, number = 0, syain[4010], tanka[4010], suuryou[4010], score[4010] = { 0 }, noruma = 1000000, sens = 0;
	while (count) {
		scanf("%d", &count);
		for (size_t i = 0; i < count; i++)
		{
			scanf("%lld %lld %lld", &syain[number], &tanka[number], &suuryou[number]);
			score[syain[number]] += tanka[number] * suuryou[number];
			if (score[syain[number]] >= noruma)
			{
				printf("%lld\n", syain[number]);
				sens++;
			}
			number++;
		}
		if (sens == 0 && count != 0)
		{
			printf("NA\n");
		}
		sens = 0;
	}
	return 0;
}

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

using namespace std;

#define ll long long

int main(void){
  map<int,ll> m;
  int n;
  int no,amount,price;

  while(cin >> n){
	bool exist = false;
        if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  m[no] += amount*price;
	}
	map<int,ll>::iterator it = m.begin();
	while(it!=m.end()){
	  if((*it).second >= 1e+6){
		cout << (*it).first << endl;
		exist = true;
	  }
	  ++it;
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
  }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

int main(){
	
	int num;
	while(~scanf("%d",&num)){
		if(num==0) break;
		bool isok=false;
		map<string,int> val;
		for(int i=0;i<num;i++){
			char n[16];
			int m,o;
			scanf("%s %d %d",n,&m,&o);
			val[n] += m*o;
		}

		for(map<string,int>::iterator it = val.begin(); it != val.end(); it++){
			if(it->second >= 1000000){
				cout << it->first << endl;
				isok=true;
			}
		}
		if(!isok) cout <<  "NA" << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n,a,b,tanka,uriage,jun[N];
  long long int num[N];
  bool judge;

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

    for(int i=0;i<N;i++){
      num[i] = 0;
      jun[i] = 0;
    }

    for(int i=0,b=0;i<n;i++){
      judge = true;
      cin >> a >> tanka >> uriage;
      num[a] += (long long int)tanka * (long long int)uriage;
      for(int j=0;j<i;j++){
	if(jun[j]==a){
	  judge = false;
	  break;
	}
      }
      if(judge){
	jun[b] = a;
	b++;
      }
    }

    judge = true;
    for(a=0;jun[a]!=0;a++){
      if(num[jun[a]]>=1000000){
	cout << jun[a] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int ans[4000];

int main(){
	int N;
	int n;
	long long int e, p, q;
	int x;
	while (1){
		x = 0;
		cin >> N;
		n = N;
		if (N == 0){ break; }
		while (N){
			cin >> e >> p >> q;
			cout << N<<x << endl;
			if (p*q >= 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
			for (int i = 0; i < n; i++)
			{
				if (i == 0 && ans[i] == 0)cout << "NA" << endl;
				if (ans[i] == 0){ break; }
				cout << ans[i] << endl;
			}
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		vector<pair<int,int> > company;
		pair<int, int> sells;
		bool hero = false;
		int num, sell, cnt;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			bool search = false;
			for (int j = 0; j < company.size(); j++)
			{
				if (company[j].first == num){
					search = true;
					company[j].second += sell*cnt;
					break;
				}
			}
			if (search == false)
			{
				sells.first = num;
				sells.second = sell*cnt;
				company.push_back(sells);
			}
		}
		for (int i = 0; i < company.size(); i++)
		{
			if (company[i].second >= target)
			{
				hero = true;
				printf("%d\n", company[i].first);
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
	int n;
	int e[1000];
	int p[1000];
	int q[1000];
	int total[1000];
	cin >> n;
	while (n!=0){
		e[1000] = { 0 };
		p[1000] = { 0 };
		q[1000] = { 0 };
		total[1000] = { 0 };
		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p[i] >> q[i];
			total[i] = p[i] * q[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j && e[i] == e[j]) {
					total[i] += total[j];
					total[j] = 0;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (total[i] >= 1000000)printf("%d\n", e[i]);
			else printf("NA\n");
		}
		cin >> n;
	}
	return 0;
}