Language: C++

//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

ll n,m;
ll t[10000];
const int MA=1000000;
ll s1[MA];
ll s2[MA];


int main(){

while(cin>>n>>m,n||m){
rep(i,MA)s1[i]=s2[i]=0;
rep(i,10000)t[i]=0;

for(int i=1;i<=n;i++)cin>>t[i];
int g=0;

for(int i=0;i<=n;i++){
	for(int j=0;j<=n;j++){
		s1[i*(n+1)+j]=t[i]+t[j];
		g++;
	}
}


sort(s1,s1+g);
rep(i,g)s2[i]=s1[i];

int ans=0;

for(int i=0;i<g;i++){
	int now=s1[i];

	int l=0;
	int r=g-1;
	int mid=(l+r)/2;
	int x=s2[mid];

	for(int i=0;i<70;i++){
		if(x+now==m)break;
		if(l>r)break;
		if(x+now>m){
			r=mid;
			mid=(r+l)/2;
			x=s2[mid];
		}
		else{
			l=mid;
			mid=(r+l)/2;
			x=s2[mid];
		}
	}

	//cout<<" "<<x<<" "<<now<<" "<<x+now<<endl;
	if(x+now<=m)
	ans=max(ans,x+now);
}
cout<<ans<<endl;
}
	return 0;
}



Compiler output:
a.cc:19:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   19 | #define ll __int64
      |            ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
   21 | ll n,m;
      | ^~
a.cc:19:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   19 | #define ll __int64
      |            ^~~~~~~
a.cc:22:1: note: in expansion of macro 'll'
   22 | ll t[10000];
      | ^~
a.cc:19:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   19 | #define ll __int64
      |            ^~~~~~~
a.cc:24:1: note: in expansion of macro 'll'
   24 | ll s1[MA];
      | ^~
a.cc:19:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   19 | #define ll __int64
      |            ^~~~~~~
a.cc:25:1: note: in expansion of macro 'll'
   25 | ll s2[MA];
      | ^~
a.cc: In function 'int main()':
a.cc:30:12: error: 'n' was not declared in this scope
   30 | while(cin>>n>>m,n||m){
      |            ^
a.cc:30:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   30 | while(cin>>n>>m,n||m){
      |               ^
      |               tm
a.cc:31:10: error: 's1' was not declared in this scope
   31 | rep(i,MA)s1[i]=s2[i]=0;
      |          ^~
a.cc:31:16: error: 's2' was not declared in this scope
   31 | rep(i,MA)s1[i]=s2[i]=0;
      |                ^~
a.cc:32:13: error: 't' was not declared in this scope
   32 | rep(i,10000)t[i]=0;
      |             ^
a.cc:34:27: error: 't' was not declared in this scope
   34 | for(int i=1;i<=n;i++)cin>>t[i];
      |                           ^
a.cc:39:17: error: 's1' was not declared in this scope
   39 |                 s1[i*(n+1)+j]=t[i]+t[j];
      |                 ^~
a.cc:39:31: error: 't' was not declared in this scope
   39 |                 s1[i*(n+1)+j]=t[i]+t[j];
      |                               ^
a.cc:45:6: error: 's1' was not declared in this scope
   45 | sort(s1,s1+g);
      |      ^~
a.cc:46:9: error: 's2' was not declared in this scope
   46 | rep(i,g)s2[i]=s1[i];
      |         ^~
a.cc:56:15: error: 's2' was not declared in this scope
   56 |         int x=s2[mid];
      |               ^~