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<stdio.h>
#include<string>
#include <iostream>

using namespace std;

int main(){
  int n, max;
  int price[50000];
  int i, j;

  while(1){
    cin >> n >> max;
    if(n == 0)
      break;
    
    for(i=0; i<n; i++){
      cin >> price[i];
    }

    int max_after=0;

    for(i=0; i<n; i++){
      for(j=i+1; j<n; j++){
	if(price[i]+price[j] <= max && price[i]+price[j] > max_after)
	  max_after = price[i]+price[j];
      }
    }

    if(max_after == 0){
      cout << "NONE" << endl;
    }else  cout << max_after << endl;

  }
}

C++: #include <iostream>

int main(void)
{
    int i, j, num, lim, price[1000], temp, max;

    for(;;) {
        cin >> num;
        cin >> lim;
        if(num == 0 && lim == 0) {
            return 0;
        }
        for(i = 0; i < num; i++) {
            cin >> price[i];
        }
        max = 0;
        for(i=0; i < num - 1; i++) {
            for(j = i + 1; j < num; j++) {
                temp = price[i] + price[j];
                if(temp > max && temp <= lim) {
                    max = temp;
                }
            }
        }
        if(max == 0) {
            cout << "NONE\n";
        }
        else {
            cout << max << "\n";
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,m,i,j,mx,x,a[1000];
	while(1)	{
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)	break;
		for(i=0;i<n;i++)	scanf("%d",&a[i]);
		mx=0;
		for(i=0;i<n-1;i++)	{
			for(j=i+1;j<n;j++)	{
				if(a[i]+a[j]<=m)	{
					mx=max(mx,a[i]+a[j]);
				}
			}
		}
		if(mx!=0)	printf("%d\n",mx);
		else printf("NONE\n");
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int solve(vector<int> a,int x){
  int max=0;
  for(int i=0;i<a.size();i++){
    for(int j=i;j<a.size();j++){
      if(a[i]+a[j]>max && a[i]+a[j]<=x){
	max=a[i]+a[j];
      }
    }
  }
  if(max>0){
     return max;
  }else{
    return 0;
  }    
}

int main(){
  int n,m,s,max_n=0;
  vector<int> a,b;
  while(n!=0 && m!=0){
    cin>>n;
    cin>>m;
    for(int i=0;i<n;i++){
      cin>>s;
      a.push_back(s);
    }
    b.push_back(solve(a,m));
    a={0};
  }
  cout<<"\n";
  for(int i=0;i<b.size()-1;i++){
    if(b[i]==0){
      cout<<"NONE"<<"\n";
    }else{
      cout<<b[i]<<"\n";
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;

int main() {
    while(1) {
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector<int> avec(n, 0);
        for(int i = 0; i < n; ++i) cin >> avec[i];
        int ans = -1;
        for(int i = 0; i < n; ++i) {
            for(int j = i+1; j < n; ++j) {
                int sum = avec[i]+avec[j];
                if(sum <= m) {
                    chmax(ans, sum);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

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

using i64 = int64_t;

int main(){
    int n, m;
    while(cin >> n >> m, n != 0){
        vector<i64> v;
        for(int i=0;i<n;++i){
            i64 a;
            cin >> a;
            v.push_back(a);
        }
        i64 ans = -1;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                if(v[i] + v[j] <= m && ans < v[i] + v[j]){
                    ans = v[i] + v[j];
                }
            }
        }
        if(ans == -1)cout << "NONE" << endl;
        else cout << ans << endl;
    }

    return 0;
}

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 "bits/stdc++.h"

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int n, m, value;
	vector<int> vec;
	while (1) {
		cin >> n >> m;
		if (n == 0 and m == 0) {
			break;
		}
		value = 0;
		vec.resize(n);
		for (int i = 0; i < n; i++) {
			cin >> vec[i];
		}
		sort(vec.begin(), vec.end(), greater<int>());
		for (auto itr = vec.begin(); itr < vec.end(); itr++) {
			for (auto itr2 = itr+1; itr2 < vec.end(); itr2++) {
				int tmp = *itr + *itr2;
				if (tmp <= m and value < tmp) {
					value = tmp;
				}
			}
		}
		if (value != 0) {
			cout << value << endl;
		} else {
			cout << "NONE" << endl;
		}
		vec.resize(0);
	}

	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}