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;

typedef long long int lli;

lli employees[4001];
bool checked[4001];

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

		vector<lli> ans;

		for (lli i = 0; i < n; ++i) {
			lli 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 (lli i = 0; i < ans.size(); ++i) {
			cout << ans[i] << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n,c,a,b;
	while(1){
		int cc=0,t[4010]={},f[4010]={};
		cin>>n;
		if(n==0) break;
		rep(i,0,n){
			cin>>c>>a>>b;
			t[c]+=a*b;
			if(t[c]>=1000000&&f[c]==0){
				o(c); cc++; f[c]=1;
			}
		}
		if(cc==0) o("NA");
	}
}

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

int main(){
	int n, num, count;
	long long int p, q, nu[5000];
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < 5000; i++) {
			nu[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> num >> p >> q;
			nu[num] += p * q;
		}
		count = 0;
		for (int i = 1; i < n; i++) {
			if(nu[i]>999999){
				cout << i << endl;
				count++;
			}
		}
		if (count==0){
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std ;

int member[4010][3] ;
int price[4010] ;
int idx[4010] ;

struct ANS{
	bool ans ;
	int num ;
	int s ;
	bool operator < ( const ANS &n ) const{
		return num < n . num ;
	}
}A[4010];

bool cmp ( int a , int b ) ;

int main ( )
{
	int n ; 
	bool na ;
	while ( scanf ( "%d" , &n ) == 1 && n ){
		na = false ;
		memset ( price , 0 , sizeof ( price ) ) ;
		for ( int i = 0 ; i < 4010 ; i++ ){
			A[i] . ans = false ;
			A[i] . num = 9999 ;
			idx[i] = i ;
		}
		for ( int i = 0 ; i < n ; i++ ){
			scanf ( "%d %d %d" , &member[i][0] , &member[i][1] , &member[i][2] ) ;
			int tmp = member[i][1] * member[i][2] ;
			price[member[i][0]] += tmp ;
			if ( price[member[i][0]] >= 1000000 ){
				A[member[i][0]] . ans = true ;
				na = true ;
			}
			A[member[i][0]] . num = ( A[member[i][0]].num == 9999 ) ? i : A[member[i][0]] . num ;
		}
		if ( ! na ){
			printf ( "NA\n" ) ;
		}
		else{
			sort ( idx , idx + 4010 , cmp ) ;
			for ( int i = 0 ; i < n ; i++ ){
				if ( A[idx[i]] . ans == true ){
					printf ( "%d\n" , idx[i] ) ;
				}
			}
		}
	}
	return 0 ;
} 

bool cmp ( int a , int b )
{
	return A[a] . num < A[b] . num ;
}

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);
            if (price * num >= 1000000)
            {   
                printf("%d\n", id);
                flag = true;
            }   
        }   
        if (flag == false) printf("%s\n", "NA");
    
        scanf("%d", &n);
    }   

    return 0;
}

C++: #include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

#include<iostream>

using namespace std;

typedef long long ll;

struct data{
  int id;
  ll sum;
};

int main(void)
{

  int n;
  ll num, cost;
  data d[10000];

  while(cin >> n && n){
    int flag = true;
    for(int i = 0; i < n; i++){
      cin >> d[i].id >> cost >> num;
      d[i].sum = cost*num;
    }

    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        if(d[i].id == d[j].id && d[j].id){
          d[i].sum += d[j].sum;
          d[j].id = false;
        }
      }
    }

    for(int i = 0; i < n; i++){
      if(d[i].sum >= 1000000 && d[i].id){
        cout << d[i].id << endl;
        flag = false;
      }
    }
    if(flag){
        cout << "NA" << endl;
    }
  }

  return 0;
}

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

int main(){
    long size, id, price, quantity;
    bool noone = true;
    while (1){
	cin >> size;
	if (size == 0) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    if (price * quantity >= 1000000){
		cout << id << endl;
		noone = false;
	    }
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map<int,pair<int,int> > com;
    vector<pair<int,int> > ans;
    int a,b,c,x = 1;
    while(n--){
      cin >>a>>b>>c;
      if(!com[a].first){com[a].first = x++;}
      if(com[a].second+b*c>1000000){com[a].second = 1000000;}
      else{com[a].second+=b*c;}
    }
    map<int,pair<int,int> >::iterator pos;
    for(pos=com.begin(); pos!=com.end(); pos++){
      if(pos->second.second>=1000000){ans.push_back(make_pair(pos->second.first,pos->first));}
    }
    if(ans.empty()){cout <<"NA"<<endl;}
    else{
      sort(ans.begin(),ans.end());
      for(int i=0; i<ans.size(); i++){
	cout <<ans[i].second<<endl;
      }
    }
  }
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, long long int> > v;
        for(int i=0; i < n; i++){
            int place = -1;
            int p, q, r;
            cin >> p >> q >> r;

            bool isExist = false;
            for(int i=0; i < v.size(); i++){
                if(v[i].first == p){
                    isExist = true;
                    place = i;
                }
            }
            if(!isExist) v.push_back(mp(p, q*r));
            else {
                v[place].second += q*r;
            }
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= v[i].second){
                isExist = true;
                cout << v[i].first << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

C++: #include<stdio.h>

int main(void){
	int x,n,a,b,i,nan,k;
	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		k=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nan,&a,&b);
			if(a*b>999999){
				printf("%d\n",nan);
				k++;
			}
		}
		if(k==0) printf("NA\n");
		k=0;
	}
	return 0;
}