akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,tot;
    cin >> n >> tot;
    vector<int> a(n);
    for ( int i=0; i<n; i++ ) cin >> a[i];
    sort(a.begin(),a.end());
    
    int ans=0;
    for ( int i=0; i<n; i++ ) {
        if ( tot<=0 ) break;
        if ( tot>=a[i] ) ans++;
        tot-=a[i];
    }
    if ( tot>0 ) ans--;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b) {
    printf("a == b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a < b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define N 2*123456
using namespace std;
#define LL long long
LL a[N];
LL sum[N+100],sum2[N+100];
LL Min=0x3f3f3f3f3f3f3f3f;
int main(){
    LL n,m;
    scanf("%lld",&n);
    sum[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=n-1;i++){
     //   cout<<abs(sum[i]-(sum[n]-sum[i]))<<" "<<Min<<endl;
        Min=min(abs(sum[i]-(sum[n]-sum[i])),Min);
    }
    printf("%lld\n",Min);
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; 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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);


int main(){
    ll n;cin >> n;
    map<ll,ll> mp;
    ll a,b;
    rep(i,n+1){
        ll t;cin >> t;
        if(mp.count(t)){
            b=i;a=mp[t];
        }
        else mp[t]=i;
    }
    b=n-b;
    rep(i,n+1){
        mint res=comb(n+1,i+1);
        mint t=comb(a+b,i);
        cout << res-t <<endl;
    }
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	ll s;
	cin >> s;
	vector<int> c1(2), c2(2), c3(2);
	c1[0] = c1[1] = 0;
	c2[0] = 1e9;
	c2[1] = 1;
	c3[1] = (s + c2[0] - 1) / c2[0];
	c3[0] = c3[1] * c2[0] - s;
	put(c1, c2, c3);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
edges = [[0 for _ in range(50)] for _ in range(50)]
for _ in range(m):
    a,b = map(int, input().split())
    edges[a-1][b-1] = 1
    edges[b-1][a-1] = 1

def dfs(start):
    if visited[start]:
        return
    visited[start] = 1
    for i in range(n):
        if edges[start][i]:
            dfs(i)

ans = m
# edgeを一つづつ見ていく
for i in range(m-1):
    for j in range(i+1, m):
        if not edges[i][j]:
            continue
        # エッジを削除した場合に、連結しているかをdfsで確認
        #   visited: 訪れたかどうかを表す変数
        visited = [0] * n
        edges[i][j] = 0
        edges[j][i] = 0
        dfs(0)
        # お片付け、削除したedgeを元に戻しておく
        edges[i][j] = 1
        edges[j][i] = 1
        # 全て訪れられていたら、そのエッジはなくても非連結にならないので、bridgeではない
        if sum(visited) == n:
            ans -=1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    ll n; cin>>n;
    cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int even = 0;
		int odd = 0;

		even = N * (N - 1) / 2;
		odd = M * (M - 1) / 2;

		System.out.println(even + odd);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  char a[3];
  rep(i, 0, 3){
    cin >> a[i];
    if(a[i] == '1'){
      a[i] = '9';
    }
    else{
      a[i] = '1';
    }
  }
  
  rep(i, 0, 3){
    cout << a[i];
  }
}
      

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

int mp[35][35];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,m;cin>>n>>m;
  for(int i=0;i<n;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int a;cin>>a;a--;
      mp[i][a]=1;
    }
  }
  int res=0;
  for(int i=0;i<m;i++){
    int ok=1;
    for(int j=0;j<n;j++){
      if(!mp[j][i])ok=0;
    }
    if(ok)res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main (){
    char s[101], p[101], t[201]="", a;
    scanf("%s", p);
    scanf("%s", s);
    strcat(strcat(t, p),p);
    a=strstr(t, s);
    if(a==0)printf("No\n");
    else printf("Yes\n");
    
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == 7 && b == 5 && c == 5) || (b == 7 && a == 5 && c == 5) || (c == 7 && a == 5 && b == 5)) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  int ans = 0;
  for(int X=0; X<=K; X++){
    for(int Y=0; Y<=K; Y++){
      int m = S-X-Y;
      if(0<=m && m<=K){
          ans++;
        }
    }
  }
  cout << ans;
  return 0;
}

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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int n,m;scanf("%d%d",&n,&m);
   int a[51],b[51];for(int i = 0;i < m;i++)scanf("%d%d",&a[i],&b[i]);
   int count[51]={0};
   for(int i = 0;i < m;i++){
      count[a[i]-1]++;
      count[b[i]-1]++;
   }
   for(int i = 0;i < n;i++){
      printf("%d\n",count[i]);
   }
}

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

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

    int rcnt = 0;
    rep(i, n) {
        if (s[i] == 'R')
            rcnt++;
    }

    int ans = 0;
    rep(i, rcnt) {
        if (s[i] == 'W')
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w, m;
    cin >> h >> w >> m;
    map<ll, ll> xCnt, yCnt;
    vi hm(m), wm(m);
    set<pair<ll, ll>> st;
    ll hmmax = 0, wmmax = 0;
    // x, y座標ごとの爆弾の数を数える
    rep(i, m){
        cin >> hm[i] >> wm[i];
        hm[i]--, wm[i]--;
        st.insert({hm[i], wm[i]});
        chmax(hmmax, ++yCnt[hm[i]]);
        chmax(wmmax, ++xCnt[wm[i]]);
    }

    // x, y座標ごとに最大値を取る場所を候補としてリストアップ
    vi hmc, wmc;
    for(auto &num: yCnt) if(hmmax == num.second) hmc.emplace_back(num.first);
    for(auto &num: xCnt) if(wmmax == num.second) wmc.emplace_back(num.first);

    // hmc, wmcの全ての組み合わせの中に爆弾じゃない位置があれば、答えはhmmax+wmmax
    // 全て爆弾であれば、答えはhmmax+wmmax-1となる。
    for(auto &y: hmc){
        for(auto &x: wmc){
            if(st.find({y, x}) == st.end()){
                cout << hmmax + wmmax << endl;
                return 0;
            }
        }
    }
    cout << hmmax + wmmax - 1 << endl;
    return 0;
}

