akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) {if (a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a, const T& b) {if (a>b){a=b;return true;}return false;}
// clang-format on

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a;
    a.pb(0);
    int tmp;
    rep (i, n) {
        cin >> tmp;
        a.pb(tmp);
    }

    vec b;
    Forr(i, n, 1) {
        if (a[i] == 1) {
            b.pb(i);
            For(j, 1, sqrt(i)) {
                if (i % j == 0) {
                    a[j] = 1 - a[j];
                    if (j < i / j) {
                        a[i / j] = 1 - a[i / j];
                    }
                }
            }
        }
    }
    print(b.size());
    if (b.size() > 0) print(b);

    return 0;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  cin>>a>>b;
  int n=len(a),m=len(b);
  if(n>m) cout<<"GREATER"<<endl;
  else if(n<m) cout<<"LESS"<<endl;
  else{
    rep(i,n){
      if(a[i]>b[i]){
        cout<<"GREATER"<<endl;
        return 0;
      }
      else if(a[i]<b[i]){
        cout<<"LESS"<<endl;
        return 0;
      }
    }
    cout<<"EQUAL"<<endl;
  }
}

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

int main()
{
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	S = min(S, min(Q * 4, H * 2));
	cout << min(S * N, N / 2 * D + (N & 1) * S) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  int n; cin >> n;
  rep(i, 10) {
    rep(j, 10) {
      if (i*j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;

	ll n ;
	cin>>n ;
	set<ll> st;
	for(ll i=0,a;i<n;i++){
		cin>>a;
		st.insert(a);
	}
	puts(n==st.size()? "YES" : "NO");

	return 0;
}

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

const ll INF =100000000009;
ll dp[200][200000];

template<class T> inline bool chmax(T &x, T y){
	if(x < y){x = y; return true;}
	else return false;
}

int main(){
	ll N,W; cin >> N >> W;
	vl n(N); vl w(N);
	rep(i,N)cin >> w[i] >> n[i];
    rep(i,N+10){
      rep(j,W+10){
        dp[i][j] = 0;
      }}
	rep(i,N){
		rep(j,W+1){
			if(j >= w[i])dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + n[i]);
			else dp[i+1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;
}


Measured memory_bytes: 171520
a, b = map(int, input().split())
if a&1:
	if (b-a) % 4 <= 1:
		ans = 1
	else:
		ans = 0
else:
	if 1 <= (b-a) % 4 <= 2:
		ans = 1
	else:
		ans = 0
for i in range(1, 40):
	cnt = 0
	if (a>>i) & 1 and (a % (1<<i)) & 1:
			cnt += 1
	if ((b+1)>>i) & 1 and ((b+1) % (1<<i)) & 1:
			cnt += 1
	if cnt & 1:
		ans += (1<<i)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n;
	vector<ll> L(2000);
	ll cou = 0;
	cin >> n;
	FOR(n)
		cin >> L[i];

	sort(ALL(L), greater<ll>());
	FOR(n - 2)
	{
		ll longest = L[i];
		for (int j = i + 1; j < n - 1; ++j) {
			for (int k = j + 1; k < n; ++k)
				if (longest < L[j] + L[k])
				{
					++cou;
				}
				else {
					break;
				}
		}
	}

	cout << cou << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,A,B,C,D;
string S;
bool flag=true;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>N>>A>>B>>C>>D>>S;
    A--;
    B--;
    C--;
    D--;
    if(C>D){         //追い越し
        bool oiko=false;
        repi(i,B-1,D){
            if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.')oiko=true;
        }
        if(!oiko)flag=false;
    }
    repi(i,A+1,C){
        if(S[i]=='#'&&S[i+1]=='#'){
            flag=false;
            break;
        }
    }
    repi(i,B+1,D){
        if(S[i]=='#'&&S[i+1]=='#'){
            flag=false;
            break;
        }
    }
    if(flag) out("Yes");
    else out("No");
    
    
}


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

int main() {
  int ans = 0;
  vector<int> amari(0);
  for (int i = 0; i < 5; i++) {
    int tmp;
    cin >> tmp;
    ans += ((tmp+9)/10)*10;
    tmp %= 10;
    amari.push_back(tmp);
  }
  sort(amari.begin(), amari.end());
  for (int i = 0; i < 5; i++) {
    if (amari[i] != 0) {
      ans -= (10-amari[i]);
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void Main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end());
    int ans = A[N / 2] - A[N / 2 - 1];
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main() 
{ 
	// freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
  char t;
  cin>>t;
  int x = (int)t;
  if((t - 97) < 0 ){
      cout<<"A\n";
  }else{
    cout<<"a\n";
  }
	return 0; 
} 
 

Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

string S, T;
int q;
int sumS[100005], sumT[100005];

int main(void)
{
	cin >> S >> T;
	for(int i = 1; i <= S.size(); i++){
		if(S[i-1] == 'A') sumS[i] = sumS[i-1] + 1;
		else sumS[i] = sumS[i-1] + 2;
		sumS[i] %= 3;
	}
	for(int i = 1; i <= T.size(); i++){
		if(T[i-1] == 'A') sumT[i] = sumT[i-1] + 1;
		else sumT[i] = sumT[i-1] + 2;
		sumT[i] %= 3;
	}
	
	cin >> q;
	int a, b, c, d;
	int s, t;
	for(int i = 0; i < q; i++){
		cin >> a >> b >> c >> d;
		s = (sumS[b] - sumS[a-1] + 3) % 3;
		t = (sumT[d] - sumT[c-1] + 3) % 3;
		if(s == t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
# ABC 065
def getInt(): return int(input())
def getIntFromRows(n): return [int(input()) for i in range(n)]
debug = True
def db(x): 
    if debug: print(x)

debug = False

n = getInt()
a = getIntFromRows(n)
db(a)
btn = 1
c = 0
while btn!=2 and c<n:
    btn = a[btn-1]
    c += 1
if c>=n: c = -1
print(c)



Measured memory_bytes: 7084
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> vec;
    
    for(int i = 1; i <= N; ++i)
      vec.push_back(i);
    
    do
    {
        for(int i = 0; i < N; ++i)
          cout << (i == 0 ? "" : " ") << vec[i];
        cout << endl;  
    }
    while(next_permutation(vec.begin(), vec.end()));
    
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;


int main() {
	int x1, x2;
	cin >> x1 >> x2;
	if (x1 > x2) {
		cout << x1 - x2 << endl;
	}
	else {
		cout << x2 - x1 << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
  string S;
  int ans = 0;
  
  cin >> S;
  
  for (int i = 0; i < S.length(); i++) {
    if (S.at(i) == '+') {
      ans++;
    } else if (S.at(i) == '-') {
      ans--;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	as <- sort <$> readIntegers
	print $ fromMaybe (-1) $ foldM f 1 as

f a b
	| a * b <= 10 ^ 18 = Just $ a * b
	| otherwise = Nothing

Measured memory_bytes: 19160
#include<iostream>
#include<string>

using namespace std;

int main(){
	int c=0,e=0;
	string n;
	while(cin>>n){
			e++;
		for(int i=0;i<=n.size()/2;i++){
			if(n[i]!=n[n.size()-i-1]){
				//cout<<n[i]<<n[n.size()-i-1]<<endl; 
				c++;
				break;}
		}
	}
	cout<<e-c<<endl;
}

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> nums = new List<int>();

            string input, num = "";

            while ((input = Console.ReadLine()) != null)
            {
                input += " ";

                for (int i = 0; i < input.Length; i++)
                {
                    if (input[i] >= '0' && input[i] <= '9')
                    {
                        num += input[i];
                    }
                    else if (num != "")
                    {
                        nums.Add(int.Parse(num));
                        num = "";
                    }
                }
            }
            Console.WriteLine(nums.Sum());
        }
    }
}

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

const int N = 3005;
int n, t, f[N][2];

int main() {
  cin >> n >> t;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    for (int j = t - 1; j >= 0; --j) {
      f[j][1] = max(f[j][1], f[j][0] + b);
      if (j >= a) {
        f[j][0] = max(f[j][0], f[j - a][0] + b);
        f[j][1] = max(f[j][1], f[j - a][1] + b);
      }
      ans = max({ans, f[j][0], f[j][1]});
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll dp[102][100002] = {0};

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

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    REP(i, N) { cin >> w.at(i) >> v.at(i); }

    REP(i, N) {
        REP(j, W + 1) {
            // cout << i << " " << j << " " << dp[i][j] << endl;
            if (w[i] + j <= W) {
                chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
int main()
{
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for (int i = 0; i <= k && i <= s; i++)
    {
        for (int j = 0; j + i <= s && j <= k; j++)
        {
            if (s - (i + j) >= 0 && s - (i + j) <= k)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  int count=0,max=0;
  for(int i=0;i<str.length();i++){
    if(str[i]=='R'){
      count++;
      if(count>max){
        max=count;
      }
    }else{
      count=0;
    }
  }
  printf("%d\n",max);
  return 0;
}


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

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

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
	ll ans = 0;
	ll h, n;
	cin >> h >> n;
	vector <int> a(n);
	ll sum = 0;
	rep(i, n){
		cin >> a[i];
		sum += a[i];
	}
	if(sum >= h){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}

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

int main(){
  int a,b,c,d,N;
  cin >>N;
  a=N%10;
  b=N%100 - a;
  c=N%1000 -(a+b);
  d=N-(a+b+c);
  b=b/10;
  c=c/100;
  d=d/1000;
  
  if(d==c&&c==b){
    cout <<"Yes"<<endl;
  }
  
  else if(c==b&&b==a){
    cout <<"Yes"<<endl;
  }
  
  else{
    cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
int main(){
  int count;
  int as[1000000];

  scanf("%d\n", &count);

  for(int i=0; i<count; i++){
    scanf("%d", &as[i*3+0]);
    scanf("%d", &as[i*3+1]);
    scanf("%d", &as[i*3+2]);
  }

  std::vector<int> av(as, as+(3*count));

  std::sort(av.rbegin(), av.rend());

  long sum=0;
  for(int i=0; i<count; i++){
    sum+= av[i*2+1];
  }
  printf("%ld\n", sum);
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
const int maxn=50;
const long long maxl=1000000000;
long long sx=maxl+1,bx=-maxl-1,sy=maxl+1,by=-maxl-1;
long long x[maxn+1],y[maxn+1];
int n,k;
long long ans=(maxl*2+1)*(maxl*2+1);
void dfs(int p,int c){
	if(c+n-(p-1)<k)return;
	long long ar=(bx-sx)*(by-sy);
	if(c>0&&ar>=ans)return;
	if(p==n+1){
		ans=min(ans,ar);
		return;
	}
	//point p not chosen
	dfs(p+1,c);
	
	//point p chosen
	long long _sx=sx,_bx=bx,_sy=sy,_by=by;
	sx=min(sx,x[p]);bx=max(bx,x[p]);
	sy=min(sy,y[p]);by=max(by,y[p]);
	dfs(p+1,c+1);
	sx=_sx;bx=_bx;sy=_sy;by=_by;
}
	
int main(int argc,char *argv[]){
	if(argc>=2){freopen(argv[1],"r",stdin);}
	if(argc>=3){freopen(argv[2],"w",stdout);}
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld%lld",&x[i],&y[i]);
	dfs(1,0);
	printf("%lld",ans);
	fclose(stdin);fclose(stdout);
	return 0;
}


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

int main() {
    string N;
    cin >> N;
    //if ((N.at(0)==N.at(1)) && N.at(0)==N.at(2) || N.at(1)==N.at(2)==N.at(3)) cout << "Yes\n";
    if ((N.at(0)==N.at(1) && N.at(0)==N.at(2)) || (N.at(1)==N.at(2) && N.at(1)==N.at(3)) ) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;
typedef struct _BLOCK{
    long long n;
    long long x;
}BLOCK;
int main() {
    long long n, x;
    vector<BLOCK> manager;
    BLOCK block;
    long long cnt;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        block.n = n;
        block.x = x;
        manager.push_back(block);
    }
    for(int i=0; i<manager.size(); i++){
        n = manager.at(i).n;
        x = manager.at(i).x;
        cnt = 0;
        for(int a=1; a<=n-2; a++){
            for(int b=a+1; b<=n-1; b++){
                for(int c=b+1; c<=n; c++){
                    if((a+b+c)==x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3140
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>


int main(){
    long int n;
    scanf("%ld",&n);
    long int rootn=(int)sqrt(n);
    long int i=rootn+1;
    int flag=0;
    while(flag==0){
        i--;
        if(n%i==0)flag=1;
    }
    long int max=n/i;
    long int ans=0;
    while(max>=1){
        max/=10;
        ans++;
    }
    printf("%ld",ans);
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  int red = 0;
  for(int i = 0; i <S.size();i++){
    if(S[i] == 'R')red++;
    else red--;
  }
  
  if(red >0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n, k;
    cin >> n >> k;

    if (k % 2 == 0) {
        ll a = n/k;
        ll b = (n +(k/2)) / k;
        cout << a*a*a + b*b*b << endl;
    } else {
        ll a = n/k;
        cout << a*a*a << endl;
    }


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

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int get(int m,int s){
	return m * 60 + s;
}
int main(){
	int n;
	while(cin >> n , n){
		vector< pair<int,int> > data;
		rep(i,n){
			int m,s,c,sum = 0;
			cin >> c;
			rep(j,4)cin >> m >> s , sum += get(m,s);
			data.push_back(make_pair(sum,c));
		}
		sort(data.begin(),data.end());
		cout << data[0].second << endl;
		cout << data[1].second << endl;
		cout << data[data.size()-2].second << endl;
	}
}

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

using namespace std;
int main(){

int N,M;
cin >> N;
vector<int> T = vector<int>(N,0);
int t=0;
for (int i=0; i<N; i++){
    int x;
    cin >> x;
    T[i] = x;
    t+=x;

}

cin >> M;


for (int i = 0; i < M; ++i) {
    int p,m;
    cin >> p>> m;
    int tt = t + (m - T[p-1]  );
    cout << tt << endl;
    
}



}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  int cnt1, cnt2;
  map<ll, ll> cnts1_map, cnts2_map;
  for (int i = 0; i < n; ++i) {
    int amount = i == 0 || i == n - 1 ? 1 : 2;
    int sign = i % 2 == 0 ? -1 : 1;
    cnts1_map[amount * sign]++;
    cnts2_map[amount * -sign]++;
  }

  sort(va.begin(), va.end());

  ll ans1 = 0, ans2 = 0, cur = 0;
  for (auto &p : cnts1_map) {
    ans1 += p.first *
            accumulate(va.begin() + cur, va.begin() + cur + p.second, 0ll);
    cur += p.second;
  }

  cur = 0;
  for (auto &p : cnts2_map) {
    ans2 += p.first *
            accumulate(va.begin() + cur, va.begin() + cur + p.second, 0ll);
    cur += p.second;
  }

  cout << max(ans1, ans2) << '\n';
}

Measured memory_bytes: 4040
#include <iostream>
#include <map>

using namespace std;

int main()
{
	int month = 0, day = 0, total_day = 0, week_num = 0;
	map<int, int> month_num;

	month_num[1] = 0;
	month_num[2] = 31;
	month_num[3] = 60;
	month_num[4] = 91;
	month_num[5] = 121;
	month_num[6] = 152;
	month_num[7] = 182;
	month_num[8] = 213;
	month_num[9] = 244;
	month_num[10] = 274;
	month_num[11] = 305;
	month_num[12] = 335;

	cin >> month >> day;

	while ( month * day != 0 )
	{
		total_day = month_num[month] + day-1;
		switch ( total_day % 7 )
		{
			case 0:
				cout << "Thursday" << endl;
				break;
			case 1:
				cout << "Friday" << endl;
				break;
			case 2:
				cout << "Saturday" << endl;
				break;
			case 3:
				cout << "Sunday" << endl;
				break;
			case 4:
				cout << "Monday" << endl;
				break;
			case 5:
				cout << "Tuesday" << endl;
				break;
			case 6:
				cout << "Wednesday" << endl;
				break;
			default:
				break;
		}
		cin >> month >> day;
	}

	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int h[n], dp[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(abs(h[i] - h[i - 2]) + dp[i - 2], abs(h[i] - h[i - 1]) + dp[i - 1]);
	}
	cout << dp[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 4332
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n;
vector<pair<int, int> > adj[MAX];

void dijkstra()
{
    int color[MAX], d[MAX];
    priority_queue<pair<int, int> > PQ;
    for (int i = 0; i != n; ++i)
    {
        color[i] = WHITE;
        d[i] = INFTY;
    }
    d[0] = 0;
    color[0] = GRAY;
    PQ.push(make_pair(0, 0));

    while (!PQ.empty())
    {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;



        for (int i = 0; i != adj[u].size(); ++i)
        {
            int v = adj[u][i].first;
            if (color[v] == BLACK)                {
                continue;
            }
            if (d[v] > d[u] + adj[u][i].second)
            {
                d[v] = d[u] + adj[u][i].second;
                color[v] = GRAY;
                PQ.push(make_pair(d[v] * (-1), v));
            }
        }
    }
    for (int i = 0; i != n; ++i)
    {
        cout << i << " " << d[i] << endl;
    }
}

int main()
{
    int u, k, v, c;
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        cin >> u >> k;
        for (int j = 0; j != k; ++j)
        {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }
    dijkstra();
    return 0;
}


Measured memory_bytes: 8008
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();

        boolean turnT = true;
        while (0 < A && 0 < C) {
            if (turnT) {
                C -= B;
            } else {
                A -= D;
            }
            turnT = !turnT;
        }
        System.out.println(A < 1 ? "No" : "Yes");
    }
}

Measured memory_bytes: 35780
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI eratosthenes()
{
	vector<bool> nums( 1000001, true );
	nums[0] = nums[1] = false;
	VI res;

	REP( i, 0, nums.size() )
	{
		if ( !nums[i] )
		{
			continue;
		}

		res.PB( i );
		for ( int j = 1; i * j < nums.size(); j++ )
		{
			nums[ i * j ] = false;
		}
	}

	return res;
}

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

	VI primes = eratosthenes();

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int res = 0;
		REP( i, 0, primes.size() )
		{
			auto pos = lower_bound( ALL( primes ), n - primes[i] );
			if ( *pos != n - primes[i] || *pos < primes[i] )
			{
				continue;
			}
			res++;
		}

		cout << res << endl;
	}

	return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int num;
    cin >> num;
    int ans = abs(num - x);
    for (int i=0; i<n-1; ++i) {
        cin >> num;
        int dist = abs(num - x);
        ans = __gcd(ans, dist);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int a, b;
	std::cin >> a >> b;
	int d = a / b;
	int r = a % b;
	double f = (double)a / b;
	std::cout << std::fixed;
	std::cout << std::setprecision(5) << d << ' ' << r << ' ' << f << std::endl;
	return 0;
}


Measured memory_bytes: 3240
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A1 = new int[N];
        int[] A2 = new int[N];
        for (int i = 0; i < N; i++) {
            A1[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            A2[i] = sc.nextInt();
        }

        List<Integer> result_list = new ArrayList<Integer>();
        int firstline_result = 0;
        for (int i=0; i < A1.length; i++) {
            firstline_result += A1[i];
            int tmp = firstline_result;
            for (int k=i; k < A2.length; k++) {
                tmp += A2[k];
            }
            result_list.add(tmp);
        }

        int max = result_list.get(0);
        for (int i = 1; i < result_list.size(); i++) {
            int v = result_list.get(i);
            if (v > max) {
                max = v;
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 21844
#include <cmath>
    // #include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
const int MM = 120000;
lli m,n,k,p1,p,p2,p3,f,a[MM],v[MM];
vector<lli> gr[MM];
lli dfs(lli s)
{
    v[s] = 1;
    lli cnt = 1;
    for(lli u : gr[s])
    {
        if(!v[u])
        {
            p = dfs(u);
            if(p==-1)
            {
                return -1;
            }
            cnt += p%2;
        }
    }
    if(cnt == 2)
    {
        return 0;
    }
    else if(cnt == 1)
    {
        return 1;
    }
    else
    {
        return -1;
    }
}

int main(){
    fio;
    lli q;
    cin>>n;
    for (int i=1; i<n; i++) {
        cin>>p1>>p2;
        p1--; p2--;
        gr[p2].push_back(p1);
        gr[p1].push_back(p2);
    }
    
    if(dfs(0) != 0)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

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

int main() {
	int i;cin >> i;
	if (i % 2 == 0){
		cout << (i / 2) * (i / 2) << endl;
	}
	else cout << (i / 2 + 1) * (i / 2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
  int n,m; cin >>n >>m;
  ll ans=0; priority_queue<int>q;
  for(int i=0; i<n; i++){
    int x; cin >>x; q.push(x);
  }
  for(int i=0; i<m; i++){
    int x=q.top(); q.pop(); q.push(x/2);
  }
  for(int i=0; i<n; i++){
    int x=q.top(); ans+=x; q.pop();
  }
  cout <<ans;
return 0;}

Measured memory_bytes: 892
#include <iostream>
//#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>

int solve(	int k, std::list<int>& dv )
{
	int count = 1;

	int len = 0;
	for( auto l : dv ) {
		len += l;
	}
	
	if( k == 1 ) {
		return len;
	}

	while ( count < k ) {
		if( len == 0 ) break;
		len -= (*dv.begin());
		dv.pop_front();
		count++;
	}

	return len;
}

int main(int argc, char* argv[])
{
	// std::ifstream ifs;
	//ifs.open(argv[1]);

	typedef boost::char_separator<char> char_separator;
    typedef boost::tokenizer<char_separator> tokenizer;
    char_separator sep(" ", "", boost::keep_empty_tokens);	

	int N;
	std::string line;
	std::getline(std::cin, line);
	{
		tokenizer tokens(line, sep);
		tokenizer::iterator tok_iter = tokens.begin();
		N = boost::lexical_cast<int>(*tok_iter);
	}

	for( int i = 0; i < N; i++ ) {

		int n, k;
		std::getline(std::cin, line);
		{
			tokenizer tokens(line, sep);			
			tokenizer::iterator tok_iter = tokens.begin();
			n = boost::lexical_cast<int>(*tok_iter++);
			k = boost::lexical_cast<int>(*tok_iter);
		}

		std::vector<int> pv;
		std::getline(std::cin, line);
		{
			tokenizer tokens(line, sep);
			for( auto sp : tokens ) {
				pv.push_back(boost::lexical_cast<int>(sp));
			}
		}

		std::list<int> dv;
		int pp = -1;
		for( auto p : pv ) {
			int d = p - pp;
			if( pp != -1 ) {
				dv.push_back(d);
			}
			pp = p;
		}

		dv.sort(std::greater<int>());
		std::cout << solve(k, dv) << std::endl;
	}
	
	return 0;
}

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

int search(int *array, int n, int x) {
    int pl = 0;
    int pr = n - 1;
    
    while(pl <= pr) {
        int pc = (pl + pr) / 2;
        if(array[pc] == x) {
            return pc;
        } else if(array[pc] < x) {
            pl = pc + 1;
        } else if(x < array[pc]) {
            pr = pc - 1;
        }
    }
    
    return -1;
}

int main(void) {
    int n;
    scanf("%d", &n);

    int *s = malloc(n * sizeof(int));
    if(s == NULL) {
        return 1;
    }

    for(int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }

    int q;
    scanf("%d", &q);

    int *t = malloc(q * sizeof(int));
    if(t == NULL) {
        return 1;
    }

    for(int i = 0; i < q; i++) {
        scanf("%d", &t[i]);
    }

    int cnt = 0;
    for(int i = 0; i < q; i++) {
        if(search(s, n, t[i]) != -1) {
            cnt++;
        }
    }

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

    free(s);
    free(t);
    return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

//dp[i][j][k] : i番目まで使ってjを作れるかどうか,ただしk個使った。

signed main() {
	int N, A;
	cin >> N >> A;
	vector<int>x(N);
	rep(i, N)cin >> x[i];
	int sum = 0;
	rep(i, N)sum += x[i];
	vector<vector<vector<int>>>dp(N + 1, vector<vector<int>>(sum + 1, vector<int>(N + 1, 0)));
	dp[0][0][0] = 1;
	rep(i, N) {
		for (int j = 0; j <= sum; j++) {
			for (int k = 0; k < N; k++) {
				dp[i + 1][j][k] += dp[i][j][k];
				if (j + x[i] <= sum)dp[i + 1][j + x[i]][k + 1] += dp[i][j][k];
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int num = A * i;
		if (num > sum)continue;
		ans += dp[N][num][i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 56192
#include <iostream>
#include <string>


using namespace std;



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

	if (a == "H") cout << b << endl;
	else if(a=="D")
	{
		if (b == "H")cout << "D" << endl;
		else if (b == "D")cout << "H" << endl;
	}

	return 0;
}


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

int main(){
    long long n;
    cin >> n;

    string s;
    cin >> s;
    string ans;

    for(long long i = 0; i < s.size(); i++){
        if(s[i] + n <= 'Z') ans.push_back(s[i] + n);
        else{
            long long delta = s[i] + n - 'Z' - 1;
            ans.push_back('A' + delta);
        }
    }

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

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

int main() {
  int N; cin >> N;
  int A[N][3];
  for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> A[i][j];
  int dp[N][3]; for (int j = 0; j < 3; j++) dp[0][j] = A[0][j];
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = 0;
      for (int k = 0; k < 3; k++) {
        if (j != k) dp[i][j] = max(dp[i][j], dp[i-1][k] + A[i][j]);
      }
    }
  }
  cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}

Measured memory_bytes: 5928
from collections import Counter
import heapq

n = int(input())
v = list(map(int, input().split()))
o = [x for x in v[0:n:2]]
e = [x for x in v[1::2]]
oc = Counter(o)
ec = Counter(e)
ocfreq = [(x[1]*(-1),x[0]) for x in oc.items()]
ecfreq = [(x[1]*(-1),x[0]) for x in ec.items()]
heapq.heapify(ocfreq)
heapq.heapify(ecfreq)
o1 = heapq.heappop(ocfreq)
e1 = heapq.heappop(ecfreq)
if o1[1] != e1[1]:
    print(n+o1[0]+e1[0])
else:
    if len(ocfreq) == 0 and len(ecfreq) == 0:
        print(n//2)
    elif len(ocfreq) == 0:
        e2 = heapq.heappop(ecfreq)
        print((n//2)+e2[0])
    elif len(ecfreq) == 0:
        o2 = heapq.heappop(ocfreq)
        print((n//2)+o2[0])
    else:
        e2 = heapq.heappop(ecfreq)
        o2 = heapq.heappop(ocfreq)
        print(n+min(o1[0]+e2[0],o2[0]+e1[0]))

Measured memory_bytes: 23896
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;


int main() {
	int n,k;
	cin >> n >> k;
	long long  ans = 0;

	
	if (k % 2 == 0) {
		k /= 2;
		//cout << n / k << endl;

		long long pat1, pat2;
		pat1 = (n / k) / 2;
		pat2 = n / k - pat1;
		ans = pat1 * pat1*pat1 + pat2 * pat2*pat2;
	}
	else {
		long long abc_pat = n / k;
		ans += abc_pat * abc_pat * abc_pat;
	}
	cout << ans << endl;
}

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

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    rep(i, A)
    {
        if (K <= 0)
        {
            break;
        }
        ans++;
        K--;
    }
    rep(i, B)
    {
        if (K <= 0)
        {
            break;
        }
        K--;
    }
    rep(i, C)
    {
        if (K <= 0)
        {
            break;
        }
        ans--;
        K--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools


def rdp_connect() -> bool:
    global n, m, a
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        return False
    a = list(map(int, input().split()))
    return True


if __name__ == '__main__':
    while rdp_connect():
        lis = filter(lambda e: e <= m, map(sum, itertools.combinations(a, 2)))
        try:
            print(max(lis))
        except ValueError:
            print('NONE')

Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
long long ans=0,a,b,c,n;
string s,t;
int main(){
  cin >> a >> b >> c >> n;
  int d=max({a,b,c});
  for(int i=0;i<n;i++){
    d*=2;
  }
  ans+=a+b+c+d-max({a,b,c});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int cnt;
int m;
vector<int> G;
void insertionSort(int A[], int n, int g);
void shellSort(int A[], int n);

int main()
{
  int n;
  cin >> n;
  int *array = new int[n];
  for(int i = 0; i < n; i++) cin >> array[i];
  shellSort(array, n);
  cout << m << endl;
  for(int i = m-1; i >= 0; i--){
    cout << G.at(i);
    if(i != 0) cout << " ";
  }
  cout << endl;
  cout << cnt << endl;
  for(int i = 0; i < n; i++) cout << array[i] << endl;
  
  return 0;
}

void insertionSort(int A[], int n, int g){
  for(int i = g; i < n; i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  cnt = 0;
  m = 1;
  int add = 1;
  G.push_back(add);
  add = 3 * add + 1;
  while(add <= n){
    G.push_back(add);
    add = 3 * add + 1;
    m++;
  }
  
  for(int i = m-1; i >= 0; i--){
    insertionSort(A, n, G.at(i));
  }
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n;
  string s;
  cin >> n >> s;
  Vi a(2,0);
  rep(i,0,n){
    if(s[i]=='(') a[1]++;
    else if(s[i]==')' && a[1]==0) a[0]++;
    else a[1]--;
  }
  //Vout(a);
  
  rep(i,0,a[0]) cout << '(';
  cout << s;
  rep(i,0,a[1]) cout << ')';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
#define EPR(msg) cerr << msg << endl;
#define AST(exp, msg) EPR(msg) assert(exp);
#define TAST(exp, msg) EPR(msg) while(!exp){}
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


bool is_palindrome(string S) {
  string T = S;
  reverse(T.begin(), T.end());
  return S == T;
}

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

  string S; cin>>S;
  int N = S.size();
  AST(N%2 == 1, "長さは奇数");

  string L = S.substr(0,N/2);
  string R = S.substr((N+1)/2, N/2);
  
  string  ans = "No";
  if (is_palindrome(S) && is_palindrome(L) && is_palindrome(R)){
    ans = "Yes";
  }

  cout << ans << endl;


  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=1000+5;
const ll MOD=(ll)1e9+7;

int n,m;
bool a[N][N];
ll dp[N][N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=m;j++)
        {
            if(s[j-1]=='#')
            {
                a[i][j]=1;
            }
        }
    }
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]==0)
            {
                if(i==1 && j==1) continue;
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[n][m]<<"\n";
    return 0;
}


Measured memory_bytes: 9088
/*  ex5_3
    hangan2020 */

#include <stdio.h>
#define IS 101

int main(void){
    int H, W;
    int i, j;
    char matrix[IS][IS];


    scanf("%d %d", &H, &W);
    //Input by loop
    for (i = 0; i < H ; i++){
        for(j = 0; j < W ; j++){
            scanf(" %c", &matrix[i][j]);
        }
    }

    // Scanning for '.' only rows
    for (i = 0; i < H ; i++){
        for(j = 0; j < W ; j++){
            if(matrix[i][j] != '.'){
                break;
            }
            else if((j == W-1)&&(matrix[i][j] == '.')){
                matrix[i][W] = 'n';// Mark n(for none) at end of row
            }
        }
    }
    // Scanning for '.' only columns
    for (j = 0; j < W ; j++){
        for(i = 0; i < H ; i++){
            if(matrix[i][j] != '.'){
                break;
            }
            else if((i == H-1)&&(matrix[i][j] == '.')){
                matrix[H][j] = 'n';// Mark n(for none) at end of column
            }
        }
    }

    //Printing out by loop ( except for rows or columns that starts with 'n')
    for (i = 0; i < H ; i++){
        if(matrix[i][W] != 'n'){
            for(j = 0; j < W ; j++){
                if(matrix[H][j] != 'n'){
                    printf("%c", matrix[i][j]);
                }
            }
        printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

    int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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

int main()
{
    string S;
    cin >> S;
    string edit;
    string lat;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == '0'){
            edit += '0';
            lat = '0';
        }
        else if(S[i] == '1'){
            edit += '1';
            lat = '1';
        }
        else{
            if(edit.size() > 0){
                edit.erase(edit.size() - 1);
            }
        }
    }
    cout << edit << endl;
}


Measured memory_bytes: 256