akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	int H, W; cin >> H >> W;
	char s[H][W];
	rep(i, H)rep(j, W) cin >> s[i][j];
	int dp[H][W];
	if(s[H-1][W-1] == '#') dp[H-1][W-1] = 2;
	else dp[H-1][W-1] = 0;
	for(int i=H-1; i>=0; i--){
		for(int j=W-1; j>=0; j--){
			if(i+j==H+W-2) continue;
			if(i==H-1){
				if(s[i][j] == '#' && s[i][j+1] == '.') dp[i][j] = dp[i][j+1] + 2;
				else dp[i][j] = dp[i][j+1];
			}else if(j==W-1){
				if(s[i][j] == '#' && s[i+1][j] == '.') dp[i][j] = dp[i+1][j] + 2;
				else dp[i][j] = dp[i+1][j];
			}else{
				dp[i][j] = 1e9;
				if(s[i][j] == '#' && s[i+1][j] == '.') chmin(dp[i][j], dp[i+1][j]+2);
				else chmin(dp[i][j], dp[i+1][j]);
				if(s[i][j] == '#' && s[i][j+1] == '.') chmin(dp[i][j], dp[i][j+1]+2);
				else chmin(dp[i][j], dp[i][j+1]);
			}
		}
	}
	cout << dp[0][0]/2 << endl;
	return 0;
}



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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool contains(vector<int>&vs, int x) {
  for (int v : vs) {
    if (v == x) return true;
  }
  return false;
}

int main() {
more:;
  int n, m; cin >> n >> m;
  if (!n && !m) return 0;

  vector<pair<int, int>> dps;

  rep (i, n) {
    int d, p; cin >> d >> p;
    dps.push_back(cons(p, d));
  }
  sort(all(dps));
  reverse(all(dps));

  int idx = 0;
  rep (i, m) {
    while (cdr(dps[idx]) <= 0) ++idx;
    if (idx >= n) break;
    cdr(dps[idx])--;
  }

  int sum = 0;
  rep (i, n) {
    sum += car(dps[i]) * cdr(dps[i]);
  }
  cout << sum << endl;

  goto more;
}

Measured memory_bytes: 1328
n,d=map(int,input().split())
P=[]
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    P.append(a)

for i in range(n-1):
    for j in range(i+1,n):
        Ds=0
        for k in range(d):
            Ds += (P[i][k]-P[j][k])**2

        if int(Ds**0.5)*int(Ds**0.5) == Ds:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}
 

