akhauriyash/Code-Regression huggingface dataset:
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) /@ (fun _ -> (cnv % read_line) ())

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let n = scan "%d" identity
let s = scan_listn n identity

module SMap = Map.Make (struct
    type t = string
    let compare = String.IString.compare
  end)

let () =
  let map = fold (fun m k -> SMap.modify_def 0 k succ m) SMap.empty s in
  let m = SMap.fold (fun _ v m -> if v > m then v else m) map 0 in
  SMap.filter (fun _ n -> n = m) map
  |> List.of_enum % SMap.keys
  |> String.concat "\n" % List.sort String.compare
  |> printf "%s\n"


Measured memory_bytes: 35944
#include<cstdio>
#include<cmath>
#include<algorithm>


using namespace std;

int main(void){
    int n;
    while(scanf("%d", &n),n){
        int dp[64] ={0};
        dp[0] = 1;
        for(int i = 0; i <= n; i++){
            for(int j = 1; j < 4; j++){
                if(i - j >= 0){
                    dp[i] += dp[i-j];
                }
            }
        }
        printf("%d\n", dp[n]/3650 + 1);


    }

    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>

using namespace std;

int main(int argc, char *argv[])
{
  int H,W;
  while(scanf("%d %d",&H,&W)!= EOF){
    if(H ==0&&W == 0)
      break;
  for(int i= 0;i < H;i++){
    for(int j = 0;j < W;j++){
      if(i%2==0){
	if(j%2 ==0)
	  cout <<"#";
	else
	  cout<<".";
      }
      else if(i%2 !=0){
	if(j%2 !=0)
	  cout <<"#";
	else
	  cout<<".";
      }
    }
    cout <<endl;
  }
  cout <<endl;
  }
  return 0;
  }

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		 int n = readInt(r);
		 int[] s = strAryToIntAry(r.readLine().split(" "));
		 int q = readInt(r);
		 int[] t = strAryToIntAry(r.readLine().split(" "));

		 System.out.println(serach(n,s,q,t));

	}

	public static int readInt(BufferedReader r) throws Exception{
        return Integer.parseInt(r.readLine());
    }

	public static int[] strAryToIntAry(String[] strAry){
		int arraySize = strAry.length;
		int[] intAry= new int[arraySize + 1];
		for(int i = 0 ; i < arraySize ; i++){
			intAry[i] =Integer.parseInt(strAry[i]);
		}

		return intAry;
	}

	public static int serach(int n, int[] s,int q,int[] t){

		int key;
		int sum = 0;

		for(int i = 0 ; i < q ;i++){
			key = t[i];
			s[s.length -1] = key;
			if(keySerach(key, s)) sum++;
		}
		return sum;
	}

	public static boolean keySerach(int key,int[] s){
		int i = 0;
		while(key != s[i]) i++;
		return i != s.length -1;
	}

}

Measured memory_bytes: 27196
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const S = tmp[0];
    const T = tmp[1];

    let count = 0;
    for (let i = 0; i < S.length; i++) {
        if (S[i] !== T[i]) {
            count += 1;
        }
    }
    console.log(count);

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32944
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

int process(int v, int limit)
{
	int need = 0;
	while (v < limit)
	{
		v *= 2;
		need++;
	}

	return need;
}

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

	int N, K;
	cin >> N >> K;

	double result = 0.0;
	for (int i = 1; i <= N; i++)
	{
		int need = process(i, K);
		double left_prob = 1.0;
		for (int i = 1; i <= need; i++)
		{
			left_prob *= (1.0 / 2.0);
		}

		result += ((1.0 / N) * left_prob);
	}

	cout.setf(ios::fixed);
	cout.precision(9);
	cout << result;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(ll hh=f;hh<n+f;hh++)cin>>a[hh];
#define printdecimal(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX
#define fileio freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}


signed main()
{
    fastio;
    //fileio;
	ll n,i;
	cin>>n;
	inp(a,n,0);
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
}

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

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

vector<vector<int>> g(100100);
bool visited[100100];

void dfs(int cur, vector<int>& ans) {
    visited[cur] = true;
    for (int v: g[cur]) {
        if (!visited[v]) {
            ans.push_back(v);
            dfs(v, ans);
            break;
        }
    }
    return ;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans;
    dfs(0, ans);
    reverse(ans.begin(), ans.end());
    ans.push_back(0);
    dfs(0, ans);
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++) {
        printf("%d ", ans[i] + 1);
    }
    printf("\n");
    
    
    
    return 0;
}

