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

string a, b;
int memo[3001][3001];

int out(int n, int m) {
    //cout << "calling with " << n << ' ' << m << endl;
    if (n == 0 || m == 0) {
        memo[n][m] = 0;
        return 0;
    }
    if (memo[n][m] != -1) {
        return memo[n][m];
    }
    int yeet = -1;
    if (a[n-1] == b[m-1]) {
        yeet = out(n-1, m-1) + 1;
    }
    yeet = max(yeet, out(n-1, m));
    yeet = max(yeet, out(n, m-1));
    return memo[n][m] = yeet;
}

int main() {
    cin >> a >> b;
    for (int i = 0; i <= a.size(); i++) {
        for (int j = 0; j <= b.size(); j++) {
            memo[i][j] = -1;
        }
    }
    out(a.size(), b.size());
    stack<char> yoink;
    int n = a.size();
    int m = b.size();
    while (n > 0 && m > 0) {
        //cout << n << ' ' << m << endl;
        if (a[n-1] == b[m-1]) {
            yoink.push(a[n-1]);
            n--;
            m--;
        } else if (memo[n-1][m] > memo[n][m-1]) {
            n--;
        } else {
            m--;
        }
    }
    while (yoink.size() > 0) {
        cout << yoink.top();
        yoink.pop();
    }
    cout << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll x;
  cin >> x;

  ll t = 0;
  while(true){
    if(t*(t+1)/2 >= x)
      break;

    t++;
  }

  cout << t << endl;
  
  
}


Measured memory_bytes: 256
N, x = [int(n) for n in input().split()]
As = [int(n) for n in input().split()]

sAs = sorted(As)

c = 0
for i in range(len(sAs)):
    if x >= sAs[i]:
        x -= sAs[i]
        sAs[i] = 0
        c += 1

if all([n == 0 for n in sAs]) and x != 0:
    c -= 1

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int N, K;
	while ( cin >> N >> K && N != 0 && K != 0 )
	{
		vector <int> S( K );
		for ( int i = 0; i < K; i++ )
		{
			cin >> S[i];
		}

		for ( int lpc = 0; lpc < N; lpc++ )
		{
			for ( int i = 0; i < K; i++ )
			{
				int B;
				cin >> B;
				S[i] -= B;
			}
		}

		bool ok = true;
		for ( int i = 0; i < K; i++ )
		{
			if ( S[i] < 0 )
				ok = false;
		}

		if ( ok )
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}

	return 0;
}

Measured memory_bytes: 896
/*	ex3_2
	suzuto	*/

  #include <stdio.h>

  int main(void) {
    int num, first_place; /*変数の宣言*/

    scanf("%d",&num); /*本数の入力*/
    first_place = num % 10; /*本数の一の位をfirst_placeに代入*/

    switch (first_place) {
      case 2:
      case 4:
      case 5:
      case 7:
      case 9:
        printf("hon\n"); /*読み方が「ほん」の時*/
        break;
      case 0:
      case 1:
      case 6:
      case 8:
        printf("pon\n"); /*読み方が「ぽん」の時*/
        break;
      case 3:
        printf("bon\n"); /*読み方が「ぼん」の時*/
        break;
    }
    return 0;
  }


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int x;
    cin >> x;
    cout << (x >= 1200 ? "ARC" :"ABC") << endl;
}

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