Measured memory_bytes: 72564
#include <algorithm>
#include <cstdio>
#include <stack>

using namespace std;

#define MAX_W (1410)
#define MAX_H (1410)

typedef pair<int, int> Data;	// first: height, second: pos

int hist[MAX_H][MAX_W];
int tile[MAX_H][MAX_W];		// 0: clean, 1: dirty
int main()
{
    int H, W;
    scanf("%d %d", &H, &W);

    for ( int y = 0; y < H; y++ ) {
	for ( int x = 0; x < W; x++ ) {
	    scanf("%d", &tile[y][x]);
	}
    }

    for ( int y = 0; y < H; y++ ) {
	for ( int x = 0; x < W; x++ ) {
	    if ( tile[y][x] == 1 ) hist[y][x] = 0;
	    else {
		if ( y == 0 ) hist[y][x] = 1;
		else hist[y][x] = hist[y-1][x] + 1;
	    }
	}
    }

    int ans = 0;

    for ( int y = 0; y < H; y++ ) {
	stack<Data> S;
	for ( int x = 0; x < W; x++ ) {
	    if ( hist[y][x] > 0 ) {
		if ( S.empty() ) { // ????????´???
		    S.push( make_pair( hist[y][x], x ) );
		}
		else {
		    Data top = S.top();
		    if ( hist[y][x] > top.first ) {
			S.push( make_pair( hist[y][x], x ) );			
		    } 
		    else if ( hist[y][x] == top.first ) {
			// ???????????????
		    } 
		    else if ( hist[y][x] < top.first ) {
			int prePos = x;
			while ( !S.empty() ) {
			    Data top = S.top();
			    if ( hist[y][x] <= top.first ) {
				S.pop();
				ans = max( ans, top.first * ( x - top.second ) );
				prePos = top.second;
			    }
			    else {
				break;
			    }
			}
			S.push( make_pair( hist[y][x], prePos ) );
		    }
		}
	    }
	    else {
		while ( !S.empty() ) {
		    Data top = S.top(); S.pop();
		    ans = max( ans, top.first * ( x - top.second ) );
		}
		
	    }
	}
	while ( !S.empty() ) {
	    Data top = S.top(); S.pop();
	    ans = max( ans, top.first * ( W - top.second ) );
	}
    }

    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
 unsigned long long int N,x,ans=0,tmp=0;
  cin >>N>>x;
 lint M[N];
 rep(i,N)cin >>M[i];
 
  repp(i,1,N){
    tmp=(M[i-1]+M[i]);
    if(tmp>x){
      ans+=tmp-x;
      M[i]-=(tmp-x);
      if(M[i]<0)M[i]=0;
    }
    tmp=0;
  }
  cout <<ans;
}


  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <math.h>

