akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstdlib>

using namespace std;

typedef long long lli;
typedef pair<lli, int> P;
const int L = 4;
lli n, in;
vector<lli> input;
map<lli, int> data;
set<lli> vis;

lli rev(lli num, int a, int b){
  string str;
  while(num > 0){
    str += (char)((int)(num % 10LL) + '0');
    num /= 10LL;
  }
  reverse(str.begin(), str.end());
  if(str.size() != n) str = "0" + str;
  reverse(str.begin() + a, str.begin() + b + 1);
  /*lli res = 0;
  for(int i=0;i<str.size();i++){
    res *= 10LL;
    res += (lli)(str[i] - '0');
    }
    return res;*/
  return strtoll(str.c_str(), NULL, 10);

}

int solve(){
  lli state = 0;
  for(int i=0;i<n;i++){
    state *= 10;
    if(input[i] != 10) state += input[i];
  }
  if(data.find(state) != data.end()) return data[state];
  vis.clear();
  P u = P(state, 0), v;
  queue<P> q;
  q.push(u);
  while(!q.empty()){
    u = q.front();
    q.pop();
    //if(data.find(u.first) != data.end()) return data[u.first] + u.second;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        v = P(rev(u.first, i, j), u.second + 1);
        if(vis.find(v.first) == vis.end()){
          vis.insert(v.first);
          if(data.find(v.first) != data.end()) return data[v.first] + v.second;
          if(v.second < L) q.push(v);
        }
      }
    }
  }
  return n-1;
}

void init(){
  data.clear();
  lli state = 0;
  for(int i=1;i<=n;i++){
    state *= 10;
    if(i != 10) state += i;
  }
  P u = P(state, 0), v;
  queue<P> q;
  q.push(u);
  data[state] = 0;
  //cout << u.first << ' ' << u.second << endl;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i == j) continue;
        v = P(rev(u.first, i, j), u.second + 1);
        if(data.find(v.first) == data.end()){
          //cout << v.first << ' ' << v.second << endl;
          data[v.first] = v.second;
          if(v.second < L) q.push(v);
        }
      }
    }
  }
}

main(){
  while(cin >> n){
    input.clear();
    for(int i=0;i<n;i++){
      cin >> in;
      input.push_back(in);
    }
    init();
    cout << solve() << endl;
  }
}

Measured memory_bytes: 29112
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

string in[11];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h, w, k, i, j, a;
    cin >> h >> w >> k;
    rep(i, h) {
        cin >> in[i];
    }
    ll ans(INF);
    rep(i, Lshift(1, (h - 1))) {
        ll ta(0);
        int cnt[11];
        memset(cnt, 0, sizeof(cnt));
        rep(a, w) {
            int idx(0);
            cnt[0] += in[0][a] - '0';
            xrep(j, 1, h) {
                if (i & Lshift(1, (j - 1))) {
                    idx++;
                }
                cnt[idx] += in[j][a] - '0';
            }
            rep(j, h) {
                if (cnt[j] > k) {
                    break;
                }
            }
            if (j < h) {
                // cout << "www " << cnt[j] << ' ' << k << endl;
                ta++;

                memset(cnt, 0, sizeof(cnt));
                idx = 0;
                cnt[0] += in[0][a] - '0';
                xrep(j, 1, h) {
                    if (i & Lshift(1, (j - 1))) {
                        idx++;
                    }
                    cnt[idx] += in[j][a] - '0';
                }
                rep(j, h) {
                    if (cnt[j] > k) {
                        ta = ans;
                        break;
                    }
                }
            }
        }
        rep(j, h) {
            if (i & Lshift(1, j)) {
                ta++;
            }
        }

        ans = min(ans, ta);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    bool array[N] = {false};
    for (int i = 1; i <= K; i++)
    {
        int di;
        cin >> di;
        for (int j = 1; j <= di; j++) {
            int a;
            cin >> a;
            if (array[a - 1] != true)
                array[a - 1] = true;
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if (array[i] == true)
            cnt++;
    }
    cout << N - cnt;
    return 0;
}

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

#define fs first
#define sc second

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; }


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

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
    map<string,string> mp{
        {"Sunny", "Cloudy"},
        {"Cloudy", "Rainy"},
        {"Rainy", "Sunny"},
    };

    string s; cin >> s;

    cout << mp[s] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Node{
   int parent,left,right;
};
const int NIL = -1;

void Preorder(Node A[], int n, int root) {
    if ( root != NIL ) {
    cout<<" "<<root;
    Preorder( A, n, A[root].left);
    Preorder( A, n, A[root].right);
   }
}
void Inorder(Node A[], int n, int root) {
     if ( A[root].left != NIL )     Inorder( A, n, A[root].left);
      cout<<" "<<root;
     if ( A[root].right != NIL )  Inorder( A, n, A[root].right);
}