ll f(ll n) { return n*(n+1)/2;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int res = 0;
  rep(i,k) res += p[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(){
    int A[100];
    int n,i,j,count=0,tmp,tmp1,flag;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    // SelectionSort
    for(i=0;i<n;i++){
        tmp = i;
        flag =0;
        for(j=i;j<n;j++){
            if(A[j]<A[tmp]){
                tmp = j;
                flag =1;
            }
            
        }
        if(flag==1){
        tmp1 = A[i];
        A[i] = A[tmp];
        A[tmp] = tmp1;
        count++;
        }
    }
    for(i=0;i<n;i++){
        printf("%d",A[i]);
        if(i==n-1){
            printf("\n");
            break;
        }
        else printf(" ");
    }
    printf("%d\n",count);
    return 0;
}


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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); for (ll i = 0; i < N; ++i) cin >> A[i];
	vector<ll> sum(100010);

	for (ll i = 0; i < N; ++i)
		++sum[A[i]];

	ll res{0};
	for (ll i = 1; i < 100000; ++i)
	{
		ll tmp{0};
		tmp+= sum[i-1];
		tmp += sum[i];
		tmp += sum[i+1];
		res = max(res, tmp);
	}
	std::cout << res << std::endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll, int> ii;

const int len = 1e5+5;
const ll inf = 1e15;
int a[len], n, en, t, nex[len];
ll dp[len], suf[len];
deque<ii> deq;

int main(){
    scanf("%d %d %d", &n, &en, &t);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);

    for (int i = 1, j = 1; i <= n; i++){
        while (j <= n && 2*(a[j]-a[i]) <= t)
            j++;
        nex[i] = j;
    }

    deq.push_back(mp(0, n+1));
    suf[n+1] = inf;
    for (int i = n; i >= 1; i--){
        int j = nex[i];

        dp[i] = min(deq.front().fi+t, suf[j]-2*a[i]);

        suf[i] = min(suf[i+1], dp[i+1]+2*a[i]);
        while (!deq.empty() && dp[i] <= deq.back().fi)
            deq.pop_back();
        deq.push_back(mp(dp[i], i));
        while(!deq.empty() && deq.front().se > nex[i-1])
            deq.pop_front();
    }

    printf("%lld\n", dp[1]+en);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    while(cin >> h >> w, h){
        auto v = make_v(h+2, w+2, 0);
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> v[i+1][j+1];
            }
        }
        int ans = 0;
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                for (int k = i+2; k <= h; ++k) {
                    for (int l = j+2; l <= w; ++l) {
                        int m1 = v[i][j], m2 = 0;
                        for (int m = i; m <= k; ++m) {
                            for (int n = j; n <= l; ++n) {
                                if(m == i || m == k || n == j || n == l){
                                    m1 = min(m1, v[m][n]);
                                }else {
                                    m2 = max(m2, v[m][n]);
                                }
                            }
                        }
                        if(m1 > m2) {
                            int sum = 0;
                            for (int m = i; m <= k; ++m) {
                                for (int n = j; n <= l; ++n) {
                                    if(m == i || m == k || n == j || n == l); else {
                                        sum += m1-v[m][n];
                                    }
                                }
                            }
                            ans = max(ans, sum);
                        }

                    }
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3164
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
// #include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
// using mint = atcoder::modint1000000007;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  vector<pair<ll,ll>> D(N);
  
  for (auto&& i : D)
    cin >>i.first>>i.second;
  
  REP(i, N-2) {
    bool r = true;
    REP(j, 3)
      if (D[i+j].first != D[i+j].second)
        r = false;
    
    if (r)
      return "Yes";
  }


  return "No";
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
using namespace std;

int n;
long long int takahashi = 0, aoki = 0;
vector<long long int> a;
vector<long long int> b;

vector<pair<long long int, int>> c;

int check[100001];

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        long long int tmp, tmp2;
        cin >> tmp >> tmp2;
        a.push_back(tmp);
        b.push_back(tmp2);
        c.push_back(make_pair(tmp + tmp2, i));
    }

    sort(c.begin(), c.end(), greater<pair<long long int, int>>());

    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            takahashi += a[c[i].second];
        }
        else
        {
            aoki += b[c[i].second];
        }
    }

    cout << takahashi - aoki;
    return 0;
}


Measured memory_bytes: 3676
# -*- coding: utf-8 -*-

N = int(input())
INF = float("inf")
adj = [[INF]*N for _ in range(N)]

for n in range(N):
    inp = tuple(map(int, input().split()))
    assert n == inp[0]
    for i in range(inp[1]):
        adj[inp[0]][inp[2*i+2]] = inp[2*i+3]

not_MST = list(range(1, N))
MST = [0]
costs = {n:INF for n in range(N)}
costs[0] = 0

for n in range(1, N):
    if adj[0][n] < INF:
        costs[n] = adj[0][n]

