Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<stdio.h>

int main(){

	int n=1, i, x[4000] = {}, xx[4000] = {}, xxx[4000] = {}, r, y;

	while (n > 0){
		scanf("%d", &n);

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[i],&xx[i],&xxx[i]);
		}

		for (r = 0; r < 4000; r++){
			
			if (xx[r] * xxx[r] > 1000000){
				printf("%d\n", x[r]);
			}	
		}
		if (y == 0){ printf("NA\n"); (y = 0); }		
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> ids;
        map<int, ll> sales;
        int i;
        ll p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            if ( ! sales.count(i)) ids.push_back(i);
            sales[i] += p * q;
        }
        bool na = true;
        for (int k=0; k<(int)ids.size(); ++k) {
            if (1000000 <= sales[ids[k]]) {
                cout << ids[k] << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
}

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

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

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

int n;
int s[4000];

int main(){
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		rep(i, n){
			int a, x, y;
			scanf("%d%d%d", &a, &x, &y);
			s[--a] = (int)min(s[a] + ll(x) * y, ll(1e6));
		}

		bool none = true;
		rep(i, 4000){
			if(s[i] >= (int)1e6){
				printf("%d\n", i + 1);
				none = false;
			}
			s[i] = 0;
		}
		if(none){
			puts("NA");
		}
	}
	return 0;
}

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

using namespace std;

struct person
{
	int id;
	int price;
	int number;
};

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<person> P(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> P[i].id >> P[i].price >> P[i].number;
		}
		bool flag = true;
		for(int i = 0; i < n; ++i)
		{
			unsigned long long int amount = P[i].price * P[i].number;
			if(amount >= 1000000)
			{
				cout << P[i].id << endl;
				flag = false;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

typedef struct{
	int pid;
	long long sell;
}people;

int main(){
	while(1){
		long n;
		people p[4000];
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		int now=0;
		
		for(long i=0; i<n; ++i){
			int num;
			long t, u;
			scanf(" %d %ld %ld", &num, &t, &u);
			
			bool find=false;
			for(int j=0; j<now; ++j){
				if(p[j].pid==num){
					p[j].sell+=t*u;	
					find=true;
				}
			}
			if(!find){
				p[now].pid=num;
				p[now].sell=t*u;
				now++;
			}
		}		
		
		int count=0;
		for(int i=0; i<now; ++i){
			if(p[i].sell>=1000000){
				printf("%d\n", p[i].pid);
				++count;
			}		
		}
		
		if(count==0) printf("NA\n");
	}	
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n,x,y,z;
	int a = 0,b=0,c=0,d=0;
	int g[4000];

	while(true){
        int d=0;
		cin >> n;

		if(n==0){
			break;
		}
		for(int i=0 ;i<n ;i++){

	       cin >> x >> y >> z;

		   a = y*z;
		   if(a>=1000000){
			
			 g[b] = x;
			 b++;  
		     d++;
		   }
		}
		  if(d==0){
			c++;
		  }
		
	   
	}	
	if(b>0){
	     	for(int i=0 ;i<b ;i++){
			cout << g[i] << endl;			
		   }	
	}	
    if(c>0){
		for(int i=0 ;i<c ;i++){
			cout << "NA" << endl;
		}
	}
	
	
	return 0;
}

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

int main()
{
	int n;
	int ans[4000];
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			int num[4000];
			int flag=1;
			double a[4000],b[4000];
			cin >> num[i] >> a[i] >> b[i] ;
			for(int l=0;l<i;l++)
			{
				if(num[l]==num[i])
				{
//					cout << "in" << endl;
					a[i]+=a[l];
					b[i]+=b[l];
				}
			}
			if(a[i]/10000.0*b[i]>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num[i])
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num[i];
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			ll s; int f; s = it->second; f = it->first;
			if(s >= 1000000){
				ok = false;
				printf("%d\n", f);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

int main(){
    int n;
    map<string, ll> data;
    vector<string> id;
    while (cin >> n && n){
        id.clear();
        data.clear();
        rep(i, n){
            string a;
            ll b, c;
            cin >> a >> b >> c;
            if (data.count(a)){
                data[a] = c*b;
                id.push_back(a);
            }
            else{
                data[a] += c*b;
            }
        }

        bool NA = true;
        rep(i, id.size()){
            if (data[id[i]] >= 1000000){
                cout << id[i] << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;

    }
    return 0;
}

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

const int lim = 1000000;

int main()
{
    int n; long long en, price, qty;

    while(cin >> n && n) {
        int check[4001] = {0}; queue<int> que;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= lim) continue;
            if (check[en] >= 0) check[en] += price*qty;
            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) cout << "NA" << endl;
        else {
            while(!que.empty()) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}