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>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vl = vector<ll>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using vs = vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.141592653589793

template<class S, class T>ostream&operator<<(ostream&os, pair<S, T>p)
{
	os << "[" << p.first << "," << p.second << "]"; return os;
}
template<class S>auto&operator<<(ostream&os, vector<S>t)
{
	bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; }
	return os;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	while (cin >> n >> m, n) {
		vi v(n);
		ll max = -1;
		rep(i, n) {
			cin >> v[i];
		}
		rep(i, n) {
			rep(j, n) {
				if (i == j) continue;
				if (v[i] + v[j] > max&&v[i] + v[j] <= m) {
					max = v[i] + v[j];
				}
			}
		}
		if (max == -1) {
			cout << "NONE" << endl;
		}
		else {
			cout << max << endl;
		}
	}
	return 0;
}

C++: int main(){
  int n,m;
  int A[10000];
  int B[10000];
  int max;
  
  while(1){
    std::scanf("%d %d",&n,&m);
    if(n == 0 && m == 0) break;
    bool flag = 1;
    for(int i = 0;i < n;i++){
      std::scanf("%d",&A[i]);
    }

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

    if(!flag){
      std::printf("%d\n",max);
    }else{
      std::printf("NONE\n");
    }
    
    std::scanf("%d %d",&n,&m);
  }
  
  return 0;
}

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n==0 && m==0) {
      break;
    }
    int a[n];
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    int ans = -INT_MAX;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	if (i!=j && a[i]+a[j]<=m) {
	  ans = max(ans,a[i]+a[j]);
	}
      }
    }
    if (ans<0) {
      cout << "NONE" << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
static const int  NMAX = 1000;

static const int INFTY = (1 << 29);
using namespace std;

int main(){
    int n,m,maxPrice;
    int product[NMAX];
    while(true){
      maxPrice = -1;
      cin >> n >> m;
      if(n == 0 && m == 0) break;

      for(int i = 0; i < n ; i++){
        cin >> product[i];
      }
      for(int i = 0; i < n ; i++){
        for(int j = i + 1 ; j < n ; j++){
          if(product[i] + product[j] <= m) maxPrice = max((product[i] + product[j]),maxPrice);
        }
      }
      if(maxPrice == -1) cout << "NONE" << endl;
      else cout << maxPrice << endl;
    }
  return 0;
}

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

int main() {
	
	int n, m;
	int count = 0;
	
	while (1)
	{
		int max = 0;
		int sum;
		
		std::cin >> n >> m;
		
		if ( n == 0 && m == 0) break;
		
		count++;
		int a[n];
		
		// 入力
		for (int i = 0; i < n; i++)	std::cin >> a[i];
		
		for (int i = 0; i < n; i++) {
			
			for (int j = i + 1; j < n; j++) {
				
				sum = a[i] + a[j];
				
				// 合計値が容量を下回るときのみ
				if ( sum <= m )
				{
					// 現在の最大値より大きいとき
					if ( sum > max ) 
					{
						max = sum;
					}
				}
				
			}
		}
		
		// 結果出力
		if ( max == 0) std::cout << "NONE" << std::endl;
		else		   std::cout <<   max  << std::endl;
		
	}
	
	/*
	for (int i = 0; i < count; i++) {
		cout <<  << endl;
	}
	
	*/
	
	return 0;
}

C++: #include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    while(true){
        int n, m;
        cin >> n >> m;

        if(n == 0 && m == 0){
            break;
        }

        vector<int> a(n);
        rep(i, n) cin >> a[i];

        int ans = -1;
        rep(i, n){
            rep(j, n){
                if(i == j){
                    continue;
                }

                int tmp = a[i] + a[j];
                if(tmp > ans && tmp <= m){
                    ans = tmp;
                }
            }
        }
        if(ans == -1){
            cout << "NONE" << endl;
        }else{
            cout << ans << endl;
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;
int main() {
  while (true) {
    long long n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
      cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        if (ans < a[i] + a[j] && a[i] + a[j] <= m) {
          ans = a[i] + a[j];
        }
      }
    if (ans)
      cout << ans << endl;
    else
      cout << "NONE" << endl;
  }
  return 0;
}