m = 0

while len(not_MST):
    tmp_min = INF
    tmp_idx = -1
    
    for n in not_MST:
        if costs[m] + adj[m][n] < costs[n]:
            costs[n] = costs[m] + adj[m][n]
    
    for m in not_MST:
        if costs[m] < tmp_min:
            tmp_min = costs[m]
            tmp_idx = m
    
    MST.append(tmp_idx)
    not_MST.remove(tmp_idx)
    m = tmp_idx

for n in range(N):
    print("{} {}".format(n, costs[n]))

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

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int H, W, K; cin >> H >> W >> K;
	vector<string> c(H);
	REP(i,H) cin >> c[i];
	vector<string> copied;
	copied = c;
	int n = H + W;
	int res = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
        for (int i = 0; i < H; ++i) {
            if (bit & (1 << i)) {
				REP(j,W) {
					c[i][j] = 'x';
				}
            }
        }
		for (int i = H; i < H + W; ++i) {
            if (bit & (1 << i)) {
				REP(j,H) {
					c[j][i - H] = 'x';
				}
            }
        }
		int cnt = 0;
		REP(i,H) {
			REP(j,W) {
				if (c[i][j] == '#') ++cnt;
			}
		}
		if (cnt == K) {
			++res;
		}
		c = copied;
    }
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int m[1000001];
int main(){
  int N;
  while(cin>>N){
    memset(m,0,sizeof(m));
    for(int i=0;i<=1000;i++){
      for(int j=0;j<=1000;j++){
        if(N-(i+j)>=0)
          m[N-(i+j)]++;
      }
    }
    ll res=0;
    for(int i=0;i<=1000;i++){
      for(int j=0;j<=1000;j++){
        res+=m[i+j];
      }
    }
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 5072
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A;
	double B;
	while(cin>>A>>B) {
		ll b = B*100.0+0.001;
		ll ans=A*b/100;
		cout<<ans<<endl;
	}
	
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	int l[n],r[n];
	int sum=0;
	for (int i = 0; i < n; i++){
		cin>>l[i]>>r[i];
		sum+= r[i]-l[i]+1;
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

char x;
void input(){
    fast_io();
    cin >> x;
}

int solve(){
    if(x>='A' && x<='Z') cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3640
/*
 *  Created by Andrei Arhire 02/08/2020
 *  Copyright © 2020 Andrei Arhire. All rights reserved.
 */
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long
#define llf __float128
#define lld long double
using namespace std;
const lll NR = 1e5 + 10  ,oo = 2e9 + 10, MOD = 1e9 + 7 ;
const long double pi = 2*acos(0.0);

string s ;
int red , white , ans, n  ;

signed main () {
    int i ;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0) ;
   cin >> n ;
   cin >> s ;
   for ( i = 0 ; i < s.size() ; ++ i )  {
       if ( s [ i ] == 'R' )    red ++ ;
       else                     white ++ ;
   }
   for ( i = 0 ; i < red ; ++ i )   {
       if ( s [ i ] != 'R' )    {
           ans ++ ;
       }
   }
   cout << ans << '\n' ;
    return 0 ;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> p(n),q(n),a(n);
    iota(ALL(a),1);
    REP(i,n) cin >> p[i];
    REP(i,n) cin >> q[i];

    int pp, pq;
    int cnt = 0;
    do
    {
        bool b = true;
        REP(i,n) {
            if (p[i] != a[i]) {
                b = false;
                break;
            }
        }
        if (b) pp = cnt;
        b = true;
        REP(i,n) {
            if (q[i] != a[i]) {
                b = false;
                break;
            }
        }
        if (b) pq = cnt;
        cnt++;

    } while (next_permutation(ALL(a)));
    
    //cerr << pp << pq << endl;
    
    OUT(abs(pp-pq))

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
char pixel[101];
int main() {
	int h, w;
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> pixel[j];
			cout << pixel[j];
		}
		cout << endl;
		rep(j, w) cout << pixel[j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long n;
    int pout=0;
    cin>>n;
    for(long long i=n; i>0;)
    {
        if(i%10==9)
        {
            pout=2;
            cout<<"Yes\n";
            return 0;
        }
        i=i/10;
    }
    cout<<"No\n";

return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


bool b[103];
int main(){
	ll x,n;
	cin>>x>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		b[a[i]]=true;
	}
	for(ll i=0; i<103; i++){
		if(b[i]==false){
			ll flag=abs(x-i);
			mn=min(mn,flag);
		}
	}
	for(ll i=0; i<103; i++){
		if(abs(x-i)==mn && b[i]==false){
			cout<<i<<endl;
			break;
		}
	}
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int a,b,c,x; cin >>a>>b>>c>>x;
    
    int res = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if(500*i + 100*j + 50*k == x) {
                    res += 1;
                }
            }
        }
    }
    
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 256
N=int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key = lambda x: x[1])#締め切り時間が速いものからやる。貪欲法
time=0
c=0
for ab in AB:
  time+=ab[0]
  if time>ab[1]:
    print("No")
    c=1
    break
if c==0:
  print("Yes")
  

Measured memory_bytes: 89816
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}

