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<cstdio>

int main(){
  int n,m;
  int A[10000];
  int B[10000];
  int cnt = 0;
  int max;

  std::scanf("%d %d",&n,&m);
  
  while(!(n == 0 && m == 0)){
    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)){
      B[cnt] = max;
    }else{
      B[cnt] = -1;
    }
    cnt++;
    std::scanf("%d %d",&n,&m);
  }
  
  for(int i = 0;i < cnt;i++){
    if(B[i] != -1){
      std::printf("%d\n",B[i]);
    }else{
      std::printf("NONE\n");
    }
  }
  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n,m;
  while(cin>>n>>m,n){
  ll a[1111];
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
	  ll tmp=a[i]+a[j];
	  if(tmp>m)continue;
	  ans=max(ans,tmp);
	}
  }
  if(ans)cout<<ans<<endl;
  else cout<<"NONE"<<endl;
  }
  return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, a[200005],res=0;
	cin >> n >> m;
	while (1) {
		res = 0;
		if (n == 0 && m == 0) { return 0; }
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m && a[i] + a[j] > res) {
					res = a[i] + a[j];
				}
			}
		}
		if (res == 0) { cout << "NONE" << endl; }
		else { cout << res << endl; }
		cin >> n >> m;
	}

}

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

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

int main() {
	int n, m;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		int sum=0,maxv=0;
		//bool flag = true;
		vector<int> a(n);
		for (int i = 0; i < n; i++)cin >> a[i];

		sort(a.begin(), a.end());
		for (int i = n-1; i >= 0; i--) {
			for (int j = n-2; j >= 0; j--) {
				if (i != j)  sum += a[i] + a[j];
				if (max(maxv, sum) == sum && sum <= m) {
					maxv = sum;
					sum = 0;
					//flag = false;
				} else {
					sum = 0;
				}
			}
		}
		if (maxv==0)cout << "NONE" << endl;
		else cout << maxv << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

// using ll = long long;
// using P = pair<int, int>;
// using minpq = priority_queue<int, vector<int>, greater<int> >;


int main() {
    while (true) {
        int n,m;
        cin>>n>>m;
        if(n==0&&m==0)break;
        vector<int>a(n);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        int MAX = -1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a.at(i)+a.at(j)<=m){
                    MAX = max(MAX, a.at(i)+a.at(j));
                }
            }
        }
        if(MAX == -1){
            cout<<"NONE"<<endl;
        }
        else{
            cout<<MAX<<endl;
        }
    }
    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, m;
    int a[1000];
    while(true){
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        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(ans, a[i] + a[j]);
            }
        }
        if(ans >= 0) printf("%d\n", ans);
        else printf("NONE\n");
    }
    
    return 0;
}