akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int a = 0, b = 0;
	string s;
	bool t1 = 1, t2 = 1, t3 = 1;

	cin >> a >> b;
	cin >> s;

	for (int i = 0; i < a; i++)
		if (!isdigit(s[i])) {
			t1 = 0;
			break;
		}

	if (s[a] != '-')
		t2 = 0;

	for (int i = 0; i < b; i++)
		if (!isdigit(s[i + a + 1])) {
			t3 = 0;
			break;
		}	
	if (s.size() == a + b + 1 && t1 && t2 && t3)
			cout << "Yes" << endl;	
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[16];
  int i,co=0,len;
  scanf("%s",s);
  len=strlen(s);
  for(i=0;i<len;i++){
    if(s[i]=='x'){
      co++;
    }
  }
  if(co>=8){
    printf("NO");
  }
  else{
    printf("YES");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	  for(auto &e:u) fill_v<T>(e,v...);
}

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

  string s;
  int64 K;
  cin >> s >> K;
  auto dp = make_v<int64>(s.size()+1, s.size()+1, K+1); // [l, r]で作れるアの最大値
  REP(k, K+1) {
    REP(w, s.size()) {
      REP(l, s.size() - w) {
        int64 r = l + w;
        if (k+(s[l] != s[r]) <= K) {
          if (l == r)
            chmax(dp[l][r][k + (s[l] != s[r])], 1);
          else
            chmax(dp[l][r][k + (s[l] != s[r])], dp[l+1][r-1][k] + 2);
        }
        if (l+1 <= s.size())
          chmax(dp[l][r][k], dp[l+1][r][k]);
        if (r-1 >= 0)
          chmax(dp[l][r][k], dp[l][r-1][k]);
      }
    }
  }
  int64 res = 0;
  REP(i, s.size()) {
    REP(j, s.size()) {
      REP(k, K+1) {
        chmax(res, dp[i][j][k]);
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 216832
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0) printf("Positive\n");
    else if(a<0&&b<0){
        if((b-a)%2) printf("Positive\n");
        else printf("Negative\n");
    }
    else printf("Zero\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

long fizzBizzSum(long v);
long sum_step(long end, long step);

int main(void) {
    long v;
    long sum;
    
    std::cin >> v;
    
    sum = fizzBizzSum(v);
    
    std::cout << sum << std::endl;
    
    return 0;
}

long fizzBizzSum(long v) {
    long sum, sum_fizzBizz, sum_fizz, sum_bizz;
    
    sum = sum_step(v, 1);
    sum_fizzBizz = sum_step(v, 15);
    sum_fizz = sum_step(v, 3) - sum_fizzBizz;
    sum_bizz = sum_step(v, 5) - sum_fizzBizz;
    
    return sum - sum_fizzBizz - sum_fizz - sum_bizz;
}

long sum_step(long end, long step) {
    // 0*step + 1*step + 2*step + ... + (end/step)*step
    long N = end/step;
    
    return N * (N+1) / 2 * step;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int r, d, x ;
  cin >> r >> d >> x ;
  vector<int> vec(11) ;
  vec.at(0) = x ;
  
  REP(i, 10){
    vec.at(i+1) =r*vec.at(i) - d ;
    cout << vec.at(i+1)<<endl ;
  }
  
    return 0 ;
}




Measured memory_bytes: 256
//by szh
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int x,y;
ll tmp[200010];

ll PoW(ll base,int x) {
	ll res=1;
	while (x) {
		if (x%2==1) res=(res*base)%mod;
		base=(base*base)%mod;
		x/=2;
	}
	return res;
}

ll calc(int x,int y) {
	if (y==0||x==y) return 1;
	return tmp[x]*PoW(tmp[y],mod-2)%mod*PoW(tmp[x-y],mod-2)%mod;
}

int main(){
	cin>>x>>y;
	tmp[1]=1;
	for (int i=2;i<200010;i++) tmp[i]=(tmp[i-1]*(ll)i)%mod;
	ll ans=0;
	for (int i=max(1,x-y);i<=x;i++) {
		ans+=calc(x,i)*calc(x-1,i-1)%mod;
		ans%=mod; 
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 1e5 + 5;

int a[N], b[N], out_degree[N];
vector<pair<int, int>> g[N];
vector<bool> seen(N, false);

void dfs(int u, int id);
				
int32_t main() {
	fast_cin();  
	int n, m; cin >> n >> m;
	if (m & 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i <= m; ++i) {
		cin >> a[i] >> b[i];
		g[a[i]].push_back({b[i], i});
		g[b[i]].push_back({a[i], i});
		++out_degree[a[i]];
	}
	dfs(1, 0);
	for (int i = 1; i <= m; ++i) {
		cout << a[i] << " " << b[i] << endl;
	}
}

void dfs(int u, int id) {
	seen[u] = true;
	for (auto &e : g[u]) {
		auto [v, n_id] = e;
		if (!seen[v]) {
			dfs(v, n_id);
		}
	}
	if (out_degree[u] & 1) {
		assert(id != 0);
		--out_degree[a[id]], ++out_degree[b[id]];
		swap(a[id], b[id]);
	}
}

Measured memory_bytes: 17664
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  vs vec;
  rep(i,0,3){
    cin >> s;
    vec.pb(s);
  }
  n = m = l = 0;
  ll p = 0;
  while(1){
    //print(p);
    if(n == vec[0].sz+1){
      puts("A");
      break;
    }else if(m == vec[1].sz+1){
      puts("B");
      break;
    }else if(l == vec[2].sz+1){
      puts("C");
      break;
    }
    switch(p){
      case 0:p = vec[p][n++]-'a';break;
      case 1:p = vec[p][m++]-'a';break;
      case 2:p = vec[p][l++]-'a';break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<n;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define mod 10000000007
#define modpro 99824435
using namespace std;

void solve(){
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int count=0;
	F(0,n,i){
		if(s[i]!=t[i]) count++;
	}
	cout<<count;
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  string s;
  int k;
  cin >> s >> k;

  int idx=INF;
  char c;
  REP(i, s.size()) {
    if(s[i]!='1') {
      idx = i;
      c = s[i];
      break;
    }
  }

  if(idx==INF) {
    cout << 1 << endl;
  } else {
    if(k <= idx) {
      cout << 1 << endl;
    } else {
      cout << c << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX_LEN 20
#define MAX_CNT 10

int compare_int(const void* a, const void* b);

int main(){
	char buf[MAX_LEN];
	int table[MAX_CNT];
	int i;
	i=0;
	while((fgets(buf,MAX_LEN,stdin)!=NULL)&&(i<10)){
		if(sscanf(buf,"%d",&table[i])<=0){
			fprintf(stderr,"error:invalid input\n");
		}else{
			i++;
		}
	}
	
	qsort( table, MAX_CNT, sizeof(int), compare_int );
	for(i=0;i<3;++i){
		printf( "%d\n",table[i] );
	}
	return 0;
}

int compare_int(const void* a, const void* b){
	return ( *(int*)b - *(int*)a );
}

Measured memory_bytes: 0
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            cnt = 0
            for k in range(i - 1, i + 2):
                for l in range(j - 1, j + 2):
                    if 0 <= k < h and 0 <= l < w:
                        if s[k][l] == "#":
                            cnt += 1
            s[i][j] = cnt

for i in range(h):
    print("".join(map(str, s[i])))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
map<ll, int> factor;
/* function */
void primeFactorization(ll n) {
    ll x = n;
    if (x < 2) {
        return ;
    }
    for (ll i = 2; i*i <= n; i++) {
        while (x%i == 0) {
            factor[i]++;
            x /= i;
        }
    }
    if (x != 1)
        factor[x]++;
    return;
}
int calc(int x) {
    int ret = 0;
    for (; ret*(ret+1)/ 2 <= x; ret++) {}
    return ret - 1;
}
/* main */
int main(){
    ll n;
    cin >> n;
    primeFactorization(n);
    int ans = 0;
    for (auto m : factor) { ans += calc(m.second); }
    cout << ans << '\n';
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        for (int i = 0; i < b; i++){
            cout << a;
        }
        cout << endl;
    }else{
        for (int i = 0; i < a; i++){
            cout << b;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 3010

int dp[MAXN][MAXN];
int lcs(const string &a, const string &b, int n, int m)
{
    if (n >= a.size() || m >= b.size())
    {
        return 0;
    }
    if (dp[n][m] != -1)
        return dp[n][m];
    if (a[n] == b[m])
    {
        dp[n][m] = 1 + lcs(a, b, n + 1, m + 1);
    }
    else
    {
        dp[n][m] = max(lcs(a, b, n + 1, m), lcs(a, b, n, m + 1));
    }

    return dp[n][m];
}
void solve()
{
    s(dp, -1);
    string a, b;
    cin >> a >> b;
    int an = lcs(a, b, 0, 0);
    string ans = "";
    int i = 0, j = 0;
    while (i < a.size() && j < b.size())
    {
        if (a[i] == b[j])
        {
            ans += a[i];
            i++;
            j++;
        }
        else if (dp[i + 1][j] > dp[i][j + 1])
        {
            i++;
        }
        else
        {
            j++;
        }
    }
    cout << ans << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    // cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 39500
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(){
	std::bitset<64> flag;
	int q;
	int com, n;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com;
#else
		std::cin >> com;
#endif
		if(com >= 0 && com <= 3){
#if INPUT_FROM_FILE
			ifs >> n;
#else
			std::cin >> n;
#endif
			if(com == 0){
				if(flag.test(n)){
					std::cout << "1" << std::endl;
				}
				else{
					std::cout << "0" << std::endl;
				}
			}
			else if(com == 1){
				flag.set(n);
			}
			else if(com == 2){
				flag.reset(n);
			}
			else{
				flag.flip(n);
			}
		}
		else if(com == 4){
			if(flag.all()){
				std::cout << "1" << std::endl;
			}
			else{
				std::cout << "0" << std::endl;
			}
		}
		else if(com == 5){
			if(flag.any()){
				std::cout << "1" << std::endl;
			}
			else{
				std::cout << "0" << std::endl;
			}
		}
		else if(com == 6){
			if(flag.none()){
				std::cout << "1" << std::endl;
			}
			else{
				std::cout << "0" << std::endl;
			}
		}
		else if(com == 7){
			std::cout << flag.count() << std::endl;
		}
		else if(com == 8){
			std::cout << flag.to_ulong() << std::endl;
		}
	}
   
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;



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

    int n; cin >> n;
    int pos;
    vector<ll> x(n), y(n), h(n);
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) pos = i;
    }
    ll height;
    rep(i, 101)rep(j, 101){
        height = h[pos] + abs(x[pos] - i) + abs(y[pos] - j);
        bool flag = true;
        rep(k, n){
            if(h[k] > 0 and height - h[k] != abs(x[k] - i) + abs(y[k] - j)){
                flag = false;
            }
            if(h[k] == 0 and height > abs(x[k] - i) + abs(y[k] - j)){
                flag = false;
            }
        }
        if(flag) cout << i << " " << j << " " << height << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n,a,b;
ll q,x;

int main(){
	cin >> n;
	a = 1;
	b = 0;
	for(int i=0;i<n;i++){
		cin >> q >> x;
		if(q == 1){
			a *= x;
			b *= x;
		}else if(q == 2){
			b += x;
		}else{
			b -= x;
		}
	}
	cout << -1 * b << " " << a << endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
int solve(int, int,int *,int);
int main()
{
  int i,n,q;
  int A[2000],M[2000];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }
 
  for(i=0;i<q;i++){
    if(solve(0,M[i],A,n)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  return 0;
}
 
int solve(int i,int m,int *A,int n)
{ 
  int S=0;
  if(m==0)return 1;
  if(i>=n)return 0;
  else{
  S+=solve(i+1,m,A,n);
  S+=solve(i+1,m-A[i],A,n); 
  }
  return S;
}


Measured memory_bytes: 2036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define NUM 20001
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int b[20000];
int main(void)
{
	int n,p,i;
	scanf("%d",&n);
	FOR(i,0,n){
		printf("%d%c",NUM*(i+1),i==n-1?'\n':' ');
		b[i]=NUM*(n-i);
	}
	FOR(i,0,n){
		scanf("%d",&p);
		b[p-1]+=i;
	}
	FOR(i,0,n) printf("%d%c",b[i],i==n-1?'\n':' ');
	return 0;
}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }else if(n<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<k)
	cout<<n*x;
	if(n==k)
	cout<<n*x;
	if(n>k)
	{
		int c=n-k;
		cout<<k*x+c*y;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << endl

using namespace std;
typedef long long LL;
typedef pair<int, int> P;


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  int f=0, s=0;
  cin >> a >> b >> c;
  if(a == 5) f++;
  if(a == 7) s++;
  if(b == 5) f++;
  if(b == 7) s++;
  if(c == 5) f++;
  if(c == 7) s++;
  if(f==2 && s ==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main(){
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                       

using namespace std;
using ll = long long;

const int MAX = 2e3;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);
    cout << c * 10 + b + a;
    return 0;
}                                                               
    
                

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main() {
	char s[11];
	bool isCExist = false;
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		if (i == 0) {
			if (s[0] != 'A') {
				printf("WA\n");
				return 0;
			}
		} else if (2 <= i && i <= strlen(s) - 2 &&
			!isCExist && s[i] == 'C') {
			isCExist = true;
		} else if ('a' <= s[i] && s[i] <= 'z') {
			;
		} else {
			printf("WA\n");
			return 0;
		}
	}
	printf("%s\n", isCExist ? "AC" : "WA");
	return 0;
}

Measured memory_bytes: 128
/*
 * @Author: Kaizyn
 * @Date: 2020-08-27 13:47:53
 * @LastEditTime: 2020-08-27 14:45:25
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 3e2+7;

int n;
long long a[N];

inline long long solve() {
  cin >> n;
  long long presum = 0, sufsum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sufsum ^= a[i];
  }
  sufsum ^= a[1]^a[2];
  presum = a[1]+a[2];
  if (presum < sufsum) return -1;
  presum -= sufsum;
  if (presum&1) return -1;
  presum >>= 1;
  if (presum&sufsum) return -1;
  // a[1] += presum, a[2] += presum
  // distribute sufsum to a[1], a[2]
  if (presum >= a[2]) return presum-a[2];
  a[2] -= presum;
  if (sufsum < a[2]) return -1;
  if ((sufsum&a[2]) == a[2]) return 0;
  // get subset from sufsum >= a[2]
  long long res = sufsum-a[2], cur = 0;
  for (int i = 40; i >= 0; --i) if ((sufsum>>i)&1) {
    if (cur+(1ll<<i) <= a[2]) {
      cur += (1ll<<i);
    } else {
      res = min(res, cur+(1ll<<i)-a[2]);
    }
  }
  if (cur == a[2]) res = 0;
  if (res == a[1]) return -1; // a[1] = 0
  return res;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define EPS 1e-5
int main(void){
  double q,x;
  int times;


  while(cin >> q){
	if(q == -1) break;
	x = q / 2;
	
	while(fabs(pow(x,3) - q) >= EPS * q){
	  x = x - (pow(x, 3) - q) / (3 * pow(x,2)); 
	}
	printf("%.6f\n", x);
  }
}

Measured memory_bytes: 0
x = int(input())


c = 0
l = []
idx = []
bre = False
for i in range(-1800, 1800):
    idx.append(i)
    l.append(i**5)


for i in range(len(l)):
    if bre:
        break
    for j in range(len(l)):
        if l[i]-l[j] == x:
            a = i
            b = j
            bre = True
            break
    
    
    

print(idx[a], idx[b])

Measured memory_bytes: 9428
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {

	int x;

	cin >> x;

	int m = 1;


	for (int i = 2; i <= sqrt(x); i++) {
		int j = i;
		while (j <= x) {
			m = max(j, m);
			j *= i;
		}
	}

	
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

H,A = II()

print(math.ceil(H/A))

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int i=2; i<X; i++) {
    int tmp = i*i;
    bool stop = true;
    while (tmp <= X) {
      ans = max(ans, tmp);
      tmp *= i;
      stop = false;
    }
    if (stop) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int N; cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  sort(all(d));
  ll res=0;
  rep(i,100001){
    int lower_num = lower_bound(all(d),i) - d.begin();
    int upper_num = d.end() - lower_bound(all(d),i);
    if (lower_num == upper_num) res++;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a, b, h;
    cin >> a >> b >> h;

    int ans = (a + b) * h / 2;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>

using namespace std;

int main(){
    int len_array,num_query,temp;
    int b,e,key;
    
    // --- load array --- //
    scanf("%d",&len_array);
    vector<int> int_array(len_array,0);
    for(int i = 0;i < len_array;i++){
        scanf("%d",&temp);
        int_array[i] = temp;
    }
    // --- query --- //
    scanf("%d",&num_query);
    for(int i = 0;i < num_query;i++){
        scanf("%d %d %d",&b,&e,&key);
        int counter = 0;
        for(int j = b;j < e;j++){
            if(key == int_array[j]) counter++;
        }
        printf("%d\n",counter);
        
    }
    
    
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,Q;cin>>N>>Q;
  std::vector<int> edge[N];
  for(int i=1;i<N;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  std::vector<int> v(N,0);
  while(Q--){
    int p,x;cin>>p>>x;p--;
    v[p]+=x;
  }
  std::vector<int> used(N,0);
  typedef pair<int,int> P;
  queue<P> que;
  que.push(P(0,v[0]));
  while(que.size()){
    P p=que.front();que.pop();
    int a=p.first,b=p.second;
    used[a]++;
    for(int q:edge[a]){
      if(used[q])continue;
      v[q]+=b;
      que.push(P(q,v[q]));
    }
  }
  for(int i=0;i<N;i++)cout<<v[i]<<" ";cout<<endl;
}


Measured memory_bytes: 21104
#include <iostream>
#include <map>
#include <queue>

using namespace std;

struct Data {
  int a, b;
  Data(int A, int B) : a(A), b(B) {}
  bool operator< (const Data& d ) const {
    return a < d.a;
  }
};

int main(){
  int N,M;
  int c=0;
  vector<Data> job;
  priority_queue<int> salary;
  cin >>N>>M;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    job.push_back(Data(a,b));
  }
  sort(job.begin(), job.end());
  int idx = 0;
  for(int i = 1; i<=M; i++){
    while (idx < N && job[idx].a <= i) {
      salary.push(job[idx].b);
      idx++;
    }
    if (!salary.empty()){
      c += salary.top();
      salary.pop();
    }
  }
  cout << c << endl;

}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

vector<int> n;

int main(void){
	
	for(int i = 0; i < 3; ++i){
	    int a; scanf("%d", &a);
	    n.push_back(a);
	}
	
	int ans = 0;
	auto itr = min_element(n.begin(), n.end());
	ans += *itr;
	*itr = INT_MAX;
	itr = min_element(n.begin(), n.end());
	ans += *itr;
	
	printf("%d\n", ans);
	
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, a[200+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    int min=1000000000;
    for(int i=0; i<n; i++){
        int cnt=0;
        while(a[i]%2==0 && cnt<min){
            a[i]/=2;
            cnt++;
        }
        if(cnt<min)min=cnt;
    }
    printf("%d\n", min);
    return 0;
}


Measured memory_bytes: 1736
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if (500 * i + 100 * j + 50 * k == x):
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
/**
 *    author:  FromDihPout
 *    created: 2020-07-23
**/

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


const long long INF = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    long long W;
    cin >> N >> W;
    vector<long long> w(N);
    vector<int> v(N);
    int max_val = 0;
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
        max_val += v[i];
    }
    
    vector<long long> dp(max_val + 1, INF);
    dp[0] = 0;
    for (int item = 0; item < N; item++) {
        for (int val = max_val; val >= v[item]; val--) {
            if (dp[val - v[item]] + w[item] <= W) {
                dp[val] = min(dp[val], dp[val - v[item]] + w[item]);
            }
        }
    }
    
    for (int i = max_val; i >= 0; i--) {
        if (dp[i] <= W) {
            cout << i << '\n';
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3956
#C
import math

A ,B ,H ,M = map(int,input().split())
x = A*math.sin(math.radians(30*(H+M/60)))-B*math.sin(math.radians(6*M))
y = A*math.cos(math.radians(30*(H+M/60)))-B*math.cos(math.radians(6*M))
print((x**2+y**2)**(0.5))


Measured memory_bytes: 9448
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,ts=0,hs=0;
    string t,h;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>h;
        if(t>h){
            ts+=3;
        }else if(h>t){
            hs+=3;
        }else{
            ts++;
            hs++;
        }
    }
    cout<<ts<<" "<<hs<<endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n],a1,a2,a3;
    double mi=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<16;i++)
      for(int j=0;j<16;j++)
        for(int k=0;k<16;k++){
          int R=i;
          int b[256]={};
          for(int l=0;l<n;l++){
            R=(j*R+k)%256;
            b[(a[l]+R)%256]++;
          }
          double h=0;
          //cout<<h<<endl;
          for(int l=0;l<256;l++)
            if(b[l]>0)
            h-=(double)b[l]*log((double)b[l]);
          if(mi>h){
            mi=h;
            a1=i;
            a2=j;
            a3=k;
          }
        }
    cout<<a1<<' '<<a2<<' '<<a3<<endl;
  }
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin>>n;
    
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    sort(a.begin(), a.end(), greater<int>());
    
    int temp=a[0];
    
    int sum=0;
    
    for(int i=1; i<a.size(); i++){
        
        sum+=temp-a[i];
        temp=a[i];
    }
    
    cout<<sum<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N;
    cin >> S;

    vector<vector<int>> a(10, vector<int>(N + 1, N));
    REP(i, 10) {
        a[i][N] = N;
    }
    RREP(i, N) {
        REP(d, 10) {
            if (S[i] - '0' == d) {
                a[d][i] = i;
            } else {
                a[d][i] = a[d][i + 1];
            }
        }
    }
    int result = 0;
    REP(d1, 10) {
        REP(d2, 10) {
            REP(d3, 10) {
                int i1 = a[d1][0];
                if (i1 < N) {
                    int i2 = a[d2][i1 + 1];
                    if (i2 < N) {
                        int i3 = a[d3][i2 + 1];
                        if (i3 < N) {
                            ++result;
                        }
                    }
                }
            }
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 1664
/**
 *    author:  [itmo] enot.1.10
 *    created: 21.08.2016 15:33:51       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */

const int T = 3;
const int mod = 1e9 + 7;

ll tmp[T][T];
ll A[T][T], R[T][T];

void multRR()
{
    memset(tmp, 0, sizeof tmp);
    forn(i, T) forn(j, T) forn(k, T) tmp[i][j] = (tmp[i][j] + R[i][k] * (ll)R[k][j]) % mod;
    forn(i, T) forn(j, T) R[i][j] = tmp[i][j];
}

void multRA()
{
    memset(tmp, 0, sizeof tmp);
    forn(i, T) forn(j, T) forn(k, T) tmp[i][j] = (tmp[i][j] + R[i][k] * (ll)A[k][j]) % mod;
    forn(i, T) forn(j, T) R[i][j] = tmp[i][j];
}

int mpow(int a, ll b)
{
    int res = 1;
    while (b)
    {
        if (b & 1) res = (res * (ll)a) % mod;
        a = (a * (ll)a) % mod;
        b >>= 1;
    }
    return res;
}



const int N = 1010;

char s[N][N];


int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    int n, m;
    scanf("%d%d", &n, &m);
    ll k;
    scanf("%lld", &k);
    if (k <= 1) return 0 * printf("1\n");
    forn(i, n) scanf("%s", s[i]);
    int V = 0, H = 0;
    forn(i, n) if (s[i][0] == '#' && s[i][m - 1] == '#') H++;
    forn(i, m) if (s[0][i] == '#' && s[n - 1][i] == '#') V++;
    if (H == 0 && V == 0)
    {
        int res = 0;
        forn(i, n) forn(j, m) res += s[i][j] == '#';
        res = mpow(res, k - 1);
        printf("%d\n", res);
        return 0;
    }
    if (H > 0 && V > 0) return 0 * printf("1\n");

    if (H == 0 && V > 0)
    {
        int mx = max(n, m);
        forn(i, mx) forn(j, mx) if (i < j) swap(s[i][j], s[j][i]);
        swap(n, m);
        swap(H, V);
    }
    ll cnt = 0;
    ll pairs = 0;
    ll sides = H;
    forn(i, n) forn(j, m) cnt += s[i][j] == '#';
    forn(i, n) forn(j, m - 1) if (s[i][j] == '#' && s[i][j + 1] == '#') pairs++;


    A[0][0] = cnt;
    A[1][1] = cnt;
    A[1][2] = pairs;
    A[2][2] = sides;

    forn(i, T) R[i][i] = 1;

    ll b = k - 2;
    for (int i = 60; i >= 0; --i)
    {
        multRR();
        if (b & pw(i)) multRA();
    }

    ll cnt2 = (cnt * (ll)R[0][0] + pairs * (ll)R[0][1] + sides * (ll)R[0][2]) % mod;
    ll pairs2 = (cnt * (ll)R[1][0] + pairs * (ll)R[1][1] + sides * (ll)R[1][2]) % mod;
    
    int res = (cnt2 - pairs2 + mod) % mod;

    printf("%d\n", res);

    
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  int a[105][105];
  bool have[n];
  for(int i = 0; i < n; i++){
    have[i]=false;
  }
  for (int i = 0; i < k; i++)
  {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++)
    {
      cin >> a[i][j];
      have[a[i][j]-1] = true;
    }
  }

  int ans = 0;
  for(int i = 0; i < n;i++){
    if(have[i] == false){
      // cout << i << "sunuke";
      ans++;
    }
  }
  cout << ans << endl;




}

Measured memory_bytes: 3640
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

/* Find the maximum x∈[low, up) such that f(x) is true
    ---*     (true)
        ---- (false)
*/
template<typename F> int binarySearchL(int low, int up, const F &f) {
  while (up - low > 1) {
    int mid = low + (up - low) / 2;
    (f(mid) ? low : up) = mid;
  }
  return low;
}

main() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<int> p(n);
    cin >> p;
    p.emplace_back(0), ++n;
    vector<int> v;
    v.reserve(n * n);
    rep(i, n) rep(j, n) v.emplace_back(p[i] + p[j]);
    sort(all(v));
    int ans = 0;
    rep(i, v.size()) {
      int j = binarySearchL(0, v.size(), [&](int k) { return v[i] + v[k] <= m; });
      if (v[i] + v[j] <= m) cmax(ans, v[i] + v[j]);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 11432
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	string s;
	cin>>s;
	ll val=0;
	for(ll i=0;i<s.size();i++)
	{
		val+=(s[i]-'0');
		val%=9;
	}	
	if(val) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3768
#include<stdio.h>
#include<string.h>
int main()
{
    char S[5],T[5];
    int count=0,i;
    scanf("%s %s",S,T);
    for(i=0; i<strlen(S); i++)
    {
        if(S[i]==T[i])
            count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int n,i,r=1;
	char s[100];
	scanf("%d%s",&n,s);
	if(n%2){
		r=0;
	}
	else{
		for(i=0;i<n/2;i++){
			r*=s[i]==s[n/2+i];
		}
	}
	printf(r?"Yes":"No");
	return 0;
}


Measured memory_bytes: 1704
N = int(input())
A = list(map(int, input().split()))
count = 0
max = A[0]
for i in range (0,N):
    while(max>A[i]):
        count = count + (max - A[i])
        A[i] = max
       # print(A)
    if(max<=A[i]):
        max = A[i]
      #  print(A)
print(count)

Measured memory_bytes: 32020
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

ll n,m;

int main(){
    cin>>n>>m;
    ll ans;
    if(n==1 && m==1) ans=1;
    else if(n==1 || m==1) ans=n*m-2;
    else if(n==2 || m==2) ans=0;
    else ans=(n-2)*(m-2);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3592
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll a,b,c;int main()
{
	cin>>a>>b>>c;
	cout<<min(a*b,c);
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    s = s.substr(1) + s[0];
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256