int main(){
	int a, b, k;
	cin >> k >> a >> b;
	for (int i = a;i <=b; i++){
		if (i%k==0){
			cout << "OK" << endl;
			return 0;
		}
	}	
	cout << "NG" << endl;
}



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

int main(){

int x1,y1,x2,y2;
int dx,dy;
int opr_x=1,opr_y=1;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

dx = abs(x2-x1);
dy = abs(y2-y1);
if (y2 > y1){opr_x = -1;}
if (x2 < x1){opr_y = -1;}

printf("%d ",x2 + opr_x*dy);
printf("%d ",y2 + opr_y*dx);
printf("%d ",x1 + opr_x*dy);
printf("%d ",y1 + opr_y*dx);

return 0;

}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int[] rs = new int[n];
		int[] cs = new int[n];
		
		for(int i = 0; i < n; i++){
			rs[i] = sc.nextInt();
			cs[i] = sc.nextInt();
		}
		
		int[][] DP = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j){
					DP[i][j] = 0;
				}else{
					DP[i][j] = Integer.MAX_VALUE;
				}
			}
		}
		
		for(int space = 1; space < n; space++){
			for(int start = 0; start < (n - space); start++){
				final int last = start + space;
				
				for(int sep = start; sep < last; sep++){
					DP[start][last] = Math.min(DP[start][last], DP[start][sep] + DP[sep + 1][last] + rs[start] * cs[sep] * cs[last]);
				}
			}
		}
		
		System.out.println(DP[0][n-1]);
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}

}

Measured memory_bytes: 19752
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int n;

int dp[1000001][10][2][2];

int fun(int ind, int v, int f1, int f2) {
  if (ind == n) {
    return (f1 && f2);
  }
  if (~dp[ind][v][f1][f2]) return dp[ind][v][f1][f2];
  int ans = 0;
  for (int i = 0; i <= 9; i++) {
    ans = add(ans, fun(ind + 1, i, (f1 || (i == 0)), (f2 || (i == 9))));
  }
  return dp[ind][v][f1][f2] = ans;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  cin >> n;
  memset(dp, -1, sizeof(dp));
  int ans = fun(0, 0, 0, 0);
  cout << ans << endl;  

  return 0;
}

Measured memory_bytes: 237796
#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>
#define ms(x,y)                     memset(x,y,sizeof(x))
#define ump                         unordered_map<int,int>

#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265

const int MOD = 1e9 + 7;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}

inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}

inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}

inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}

bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}

int32_t main()
{
  fast ;


  int n; cin >> n;
  double dp[n + 1][n + 1];
  double p[n];
  for (int i = 0; i < n; i++)cin >> p[i];
  ms(dp, 0);
  for (int i = 0; i <= n; i++)dp[i][0] = 1;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      dp[i][j] = (dp[i - 1][j]) * (1 - p[i - 1]) + (dp[i - 1][j - 1]) * (p[i - 1]);
    }
  }
  cout << fixed << setprecision(10) << dp[n][(n + 1) / 2];


}



