akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------

bool b[10000000];
int cnfa[1000000];

int main(){
  int H,N;
  cin >> H >> N;
  int sum = 0;
  rep(i,N){
    int a;
    cin >> a;
    sum+=a;
  }
  bool f = true;
  if(sum < H) f=false;
  cans(f);

  
  return 0;
}




Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	int A = 0;
	int B = 0;
	int C = 0;
	int X = 0;
	int count = 0;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		A =sc.nextInt();
		B =sc.nextInt();
		C =sc.nextInt();
		X =sc.nextInt();
		for(int i = 0; i <= A; i++) {
			for(int j = 0; j <= B; j++) {
				for(int k = 0; k <= C; k++) {
					if(i * 500 + j * 100 + k * 50 == X) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

Measured memory_bytes: 23636
N, M = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = list(map(int, input().split()))

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    
    for s in d:
      count += switch_states[s-1]
      
    if count % 2 != P[di]:
      ans -= 1
      break

  ans += 1
        
        
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <map>

using namespace std;

int solve(){
    int year,month, day;
    vector<string> reiwa;
    cin>>year>>month>>day;
    if(year > 31){
        // reiwa.push_back("?");
        // reiwa.push_back(sprintf(year-30));
        cout<<"? "<<year-30<< " "<<month<<" "<<day<<endl;
            return 0;
    }else if(year == 31){
        if(month >= 5){
            // reiwa.push_back("?");
            // string s = (string)(year-30);
            // reiwa.push_back(sprintf(year-30));
            cout<<"? "<<year-30<< " "<<month<<" "<<day<<endl;
            return 0;
        }
        else {
            // reiwa.push_back("HEISEI");
            // reiwa.push_back(sprintf(year));
            cout<<"HEISEI "<<year<< " "<<month<<" "<<day<<endl;
            return 0;
        }
    }else{
        //  reiwa.push_back("HEISEI");
        //  reiwa.push_back(sprintf(year));
        cout<<"HEISEI "<<year<< " "<<month<<" "<<day<<endl;
        return 0;
    }
    // reiwa.push_back(sprintf(month));
    // reiwa.push_back(sprintf(day));
    // return reiwa;
}

int main(){
    string heisei;
    vector<vector<string>> ans;
    while(1){
        cin>>heisei;
        if(heisei == "#")break;
        // ans.push_back(solve());
        solve();
    }

    // for(int i = 0;i < ans.size(); i++){
    //     cout<<ans[i][0] << " "<<ans[i][1] << " "<<ans[i][2] <<" "<<ans[i][3]<<endl;
    // }
}


Measured memory_bytes: 3116
# Aizu Problem 00126: Puzzle
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def check_puzzle(puzzle):
    marker = [[' ' for _ in range(9)] for __ in range(9)]
    # check rows:
    for r in range(9):
        row = puzzle[r]
        for k in range(1, 10):
            if row.count(k) != 1:
                for idx in [j for j in range(9) if row[j] == k]:
                    marker[r][idx] = '*'
    # check columns:
    for c in range(9):
        col = [puzzle[r][c] for r in range(9)]
        for k in range(1, 10):
            if col.count(k) != 1:
                for idx in [j for j in range(9) if col[j] == k]:
                    marker[idx][c] = '*'
    # check sub-squares:
    for rs in range(3):
        for rc in range(3):
            square = puzzle[3*rs][3*rc:3*rc+3] + puzzle[3*rs+1][3*rc:3*rc+3] + \
                     puzzle[3*rs+2][3*rc:3*rc+3]
            for k in range(1, 10):
                if square.count(k) != 1:
                    for idx in [j for j in range(9) if square[j] == k]:
                        ridx = 3 * rs + idx // 3
                        cidx = 3 * rc + idx % 3
                        marker[ridx][cidx] = '*'
            
    return marker


first = True
N = int(input())
for n in range(N):
    puzzle = [[int(_) for _ in input().split()] for __ in range(9)]
    marker = check_puzzle(puzzle)
    if first:
        first = False
    else:
        print()
    for k in range(9):
        out = ''.join([marker[k][j] + str(puzzle[k][j]) for j in range(9)])
        print(out)

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int p[n];
    int newnum;
    for(int i=0; i<n; i++){
        cin >> newnum;
        p[i] = newnum - i - 1;
    }

    int res = 0;

    int pointer = 0;
    while(pointer < n){
        if(p[pointer] == 0){
            res += 1;
            pointer += 2;
        }else{
            pointer ++;
        }
    }

    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join(
            '{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
print(uf.group_count()-1)

Measured memory_bytes: 75532
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	string s;
	cin>>s;
	if(s[s.length()-1]=='s')
		cout<<s+"es";
	else
		cout<<s+"s";
	return 0;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
 
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
 
int main(){
    ll x=0,y=0,d=0,n,h,w,k,max=-100000,min=100000000000000,ans=0,count=0,sum=0;
    string s;
    cin >> n;
    vector<ll> a;
    a = divisor(n);
    //operator << (cout,a);
    for(int i=0;i<a.size()/2+1;i++){
        if(min > a[i]-1 + (n/a[i])-1){
            min = a[i]-1 + (n/a[i])-1;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 384
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 cnt = 0;
		
		for(int i=a ; i<=b ; i++) {
			if( check(String.valueOf(i)) ) {
				cnt++;
			}
		}
		System.out.print(cnt);
	}

	public static boolean check(String sen) {
        int minIdx = 0;
        int maxIdx = sen.length() - 1;
 
        while(minIdx < maxIdx) {
            if(sen.charAt(minIdx++) != sen.charAt(maxIdx--)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 28756
#define LL long long
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	LL N,a;
	cin>>N;
	vector<long long int> v;
	for(int i=N;i>0;i--){
		cin>>a;
		v.push_back(a);
	}

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

	cout<<v[N-1]-v[0]<<endl;
	return 0;
}

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

int main(){
  int Q;
  cin>>Q;
 long long l,r;
int a[100001],c[100001];
  for(int i=2;i<100001;i++){
    a[i]=0;
  }
    for(int i=2;i<100001;i++){
    a[i]=0;
  }
  for(int i=2;i<100001;i++){
    if(a[i]==0){
    for(int j=i*2;j<100001;j+=i){
    a[j]=1;
  }
    }
  }
    c[1]=0;
      for(int i=3;i<100001;i+=2){
    if(a[i]==0&&a[(i+1)/2]==0){
      c[i]=c[i-2]+1;
    }
        else{
          c[i]=c[i-2];
        }
  }
  for(int i=0;i<Q;i++){
    cin>>l>>r;
cout<<c[r]-c[l-2]<<endl;
  }
 }

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n);

    for (ll i=0; i<n; ++i)
        cin >> p[i];

    vector<ll> sub(3);
    ll counter (0);
    for (ll i=1; i<n-1; ++i)
    {
        sub[0] = p[i-1];
        sub[1] = p[i];
        sub[2] = p[i+1];

        ll centre = sub[1]; 

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

        if (centre == sub[1]) counter++;
    }

    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize, mut m: usize,
        a: [u64; n],
    }
    let mut bh = BinaryHeap::new();
    for i in 0..n {
        bh.push(a[i]);
    }

    while m > 0 {
        let mut v = bh.pop().unwrap();
        v /= 2;
        m -= 1;
        bh.push(v);
    }

    let mut ans = 0;
    for _ in 0..n {
        let acc = bh.pop().unwrap();
        ans += acc;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
S = list(input())
rem=len(S)
ans='No'

if rem%2:
    pass
else:
    for i in range(rem//2):
        if S[2*i]=='h' and S[2*i+1]=='i':
            pass
        else:
            break  
    else:
        ans='Yes'
        
print(ans)

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n;
    cin >> n;
    li ju = 1;
    li kyu = 1;
    li hachi = 1;
    rin{
        ju = ju * 10 % MOD;
        kyu = kyu * 9 % MOD;
        hachi = hachi * 8 % MOD;
    }
    cout << (ju - kyu - kyu + hachi + MOD * 2) % MOD << endl;
    return 0;
}


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

int main()
{
    int a, b, t;
    unsigned long long suma = 0, res = 0;
    scanf("%d %d", &a, &b);
    for (int i = 0; i < a; i++) { scanf("%d", &t); suma += t; }
    for (int i = 0; i < b; i++) { scanf("%d", &t); res += suma * t; }
    printf("%llu\n", res);
     return 0;
}


Measured memory_bytes: 2756
// https://kimiyuki.net/writeup/algo/etc/icpc-2016-domestic-d/
// http://tsutaj.hatenablog.com/entry/2017/03/07/173127
#include <bits/stdc++.h>
using namespace std;

int w[300];
bool isOK[301][301];    // isOK[l][r] := [l, r)が取り出し可能かどうか
int DP[301][301];       // DP[l][r] := [l, r)取り出し可能なブロック数

bool isConnected(int i, int j) {
    return abs(w[i] - w[j]) <= 1;
}

bool solve()
{
    int n;
    cin >> n;
    if(n == 0) return false;
    for(int i = 0; i < n; ++i) cin >> w[i];
    memset(isOK, 0, sizeof(isOK));
    memset(DP, 0, sizeof(DP));
    for(int i = 0; i < n; ++i) {
        isOK[i][i] = true;
    }
    for(int len = 2; len <= n; ++len) {
        for(int i = 0; i + len <= n; ++i) {
            // [i, i + len) が取り出し可能か調べる
            if(isOK[i+1][i + len - 1] && isConnected(i, i + len - 1)) {
                isOK[i][i+len] = true;
                continue;
            }

            // [i, i+k) と [i+k, i+len)が取り出し可能なら[i, i+len)も取り出し可能
            for(int k = 0; k <= len; ++k) {
                if(isOK[i][i+k] && isOK[i+k][i+len]) {
                    isOK[i][i+len] = true;
                    break;
                }
            }
        }
    }
    
    for(int left = 0; left < n; ++left) {
        for(int right = left; right <= n; ++right) {
            if(isOK[left][right]) DP[left][right] = right - left;
        }
    }

    for(int left = 0; left <= n; ++left) {
        for(int right = left; right <= n; ++right) {
            for(int k = left; k <= right; ++k) {
                DP[left][right] = max(DP[left][right], DP[left][k] + DP[k][right]);
            }
        }
    }
    cout << DP[0][n] << endl;
    return true;
}

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


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

int main(void) {
	int n, r;

	while(cin >> n >> r, n || r) {
		vector<int> deck;
		
		for(int i = 0; i < n; i++) {
			deck.push_back(n - i);
		}

		for(int j = 0; j < r; j++) {
			int p, c;
			cin >> p >> c;
			vector<int> tmp(deck.begin(), deck.begin() + p);
			for(int k = 0; k < c; k++) {
				deck[k] = deck[p - 1 + k];
			}

			for(int k = c; k < p - 1 + c; k++) {
				deck[k] = tmp[k - c];
			}
		}

		cout << deck[0] << endl;
	}
}

Measured memory_bytes: 1220
import numpy as np
n, W = map(int,input().split())
w = []
v = []
for i in range(n):
    w_,v_= map(int,input().split())
    w.append(w_)
    v.append(v_)
dp = np.zeros(W+1, dtype=np.int64)
for i in range(n):
	dp[w[i]:] = np.maximum(dp[:-w[i]] + v[i], dp[w[i]:])
print(dp[W])

Measured memory_bytes: 29808
/*
 * author: Anuj Sahai
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    private static class Solution {
        void solve() {
            final String s = or.next();
            int maxCount = 0, count = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'R') {
                    count += 1;
                } else {
                    maxCount = Math.max(maxCount, count);
                    count = 0;
                }
            }
            maxCount = Math.max(maxCount, count);
            pw.println(maxCount);
        }

        final PrintWriter pw; // pw.println(...);
        final OpReader or; // or.next...();

        Solution() {
            pw = new PrintWriter(System.out);
            or = new OpReader();
        }

        void tearDown() {
            pw.close();
        }
    }

    private static class OpReader {
        final BufferedReader br;
        StringTokenizer st;

        public OpReader() {
            br = new BufferedReader(new InputStreamReader(System.in), 32 * 1024);
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    }

    public static void main(String[] args) {
        final Solution solution = new Solution();
        solution.solve();
        solution.tearDown();
    }
}


Measured memory_bytes: 32892
N, M = map(int, input().split())

ans = ["_" for _ in range(N)]
change = []
for _ in range(M):
    s_i, c_i = map(int, input().split())
    if s_i not in change:
        ans[s_i - 1] = str(c_i)
        change.append(s_i)
    else:
        if ans[s_i - 1] == str(c_i):
            continue
        else:
            print(-1)
            exit()

new_ans = []
for i, k in enumerate(ans):
    if k == "_":
        if i == 0 and N > 1:
            new_ans.append("1")
        else:
            new_ans.append("0")
    else:
        new_ans.append(k)

if N > 1:
    if new_ans[0] == "0":
        print(-1)
    else:
        print("".join(new_ans))
else:
    print(new_ans[-1])

Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	BigInteger fact(int n) {
		BigInteger bi = BigInteger.ONE;
		for (int i = 2; i <= n; i++) {
			bi = bi.multiply(new BigInteger(String.valueOf(i)));
		}
		return bi;
	}
	
	void run() {
		int n = sc.nextInt();
		BigInteger bi = fact(n+1);
		out.println(bi.add(new BigInteger("2")));
		for (int i = 2; i <= n+1; i++)
			out.println(i);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 26284
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

   vector< vector<int> > arr;
   arr.resize(n-1);
   for (int i=0; i<n-1; i++) {
      arr[i].resize(3);
      for (int j=0; j<3; j++) {
         scanf("%d", &arr[i][j]);
      }
   }

   for (int i=0; i<n; i++) {
      int t = 0;
      for (int j=i; j<n-1; j++) {
         if (t<arr[j][1]) t=arr[j][1];
         else if (t%arr[j][2] == 0);
         else t = t + arr[j][2] - t % arr[j][2];
         t += arr[j][0];
      }
      printf("%d\n", t);
   }

   return 0;

}


Measured memory_bytes: 256
(N, M), *SCs = readlines.map{|l| l.split.map(&:to_i)}

x = Array.new(N, nil)
SCs.each do |s, c|
  s -= 1
  case x[s]
  when nil, c
    x[s] = c
  else
    puts -1
    exit
  end
end
if N >= 2
  case x[0]
  when nil
    x[0] = 1
  when 0
    puts -1
    exit
  end
end
N.times{|i| x[i] = 0 if x[i].nil?}
puts x.join

Measured memory_bytes: 1788
N, M, X = map(int, input().split())

C = [0] * N
A = [[] for _ in range(N)]

for i in range(N):
    t = [int(x) for x in input().split()]
    C[i] = t[0]
    A[i] = t[1:]

ans = float("inf")
for bit in range(2**N):
    score = [0] * M
    cost = 0
    for i in range(N):
        if (bit >> i) & 1:
            cost += C[i]
            for j in range(M):
                score[j] += A[i][j]

    is_ok = True
    for i in range(M):
        if score[i] < X:
            is_ok = False

    if is_ok:
        ans = min(ans, cost)

print(-1 if ans == float("inf") else ans)


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
bool color[505][505], visited[505][505];
int ans[505][505];

int edge;
int DFS(int level, int now){
  if (visited[level][now]) return 0;
  visited[level][now] = true;
  for (int i = now + 1; i < N; i++){
    if (ans[now][i] > 0) continue;
    if (color[level][now]) color[level][i] = false;
    else color[level][i] = true;
    DFS(level, i);
    return 0;
  }

  for (int i = edge; i < N; i++){
    if (visited[level][i]) {
      edge++; continue;
    }

    DFS(level, edge);
  }
  
  return 0;
}

int Solve(int level){
  vector <int> Black, White;
  for (int i = 0; i < N; i++){
    if (!visited[level][i]) continue;
    if (color[level][i]) Black.push_back(i);
    else White.push_back(i);
  }

  for (int i = 0; i < Black.size(); i++){
    for (int j = 0; j < White.size(); j++){
      int B = Black[i], W = White[j];
      if (B > W) swap(B, W);
      if (ans[B][W] == 0) ans[B][W] = level;
    }
  }
  return 0;
}

int main(){
  cin >> N;

  int start = 0;
  for (int level = 1; level <= N; level++){
    bool flag = true;
    for (int i = start; i < N; i++){
      edge = i;
      for (int j = i + 1; j < N; j++){
        if (ans[i][j] == 0) flag = false;
      }
      if (flag) {
        start++; continue;
      }
      DFS(level, i); Solve(level);
      break;
    }
  }


  for (int i = 0; i < N - 1; i++){
    cout << ans[i][i+1];
    for (int j = i + 2; j < N; j++){
      cout << " " << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 4600
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    Int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) {
        println(s);
    } else {
        rep(i, k) cout << s[i];
        println("...");
    }

    return 0;
}


Measured memory_bytes: 3632
o = list(input())
e = list(input())
j = 0
k = 0
ans = ""
for i in range(0, len(o) + len(e)):
    if i%2 == 0:
        ans += o[j]
        j += 1
    else:
        ans += e[k]
        k += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

string S;

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

  if (S.size() == 2) {
    cout << S << endl;
  } else {
    reverse(S.begin(), S.end());
    cout << S << endl;
  }

  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
using namespace std;
int main()
{
  ll a,b;
  cin>>a>>b;
  if(a>=13)
  cout<<b;
  else if(a>=6&&a<=12)
  cout<<b/2;
  else
  cout<<"0";	
	
	
	
	
	
 return 0;
}

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int cnt = 0;
  cnt = n / x;
  if (n%x != 0) cnt++;  
  int ans = cnt * t;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

const ll MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll mx = max(x, y);
    ll mn = min(x, y);
    if (mx / 2 > mn) {
        cout << 0 << endl;
        return 0;
    }
    if (mx / 2 == mn) {
        cout << 1 << endl;
        return 0;
    }
    ll x2 = 0;
    ll y2 = 0;
    while (x2 - x != -(y2 - y)) {
        x2 += 2;
        y2 += 1;
    }
    cominit();
    cout << com(y2, x2 - x) << endl;
    return 0;
}


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

int qai[101000], n, t;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		qai[t] = i + 1;
	}

	for (int j = 1; j <= n; j++)
		cout << qai[j] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1152
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;

//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,a,b;
		cin>>n>>a>>b;
		cout<<min(n*a,b);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	bitset<45> b[100010];
	int n;
	long long k;
	cin >> n >> k;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		ans += a;
		b[i] = (a);
	}
	long long t = 1;
	long long sum[100] = { 0 };
	for (int i = 0; i <= 40; i++) {
		for (int j = 0; j < n; j++) {
			if (b[j][i]) {
				sum[i] -= t;
			}
			else {
				sum[i] += t;
			}
		}
		t *= 2;
	}
	for (int i = 0; i <= 40; i++) {
		if (sum[i] < 0) {
			sum[i] = 0;
		}
	}
	t /= 2;
	long long co = 0, co1 = 0;
	long long ma = 0;
	for (int i = 40; i >= 0; i--) {
		if (t <= k) {
			if (sum[i] > ma) {
				ma = sum[i];
			}
		}
		if (co + t <= k) {
			co += t;
			if (co1 + sum[i] > ma) {
				ma = co1 + sum[i];
			}
			long long co2 = 0;
			for (int j = i - 1; j >= 0; j--) {
				co2 += sum[j];
			}
			if (co1 + co2 > ma) {
				ma = co1 + co2;
			}
			co1 += sum[i];
		}
		t /= 2;
	}
	cout << ans + ma << endl;
	return 0;
}


Measured memory_bytes: 4396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static int[] dx = new int[] { -1, 0, 1, 0, -1, -1, 1, 1 };
	static int[] dy = new int[] { 0, 1, 0, -1, -1, 1, -1, 1 };
	static int A, B, C;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		int[] arr = new int[3];
		arr[0] = a;
		arr[1] = b;
		arr[2] = c;
		String[] str = new String[n];
		for (int i = 0; i < str.length; i++) {
			str[i] = br.readLine();
		}
		boolean f = true;
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			String s = str[i];
			int id1 = s.charAt(0) - 'A';
			int id2 = s.charAt(1) - 'A';
			if (arr[id1] == 0 && arr[id2] == 0) {
				f = false;
			} else if (arr[id1] == 1 && arr[id2] == 1 && i != n - 1) {
				String t = str[i + 1];
				int x = t.charAt(0) - 'A';
				int y = t.charAt(1) - 'A';
				if (id1 == x || id1 == y) {
					arr[id1]++;
					arr[id2]--;
					ans[i] = id1;
				} else {
					arr[id1]--;
					arr[id2]++;
					ans[i] = id2;
				}
			} else if (arr[id1] > arr[id2]) {
				arr[id1]--;
				arr[id2]++;
				ans[i] = id2;
			} else {
				arr[id1]++;
				arr[id2]--;
				ans[i] = id1;
			}
		}
		if (f) {
			pw.println("Yes");
			for (int i = 0; i < ans.length; i++) {
				pw.println((char) ('A' + ans[i]));
			}
		} else
			pw.println("No");
		pw.flush();
	}

}


Measured memory_bytes: 42804
#include <stdio.h>
#define NUM 200


int main(void){
	int yoko;
	int i=0, j=0 ,r=0;
	int v[3][NUM] ;
	int sum[NUM] = { 0 };
	int max=0;

	scanf("%d",&yoko);
	//printf("%d\n", yoko);

	for (i = 1;i <= 2;i++) {
		for (j = 1;j <= yoko;j++) {
			scanf("%d", &v[i][j]);
		}
	}

	for (r = 1;r <= yoko;r++) {
		for (i = 1;i <=r;i++) {
			sum[r] += v[1][i];
		}
		for (j = r;j <= yoko;j++) {
			sum[r] += v[2][j];
		}
		//printf("sum[%d]=%d\n", r, sum[r]);
		if (max < sum[r])
			max = sum[r];
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n, w, a[N], b[N], dp[101][N];

void solve()
{
    cin >> n >> w;
    for (int i=1; i<=n; i++) cin >> a[i] >> b[i];

    for (int i=1; i<=w; i++) {
        for (int j=1; j<=n; j++) {
            dp[j][i] = dp[j-1][i];
            if (i>=a[j]) {
                dp[j][i] = max(dp[j][i], dp[j-1][i-a[j]] + b[j]);
            }
        }
    }nout(dp[n][w]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}   

Measured memory_bytes: 81768
H, W = map(int,input().split())
a=[]
N2=0
for i in range(H):
    b=[int(i) for i in input().split()]
    for j in range(W):
        if b[j]%2==1:
            N2+=1
    a.append(b)
if N2%2==1:
    N2-=1
N=0
N3=0
idou=1
if W==1:
    idou=2
c=0
i=0
j=0
s=[]
for k in range(H*W):
    if N3==N2:
        break
    if idou==1:
        if a[i][j]%2==1:
            N+=1
            s.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j+2))
            a[i][j+1]+=1
            a[i][j]-=1
            if a[i][j+1]%2==0:
                N3+=2
        j+=1
        if j==W-1-c:
            idou=2
    elif idou==2:
        if a[i][j]%2==1:
            N+=1
            s.append(str(i+1)+" "+str(j+1)+" "+str(i+2)+" "+str(j+1))
            a[i+1][j]+=1
            a[i][j]-=1
            if a[i+1][j]%2==0:
                N3+=2
        i+=1
        if i==H-1-c:
            idou=3
    elif idou==3:
        if a[i][j]%2==1:
            N+=1
            s.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j))
            a[i][j-1]+=1
            a[i][j]-=1
            if a[i][j-1]%2==0:
                N3+=2
        j-=1
        if j==c:
            idou=4
    elif idou==4:
        if a[i][j]%2==1:
            N+=1
            s.append(str(i+1)+" "+str(j+1)+" "+str(i)+" "+str(j+1))
            a[i-1][j]+=1
            a[i][j]-=1
            if a[i-1][j]%2==0:
                N3+=2
        i-=1
        if i==c+1:
            idou=1
            c+=1
print(N)
for i in range(N):
    print(s[i])


Measured memory_bytes: 16372
#!/usr/bin/env python3
S = input()[::-1]

mod = [0]*2019
mod[0] = 1
ten = 1
index = 0
for s in S:
    index += ten*int(s)
    index %= 2019
    mod[index] += 1
    ten *= 10
    ten %= 2019

ans = 0
for m in mod:
    ans += m * (m-1) // 2

print(ans)


Measured memory_bytes: 68692
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#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> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli a, b, c, d;
	cin >> a >> b >> c >> d;
	lli a1 = max(a * c, a * d);
	lli a2 = max(b * c, b * d);
	cout << max(a1, a2) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 3648
[A, B, C] = list(map(int, input().split()))

def main(A, B, C):

    if A == B:
        if not A == C:
            return "Yes"

    if A == C:
        if not A == B:
            return "Yes"

    if B == C:
        if not A == B:
            return "Yes"
    
    return "No"

if __name__ == "__main__":

    answer = main(A, B, C)
    print(answer)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
    lli n,k;
    cin>>n>>k;
    set<lli>s;
    while(k--)
    {
        lli d;
        cin>>d;
        lli x;
        for(lli i=0;i<d;i++)
        {
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size()<<endl;
}

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

using namespace std;

int N, x;

int main ()
{
scanf ("%d %d", &N, &x);
if (x == 1 || x == 2 * N - 1)
{
    printf ("No\n");
    return 0;
}
printf ("Yes\n");
int j = 0;
for (int i=1; i<2 * N; i++)
    if (i < N - 1 || i > N + 1)
    {
        j ++;
        while (x - 1 <= j && j <= x + 1) j ++;
        printf ("%d\n", j);
    }
    else printf ("%d\n", x + i - N);
return 0;
}


Measured memory_bytes: 1536
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let p: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    // 各インデックスの順位をもとにa, bの前項との差分を定める
    let q = p.iter()
        .enumerate()
        .map(|(i, &x)| (x - 1, i as i64))
        .collect::<std::collections::HashMap<_, _>>();
    let ans = {
        let mut a = vec![0; N];
        let mut b = vec![0; N];
        a[0] = 500_000_000;
        b[0] = 500_000_000;
        for i in 1..N {
            let d = q.get(&i).unwrap() - q.get(&(i - 1)).unwrap();
            a[i] = if d > 0 {
                a[i - 1] + d + 1
            } else {
                a[i - 1] + 1
            };
            b[i] = if d > 0 {
                b[i - 1] - 1
            } else {
                b[i - 1] + d - 1
            };
        }
        format!(
            "{}\n{}",
            a.iter()
                .map(std::string::ToString::to_string)
                .collect::<Vec<_>>()
                .join(" "),
            b.iter()
                .map(std::string::ToString::to_string)
                .collect::<Vec<_>>()
                .join(" ")
        )
    };

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


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

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

    rep(i, n) {
        char s;
        cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

k = ni()

luns = []


def make_lunlun(l):
    if l > 3234566667:
        return
    luns.append(l)

    last = l-l//10*10

    if last!=0:
        make_lunlun(l*10 + last-1)
    make_lunlun(l*10+last)
    if last!=9:
        make_lunlun(l*10 + last+1)


for i in range(1,10):
    make_lunlun(i)

print(sorted(luns)[k-1])

Measured memory_bytes: 8404
#include <stdio.h>

int main(){
  int n;
  int p[20];
  int out=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
	scanf("%d ",&p[i]);
  }
  for(int i=1;i<n-1;i++)
  	if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))
      out++;
  printf("%d\n",out);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
flg = True
cnt = 0
total = 0

while flg:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
            cnt += 1
    if cnt == N:
        total += 1
    else:
        flg = False
    cnt = 0
print(total)
    


Measured memory_bytes: 3060
// シンプルにする2つ目
// 高階関数を利用
// これはまだ早いかもなぁ

fun main (args:Array<String>){
    val (a , b , c , k) = readLine()!!.split(" ").map(String::toLong)

    val sumCount = fun(lastSelectCount: Long, sumNum: Long): (cardCount: Long, cardNum: Long) -> Long {
        var lastSelectCount = lastSelectCount
        var sumNum = sumNum
        return fun(cardCount: Long, cardNum: Long): Long {
            if (cardCount < lastSelectCount) {
                lastSelectCount -= cardCount
                sumNum += cardCount * cardNum
            } else {
                sumNum += lastSelectCount * cardNum
                lastSelectCount = 0
            }
            return sumNum
        }
    }

    val calc = sumCount(k, 0)
    calc(a, 1)
    calc(b, 0)
    print(calc(c, -1))
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vi L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    sort(all(L));
    ll res=0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            int it1=upper_bound(all(L), L[j]-L[i])-L.begin();
            it1=max(it1, j+1);
            int it2=lower_bound(all(L), L[j]+L[i])-L.begin();
            res+=it2-it1;
        }
    }
    cout << res << endl;
    return 0;
}

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

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

	int ans = 0;
	int i = 1;
	int x; cin >> x;
	while (ans + i <= x) {
		ans += i;
		i++;
	}
	if (ans == x) {
		cout << i-1;
		return 0;
	}
	cout << i;
}

Measured memory_bytes: 256
# N回だけトレーニングする
import numpy as np
N = int(input())

# パワー
power = 1

# i回目のトレーニングを終えるとパワーが
# i倍されます。
# 答えの値は非常に大きな値になることがあるので
# 10**9+7で割ったあまりを出力

for i in range(1, N + 1):
    power = np.mod(i * power, 10 ** 9 + 7)
print(power)


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

using namespace std;

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int n = -1;
	cin >> n;
	assert(n >= 1 && n <= 100);
	string s = "";
	cin >> s;
	assert(s.size() == n);
	int m = n / 2;
	string ans = "No";
	if (m + m == n && s.substr(0, m) == s.substr(m, m))
	{
		ans = "Yes";
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256