using namespace std;







int main(){

 long long Q,diff=0;
 cin>>Q;

 while(Q--){

    long long l,r;
    cin>>l>>r;

    diff += abs(l-r)+1;
 }

  cout<<diff<<endl;

return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    ll s; cin >> s;
    ll x2 = 1e9;
    ll y2 = 1;
    ll x3 = (x2-s%x2)%x2;
    ll y3 = (s+x3)/x2;

    cout << 0 << ' ' << 0 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;

    return 0;
}

Measured memory_bytes: 256
import fractions
def lcm(a,b):
  return a*b //fractions.gcd(a, b)

A, B,C,D = map(int, input().split())
 
b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
print((B-(A-1))-(b_num-a_num))

Measured memory_bytes: 5048
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a, b, c;

  cin >> a >> b >> c;
  int ans = 0;
  if (a == b)
    if (b == c)
      ans = 1;
    else
      ans = 2;
  else if (b == c)
    ans = 2;
  else if (a == c)
    ans = 2;
  else
    ans = 3;

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



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<int, int> cnt;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    if(cnt.size() % 2 == 0) cout << cnt.size() - 1 << endl;
    else cout << cnt.size() << endl;
    return 0;
}

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

using namespace std;

// ユークリッドの互除法で最大公約数（gcd: greatest common divisor）を求める
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  int N, ans;
  cin >> N;
  int HP[N];
  for (int i = 0; i < N; i++) {
    cin >> HP[i];
  }
  ans = gcd(HP[0], HP[1]);
  for (int i = 2; i < N; i++) {
    ans = gcd(ans, HP[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int n,m;
  int a[100][100],b[100];
  int i,k,r;

  scanf("%d%d",&n,&m);

  for(i=0; i<n; ++i){
    for(k=0; k<m; ++k){
      scanf("%d",&a[i][k]);
    }
  }

  for(i=0; i<m; ++i){
    scanf("%d",&b[i]);
  }

  for(i=0; i<n; ++i){
    r=0;
    for(k=0; k<m; ++k){
      r+=a[i][k]*b[k];
    }
    printf("%d\n",r);
  }



  return 0;
}


Measured memory_bytes: 2768
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long n = read.to!long;
	long p = read.to!long;
	long[] as = readln.chomp.split.map!(to!long).array;
	
	long c0 = as.map!(a => a % 2).filter!(x => x == 0).array.length;
	long c1 = as.map!(a => a % 2).filter!(x => x > 0).array.length;
	
	BigInt ans = 1;
	foreach(i; 0 .. c0) ans *= 2;
	if(p == 0){
		if(c1 > 1) foreach(i; 1 .. c1) ans *= 2;
		}
	else{
		if(c1 > 1) foreach(i; 1 .. c1) ans *= 2;
		else ans = 0;
		}
	
	ans.writeln;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define forit(it,cont) for(auto it=cont.begin();it!=cont.end();it++)
#define for0(i,n) for(i=0;i<n;i++)
#define for1(i,n) for(i=1;i<=n;i++)
#define for0r(i,n) for(i=n-1;i>=0;i--)
#define for1r(i,n) for(i=n;i>=1;i--)
#define ll long long 
ll a[110][100010];
ll w[110];
ll v[110];
int main()
{
	IOS;
	ll n,W,i,j;
	cin>>n>>W;
	for0(i,n)
	cin>>w[i]>>v[i];
	for0(i,n)
	{
		for(j=0;j<=W;j++)
		{
			if(j==0)
				a[i][j]=0;
			else if(i==0)
			{
				if(w[0]>j)
					a[i][j]=0;
				else
					a[i][j]=v[i];
			}
			else if(w[i]<=j)
			{
				a[i][j]=max(a[i-1][j],a[i-1][j-w[i]]+v[i]);
			}
			else
				a[i][j]=a[i-1][j];
		}
	}
	cout<<a[n-1][W]<<endl;
	return 0;	
}


Measured memory_bytes: 80128
def fn(a, b, c, d):
  result = []
  result.append(a * c)
  result.append(a * d)
  result.append(b * c)
  result.append(b * d)
  if (a <= 0 and b >= 0) or (c <= 0 and d >= 0):
    result.append(0)

  return max(result)

if __name__ == "__main__":
  input = list(map(int, input().split()))
  print(fn(input[0], input[1], input[2], input[3]))

Measured memory_bytes: 9192
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

class edge {
  public:
    int u, v;
    int w;
    edge(int u, int v, int w): u(u), v(v), w(w){}
};

int n;
vector< edge > graph[MAX_N];

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

void dfs(int v, int p, ll d, int color[]){
  if(d % 2 == 0) color[v] = 0;
  else color[v] = 1;
  for(edge e: graph[v]){
    if(e.v != p) dfs(e.v, v, d + e.w, color);
  }
}

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

  cin >> n;
  int u[n - 1], v[n - 1], w[n - 1];
  for(int i = 0; i < n - 1; i++){
    cin >> u[i] >> v[i] >> w[i];
    --u[i]; --v[i];
  }

  for(int i = 0; i < n - 1; i++){
    graph[u[i]].push_back(edge(u[i], v[i], w[i]));
    graph[v[i]].push_back(edge(v[i], u[i], w[i]));
  }

  int color[n];
  fill(color, color + n, -1);
  dfs(0, -1, 0, color);

  string buf;
  for(int v = 0; v < n; v++){
    buf += to_string(color[v]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 10556
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int a,b,c;cin>>a>>b>>c;
	if(a+b+c>21){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <string.h>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

int main (void)
{
	int a,b;
	cin >> a >> b;

	cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 3096
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
double p[3002];
int n;
double ss,s;
double dp[3004][3004];
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;i++){
	cin>>p[i];
}
dp[0][0]=1.0;
for(int i=1;i<=n;i++){
	dp[i][0]=(1-p[i])*dp[i-1][0];
}
for(int i=1;i<=n;i++){
	for(int j=1;j<=i;j++){
		dp[i][j]=p[i]*dp[i-1][j-1];
		if(j<i)dp[i][j]+=(1-p[i])*dp[i-1][j];
//		cout<<dp[i][j]<<endl;
	}
}
for(int i=(n+1)/2;i<=n;i++){
	s+=dp[n][i];
}
for(int i=1;i<=n;i++){
	ss+=dp[n][i];
}
cout<<fixed<<setprecision(10)<<s<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]=s[k-1]+'a'-'A';
  cout<<s<<endl;
  return 0;
}

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

int main() {
    string s;
    vector<string> day{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cin >> s;
    for(int i = 0; i < 7; i++) {
        if (day.at(i) == s) cout << 7-i << endl; 
    }
    return 0;
}

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

#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define debug cout<<"debugging"<<endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int I_LIMIT = 999999999;
ll L_LIMIT = 1999999999999999999;
ll mod = 1000000000;
vector <int> v[100005];

void solve()
{
    ll a,b,c,d,ans=-L_LIMIT;

    cin>>a>>b>>c>>d;
    ans = max(ans,b*d);
    ans = max(ans,a*c);
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    cout<<ans<<"\n";
    
}
int main()
{
    IOS;
    int t;
    //cin>>t;
    //for(int i=1;i<=t;i++)
        solve();
}


Measured memory_bytes: 5992
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			StringBuilder str=new StringBuilder(sc.next());
			int k=sc.nextInt();
			StringBuilder res=new StringBuilder();
			for(int i=0;i<str.length();i++){
				if(i+1==str.length()){
					k%=26;
					int a=str.charAt(i)-'a'+k;
					a%=26;
					res.append((char)('a'+a));
				}
				else if(str.charAt(i)!='a' && 'z'-str.charAt(i)+1<=k){
					res.append("a");
					k-=(int)('z'-str.charAt(i))+1;
				}
				else res.append(str.charAt(i));
			}
			System.out.println(res);
		}
	}
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    set<int> A;
    for(int i = a; i < a + k; i++){
        if(i > b) break;
        else A.insert(i);
    }
    for(int i = b; i > b - k; i--){
        if(a > i) break;
        else A.insert(i);
    }
    for(auto x : A){
        cout << x << endl;
    }

    return 0;
}

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


int main() {
  int L,R,d;
  cin >> L >> R >> d;
  
  if(L%d ==0 && R%d==0){
    cout << (R-L)/d+1 <<endl;
  }
  else if(L%d ==0 || R%d==0){
    cout << (R-L)/d +1 <<endl;
  }
  else{
    cout << (R-L)/d <<endl;
  }
}


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

int bye(double a){
  int i=0;
  while(i<=a){
    i++;
  }
  return i-1;
}

int main(){
  int N;
  cin >> N;
  for(int i=0; i<=N; i++){
    if(bye(i*1.08)==N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> edge(N);
    for(int i=0;i<N;i++){
        cin>>edge.at(i);
    }
    sort(edge.rbegin(),edge.rend());

    int sum=0;
    for(int i=1;i<N;i++){
        sum+=edge.at(i);
    }
    //cout<<edge.at(0)<<sum<<endl;
    if(sum<=edge.at(0)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 2e5 + 5;
vector<int> v, dp, l(N, INT_MAX), g[N];

void dfs(int a = 0, int p = 0)
{
    int j = lower_bound(l.begin(), l.end(), v[a]) - l.begin();
    int val = l[j];
    l[j] = v[a];
    dp[a] = max(j, dp[p]);
    for (auto elm : g[a])
    {
        if (elm != p)
            dfs(elm, a);
    }
    l[j] = val;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    l[0] = INT_MIN;
    dp.resize(n, 0), v.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b), g[b].push_back(a);
    }
    dfs();
    for (int i = 0; i < n; i++)
    {
        cout << dp[i] << '\n';
    }
    return 0;
}

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    long long ans = 0;
    for(i = 0;i < n;i++){
        for(long long d = 1;;d *= 10){
            long long p = ans/d%10;
            long long q = ans/d/10%10;
            if(ans < d*10){
                q = p;
            }
            if(p > q || p == 9) continue;
            ans = ans+d;
            for(d /= 10;d > 0;d /= 10){
                p = ans/d%10;
                q = ans/d/10%10;
                ans -= p*d;
                if(q > 0) ans += (q-1)*d;
            }
            break;
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static final int MOD_SEED = 1000000007;

	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int M = io.nextInt();
		long[] x = new long[N-1];
		long[] y = new long[M-1];
		
		int pr = io.nextInt();
		int sum=0;
		for(int i=0;i<N-1;i++){
			int cr = io.nextInt();
			x[i] = cr-pr;
			sum += (cr-pr);
			pr = cr;
		}
		
		long pushX = foldin(x,sum);
		
		pr = io.nextInt();
		sum = 0;
		for(int i=0;i<M-1;i++){
			int cr = io.nextInt();
			y[i] = cr-pr;
			sum += cr-pr;
			pr = cr;
		}
				
		long pushY = foldin(y,sum);
		System.out.println(pushX*pushY%MOD_SEED);
	}
	
	public static long foldin(long[] belt,long sum){
		long ans = 0;
		for(int i=0;i<(belt.length+1)/2;i++){
			ans = (ans + sum*(belt.length-2*i))%MOD_SEED;
			sum -= belt[i];
			sum -= belt[belt.length-1-i];
		}
		return ans;
	}
}

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

using namespace std;

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

  int a, b;
  cin >> a >> b;

  int t2 = 1, t1 = 0;
  for (int i = 2; i < 1000; ++i) {
    t2 = t2 + i;
    t1 = t1 + i-1;
    if (t2 - b == t1 - a) {
      cout << (t2 - b) << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 1

int n, M[N][N];
int color[N], s[N], f[N], ts; 

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    s[u] = ++ts;
    for (v=0; v<n; v++) {
        if(M[u][v]==0){
            continue;
        }
        if (color[v]==WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++ts;
}

void dfs() {
    int u;
    for (u=0; u<n; u++) {
        color[u] = WHITE;
    }
    ts = 0;
    for (u=0; u<n; u++) {
        if (color[u]==WHITE){
            dfs_visit(u);
        }
    }
    for (u=0; u<n; u++) {
        printf("%d %d %d\n", u+1, s[u], f[u]);
    }
}

int main() {
    int u, k, tmp;
    cin >> n;
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i=0; i<n; i++) {
        cin >> u >> k;
        for (int j=0; j<k; j++) {
            cin >> tmp;
            M[u-1][tmp-1] = 1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define M 200005

int n,A[M<<1];
int main(){
	scanf("%d",&n);
	int l=M,r=M-1,t=0;
	while(n--){
		int x;
		scanf("%d",&x);
		if(t==0)A[--l]=x;
		else A[++r]=x;
		t=!t;
	}
	if(t==1)for(int i=l;i<=r;i++)printf("%d ",A[i]);
	if(t==0)for(int i=r;i>=l;i--)printf("%d ",A[i]);
	puts("");
    return 0;
}

Measured memory_bytes: 2944
N, W = map(int, input().split())
WV = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N)]

for i in range(N):
    for w in range(W+1):
        w_i = WV[i][0]
        if w >= w_i:
            dp[i][w] = max(dp[i-1][w-w_i]+WV[i][1], dp[i-1][w]) 
        else:
            dp[i][w] = dp[i-1][w]

print(dp[-1][-1])

Measured memory_bytes: 171848
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void 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(ret.begin(), ret.end());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll g = gcd(n, m);
	rep(i, g) {
		if (s[i*n / g] != t[i*m / g]) {
			cout << -1;
			return 0;
		}

	}
	cout << n * m / g;
	
	return 0;
}


Measured memory_bytes: 512
n = int(input())
cnt = 0
p = list(map(int,input().split()))
for i in range(n):
    if p[i]==i+1:
        if i==0:
            p[i+1],p[i] = p[i],p[i+1]
            cnt+=1
        elif i==n-1:
            cnt+=1
            break
        elif p[i]==i+2:
            p[i-1],p[i] = p[i],p[i-1]
            cnt+=1
        else:
            p[i],p[i+1] = p[i+1],p[i]
            cnt+=1
print(cnt)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[101],Y[101];

const ll EPS=0;

template<class C> C veccross(pair<C,C> p1,pair<C,C> p2,pair<C,C> p3) {
	p3.first-=p1.first;p2.first-=p1.first;
	p3.second-=p1.second;p2.second-=p1.second;
	return p3.first*p2.second-p2.first*p3.second;
}

template<class C> vector<int> convex_hull(vector< pair<C, C> >& vp) {
	vector<pair<pair<C, C>, int> > sorted;
	vector<int> res;
	int i,k=0,rb;
	
	if(vp.size()<=2) {
		if(vp.size()>=1) res.push_back(0);
		if(vp.size()>=2 && vp[0]!=vp[1]) res.push_back(1);
		return res;
	}
	
	FOR(i,vp.size()) sorted.push_back(make_pair(vp[i],i));
	sort(sorted.begin(),sorted.end());
	
	res.resize(vp.size()*2);
	/* bottom */
	FOR(i,vp.size()) {
		while(k>1 && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=-EPS) k--;
		res[k++]=sorted[i].second;
	}
	/* top */
	for(rb=k, i=vp.size()-2;i>=0;i--) {
		while(k>rb && veccross(vp[res[k-2]],vp[res[k-1]],sorted[i].first)<=-EPS) k--;
		res[k++]=sorted[i].second;
	}
	res.resize(k-1);
	return res;
}




void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<pair<ll,ll>> V;
	V.push_back({0,0});
	FOR(i,N) {
		cin>>x>>y;
		j=V.size();
		FOR(k,j) V.push_back({V[k].first+x,V[k].second+y});
		
		vector<int> W=convex_hull(V);
		
		vector<pair<ll,ll>> V2;
		FORR(w,W) V2.push_back(V[w]);
		swap(V,V2);
	}
	
	double ma=0;
	FORR(v,V) ma=max(ma,hypot(v.first,v.second));
	_P("%.12lf\n",ma);
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> p(N);
  int a, x, y;
  for (int i = 0; i < N; i++) {
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> x >> y;
      p[i].push_back(make_pair(x - 1, y));
    }
  }
  debug(p);
  int mx = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<20> s(tmp);
    bool break_flag = 0;
    for (int i = 0; i < N; i++) {
      if (s.test(i)) {
        for (auto v : p[i]) {
          if ((v.second == 0 && s.test(v.first)) ||
              (v.second == 1 && !s.test(v.first))) {
            break_flag = 1;
            break;
          }
        }
      }
      if (break_flag) break;
    }
    if (!break_flag) mx = max(mx, (int)s.count());
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 3592
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        
        int n = Integer.parseInt(scan.nextLine());
        Map<String, Integer> map = new HashMap<>();
        for(int i=0; i<n; i++){
            String str = scan.nextLine();
            if(map.containsKey(str)) map.put(str, map.get(str)+1);
            else map.put(str, 1);
        }
        int m = Integer.parseInt(scan.nextLine());
        for(int i=0; i<m; i++){
            String str = scan.nextLine();
            if(map.containsKey(str)) map.put(str, map.get(str)-1);
        }

        int max = 0;
        for(String key : map.keySet()){
            if(max < map.get(key)) max = map.get(key);
        }
        
        System.out.println(max);

        scan.close();
    
    }

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

const ll N = 30001;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	vl pf(N);
	iota(all(pf),0);
	for (ll i = 2; i < N; i++) if (pf[i] == i) for (ll j = i*i; j < N; j += i) pf[j] = min(pf[j],i);
	
	vl v;
	FOR(i,2,N) if (pf[i] <= 5) v.pb(i);
	sort(all(v),[&](ll i, ll j) { return pf[i] < pf[j]; });
	
	ll n; cin >> n;
	
	ll cnt = 0;
	while (true) {
		cnt++;
		random_shuffle(all(v));

		ll g = 0;
		FOR(i,0,n) g = __gcd(g,v[i]);

		if (g > 1) continue;

		ll sum = 0;
		FOR(i,0,n) sum += v[i];

		bool ok = true;
		FOR(i,0,n) if (__gcd(v[i],sum) == 1) {
			ok = false;
			break;
		}
		
		if (!ok) continue;

		FOR(i,0,n) cout << v[i] << " \n"[i+1==n];
		break;
	}
	cerr << cnt << endl;
}



Measured memory_bytes: 896
#include<stdio.h>
int main()
{
  long N,D;
  scanf("%ld %ld",&N,&D);
  long X[200010],Y[200010];
  for(int i=0;i<N;i++){
    scanf("%ld %ld",&X[i],&Y[i]);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(X[i]*X[i] + Y[i]*Y[i] <= D*D){count++;}
  }
  printf("%d",count);
}

Measured memory_bytes: 4856
s='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'.split(', ')
print(s[int(input())-1])

Measured memory_bytes: 38384
def dfs(v, current, goal, visited_list = [], m)
  if current == goal
    @result << m unless @result.include?(m)
    return
  end

  v.each do |w|
    if w[0] == current && !visited_list.include?(w[1])
      dfs(v, w[1], goal, visited_list << current, m)
    elsif w[1] == current && !visited_list.include?(w[0])
      dfs(v, w[0], goal, visited_list << current, m)
    end
  end
end
n, m = gets.chomp.split(' ').map(&:to_i)
v = []
m.times { |m| v << gets.chomp.split(' ').map(&:to_i) }
@result = []

m.times do |m|
  dfs(v.reject.with_index { |e, idx| idx == m }, v[m][0], v[m][1], [], m)
end

puts m - @result.size

Measured memory_bytes: 1916
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int dp[N][2];
string s;

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}
                                                
int calc (int pos = 0, int sa = 1) {
   if (pos == sz (s)) return 1;
   int &res = dp[pos][sa];
   if (res != -1) return res;
   res = 0;
   for (int i = 0; i < 2; i ++)
      for (int j = 0; j < 2; j ++) {
         if (i == 1 && j == 1) continue;
         if (sa && (i + j) > s[pos]) continue;
         res = add (res, calc (pos + 1, (sa & ((i + j) == s[pos]))));
      }
   return res;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> s;
   for (int i = 0; i < sz (s); i ++) s[i] -= '0';
   memset (dp, -1, sizeof dp);
   cout << calc ();
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                         

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=m;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){

    ll n;
    cin>>n;

    vector<ll> data(n);

    rep(i,n){
        ll tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    sort(ALL(data));
    reverse(ALL(data));

    long long answer=0;

    answer+=data.at(0);

    if (n%2==0){
        ll tmp=(n-2)/2;

        rep(i,tmp){
            answer+=2*data.at(i+1);
        }

    }

    else {
        ll tmp=(n-2)/2;

        rep(i,tmp){
            answer+=2*data.at(i+1);
        }
        answer+=data.at(tmp+1);
    }


    cout<<answer<<endl;




            



}

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

int main(){
  int N;
  cin >> N;
  vector<int> D(N - 1);
  for (int i = 0; i < N - 1; i++){
    cin >> D.at(i);
  }
  int sum = 0;
  sum += D.at(0);
  for (int i = 1; i < N - 1; i++){
    sum += min(D.at(i - 1), D.at(i));
  }
  sum += D.at(N - 2);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3628