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

int main(){
    int n, m, max;
    int a[1000];

    while(cin >> n >> m){
        max = 0;
        if(n == 0 && m == 0) break;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]+a[j] <= m){
                    if(a[i]+a[j] >= max){
                        max = a[i] + a[j];
                    }
                }
            }
        }
        if(max == 0){
            cout << "NONE";
        }else{
            cout << max << "\n";
        }
    }
}

C++: #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

void solve() {
    while(1) {
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        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(a[i] + a[j] <= m) {
                    ans = max(a[i] + a[j],ans);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

C++: #include<iostream>
int main()
{
  int n,m,k=0;
  int a[100000];
  int ans[50000]={0};
  int max;

  while(n>0 && m>0){
    std::cin>>n>>m;
    if(n==0 && m==0) break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    max=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if(a[i]+a[j]<=m && max<a[i]+a[j]){
	  max=a[i]+a[j];
	}
      }
    }
    ans[k]=max;
    k++;
  }
  for(int i=0;i<k;i++){
    if(ans[i]!=0){
      std::cout<<ans[i]<<'\n';
    }else{
      std::cout<<"NONE"<<'\n';
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


int main() {
	
	while (1) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) { return 0; }
		int a[1919];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (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 <bits/stdc++.h>
using namespace std;

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n, m;

	while( 1 ) {
		cin >> n >> m;
		if( n == 0 && m == 0 ) break;
		int sum = 0;
		vector<int> a( n );
		REP( i, n ) cin >> a[i];
		
		sort( ALL( a ) );
		
		if( a[0] + a[1] > m ) cout << "NONE" << endl;
		else if( a[0] + a[1] == m ) cout << a[0] + a[1] << endl;
		else {
			REP( i, n ) {
				REP( j, n - i - 1) {
					if( a[n - i - 1] + a[j] <= m ) {
						sum = max( sum, a[n - i - 1] + a[j] );
					}
				}
			}
			cout << sum << endl;
		}
	}

}

C++: #include<iostream>
int main()
{
  int n,m,k=0;
  int a[100000];
  int ans[50000]={0};
  int max;

  while(n>0 && m>0){
    std::cin>>n>>m;
    if(n==0 && m==0) break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    max=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if(a[i]+a[j]<=m && max<a[i]+a[j]){
	  max=a[i]+a[j];
	}
      }
    }
    ans[k]=max;
    k++;
  }
  for(int i=0;i<k;i++){
    if(ans[i]!=0){
      std::cout<<ans[i]<<'\n';
    }else{
      std::cout<<"NONE"<<'\n';
    }
  }
  return 0;
}