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<iostream>
#include<vector>
#include<map>
#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  while(cin>>n,n){
    int tof = 1;
    int num;
    long long price,qua;
    map<int,long long> staff;
    map<int,long long>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] += price*qua;

    }
    for(itr = staff.begin(); itr != staff.end(); itr++){

      if(itr->second >= SALES_GOAL){
        cout << itr->first << endl;
        tof = 0;
      }
      
    }
    if(tof)cout << "NA" << endl;
    
  }


}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int st[4444];
int stf[4444];
int main(void)
{
  while(1){
    int n;
    bool f = true;
    cin >> n;
    if(!n) break;
    memset(st,0,sizeof(st));
    memset(stf,-1,sizeof(stf));
    for(int i = 0; i < n; i++){
      int a,b,c;
      cin >> a >> b>> c;
      st[a] += b * c;
      if(1000000 <= st[a] && stf[a]){
	cout << a << endl;
	stf[a] = 0;
	f = false;
      }
    }
    if(f) puts("NA");
  }
}

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 ;
}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 < 4010 ; 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<iostream>
using namespace std;
int ans[4000];

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

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

int main(){
    int n;
    long int array[n][3];
    int count=0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[j][1]=0;
                array[j][2]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    if(count==0){
        cout<<"NA\n";
    }
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int n;
	scd(n);
	LL a,b;
	string c;
	vector<tuple<string,LL,LL>> d;
	while(n!=0)
	{
		d.clear();
		int fl=0;
		forin(i,0,n)
		{
			cin>>c;
			scdlld(a,b);
			d.pb(make_tuple(c,a,b));
		}
		sort(d.begin(),d.end());
		
		int size=d.size();
		LL z=0;
		int l=0;
		int flag;
		for(int i=0 ; i<size ; i++)
		{
			flag=0;
			a=get<1>(d[i])*get<2>(d[i]);
			for(int j=i+1 ; j<size ; j++)
			{
				if(get<0>(d[i])==get<0>(d[j]))
				{
					l=j;
					flag=1;	
					a+=get<1>(d[j])*get<2>(d[j]);
				}
			}
			if(flag==1)
			i+=l;
			
			
			if(a>=1000000)
			{
				cout<<get<0>(d[i])<<endl;
				fl=1;
			}
		}
		
		if(fl==0)
		printf("NA\n");
		
		
		scd(n);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int n; cin >> n;
    do {
        int e[n], p[n], q[n];
        ll tmp[4010] = {};
        int flag = 0;
        rep(i, n) cin >> e[i] >> p[i] >> q[i];
        for (int i = 0; i < n; i++) {
            tmp[e[i]] += p[i] * q[i];
        }
        for (int i = 0; i < n; i++) {
            if (tmp[e[i]] >= 1000000) {
                cout << e[i] << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
        cin >> n;
    } while(n != 0);

    return 0;
}