akhauriyash/Code-Regression huggingface dataset:
// Fri Aug 21 19:35:37 IST 2020      
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int N = 1e5+7; 
const int INF = 2e9;
const int64 reallyBig = 1e16+7;

struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 

int tests(){    
    string s;
    cin >> s;
    int ans = 0;
    for(auto c:  s)
        ans += c-'0';
    cout << (ans%9 == 0 ? "Yes" : "No") << endl;
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3744
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
   
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b != 3:
        print('#' * 20)

Measured memory_bytes: 7772
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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

int main(){
	int d;
	int s;
	
	while(cin>>d){
		s = 0;
		for(int i=d;i<600;i+=d){
			s+=i*i*d;
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INFTY 1000000
int color[100];
int M[100][100];
int d[100];
int p[100];
int n;
void prim(){
  int u,minv,total;
  int i;

  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INFTY;
    p[i]=-1;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && M[u][i]!=INFTY){
        if(d[i]>M[u][i]){
          d[i]=M[u][i];
          p[i]=u;
          color[i]=GRAY;
        }
      }
    }
  }
  total=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)
    total+=M[i][p[i]];
  }
  printf("%d\n",total);
}

int main(int argc, char const *argv[]) {
  int i,j,s;
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    for(j=0;j<n;j++){
      scanf("%d",&s);
      M[i][j]=(s==-1)? INFTY:s;
    }
  }
  prim();
  return 0;
}

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

using namespace std;

typedef long long int lli;

// ####################
//  Calc nCr
// ####################
const lli MAX = 1000000;
const lli MOD = 1000000007;