void solve()
{
 
int n;
cin >> n;

int a[n];

forf(i,0,n) cin >> a[i];


sort(a,a+n);

int cur =0 ;

forf(i,0,n-2)
{
  forf(j,i+1,n-1)
  {
    int vl = a[i]+a[j];
    auto it = lower_bound(a,a+n,vl)-a;
    --it;
    cur += max((int)0,it-j);
  }
}

cout<<cur;

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;

int32_t main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n+1);
    vector<pair<int,int>> fact(m+1);
    map<pair<int,int>, bool> mp;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(x > y) swap(x, y);
        if(mp[{x,y}]) continue;
        mp[{x,y}] = true;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    vector<bool> visited(n+1);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(visited[i]) continue;
        queue<int> q;
        q.push(i);
        int count = 0;
        while(!q.empty()){
            int top = q.front();
            visited[top] = true;
            count += 1;
            for(int a : graph[top]){
                if(visited[a]) continue;
                q.push(a);
                visited[a] = true;
            }
            q.pop();
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    /*for(auto a : graph){
        for(int b : a){
            cout << b << " ";
        }
        cout << endl;
    }*/
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int cnt[252521], cnt2[252521];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin>>n>>s;
	int ans=1e9;
	FORR(i, 0, n){
		cnt[i]=cnt[i+1]+(s[i]=='.' ? 1 : 0);
		// DEBUG(cnt[i]);
	}
	REP(i, n){
		cnt2[i+1]=cnt2[i]+(s[i]=='#' ? 1 : 0);
	}
	REP(i, n){
		// DEBUG(ans);
		CHMIN(ans, cnt2[i]+cnt[i+1]);
		// DEBUG(cnt[i+1]);
		// DEBUG(cnt2[i]);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
long long int arr[100002][101];
long long int rec(int i,int j,int w[],long long int v[]){
    if(j<0)
    return 0;
    long long int dp1=0,dp2=0;
    if(arr[i][j]!=0){
        return arr[i][j];
    }
    if(i-w[j]>=0){
        dp1=rec(i-w[j],j-1,w,v)+v[j];
    }
    dp2=rec(i,j-1,w,v);
    arr[i][j]=max(dp1,dp2);
    return arr[i][j];
    
}
int main() {
	int n,W;
	cin>>n>>W;
	long long int v[n];
	int w[n];
	for(int i=0;i<n;i++){
	    cin>>w[i]>>v[i];
	}
	for(int i=0;i<=W;i++){
	    for(int j=0;j<=n;j++){
	        arr[i][j]=0;
	    }
	}
	cout<<rec(W,n-1,w,v);
	
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
string S;

string sw = "SW";
map<pair<char,string>, char> mp;

int main() {
	cin >> N >> S;
	// s[0]が'S'か'W'かと, S[1], S[N-1]が'S'か'W'かを決めたらあとは一意に定まる
	// 定まったS[N-1]が本来あるべきS[N-1]か確かめればいい
	vector<pair<char, string>>  cs;
	cs.push_back(make_pair('S', "S"));
	cs.push_back(make_pair('W', "S"));
	cs.push_back(make_pair('S', "W"));
	cs.push_back(make_pair('W', "W"));

	mp[make_pair('o',"SS")] = 'S';
	mp[make_pair('o',"WS")] = 'W';
	mp[make_pair('o',"SW")] = 'W';
	mp[make_pair('o',"WW")] = 'S';

	mp[make_pair('x',"SS")] = 'W';
	mp[make_pair('x',"WS")] = 'S';
	mp[make_pair('x',"SW")] = 'S';
	mp[make_pair('x',"WW")] = 'W';

	for(int i=1;i<=N;i++) {
		for(int j=0;j<cs.size();j++) {
			if(i == 1) {
				string tmp = "";
				tmp += cs[j].first;
				tmp += cs[j].second[i-1];
				cs[j].second += mp[make_pair(S[i-1], tmp)];
			} else {
				string tmp = "";
				tmp += cs[j].second[i-2];
			  	tmp += cs[j].second[i-1];
				cs[j].second += mp[make_pair(S[i-1], tmp)];
			}
		}
	}
	string ans = "-1";
	for(int i=0;i<cs.size();i++) {
		if(cs[i].second[0] == cs[i].second[N] and cs[i].first == cs[i].second[N-1]) {
			(cs[i].second).pop_back();
			ans = cs[i].second;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(in.readLine());
            int[] arr = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

            int cnt = 0;

            for (int i = 0; i < N; i++) {
                for (int j = N - 1; j > i; j--) {
                    if (arr[j] < arr[j - 1]) {
                        int tmp = arr[j];
                        arr[j] = arr[j - 1];
                        arr[j - 1] = tmp;
                        cnt++;
                    }
                }
            }

            System.out.println(Arrays.stream(arr).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
            System.out.println(cnt);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 31048
n,k = map(int, input().split())
square = [[0 for i in range(k*2)] for j in range(k*2)]
 
for i in range(n):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c=='W':
        y += k
    x = x%(k*2)
    y = y%(k*2)
    square[x][y] += 1
 
class CumulativeSum2d():
    def __init__(self, collection_2d):
        yl = len(collection_2d)
        xl = len(collection_2d[0])
        self.data = [[0] * (xl+1) for _ in range(yl+1)]
        for y in range(1, yl+1):
            for x in range(1, xl+1):
                top_sum         = self.data[y-1][x]
                left_sum        = self.data[y][x-1]
                dup_sum         = self.data[y-1][x-1]
                self.data[y][x] = top_sum + left_sum - dup_sum
                self.data[y][x] += collection_2d[y-1][x-1]
 
    def query(self, x, y, x1, y1):
        return self.data[y1][x1] - self.data[y-1][x1] - self.data[y1][x-1] + self.data[y-1][x-1]
 
cs = CumulativeSum2d(square)
 
"""
xxxxxx
xxxxxx
xxxxxx
xxxxxx
xxxxxx
xxxxxx
 
oxxxoo
oxxxoo
oxxxoo
xoooxx
xoooxx
xoooxx
 
0xxxoo
x000xx
x000xx
x000xx
0xxxoo
0xxxoo
 
xoooxx
oxxxoo
oxxxoo
oxxxoo
xoooxx
xoooxx
 
1 k  2k
xxxooo
xxxooo
xxxooo
000xxx
000xxx
000xxx
 
          1xk  2k
         10xxxoo
         yx000xx
         kx000xx
          x000xx
          0xxxoo
        2k0xxxoo
 
left top position determine everything
"""
ans = 0
for x in range(1,k*2+1):
    for y in range(1,k*2+1):
        sumd = 0
        # main_area
        sumd += cs.query(x, y, min(k*2, x+k-1), min(k*2, y+k-1))
        """
        """
        if x-k>1:
            # left_area
            sumd += cs.query(1, y, x-k-1, min(k*2, y+k-1))
        if y-k>1:
            # top_area
            sumd += cs.query(x, 1, min(k*2, x+k-1), y-k-1)
        if x>1 and y>1:
            # left_top_area
            sumd += cs.query(max(1, x-k), max(1, y-k), x-1, y-1)
        if x>1 and y-k<1:
            # left_bottom_area
            sumd += cs.query(max(1, x-k), y+k, x-1, k*2)
        if x-k<1 and y>1:
            # right_top_area
            sumd += cs.query(x+k, max(1, y-k), k*2, y-1)
        if x-k<1 and y-k<1:
            # right_bottom_area
            sumd += cs.query(x+k, y+k, k*2, k*2)
        ans = max(sumd, ans)
 
print(ans , flush=True)

Measured memory_bytes: 141964
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    size_t N;    
    cin >> N;

    // 文字数の探索
    int n = 1;
    size_t B = 1;
    size_t E = 26;
    while(N > E) 
    {
        B = E + 1;
        E = 26 + E * 26;        
        ++n;
    }

    vector<char> out(n, 'x');
    size_t X = N - B;
    char x = 'a';

    for(int i = 0; i < n; ++i)
    {
        out[n-1-i] = static_cast<char>((x + X % 26));
        X /= 26;
    }

    for(int i = 0; i < n; ++i)
    {
        cout << out[i];
    }
    cout << endl;
    

    return 0;    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

ll gcd(ll a, ll b){
    if(b==0)return a;
    return gcd(b, a%b);
}

int main(){
    ll K;
    cin>>K;
    ll Sum=0;
    for(ll i=1; i<=K; i++){
        for(ll j=i+1; j<=K; j++){
            for(ll k=j+1; k<=K; k++){
                ll G=gcd(gcd(i, j), k);
                Sum+=6*G;
            }
        }
    }
    for(ll i=1; i<=K; i++){
        for(ll j=1; j<=K; j++){
            if(i==j)continue;
            Sum+=3*gcd(i, j);
        }
    }
    Sum+=K*(K+1)/2;
    cout<<Sum<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int cnt=0;
        if(K>1) {          	
         cnt = N-K;	
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <set>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc130_b(vector<vector<int>> v) {

    int n = v[0][0];
    int x = v[0][1];
    vector<int> vec=v[1];

    int cnt=1;
    
    int mysum=0;
    
    for(int i=0;i<n;i++){
        
        mysum+=vec[i];
        if(mysum<=x){
            cnt+=1;
        }
    }
    
    cout << cnt<<endl;
    

}

int main() {

    //    vector<vector < string>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    abc130_b(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair


using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    vector<vector<int>> to;
    vector<pair<int,int>> v;

    rep(i,n + 1){
        vector<int> tmp;
        to.pback(tmp);
    }

    rep(i,m){
        int a,b;
        cin >> a >> b;

        v.pback(mpair(min(a,b), max(a,b)));

        to[a].pback(b);
        to[b].pback(a);
    }

    int ans = 0;

    rep(i,m){
        map<int,int> m;
        queue<int> q;

        int start = v[i].first;
        int goal = v[i].second;

        m[start] = 1;
        rep(j,to[start].size()){
            if(to[start][j] != goal){
                q.push(to[start][j]);
            }
        }

        while(!q.empty()){
            int tmpn = q.front();
            m[tmpn] = 1;

            rep(j,to[tmpn].size()){
                if(m[to[tmpn][j]] != 1){
                    q.push(to[tmpn][j]);
                }
            }
            q.pop();
        }

        if(m[goal] == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

//Darts
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt();
			if((n|m)==0)break;
			int[] p = new int[n+1];
			for(int i=0;i<n;i++)p[i]=sc.nextInt();
			int[] a = new int[n*n];
			int N = 0;
			for(int i=0;i<=n;i++)for(int j=0;j<=i;j++)if(p[i]+p[j]<=m)a[N++]=p[i]+p[j];
			Arrays.sort(a);
			int max = 0;
			int s = 0;
			int t = a.length-1;
			while(s<=t){
				if(max==m)break;
				if(a[s]+a[t]<=m){
					max=Math.max(max, a[s]+a[t]);
					s++;
				}
				else t--;
			}
			System.out.println(max);
		}
	}
//	class Scanner {
//		int nextInt() {
//			try {
//				int c = System.in.read();
//				while (c != '-' && (c < '0' || '9' < c))
//					c = System.in.read();
//				if (c == '-') return -nextInt();
//				int res = 0;
//				do {
//					res *= 10;
//					res += c - '0';
//					c = System.in.read();
//				} while ('0' <= c && c <= '9');
//				return res;
//			} catch (Exception e) {
//				return -1;
//			}
//		}
//	}	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
    t[i+1]=t[i]+(1 if S[i : i+2]=='AC' else 0)
for i in range(Q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])


Measured memory_bytes: 7748
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	int k = sca.nextInt();
	int x = sca.nextInt();


	// 処理
	if(x <= 500*k) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}


	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		VI s(n), p(n), q(n), r(n);
		rep(i, n)cin >> s[i] >> p[i] >> q[i] >> r[i];
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;

		VI ans;
		rep(i, n) {
			if (p[i] <= P && q[i] <= Q && r[i] <= R && p[i] * 4 + q[i] * 9 + r[i] * 4 <= C)ans.pb(s[i]);
		}
		if (ans.empty())puts("NA");
		else {
			rep(i, sz(ans))cout << ans[i] << endl;
		}
	}
}


Measured memory_bytes: 3200
#include<stdio.h>

int main(void)
{
	int n, x, min = 1000000, max = -1000000, i;
	long long int sum = 0;

	scanf("%d", &n);
	
	if (n == 0)
	{
		printf("0 0 0\n");
	}
	else if (n == 1)
	{
		scanf("%d", &x);
		printf("%d %d %d\n", x, x, x);
	}
	else if (n >= 2)
	{
		for (i = 0; i < n; i++)
		{
			scanf("%d", &x);
			if (x < min)
			{
				min = x;
			}
			if (x > max)
			{
				max = x;
			}
			sum = sum + x;
		}

		printf("%d %d %lld\n", min, max, sum);
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int count=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            count+=i;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(ll (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

using namespace std;


ll a[100006],b[100006];

int main() {
	ll n;
	cin >> n;
	ll kai = 0;
	ll tyousei = 0;
	ll ans = 0;

	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		cin >> b[i];
	}
	rep(i,n){
		kai = b[i]-a[i];
		if (b[i] > a[i]) tyousei = (b[i] - a[i]) / 2 + (b[i] - a[i]) % 2;
		else tyousei = 0;
		ans += kai - tyousei;

	} 

	if (ans >=0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
void main() {
    string[] s = readln.split;
    writeln(s[0][0], s[1][0], s[2][0]);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long tmp = X;
		int res = 0;
		while (tmp <= Y) {
			tmp = tmp << 1;
			res++;
		}
		System.out.print(res);
	}
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;
		try {
			while ((line = br.readLine()) != null) {
				String[] v = line.split(" ");
				double a = Double.parseDouble(v[0]);
				double b = Double.parseDouble(v[1]);
				double c = Double.parseDouble(v[2]);
				double d = Double.parseDouble(v[3]);
				double e = Double.parseDouble(v[4]);
				double f = Double.parseDouble(v[5]);

				double x = (c * e - b * f) / (a * e - b * d) + 0;
				double y = (c * d - a * f) / (b * d - a * e) + 0;

				System.out.println(String.format("%.3f %.3f", x, y));
			}
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 24852
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;

int F(int a){
	int ret = 0;
	while(a%2 == 0) ++ret , a/=2;
	return ret;
}

int32_t main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	int a,b,c;
	cin >> a>>b>>c;
	if(a%2 + b%2 + c%2) return cout << 0 << '\n' , 0;
	if(a == b && b == c) return cout << -1 << '\n' , 0;
	cout << min(F(a+b) , min(F(a+c) , F(b+c))) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;

  vector<vector<int>> G(n);
  G[x].push_back(y);
  G[y].push_back(x);

  rep(i, 0, n - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }

  vector<int> ans(n - 1, 0);

  rep(i, 0, n) {
    queue<int> q;
    vector<int> root(n, 1e9);
    q.push(i);
    root[i] = 0;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (auto g : G[t]) {
        if (root[g] != 1e9)
          continue;
        chmin(root[g], root[t] + 1);
        q.push(g);
      }
    }

    rep(j, i + 1, n) { ans[root[j] - 1]++; }
  }

  rep(i, 0, n - 1) cout << ans[i] << endl;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;cin>>n;
  ll res=0;
  for(ll i=1;i*i<=n;i++){
    res=i*i;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

struct card{
    int t;
    char c;
    int idx;
};

int part(vector<card> &A,int p,int r){
    int x = A[r].t;
    int i = p-1;
    for(int j=p;j<r;j++){
        if(A[j].t<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

void quicksort(vector<card> &A,int p,int r){
    if(p<r){
        int q = part(A,p,r);
        quicksort(A,p,q-1);
        quicksort(A,q+1,r);
    }
}

int main(){
    int N;
    cin >> N;
    vector<card> A(N);
    auto save = A;
    rep(i,N){
        cin >> A[i].c >> A[i].t;
        A[i].idx = i;
    }

    quicksort(A,0,N-1);

    [=](){
        for(int i=0;i<N-1;i++){
            if(A[i].t==A[i+1].t){
                if(A[i].idx > A[i+1].idx){
                    cout << "Not stable" << endl;
                    return;
                }
            }
        }
        cout << "Stable" << endl;
        return;
    }();

    rep(i,N){
        cout << A[i].c << " " << A[i].t << endl;
    }
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

ll counum(ll n){
    ll cou=0;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            cou+=i;
            if(n/i!=i&&i!=1)cou+=n/i;
        }
    }
    if(n!=1)return cou;
    else return 0;
}

int main(){
    int n;
    while(cin >> n,n){
        ll cou=counum(n);
        if(n==cou)cout << "perfect number" << endl;
        else if(n<cou)cout << "abundant number" << endl;
        else cout << "deficient number" << endl;
    }

}



Measured memory_bytes: 3008
N, A, B = map(str, input().split())

ans = 0
for i in range(1, int(N) + 1):
    tmp = 0
    strN = str(i)
    for j in strN:
        tmp += int(j)
    if tmp >= int(A) and tmp <= int(B):
        ans += i

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int n,m;

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= n-1 && col >= 0 && col <= m-1)return true;
	else{
		return false;
	}
}

int main(){

	int div,row,col;
	char order[10],dir;
	bool finishFLG;

	while(true){
		scanf("%d %d",&m,&n);
		if(n == 0 && m == 0)break;

		finishFLG = false;

		row = n-1,col = 0;
		dir = 'N';

		while(!finishFLG){
			scanf("%s",order);
			switch(order[0]){
			case 'F':
				scanf("%d",&div);

				switch(dir){
				case 'N':
					if(rangeCheck(row-div,col)){
						row = row - div;
					}else{
						row = 0;
					}
					break;
				case 'E':
					if(rangeCheck(row,col+div)){
						col = col + div;
					}else{
						col = m-1;
					}
					break;
				case 'S':
					if(rangeCheck(row+div,col)){
						row = row + div;
					}else{
						row = n-1;
					}
					break;
				case 'W':
					if(rangeCheck(row,col-div)){
						col = col - div;
					}else{
						col = 0;
					}
					break;
				}

				break;
			case 'B':
				scanf("%d",&div);

				switch(dir){
				case 'N':
					if(rangeCheck(row+div,col)){
						row = row + div;
					}else{
						row = n-1;
					}
					break;
				case 'E':
					if(rangeCheck(row,col-div)){
						col = col - div;
					}else{
						col = 0;
					}
					break;
				case 'S':
					if(rangeCheck(row-div,col)){
						row = row - div;
					}else{
						row = 0;
					}
					break;
				case 'W':
					if(rangeCheck(row,col+div)){
						col = col + div;
					}else{
						col = m-1;
					}
					break;
				}
				break;
			case 'R':
				switch(dir){
				case 'N':
					dir = 'E';
					break;
				case 'E':
					dir = 'S';
					break;
				case 'S':
					dir = 'W';
					break;
				case 'W':
					dir = 'N';
					break;
				}
				break;
			case 'L':
				switch(dir){
				case 'N':
					dir = 'W';
					break;
				case 'E':
					dir = 'N';
					break;
				case 'S':
					dir = 'E';
					break;
				case 'W':
					dir = 'S';
					break;
				}
				break;
			case 'S':
				printf("%d %d\n",col+1,n-row);
				finishFLG = true;
				break;
			}
		}
	}

    return 0;
}

Measured memory_bytes: 2748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//D問題　間違った解答
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long[] A = new long[N];
		long[] answer = new long[N];
		long totalValue = 0;
		for(int i = 0; i < N; i++) {
			A[i] = (long) Integer.parseInt(sc.next());
			totalValue += A[i];
		}
		sc.close();
		
		for(int i = 1; i < N - 1; i += 2) {
			totalValue -= 2 * A[i];
		}
		
		answer[0] = totalValue;
		System.out.print(answer[0]);

		for(int i = 1; i < N; i++) {
			answer[i] = 2 * A[ i - 1] - answer[i -1];
			System.out.print(" " + answer[i]);
		}
	}
}

Measured memory_bytes: 51920
import javax.management.monitor.CounterMonitor;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int answer=0;
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D =sc.nextInt();
        int X=sc.nextInt();

        for(int i=0;i<10;i++)
        {
            answer=r*X-D;
            System.out.println(answer);
            X=answer;
        }
        //出力
        //System.err.println();//標準エラー出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(answer);
    }
}

Measured memory_bytes: 20436
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << 
 << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int x;
    int m = 0, sum = 0;
    cin >> x;
    while (sum < x) {
        sum += ++m;
    }
    cout << m << endl;
    
    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int x, a, b;
    cin >> x >> a >> b;
    
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAX=105;
const LL INF=1LL<<31;
LL G[MAX][MAX],A[MAX][MAX];
int V,E;
void init(int type){
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			if(type){
				if(i!=j)G[i][j]=INF;
				else G[i][j]=0;
			}else 
				A[i][j]=G[i][j];
		}
	}
}
void warshallFloyd(){
	for(int k=0;k<V;k++)
		for(int i=0;i<V;i++)
			for(int j=0;j<V;j++)
				if(A[i][k]!=INF&&A[k][j]!=INF)
					A[i][j]=min(A[i][j],A[i][k]+A[k][j]);
}
int main(){
	init(1);
	int s,t,d;
	cin>>V>>E;
	for(int i=0;i<E;i++){
		cin>>s>>t>>d;
		G[s][t]=d;
	}
	init(0);
	warshallFloyd();
	int flag=true;
	for(int i=0;i<V;i++){
		if(A[i][i]<0){
			flag=false ;
			break;
		}
	}
	if(flag)
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(j)cout<<" ";
				if(A[i][j]==INF) cout<<"INF";
				else cout<<A[i][j];
			}
			cout<<endl;
		}
	else cout<<"NEGATIVE CYCLE"<<endl;
	return 0;
} 


Measured memory_bytes: 3276
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
int inf = 1000000000;
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
int main() {
	int n, k;
	cin >> n >> k;
	if (n%k)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 764
s = list(map(int, input()))

n = len(s)

def count_flips(s0):
  ans = 0
  for i in range(n):
    si = (s0 + i) % 2
    if s[i] != si:
      ans += 1
  return ans

print(min(count_flips(0), count_flips(1)))

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

using namespace std;

typedef long long ll;

int main () {
	ll x;
	ll i, j;
	ll ret=0;
	
	cin >> x;
	
	i=100;
	while(i<x){
		i+=(i/100);
		ret++;
	}
	cout << ret <<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int r;
    cin >> r;
    double pi = 3.14159;
    double ans = 2.0*r*pi;
    printf("%.6f\n",ans);
    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
int main(){
	int high_1=0,high_2=0,high_3=0,yama=0,i;
	for(i=0;i<10;i++){
		scanf("%d",&yama);
		if(high_1<yama){
			high_3=high_2;
			high_2=high_1;
			high_1=yama;
		}
		else if(high_2<yama){
			high_3=high_2;
			high_2=yama;
		}
		else if(high_3<yama){
			high_3=yama;
		}
	}
	printf("%d\n%d\n%d\n",high_1,high_2,high_3);
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; string s; cin >> n >> s;
    int k = s.length();
    int ans = 0;
    FOR(fugfuyfffsdfvgefge, 0, n) {
        string t; cin >> t;
        int m = t.length();

        bool ok = false;
        FOR(diff, 1, m)FOR(start, 0, m) {
            bool s_ok = true;
            FOR(i, 0, k) {
                s_ok &= (start + i * diff < m && s[i] == t[start + i * diff]);
            }
            ok |= s_ok;
        }
        if (ok)++ans;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3212
#include <iostream>
using namespace std;

int main(void) {
    int n, min = 0, maxpos=0;
    int h[100000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (h[i] > h[maxpos]) maxpos = i;
        else if (h[maxpos]-h[i] >= 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct Dice
{
	char f[8];
	int count;
	
	Dice() : count(0) {}
	
	void swap(int a, int b, int c, int d)
	{
		char tmp = f[a];
		f[a] = f[b];
		f[b] = f[c];
		f[c] = f[d];
		f[d] = tmp;
	}
	
	void xroll()
	{
		swap(0, 1, 5, 4);
	}
	
	void yroll()
	{
		swap(1, 2, 4, 3);
	}
	
	void zroll()
	{
		swap(0, 2, 5, 3);
	}
	
	void next()
	{
		zroll();
		if(count % 8 == 3)
			xroll();
		else if(count % 8 == 7)
			yroll();
		++count;
	}

	bool operator< (const Dice& d)const
	{
		return strcmp(f, d.f) < 0;
	}
};

bool okok(char a, char b)
{
	return a != b && (tolower(a) == b || a == tolower(b));
}

bool search(Dice d[8], int depth)
{
	if(depth == 8)
		return true;
	
	rep(i, 24){
		bool ok;
		if(depth == 1)
			ok = okok(d[0].f[2], d[1].f[3]);
		else if(depth == 2)
			ok = okok(d[0].f[4], d[2].f[1]);
		else if(depth == 3)
			ok = okok(d[1].f[4], d[3].f[1]) && okok(d[2].f[2], d[3].f[3]);
		else if(depth == 4)
			ok = okok(d[0].f[0], d[4].f[5]);
		else if(depth == 5)
			ok = okok(d[1].f[0], d[5].f[5]) && okok(d[4].f[2], d[5].f[3]);
		else if(depth == 6)
			ok = okok(d[2].f[0], d[6].f[5]) && okok(d[4].f[4], d[6].f[1]);
		else
			ok = okok(d[3].f[0], d[7].f[5]) && okok(d[5].f[4], d[7].f[1]) && okok(d[6].f[2], d[7].f[3]);
		
		if(ok && search(d, depth+1))
			return true;
		
		d[depth].next();
	}
	return false;
}

int main()
{
	Dice dice[8];
	while(1){
		bool quit = false;
		rep(i, 8){
			scanf("%s", dice[i].f);
			if(dice[i].f[0] == '0'){
				quit = true;
				break;
			}
		}
		if(quit)
			break;

		int ans = false;
		sort(dice, dice+8);
		do{
			bool ok = false;
			set<int> memo;
			rep(i, 24){
				char c[3] = {dice[0].f[0], dice[0].f[2], dice[0].f[4]};
				sort(c, c+3);
				int key = (c[0]<<16) + (c[1]<<8) + c[2];
				if(!memo.count(key)){
					memo.insert(key);
					if(search(dice, 1)){
						ok = true;
						break;
					}
				}
				dice[0].next();
			}
			if(ok){
				ans = true;
				break;
			}
		}while(next_permutation(dice+1, dice+8));
		puts(ans ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "string.h"

using namespace std;

static const int MAX = 1048576;
static const int LEN = 14;

int makeKey( char str[LEN] ) {
	int key = 0, x;

	int l = strlen(str);

	for (int i = 0; i < 9; i++) {
		x = 0;
		if (i < l) {
			if (str[i] == 'A') x = 0;
			else if (str[i] == 'C') x = 1;
			else if (str[i] == 'G') x = 2;
			else if (str[i] == 'T') x = 3;
		}
		key = key * 4 + x;
	}
	return key * 4;
}

bool same( char str[LEN], char str2[LEN] ) {
	int l = strlen(str);
	if( l != strlen(str2)) return false;
	
	for (int i = 0; i < l; i++) {
		if (str[i] != str2[i]) return false;
	}
	return true;
}

char dic[MAX][LEN];

int main() {

	int lnum;
	char com[9], str[LEN];
	bool used[MAX];

	cin >> lnum;

	for (int i = 0; i < MAX; i++) {
		used[i] = false;
	}

	for (int i = 0; i < lnum; i++) {
		cin >> com;
		cin >> str;

		if (com[0] == 'i') {
			
			int k = makeKey(str);
			if (k >= MAX) {
				//cout << "RE" << endl;
			}
			while (used[k]) {
				k += 11;
				if (k >= MAX) k -= MAX;
			}
			int i;
			for (i = 0; i < strlen(str); i++) {
				dic[k][i] = str[i];
			}
			dic[k][i] = '\0';
			used[k] = true;
			
		}
		else if( com[0] == 'f' ){
			
			bool found = false;
			int k = makeKey(str);
			if (k >= MAX) {
				//cout << "RE" << endl;
			}
			
			while (used[k]) {
				int i;
				char s[LEN];
				for (i = 0; i < strlen(dic[k]); i++) {
					s[i] = dic[k][i];
				}
				s[i] = '\0';
				if (same(str,s)) {
					found = true;
					cout << "yes" << endl;
					break;
				}
				k += 11;
				if (k >= MAX) k -= MAX;
			}
			if (!found) cout << "no" << endl;
		
		}
	}

	return 0;
}

Measured memory_bytes: 16520
from bisect import bisect_left

N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
left = 0
right = max(A) * 2 + 1

while left + 1 < right:
  mid = (left + right) // 2
  
  cnt = 0
  for i in range(N):
    cnt += N - bisect_left(A, mid - A[i])
  if cnt >= M:
    left = mid
  else:
    right = mid

Acum = [0]
for a in A:
  Acum.append(Acum[-1] + a)

answer = 0
cnt = 0
for i in range(N):
  bi = bisect_left(A, left - A[i])
  answer += (Acum[-1] - Acum[bi]) + (N - bi) * A[i]
  cnt += (N - bi)
answer -= (cnt - M) * left

print(answer)

Measured memory_bytes: 60172
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = A[0]
b = B[0]
a_lis = [0,a]
b_lis = [b]
for i in range(1,N):
    a += A[i]
    a_lis.append(a)
for j in range(1,M):
    b += B[j]
    b_lis.append(b)
ans = 0
for i in range(N+1):
    if a_lis[i] <= K:
        j = bisect.bisect_right(b_lis,K-a_lis[i])
        tmp_ans = i + j 
        if ans < tmp_ans:
            ans = tmp_ans
    else:
        break
print(ans)

Measured memory_bytes: 47496
S = input()
Q = int(input())
L = [list(map(str,input().split())) for i in range(Q)]

cnt = 0
FR = ""
BA = ""

for i in range(Q):
    if len(L[i]) == 1:
        cnt += 1
    else:
        if (int(L[i][1])+cnt)%2 == 0:
            BA = BA + L[i][2]
        else:
            FR = L[i][2]+FR

if cnt%2 == 0:
    print(FR+S+BA)
else:
    new_S = ''.join(list(reversed(FR+S+BA)))
    print(new_S)

Measured memory_bytes: 42032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int a; cin >> a;
  int ans = a + a*a + a*a*a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592