Measured memory_bytes: 9720
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>
 
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>
 
#define cauto const auto&
#else
 
#endif
 
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
 
template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}
 
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
 
#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

ll solve(ll N, vint a, vint b) {
    vll dp(N+1, 0);
    vint c;
    vint d;
    rep(i, 3){
        if(b[i]-a[i]>0){
            c.PB(b[i]-a[i]);
            d.PB(a[i]);
        }
    }
    rep(i, N) {
        rep(j, c.size()) {
            if(i+d[j]<=N) maxs(dp[i+d[j]], dp[i]+c[j]);
        }
    }
    ll ans = 0;
    rep(i, N+1) maxs(ans, dp[i]);
    return N+ans;
}

int main() {
    ll N;
    cin >> N;
    vvint vv;
    initvv(vv, 2, 3);
    rep(i, 2) rep(j, 3) cin >> vv[i][j];
    N = solve(N, vv[0], vv[1]);
    N = solve(N, vv[1], vv[0]);
    cout << N << endl;
}

Measured memory_bytes: 195584
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, N, add;

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

  cin >> N;
  rrep(i, 1, N + 1) {
    a = i;
    d = i;
    n = N / a;
    add = 2 * a + (n - 1) * d;
    add *= n;
    add /= 2;
    ans += add;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3600
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, ipti().split()))
    node_next = [set() for _ in range(n)]

    for i in range(m):
        u, v = list(map(int, ipti().split()))
        node_next[u - 1].add(v - 1)

    s, t = list(map(int, ipti().split()))
    s, t = s - 1, t - 1

    dist = [[INF] * n for _ in range(3)]
    dist[0][s] = 0

    que = deque()
    que.append((0, s))

    while que:
        cstate, cnode = que.popleft()
        d = dist[cstate][cnode]
        nstate = (cstate + 1) % 3
        for nnode in node_next[cnode]:
            if dist[nstate][nnode] == INF:
                dist[nstate][nnode] = d + 1
                que.append((nstate, nnode))

    if dist[0][t] != INF:
        print(dist[0][t] // 3)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41488
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;

typedef complex<double> P;

const double pi = acos(-1);

int N, M;
P Ps[40];
double T[40][40][40];
double D[40][40][40];

double cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }
double getArea(P a, P b, P c) { return cross(b-a, c-b)/2.0; }

void make() {
  for(int a = 0; a < N; ++a) {
    for(int b = a+1; b < N; ++b) {
      for(int c = b+1; c < N; ++c) {
	T[a][b][c] = getArea(Ps[a], Ps[b], Ps[c]);
      }
    }
  }
}

double solve() {
  make();
  double res = 0;
  fill(D[0][0], D[40][0], 0);
  for(int k = 2; k < M; ++k) {
    for(int i = 0; i < N; ++i) {
      for(int j = i+1; j < N; ++j) {
	for(int t = i+1; t < j; ++t) {
	  D[k+1][i][t] = max(D[k+1][i][t], D[k][i][j]+T[i][t][j]);
	  if(k+1 == M) res = max(res, D[k+1][i][t]);
	}
      }
    }
  }
  return res;
}

