akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
int gcd(int,int);

int main(){
  int k;
  cin >> k;
  
  int sum = 0;
  rep(i,k){
    rep(j,k){
      rep(m,k){
        sum += gcd(gcd(i,j),m);
      }
    }
  }
  cout << sum << endl;
}

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

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl "\n"
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n;
    cin >> n;
    vector<double> p(n);
    vector<vector<double>> dp(n, vector<double>(n+1));
    rep(i,0,n) {
        cin >> p[i];
    }
    dp[0][0] = 1-p[0];
    dp[0][1] = p[0];
    rep(i,1,n) {
        rep(j,0,i+2) {
            dp[i][j] = dp[i-1][j]*(1-p[i]);
            if (~j) {
                dp[i][j] += dp[i-1][j-1]*p[i];
            }
        }
    }
    double ans = 0;
    rep(i,n/2+1, n+1) {
        ans += dp[n-1][i];
    }
    printf("%.10lf\n", ans);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 73628
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  long a, b, c;
  cin >> a >> b >> c;
  if((a % 2) * (b % 2) * (c % 2)){
    if(a > b && b > c) cout << b * c << endl;
    else if(b > c) cout << a * c << endl;
    else cout << a * b << endl;
  }else{
    std::cout << 0 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << '\n';
    return 0;
}


Measured memory_bytes: 888
n=int(input())
A=list(map(int,input().split()))
Alist=[0]*(10**5+1)
for a in A:
    Alist[a]+=1
ans=1
for i in range(min(A),max(A)):
    ans=max(ans,Alist[i]+Alist[i+1]+Alist[i+2])
if min(A)==max(A):
    ans=n
print(ans)

Measured memory_bytes: 20728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	set<string> st;
	string s, t;
	cin >> s >> t;

	int n = sz(s), m = sz(t);
	rep(i, 0, n) {
		string _s = s;
		bool flag = true;
		rep(j, 0, m) {
			if (i + j > n || (s[i + j] != '?' && s[i + j] != t[j])) {
				flag = false;
				break;
			}
			_s[i + j] = t[j];
		}
		if (flag) {
			rep(i, 0, n) {
				if (_s[i] == '?') _s[i] = 'a';
			}
			st.insert(_s);
		}
	}

	if (sz(st) == 0) {
		cout << "UNRESTORABLE" << endl;
	} else {
		cout << *st.begin() << endl;
	}
}

Measured memory_bytes: 3040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int N, W;
    s2(N, W);

    vi dp(W + 1, 0);
    int w, vl;
    f(i, 0, N){
        s2(w, vl);
        for(int j = W - w; j >= 0; j--){
            dp[j + w] = max(dp[j + w], dp[j] + vl);
        }
    }

    int ans = *max_element(dp.begin(), dp.end());
    p(ans);
    return;
}

class DKnapsack1 {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    DKnapsack1 solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

int main(){
	int a,b,c;

	cin>>a>>b>>c;

	if(a==b&&b==c){
		cout<<1<<endl;
	}else if(a==b){
		cout<<2<<endl;
	}else if(b==c){
		cout<<2<<endl;
	}else if(c==a){
		cout<<2<<endl;
	}else{
		cout<<3<<endl;
	}
	
	return 0;
}

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

#define X first
#define Y second
#define Mod 1000000007
#define N 100010
#define M 101

int t[N];

const int INF=1<<30;

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,c,k,ans=0;
	scanf("%d%d%d",&n,&c,&k);
	for (int i=1;i<=n;i++) scanf("%d",&t[i]);
	sort(t+1,t+n+1);
	for (int i=1;i<=n;)
	{
		int j=i;
		while (j<=n && t[j]<=t[i]+k && j-i+1<=c) j++;
		i=j;  ans++;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace ITP1_9_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] cmd = Console.ReadLine().Split(' ');
                int a = int.Parse(cmd[1]);
                int b = int.Parse(cmd[2]);
                switch (cmd[0])
                {
                    case "print": Console.WriteLine(str.Substring(a, b - a + 1)); break;
                    case "reverse":
                        string sub = str.Substring(a, b - a + 1);
                        str = str.Remove(a, b - a + 1);
                        str = str.Insert(a,new string(sub.Reverse().ToArray()));
                        break;
                    case "replace": str = str.Remove(a, b - a + 1).Insert(a, cmd[3]); break;
                    default: break;
                }
            }
        }
    }
}

