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 <iostream>
#include <map>
#include <string>
using namespace std;

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long long> m;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			m[str] += (num * a);
		}
		map <string, long long> ::iterator it;
		bool flag = true;
		/*
		for (it = m.begin(); it != m.end(); it++){
			cout << it->first << " -- " << it->second << endl;
		}*/
		
		for (it = m.begin(); it != m.end(); it++){
			if (1000000 <= it->second){
				cout << it->first << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			printf("data_id = %d\n",i);
			cid=int (0);
			price=num=long long int (0);
			scanf("%d",&cid);
			scanf("%lld",&price);
			scanf("%lld",&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}
			for(j=0;j<idcount;j++){
				printf("%d %lld\n",id[j],sale[j]);
			}
		}



		for(i=0;i<idcount;i++){
			if(sale[i]>1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[5000],check[5000];
	int a,b,c;
	while(true){
	cin>>n;
	bool t=false;
	if(n==0)
		break;
	for(int i=0;i<5000;i++){
		s[i]=0;
		check[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		s[a]+=b*c;
		if(s[a]>=1000000){
			if(check[a]==0)
			cout<<a<<endl;
			check[a]=1;
			t=true;
		}
	}
	if(t==false)
		cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001]={0};
    int id_list[4000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(c*q);
            cin>>id>>c>>q;
            id_flag=true;
            for(i=0;i<k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
                data_list[l]=0;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    
    return 0;
}

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

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check;
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    check = 0;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      //      cout << ID << " " << price << " " << quantity << endl;
      sales[ID] += price * quantity;
      if(sales[ID] >= 1000000) {
        cout << ID << endl;
        check = 1;
        sales[ID] = -100000000;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
#define int long long

int A[1000000];

signed main(){
	int N,B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("NA");
	}
    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 < 4010; i++) {
            if (tmp[i] >= 1000000) {
                cout << i << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
        cin >> n;
    } while(n != 0);

    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;


int n;
int index, a, b;
vector<P> vp;

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> index >> a >> b;
			bool f = 1;
			REP(j, vp.size()){
				if (vp[j].first == index){
					vp[j].second += a*b;
					f = 0;
				}
			}
			if (f)vp.push_back(P(index, a*b));
		}
		bool f = 1;
		REP(i, vp.size()){
			if (vp[i].second >= 1000000){
				cout << vp[i].first << endl;
				f = 0;
			}
		}
		if (f)cout << "NA" << endl;
		vp.clear();
	}
}

C++: #include <iostream>
#include<algorithm>
using namespace std;
#define MAX 10000000
bool prime[MAX]={true};

int countPrime(int n){
	if(n<2) return 0;
	if(n==2) return 1;
	int ret=0;
	// fill(data, data + numof(data), 0);
	fill(prime, prime+MAX,true);
	for(int i=2;i*i<=n;i++){
		if(prime[i]){
			for(int j=i*i;j<=n;j=j+i){
				prime[j]=false;
			}
		}
	}
	for(int i=2;i<=n;i++){
		if(prime[i]) ret++;
	}
	return ret;
}

int main(){
	int n;
	while(cin>>n){
		cout <<countPrime(n) <<endl;		
	}
	return 0;
}