akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

unordered_map<ll,ll> calc_factors(ll n)
{
    unordered_map<ll, ll> factors;
    for (ll i = 2; i * i <= n; i++)
    {
        while(n%i==0){
            factors[i]++;
            n /= i;
        }
    }

    if(n != 1){
        factors[n]++;
    }
    return factors;
}

int main(void)
{
    ll n;
    cin >> n;

    unordered_map<ll, ll> factors_of_factrial;
    FOR(i,2,n+1){
        unordered_map<ll,ll> factors = calc_factors(i);
        for (auto itr = factors.begin(); itr != factors.end();itr++){
            factors_of_factrial[itr->first] += itr->second;
        }
    }

    ll ans = 1;
    ll mod = 1e9 + 7;

    for (auto itr = factors_of_factrial.begin(); itr != factors_of_factrial.end();itr++){
        ans = (ans * (itr->second + 1) % mod) % mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);

    rep(i,n+1)cin >> a[i];
    rep(i,n)cin >> b[i];

    int ans = 0;
    rep(i,n){
        if(a[i] >= b[i]){
            ans += b[i];
        }else{
            ans += a[i];
            b[i] -= a[i];
            if(a[i+1] >= b[i]){
                a[i+1] -= b[i];
                ans += b[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;


    


    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc135.contest.atcoder.jp/tasks/abc135_a

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

int main()
{
	int n;
	cin >> n;
	int sum = 0, len = 0;
	for(auto i = 0; i < n; ++i){
		int l;
		cin >> l;
		sum += l;
		len = max(len, l);
	}
	cout << (len < sum - len ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int64_t, int64_t>> vs;
    for (int i = 0; i < n; i++)
    {
        int64_t a;
        cin >> a;
        vs.emplace_back(a, 1);
    }
    for (int i = 0; i < m; i++)
    {
        int64_t b, c;
        cin >> b >> c;
        vs.emplace_back(c, b);
    }
    sort(vs.begin(), vs.end(), greater<>());

    int64_t sum = 0;
    int64_t rest = n;
    for (auto v : vs)
    {
        auto select = min(rest, v.second);
        rest -= select;
        sum += select * v.first;
    }
    cout << sum << endl;
}

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

void kock(double,double,double,double,int);

int main(){
  int n;
  
  scanf("%d", &n);
  printf("%f %f\n", 0.0, 0.0);
  koch(0.0, 0.0, 100.0, 0.0, n);
  printf("%f %f\n", 100.0, 0.0);
  return 0;
}


void koch(double p1x, double p1y, double p2x, double p2y, int c){
  double sx, sy, tx, ty, ux, uy;
  if(c != 0){
    sx = (2 * p1x + p2x) / 3;
    sy = (2 * p1y + p2y) / 3;
    tx = (p1x + 2 * p2x) / 3;
    ty = (p1y + 2 * p2y) / 3;
    ux = sx + (tx - sx) * cos(M_PI/3) - (ty - sy) * sin(M_PI/3);
    uy = sy + (tx - sx) * sin(M_PI/3) + (ty - sy) * cos(M_PI/3);
 
    koch(p1x, p1y, sx, sy, c - 1);
    printf("%f %f\n", sx, sy);
    koch(sx, sy, ux, uy, c - 1);
    printf("%f %f\n", ux, uy);
    koch(ux, uy, tx, ty, c - 1);
    printf("%f %f\n", tx, ty);
    koch(tx, ty, p2x, p2y, c - 1);
  }
}

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

string cmp(int a, int b)
{
    return (a == b) ? "==" : (a < b) ? "<" : ">";
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << "a " << cmp(a, b) << " b" << endl;

    return 0;
}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;

    int b[n];
    for (int i = 0; i < n; ++i){
        b[i] = k - q;
    }

    int a[q];
    for (int i = 0; i < q; ++i){
        cin >> a[i];
        b[a[i]-1]+=1;
    }

    for (int i = 0; i < n; ++i){
        if(b[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, W = na()
wv = [na() for _ in range(n)]
dp = [0]+[float("inf")]*(10**5)
for i in range(n):
      for j in range(10**5,1,-1):
        dp[j] = min(dp[j],dp[j-wv[i][1]]+wv[i][0])

res = 0
for v,e in enumerate(dp):
  if e <= W:
    res = v
    
print(res)
      

Measured memory_bytes: 98108
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int main(){
	int n, m;
	cin>>n>>m;
	int mx=0, mn=INT_MAX;
	for(int i=1;i<=m;i++){
		int l, r;
		cin>>l>>r;
		mx = max(mx, l);
		mn = min(mn, r);
	}
	if(mn-mx+1>=0) cout<<mn-mx+1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#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>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

vector<pair<int, int>> factor(int n) {
    vector<pair<int, int>> res;
    for(int i = 2; i * i <= n; i++) {
        if(n % i != 0) continue;
        int ex = 0;
        while(n % i == 0) {
            ex++;
            n /= i;
        }
        res.push_back({i, ex});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}


int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        vector<pair<int, int>> f;
        f = factor(a);
        for(auto x : f) {
            mp[x.first]++;
        }
    }
    int k = 0;
    for(auto x : mp) {
        k = max(k, x.second);
    }
    if(k == n) cout << "not coprime" << endl;
    else if(k > 1) cout << "setwise coprime" << endl;
    else cout << "pairwise coprime" << endl;
    return 0;
}


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

int h, w, m;
// vector <vector <int> > v;

vector <int> cntr, cntc;

signed main() {
  cin>>h>>w>>m;
  set <pair <int, int> > tar;
  int u, v;
  vector <int> cntr(h, 0), cntc(w, 0);
  int rmax=0, cmax=0;
  for (int i=0; i<m; i++) {
  	cin>>u>>v;
  	tar.insert({u-1, v-1});
  	cntr[u-1]++;
  	cntc[v-1]++;
  	rmax = max(rmax, cntr[u-1]);
  	cmax = max(cmax, cntc[v-1]);
  }
  
  vector <int> rs, cs;
  for (int i = 0; i<h; i++) if (cntr[i] == rmax) rs.push_back(i);
  for (int i = 0; i<w; i++) if (cntc[i] == cmax) cs.push_back(i);
  if ((int)rs.size() * cs.size() > m) {
  	cout<<rmax + cmax;
  	return 0;
  }
  
  for (int i: rs) for (int j: cs) {
  	if (tar.count({i, j}) == 0) {
  		cout<<rmax+cmax;
  		return 0;
  	}
  }
  
  cout<<rmax+cmax-1;
  
  
  
  
  
  
}


Measured memory_bytes: 34984
#include <stdio.h>
#include <math.h>
  
struct Point{
  double x, y;
};
  
void koch(int n, struct Point a, struct Point b){
  if(n == 0) return;
  struct Point s, t, u;
  double th = M_PI * 60.0 / 180.0;
  
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
  
  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}
  
int main(){
  struct Point a, b;
  int n;
  
  scanf("%d", &n);
  
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  
  return 0;
}


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

long long MOD = 1e9 + 7;

long long f(long long a, long long b){
    if(b == 0) return 1;
    if(b % 2 == 0){
        long long t = f(a, b / 2) % MOD;
        return ((t % MOD) * (t % MOD)) % MOD;
    }else{
        long long t = f(a, b / 2) % MOD;
        return (((t % MOD) * (t % MOD)) % MOD * a) % MOD;
    }
}

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

    long long m, n;
    cin >> m >> n;

    cout << f(m, n) << endl;

    return 0;
}


Measured memory_bytes: 3216
As = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(As[K-1])


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
#define INF ( 1 << 30 )
#define fr first
#define sc second
typedef pair < int , int > Pi;
typedef pair < Pi , Pi > Pii;
const int dy[] = { 0, 1, -1, 0}, dx[] = { 1, 0, 0, -1};
int h, w, Sx, Sy, Gx, Gy;
vector< Pi > hoge[5];
int dp[5][1000], num;
char c;
int dis(Pi x1,Pi x2){
  return abs(x1.fr - x2.fr) + abs(x1.sc - x2.sc);
}
int rec(int now,int java){
  if(dp[now][java] != -1) return dp[now][java];
  int ret = INF, next = ( now + 1 ) % 5;
  if(now == num) ret = dis(hoge[now][java],Pi(Gy,Gx));
  else for(int i = 0 ; i < hoge[next].size() ; i++ ){
    ret = min( ret, rec( next, i) + dis(hoge[now][java],hoge[next][i]));
  }
  return dp[now][java] = ret;
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < 5 ; i++ ) hoge[i].clear();
    for(int i = 0 ; i < h ; i++ ){
      for(int j = 0 ; j < w ; j++ ){
        cin >> c;
        if(c == 'S') Sy = i, Sx = j;
        else if(c == 'G') Gy = i, Gx = j;
        else if(c != '.') hoge[c-'1'].push_back(Pi(i,j));
      }
    }
    Pi ret = Pi(INF,INF);
    for(int i = 0 ; i < 5 ; i++ ){
        for(int j = 0 ; j < 5 ; j++ )
          for(int k = 0 ; k < 1000 ; k++ ) dp[j][k] = -1;
      num = ( i + 4 ) % 5;
      int next = ( i + 1 ) % 5, tmp = INF;
      for(int j = 0 ; j < hoge[next].size() ; j++ ){
        tmp = min( tmp, rec( next, j) + dis(Pi(Sy,Sx),hoge[next][j]));
      }
        ret = min( ret, Pi( tmp, i + 1));
    }
    if( ret.fr == INF ) cout << "NA" << endl;
    else cout << ret.sc << " " << ret.fr << endl;
  }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
using namespace std;
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

template <class Monoid>
struct sliding_window_aggregation {
    typedef typename Monoid::value_type value_type;
    Monoid mon;
    std::stack<value_type> front, back;
    std::stack<value_type> sum_front;
    value_type sum_back;
    sliding_window_aggregation(const Monoid & mon_ = Monoid()) : mon(mon_) {
        sum_front.push(mon.unit());
        sum_back = mon.unit();
    }
    /**
     * @note O(1)
     */
    void push(value_type x) {
        back.push(x);
        sum_back = mon.append(sum_back, x);
    }
    /**
     * @note amortized O(1)
     */
    void pop() {
        if (front.empty()) {
            while (not back.empty()) {
                front.push(back.top());
                sum_front.push(mon.append(front.top(), sum_front.top()));
                back.pop();
            }
            sum_back = mon.unit();
        }
        assert (not front.empty());
        front.pop();
        sum_front.pop();
    }
    /**
     * @brief get sum of elements in the queue
     * @note O(1)
     */
    value_type accumulate() const {
        return mon.append(sum_front.top(), sum_back);
    }
    bool empty() const {
        return front.empty() and back.empty();
    }
    size_t size() const {
        return front.size() + back.size();
    }
};

struct min_monoid {
    typedef int value_type;
    value_type unit() const { return INT_MAX; }
    value_type append(value_type a, value_type b) const { return std::min(a, b); }
};

vector<int> solve(int n, int m, const string & s) {
    vector<int> dist(n + 1, INT_MAX);
    sliding_window_aggregation<min_monoid> swag;
    REP_R (i, n + 1) {
        dist[i] = (
            s[i] == '1' ? INT_MAX :
            i == n ? 0 :
            swag.accumulate() == INT_MAX ? INT_MAX :
            swag.accumulate() + 1
        );
        swag.push(dist[i]);
        if (swag.size() > m) swag.pop();
    }
    if (dist[0] == INT_MAX) return vector<int>(1, -1);
    vector<int> answer;
    for (int i = 0; i < n; ) {
        int delta = 1;
        while (dist[i + delta] != dist[i] - 1) {
            ++ delta;
            assert (i + delta <= n);
        }
        answer.push_back(delta);
        i += delta;
    }
    return answer;
}

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    cout << solve(n, m, s) << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589
 
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll c=0;
    for(int i=1;i<=n;i++)
    {
        if(n%i!=0)
            c+=(n/i);
        else
        {
            c+=(n/i);
            c--;
        }
   }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3636
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
typedef struct{
    ll l;
    ll r;
    ll idx;
} P;

struct BIT { //1-indexed
private:
    int n,n2;
    vector<ll> bit;

public:
    BIT(ll N){
        n = N;
        bit.assign(n+1, 0);
        n2 = 1;
        while(n2 * 2 <= n) n2 *= 2;
    }

    ll sum(ll x){ //[1, x]
        ll res = 0;
        for(ll i = x; i > 0; i -= i & -i) res += bit[i];
        return res;
    }

    ll sum(ll lv, ll rv){ // [lv, rv)
        return sum(rv-1) - sum(lv-1);
    }

    void add(ll x, ll v){
        if(x == 0) return;
        for(ll i = x; i <= n; i += i & -i) bit[i] += v;
    }

    ll lower_bound(ll w) {
        if (w <= 0) return 0;
        ll x = 0;
        for (ll k = n2; k > 0; k /= 2) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};
ll ans[500010] = {};
ll last_pos[500010] = {};
ll c[500010];
void solve(){
    ll N,Q;
    cin >> N >> Q;
    rep(i,0,N) cin >> c[i];
    vector<P> vp;
    rep(i,0,Q){
        ll l,r;
        cin >> l >> r;
        vp.push_back({l,r,i});
    }
    sort(vp.begin(), vp.end(), [](P p1, P p2){
        return p1.r < p2.r;
    });
    rep(i,0,N+1) last_pos[i] = -1;
    // rep(i,0,N){
    //     last_pos[c[i]] = i;
    // }
    BIT bit(N+10);
    // ll r0 = vp[0].r;
    ll cur_r = 1;
    rep(i,0,Q){
        ll l = vp[i].l, r = vp[i].r, idx = vp[i].idx;
        rep(j,cur_r,r+1){
            ll cur = last_pos[c[j-1]];
            if(cur != -1){
                bit.add(cur, -1);
            }
            last_pos[c[j-1]] = j;
            bit.add(j, 1);
        }
        cur_r = r+1;
        ll res = bit.sum(l, r+1);
        ans[idx] = res;
        // rep(i,1,N+1){
        //     cout << bit.sum(i,i+1) << " "; 
        // }
        // cout << endl;
    }
    rep(i,0,Q){
        print(ans[i]);
    }




    

}

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

Measured memory_bytes: 31088
import math

def main():
    A,B = list(map(int,input().split()))

    ans = -1
    flag = True

    for i in range(1,1010):
        if(math.floor(i*0.08) == A and math.floor(i*0.1) == B):
            ans = i
            flag = False
            break
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void solve(int N,int L,int R){
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    auto judge = [&](int x) -> bool{
        rep(i,0,N){
            if(x % V[i] == 0)return i%2 == 0;
        }
        return N % 2 == 0;
    };
    int cnt = 0;
    rep(i,L,R+1)cnt += judge(i);
    cout << cnt << endl;
}
main(){
    int N,L,R;
    cin >> N >> L >> R;
    while(N){
        solve(N,L,R);
        cin >> N >> L >> R;
    }
}


Measured memory_bytes: 3052
import bisect as bis
n, m = map(int, input().split())
p, y = [], []
idx = lambda x: x-1
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i in range(m):
    val[idx(p[i])].append(y[i]) # 市を県に対応づけるリスト
for i in range(n):  # ソートする
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])  # 順番から、idをつける
    print(str(v).zfill(6) + str(id).zfill(6))

Measured memory_bytes: 24036
#include<stdio.h>
int main(void){
  char a[202];
  int k;
  for(k=1;k<=201;k++){
    scanf("%c",&a[k]);
    if('a'<=a[k]&&a[k]<='z'){
      a[k]-=32;
    }
    printf("%c",a[k]);
    if(a[k]=='\n') break;
  }
  return 0;
}

Measured memory_bytes: 524
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (int i = 0; i < (n); ++i)

template<typename T>
T powint (const T& x, const T& y) {
  T ret = 1;
  for(int i=0; i<y; ++i) ret *= x;
  return ret;
}

long long factorial(long long X) {
  long long ans = 1;
  for(int i=1; i<X+1 ; ++i) ans *= i;
  return ans;
}

std::map<long long, long long> prime_factor(long long n) {
  std::map<long long, long long> ret;
  for(long long i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1; // if n is prime number.
  return ret;
}

template<typename intxx>
std::vector<bool> binary_representation(intxx intbit, int bitnum) {
  std::vector<bool> ret;
  for (int i=0; i<bitnum; ++i) {
    ret.push_back(intbit & 1); // logical product of 1 is same as mod 2
    intbit = intbit >> 1;
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector< vector<int> > x(N);
  vector< vector<int> > y(N);
  rep (i, N) {
    cin >> A[i];
    x[i].resize(A[i]);
    y[i].resize(A[i]);
    rep(j, A[i]) {
      cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;
  for (unsigned int bit = 0; bit < (1 << N); ++bit ) {
    int sum = 0;
    rep (j, N) {
      if (bit & (1<<j)) {
        rep (k, A[j]) {
          if (((bit >> (x[j][k]-1)) & 1) != y[j][k]) goto nextbit;
        }
      }
    }
    rep (i, N) sum += ((bit>>i) & 1); 
    ans = max(ans, sum);
nextbit:
    continue;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
typedef long long LL;
int neededOnes = 0;
int neededTwos = 0;
int neededFours = 0;
map<char,int> buckets; 
int main()
{
    int H, W;
    cin >> H >> W;
    if(H==1 && W==1)
        cout<<"Yes"<<endl;
    else
    {
        if(H != 1 && W != 1)
        {
            neededOnes = (H%2) * (W%2);
            neededTwos = 2*(H%2) + 2*(W%2);
            neededFours = ((H)/2) * ((W)/2);
        }
        else if(H==1)
        {
            neededOnes = (W%2);
            neededTwos = W/2;
            neededFours = 0;
        }
        else if(W==1)
        {
            neededOnes = (H%2);
            neededTwos = H/2;
            neededFours = 0;
        }
        int twosIHave = 0;
        int foursIHave = 0;
        for(int i = 0; i < H; i++)
            for(int j = 0; j < W; j++)
            {
                char c;
                cin >> c;
                buckets[c]++;
                if(buckets[c]%2==0)
                    twosIHave++;
                if(buckets[c]%4==0)
                {
                    twosIHave -= 2;
                    foursIHave ++;
                }
            }
        if(foursIHave >= neededFours)
        {
            foursIHave -= neededFours;
            twosIHave += foursIHave*2;
            if(twosIHave >= neededTwos)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
    return 0;
}

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



int main(){
    
    ll n,m,num[200010];
    rep(i,0,200010)num[i]=0;
    cin>>n>>m;
    
    vector<pair<ll,ll> > ab(m);
    rep(i,0,m)cin>>ab.at(i).first>>ab.at(i).second;
    sort(ab.begin(),ab.end());
    
    rep(i,0,m){
        if(ab.at(i).first==1){
            num[ab.at(i).second]++;
        }
    }
    rep(i,0,m){
        if(ab.at(i).second==n&&num[ab.at(i).first]!=0){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    
}






Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n, K; cin >> n >> K;
    vector<pair<ll,ll>> cood(n);
    rep(i,n) {
        ll x, y; cin >> x >> y;
        cood[i] = P(x,y);
    }
    sort(all(cood));
    ll ans = inf_l;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ll side = cood[j].first-cood[i].first;
            vll tmp;
            for (int k = i; k <= j; k++) {
                tmp.push_back(cood[k].second);
            }
            if (tmp.size() < K) continue;
            sort(all(tmp));
            for (int k = 0; k <= tmp.size()-K; k++) {
                ll vertical = tmp[k+K-1]-tmp[k];
                ans = min(ans,side*vertical);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# 2019-11-15 13:51:51(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 2019

def main():
    l, r = [int(x) for x in sys.stdin.readline().split()]

    if l + 2019 <= r:
        m = l + 2018
    else:
        m = r
    
    remainders = []
    for i in range(l, m):
        for j in range(i+1, m+1):
            remainders.append(i * j % mod)
    
    print(min(remainders))

if __name__ == "__main__":
    main()


Measured memory_bytes: 75416
z = gets.to_i
nums = gets.split.map(&:to_i)

ans = []
pre_num = nums[0]
nums.each_with_index do |i, j|
  if pre_num < i
    ans[j] = pre_num
  else
    ans[j] = i
  end
  pre_num = i
end
ans << nums[-1]
puts ans.inject(:+)


Measured memory_bytes: 1788
N = int(input())
series = list(map(int,input().split()))


series_sorted = series[:]
series_sorted.sort()

def make_no_decrease(condition, series):
    if condition == 0:#正の整数列
        for i in range(1,N):
            print(i, i+1)
    elif condition == 1:#負の整数列
        for i in range(1,N):
            print(N-i+1, N-i)
            
if series_sorted[0]  >= 0: #正の時
    print(len(series)-1)
    make_no_decrease(0, series)
elif series_sorted[-1] < 0: #負の時
    print(len(series)-1)
    make_no_decrease(1, series)
else:
    if abs(series_sorted[-1]) <= abs(series_sorted[0]): #負の値のほうが大きい時
        print(2*len(series)-1)
        min = series.index(series_sorted[0])
        for i in range(len(series)):
            print(min+1, i+1)
        make_no_decrease(1, series)
    elif abs(series_sorted[0]) < abs(series_sorted[-1]): #正の値のほうが大きい時
        print(2*len(series)-1)
        max = series.index(series_sorted[-1])
        for i in range(len(series)):
            print(max+1, i+1)
        make_no_decrease(0, series)

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

int main(){
    ll n, k;
    cin>>n>>k;
    ll ans=0;
    ll h[n];
    for(ll i=0;i<n;++i){
        cin>>h[i];
        if(h[i]>=k){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
/*
[abc131] C - Anti-Division
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

ll A, B, C, D;

ll gcd(ll a, ll b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

ll lcm(ll a, ll b) {
    ll d = gcd(a, b);
    return a * b / d;
}

ll calc(ll x) { return x / C + x / D - x / lcm(C, D); }

ll solve() {
    ll ans = B - A + 1 - (calc(B) - calc(A - 1));
    return ans;
}

int main() {
    cin >> A >> B >> C >> D;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 20
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );
Search Find(int ,Search);

int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='f'){
      scanf("%d",&numnode);
      Search judge=Find(numnode,road);

      if(judge!=Gard){
	printf("yes\n");
      }

      else{
	printf("no\n");
      }
    }
    
    else if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
  }
  
  return 0;
}

void Insert(int numnode){
  Search x,y,z;
  
  x=road;
  y=Gard;
  z=malloc(sizeof(struct Tree));
  z->nodekey=numnode;
  z->leftch=Gard;
  z->rightch=Gard;
  
  while(x!=Gard){
    y=x;
    
    if(z->nodekey<x->nodekey){
      x=x->leftch;
    }
    
    else{
      x=x->rightch;
    }
  }
  
  z->parent=y;
  
  if(y==Gard){
    road=z;
  }
  
  else if(z->nodekey<y->nodekey){
    y->leftch=z;
  }
  
  else{
    y->rightch=z;
  }
  
}

void Pre(Search road){
  
  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
  
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){
  
  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}

Search Find(int numnode, Search road){
  
  if((road==Gard) || (numnode==road->nodekey)){
    return road;
  }
  
  else if(numnode<road->nodekey){
    return Find(numnode,road->leftch);
  }
  
  else{
    return Find(numnode,road->rightch);
  }
}



Measured memory_bytes: 20528
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n;
    int cnt = 0;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(auto &i : s){
        cnt += (i == 'I') ? 1 : -1;
        ans = max(cnt, ans);
    }
    cout << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int num[10];
bool test(int l_num, int r_num, int i) {
  if (i >= 10) return true;
  if (num[i] > l_num && num[i] > r_num) return test(num[i], r_num, i+1) || test(l_num, num[i], i+1);
  if (num[i] > l_num) return test(num[i], r_num, i+1);
  if (num[i] > r_num) return test(l_num, num[i], i+1);
  return false;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> num[j];
    }
    if (test(0, 0, 0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define N 200006
#define mo 1000000007
using namespace std;
int n,m,x,y,t,a[N],s[N],A,B,fac[N],inv[N];
inline int read()
{
	int x=0,c=getchar(),f=1LL;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1LL)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(long long x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
int ksm(int x,int y)
{
	if(y==0)return 1;if(y==1)return x;int p=ksm(x,y>>1);
	if(y&1)return 1LL*p*p%mo*x%mo;return 1LL*p*p%mo;
}
int C(int a,int b)
{
	if(b>a)return 0;
	return 1LL*fac[a]*inv[b]%mo*inv[a-b]%mo;
}
int main()
{
	n=read()+1;fac[0]=inv[0]=1;
	if(n==1)return puts("1"),0;
	for(int i=1;i<=n;i++)
		{x=read();if(a[x])B=i,A=a[x];a[x]=i;}
	for(int i=1;i<N;i++)
		fac[i]=1LL*i*fac[i-1]%mo,inv[i]=ksm(fac[i],mo-2);
	printf("%d\n",n-1);
	for(int i=2;i<n;i++){
		printf("%d\n",(C(n,i)-C(A+n-B-1,i-1)+mo)%mo); 
	}
	printf("%d\n",1);
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt(); // 500
    int B = sc.nextInt(); // 100
    int C = sc.nextInt(); // 50
    int X = sc.nextInt(); // sum
    int rc = 0;           // result count
    
    for (int a =0;a<=A;a++) {
      for (int b =0;b<=B;b++) {
        for (int c =0;c<=C;c++) {
          if (X == 500*a+100*b+50*c) {
            rc = rc +1;
          }
        }
      }
    }
    System.out.println(rc);
  }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

string s, t;
ll n;
ll nextIndex[26][100000];

int main(){
  cin >> s >> t;
  n = s.size();
  for(int i=0;i<26;i++){
    vector<ll> shown;
    for(int j=0;j<n;j++) if (s[j]=='a'+i) shown.pb(j);
    if (shown.size()==0) for(int j=0;j<n;j++) nextIndex[i][j] = -1;
    else{
      int offs = 0;
      for(int j=0;j<n;j++){
        if (j == shown[offs]) offs = (offs + 1) % shown.size();
        nextIndex[i][j] = shown[offs];
      }
    }
  }
    
  ll ans = -n;
  ll now = n - 1;
  for(int i=0;i<t.size();i++){
    ll next = nextIndex[t[i]-'a'][now];
    // cerr << next << endl;
    if (next == -1){
      cout << -1 << endl; return 0;
    }
    if (now >= next) ans += n;
    now = next;
  }
  ans += 1 + now;
    
  cout << ans << endl;
  return 0;
}
  

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

int main() {
  int n,r;
  cin>>n>>r;
  int i=0;
  if(n>9){
    i+=r;
  }
  else if(0<n<10){
    i+=r+100*(10-n);
  }
  cout<<i;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int a, b, k;

    cin >> a >> b >> k;

    int n = __gcd(a, b);

    vector <int> v;

    for (int i = 1; i <= sqrt(n); i++) {

        if (n%i == 0) {

            if (i*i == n) v.push_back(i);
            else {

                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }

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

    cout << v[v.size()-k];

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <memory>

template <class Key>
class BinarySearchTree {
    struct Node {
        bool isvalid;  // falseなら空Node
        Key key;

        std::unique_ptr<Node> lch, rch;
        Node() : isvalid(false), key(0) {}
    };
    using pNode = std::unique_ptr<Node>;

private:
    pNode root;

    // keyを持つNodeのポインタを返す
    // なければkeyを持つべき空Nodeのポインタを返す
    pNode& search(Key key, pNode& node) {
        if (!node->isvalid) return node;
        if (key == node->key) return node;
        return search(key, (key < node->key ? node->lch : node->rch));
    }

    pNode& downleft(pNode& node) {
        if (!node->lch->isvalid) return node;
        return downleft(node->lch);
    }

    void erase(pNode& node) {
        if (!node->isvalid) return;

        if (node->lch->isvalid && node->rch->isvalid) {
            pNode& ch = downleft(node->rch);
            node->key = ch->key;
            erase(ch);
            return;
        }

        if (node->lch->isvalid) {
            node = std::move(node->lch);
        } else if (node->rch->isvalid) {
            node = std::move(node->rch);
        } else {
            node->lch.release();
            node->rch.release();
            node->isvalid = false;
        }
    }

    void dfs(int type, pNode& node, std::vector<Key>& v) {
        if (!node->isvalid) return;

        if (type < 0) v.push_back(node->key);
        dfs(type, node->lch, v);
        if (type == 0) v.push_back(node->key);
        dfs(type, node->rch, v);
        if (type > 0) v.push_back(node->key);
    }

public:
    explicit BinarySearchTree() : root(new Node()) {}

    void insert(Key key) {
        pNode& node = search(key, root);
        if (node->isvalid) return;

        node->isvalid = true;
        node->key = key;
        node->lch.reset(new Node());
        node->rch.reset(new Node());
    }

    bool find(Key key) {
        pNode& node = search(key, root);
        return node->isvalid;
    }

    void erase(Key key) { erase(search(key, root)); }

    // type < 0 : 行きがけ順
    // type = 0 : 通りがけ順
    // type > 0 : 帰りがけ順
    std::vector<Key> tour(int type) {
        std::vector<Key> ret;
        dfs(type, root, ret);
        return ret;
    }
};

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

    BinarySearchTree<int> bst;
    for (int q = 0; q < Q; ++q) {
        std::string type;
        std::cin >> type;

        if (type == "insert") {
            int key;
            std::cin >> key;
            bst.insert(key);

        } else if (type == "find") {
            int key;
            std::cin >> key;
            std::cout << (bst.find(key) ? "yes" : "no") << std::endl;

        } else if (type == "delete") {
            int key;
            std::cin >> key;
            bst.erase(key);

        } else {
            auto in = bst.tour(0);
            for (auto k : in) std::cout << " " << k;
            std::cout << std::endl;

            auto pre = bst.tour(-1);
            for (auto k : pre) std::cout << " " << k;
            std::cout << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 32528
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		sc.close();

		//N<=Mにする
		if (N > M) {
			int tmp = N;
			N = M;
			M = tmp;
		}

		long ans;
		if (N == 1 && M == 1) {
			ans = 1;
		} else if (N == 1) {
			// 2 3 3 3 2
			// 端以外は裏
			ans = M - 2;
		} else {
			// 4 6 6 6 4
			// 6 9 9 9 6
			// 6 9 9 9 6
			// 4 6 6 6 4
			//内側のみ裏
			ans = (long)(N - 2) * (M - 2);

		}

		out.println(ans);
	}

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


Measured memory_bytes: 22612
S = input().strip('\n')
S1=S[:(len(S)-1)//2]
S2=S[(len(S)-1)//2+1:]
flag=True
for i in range(len(S)//2):
    if S[i]!=S[-i-1]:
        flag=False               
for i in range(len(S)//2//2):
    if S1[i]!=S1[-i-1] or S2[i]!=S2[-i-1]:
        flag=False
print('Yes' if flag else 'No')

Measured memory_bytes: 3064
import java.util.Scanner;

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

        Scanner as = new Scanner(System.in);
        int a = as.nextInt();
        int b = as.nextInt();

        int ab=a*b;
        int apb=(a*2)+(b*2);
        
 
        System.out.println(ab+" "+apb);
 
 
   }
 
 
}

Measured memory_bytes: 25968
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

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

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const yes = "YES"
const no = "NO"

func solve(n int, as []int) bool {
	sort.Ints(as)
	p := -1
	for _, v := range as {
		if v == p {
			return false
		}
		p = v
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	as := nextInts(n)
	if solve(n, as) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

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

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int {
	a, _ := strconv.ParseInt(next(), 10, 32)
	return int(a)
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := int(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int n,i;
  cin>>n>>i;
  ou(n-i+1);
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound

using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime

vector< pair<ll,ll> >a ;

void solve()
{
    ll n;cin>>n;
    ll x;
    forci(i,n){cin>>x;a.pb(mp(x,i));}
    ll dp[n+3][n+4];memset(dp,0,sizeof dp);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(ll i=0;i<n;i++)
    {
        for(ll j=0,k=i;k>=0;j++,k--)
        {
            dp[j+1][k]=max(dp[j+1][k],dp[j][k]+a[i].x*abs(j-a[i].y));
            dp[j][k+1]=max(dp[j][k+1],dp[j][k]+a[i].x*abs(n-1-k-a[i].y));
        }
    }
    ll ans=0;
    for(ll i=0,j=n;j>=0;j--,i++)
    {
        ans=max(ans,dp[i][j]);
    }
    cout<<ans<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }


 solve();
    return 0;
}


Measured memory_bytes: 35064
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

n = int(input())
print(180 * (n - 2))

Measured memory_bytes: 5588
#include "bits/stdc++.h"
using namespace std;

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

int main() {
        long long k;
        cin >> k;
        int n = 50;
        vector<long long> a(n);
        for (int i = 0; i < n; i ++) a[i] = i;
        long long mod = k % n;
        long long div = k / n;
        for (int i = 0; i < n; i ++) a[i] += div;
        for (int i = 0; i < mod; i ++) a[i] += n - (mod - 1);
        for (int i = mod; i < n; i ++) a[i] -= mod;
        cout << n << endl;
        for (int i = 0; i < n; i ++) cout << a[i] << (i != n - 1 ? ' ' : '\n');
        return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
	int base=0,out=0,score=0,e,i,j;
	char str[10];
	scanf("%d",&e);
	for(i=0;i<e;){
		scanf("%s",&str);
		if(!strcmp(str,"HIT"))base++;
		
		else if(!strcmp(str,"OUT")){
			out++;
		}
		
		else if(!strcmp(str,"HOMERUN")){
			score=score+base+1;
			base=0;
		}
		if(base>3){
			base--;
			score++;
		}
		if(out==3){
			out=0;
			printf("%d\n",score);
			i++;
			base=0;
			score=0;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int cnt = 0;
    while(1){
        if(cnt % 2 == 0) c -= b;
        else a -= d;
        cnt++;
        if(a <= 0){
            no();
            return 0;
        }
        if(c <= 0){
            yes();
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3596