Measured memory_bytes: 9524
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

bool range(int n, int x, int y)
{
	return 0 <= x && x < n && 0 <= y && y < n;
}
void rec(vector<vector<char> >& g, int x, int y, int dx, int dy, int c)
{	
	int n = g.size();
	if(c == 4) return;
	
	g[x][y] = '#';

	int nx = x + dx, ny = y + dy;
	if(range(n, nx, ny) && g[nx][ny] != '#' && (range(n, nx + dx, ny + dy) ? g[nx + dx][ny + dy] != '#' : true))
	{
		rec(g, nx, ny, dx, dy, 0);
	}
	else
	{
		if(dx == 0 && dy == -1) 	rec(g, x, y,  1, 0, c + 1);
		else if(dx == 1 && dy == 0)	rec(g, x, y,  0, 1, c + 1);
		else if(dx == 0 && dy == 1)	rec(g, x, y, -1, 0, c + 1);
		else						rec(g, x, y, 0, -1, c + 1);
	}
}

int main()
{
	int d;
	cin >> d;
    
	for(int n; d && cin >> n; d--)
	{
		vector<vector<char> > g(n, vector<char>(n, ' '));
		
		rec(g, 0, n - 1, 0, -1, 0);
		
		if(n % 2 == 0) g[n / 2][n / 2] = ' ';
		
		rep(y, n) rep(x, n) cout << g[x][y] << (x + 1 == n ? "\n" : "");
		
		if(d != 1) cout << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;

    ll res;

    res = (N-1)*(1+N-1)/2;

    cout << res << endl;

    return 0;    

}



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

using namespace std;

const int N = 100005;
string s, t;
int ps[N], pt[N], n, m, q;

main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	n = s.size(); m = t.size(); 
	s = ' ' + s;
	for(int i = 1; i <= n; ++i) {
		int tmp = 1;
		if(s[i] == 'B') tmp++;
	 	ps[i] = ps[i - 1] + tmp;
	}
	t = ' ' + t;
	for(int i = 1; i <= m; ++i) {
		int tmp = 1;
		if(t[i] == 'B') tmp++;
		pt[i] = pt[i - 1] + tmp;
	}
	cin >> q;
	while(q--) {
		int x, y, u, v;
		cin >> x >> y >> u >> v;
		if((ps[y]-ps[x - 1]) % 3 == (pt[v]-pt[u - 1]) % 3) cout << "YES\n";
		else cout << "NO\n";
	}
}