int main() {
  while(cin >> N >> M && (N | M)) {
    for(int i = 0; i < N; ++i) {
      double d;
      cin >> d;
      double rad = 2.0*pi*d;
      Ps[i] = P(cos(rad), sin(rad));
    }
    printf("%.6f\n", solve());
  }
  return 0;
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main(){

    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    
    ll cnt{}, l{}, r{}, min_num{}, ans{};
    cnt = abs(X/D);

    if(cnt>K){
//        cout << "called"s << endl;
        ans = abs(X - K*D);
    }
    else{
        l = abs(X - D*(cnt+1));
        r = abs(X - D*cnt);
        min_num = min(l, r);
        
        bool lflg = false;
        if(min_num == l) lflg = true;
        else lflg = false;

        ll cnt_dif{};
        if(lflg == true) cnt_dif = K - (cnt+1);
        else cnt_dif = K - cnt;

        if(cnt_dif%2 == 0) ans = min_num;
        else{
            if(lflg == true) ans = r;
            else ans = l;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! (n: usize);
    let s = match n % 10 {
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => "hon"
    };
    println!("{}", s);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
/*
int grundy(int a, int k){
	vi v(1);
	for(int l = 0, r = k, i = 1; ;l += k, r += k, i++){
		if(l <= a && a < r) return v[(a - l) % i];
		
		vi nv(1, i);
		rep(j, i) nv.pb(v[(k + j) % i]);
		v = nv;
	}
}
*/

int grundy(int n, int k){
	while(1){
		if(n % k == 0) return  n / k;
		if(n < k) return 0;
		int m = n / k + 1;
		while((n - m * 1000) / k == n / k) n -= m * 1000;
		n -= n / k + 1;
	}
}
void test_grundy(){
	
	int k = 1000, n = 100000;
	vi g(n), ng(1);
	for(int i = 1; i < n; i++){
		if(i % 10000 == 0) dbg(i);
		
		ng.pb(grundy(i, k));
		set<int> s;
		rep(j, i / k) if(i > j) s.insert(g[i - j - 1]);
		for(int j = 0; ; j++) if(!s.count(j)){
			g[i] = j;
			break;
		}
		if(g[i] != ng[i]) dbg(i, g[i], ng[i], s);
		assert(g[i] == ng[i]);
	}
	//dbg(g);
	//dbg(ng);
}



int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	//test_grundy(); exit(0);
	
	int n, s = 0; cin >> n;
	rep(i, n){
		int a, k; cin >> a >> k;
		s ^= grundy(a, k);
	}
	cout << (s ? "Takahashi" : "Aoki") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    string S;
    cin >> N >> S;
    
    int ans = 0;
    for(int i = 2; i < N; i++){
        if(S[i-2] == 'A' && S[i-1] == 'B' && S[i] == 'C') ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef pair<int,int>P;
vector<P>vec;
int sum[500000];

int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  int cnt=1;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
      if(s[i]=='0'){
	vec.push_back(P(cnt,0));
      }
      else{
	vec.push_back(P(cnt,1));
      }
      cnt=1;
    }
    else{
      cnt++;
    }
  }
  if(cnt>0){
    if(s[n-1]=='0'){
      vec.push_back(P(cnt,0));
    }
    else{
      vec.push_back(P(cnt,1));
    }
  }

  for(int i=1;i<=vec.size();i++){
    sum[i]=sum[i-1]+vec[i-1].fi;
    //cout<<vec[i-1].fi<<' ';
  }
  for(int i=vec.size()+1;i<vec.size()+k*3;i++){
    sum[i]+=sum[i-1];
  }
  //cout<<endl;
  
  int ans=0;
  for(int i=1;i<=vec.size();i++){
    if(vec[i-1].se==1){
      ans=max(ans,sum[k+(k+1)+i-1]-sum[i-1]);
      //cout<<sum[k+(k+1)+i-1]<<endl;
    }
    else{
      ans=max(ans,sum[k+k+i-1]-sum[i-1]);
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<long long>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<vector<long long>>dp(n, vector<long long>(2, 0));
	dp[0][0] = v[0];
	dp[0][1] = -v[0];
	for (int i = 1; i < n - 1; i++) {
		dp[i][0] = max(dp[i - 1][0] + v[i], dp[i - 1][1] - v[i]);
		dp[i][1] = max(dp[i - 1][0] - v[i], dp[i - 1][1] + v[i]);
	}
	cout << (max(dp[n - 2][0] + v[n - 1], dp[n - 2][1] - v[n - 1])) << endl;
}

Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) (int)s.size()
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
void solve()
{
fastio
ll a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max(max(a*c,a*d),max(b*c,b*d));
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3644
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto S = scanString;
  dchar c;
  long i;
  foreach(_;S){
    if(c==_){
      i++;
      if(i==3)end("Yes");
    }else{
      i=1;
    }
    c=_;
  }
  end("No");
}


Measured memory_bytes: 256
def gcd(a, b):
    while b!= 0:
        a,b = b, a%b
    return a
def lcm(a,b):
    return a*b //(gcd(a, b))

N = int(input())
A = list(map(int, input().split()))
a_lcm = A[0]

mod = 10 ** 9 + 7

for i in range(1,N):
    a_lcm = lcm(a_lcm, A[i])

ans = 0
for i in range(N):
    ans += a_lcm*pow(A[i], mod-2, mod)
print(ans%mod)  

Measured memory_bytes: 43740
#include <bits/stdc++.h>
#define ll long long
#define fast cin.tie(0);cout.tie(0);
#define order ios::sync_with_stdio(0);
using namespace std;
int n,k,c;
string s;
int o[2][200009],sm;
int main()
{
    cin>>n>>k>>c>>s;
    for(int i=0;i<n;i+=c+1)
    {
        while(s[i]=='x'){i++;if(i==n)break;}
        if(i==n)break;
        sm++;
        o[0][i]=1;
    }
    if(sm>k)return 0;
    reverse(s.begin(),s.end());
    for(int i=0;i<n;i+=c+1)
    {
        while(s[i]=='x'){i++;if(i==n)break;}
        if(i==n)break;
        o[1][i]=1;
    }
    reverse(o[1],o[1]+n);/*
    for(int i=0;i<n;i++)cout<<o[0][1];
    for(int i=0;i<n;i++)cout<<o[1][i];*/
    for(int i=0;i<n;i++)
    {
        if(o[0][i]==o[1][i]&&o[0][i]==1)cout<<i+1<<"\n";
    }
}



Measured memory_bytes: 3332
n = int(input())
if n == 1:
    x, y, h = map(int, input().split())
    print(x, y, h)
    exit()
s = [list(map(int, input().split())) for _ in range(n)]
for i in range(101):
    for j in range(101):
        h = -1
        ok = 1
        for t in s:
            if t[2] == 0:
                ok += 1
            elif h == -1:
                h = abs(t[0] - i) + abs(t[1] - j) + t[2]
            else:
                h0 = abs(t[0] - i) + abs(t[1] - j) + t[2]
                if h == h0:
                    ok += 1
        if ok == n:
            for t in s:
                if abs(t[0] - i) + abs(t[1] - j) <= h:
                    if not h == abs(t[0] - i) + abs(t[1] - j) + t[2]:
                        ok = 0
                else:
                    if not t[2] == 0:
                        ok = 0
            if ok == n:
                print(i, j, h)
                exit()

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

int main() {
  int N,M,k;
  k=0;
  cin >>N >>M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  for (int i=0; i<M; i++){
    k = k + vec.at(i);
  }
  if(k>N){
    cout <<"-1" <<endl;
  }
  else{
    cout <<N-k <<endl;
  }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
long long fac[3005],fx[3005],inv[3005];
const int mod=1e9+7;
void init()
{
	fac[0]=fac[1]=1;for(int i=2;i<=3001;++i)fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(int i=2;i<=3001;++i)inv[i]=(mod-mod/i)%mod*inv[mod%i]%mod;
	fx[0]=fx[1]=1;for(int i=2;i<=3001;++i)fx[i]=inv[i]%mod*fx[i-1]%mod;
}
struct node
{
	int l,r;
}p[3005],q[3005];
int a[3005];
char s[3005];
long long dp[3005][3005];
int n,m;
long long C(int n,int m)
{
	return 1ll*fac[n]%mod*fx[m]%mod*fx[n-m]%mod;
}
int main()
{
	init();
	scanf("%d%d",&n,&m);scanf("%s",s);
	for(int i=0;i<n;++i)
	a[i+1]=a[i]+s[i]-'0';
	int cnt=0;
	for(int i=1;i<=m;++i)scanf("%d%d",&p[i].l,&p[i].r);
	for(int i=1;i<=m;i++)
	{
		if(p[i].l==p[i+1].l&&p[i].r<=p[i+1].r){
			continue;
		}
		int j=i+1;
		while(p[i].l<=p[j].l&&p[i].r>=p[j].r&&j<=m)
		{
			++j;
		}
		q[++cnt].l=p[i].l;q[cnt].r=p[i].r;
		i=j-1;
	}m=cnt;
	memset(dp,0,sizeof(dp));
	q[m+1].l=n+1;q[m+1].r=n+1;a[n+1]=a[n];
	dp[1][a[q[1].r]-a[q[1].l-1]]=1;
	for(int i=1;i<=m;++i){
		if(q[i].r<q[i+1].l){
			int tmp=a[q[i+1].r]-a[q[i+1].l-1];
			for(int j=0;j<=q[i].r-q[i].l+1;++j)
			dp[i+1][tmp]=(dp[i+1][tmp]+dp[i][j]*C(q[i].r-q[i].l+1,j)%mod)%mod;
			
		}
		else
		{
			int tmp=a[q[i+1].r]-a[q[i].r];
			int t=q[i].r-q[i].l+1;
			int pre=q[i+1].l-q[i].l;
			int len=q[i].r-q[i+1].l+1;
			for(int j=0;j<=t;++j)
			for(int k=max(0,j-pre);k<=j&&k<=len;++k){
				dp[i+1][tmp+k]=(dp[i+1][tmp+k]+dp[i][j]*C(pre,j-k)%mod)%mod;
			}
		}
	}
	printf("%lld",dp[m+1][0]%mod);
	return 0;
} 

Measured memory_bytes: 70912
n = int(input())
l = list(map(int, input().split()))
l.sort()

cnt = 0
for i in range(n):
    for j in range(i + 1 , n):
        for k in range(j + 1, n):
            if len(set([l[i], l[j], l[k]])) == 3:
                if l[i] + l[j] > l[k]:
                    cnt += 1
print(cnt)


Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
int a[MAX];
int G[105][105];

int main()
{
    int h,o;
    while(scanf("%d%d",&h,&o)!=EOF)
    {
        int num;
        scanf("%d",&num);
        for(int i=1;i<=num;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=o;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=o;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=o;++j)
            {
                if(j!=o) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string s;
    cin >> s;

    stack<char > st;

    for(ll i = 0; i < s.length(); i++){
        if(s[i] == '0'){
            st.push('0');
        }else if(s[i] == '1'){
            st.push('1');
        }else{
            if(!st.empty()) st.pop();
        }
    }

    //表示
    string ans;
    while(!st.empty()){
        ans += st.top();
        st.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vii;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define PB push_back
#define F first
#define S second
#define nul -1
int main()
{
   int n;cin>>n;
   int ac=0,wa=0,tle=0,re=0;
   while(n--)
   {
       string s;cin>>s;
       if(s=="AC") ac++;
       else if(s=="WA") wa++;
       else if(s=="TLE") tle++;
       else if(s=="RE") re++;

   }
   cout<<"AC x "<<ac<<endl;
   cout<<"WA x "<<wa<<endl;
   cout<<"TLE x "<<tle<<endl;
   cout<<"RE x "<<re<<endl;
   return 0;
}


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

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  if(A>=B){
    cout << "delicious" << endl;
  }
  else if(B-A<=X){
    cout << "safe" << endl;
  }
  
  else{
    cout << "dangerous" << endl;
  }

return 0;  
}

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

int ll_min(ll a, ll b){
    if (a < b) return a;
    else return b;
}

int main(void){
    ll N; cin >> N;
    
    ll min_n = 999999;
    for (ll i = 1; i < sqrt(N) + 1; i++){
        if (N % i != 0) continue;
        ll a = i, b = N / i;
        min_n = min(min_n, max(ll(log10(a)), ll(log10(b))));
    }
    cout << min_n + 1 << endl;
}


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

int main(){
    ll h;
    cin >> h;
    ll res = 1;
    ll sum = 1;
    bool ok = true;
    while(ok){
        if(h > 1){
            h /= 2;
            res *= 2;
            sum += res;
        }
        else ok = false; 
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
#define P pair<int, int>

bool comp(const P &a, const P &b)
{
	return a.second > b.second;
}

int main()
{
	vector<P> v;
	int rank[128];
	int a, b, cnt = 0, n = 1;

	while(scanf("%d%*c%d",&a ,&b))
	{
		if(!a && !b)
		{
			break;
		}
		v.push_back( make_pair(a, b) );
		cnt++;
	}

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

	rank[v[0].first] = 1;
	for(int i = 1; i < cnt; i++)
	{
		if( v[i-1].second != v[i].second )
		{
			n++;
		}
		rank[v[i].first] = n;
	}

	while(cin >> a)
	{
		cout << rank[a] << endl;
	}
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e5+10;
const ll inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    double a,b;
    cin>>a>>b;
    int la=a/0.08+0.5,ra=(a+1)/0.08+0.5;
	int lb=b/0.1+0.5,rb=(b+1)/0.1+0.5;
	if(max(la,lb)<min(ra,rb))
	cout<<max(la,lb);
	else cout<<-1;
}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 1000 + 10, W = 20010;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, a[N], w[N], s[N], v[N], ind[N];
ll dp[N][W], ps[N][W];

bool cmp(int x, int y){
	return w[x] + s[x] < s[y] + w[y];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> w[i] >> s[i] >> v[i];
		ind[i] = i;
	}
	sort(ind + 1, ind + n + 1, cmp);
	for (int i = 1; i <= n; i++){
		//cout << ind[i] << '\n';
		for (int j = 0; j < w[ind[i]]; j++) dp[i][j] = dp[i - 1][j];
		for (int j = w[ind[i]]; j <= min(W - 1, s[ind[i]] + w[ind[i]]); j++){
			//cout << i << ' ' << j << ' ' << v[ind[i]] << '\n';
			dp[i][j] = max(dp[i - 1][j], ps[i - 1][j - w[ind[i]]] + v[ind[i]]);
		}
		for (int j = min(W - 1, s[ind[i]] + w[ind[i]]) + 1; j < W; j++) dp[i][j] = dp[i - 1][j];
		ps[i][0] = dp[i][0];
		for (int j = 1; j < W; j++) ps[i][j] = max(dp[i][j], ps[i][j - 1]);
	}
	//cout << ps[1][2] << '\n';
	//cout << dp[2][4] << '\n';
	cout << ps[n][W - 1];









	return 0;
}


Measured memory_bytes: 315520
import copy
 
n,k,c = map(int,input().split())
s = list(input())
 
front = []
back = []
 
# 前から貪欲
j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front.append(i)
    i += c+1
    j -= 1
  else:
    i += 1
 
# 後ろから貪欲
 
j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back.append(i)
    i -= c+1
    j -= 1
  else:
    i -= 1

back.sort()
for i in range(k):
  if front[i] == back[i]:
    print(front[i]+1)

Measured memory_bytes: 22564
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  map<string,int>mp;
  string temp;
  for(int i=0;i<N;i++){
    cin>>temp;
    mp[temp]++;
  }
 
  int maxn=0;
  for(auto it=mp.begin();it !=mp.end();it++){
    if(it->second >= maxn){
      maxn=it->second;
    }
  }
  for(auto it=mp.begin();it !=mp.end();it++){
    if(it->second == maxn){
      cout<<it->first<<endl;
    }
  }  
 
  return 0;
}


Measured memory_bytes: 19212
#include <stdio.h>
#include <iostream>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c,d,e,k;
    int sz[5];
    for(int i=0;i<5;i++)
        cin>>sz[i];
    cin>>k;
    int cnt=1;
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(abs(sz[i]-sz[j])>k)
            {
                cnt=0;
                break;
            }
        }
    }
    if(cnt)
    {
        cout<<"Yay!"<<endl;
    }
    else
        cout<<":("<<endl;
    return 0;
}

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

int main()
{
    int x,y;
    cin >> x >> y;

    while (!(x == 0 && y == 0))
    {
        if (x > y)
        {
            swap(x,y);
        }
        cout << x << " " << y << endl;
        cin >> x >> y;
    }
    return 0;
    
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n;
ll arr[3001], dp[3001][3001][2];

ll solve(int i = 0, int j = n-1, int t = 0) {
    if (i == n | j < 0 || i > j) {
        return 0;
    }
    ll& ret = dp[i][j][t];
    if (~ret) {
        return ret;
    }
    if (!t) {
        return ret = max(arr[i] + solve(i+1, j, 1), arr[j] + solve(i, j-1, 1));
    }
    return ret = min(solve(i+1, j, 0)-arr[i], solve(i, j-1, 0)-arr[j]);
}
int main()
{
    IOS
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    cout << solve() << endl;


    return 0;
}


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

int main(void){
	int L, R, d;
	cin >> L >> R >> d;
	int ans=0;
	while (L<=R){
		if (L%d==0) ans++;
		L++;
	}
	cout << ans << endl;

return 0;
}


Measured memory_bytes: 3632
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

int powz(int v,int k) { int r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }

signed main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > a(n,std::vector<int>(n));
	rep(i,n) rep(j,n) std::cin >> a[i][j];
	std::vector<std::vector<mint> > dp(n+1, std::vector<mint>(powz(2,n),0));
	dp[0][0]=1;
	rep(i,n) {
		rep(j,powz(2,n)) {
			if(!(dp[i][j]==mint(0))) {
				rep(k,n) {
					if(a[i][k] && !(j&(1<<k))) {
						dp[i+1][j|(1<<k)] += dp[i][j];
					}
				}
			}
		}
	}
	print(dp[n][(1<<n)-1]);

	return 0;
}


Measured memory_bytes: 377216
a = input()

a = list(a)
b = a[0]+a[1]
c = a[2]+a[3]

b = int(b)
c = int(c)

if c >= 1 and c <= 12 and b >= 1 and b <= 12:
        print("AMBIGUOUS")

elif c >= 1 and c <= 12:
    print("YYMM")

elif b >= 1 and b <= 12:
    if c >= 1 and c <= 12:
        print("AMBIGUOUS")
    print("MMYY")
    
else:
    print('NA')

Measured memory_bytes: 38256
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

type Color = "Black" | "White";
type PickData = {
  index: number;
  isPicked: boolean;
};

{
  const [H, W, K] = [nCin(), nCin(), nCin()];

  const cnt = (() => {
    const css: Color[][] = range(H).map(() =>
      cin()
        .split("")
        .map((c) => (c === "#" ? "Black" : "White") as Color)
    );

    const getBlackCnt = (hPicks: PickData[], wPicks: PickData[]) =>
      hPicks
        .filter(({ isPicked }) => isPicked)
        .map(({ index }) => {
          const cs = css[index];
          return wPicks
            .filter(({ isPicked }) => isPicked)
            .map(({ index }) => {
              return (cs[index] === "Black" ? 1 : 0) as number;
            })
            .reduce((acc, x) => acc + x, 0);
        })
        .reduce((acc, x) => acc + x, 0);

    const initialBlackCnt = getBlackCnt(
      range(H).map((i) => ({ index: i, isPicked: true })),
      range(W).map((j) => ({ index: j, isPicked: true }))
    );

    const wPickFn = (n: number, hPicks: PickData[], wPicks: PickData[]): number =>
      n >= W
        ? (() => {
            const hCnt = getBlackCnt(
              range(H).map((i) => ({ index: i, isPicked: true })),
              wPicks
            );
            const wCnt = getBlackCnt(
              hPicks,
              range(W).map((j) => ({ index: j, isPicked: true }))
            );
            const hwCnt = getBlackCnt(hPicks, wPicks);

            return initialBlackCnt - (hCnt + wCnt - hwCnt);
          })() === K
          ? 1
          : 0
        : wPickFn(n + 1, hPicks, wPicks) +
          wPickFn(
            n + 1,
            hPicks,
            wPicks.map(({ index, isPicked }) =>
              index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
            )
          );

    const hPickFn = (n: number, hPicks: PickData[]): number =>
      n >= H
        ? wPickFn(
            0,
            hPicks,
            range(W).map((j) => ({ index: j, isPicked: false }))
          )
        : hPickFn(n + 1, hPicks) +
          hPickFn(
            n + 1,
            hPicks.map(({ index, isPicked }) =>
              index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
            )
          );

    return hPickFn(
      0,
      range(H).map((i) => ({ index: i, isPicked: false }))
    );
  })();

  console.log(cnt);
}


Measured memory_bytes: 40396
def main():
    N = int(input())
    ans = ""
    while N != 0:
        tmp = (-2) ** len(ans)
        if N % (tmp*-2) == 0:
            ans = "0" + ans
        else:
            ans = "1" + ans
            N -= tmp
    if ans == "":
        ans = "0"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  int p[100000]; int q[100000]; int r[100000];
  for (int i = 0; i < a; ++i) cin >> p[i]; sort(p, p+a, greater<int>());
  for (int i = 0; i < b; ++i) cin >> q[i]; sort(q, q+b, greater<int>());
  for (int i = 0; i < c; ++i) cin >> r[i]; sort(r, r+c, greater<int>());
  
  long long sum = 0;
  for (int i = 0; i < x; ++i) sum += p[i];
  for (int i = 0; i < y; ++i) sum += q[i];
  int s = x-1, t = y-1;
  for (int i = 0; i < c; ++i)
    if (s >= 0 and t >= 0) {
      if (p[s] < q[t] and p[s] < r[i]) sum += r[i] - p[s--];
      else if (q[t] < r[i]) sum += r[i] - q[t--];
    }
    else if (s >= 0 and p[s] < r[i]) sum += r[i] - p[s--];
    else if (t >= 0 and q[t] < r[i]) sum += r[i] - q[t--];
  
  cout << sum << endl;
  return 0;
}

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

int n,l;
int main(){
    cin>>n;
    cin>>l;
    
    if(l>=0)
        cout<<((2*l+n)*(n-1))/2<<endl;
    else if(l+n<=1)
    {
        cout<<(l+l+n-2)*(n-1)/2<<endl;
    }
    else
        cout<<(l+l+n-1)*n/2<<endl;
    
}

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

int main(){
  

  
  int H,R ;
  cin>>H>>R  ;
  if(-H==R){
    
    cout<<0<<endl;
  }else if(-H>R){
    
    cout<<-1<<endl;
  }else{
    cout<<1<<endl;
  }

  
  

  return 0;
}



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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> X(N), Y(N);
  set<int> xs, ys;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    xs.insert(X[i]);
    xs.insert(X[i] - 1);
    ys.insert(Y[i]);
    ys.insert(Y[i] - 1);
  }
  unordered_map<int, unordered_map<int, int>> m;
  for (auto x : xs) {
    m[x] = unordered_map<int, int>();
    for (auto y : ys) {
      for (int i = 0; i < N; i++) {
        if (X[i] <= x and Y[i] <= y) m[x][y]++;
      }
    }
  }
  long long ans = 9 * 1e18;
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  for (int i1 = 0; i1 < N; i1++) {
    int x1 = X[i1];
    for (int i2 = i1 + 1; i2 < N; i2++) {
      int x2 = X[i2];
      for (int j1 = 0; j1 < N; j1++) {
        int y1 = Y[j1];
        for (int j2 = j1 + 1; j2 < N; j2++) {
          int y2 = Y[j2];
          int cnt = m[x2][y2] - m[x2][y1 - 1] - m[x1 - 1][y2] + m[x1 - 1][y1 - 1];
          if (cnt >= K) {
            long long s = (long long)(x2 - x1) * (y2 - y1);
            chmin(ans, s);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 768
#include <algorithm>
#include  <iterator>
#include  <iostream>
#include   <cstring>
#include   <cstdlib>
#include   <iomanip>
#include    <bitset>
#include    <cctype>
#include    <cstdio>
#include    <string>
#include    <vector>
#include     <stack>
#include     <cmath>
#include     <queue>
#include      <list>
#include       <map>
#include       <set>
#include   <cassert>

using namespace std;
#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue



typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 bll;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
typedef pair<int,pii> p3;
typedef pair<ll,int>pli;
//priority_queue<int> q;//这是一个大根堆q
//priority_queue<int,vector<int>,greater<int> >q;//这是一个小根堆q
#define fi first
#define se second
//#define endl '\n'

#define OKC ios::sync_with_stdio(false);cin.tie(0)
#define FT(A,B,C) for(int A=B;A <= C;++A)  //用来压行
#define REP(i , j , k)  for(int i = j ; i <  k ; ++i)
#define max3(a,b,c) max(max(a,b), c);
#define min3(a,b,c) min(min(a,b), c);
//priority_queue<int ,vector<int>, greater<int> >que;

const ll mos = 0x7FFFFFFF;  //2147483647
const ll nmos = 0x80000000;  //-2147483648
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f; //18
const int mod = 1e9+9;
const double esp = 1e-8;
const double PI=acos(-1.0);
const double PHI=0.61803399;    //黄金分割点
const double tPHI=0.38196601;


template<typename T>
inline T read(T&x){
    x=0;int f=0;char ch=getchar();
    while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
    while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x=f?-x:x;
}
/*-----------------------showtime----------------------*/
int main(){
            string s[5];
            int n;
            cin>>n>>s[1] >>s[2]>>s[3];

            int res = 0;
            for(int i=0; i<n; i++){
                if(s[1][i] == s[2][i] && s[1][i] == s[3][i]) continue;


                if(s[1][i] != s[2][i] && s[1][i] != s[3][i] && s[2][i] != s[3][i]) res += 2;
                else res += 1;

            }
            cout<<res<<endl;

            return 0;
}


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

public class Main  {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        int count = 1;
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int max = Integer.parseInt(tokenizer.nextToken());
        int value;
        for (int i = 1; i < n; i++) {
            value = Integer.parseInt(tokenizer.nextToken());
            if (value >= max)
                count++;

            max = Math.max(max, value);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21204
#include <iostream>

using namespace std;

void solve()
{
	int sum = 0;
	for(int i = 0; i < 10; ++i)
	{
		int n;
		cin >> n;
		sum += n;
	}
	cout << sum << endl;
}

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

Measured memory_bytes: 1160
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[int(input()) - 1])

Measured memory_bytes: 61888