void Postorder(Node A[], int n, int root) {
   if ( A[root].left != NIL )     Postorder( A, n, A[root].left);
   if ( A[root].right != NIL )  Postorder( A, n, A[root].right);
      cout<<" "<<root;
}
int main(){
	int n;
	cin>>n;
	Node *A = new Node[n];
   int v,left,right;
   for(int i=0;i<n;i++) { 
   		A[i].left = A[i].right = A[i].parent = NIL;
   }

   for(int i=0;i<n;i++){
   		cin>>v>>left>>right;
   		A[v].left=left;
   		A[v].right=right;
   		A[left].parent = v;
   		A[right].parent = v;
    }


   int root=0;
   for ( int i = 0; i < n; i++ ) {
   	   if ( A[i].parent == NIL ) root = i;
   }

  cout<<"Preorder"<<endl;
  Preorder(A, n, root);
  cout<<endl;

  cout<<"Inorder"<<endl;
  Inorder(A, n, root);
  cout<<endl;
  
  cout<<"Postorder"<<endl;
  Postorder(A, n, root);
  cout<<endl;
  
	return 0;
}


Measured memory_bytes: 3100
N, X = map(x -> parse(Int64,x), split(readline(STDIN)))

a(i) = 2^(i+2) - 3
p(i) = 2^(i+1) - 1

function f(i::Int, X::Int)
    if i == 0
        return X >= 1 ? 1 : 0
    else
        a_i = a(i)
        center_num = Int((a_i + 1) / 2)
        if center_num > X
            return f(i - 1, X - 1)
        elseif  center_num == X
            return  p(i - 1) + 1
        else
            return p(i - 1) + 1 + f(i - 1, X - center_num)
        end
    end
end

println(f(N, X))

