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++: #include <iostream>
using namespace std;
int main(void){
    int a, b;
    for(int i=0; i < 55; i++){
      cin >> a >> b;
      if(a==0 && b==0){
          break;
      }
      if(i != 0){
          cout << endl;
      }
      if(a%4 == 0){
          if(a+4 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+4 <= b){
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                  if(a%400 != 0 && a%100 == 0){
                    a += 4;
                  }else{
                    cout << a << endl;
                    a+=4;
                  }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 1){
          if(a+3 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+3 <= b){
              a += 3;
              int c;
              c= b-a;
              for(int j=0; j <= c/4 ; j++){
                if(a%400 != 0 && a%100 == 0){
                a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 2){
          if(a+2 == b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+2 <= b){
              a += 2;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                  a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
      
      if(a%4 == 3){
          if(a+1 <= b && a%400 != 0 && a%100 == 0){
              cout << "NA" << endl;
          }else if(a+1 <= b){
              a += 1;
              int c;
              c = b-a;
              for(int j=0; j <= c/4; j++){
                if(a%400 != 0 && a%100 == 0){
                  a+=4;
                }else{
                  cout << a << endl;
                  a+=4;
                }
              }
          }else{
              cout << "NA" << endl;
          }
      }
    }
    
}

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

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

int a, b;
V vi;

int main(){
	while (cin >> a >> b&&a+b){
		for (int i = a; i <= b; i++){
			if (i % 4 == 0){
				if (i % 100 == 0){
					if (i % 400 == 0){
						vi.push_back(i);
					}
					continue;
				}
				vi.push_back(i);
			}
		}
		if (vi.empty())cout << "NA" << endl;
		REP(i, vi.size()){
			cout << vi[i] << endl;
		}
		cout << "" << endl;
		cout << "" << endl;
		vi.clear();
	}
}

C++: #include <iostream>

int LeapYear (int x);
int main()
{
    int a,b;
    std::cin >> a >> b;
    while (true) {
        int n = 0;
        if (a == 0 && b == 0) {
	        break;
        } else {
            for (int i = a; i <= b; i++) {
                if (LeapYear (i) == 1) {
                    std::cout << i <<std::endl;
                    n++; 
            }				
        }
        if (n == 0) {
            std::cout << "NA" << std::endl;
        }
        std::cin >> a >> b;
        }
    }
    return 0;
}

int LeapYear (int x)
{
    if (x % 400 == 0) {
    return 1;
    } else if (x % 100 == 0) {
    return 0;
    } else if (x % 4 == 0) {
    return 1;
    }else {
    return 0;
    }
}

C++: #include <iostream>

bool judgeUruyear(int year)
{

    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }

}

//int flag = 0;

void printUruyear(int year_begin, int year_end)
{

  //  if(flag == 1){
        std::cout << std::endl;
    //}
    //flag = 1;

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou
    for (int i = year_begin; i <= year_end; i++) {
        
        if (judgeUruyear(i)) {

            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if (count_year == 0) { 
        std::cout << "NA" << std::endl;
    }
    
}

int main()
{
    int year_begin, year_end;

    while (true) {

        std::cin >> year_begin >> year_end;

        if (year_begin == 0 && year_end == 0) {
            break;
        }

        printUruyear(year_begin, year_end);
    }
    
    return 0;
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1877346#1

C++: #include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int year_f,year_l;
    bool fast_f=false;
    bool flag;

    while(cin>>year_f>>year_l,year_f&&year_l){
        flag=true;
        if(fast_f){
            cout<<"\n";
        }
        fast_f=true;
        for(i=year_f;i<year_l;i++){
            if((!(i%4)&&(i%100))||!(i%400)){
                cout<<i<<endl;
                flag=false;
            }
        }
        if(flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
    
}

C++: #include <stdio.h>

int leap_year(int, int);

int main(void)
{
	int a, b;
	int i = 0;
	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}
		if (i++) {
			printf("\n");
		}
		leap_year(a, b);
	}
	return 0;
}

int leap_year(int a, int b)
{
	int leap_year_number = 0;
	for (int i = a; i <= b; i++) {
		if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
			printf("%d\n", i);
			leap_year_number += 1;
		}
	}
	if (leap_year_number == 0) {
		printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
		int a,b;
		cin>>a>>b;
		if(a==0 && b==0){break;}
		int cnt=0;
		for(int i=a;i<=b;i++){
			if(i%400==0){cout<<i<<endl;cnt++;}
			else if(i%4==0 && i%100>=1){cout<<i<<endl;cnt++;}
		}
		if(cnt==0){cout<<"NA"<<endl;}
		cout<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b,count;
  while(cin >>a>>b){
    count=0;
    if(a==0&&b==0)break;
    for(int i=a;i<=b;i++){
      
      if( i%4==0){

	if(i%400==0 ){
	  cout <<i<<endl;count++;}
      else if( i%100!=0){
	cout <<i<<endl;count++;}
    
      }
    }
	
    
      
    if(count==0)cout<<"NA"<<endl;
  }
  return 0;

      
  }