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>
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<vector>
using namespace std;
int main() {
	int n,m;
	while (cin >> n >> m && n&&m) {
		vector<int> a(n);
		int maxv = 0;
		for (int i = 0; i < n; ++i) cin >> a[i];
		sort(a.begin(), a.end());
		for (int i = 0; i < n - 1; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (a[i] + a[j] <= m) maxv = max(maxv, a[i] + a[j]);
				else break;
			}
		}
		if (maxv) cout << maxv << endl;
		else cout << "NONE" << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;
        vector<ll> a(n);
        for(auto &e: a) cin >> e;
        sort(a.begin(), a.end());

        ll r = -1;
        for(ll i=0; i<n; i++) {
            ll j = upper_bound(a.begin(), a.end(), m-a[i]) - a.begin() - 1;
            if(i == j) j--;
            if(j < 0) continue;
            r = max(r, a[i]+a[j]);
        }
        if(r == -1) cout << "NONE" << endl;
        else cout << r << endl;
    }
}

C++: #include <iostream>

using namespace std;


int main(){
while(1){
	int n,m;
	bool P=false;
	cin>>n>>m;
	if(n==0&&m==0) break;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int max=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j&&a[i]+a[j]<=m&&a[i]+a[j]>max){
				max=a[i]+a[j];
				P=true;
			}
		}
	}

	if(P==false) cout<<"NONE"<<endl;
	else cout<<max<<endl;

}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,m;
    while(true){
        cin>>n>>m;
        if(n+m==0)break;
        vector<ll> v(n);
        rep(i,n){
            cin>>v[i];
        }
        sort(v.rbegin(),v.rend());
        bool f=true;
        ll ans=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
            if(v[i]+v[j]<=m&&v[i]+v[j]>ans) {
                ans = v[i] + v[j];
                f = false;
                
            }
            }
        }
        if(f==true){
            cout<<"NONE"<<endl;
        }else{
            cout<<ans<<endl;
        }

    }





    return 0;
}

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

int main(){
    int n,m;
    int tmp;
    int ans;
    int p[1000];
    std::cin >> n;
    std::cin >> m;

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

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(!n)break;
		int a[n];
		rep(i,n){
			cin>>a[i];
		}
		int ans=0;
		rep(i,n-1){
			REP(j,i+1,n){
				if(a[i]+a[j]<=m&&ans<a[i]+a[j])
					ans=a[i]+a[j];
			}
		}
		if(ans)cout<<ans<<endl;
		else puts("NONE");
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int n, m;
	int maximum;
	for (int i = 0; i < 500000; i++) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> a(n);
		for (int j = 0; j < n; j++) {
			cin >> a[j];
		}
		for (int j = 0; j < n - 1; j++) {
			for (int t = j + 1; t < n; t++) {
				if (a[j] + a[t] <= m) {
					maximum = max(maximum, a[j] + a[t]);
				}
			}
		}
		if (maximum == 0) {
			cout << "NONE" << endl;
		}
		else {
			cout << maximum << endl;
		}
	}

}

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

int main() {
    int n, m;
    while(cin >> n >> m, n + m) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a.begin(), a.end(), greater<int>());

        int ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                if (a[i] + a[j] <= m) {
                    ans = max(a[i] + a[j], ans);
                }
            }
        }
        if (ans < 0) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}