Measured memory_bytes: 109948
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_M 100000
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

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

  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }

  vector< pii > edges;
  for(int i = 0; i < m; i++){
    edges.push_back(make_pair(b[i], a[i]));
  }
  sort(edges.begin(), edges.end());

  int count = 0;
  int cut = -1;
  for(pii e: edges){
    int s = e.second, t = e.first;
    if(cut <= s){
      cut = t;
      ++count;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

bool is_prime(ll n){
    if(n<2) return false;
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

int main(void)
{
    int n, m, sum=0;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int cnt=0;
    rep(i,n){
        if(a[i]*4*m < sum) cnt++;
    }
    if(n-cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
using namespace std;

int T, N, V[1010], W[1010];

int main() {

	for ( int t = 1; scanf( "%d", &T ) && T; t++ ) {
	
		scanf( "%d", &N );
	
		for ( int i = 0; i < N; i++ ) { scanf( "%d,%d", &V[i], &W[i] ); }
	
		int A[1010][1010] = {{0}};
	
		for ( int i = 1; i <= N; i++ ) {
		
			for ( int j = 0; j <= T; j++ ) {
	
				if ( j < W[i-1] ) {
	
					A[i][j] = A[i-1][j];
	
				} else {
	
					A[i][j] = max( A[i-1][j], A[i-1][j-W[i-1]] + V[i-1] );
					
				}
	
			}
	
		}
		
		int best = -1, best_w = -1;
		
		for ( int j = 0; j <= T; j++ ) {
		
			if ( A[N][j] > best ) {
			
				best = A[N][j];
				best_w = j;
				
			}
		
		}
		
		printf( "Case %d:\n%d\n%d\n", t, best, best_w );
	
	}

}

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

int main() {
	int n, k; cin >> n >> k;
	int cnt = n / k;
	long long ans = (long long)cnt * cnt * cnt;
	if (~k & 1) {
		cnt += (n % k >= k / 2);
		ans += (long long)cnt * cnt * cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    string s;
    scan(s);
    int n = s.length.to!int;
    int ans;
    foreach (i ; 0 .. n / 2) {
        if (s[i] != s[n - 1 - i]) ans++;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

void solve(vector<vector<ll>> &v,ll l,ll r,ll num){
  if(r-l==1)v[l][r]=num;
  else{
    ll av=(l+r)/2;
    for (ll i = l; i <= av; i++)
    {
      for (ll j = av+1; j <= r; j++)
      {
        v[i][j]=num;
      }
    }
    solve(v,l,av,num+1);
    if(av+1!=r)solve(v,av+1,r,num+1);
  }
}


int main()
{
ll n ;
cin >> n ;
vector<vector<ll>> v(n+1, vector<ll>(n+1,0) );
solve(v,1,n,1);
rep(i,n-1){
  rep(j,n-i-1){
    cout << v[i+1][j+i+2] << " ";
}
cout << endl;
}
return 0;
}


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

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

using namespace std;
using ll = long long int;

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



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

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

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

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

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

//繰り返し2乗法を用いたべき乗.x^nを返す.
long long int pow_(long long int x,long long int n){
	long long int res = 1;
	while (n)
	{
		if (n&1){
			res *= x;
		}
		n >>= 1;
		x = x * x;
	}
	return res;
}


int main(){
	ll x;
	cin >> x;
	int y = 1000;
	for (ll a = -y; a < y; a++)
	{
		for (ll b = -y; b < y; b++){
			if(a*a*a*a*a-b*b*b*b*b == x){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	assert(false);

	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
 
int main(){
    char A[1000001],B[10001];
    int i, k, in, state;
     
    scanf("%s",A);
    scanf("%s",B);
    in=strlen(A);
    k=strlen(B);
     
    for(i=0;i<in;i++){
        if(strncmp(&A[i],B,k)==0)printf("%d\n",i);
    }
     
     
    return 0;
     
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long inf = 1e16;
long long pre[maxn], suf[maxn];
struct data {
  int a, b, c;
  data () {}
  bool operator < (data d) const {
    return b - a < d.b - d.a;
  }
} arr[maxn];
int t[maxn * 4];
long long sum[maxn * 4];
int rev[maxn];
int idx;

void add(int x, int c = 1, int b = 1, int e = idx) {
  if(b == e) {
    t[c] += 1;
    sum[c] += rev[b];
    return ;
  }
  int m = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  if(x <= m) add(x, l, b, m);
  else add(x, r, m + 1, e);
  t[c] = t[l] + t[r];
  sum[c] = sum[l] + sum[r];
}
long long get(int x, int c = 1, int b = 1, int e = idx) {
  if(b == e) {
    return 1LL * rev[b] * x;
  }
  int m = (b + e) >> 1;
  int l = c << 1;
  int r = l + 1;
  if(t[r] >= x) return get(x, r, m + 1, e);
  else return sum[r] + get(x - t[r], l, b, m);
}
int main() {
  ios_base :: sync_with_stdio (false); cin.tie(0);
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int n = X + Y + Z;
  map <int, int> cmp;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i].a >> arr[i].b >> arr[i].c;
    cmp[arr[i].c - arr[i].a];
    cmp[arr[i].c - arr[i].b];
  }
  sort(arr + 1, arr + n + 1);
  for(auto &i : cmp) {
    i.second = ++idx;
    rev[idx] = i.first;
  }
  long long total = 0;
  for(int i = 1; i <= n; i++) {
    int x = cmp[arr[i].c - arr[i].a];
    add(x);
    total += arr[i].a;
    if(i >= X) pre[i] = total + get(i - X);
    else pre[i] = -inf;
  }
  memset(t, 0, sizeof t);
  memset(sum, 0, sizeof sum);
  total = 0;
  for(int i = n; i >= 1; i--) {
    int x = cmp[arr[i].c - arr[i].b];
    add(x);
    total += arr[i].b;
    if(n - i + 1 >= Y) suf[i] = total + get(n - i + 1 - Y);
    else suf[i] = -inf;
  }
  long long ans = -inf;
  for(int i = 1; i < n; i++) {
    ans = max(ans, pre[i] + suf[i + 1]);
  }
  cout << ans << endl;
  return 0;
}


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

int n, p;
int v[3] = {1, 400, 160000};
double dp[50000000];

double func(int q){
	if(dp[q] != 0.0) return dp[q];
	if(q == 0) return dp[q] = 0.0;
	double res = 0.0;
	int w[3] = {q % 400, q / 400 % 400, q / 160000 % 400};
	if(w[0] != 0){
		res += (double)w[0]/n*(1+func(w[0]-1+w[1]*400+w[2]*160000));
	}
	if(w[1] != 0){
		res += (double)w[1]/n*(1+func(w[0]+1+(w[1]-1)*400+w[2]*160000));
	}
	if(w[2] != 0){
		res += (double)w[2]/n*(1+func(w[0]+(w[1]+1)*400+(w[2]-1)*160000));
	}
	res += 1 - (double)(w[0] + w[1] + w[2]) / n;
	res *= (double)n / (w[0] + w[1] + w[2]);
//	cout << w[0] << " " << w[1] << " " << w[2] << " " << res << "\n";
	return dp[q] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		p += v[t-1];
	}
	cout << setprecision(14) << func(p) << "\n";
}

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

int N;
string S;
int E[300010], W[300010];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>N>>S;
    for(int n = 1; n <= N; n++) {
        E[n] = E[n-1] + (S[n-1]=='E'?1:0);
        W[n] = W[n-1] + (S[n-1]=='W'?1:0);
    }
    int ansv = 0x3f3f3f3f;
    for(int i = 0; i < N; i++) {
        int curv = W[i] + E[N] - E[i+1];
        ansv = min(ansv, curv);
    }
    cout<<ansv<<'\n';
    return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAXN = 1e6 + 7;
const int INF = 1e9;
vector<pii>vec;
char s[MAXN];
stack<char>stk;
int N, a[MAXN], v[MAXN];
    
#define lson (rt << 1)
#define rson (rt << 1 | 1)
struct node{int val, pos;} T[MAXN << 2];
node merge(node &x, node &y) {
    if (x.val > y.val) return x;
    else return y;
}
void pushup(int rt) {T[rt] = merge(T[lson], T[rson]);}
void build(int rt, int l, int r) {
    if (l == r) {T[rt] = {v[l], l}; return;}
    int mid = (l + r) >> 1;
    build(lson, l, mid);
    build(rson, mid + 1, r);
    pushup(rt);
}
void update(int rt, int l, int r, int pos, int v) {
    if (l == r) {T[rt] = {v, l}; return;}
    int mid = (l + r) >> 1;
    if (pos <= mid) update(lson, l, mid, pos, v);
    else update(rson, mid + 1, r, pos, v);
    pushup(rt);
}
node query(int rt, int l, int r, int L, int R) {
    if (L <= l && r <= R) return T[rt];
    int mid = (l + r) >> 1;
    node resl = {-INF, -1}, resr = {-INF, -1};
    if (L <= mid) resl = query(lson, l, mid, L, R);
    if (mid <  R) resr = query(rson, mid + 1, r, L, R);
    return merge(resl, resr);
}
    
int main() {
    int n; scanf("%d", &n);
    int sum1 = 0, sum2 = 0;
    for (int k = 1; k <= n; k++) {
        scanf(" %s", s);
        int len = strlen(s);
        for (int i = 0; i < len; i++) {
            if (s[i] == '(') stk.push(s[i]);
            else {
                if (stk.size() && stk.top() == '(') stk.pop();
                else stk.push(s[i]);
            }
        }
        pii item = {0, 0};
        while (stk.size()) {
            if (stk.top() == '(') item.second++;
            else item.first++;
            stk.pop(); 
        }
        if (item.first == 0) sum1 += item.second;
        else if (item.second == 0) sum2 += item.first;
        else vec.push_back(item);
    }
    sort(vec.begin(), vec.end());
    N = vec.size();
    for (int i = 1; i <= N; i++) {
        a[i] = vec[i - 1].first;
        v[i] = vec[i - 1].second - vec[i - 1].first;
    }
    if (N > 0) build(1, 1, N);
    for (int i = 1; i <= N; i++) {
        int p = upper_bound(a + 1, a + 1 + N, sum1) - a - 1;
        if (p < 1) {puts("No"); return 0;}
        node res = query(1, 1, N, 1, p);
        if (res.pos == -1 || sum1 < a[res.pos]) {puts("No"); return 0;}
        sum1 += v[res.pos];
        update(1, 1, N, res.pos, -INF);
    }
    sum1 == sum2 ? puts("Yes") : puts("No");
    return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

signed main() {
  ll N;
  cin >> N;
  set<PLL> s;
  for (int i=1, j=(N%2==1 ? N-1 : N); i<=N; i++, j--) {
    s.insert(make_pair(i, j));
  }
  vector<PLL> ans;
  for (int i=1; i<=N; i++) {
    for (int j=i+1; j<=N; j++) {
      if (s.find(make_pair(i, j)) == s.end()) {
        ans.push_back(make_pair(i, j));
      }
    }
  }
  cout << ans.size() << endl;
  for (auto p: ans) {
    cout << p.first << " " << p.second << endl;
  }
}


Measured memory_bytes: 512
//In the name of 'ALLAH'
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b ;
    cin>>a>>b;

    if( a + b >= 24 )
    {
        cout << a+b-24 <<endl;
    }
    else
    {
        cout<< a+b <<endl;
    }
}


Measured memory_bytes: 3636
def t(n, ps):
    ac = 0
    wa = 0
    a = [False]*(n + 1)
    b = [0]*(n+1)
    for p, s in ps:
        if a[int(p)]:
            continue
        if s == 'AC':
            ac += 1
            wa += b[int(p)]
            a[int(p)] = True
        else:
            b[int(p)] += 1
    return (ac, wa)


if __name__ == '__main__':
    n, m = map(int, input().split())
    ps = [input().split() for i in range(m)]
    print(' '.join(map(str, t(n, ps))))


Measured memory_bytes: 33704
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	int x = n / 100;
	int y = (n / 10)%10;
	int z = n % 10;
	
	if (x ==7 || y ==7 || z == 7) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n, k ;
    cin >> n >> k ;
    vector<int> p (n) , c (n) ;
    rep(i, n) cin >> p[i] ;
    rep(i, n) cin >> c[i] ;
    rep(i, n) p[i]-- ;
    ll ans = -1e18 ;
    rep(i, n){
        vector<ll> loop ;
        int t = i ;
        ll tot = 0 ;
        while(1){
            t = p[t] ;
            loop.push_back(c[t]) ;
            tot += c[t] ;
            if(t == i){
                break ;
            }
        }
        int l = loop.size() ;
        for(int j = 1; j < l ; j++){
            loop[j] += loop[j-1] ;
        }
        ll g = 0 ;
        rep(j, l){
            g = loop[j] ;
            if(j + 1 > k){
                break ;
            }
            ll now = g ;
            if(tot > 0){
                ll e = (k - (1 + j)) / l ;
                now += tot*e ;
            }    
            ans = max(now, ans) ; 
        }
    }
    cout << ans << endl ; 
} 

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    bool p[100001];
    for (int i = 0; i <= 100000; i++) {
        p[i] = true;
    }
    p[0] = p[1] = false;
    for (int i = 2; i <= 100000; i++) {
        if (!p[i]) continue;
        int x = 2 * i;
        while (x <= 100000) {
            p[x] = false;
            x += i;
        }
    }

    bool d[100001];
    for (int i = 0; i <= 100000; i++) {
        if (i % 2 == 0) {
            d[i] = false;
            continue;
        }
        if (p[i] && p[(i + 1) / 2]) d[i] = true;
        else d[i] = false;
    }

    int s[100001];
    s[0] = 0;
    for (int i = 1; i <= 100000; i++) {
        s[i] = s[i - 1] + (d[i]? 1 : 0);
    }

    int q;
    cin >> q;
    int l[q], r[q];
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
    }

    for (int i = 0; i < q; i++) {
        cout << s[r[i]] - s[l[i] - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
N = int(input())
a_list = [[0 for _ in range(3)] for _ in range(N)]

for i in range(N):
    a, b, c = map(int, input().split())
    a_list[i][0] = a
    a_list[i][1] = b
    a_list[i][2] = c

dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if i == 1:
                dp[i][j] = a_list[i - 1][k]
            if j == k:
                continue
            else:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + a_list[i - 1][j])
print(max(dp[N]))


Measured memory_bytes: 45680
#include <iostream>
#include <random>

using namespace std;

#ifdef LOCAL
#define fre() freopen("in", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

#define IOS std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define repi(a,b) for(int i=a;i<b;i++)
#define repj(a,b) for(int j=a;j<b;j++)
#define mst(a,b) memset(a,b,sizeof(a))

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

int main() {
    int a;cin>>a;
    int ans=a*100/108;
    if(ans*108/100==a)cout<<ans<<endl;
    else if((ans+1)*108/100==a)cout<<ans+1<<endl;
    else cout<<":(\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	n := nextInt()
	s := nextString()

	var ans []rune
	for _, r := range s {
		if r+rune(n) > 'Z' {
			ans = append(ans, 'A'+r+rune(n)-'Z'-1)
		} else {
			ans = append(ans, r+rune(n))
		}
	}
	fmt.Println(string(ans))
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if (u == s) a--;
	if (u == t) b--;
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
const double PI=3.14159265358979323846;
using namespace std;

int main(){
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    long double ta,tb,ans;
    ta=(double)(H*60.+M)/360.*PI;
    tb=(double)(M/60.)*2.*PI;
    ans=(long double)(A*A+B*B)-2.0*A*B*cos(tb-ta);
    ans=sqrt(ans);
    cout << setprecision(10) << ans;
}

Measured memory_bytes: 4160
# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)

def solve():
  ans = []
  N, Q = map(int, input().split())
  data0 = BIT(N+1)
  data1 = BIT(N+1)
  for i in range(Q):
    p,*y = map(int, input().split())
    if p==0:
      s,t,x = y
      data0.add(s,-x*(s-1))
      data0.add(t+1,x*t)
      data1.add(s,x)
      data1.add(t+1,-x)
    else:
      s,t = y
      ans.append(data1.sum(t)*t+data0.sum(t)-data1.sum(s-1)*(s-1)-data0.sum(s-1))
  return ans
print(*solve(),sep='\n')




Measured memory_bytes: 19492
#include<stdio.h>

int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    if(n%(2*d+1)!=0){
        printf("%d\n",(n/(2*d+1))+1);
    }
    else{
        printf("%d\n",n/(2*d+1));
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

const double INF=1e12;

int N,M,P;
int A[111111],B[111111],L[111111];
double C[111111];

double dp[1111][222];
double x[222];

signed main(){
    cin>>N>>M>>P;
    rep(i,M){
        cin>>A[i*2]>>B[i*2];
        A[i*2]--;B[i*2]--;
        int x,y;
        cin>>x>>y;
        C[i*2]=1.0*y/x;
        L[i*2]=x;

        A[i*2+1]=B[i*2];
        B[i*2+1]=A[i*2];
        C[i*2+1]=C[i*2];
        L[i*2+1]=L[i*2];
    }
    M*=2;

    fill_n(*dp,1111*222,-INF);
    dp[0][0]=0;
    for(int i=0;i<P;i++){
        for(int j=0;j<M;j++){
            if(i+L[j]>P)continue;
            chmax(dp[i+L[j]][B[j]],dp[i][A[j]]+L[j]*C[j]);
        }
    }

    rep(i,M)chmax(x[A[i]],C[i]);

    double ans=0;
    rep(i,N){
        for(int j=0;j<=P;j++){
            for(int k=0;j+k<=P;k++){
                chmax(ans,dp[j][i]+dp[k][i]+(P-j-k)*x[i]);
            }
        }
    }
    printf("%.20f\n",ans);
    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,h;cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    vector<int> nage;
    for (auto &&i : b)
    {
        if(i >=a[0])
        {
            nage.push_back(i);
        }
    }
    sort(nage.begin(), nage.end(), greater<int>());

    int counter = 0;
    for (auto &&i : nage)
    {
        h -= i;
        // cout << h << endl;
        counter++;
        if(h<=0)
        {
            cout << counter << endl;
            return 0;
        }
    }
    counter += ((h-1)/a[0]+1);
    cout << counter << endl;
}

Measured memory_bytes: 4680
n=int(input())
def cal(n):
    num = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            num.append(i)
            if i != n // i:
                num.append(n//i)
    return num
div=sorted(cal(n))
ans=0
for i in range(len(div)-1):
    m=n//div[i]-1
    if n%m!=0 and m>div[i]:
        ans+=m
print(ans)


Measured memory_bytes: 3296
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    S = list(_in[1])   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [0]*N
    for i in range(N):
        if i==0:
            dp[i] = len([s for s in S[1:] if s=='E'])
        else:
            dp[i] = dp[i-1] + (1 if S[i-1]=='W' else 0) - (1 if S[i]=='E' else 0)
    cnt = min(dp)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 83520
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DubiousDocument2 solver = new DubiousDocument2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DubiousDocument2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String sstr = in.next();
            String tstr = in.next();
            char[] s = sstr.toCharArray();
            char[] t = tstr.toCharArray();
            List<String> list = new ArrayList<>();

            for (int i = 0; i < s.length; i++) {
                boolean can_replace = false;
                if (s[i] == '?' || s[i] == t[0]) {
                    int j = i;
                    int k = 0;
                    while (true) {
                        if (s.length - 1 < j) {
                            break;
                        }
                        if (s[j] == '?' || s[j] == t[k]) {
                            j++;
                            k++;
                            if (k == t.length) {
                                can_replace = true;
                                break;
                            }
                        } else {
                            break;
                        }
                    }

                    if (can_replace) {
                        char[] z = s.clone();
                        int from = i;
                        int kk = 0;
                        int to = from + t.length - 1;
                        for (int x = 0; x < z.length; x++) {
                            if (from <= x && x <= to) {
                                z[x] = t[kk];
                                kk++;
                            } else if (z[x] == '?') {
                                z[x] = 'a';
                            }
                        }
                        list.add(new String(z));
                    }
                }
            }

            if (list.isEmpty()) {
                out.print("UNRESTORABLE");
                return;
            }
            list.sort(String::compareTo);
            out.print(list.get(0));
        }

    }
}



Measured memory_bytes: 35684
#include <stdio.h>
 
int main(void)
{
    int n, card[4][13] = {0};
    int i, j, c, d;
    char m;
 
 
    scanf("%d", &n);
 
    for(i=0;i<n;i++){
        scanf(" %c %d", &m, &d);
 
        switch(m){
            case 'S' : card[0][d-1] = 1;
                        break;
            case 'H' : card[1][d-1] = 1;
                        break;
            case 'C' : card[2][d-1] = 1;
                        break;
            case 'D' : card[3][d-1] = 1;
                        break;
        }
    }
 
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(card[i][j] == 0){
                switch(i){
                    case 0 : printf("S %d\n", j+1);
                            break;
                    case 1 : printf("H %d\n", j+1);
                            break;
                    case 2 : printf("C %d\n", j+1);
                            break;
                    case 3 : printf("D %d\n", j+1);
                            break;
                }
            }
        }
    }
 
    return 0;
}

Measured memory_bytes: 596
str = gets.split
N,M,K = str[0].to_i, str[1].to_i, str[2].to_i

a = Array.new(N+1){Array.new(0)}
f = Array.new(N+1,0)
for i in 0...M do
    str = gets.split
    x,y = str[0].to_i, str[1].to_i
    a[x].push(y)
    a[y].push(x)
    f[x] += 1
    f[y] += 1
end
b = Array.new(K){Array.new(2)}
for i in 0...K do
    str = gets.split
    b[i][0],b[i][1] = str[0].to_i, str[1].to_i
end
c = Array.new(N+1,0)

z = 1
for i in 1..N do
    if !a[i].empty?
        c[i] = z
        d = Array.new(0)
        while !a[i].empty?
            d.push(a[i].pop)
        end
        while !d.empty?
            e = d.pop
            c[e] = z
            while !a[e].empty?
                d.push(a[e].pop)
            end
        end
        z += 1
    end
end

g = Array.new(z,0)
for i in 1..N do
    x = c[i]
    g[x] += 1
end
answer = Array.new(N+1,0)
for i in 1..N do
    x = c[i]
    answer[i] = g[x] - 1 - f[i]
end
for i in 0...K do
    x = b[i][0]
    y = b[i][1]
    if c[x] == c[y]
        answer[x] -= 1
        answer[y] -= 1
    end
end

for i in 1..N do
    if c[i] == 0
        answer[i] = 0
    end
    print answer[i]
    print " "
end
puts

Measured memory_bytes: 26804
h, w = map(int, input().split())
s = [ input() for _ in range(h) ]
l = [[0]*(w+2) for _ in range(h+2)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      for y in range(i, i+3):
        for x in range(j, j+3):
          if l[y][x] != "#":
            l[y][x] += 1
      l[i+1][j+1] = "#"
for i in range(1, h+1):
  print(*l[i][1:w+1], sep="")

Measured memory_bytes: 3444
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int main(void){
    int N,L;
    cin>>N>>L;
    int A[N];
    int sum=0;
    int min=10000;
    bool b=true;
    for(int i=0;i<N;i++){
        A[i]=L+i-1+1;
        sum+=A[i];
        if(min>abs(A[i])){
            min=abs(A[i]);
            if(A[i]<0){
                b=false;
            }
        }
    }
    if(b){
        cout<<sum-min<<endl;
    }
    else{
        cout<<sum+min<<endl;
    }
}


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

int main(){
    int a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    if(k % 2){
        cout << -(a - b) << endl;
    } else {
        cout << a - b << endl;
    }
    return 0;
}

Measured memory_bytes: 3572
/*
 * ALDS1_3_A.cpp
 *
 *  Created on: Apr 25, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<stack>
#include<cstdlib>

using namespace std;

int main() {
	stack<int> st;
	char s[100];
	while(scanf("%s", s) != EOF) {
		if(s[0] == '+') {
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(a+b);
		}
		else if(s[0] == '-') {
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(b-a);
		}
		else if(s[0] == '*') {
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(a*b);
		}
		else {
			st.push(atoi(s));
		}
	}
	printf("%d\n", st.top());
}





Measured memory_bytes: 2744
function main()
	lines=readlines();
	N=parse(Int,shift!(lines))
	INF=10^9
	mx=[INF,INF,INF,INF]
	my=mx[:]
	Mx=-mx
	My=Mx[:]
	for i=1:N
		x,y,d=split(shift!(lines))
		x=parse(Int,x)
		y=parse(Int,y)
		if d=="L"
			d=1
		elseif d=="R"
			d=2
		elseif d=="U"
			d=3
		elseif d=="D"
			d=4
		end
		mx[d]=min(mx[d],x)
		my[d]=min(my[d],y)
		Mx[d]=max(Mx[d],x)
		My[d]=max(My[d],y)
	end
	T=[0.0]
	push!(T,(mx[1]-mx[2])/2)
	push!(T,mx[1]-min(mx[3],mx[4]))
	push!(T,min(mx[3],mx[4])-mx[2])
	push!(T,(Mx[1]-Mx[2])/2)
	push!(T,Mx[1]-max(Mx[3],Mx[4]))
	push!(T,max(Mx[3],Mx[4])-Mx[2])
	push!(T,(my[4]-my[3])/2)
	push!(T,my[4]-min(my[1],my[2]))
	push!(T,min(my[1],my[2])-my[3])
	push!(T,(My[4]-My[3])/2)
	push!(T,My[4]-max(My[1],My[2]))
	push!(T,max(My[1],My[2])-My[3])
	ans=10^18
	for t=T
		if t<0;continue;end
		X=max(Mx[1]-t,Mx[2]+t,Mx[3],Mx[4])-min(mx[1]-t,mx[2]+t,mx[3],mx[4])
		Y=max(My[1],My[2],My[3]+t,My[4]-t)-min(my[1],my[2],my[3]+t,my[4]-t)
		ans=min(ans,X*Y)
	end
	println(ans)
end
main()


Measured memory_bytes: 156228
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int val = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='+') val++;
        else val--;
    }
    cout << val;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d=map(int, input().split())
ans=max(a*c,a*d,b*c,b*d)
if (a<=0 and b>=0) or (c<=0 and d>=0):
  ans=max(ans,0)
print(max(a*c,a*d,b*c,b*d))

Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
ll gar(ll a,ll b){//最大公约数 
return b==0?a:gar(b,a%b);
}
int main(){
	 int a,b,c;
	 while(cin>>a>>b>>c){
	 	int maxn=max(a,b),minn=min(a,b);
	 	if(c<=maxn&&c>=minn)cout<<"Yes"<<endl;
	 	else cout<<"No"<<endl;
	 }
	return 0;
}


Measured memory_bytes: 888
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');
            int[] L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = int.Parse(s[i]);
            }

            int cnt = 0;
            int all = 0;
            int a = 0;
            int b = 0;
            int c = 0;
            
            
            for (int k = 0; k <= N-3 ; k++)
            {
                a = L[k];
                for (int i = k+1; i < N; i++)
                {
                    b = L[i];
                    for (int j = i + 1; j < N; j++)
                    {
                        all++;
                        c = L[j];
                        if (a != b && c != b && a != c &&
                            a + b > c && b + c > a && a + c > b)
                        {
                            cnt++;
                        }
                    }
                }
            }

            Console.WriteLine($"{cnt}");
        }
    }
}


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

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> s;
    if(s[0] == 'M')d[0]++;
    if(s[0] == 'A')d[1]++;
    if(s[0] == 'R')d[2]++;
    if(s[0] == 'C')d[3]++;
    if(s[0] == 'H')d[4]++;
  }
  l = 0;
  rep(i,0,5){
    rep(j,i+1,5){
      rep(k,j+1,5){
        l += d[i] * d[j] * d[k];
      }
    }
  }
  print(l);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long
#define mod 1000000007

int N,M,to[111111]={},rem;;
vector<int>adj[111111];

int main() {
	cin>>N>>M;
	rem=N-1;
	to[1]=1;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	queue<int>q;
	q.push(1);
	while(!q.empty()){
		int now=q.front();
		q.pop();
		for(int i:adj[now]){
			if(to[i]==0){
				rem--;
				to[i]=now;
				q.push(i);
			}
		}
	}
	if(rem)cout<<"No"<<endl;
	else{
		cout<<"Yes"<<endl;
		for(int i=2;i<=N;i++)cout<<to[i]<<endl;
	}


	return 0;
}


Measured memory_bytes: 10616
#include<stdio.h>

int main(void)
{
int a,b;

scanf("%d %d",&a,&b);

if(a<b)
{
printf("a < b\n");
}
else if(a>b)
{
printf("a > b\n");
}
else
{
printf("a == b\n");
}
return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = s.size();

    for (int i = 0; i < s.size()-1; i++) {
        if (s.at(i) == s.at(i+1)) {
          ans--;
      }
    }
    cout << ans << endl;
}

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

long long N, K;

// N 個の整数
vector<long long> A;

// 無限
const long long INF = (long long) (1e18)+1;


// x 未満を作ることができるペアが k 個未満か（true）否か（false）
bool f(long long x) {

  // x 未満を作ることができるペアの数
  long long count = 0;

  for (int i = 0; i < N; i++) {
  
    if (0 <= A[i]) {
      // 全部 OK なら N - 1 個となる
      // 正の場合は、l が OK、r がダメ側
      int l = -1;
      int r = N;
      // border の範囲を二分探索で狭めていく
      while (l + 1 < r) {
        int border = (l + r) / 2;
        // 自分自身と自分自身のペアや、重複するペアも見る
        if (A[border] * A[i] < x) {
          l = border;
        } else {
          r = border;
        }
      }
      // 境界より左側
      count += r;
    } else {
      // 負の場合は、l がダメ側、r が OK
      int l = -1;
      int r = N;
      // border の範囲を二分探索で狭めていく
      while (l + 1 < r) {
        int border = (l + r) / 2;
        // 自分自身と自分自身のペアや、重複するペアも見る
        if (A[border] * A[i] < x) {
          r = border;
        } else {
          l = border;
        }
      }
      // 境界より右側
      count += N - r;
    }

    // 自分自身と自分自身のペアを引く
    if (A[i] * A[i] < x) {
      count--;
    }

  }

  // 半分は重複しているペアとなるので半分にする
  count /= 2;
  
  return count < K;
}


int main() {

  cin >> N >> K;

  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

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

  // 左端
  long long l = -INF;

  // 右端
  long long r = INF;

  // x の範囲を二分探索で狭めていく
  while (l + 1 < r) {

    long long x = (l + r) / 2;
    
    bool flg = f(x);

    if (flg) {
      l = x;
    } else {
      r = x;
    }

  }

  cout << l << endl;

  return 0;

}

Measured memory_bytes: 1792