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<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  10:00-
bool solve(void){
	int n,m,i,j;cin>>n>>m;
	if(n==0){return false;}
	vector<int>a(n);
	int ans=-1;
	for(i=0;i<n;i++){cin>>a[i];}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]+a[j]<=m){maxeq(ans,a[i]+a[j]);}
		}
	}
	if(ans==-1){cout<<"NONE"<<endl;}
	else{cout<<ans<<endl;}
	return true;
}
int main(void){
	while(solve()){}
}

C++: #include <iostream>
#include <vector>

int main(){

    int n,m,price,sum,temp_sum;
    sum=0;
    std::vector<int> prices;

    n=m=1;

    while(std::cin>>n>>m,n||m){

    std::cin>>n>>m;

    for(int i=0;i<n;i++){
        std::cin>>price;
        prices.push_back(price);
    }

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

    if(sum==0){
        std::cout<<"NONE"<<std::endl;
    }
    else{
        std::cout<<sum<<std::endl;
    }

}

    return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int main() {
  int n, m;
  while(cin >> n >> m){
    if(n==0) return 0;
    int ans=0;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    rep(i, n)REP(j, i+1, n){
      int t = v[i]+v[j];
      if(t<=m && ans<t) ans=t;
    }
    if(ans==0) cout << "NONE" << endl;
    else cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>

int main()
{
  int n,m;
  int a[1000];
  std::vector<int> ans;
  int max;
  while(std::cin){
    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])>=max&&(a[i]+a[j])<=m){
	  max=a[i]+a[j];
	}
      }
    }
    ans.push_back(max);
  }
  for(int i=0;i<ans.size();i++){
    if(ans[i]>0){
      std::cout<<ans[i];
    }
    else{
      std::cout<<"NONE";
    }
    std::cout<<"\n";
  }
}

C++: #include <iostream>

using namespace std;

int main() {
    int a[1001];
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) { break; }
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[i] + a[j] <= M && a[i] + a[j] > ans) {
                    ans = a[i] + a[j]
                }
            }
        }
        cout << (ans == -1 ? "NONE" : string(ans)) << endl;
    }
    return 0;
}

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

int main(){
    int n, m, max = 0, k = 0;
    int a[1000];
    int ans[50000];

    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        for(int i=0;i<n-1;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];
                    }
                }
            }
        }
        ans[k] = max;
        k++;
    }
    for(int i=0;i<k;i++){
        cout << ans[i] << "\n";
    }
}

C++: /*Problem sennobushige 16D8104015E 18.5.16*/
#include <iostream>
#define N 100000

int main(){
  int n=1,max;
  int A[N]={0},k=0;


  while(n!=0){
    int p=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0)break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=A[k]&&tmp<=max){
	  A[k]=tmp;
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;
    k++;
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
  }



}



/*実行結果
[16D8104015E@ise6bc jisen]$ ./Problem_A
3 45 
10 20 30
6 10
1 2 5 8 9 11
7 100
11 34 83 47 59 29 70
4 100
80 70 60 50
4 20
10 5 10 16
0 0
40
10
99
NONE
20
*/