Measured memory_bytes: 1644
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll H, W, K;
string strs[10];

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> H >> W >> K;
	rep(i, H) cin >> strs[i];
	ll ans = 0;

	rep(bit_h, 1 << H){
		rep(bit_w, 1 << W){
			ll tmp_k = 0;
			rep(i, H){
				rep(j, W){
					if((bit_h >> i & 1) && (bit_w >> j & 1)){
						if(strs[i][j] == '#') tmp_k++;
					}
				}
			}
			// print(bit_h, bit_w, tmp_k);
			if(tmp_k == K) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,m;cin>>n>>m;
    int s[m];
    for(int i = 0;i<m;i++) s[i] = 0;
    for(int i = 0;i<n;i++){
      int k;cin>>k;
      for(int j = 0;j<k;j++){
        int a;cin>>a;
        a -=1;
        s[a]+=1;
      }
    }
    int ko= 0;
    for(int i = 0;i<m;i++){
      if(s[i] == n) ko++;
    }
    cout<<ko;
    return 0;
}

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

int main(){
  int N,ans=1;
  cin >> N;
  vector<int>mochi(N);
  for(int i=0; i<N ; i++){
    cin >> mochi.at(i);}
  
  sort( mochi.begin(), mochi.end() );
  reverse( mochi.begin(), mochi.end() );
  
  for(int i=0; i<N-1 ; i++){
    
    if( mochi.at(i) > mochi.at(i+1) ){
      ans++;}
    
    if( mochi.at(i) == mochi.at(i+1) ){
      continue;}
  }
  
  cout << ans << endl;
}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    c = c - a - b;
    if(c < 0) {
        cout << "No" << endl;
        return 0;
    }
    c *= c;
    if(4 * a * b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
     int main() {
     int N,M,A,study;
      cin>>N>>M;
      study=0;
      while(cin>>A){
      study+=A;}
      if(N>=study){cout<<N-study<<endl;}
      else{cout<<-1<<endl;}
      return 0;
    }

Measured memory_bytes: 3640
// Try AtCoder
// author: Loenardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = n - 1;
    for i in 1 ..  {
        if i * i > n {
            break;
        }
        if n % i != 0 {
            continue;
        }
        ans = std::cmp::min(ans, (i - 1) + (n / i - 1));
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

ll n,a,b,c,d;
vector<P> operators(3);
map<ll,ll> mp;

ll dfs(ll x) {
  if(mp.find(x)!=mp.end()) return mp[x];
  ll ret=(4e18/d<x)?4e18:d*x;
  for(auto op:operators) {
    ll div=op.first,cost=op.second;
    ret=min(ret,dfs(x/div)+cost+d*(x%div));
    if(x%div!=0) ret=min(ret,dfs(x/div+1)+cost+d*(div-x%div));
  }
  mp[x]=ret;
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t;cin>>t;
  rep(tt,t) {
    cin>>n>>a>>b>>c>>d;
    mp.clear();
    operators[0]=P(2,a);
    operators[1]=P(3,b);
    operators[2]=P(5,c);
    mp[0]=0,mp[1]=d;
    print(dfs(n));
  }
  return 0;
}

Measured memory_bytes: 4460
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
constexpr int MX = 1e5+5;

int W[105];
ll V[105];
ll a[MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
	int n,w; cin >> n >> w;
	rep(i,n) {
		cin >> W[i] >> V[i];
	}

	rep(i,n) {
		for(int j=w; j-W[i]>=0; j--) {
			chmax(a[j], a[j-W[i]]+V[i]);
		}
	}

	cout << a[w] << endl;
    return 0;
}


Measured memory_bytes: 4392
#include <stdio.h>
#include <string.h>
int main (){
    char s[25];

    scanf("%[^\n]",s);

    for(int i = 0; i < strlen(s) ; i++){
        if(s[i] == ','){
            printf(" ");
        } else {
            printf("%c",s[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> nums{1};
    for (int i = 6; i <= n; i*=6) {
        nums.push_back(i);
    }
    for (int i = 9; i <= n; i*=9) {
        nums.push_back(i);
    }
    sort(nums.begin(), nums.end());
    int m = nums.size();
    vector<int> dp(n+5, 0);
    for (int i = 0; i <= n; i++) {
        dp[i] = i;
    }
    for (int i = 1; i < m; i++) {
        for (int j = 1; j <= n; j++) {
            if (j >= nums[i]) {
                dp[j] = min(dp[j], dp[j-nums[i]] + 1);
            }
        }
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,K;
    cin>>N>>K;
    vector<double> p(N);
    rep(i,N){
        cin>>p[i];
        p[i] = (p[i] + 1) / 2;
    }
    double ans = 0;
    double sum = 0;
    rep(i,K){
        sum += p[i];
    }
    ans = sum;
    for(int i = K ; i < N; i++){
        sum -= p[i - K];
        sum += p[i];
        chmax(ans, sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long ans,x=b*d,y=a*d,z=b*c,k=a*c;
    ans=max(x,max(y,max(z,k)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		final int mod = 1000000007;
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		long m = sc.nextLong();
		HashMap<Long, Integer> map = new HashMap<>();
		if(m <= 1 || n <= 1) {
			System.out.println(1); //1以下の場合
		return;
		}
		for(long i = 2 ; i <= Math.sqrt(m) + 1 ; i++) {
			if(m % i != 0)
				continue;
			m /= i;
			map.put(i, map.getOrDefault(i,  0) + 1);
			if(m == 1)
				break;
          i--;
		}
		if(m != 1)
			map.put(m, map.getOrDefault(m,  0) + 1);
		long ans = 1;
		for(Long l : map.keySet()) {
			ans *= nCk(map.get(l) + n - 1, map.get(l).intValue() , mod);
			ans += mod;
			ans %= mod;
		}
		System.out.println(ans);



	}
	public static int nCk(int n,int k,int M) {
        long ret = 1;
        int min = Math.min(k, n-k);
        for(int i=1;i<=min;i++) {
            ret = (ret * pow(i,M-2,M)) % M;
        }
        for(int i=n-min+1;i<=n;i++) {
            ret = (ret * i) % M;
        }
        return (int)ret;
    }
	 public static long pow(long a,long b,int M) {
	        long ret = 1;
	        long tmp = a;
	        while(b>0) {
	            if((b&1)==1) ret = (ret * tmp) % M;  //2進数によるべき乗の高速計算
	            tmp = (tmp * tmp) % M;
	            b = b>>1;
	        }
	        return ret;
	    }


}



Measured memory_bytes: 35840
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
vector<string> x, y;

int bubble_sort(){
    int count=0;
    int n = x.size();
    for(int i = 0; i < n-1; i++){
        for(int j = n-1; j >= i+1; j--){
            if(x[j][1] < x[j-1][1]){
                string tmp = x[j-1];
                x[j-1] = x[j];
                x[j] = tmp;
                count++;
            }
        }
    }
    return count;
}
int selec_sort(){
    int count=0;
    int n = y.size();
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i+1; j < n; j++){
            if(y[j][1] < y[minj][1]) minj = j;
        }
        string tmp = y[minj];
        y[minj] = y[i];
        y[i] = tmp;
        if(minj != i) count++;
    }
    return count;
}


int main(){
    string ch;
    int n; scanf("%d", &n);
    for(int i = 0; i < n; i++){
        cin >> ch;
        x.push_back(ch);
        y.push_back(ch);
    }
    bubble_sort();
    selec_sort();
    for(int i = 0; i < n-1; i++)
        cout << x[i] << " ";
    cout << x[n-1] << endl;
    puts("Stable");
    for(int i = 0; i < n-1; i++)
        cout << y[i] << " ";
    cout << y[n-1] << endl;
    if(x==y) puts("Stable");
    else puts("Not stable");
    return 0;
}



Measured memory_bytes: 3272
n = int(input())
flowers = list(map(int, input().split()))
flowers.append(0)
cnt = 0
if(all([x<=0 for x in flowers])): print(0)
else: 
    for i in range(sum(flowers)+1):
        #print(i)
        if(all([x<=0 for x in flowers])): break
        #print(flowers, i, cnt)
        for j in range(n-2):
            if(flowers[j] > 0 and flowers[j+1] <= 0 and any([x>0 for x in flowers[j+2:]])): cnt+=1
        flowers = list(map(lambda x: (x-1), flowers))
    print(i + cnt)

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

int main(){
  int R,G,B,N;
  cin >>R>>G>>B>>N;
  int cnt=0;
  for (int i=0;i<3001;i++){
    for (int j=0;j<3001;j++){
      if((N-i*R-j*G)<0){
        continue;
      }
      if((N-i*R-j*G)%B==0){
        cnt++;
      }
    }
  }
  cout <<cnt<<endl;
  return 0;
}



Measured memory_bytes: 256
n, k, s = map(int, input().split())

INF = 10**9
if s != 10**9:
    ans = [INF] * n
    for i in range(k):
        ans[i] = s
    print(*ans)
else:
    ans = [1] * n
    for i in range(k):
        ans[i] = s
    print(*ans)

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

int digit_sum(int x) {
    int res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    
    int ans = 1e9;
    REP(A, N) {
        int B = N - A;
        ans = min(ans, digit_sum(A) + digit_sum(B));
    }
    cout << ans << endl;
    return 0;
}


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


int main() {
  string S, T;
  cin >> S >> T;
  bool ans = false;
  for(int i = 0; i < (int)S.size(); i++){
    if(S == T){
      ans = true;
      break;
    }
    S = S.back() + S.substr(0, S.size()-1);
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(void) {
    int A,B,C;
    cin>>A>>B>>C;
    if ((A == B && A != C) || (A == C && A != B) || (C == B && A != C)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	char c;
  	for(int i=0; i<9; i++){
		cin >> c;
      if(i==0 || i==4 || i==8){
		cout << c;
      }
    }
   cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const long long int mo=1e9+7;
typedef long long ll;

ll dfs(int K,const vector<vector<int> > &graph, int now, int from)
{
    int can_use_color_num;
    if(from==-1)can_use_color_num=K-1;
    else can_use_color_num=K-2;
    if(K<graph[now].size())return 0;
    else
    {
        ll case_num=1;
        for(auto e:graph[now])
        {
            if(e==from)continue;
            case_num*=can_use_color_num;
            can_use_color_num--;
            case_num%=mo;
        }
        for(auto e:graph[now])
        {
            if(e==from)continue;
            case_num*=dfs(K,graph,e,now);
            case_num%=mo;
        }
        return case_num;
    } 
}
main()
{
    int n,k;cin>>n>>k;
    vector<vector<int> > graph(n);
    for(int i=0;i<n-1;i++)
    {
        int a,b;cin>>a>>b;a--,b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    ll answer=k*dfs(k,graph,0,-1);
    answer%=mo;
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
#include <math.h>

int main(){

  double x1,y1,x2,y2;

  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

  printf("%lf",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));

  return 0;

}	


Measured memory_bytes: 2112
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll x, y;
	cin >> x >> y;
	ll ans = 0;
	while(1){			
		if(x>y) break;
		ans++;
		x*=2;
	}
	cout << ans << endl;
	return 0;
}

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

long long int x, y;
long long int ans;
int main() {
    ios::sync_with_stdio(false);
    cin >> x >> y;
    
    for (long long int i = x; i <=y; i*=2) {
        ans++;
    }
    cout << ans << '\n';
    
}

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

int main(){

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

	long int mat1[n][m], mat2[m][l] = {0};

	for(int i=0; i<n; ++i){
		for(int j=0; j<m; ++j){cin >> mat1[i][j];}
	}

	for(int i=0; i<m; ++i){
		for(int j=0; j<l; ++j){cin >> mat2[i][j];}
	}

	long int sum=0;

	for(int i=0; i<n; ++i){
		for(int j=0; j<l; ++j){
			sum = 0;
			for(int k=0; k<m; ++k){
				sum += mat1[i][k] * mat2[k][j];
			}
			(j==l-1) ? (cout << sum << endl) : (cout << sum << " ");
		}
	}

	return 0;

}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;
ll a[3001];
ll dp[3001][3001];
bool f[3001][3001];
ll solve(int l,int r){
    if(f[l][r]) return dp[l][r];
    f[l][r]=true;
    if((l+n-1-r)%2==0){
        if(l==r) return dp[l][r]=a[l];
        return dp[l][r]=max(a[l]+solve(l+1,r),a[r]+solve(l,r-1));
    }
    else{
        if(l==r) return dp[l][r]=-a[l];
        return dp[l][r]=min(solve(l+1,r)-a[l],solve(l,r-1)-a[r]);
    }
}
int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    solve(0,n-1);
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 78464
#include<iostream>
 
using namespace std;
 
int main(){
  int n,a,b[100001]{0};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    for(int j=a-1;j<=a+1;j++){
      if(j>=0&&j<=100000)b[j]++;
    }
  }
  int MAX=0;
  for(int i=0;i<=100000;i++){
    if(b[i]>MAX)MAX=b[i];
  }
  cout << MAX << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int h,w,i,j,f=0;
    char a[60][60];
   scanf("%d %d",&h,&w);

        for(i=0;i<h;i++)
    {
        for(j=0;j<w+1;j++)
          scanf("%c",&a[i][j]);
    }
   /* for(i=0,j=0;j<=w+1;j++)
        a[i][j]='.';
    for(i=h+1,j=0;j<=w+1;j++)
        a[i][j]='.';
    for(j=0,i=1;i<=h;i++)
        a[i][j]='.';
    for(j=w+1,i=1;i<=h;i++)
        a[i][j]='.';*/
    /*for(i=0;i<h;i++)
    {
        printf("%drow\n",i);
           printf("%s",a[i]);

    }*/
    for(i=1;i<=h;i++)
       for(j=1;j<=w+1;j++)
    {
        f=0;
        if(a[i][j]=='#')
        {
            if(a[i+1][j]=='#'||a[i][j+1]=='#'||a[i-1][j]=='#'||a[i][j-1]=='#')
                f=1;
            if(f==0)
            {
                printf("No\n");return 0;
            }
        }
    }
       printf("Yes\n");


    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    char a,b;
    cin>>a>>b;
    if ((a=='H' and b=='H') or (a=='D' and b=='D')) cout << "H" << endl;
    else cout << "D" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
import math
import functools
import sys

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

wise = functools.reduce(math.gcd, A)
if wise != 1:
    print('not coprime')
    sys.exit(0)

A = list(filter(lambda a: a != 1, A))

if len(A) == 0:
    print('pairwise coprime')
    sys.exit(0)

pcount = 78498
if len(A) > pcount:
    print('setwise coprime')
    sys.exit(0)

Amax = max(A) + 1

hurui = [1] * 1001
primes = []

for n in range(2, 1001):
    if hurui[n] != 1:
        continue

    primes.append(n)

    k = 2
    while n * k <= 1000:
        hurui[n * k] = n
        k += 1




count = [0] * (Amax+1)

pairwise = True
for i in range(len(A)):
    a = A[i]
    if a == 1:
        continue

    for p in primes:
        if a % p == 0:
            count[p] += 1
            while a % p == 0:
                a = a // p
    if a != 1:
        count[a] += 1

if max(count)==1:
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 228736
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, M);
  vector<vector<int>> s(M);
  FOR(i, M) {
    int k;
    cin >> k;
    FOR(j, k) {
      GI(sn);
      s[i].push_back(sn - 1);
    }
  }
  vector<int> p(N);
  FOR(i, M) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    bool f = 1;
    FOR(m, M) {
      int sum = 0;
      for (int j : s[m]) {
        if ((i >> j) & 1) {
          sum++;
        }
      }
      if (sum % 2 != p[m]) {
        f = 0;
        break;
      }
    }
    if (f)
      ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]) {
        int i, j;
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h==0 && w==0)break;
            for (i = 0; i < h; i++) {
                if (i % 2 == 0) {
                    for (j = 0; j < w; j++) {
                        if (j % 2 == 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                } else {
                    for (j = 0; j < w; j++) {
                        if (j % 2 == 0) {
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                    System.out.println();
                }
            }
            System.out.println();
        }

        sc.close();
    }
}


Measured memory_bytes: 35380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int ans = 0;
    rep(i, s.size()){
        for(int j=1;j<=s.size()-i;j++){
            cerr<<s.substr(i,j)<<endl;
            bool isok = true;
            for(auto c : s.substr(i,j)){
                if(!(c=='A' || c=='G' || c=='C' || c=='T')) isok = false;
            }
            if(isok) ans = max(ans, (int)s.substr(i,j).size());
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  while(true)
  {
    cin>>a>>b;
    if(a==0&&b==0) return 0;
    if (b < a) swap(a,b); cout << a << " " << b << "\n";
  }
}


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

int main(){

int N,A,B,C,D;
cin >> N;
D = 0;
vector<int> L(N);

for(int i = 0; i < N;i++){
	cin >> L.at(i);
}
for(int i=0;i<N-2;i++){
	A = L.at(i);
	for(int j=i+1;j<N-1;j++){
		B = L.at(j);
		if(A==B) continue;
		for(int k=j+1;k<N;k++){
			C = L.at(k);
			if(A==C||B==C) continue;
			if((A+B>C&&B+C>A&&C+A>B)) D++;
		}
	}
}
cout << D << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)

const int INF = 100;
int h, w;
char maze[21][21];
int d[21][21];
int dx[4] = {1, 0, -1,  0};
int dy[4] = {0, 1,  0, -1};
int sx, sy;


int solve() {
    queue<P> que;

    que.push(P(sx, sy));
    d[sx][sy] = 0;
    int max_d = 0;
    
    while(que.size()){
        P p = que.front();
        que.pop();

        rep (i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny <= w && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                if (max_d < d[nx][ny]) max_d = d[nx][ny];
            }
        }
    }

    return max_d;
}

void init() {
    rep(i, h) {
        rep(j, w) {
            d[i][j] = INF;
        }
    }
}

int main() {
    int ans = 0;
    cin >> h >> w;
    rep(i, h) {
        rep(j, w) {
            cin >> maze[i][j];
            d[i][j] = INF;
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (maze[i][j] == '.') {
                sx = i; sy = j;
                int max_d = solve();
                if (ans < max_d) ans = max_d;
            }
            init();
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        l: usize, r: usize, d: usize,
    }

    let mut ans = 0;

    for i in l..=r {
        if i % d == 0 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2124
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	bool b[4] = {};
	rep(i,0,n){
		char c;
		cin >> c;
		if(c == 'G')
			b[0] = 1;
		else if(c == 'W')
			b[1] = 1;
		else if(c == 'P')
			b[2] = 1;
		else 
			b[3] = 1;
	}
	int sum = 0;
	rep(i,0,4){
		if(b[i])
			sum++;
	}

	if(sum == 3)
		P("Three");
	else
		P("Four");

	ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//累積和
// vectorっぽく使う
template <typename T>
struct cumulative_sum {
    // data[i]:元の数列
    vector<T> data;
    // sum[i]:[0,i)の和
    vector<long long int> sum;
    //要素数を指定して初期化
    cumulative_sum(const int n) {
        data.assign(n, 0);
    }
    T& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        sum.assign(data.size() + 1, 0);
        for (int i = 0; i < (int)data.size(); i++) {
            sum[i + 1] = sum[i] + data[i];
        }
    }
    //[a,b)の和を求める
    long long int query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    lint n, k;
    cin >> n >> k;
    cumulative_sum<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.build();
    vector<lint> b;
    for (int left = 0; left <= n; left++) {
        for (int right = left + 1; right <= n; right++) {
            b.push_back(a.query(left, right));
        }
    }
    lint ans = 0;
    for (int i = 45; i >= 0; i--) {
        // k個のandでiビット目を立てられるか見る
        int num_bit = 0;
        for (int j = 0; j < b.size(); j++) {
            if (b[j] & (1LL << i)) {
                num_bit++;
            }
        }
        if (num_bit >= k) {
            //粛清
            for (int j = 0; j < b.size(); j++) {
                if ((b[j] & (1LL << i)) == 0) {
                    b[j] = 0;
                }
            }
            ans += 1LL << i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6388
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int x;
  cin >> x;
  if (x == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else if (x == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (x == 24) {
    cout << "Christmas Eve" << endl;
  } else {
    cout << "Christmas" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def f(list, n):
  length=len(list)
  if list[-1]<n:
    return length
  elif list[0]>=n:
    return 0
  else:
    a=length//2
    b=length//4
    while b>=1:
      if list[a]<n:
        a+=b
      else:
        a-=b
      b=b//2
      
    if list[a]<n:
      while list[a+1]<n:
        a+=1
    else:
      while list[a]>=n:
        a-=1
        
    return a+1  

n=int(input())
l=list(map(int, input().split()))
l.sort()
counter=0
for i in range(n-2):
  for j in range(i+1, n-1):
    counter+=f(l[(j+1):], l[i]+l[j]) #f(list, n) counts num in the sorted list under n
    
print(counter)    

Measured memory_bytes: 53416
n=int(input())
A=list(map(int,input().split()))

A.sort(reverse=True)
x,y=0,0
flag=False
for i in range(1,n):
  if flag:
    flag=False
    continue
  if A[i-1]==A[i]:
    if x==0:
      x=A[i]
      flag=True
    else:
      y=A[i]
  if x!=0 and y!=0:
    break
print(x*y)

Measured memory_bytes: 14252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int[] foo = new int[9];
        int[] ful = new int[9];
          
        for (int k = 0; k < 9; k++){
            ful[k] = 0;
            foo[k]=sc.nextInt();
           }
      
        int b = sc.nextInt();
        int[] bin = new int[b];
        
        for (int i = 0; i < b; i++){
          bin[i]=sc.nextInt();
           for (int j = 0; j < 9; j++){
            if (bin[i] == foo[j]){
             ful[j] = 1;
                }
              }           
            }

      if ((ful[0] ==1 ) && (ful[1] ==1 ) && (ful[2] ==1)){
      System.out.println("Yes");
         }else if ((ful[3] ==1 ) && (ful[4] ==1 ) && (ful[5] ==1)){
       System.out.println("Yes");
         }else if ((ful[6] ==1 ) && (ful[7] ==1 ) && (ful[8] ==1)){
       System.out.println("Yes");
         }else if ((ful[0] ==1 ) && (ful[3] ==1 ) && (ful[6] ==1)){
       System.out.println("Yes");
         }else if ((ful[1] ==1 ) && (ful[4] ==1 ) && (ful[7] ==1)){
       System.out.println("Yes");
         }else if ((ful[2] ==1 ) && (ful[5] ==1 ) && (ful[8] ==1)){
       System.out.println("Yes");
         }else if ((ful[0] ==1 ) && (ful[4] ==1 ) && (ful[8] ==1)){
       System.out.println("Yes");
         }else if ((ful[2] ==1 ) && (ful[4] ==1 ) && (ful[6] ==1)){
       System.out.println("Yes");
         }else {
       System.out.println("No");
         }        
   
            
     }
}

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

int main() {
	int H, W;
	cin >> H >> W;
	char a[110][110];
	for(int i=0; i<H; ++i) for(int j=0; j<W; ++j) cin >> a[i][j];
	bool f;
	int k;
	for(int i=0; i<H; ++i){
	    f=true;
	    for(int j=0; j<W; ++j) if(a[i][j]=='#'){
	        f=false;
	        break;
	    }
	    if(f){
	        for(k=i; k<H; ++k){
	            for(int j=0; j<W; ++j){
	                if(k+1==H) a[k][j]=' ';
	                else a[k][j]=a[k+1][j];
	            }
	        }
	        --i;
	        --H;
	    }      
	}
	for(int j=0; j<W; ++j){
	    f=true;
	    for(int i=0; i<H; ++i) if(a[i][j]=='#'){
	        f=false;
	        break;
	    }
	    if(f){
	        for(k=j; k<W; ++k){
	            for(int i=0; i<H; ++i){
	                if(k+1==W) a[i][k]=' ';
	                else a[i][k]=a[i][k+1];
	            }
	        }
	        --j;
	        --W;
	    }     
	}
	for(int i=0; i<H; ++i){
	    for(int j=0;j<W; ++j) cout << a[i][j];
	    cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long n, furoTime;

	cin >> n >> furoTime;

	long time[200000];

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

	long ans = 0;

	for (int i = 0; i < n - 1; i++) {
		long next = time[i + 1] - time[i];
		ans += min(next, furoTime);
	}

	ans += furoTime;

	cout << ans << endl;




}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n,j=0;
  while(cin>>n){
  for(int a=0;a<10;a++)
    for(int b=0;b<10;b++)
      for(int c=0;c<10;c++)
	for(int d=0;d<10;d++)
	  if(a+b+c+d==n)
	    j++;
  cout<<j<<endl;
  j=0;
  }
  return 0;
}

Measured memory_bytes: 1160
import Control.Applicative

func (a,b) = a ++ " " ++ (show b)

main = do{
    n <- getLine;
    input <- map words . lines <$> getContents;
    let{
        cards = [ ((x!!0),((read::String->Int) (x!!1))) | x<-input ];
        allcards = [ (mark,number) | mark<-["S","H","C","D"], number<-[1..13] ];
        restcards = [ x | x<-allcards, notElem x cards ];
    };
    mapM_ putStrLn $ (map func) restcards;
}

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

int maior(int a, int b){
    if(a > b) return a;
    return b;
}


int main(){
    int a, b, max;
    cin >> a >> b;
    max = maior(a+b, a-b);
    max = maior(max, a*b);
    cout << max << endl;;
}

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

std::vector<int> divisor(int n) noexcept {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != n / i) {
                ret.push_back(n / i);
            }
        }
    }
    // std::sort(ret.begin(), ret.end());

    return ret;
}

int main() {
    int N;
    std::cin >> N;

    int A[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }
    std::sort(A, A + N);

    int ans = 0;
    std::set<int> s; 
    for (int i = 0; i < N; ++i) {
        if (s.count(A[i]) != 0) {
            continue;
        }

        std::vector<int> div = divisor(A[i]);
        bool ok = true;
        for (int v : div) {
            if (s.count(v) != 0) {
                ok = false;
                break;
            }
        }

        if (ok) {
            s.insert(A[i]);
            if ((i < (N-1) && A[i] == A[i+1]) == false) {
                ++ans;
            }
        }
    }

    std::cout << ans << std::endl; 

    return 0;
}


Measured memory_bytes: 13756
mod = 998244353

n, s = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

while a[-1] > s:
    a.pop(-1)
    if a == []:
        print(0)
        exit()

dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    newdp = [2 * j % mod for j in dp]
    for j in range(s - i + 1):
        newdp[j+i] += dp[j]
    dp = newdp

print(dp[s] * pow(2, n - len(a), mod) % mod)

Measured memory_bytes: 72172