Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func isLeapYear(y int) bool {
	return (y%4 == 0 && y%100 > 0) || (y%4 == 0 && y%400 == 0)
}

func cntLeap(y []int) {
	cnt := 0

	for i := y[0]; i <= y[1]; i++ {
		if isLeapYear(i) {
			cnt++
			fmt.Println(i)
		}
	}

	if cnt == 0 {
		fmt.Println("NA")
	}
}

func main() {
	num := 0

	for sc.Scan() {
		y := Sliceconvtoi()

		if y[0] == 0 && y[1] == 0 {
			break
		}

		if num > 0 {
			fmt.Println()
		}

		cntLeap(y)
		num++
	}

}

C++: #pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {

    bool first = true;

    while (true) {
        
        ll a, b; cin >> a >> b;
        if (!a && !b) break;

        if (!first) cout << "\n";
        first = false;

        bool exist = false;
        RANGE(i, a, b) {
            if (i % 4 == 0 && (i % 100 || i % 400 == 0)) {
                cout << i << endl;
                exist = true;
            }
        }

        if (!exist) {
            cout << "NA\n";
        }

    }
    
}

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

bool is_leap(int y) {
  if(y % 400 == 0) {
    return true;
  }else if(y % 100 == 0) {
    return false;
  }else if(y % 4 == 0) {
    return true;
  }

  return false;
}

int main() {
  int a, b;
  int cnt = 0;
  while(cin >> a >> b ) {
    if(a == 0 && b == 0) {
      break;
    }
    if(cnt) {
      cout << endl;
    }
    cnt++;

    bool flg = false;
    for(int i = a; i <= b; i++) {
      if(is_leap(i)) {
        cout << i << endl;

        flg = true;
      }
    }
    if(!flg) {
      cout << "NA" << endl;
    }
  }

  return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

void leapyear(int a, int b);
int a, b;
bool flag = true;
int main(void)
{
    while (1) {
        flag =true;
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) {
            break;
        }
        leapyear(a, b);
        printf("\n");
    }
    return 0;
}

void leapyear(int a, int b)
{
    for (int i = a; b >= i; ++i) {
        if (i % 4 == 0) {
            if (i % 100 == 0) {
                if (i % 400 == 0) {
                    printf("%d\n", i);
                    flag = false;
                }
            } else {
                printf("%d\n", i);
                flag = false;
            } 
        }
    }
    if (flag == true) {
        printf("NA\n");
    }
}

C++: #include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int *leap_years_list, int year_begin, int year_end);

int main(void)
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

int get_leap_years(int *leap_years_list, int year_begin, int year_end)
{
    int count = 0;//閏年の個数を数える
    for (int year = year_begin; year <= year_end; year++) {//閏年を配列に代入していく
        if (is_leap_year(year)) {
            leap_years_list[count] = year;
            count++;
        }
    }
    return count;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  int a, b;
  while(cin >> a >> b, a || b){
    bool exist = false;
    for(int i = a; i <= b; i++){
      if(i % 400 == 0) { exist = true; cout << i << endl; }
      else if(i % 4 == 0 && i % 100 != 0) { exist = true; cout << i << endl; }
    }
    if(!exist) cout << "NA" << endl;
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

bool is_leap(int x){
	if(x%400==0) return true;
	if(x%100==0) return false;
	if(x%4==0) return true;
	return false;
}

int main(){
	bool first = true;
	int a,b;
	while(cin>>a>>b,a||b){
		bool ok=false;
		if(!first) cout<<endl;
		first=false;
		for(int i=a;i<b+1;i++){
			if(is_leap(i)){
				cout<<i<<endl;
				ok=true;
			}
		}
		if(!ok){
			cout<<"NA"<<endl;
		}
	}
}

C++: #include <stdio.h>
 
void leapyear(int start, int end);
 
int main(void)
{
    int start, end;
    while (1){
        scanf("%d %d", &start, &end);
        if (start == 0 && end == 0){
            break;
        } else {
            // 2回目の出力からは前回の出力とのあいだに空行をおく
            static int first_output = 1;
            if (first_output != 1){
                printf("\n");
            }
            first_output = 0;
 
            leapyear(start, end);
        }
    }
 
    return 0;
}
 
void leapyear(int start, int end)
{
    int cnt = 0;
    for (int year = start; year <= end; year++){
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){
            printf("%d\n", year);
            cnt++;
        }
    }
    if (cnt == 0){
        printf("NA\n");
    }
}