Measured memory_bytes: 140928
x=input()
x_list=x.split()
N=int(x_list[0])
M=int(x_list[1])

y=input()
y_list=y.split()

sum1=0
count=0

for i in range(M):
  s=int(y_list[count])
  count+=1
  sum1+=s

if N>=sum1:
  print(N-sum1)
else:
  print(-1)

Measured memory_bytes: 9516
n = int(input())
h = list(map(int,input().split()))
flag = True
for i in range(n-1):
    if h[i+1] - h[i] >= 1:
        h[i+1] -= 1
    elif h[i+1] -h[i] == 0:
        pass
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	char b,a;
	scanf("%c",&b);
	if(b=='A')	a='T';
	if(b=='T')	a='A';
	if(b=='C')	a='G';
	if(b=='G')	a='C';
	printf("%c\n",a);
	return 0;
}

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

struct node{
  int key;
  node *R,*L,*P;
};

node *rt,*nil;

void inst(int k){
  node *y = nil;
  node *x = rt;
  node *z;

  z=(node *)malloc(sizeof(node));
  z->key = k;
  z->L = nil;
  z->R = nil;

  while(x != nil){
    y = x;
    if(z->key < x->key){
      x = x->L;
    }else{
      x = x->R;
    }
  }

  z->P = y;
  if(y == nil){
    rt = z;
  }else{
    if(z->key < y->key){
      y->L = z;
    }else {
      y->R = z;
    }
  }
}

void indr(node *u){










  if(u == nil) return;
  indr(u->L);
  printf(" %d",u->key);
  indr(u->R);

}
void prodr(node *u){
  if(u == nil) return;
  printf(" %d",u->key);
  prodr(u->L);
  prodr(u->R);
}

