Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.NextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if a[i]+a[j] <= m {
					ans = intMax(a[i]+a[j], ans)
				}
			}
		}
		if ans == 0 {
			io.Println("NONE")
		} else {
			io.Println(ans)
		}
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<bits/stdc++.h>

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

int n, m;
VI a(1000);
int main() {
    while(std::cin >> n >> m) {
        if(n == 0 && m == 0) break;
        REP(i, n) {
            std::cin >> a[i];
        }

        int ans = 0, cnt = 0;;
        REP(i, n) REP(j, n) {
            if(i == j) continue;
            if(a[i] + a[j] <= m) {
                ans = std::max(ans, a[i] + a[j]);
                ++cnt;
            }
        }
        if(cnt == 0) {
            std::cout << "NONE" << std::endl;
        } else {
            std::cout << ans << std::endl;
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main() {
    ll n, m;
    while(cin >> n >> m, n) {
        vector<ll> a(n);
        for(auto &x:a) cin >> x;
        ll ans = -1;
        for(int i = 0; i < n - 1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(a[i] + a[j] <= m)
                    ans = max(ans, a[i] + a[j]);
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    } 
}

C++: 
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  int m;
  int sum=0;
  int flg=0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i]+a[j]>sum && a[i]+a[j]<=m && i!=j)
	{
	  sum = a[i]+a[j];
	  flg = 0;
	} 
      else
	{
	  if(sum==0)
	    {
	      flg=1;
	    }
	}
    }
  }
  if(flg==0)
    {
      cout << sum << endl;
    }
  if(flg==1)
    {
      cout << "NONE" << endl;
    }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstdlib>
#include<cmath>

using namespace std;

#define MAX_V 100001
#define INF (1e9 + 1)
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define REV(i,n) for(long long int (i)=(n-1);(i) > -1;(i)--)

int N,M;
int a[1001];

void solve(){
  int mx = -1;
  REP(i,N){
    for(int j=i+1;j<N;j++){
      if(a[i]+a[j]<=M && a[i]+a[j]>mx) mx = a[i]+a[j];
    }
  }
  if(mx==-1) cout << "NONE" << endl;
  else cout << mx << endl;
}

int main(){
  while(true){
    scanf("%d %d",&N,&M);
    if(N==0&&M==0)break;
    REP(i,N) cin >> a[i];
    solve();
  }

  return 0;
}

C++: #include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

    for(int i=0; i<n; i++){
      std::cin >> price[i];
    }

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
  while(1){
    int n , m;
    cin >> n;
    cin >> m;
    if(n == 0 && m == 0){
      return 0;
    }

    int a[n];
    for(int i = 0 ; i < n ; i ++){
      cin >> a[i];
    }

    int sum[n][n];

    for(int i = 0 ; i < n ; i ++){
      for(int j = 0 ; j < n ; j++){
        if(i != j){ sum[i][j] = a[i] + a[j]; }
        else{ sum[i][j] = -1000; }
      }
    }

    int max = -1000;

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        if( sum[i][j] > max && sum[i][j] < m ){
          max = sum[i][j];
        }
      }
    }

    if(max == -1000){
      cout << "NONE" << endl;
    }else{
      cout << max;
    }
  }

}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=-1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(m>=a[i]+a[j])ans=max(ans,a[i]+a[j]);
            }
        }
        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}