lli fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void NCRinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
lli NCR(int n, int r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

lli NPR(int n, int r) {
    return (NCR(n, r) * fac[r]) % MOD;
}
// ####################
//  Calc nCr END
// ####################

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

    NCRinit();

    vector<vector<int>> tree(100001, vector<int>());
    vector<int> used(100001, 0), prev(100001, 0);

    int n, k, a, b;
    cin >> n >> k;
    for (int i=0; i<n-1; i++) { 
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    lli ans = k;
    queue<pair<int, int>> qu; // <prev, crnt>
    qu.push(make_pair(0, 1));
    while (!qu.empty()) {
        int prev = qu.front().first, crnt = qu.front().second;
        qu.pop();

        for (auto t : tree[crnt]) {
            if (t == prev) continue;
            qu.push(make_pair(crnt, t));
        }

        ans *= (crnt == 1) ? NPR(k-1, tree[crnt].size()) : NPR(k-2, tree[crnt].size()-1);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int w = a;
        a = b;
        b = w;
        
        w = a;
        a = c;
        c = w;
        System.out.println(a+" "+b+" "+c);
    }
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    if(a==1 && b==2)
        cout<<3;
    else if(a==1 && b==3)
        cout<<2;
    else if(a==2 && b==3)
        cout<<1;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int x[100], y[100], r[100], c[100], n;
queue<int>Q; bool p[1 << 24];
int main() {
	while (true) {
		for (int i = 0; i < (1 << 24); i++)p[i] = false;
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> r[i] >> c[i];
		Q.push((1 << n) - 1); int maxn = 0;
		while (!Q.empty()) {
			int bit[24]; int a = Q.front(); Q.pop();
			for (int i = 0; i < 24; i++)bit[i] = (a / (1 << i)) % 2;
			int cnt = 0; for (int i = 0; i < 24; i++)cnt += bit[i];
			maxn = max(maxn, n - cnt); int d[24];
			for (int i = 0; i < 24; i++)d[i] = 0;
			for (int i = 0; i < n; i++) {
				if (bit[i] == 0)continue;
				d[i] = 1;
				for (int j = 0; j < i; j++) {
					if (bit[j] == 0)continue;
					int dist = (x[i] - x[j])*(x[i] - x[j]);
					dist += (y[i] - y[j])*(y[i] - y[j]);
					if (dist < (r[i] + r[j])*(r[i] + r[j]))d[i] = 0;
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (d[i] == 0 || d[j] == 0)continue;
					if (c[i] == c[j]) {
						int v = a - (1 << i) - (1 << j);
						if (p[v] == true)continue;
						Q.push(v); p[v] = true;
					}
				}
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 19012
#include "bits/stdc++.h"

using namespace std;
inline int read() {
    int x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (f) return x;
    return 0 - x;
}
typedef long long ll;
const int maxn = 200010;
const int inf = 0x3f3f3f3f;
const ll mod = 1000000000 + 7;

ll h[maxn], sum = 0;

int main() {
    int n, k;
    n = read(), k = read();
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
        sum += h[i];
    }
    sort(h + 1, h + n + 1, greater<int>());
    if (k >= n) cout << 0 << endl;
    else {
        for (int i = 1; i <= k; i++)
            sum -= h[i];
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#define mt make_tuple
#define ll long long
#define ld long double
#define eb emplace_back
#define fi first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cin >> vec[i];}
#define printVec(vec) for(int i = 0; i < SZ(vec) ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
//#define PI 3.1415926535897932384626
 
using namespace std;
 //using namespace __gnu_pbds;
 //template <typename T>
 //using ordered_set =
    //tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
/*
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 */
//----------------------------------------------------------------------------------------------------------------------
 
void swap(int & a, int & b){
    auto temp = a;
    a = b;
    b = temp;
}
 
const ll MOD = 1e9 + 7;
 
ll inf = 1LL*1e17;
 
void no(){
    cout <<"NO" << endl;
   //exit(0);
}
 
void yes(){
    cout <<"YES" << endl; //exit(0);
}
 
const ll md = 998244353;


void sl(){
	string s;
	cin >> s;
	for(int i = 0;i < SZ(s);i++){
		cout << 'x';
	}
	cout << endl;
}
 
 
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ts = 0;
    if(ts == 1) cin >> ts;
    else ts = 1;
    while(ts--) sl(); 
    return 0;
} 


Measured memory_bytes: 256
w,h,n=map(int,input().split())
x1_max = 0
x2_min = w
y3_max = 0
y4_min = h

for i in range(n):
  x,y,a=map(int, input().split())
  if a==1: x1_max = max(x1_max, x)
  elif a==2: x2_min = min(x2_min, x)
  elif a==3: y3_max = max(y3_max, y)
  elif a==4: y4_min = min(y4_min, y)
    
print((x2_min - x1_max if x1_max < x2_min else 0)*(y4_min - y3_max if y3_max < y4_min else 0))

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

int main(){
  
  int K, S;
  cin >> K >> S;
  int count = 0;
  
  for(int i = 0; i < K + 1; i++){
    for(int j = 0; j < K + 1; j++){
     
        if(i + j <= S && K >= S - i - j ){
          count++;       
        }      
    }
  }
  
  cout << count << endl;
}
  
  
    
    

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

int main(){
    int N;
    cin>>N;
    
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin>>L.at(i);
    }
    
    sort(L.begin(),L.end());
    
    int sum=0;
    for(int i=0;i<N-1;i++){
        sum+=L.at(i);
    }
    
    if(L.at(N-1)<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  
}

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

struct union_find{
    union_find(int n){
        par = vector<int>(n, -1);
    }
    int find(int x){
        if(par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(par[x] < par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
    }
    int getSize(int x){
        return -par[x];
    }

    private:
        vector<int> par;
};


int main(){
    int N, M;  cin >> N >> M;
    union_find uf(N);
    for(int i=0; i<M; i++){
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--;  Y--;
        uf.unite(X, Y);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        if(uf.find(i) == i) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
program main 
implicit none
integer::a, b
character(100)::s, t, u
	read*,s,t,a,b,u
	s=trim(s)
	t=trim(t)
	u=trim(u)
	if(s==u)then
    	print*,a-1,b
    else
    	print*,a,b-1
    end if
end program main

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}


int main(int argc, char const *argv[])
{
	

	ll n, x, ans=0;cin>>n>>x;

	vll a(n);
	
	rep(i,n)cin>>a[i];

	if(n==1)return cout<<max(0LL,a[0]-x),0;

	for (int i = 1; i < n; ++i)
	{
		if (a[i] + a[i-1] > x)
		{
			ll dif = a[i] + a[i-1] - x;

			ll sub = min(a[i],dif);

			ans+=sub, a[i]-=sub, dif-=sub;

			a[i-1]-=dif, ans+=dif;
		}

	}
	cout<<ans;
}	

Measured memory_bytes: 1152
import Data.List

main = do
  getLine
  li <- getLine
  let xs = map read $ words li
  let ans = compute xs
  print ans

{-
-99 ～ +99 のオフセットで消費する体力の表を作っておき、
全員の分に関して1から100で必要な体力を足し合わせて最小値を得る
-}

cs = rev cs1 (0:cs1)
  where
    cs1 =[k*k | k <- [1..99]]
    rev [] xs = xs
    rev (y:ys) xs = rev ys (y:xs)

compute :: [Int] -> Int
compute xs = minimum $ map sum $ transpose $ map (\x -> take 100 $ drop (100-x) cs) xs


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,x,i,m,k=1e7,ans=0;
  cin >> n >> x;
  for (i=0;i<n;i++){
    cin >> m;
    x-=m;
    k=min(k,m);
  }
  ans=n+x/k;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#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(){
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < (int)s.size(); i++){
        bool ok = true;
        for(int j = 0; j < t.size(); j++){
            if(s[(j + i) % s.size()] != t[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}


int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


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

int main() {
	int H, N;
	cin >> H >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		sum += tmp;
	}
	if (sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

const ll MOD=1000000007;

ll poww(ll a,ll b)
{
  a%=MOD;
  ll res=1LL;
  for(;b;b>>=1)
  {
     if(b&1)res=(res*a)%MOD;
     a=(a*a)%MOD;
  }
  return res%MOD;
}


ll fac[2000010];

ll inv(ll x)
{
  return poww(x,MOD-2);
}



ll cnk(ll n,ll k)
{
  ll res=1;
  res=fac[n];
  res*=inv(fac[k]);
  res%=MOD;
  res*=inv(fac[n-k]);
  res%=MOD;
  return res;
}


ll cel(ll n)
{
  ll ans=poww(2LL,n);
  if(ans<0)ans+=MOD;
  ans%=MOD;
  return ans;
}

ll n;
int main(){
FLASH;
cin>>n;
ll ans=poww(10,n);
ll one=poww(9,n);
one*=2;
one%=MOD;
ll two=poww(8,n);

ans-=one;
if(ans<0)ans+=MOD;
ans%=MOD;
ans+=two;
ans%=MOD;
cout<<ans<<endl;







return 0;
} 


Measured memory_bytes: 3628
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int[] ary = new int[n];
      int sum = 0;
      for (int i = 0; i < n ; i++) {
        ary[i] = Integer.parseInt(sc.next());
      }
      for (int i = 1; i < n -1 ; i++) {
        if (ary[i -1] < ary[i] && ary[i] < ary[i+1]) {
          sum += 1;
        } else if (ary[i -1] > ary[i] && ary[i] > ary[i+1]) {
          sum += 1;
        }
      }
      System.out.println(sum);
      
    }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  REP(r,N+1) {
    REP(g,N+1) {
      int b = N-r*R-g*G;
      // cerr << r << " " << g << " " << b << endl;
      if(0<=b&&b%B == 0) {
        ans++;
        // cerr << "OK" << endl;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

void sharp(int w){
    for (int i = 0; i < w+2; i++){
        cout << "#";
    }
}

int main(void){
    int h, w;
    string h1 = "#", w1 = "#";
    cin >> h >> w; // i = h, j = w 
    string S[100];
    
    for(int i = 0; i < 100; i++){
        cin >> S[i];
    }
    
    sharp(w);
    cout << endl;
    
    for(int i = 0; i < h; i++){
        cout << "#" << S[i] << "#" << endl;
    }
    
    sharp(w);
}

Measured memory_bytes: 3060
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]

def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

n,m,R=MI()
r=LI_()
g,_=GI(n,m)

show(g)
inf=float('inf')
def wf(e):
    n=len(e)
    d=[[inf]*n for _ in range(n)]
    for a in range(n):
        for b,c in g[a]:
            d[a][b]=c
            d[b][a]=c
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j]>d[i][k]+d[j][k]:
                    d[i][j]=d[i][k]+d[j][k]
    
    return d

ans=inf
md=wf(g)
dists=[]
def search(st,d,ls):
    if len(ls)==1:
        dists.append(d+md[st][ls[0]])
        return
    for gl in ls:
        search(gl,d+md[st][gl],[i for i in ls if i!=gl])
    return

for i in r:search(i,0,[j for j in r if i!=j])
print(min(dists))


Measured memory_bytes: 60508
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	ll N,M;
    cin >> N >> M;
    VL A;
    ll sum = 0;
    rep(i,M){
        ll a;
        cin >> a;
        sum += a;
    }
    if(N>=sum){
        cout << N- sum << endl; 
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
        int a, b, c;
        int x,y;
        scanf("%d %d %d %d %d", &a,&b,&c,&x,&y);
        if(2*c>= a+b){
            printf("%d",x*a+y*b);
        }
        else {
            if(b<a){
                int b0 =a;
                a =b;
                b = b0;
                b0 = x;
                x = y;
                y = b0;
            }
            if(2*c<a){
                if(y<x){
                    printf("%d",x*2*c);
                }
                else{
                    printf("%d",y*2*c);

                }
            }
            else if(2*c<b){
                if(y<x){
                    printf("%d",y*2*c+(x-y)*a);
                }
                else{
                    printf("%d",y*2*c);
                }
            }
            else{
                if(y<x){
                    printf("%d",y*2*c+(x-y)*a);
                }
                else{
                    printf("%d",x*2*c+(y-x)*b);
                }
            }

        }
        return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i]; sort(A,A+N,greater<ll>());
  ll result = 0;
  if (N%2==0) rep(i,N/2) result += i==0 ? A[i] : A[i]*2;
  else rep(i,(N+1)/2) result += i==0||i==N/2 ? A[i] : A[i]*2;
  cout << result << endl;
  return 0;
}

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

int main() {
  long n,x,m,minm=1000000;
  cin >> n >> x;
  for(long i=0;i<n;i++) {
    cin >> m;
    minm=min(minm,m);
    x-=m;
  }
  cout << n+x/minm << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

#define MOD 1000000007

using namespace std;

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

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

	int add;
	int sol = 0;

	add = a < k ? a : k;

	k -= add;

	sol += add;

	add = b < k ? b : k;

	k -= add;

	add = c < k ? c : k;

	k -= add;

	sol -= add;

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

	return 0;
}

Measured memory_bytes: 1732
use List::Util qw/sum/;

use strict;
use warnings;

my @a1 = glob<>;
my @a2 = glob<>;
my @a3 = glob<>;
my $a = [\@a1, \@a2, \@a3];
my $n = glob<>;

my $b = [];
for my $i ( 0 .. $n-1 ) {
    $b->[$i] = <>;
}
my $bingo = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
];

for my $bi (@$b) {
    for my $i ( 0 .. 2 ) {
        my $ai = $a->[$i];
        for my $j ( 0 .. 2 ) {
            my $aij = $ai->[$j];
            if ($aij == $bi) {
                $bingo->[$i]->[$j] = 1;
            }
        }
    }
}

print(is_bingo($bingo) ? 'Yes' : 'No');


sub is_bingo {
    my $bin = shift;
    for my $bi (@$bin) {
        if (sum(@{$bi}) == 3) {
            return 1
        }
    }
    for my $i ( 0 .. 2 ) {
        if (sum($bin->[0]->[$i], $bin->[1]->[$i], $bin->[2]->[$i]) == 3) {
            return 1
        }
    }
    if (sum($bin->[0]->[0], $bin->[1]->[1], $bin->[2]->[2]) == 3
        or sum($bin->[0]->[2], $bin->[1]->[1], $bin->[2]->[0]) == 3) {
        return 1
    }

    return 0
}

Measured memory_bytes: 896
/*{{{*/
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_;\
__VA_ARGS__;--c_; if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define dump(...) dbg(print(#__VA_ARGS__, __VA_ARGS__))
#define dump_range(...) dbg(cerr<<#__VA_ARGS__<<": ";print_range(__VA_ARGS__))
using namespace std; using ll = long long; 
template< typename t > using V = vector< t >; void print(){cout<<'\n';}
template< typename t, typename... v > void print(const t& a, v&&... b)
{cout << a << ' '; print(b...);}
template< typename t > void print_range(t a, const t& b)
{while (a!=b) cout << (*a++) << ' '; cout << '\n';}
/*}}}*/

constexpr int maxn = 2e5;

int n;
int tb[maxn + 2];
int pt[maxn + 2];

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

    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        int v; cin >> v;
        tb[v] = i;
    }
    
    pt[n] = n + 1;
    pt[n + 1] = n + 1;

    for (int i = n - 1; i >= 1; --i)
    {
        int k = i + 1;
        while (tb[k] > tb[i])
            k = pt[k];
        pt[i] = k;
    }

    for (int i = n; i >= 1; --i)
        pt[i] = min(pt[i], pt[i + 1]);

    int res = n;

    for (int i = n + 1; i >= 1; --i)
    {
        int q = n - pt[i] + 1 + i - 1;
        res = min(res, q);
    }

    print(res);
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  string s;
  cin >> s;
  int ans = 1;
  string now = s.substr(0,1);
  int k = 1;
  while(k<s.size()){
    if(now!=s.substr(k,1)){
      now = s.substr(k,1);
      k ++;
    }
    else if(k == s.size()-1){
      break;
    }
    else{
      now = s.substr(k,2);
      k += 2;
    }
    ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;

int main() {
	int A, B, M;
	int min1 = INT_MAX, min2 = INT_MAX;
	scanf("%d%d%d", &A, &B, &M);
	int a[A + 5], b[B + 5];
	for (int i = 0; i < A; i++) {
		scanf("%d", &a[i]);
		min1 = min(min1, a[i]);
	}
	for (int i = 0; i < B; i++) {
		scanf("%d", &b[i]);
		min2 = min(min2, b[i]);
	}
	int ans = min1 + min2;
	while (M--) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		ans = min(ans, a[x - 1] + b[y - 1] - c);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, m, c, a[N], b[N];

int f(int p) {
	if (b[p] == p) return p;
	return b[p] = f(b[p]);
}

int main()
{
	int i, t1, t2;
	cin >> n >> m;
	for (i = 1; i <= n; i++) b[i] = i, scanf("%d", &t1), a[t1] = i;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		f(t1); f(t2);
		if (b[t1] != b[t2]) b[b[t2]] = b[t1];
	}
	for (i = 1; i <= n; i++) {
		f(i); f(a[i]);
		if (b[i] == b[a[i]]) c++;
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n;
    cin>>n;
    cout<<(1000*((n/1000)+1)-n)%1000;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


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

#define INF 1000000

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

int main(void){
    int N;
    cin >> N;
    int V[N+1];
    for(int i=0;i<N;i++){
        V[i]=INF;
    }
    V[0]=0;
    V[1]=1;
    for(int i=2;i<N+1;i++){
        V[i]=V[i-1]+1;   
        for(int k=1;;k++){
            if(i-pow(6.0,k)>=0){
                chmin(V[i],V[i-(int)pow(6.0,k)]+1);   
            }else{
                break;
            }
        }
        for(int k=1;;k++){
            if(i-pow(9.0,k)>=0){
                chmin(V[i],V[i-(int)pow(9.0,k)]+1);   
            }else{
                break;
            }
        }
    }
    cout << V[N] << endl;
    return 0;
}

Measured memory_bytes: 640
program two_arrays
  implicit none
  integer :: n
  integer(8) :: a(10000), b(10000), m, x, y
  a = 0_8
  b = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  m = sum(b(1:n)-a(1:n))
  x = sum(a(1:n)-b(1:n),a(1:n)-b(1:n).gt.0_8)
  y = sum((b(1:n)-a(1:n)+1_8)/2_8,b(1:n)-a(1:n).gt.0_8)
  if (m.ge.max(x,y)) then
    write(*,'(a)') "Yes"
  else
    write(*,'(a)') "No"
  end if
  stop
end program two_arrays

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a[30]={0};
  rep(i,n){
    int r;
    cin>>r;
    rep(j,r){
      int num;
      cin>>num;
      a[num-1]++;
    }
  }
  int ans=0;
  rep(i,m){
    if(a[i]==n) ans++;
  }
  cout<<ans<<endl;
  

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N;
    cin >> N;

    ll A;
    set<ll> singleEdge;
    map<ll, ll> pairEdge;

    rep(i, N){
        cin >> A;
        if(singleEdge.find(A) != singleEdge.end()){
            if(pairEdge.find(A) != pairEdge.end()){
                pairEdge[A]++;
            }else{
                pairEdge[A] = 2;
            }
        }else{
            singleEdge.insert(A);
        }
    }
    if(pairEdge.size() == 0 || (pairEdge.size() == 1 && pairEdge.rbegin()->second < 4)){
        cout << 0 << endl;
        return 0;
    }

    ll x, y;
    if(pairEdge.rbegin()->second >= 4){
        x = pairEdge.rbegin()->first;
        y = pairEdge.rbegin()->first;
    }else{
        x = pairEdge.rbegin()->first;
        pairEdge.erase(pairEdge.rbegin()->first);
        y = pairEdge.rbegin()->first;
    }

    cout << x * y << endl;

    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

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

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int h, w;
	cin >> h >> w;
	string maps[8];
	REP(i, h) cin >> maps[i];
	
	bool done[8][8] = {};
	
	bool ans = true;
	
	int x = 0, y = 0;
	done[0][0] = true;
	while (x + 1 != w || y + 1 != h) {
		if (x + 1 < w && maps[y][x + 1] == '#') x++;
		else if (y + 1 < h && maps[y + 1][x] == '#') y++;
		else {
			ans = false;
			break;
		}
		
		done[y][x] = true;
	}
	
	REP(i, h) REP(j, w) if (maps[i][j] == '#' && !done[i][j]) ans = false;
	puts(ans ? "Possible" : "Impossible");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  double x[25],y[25],ans=0,a,b,c,z;
  int cnt=0;
  while(scanf("%lf,%lf",&x[cnt],&y[cnt])!=EOF){
    if(cnt>=2){
      a=sqrt(fabs(x[0]-x[cnt-1])*fabs(x[0]-x[cnt-1])+fabs(y[0]-y[cnt-1])*fabs(y[0]-y[cnt-1]));
      b=sqrt(fabs(x[cnt-1]-x[cnt])*fabs(x[cnt-1]-x[cnt])+fabs(y[cnt-1]-y[cnt])*fabs(y[cnt-1]-y[cnt]));
      c=sqrt(fabs(x[cnt]-x[0])*fabs(x[cnt]-x[0])+fabs(y[cnt]-y[0])*fabs(y[cnt]-y[0]));
      z=(a+b+c)/2.0;
      ans+=sqrt(z*(z-a)*(z-b)*(z-c));
    }
    cnt++;
  }
  printf("%.10lf\n",ans);
  return 0;
}



Measured memory_bytes: 3164
def solve(k,s):
    isOne = True
    index = 0
    digit = -1
    while index<len(s):
        if s[index] == "1":
            index += 1
        else:
            digit = s[index]
            break
    if digit != -1:
        if k <= index:
            return(1)
        else:
            return(digit)
    else:
        return(1)

s = input()
k = int(input())
print(solve(k,s))

Measured memory_bytes: 3064
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)

for i in range(-max_a, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a, b in ab)
print(min(dp[h:]))


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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100010];
ll finv[100010];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return 0;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(100005);
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max({a*c,a*d,b*c,b*d});
    }
}

Measured memory_bytes: 3672
n, m = map(int, input().split())

arr = [0, n+1]

for i in range(m):
    a , b = map(int, input().split())
    if arr[0] < a:
        arr[0] = a
    if arr[1] > b:
        arr[1] = b

ans = arr[1] - arr[0] + 1

if ans >= 0:
    print(arr[1] - arr[0] + 1)
else:
    print(0)


Measured memory_bytes: 3064
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	ll x;
	cin >> x;
	ll c = 100;
	REP(i, 10000) {
		if(c >= x) {
			cout << i << endl;
			break;
		}
		c *= 1.01;
	}
	return 0;
}


Measured memory_bytes: 3632
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define N 75
#define ll long long
#define mo 1000000007
ll qpow(ll x,ll y=mo-2){
	ll r=1;
	for (;y;y>>=1,x=x*x%mo)
		if (y&1)
			r=r*x%mo;
	return r;
}
ll fac[N*4],ifac[N*4];
void initC(int n){
	fac[0]=1;
	for (int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mo;
	ifac[n]=qpow(fac[n]);
	for (int i=n-1;i>=0;--i)
		ifac[i]=ifac[i+1]*(i+1)%mo;
}
ll inv(int n){return ifac[n]*fac[n-1]%mo;}
ll C(int m,int n){
	if (m<n) return 0;
	return fac[m]*ifac[n]%mo*ifac[m-n]%mo;
}
int n,K;
char str[N];
int p[N],m;
ll ans;
bool judge(){
	static int q[N],need[N];
	static int used[N];
	int head=1,tail=0;
	memset(used,255,sizeof(int)*(K+1));
	int i=1,j=1;
	for (;j<=K && i<=m && p[i]>1;++j){
		if (head<=tail && str[j]=='b')
			used[j]=p[i++]-2,used[q[head++]]=0;
		else if (str[j]=='r')
			q[++tail]=j;
	}
	if (i<=m && p[i]>1) return 0;
	for (;j<=K;++j)
		if (str[j]=='r')
			q[++tail]=j;
	for (;i<=m;++i){
		if (head>tail) return 0;
		used[q[head++]]=0;
	}
	int cnt=0;
	for (int j=K;j>=1;--j){
		if (used[j]==-1)
			cnt++;
		else if (used[j]>0){
			if (cnt<used[j]) return 0;
			cnt-=used[j];
		}
	}
	return 1;
}
ll calc(){
//	for (int i=1;i<=m;++i)
//		printf("%d ",p[i]);
//	printf("\n");
	if (m==0) return 1;
	p[m+1]=-1;
	ll s=fac[m];
	for (int i=1,j=0;i<=m;++i){
		j++;
		if (p[i]!=p[i+1]){
			s=s*ifac[j]%mo;
			j=0;
		}
	}
	ll c0=2,c1=m-1;
	for (int i=1;i<=m;++i){
		if (p[i]==1)
			c1++;
		else{
			c1+=2*p[i]-3;
			c0+=2;
		}
	}
	s=s*C((n-c1)+(c1+c0)-1,n-c1)%mo;
//	printf("ans=%lld\n",s);
	return s;
}
void dfs(int s,int k){
	if (judge())
		ans+=calc();
	if (s==0)
		return;
	for (int i=k;i>=1;--i){
		if (s>=2*i-1+(s!=n)){
			p[++m]=i+1;
			dfs(s-(2*i-1)-(s!=n),i);
			--m;
		}
	}
	if (s>=1+(s!=n)){
		p[++m]=1;
		dfs(s-1-(s!=n),0);
		--m;
	}
}
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d%s",&n,&K,str+1);
	initC(n*4);
	dfs(n,n);
	ans%=mo;
	printf("%lld\n",ans);
	return 0;
}
















Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int ans[4][4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a[4][4];
    rep(i,3)rep(j,3)cin>>a[i][j];
    int n;
    cin>>n;
    vector<int>b(n);
    rep(i,n)cin>>b[i];

    rep(i,n){
        rep(j,3)rep(k,3){
            if(a[j][k] == b[i]){
                ans[j][k] = 1;
            }
        }
    }

    bool flag = false;
    if(ans[0][0] && ans[1][1] && ans[2][2])flag = true;
    if(ans[2][0] && ans[1][1] && ans[0][2])flag = true;
    rep(i,3){
        if(ans[i][0] && ans[i][1] && ans[i][2])flag = true;
        if(ans[0][i] && ans[1][i] && ans[2][i])flag = true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define PB push_back
#define MP make_pair

using namespace std;

typedef int64_t ll;
typedef pair<ll, int> pli;

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

const ll linf = 1LL << 60;
const ll INF = linf;


using G = vector<vector<int>>;
G g;
int n, m, start, goal;
vector<ll> d;

template <class Tdist>
void Dijkstra(int org, const G& g, vector<Tdist>& d);

void init()
{
	cin >> n >> m;
	n *= 3;
	g.resize(n);

	REP(_i, m)
	{
		int a, b;
		cin >> a >> b; --a; --b;
		a *= 3; b *= 3;

		g[a    ].PB(b + 1);
		g[a + 1].PB(b + 2);
		g[a + 2].PB(b);
	}

	cin >> start >> goal; --start; --goal;
	start *= 3; goal *= 3;
}

int main()
{
	init();
	Dijkstra(start, g, d);

	if (d[goal] == INF)
		cout << -1 << endl;
	else
		cout << d[goal] / 3 << endl;
}

template <class Tdist>
void Dijkstra(int org, const G& g, vector<Tdist>& d)
{
	using P = pair<Tdist, int>;

	vector<bool> done(n, false);
	d.assign(n, INF);
	d[org] = 0;

	priority_queue<P, vector<P>, greater<P>> que;
	que.push(MP((Tdist)0, org));

	while (!que.empty())
	{
		Tdist c = que.top().first;
		int v = que.top().second;
		que.pop();
		done[v] = true;

		for (auto u : g[v])
			if (!done[u] && chmin(d[u], c + 1))
				que.push(P(d[u], u));
	}
}

Measured memory_bytes: 19072
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    string t; cin >> t;

    
    vector<vector<lint>> dp(s.length()+1, vector<lint>(t.length()+1));
    vector<string> mem(t.length()+1, "");

    REP(i, t.length()+1) {
      dp[0][i] = 0;
    }

    FOR(i, 1, s.length()+1)  {
      vector<string> mem2(t.length()+1);
      FOR(j, 0, t.length()+1) {
        if(j == 0) {
          dp[i][j] = 0;
          mem2[j] = "";
          continue;
        }

        if(s[i-1] == t[j-1]) {
          if(dp[i-1][j-1] + 1 < dp[i-1][j]) {
            if(dp[i-1][j] < dp[i][j-1]) {
              dp[i][j] = dp[i][j-1];
              mem2[j] = mem2[j-1];
            } else {
              dp[i][j] = dp[i-1][j];
              mem2[j] = mem[j];
            }
          } else {
            dp[i][j] = dp[i-1][j-1] + 1;
            mem2[j] = mem[j-1] + t[j-1];
          }
        } else {
          if(dp[i-1][j] < dp[i][j-1]) {
            dp[i][j] = dp[i][j-1];
            mem2[j] = mem2[j-1];
          } else {
            dp[i][j] = dp[i-1][j];
            mem2[j] = mem[j];
          }
        }

        //        cout << i << " " << j << " " << dp[i][j] << "\n";
      }
      mem = mem2;
    }

    PRINT(mem[t.length()]);

    return 0;
}


Measured memory_bytes: 87252