int main(){
  int n,i,x;
  string cm;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> cm;
    if(cm == "insert") {
      scanf("%d",&x);
      inst(x);
    }else if(cm == "print"){
      indr(rt);
      printf("\n");
      prodr(rt);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26648
#include<stdio.h>
#include<iostream>
using namespace std;

int B[30];

int N,M,C;
int main (){
    cin >> N >> M >> C;
    for(int i=0; i<M; i++) cin >> B[i];

    int ans = 0;
    for(int i=0; i<N; i++) {
        int total = 0;
        for(int j=0;j<M; j++) {
            int a;
            cin >> a;
            total += a * B[j];
        }
        if( total + C > 0 ) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int main(void){

  string str_1;
  string str_2;

  cin >> str_1 >> str_2;

  str_1 += str_1;

  if(str_1.find(str_2) == -1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

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

int main(){
	string s, t;
	cin>>s>>t;
	for(int i = 0; i < (int)s.length(); ++i){
		if(s[i] != t[i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 3640
# 7,12,18
# ありうるのは、(7,17),(12,12),(8,16)
# ......AC...B...CA.......
# 7,12,16を選んだとき
# ......A_...B...C_.......
# BとCの差が4時間になる
# 17,12,8でもよい
# ......_C...B..._A.......
# 50人存在するが、時刻は0-23の24通り (ただし高橋くんは0固定なので、それ以外の人は23通り)
# N = 24人になったら鳩ノ巣理論により必ず誰かが同じ時刻になるため、答えは0
# 23人以下の場合は、全組み合わせ（2^23 = (10 ** 6) * 8）を試せば良い

N = int(input())
D = list(map(int,input().split()))
D = sorted(D,key = lambda x:min(x,24-x)) # ソートにより同時刻が固まるとループを抜けやすくなる？

if N >= 24:
  print(0)
  exit(0)
# 23桁のbit文字列で0の場合はそのまま、1の場合はひっくり返す（24-D[i]）
# []24桁のリスト(0は高橋くんがいるため初めから1人)に、人数を加算していく
# あるindexですでに人がいたらその時点で答えは0になる
# 最小値を更新していく
ans = 0

for i in range(2 ** N):
  data = [0] * 25
  data[0] = 1 # 高橋くん
  data[24] = 1 # 高橋くん
  for j in range(N):
    if (i >> j)&1:
      if data[24-D[j]] == 1:# 同時刻に既に誰かいた時点で最小値は0確定
        break
      data[24-D[j]] += 1
    else:
      if data[D[j]] == 1: # この時点で最小値は0確定
        break
      data[D[j]] += 1
  else:
    # 最小値が0でない場合
    minval = 24
    lastexist = 0
    for j in range(1,len(data)):
      if data[j]:
        if j - lastexist < minval:
          minval = j - lastexist
        lastexist = j
    if minval > ans:
      ans = minval
print(ans)


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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

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

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

  string ans = "No";
  string S, T;
  cin >> S >> T;

  int count = SZ(S);
  FOR(i, 0, count) {
    char temp = S[count - 1];
    S.pop_back();
    S = temp + S;

    if (S == T) {
      ans = "Yes";
      break;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
N=int(input())
num=list(input())
num=[0 if i=="W" else 1 for i in num ]
count=0
first=0
for i in num:
    if i==1:count+=1
jk=0
for i in range(count):
    if num[i]==1:
        jk+=1
print(count-jk)

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

int main(){
  int N;
  cin >> N;
  vector<int> M(5, 0);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S.at(0)=='M'){
      M.at(0)++;
    }
    if(S.at(0)=='A'){
      M.at(1)++;
    }
    if(S.at(0)=='R'){
      M.at(2)++;
    }
    if(S.at(0)=='C'){
      M.at(3)++;
    }
    if(S.at(0)=='H'){
      M.at(4)++;
    }
  }
  int64_t Ans=0;
  for(int i=0; i<4; i++){
    for(int j=i+1; j<5; j++){
      int64_t Pro=1;
      for(int k=0; k<5; k++){
        if(k!=i && k!=j){
          Pro*=M.at(k);
        }
      }
      Ans+=Pro;
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      final int MAX = 1_000_000;
      boolean[] isPrime = new boolean[MAX];
  
      Arrays.fill(isPrime,true);
      isPrime[0] = isPrime[1] = false;
  
      for ( int i=2; i < MAX; i++ ) {
        if (isPrime[i]) {
          for (int j = i<<1; j < MAX; j += i) {
            isPrime[j] = false;
          }
        }
      }

      StringBuilder buf = new StringBuilder();
      String[] lines;
      while(true) {
        lines = in.readLine().split(" ");
        int a = Integer.parseInt(lines[0]);
        int d = Integer.parseInt(lines[1]);
        int n = Integer.parseInt(lines[2]);

        if(a == 0 && d == 0 && n == 0) break;

        int prime;
        for(int p=a, i=0; ; p+=d) {
          if(isPrime[p]) {
            i++;
            if(i == n) {
              prime = p;
              break;
            }
          }
        }
        buf.append(prime).append("\n");
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 26764
N, Y = map(int, input().split())
Y //= 1000

for m in range(Y // 10, -1, -1):
	for g in range((Y - m * 10) // 5, -1, -1):
		if 10 * m + 5 * g + (N - m - g) == Y:
			print(m, g, N - m - g)
			exit()
print(-1, -1, -1)

Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << endl;
    return 0;
}


Measured memory_bytes: 3608
$debug = false

n = gets.to_i
works = []
n.times do
  a, b = gets.split.map(&:to_i)
  works << {hours: a, deadline: b}
end

works.sort! { |a, b| (a[:deadline] <=> b[:deadline]).nonzero? || b[:hours] <=> a[:hours] }
p works if $debug

flag = true
limit = 0
rest = 0
works.each do |work|
  puts "limit: #{limit}, hours: #{work[:hours]}, deadline #{work[:deadline]}}" if $debug
  if limit < work[:deadline]
    rest += work[:deadline] - limit
    limit = work[:deadline]
  end

  print "rest: #{rest}" if $debug
  rest -= work[:hours]
  puts " => #{rest}" if $debug
  if rest < 0
    flag = false
    break
  end
end

puts flag ? "Yes" : "No"


Measured memory_bytes: 63096
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto h = hw[0];
    auto w = hw[1];
    auto ab = readln.split.to!(int[]);
    auto a = ab[0];
    auto b = ab[1];
    writeln(h * w - (h / a) * (w / b) * a * b);
}


Measured memory_bytes: 2508
#include <iostream>

using namespace std;
typedef long long ll;

constexpr int N = (1<<18);

int n;
ll h[200005];
ll v[200005];

ll st[2*N];

void aseta(int k, ll x) {
	k += N;
	st[k] = x;
	for (k /= 2; k >= 1; k /= 2) {
		st[k] = max(st[2*k], st[2*k+1]);
	}
}

ll rmq(int a, int b) {
	a += N;
	b += N;
	ll cres = 0;
	while (a <= b) {
		if (a%2 == 1) cres = max(cres, st[a++]);
		if (b%2 == 0) cres = max(cres, st[b--]);
		a /= 2;
		b /= 2;
	}
	return cres;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
	}
	for (int i = 1; i <= n; ++i) {
		aseta(h[i], rmq(1, h[i])+v[i]);
	}
	ll res = 0;
	for (int i = 1; i <= n; ++i) {
		res = max(res, rmq(i, i));
	}
	cout << res << "\n";
	return 0;
}

/*
	find an increasing subsequence with max sum of values
	dp[i] = max sum ending at height i
*/


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

#define ll long long int
ll mod=1e9+7;
#define loop() for(int i=0;i<n;i++) 


int main()
{ 
      std::ios_base::sync_with_stdio(false);
     // int t;cin>>t;
     /* while(t--)
      {
           
           
      }*/
      
     int n;cin>>n;
     int a[n];
     loop()
      {
            cin>>a[i];
      } 
      sort(a,a+n);
      int ans=0;
      for(int i=0;i<n-2;i++)
      {
            int k=i+2;
            for(int j=i+1;j<n;j++)
            {
                  while(k<n&&((a[i]+a[j])>a[k]))
                  ++k;
                  if(k>j)
                  ans+=(k-j-1);
            }
      }
      
      cout<<ans<<'\n';
     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k,a[N];
LL s[N],t[N];
map<int,int>vis;
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+a[i],s[i]=(s[i]+k)%k;
    LL ans=0;
    vis[0]=1;
    int l=0;
    for(int i=1;i<=n;i++){
        while(i-l>=k){
            vis[(s[l]-l%k+3ll*k)%k]--;//相当于找到一段区间的sum-len=0 (%k )
            l++;
        }
        ans+=vis[(s[i]-i%k+3ll*k)%k];
        vis[(s[i]-i%k+3ll*k)%k]++;
    }
    cout<<ans<<'\n';
    return 0;
}

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

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    string s;
    cin>>s;
    int cnt = 0;
    for (auto c:s){
        if (c=='R') cnt++;
    }
    if (s=="RSR") cout<<1<<endl;
    else cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>
 
using namespace std;

const int N = 2e6 +123; 
typedef long long ll;

typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;
 
int occs[N], tree[N], n, ans[N];
 
void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}
 
int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}
 
int main()
{
    // ios :: sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);

    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
 
    sort(v.begin(), v.end());
 
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
 
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
 
    return 0;
}
 

Measured memory_bytes: 25360
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	ll n,k,sum=1;
	cin>>n>>k;
	for(ll i=1;i<n;i++){
		sum*=(k-1);
	}
	sum*=k;
	cout<<sum<<endl;
}


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

int main()
{
    long n,i,j,k,W;
    cin>>n>>W;
    long A[n],V[n];
    for(i=0;i<n;i++)
        cin>>A[i]>>V[i];
    long long knap[W+1][n+1];

    for(i=0;i<=n;i++)
        knap[0][i]=0;
    for(i=0;i<=W;i++)
        knap[i][0]=0;
    
    for(i=1;i<=W;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i<A[j-1])
                knap[i][j]=knap[i][j-1];
            else
                knap[i][j]=max(knap[i][j-1],knap[i-A[j-1]][j-1]+V[j-1]);
        }
    }
    cout<<knap[W][n]<<endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<(ll)w*h/2.0<<" ";
    if(2*x==w&&2*y==h)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256