akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int d=sc.nextInt();
        String s="";
        switch(d){
            case 25:
                s="Christmas";
                break;
            case 24:
                s="Christmas Eve";
                break;
            case 23:
                s="Christmas Eve Eve";
                break;
            case 22:
                s="Christmas Eve Eve Eve";
                break;
            default:
                break;
        }
        out.println(s);
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    //pはqに含まれる
    static boolean D(Point p,Point q){
        return p.x<q.x&&p.y<q.y;
    }
}


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

struct StronglyConnectedComponents {
  int n;
  vector<vector<int>> oG, rG;
  vector<int> comp, order, used;
  vector<pair<int, int>> edges;

  StronglyConnectedComponents (int n) : n(n), oG(n), rG(n), comp(n, -1), used(n, 0) {}

  int operator[] (int k) {
    return comp[k];
  }

  void add_edge(int u, int v) {
    oG[u].push_back(v);
    rG[v].push_back(u);
    edges.emplace_back(u, v);
  }

  void dfs(int v) {
    if (used[v]) return;
    used[v] = true;
    for (int to : oG[v]) dfs(to);
    order.push_back(v);
  }

  void rdfs(int v, int k) {
    if (~comp[v]) return;
    comp[v] = k;
    for (int to : rG[v]) rdfs(to, k);
  }

  void build(vector<vector<int>> &t) {
    for (int i = 0; i < n; ++i) dfs(i);

    reverse(order.begin(), order.end());
    int k = 0;
    for (int i : order) if (comp[i] == -1) rdfs(i, k++);

    t.resize(k);
    set<pair<int, int>> connect;
    for (auto &e : edges) {
      int u = comp[e.first], v = comp[e.second];
      if (u == v || connect.count({u, v})) continue;
      t[u].push_back(v);
      connect.emplace(u, v);
    }
  }
};

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

  StronglyConnectedComponents scc(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    scc.add_edge(u, v);
  }

  vector<vector<int>> G;
  scc.build(G);

  cout << (n != G.size()) << endl;
}

Measured memory_bytes: 3196
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
Asort = sorted(A)[:: -1]

L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)

Measured memory_bytes: 16124
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int dp[MAXN][2];
int n;
vector<int> e[MAXN];

int f(int x, int t, int dad) {
  if (dp[x][t] != -1) return dp[x][t];

  int ret = 0;
  
  if (t == 1) {
    ret = 1;
    for (int y : e[x]) {
      if (y == dad) continue;
      ret &= f(y, 0, x);
    }
  } else {
    int cnt0 = 0, tot = 0;
    for (int y : e[x]) {
      if (y == dad) continue;
      ++tot;
      cnt0 += f(y, 0, x);
    }

    ret = 0;
    for (int y : e[x]) {
      if (y == dad) continue;
      int my_cnt = cnt0 - f(y, 0, x);
      if (f(y, 1, x) && my_cnt >= tot - 1)
	ret = 1;
    }
  }

  return dp[x][t] = ret;
}

int main(void) {
  memset(dp, -1, sizeof(dp));
  scanf("%d",&n);
  REP(i, n - 1) {
    int u, v;
    scanf("%d %d",&u,&v);
    --u; --v;
    e[u].push_back(v);
    e[v].push_back(u);
  }

  int mat = f(0,0,-1);
  printf(mat ? "Second\n" : "First\n");
  
  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int K, S;
  cin >> K >> S;
  int X, Y, Z;
  int counter = 0;
  for(int i = 0; i <= K; i++){
    for(int j = i; j <= K; j++){
      for(int k = j; k <= K; k++){
        if(i + j + k == S){
          if(i == j && j == k) counter++;
          else if((i == j && j != k) || (i != j && j == k)) counter += 3;
          else counter += 6;
        }
      }  
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
use strict;
use warnings;
use feature 'say';

my $N = <>; chomp($N);
my $s = [];
for (1..$N) {
    my $input = <>; chomp($input);
    $input = [split "", $input];
    push(@$s, $input);
}

my $match_count = {};
my $count = 0;

for my $word (@$s) {
    my $sorted = join("", sort {$a cmp $b} @$word);
    if ($match_count->{$sorted}) {
        $count += $match_count->{$sorted};
        $match_count->{$sorted}++;
    } else {
        $match_count->{$sorted} = 1;
    }
}

say $count;

Measured memory_bytes: 104960
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
const double PI = acos(-1);
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  complex<double> a = polar(A, (H + M / 60) / 12 * 2 * PI);
  complex<double> b = polar(B, M / 60 * 2 * PI);
  cout << fixed << setprecision(10) << abs(a - b) << '\n';
  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 11072
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll x;
ll c(ll g) {
    return g*g*g*g*g;
}
int main(){
    cin>>x;
    for(int i=-1000;i<=10000;i++)
        for(int j=-1000;j<=1000;j++)
            if(c(i)-c(j)==x) {cout<<i<<" "<<j;return 0;}
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
//int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
//while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

int32_t main(void){
	IOS;
	
	in1(n);
	int arr[n];
	int x = 0;
	rep(i, 0, n)
	{
		cin>>arr[i];
		x ^= arr[i];
	}
	int brr[n];
	rep(i, 0, n)
	{
		brr[i] = x^arr[i];
		cout<<brr[i]<<" ";
	}
// 	int tmp = 0;
// 	rep(i, 1, n) tmp ^= brr[i];
// 	cout<<tmp;
}

Measured memory_bytes: 6724
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  ll ans=INF;
  for(int i=1;i<=n-1;++i){
    chmin(ans,abs(sum[i]-(sum[n]-sum[i])));
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

public class Main {
	private static FastScanner sc = new FastScanner();
	static NodeSegmentTree[] V;
	static int N;

	public static void main(String[] args) {
		int n = sc.nextInt();
		int q = sc.nextInt();

		N = 1;
		while(N < n) {
			N *= 2;
		}
		N = N * 2 - 1;
		if(N == 1) {
			N = 3;
		}

		V = new NodeSegmentTree[N];
		for(int i=0; i<N; i++) {
			V[i] = new NodeSegmentTree(i);
		}

		for(int i=N/2 - 1; i>=0; i--) {
			V[i].setSegment();
		}

		StringBuilder sb = new StringBuilder();
		for(int i=0; i<q; i++) {
			int cmd = sc.nextInt();

			if(cmd == 0) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				int x = sc.nextInt();
				V[0].updateRangeAdd(x, s, t);
			} else {
				int x = sc.nextInt();
				sb.append(V[0].get(x));
				sb.append("\n");
			}
		}

		System.out.print(sb);

	}

	static class NodeSegmentTree {
		int seg_left;
		int seg_right;
		int id;
		int value = 0;
		//left = 2 * id + 1
		//right = 2 * id + 2
		//parent = (id - 1) / 2
		//array[i] -> V[N/2 + i]

		NodeSegmentTree(int id) {
			this.id = id;
			this.seg_left = id - N/2;
			this.seg_right = id - N/2;
		}

		void setSegment() {
			seg_left = V[2 * id + 1].seg_left;
			seg_right = V[2 * id + 2].seg_right;
		}

		void updateRangeAdd(int value, int l, int r) {
			if(l <= seg_left && r >= seg_right) {
				this.value += value;
				return;
			}
			if(l > seg_right || r < seg_left) {
				return;
			}

			V[2 * id + 1].value += this.value;
			V[2 * id + 2].value += this.value;
			this.value = 0;

			V[2 * id + 1].updateRangeAdd(value, l, r);
			V[2 * id + 2].updateRangeAdd(value, l, r);
		}

		public int get(int idx) {
			if(id >= N/2) {
				return value;
			} else {
				V[2 * id + 1].value += this.value;
				V[2 * id + 2].value += this.value;
				this.value = 0;
				if(idx <= (seg_left + seg_right) / 2) {
					return V[2 * id + 1].get(idx);
				} else {
					return V[2 * id + 2].get(idx);
				}
			}
		}

	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 87740
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define m(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int maxn=2e5+100;

int main(){
	int n,k;
	while(cin>>n>>k){
		int a[maxn],cnt[maxn];
		m(a,0);
		m(cnt,0);
		for(int i=1;i<=n;i++){
			cin>>a[i];
			cnt[a[i]]++;
		}
		int count=0;
		for(int i=1;i<maxn;i++)
			if (cnt[i])
				count++;
		if (count<=k) cout<<"0"<<endl;
		else{
			int ans=count-k;
			sort(cnt,cnt+maxn);
			int sum=0,x=0;
			for(int i=1;i<=maxn;i++)
				if (cnt[i]){
					if (x==ans) break;
					sum+=cnt[i];
					x++;
				}
			cout<<sum<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

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

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}


bool check(int a) {
  return a % 7 == 1 || a % 7 == 6;
}

int main() {
  vector<int> table(300010, 1);
  rep(i, 6) table[i] = 0;

  REP(i, 6, table.size()) if(table[i]) {
    if(!check(i)) table[i] = 0;
    else for(int j = 2; j * i < table.size(); j++) if(check(j)) table[j * i] = 0;
  }

  vector<int> nums;
  rep(i, table.size()) if(table[i]) nums.push_back(i);

  for(int n; cin >> n, n != 1; ) {
    cout << n << ":" ;
    int m = n;
    for(int i : nums) {
      if (m % i == 0) {
        cout << " " << i;
      }
    }
    cout << endl;
  }
  
  return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

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

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

    ll n, m;
    cin >> n >> m;
    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }

    vi own_two_nums;
    bool ok = true;
    rep(i, n) {
        ll cp_a = a[i];
        int cnt = 0;
        while (cp_a % 2 == 0) {
            cp_a /= 2;
            cnt++;
        }
        own_two_nums.push_back(cnt);
    }
    sort(all(own_two_nums));
    if (own_two_nums.front() != own_two_nums.back()) ok = false;

    if (ok) {
        ll cnt = 1;
        rep(i, n) {
            cnt = lcm(cnt, a[i]);
        }
        ll ans = (m + cnt) / (cnt * 2);
        out(ans);
    } else {
        out(0);
    }

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=a*x+b*y;
    for(ll i=0;i<=max(x,y);i++){
        ans = min(ans, 2*c*i + a * max((ll)0,x-i) + b * max((ll)0,y-i) );
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>

const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
template<class T>void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}

int main(){std::cout << std::setprecision(10);
  string s,t;cin>>s>>t;
  ndifix::sort(s);
  ndifix::rsort(t);
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(10**7)
N,M = map(int,input().split())
R = [[] for _ in range(N)]
ans = np.zeros(N,dtype=int)
ans[0] = 1
queue = [1]
for _ in range(M):
    i,j = map(int,input().split())
    R[i-1].append(j)
    R[j-1].append(i)
    
def bfs(que):
    if que==[]:
        return
    i = que[0]
    for j in R[i-1]:
        if ans[j-1]==0:
            ans[j-1]=i
            que.append(j)
    que.pop(0)
    bfs(que)
    
bfs(queue)
print('Yes')
for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 130232
#include<bits/stdc++.h>
using namespace std;
int N,M,K;
int a[20],b[20];


int main(){
  cin>>N>>M>>K;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
  }

  b[N]=b[N+1]=b[N+2]=M;
  
  int ans=M;


  for(int i=0;i<N+3;i++){
    for(int j=0;j<N+3;j++){
      if(i==j)continue;
      for(int k=0;k<N+3;k++){
        if(i==k||j==k)continue;
        int tmp=M;

        int ai=min(tmp,b[i]);
        tmp-=ai;
        if(K>=1){
          int value = tmp + ai*a[i];
          ans=max(ans, value );
        }
        
        int aj=min(tmp,b[j]);
        tmp-=aj;
        if(K>=2){
          int value = tmp + ai*a[i] + aj*a[j];
          ans=max(ans, value );
        }
        
        int ak=min(tmp,b[k]);
        tmp-=ak;
        if(K==3){
          int value = tmp + ai*a[i] + aj*a[j] + ak*a[k];
          ans=max(ans, value );
        }

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

Measured memory_bytes: 3104
W, H, N = map(int, input().rstrip().split())
xya = [list(map(int, input().rstrip().split())) for _ in range(N)]
xy = [[0]*H for _ in range(W)]
for i in xya:
    x_y = i[:2]
    a = i[2]
    if a == 1:
        for j in range(x_y[0]):
            xy[j] = list(map(lambda x: x+1, xy[j]))
    elif a == 2:
        for j in range(x_y[0],W):
            xy[j] = list(map(lambda x: x+1, xy[j]))
    elif a == 3:
        y = x_y[1]
        for j in range(W):
            for k in range(H):
                xy[j][k] += 1 if k < y else 0  
    else:
        y = x_y[1]
        for j in range(W):
            for k in range(H):
                xy[j][k] += 1 if k >= y else 0
area = 0
for i in xy:
    area += i.count(0)
print(area)

Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

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

signed main(){
	int n; cin>>n;
	cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int W, H, N;
	cin >> H >> W >> N;
	int up = max(H, W);
	cout << (N + up - 1) / up << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[102][100004];
int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n+1],v[n+1];
	for (ll i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	for (ll i=0;i<=W;i++)
		dp[0][i]=0;
	for (ll i=0;i<=n;i++)
		dp[i][0]=0;
	ll ans=INT_MIN;
	for (ll i=1;i<=n;i++)
	{
		for (ll j=1;j<=W;j++)
		{
			if (w[i]<=j)
				dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
			else
				dp[i][j]=dp[i-1][j];
		ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 79104
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
agc012 C
"""


n, m = map(int, input().split())

graph = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

q = int(input())
qlist = [tuple(map(int, input().split())) for i in range(q)]
qlist.reverse()

dp = [[-1]*11 for i in range(n+1)]
col = [0]


def updatedp(v, t, d):
    if dp[v][d] == -1:
        for i in range(d+1):
            if dp[v][i] == -1:
                dp[v][i] = t
        if d > 0:
            for u in graph[v]:
                updatedp(u, t, d-1)


t = 0
for v, d, c in qlist:
    col.append(c)
    updatedp(v, t, d)
    t += 1

for i in range(1, n+1):
    print(col[dp[i][0]+1])


Measured memory_bytes: 53508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
 
int main () {
   IO;
   int a, b;
   cin >> a >> b;
   cout << (a ^ b);
   return 0;
}

Measured memory_bytes: 256
Acard = input()
Bcard = input()
Ccard = input()
nex  = "a"
result = "non"
for i in range(len(Acard+Bcard+Ccard)):
    if nex == "a":
        if len(Acard)==0:
            result = "A"
            break
        else:
            nex = Acard[0]
            Acard = Acard[1:len(Acard)]
    if nex == "b":
        if len(Bcard)==0:
            result = "B"
            break
        else:
            nex = Bcard[0]
            Bcard = Bcard[1:len(Bcard)]
    if nex == "c":
        if len(Ccard)==0:
            result = "C"
            break
        else:
            nex = Ccard[0]
            Ccard = Ccard[1:len(Ccard)]
print(result)

    

Measured memory_bytes: 3064
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;

ll lucas(int n) {
  ll N[90];
  N[0] = 2;
  N[1] = 1;

  rep(i,2,n) {
    N[i] = N[i-2] + N[i-1];
  }

  return N[n];
}

int main() {
  int N;
  cin >> N;
  cout << lucas(N) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(long long n) {
	if (n < 10)return 1;
	return func(n/10)+1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,T,t[200010],x;
	scanf("%d %d", &n, &T);
	REP(i, n) {
		scanf("%d", &t[i]);
	} 
	x = T;
	REP(i, n-1) {
		x += min(t[i+1]-t[i],T);
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> q = new ArrayDeque<Integer>();
		while(sc.hasNext()) {
			int t = sc.nextInt();
			if(t != 0) {
				q.addFirst(t);
			}else {
				System.out.println(q.pollFirst());
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26296
import sys
sys.setrecursionlimit(303)


def doit(n, k, m):
    if len(n) == 0 or k < 0:
        return k == 0
    if (n, k) not in m:
        d = int(n[0])
        m[(n, k)] = sum(doit(n[1:] if i == d else '9' * (len(n) - 1), k - 1 if i > 0 else k, m) for i in range(d + 1))
    return m[(n, k)]


print(doit(input(), int(input()), {}))


Measured memory_bytes: 9216
def calc(w, a, b):
	a_max = a + w
	b_max = b + w
	
	if b > a_max:
		return b - a_max
	elif a > b_max:
		return a - b_max
	else:
		return 0

inpt = raw_input().split()

w = int(inpt[0])
a = int(inpt[1])
b = int(inpt[2])

print calc(w, a, b)

Measured memory_bytes: 2568
// C.

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <numeric>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<string, string> SS;

static inline int popcount(unsigned int b) {
#ifdef __GNUC__
	return __builtin_popcount(b);
#elif _MSC_VER >= 1400
	return __popcnt(b);
#else
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
#endif
}

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int bm = 1 << n;
	map<SS, LL> m[19];
	for (int b = 0; b < bm; ++b) {
		string x[2];
		for (int i = 0, j = 1; i < n; ++i, j <<= 1) {
			if (j & b) {
				x[0] += s[i];
			} else {
				x[1] = s[i] + x[1];
			}
		}
		m[popcount(b)][SS(x[0], x[1])] += 1;
	}
	LL ans = 0;
	for (int b = 0; b < bm; ++b) {
		string x[2];
		for (int i = 0, j = 1; i < n; ++i, j <<= 1) {
			if (j & b) {
				x[0] += s[2 * n - i - 1];
			} else {
				x[1] = s[2 * n - i - 1] + x[1];
			}
		}
		ans += m[popcount(b)][SS(x[0], x[1])];
	}
	cout << ans << endl;
}


Measured memory_bytes: 87040
d,n=map(int,input().split())
if d==0:
    if n==100:
        print(101)
        exit()
    print(n)
elif d==1:
    if n==100:
        print(n*101)
        exit()
    print(n*100)
else:
    if n==100:
        print(n*10100)
        exit()
    print(n*10000)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pri 1000000007 
using namespace std;

int main() {
ll q;
cin>>q;
 priority_queue <ll>   s1;
  priority_queue <ll, vector<ll>, greater<ll> > s2; 
ll me,sum1=0,sum2=0,co=0,sz=0,d;
for(ll i=0;i<q;i++){
	ll c;
	cin>>c;
	ll ans=0;
	
	if(c==1){
		ll a,b;
		cin>>a>>b;
		co+=b;
		if(sz%2==0){
			if(sz==0)d=a;
			else{
				if(s1.top()>=a){d=s1.top();s1.pop();s1.push(a);sum1+=(a-d);}
				else if(s2.top()<=a){
					d=s2.top();s2.pop();s2.push(a);sum2+=(a-d);
				}
				else{
					d=a;
				}
			}
		}
		else{
			if(a>=d){
				s1.push(d);
				s2.push(a);
				sum1+=d;
				sum2+=a;
			}
			else{
				s1.push(a);
				s2.push(d);
				sum1+=a;
				sum2+=d;
			}
			
		}
		
		sz++;
	}
	else{
		if(sz%2==0){
			ll f=s1.top();
			ll x=sum2-sz/2*f;
			ll y=sz/2*f-sum1;
			cout<<f<<" "<<x+y+co<<endl;
			
		}
		else{
			ll f=d;
			ll x=sum2-sz/2*f;
			ll y=sz/2*f-sum1;
			cout<<f<<" "<<x+y+co<<endl;
			
			
		}
	}
	
	
}

	// your code goes here
	return 0;
}

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

int main(){
  int n,array[100],ans=0;
  vector<int> not10;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
    if(array[i]%10){
      not10.push_back(array[i]);
    }
    ans+=array[i];
  }
  if(ans%10){
    cout<<ans<<endl;
    return 0;
  }
  if(not10.size()==0){
    cout<<0<<endl;
    return 0;
  }
  sort(not10.begin(),not10.end());
  cout<<ans-not10[0]<<endl;
}
    

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

int top=0,S[1000000];

void push(int a){
    S[top]=a;
    top++;
}

int pop(){
    top--;
    return S[top];
}

int main(){
    int a,b;
    char s[1000000];
    while(scanf("%s",s)!=EOF){

        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }

        else if(s[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }

        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }

        else push(atoi(s));

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


Measured memory_bytes: 2752
l = list(map(int, input().split()))

counter5 = 0
counter7 = 0

for num in l:
    if num == 5:
        counter5+=1
    
    if num == 7:
        counter7+=1

if counter5 == 2 and counter7 == 1:
    print("YES")

else:
    print("NO")

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int dr[] = {1, -1, 0, 0};
int dc[] = {0, 0, 1, -1};

int main() {
  rd(int, h, w);
  V<string> s(h);
  rep(r, h) cin >> s[r];
  VV<bool> b(h + 2, V<bool>(w + 2));
  rep(r, h) rep(c, w) b[r + 1][c + 1] = s[r][c] == '#';
  rep(r, h) rep(c, w) if (b[r + 1][c + 1]) {
    bool ok = false;
    rep(i, 4) if (b[r + 1 + dr[i]][c + 1 + dc[i]]) ok = true;
    if (!ok) {
      wt("No");
      return 0;
    }
  }
  wt("Yes");
}


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

class Team {
public:
  string name;
  int win;
  int id;
  Team(string name="", int win=0, int id=0) : name(name), win(win), id(id) {}
  bool operator <(const Team &t) const {
    if(win == t.win) return id > t.id;
    else             return win < t.win;
  }
};

int main() {
  bool first = true;
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    Team tm[n];
    for(int i = 0; i < n; i++) {
      int a, b, c;
      cin >> tm[i].name >> a >> b >> c;
      tm[i].win = a*3 + b*0 + c*1;
      tm[i].id = i;
    }
    sort(&tm[0], &tm[n-1]+1);

    if(!first) {
      cout << endl;
    } else {
      first = false;
    }
    for(int i = n-1; i >= 0; i--) {
      cout << tm[i].name << ',' << tm[i].win << endl;
    }

  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for(int i=0; i<M; i++){
    cin >> s[i] >> c[i];
    s[i]--;
  }
  
  int ans = -1;
  vector<int> v(N, -1);
  bool b = true;
  for(int i=0; i<M; i++){
    if(v[s[i]] == -1 || v[s[i]] == c[i]){
      v[s[i]] = c[i];
    }else{
      b = false;
      break;
    }
  }
  if(N>1 && v[0]==0) b=false;
  
  if(b){
    string tmp = "";
    for(int i=0; i<N; i++){
      if(v[i] == -1){
        if(i==0){
          v[i] = 1;
        }else{
          v[i] = 0;
        }
      }
      tmp += to_string(v[i]);
    }
    ans = stoi(tmp);
    if(N==1 && M==0) ans = 0;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    float L=0.0d;
    float dif=0.0000000f;
    float answer=0.0f;
    bool flg=false;
    cin>>L;     
    cout<<fixed << setprecision(15) <<L*L*L/27<<endl;

    return 0;
}

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

int main(void) {
	int N;
	string s;
	cin >> N;
	int date[5] = { 0 };
	long int ans=0;
	for (int i = 0;i < N;i++) {
		cin >> s;
		if (s[0] == 'M') {
			date[0]++;
		}
		if (s[0] == 'A') {
			date[1]++;
		}
		if (s[0] == 'R') {
			date[2]++;
		}
		if (s[0] == 'C') {
			date[3]++;
		}
		if (s[0] == 'H') {
			date[4]++;
		}
	}
	sort(date,date+4);
	int v = 0;
	int flag[10][5] = {
		{1,1,1,0,0},
		{ 1,1,0,1,0 },
		{ 1,0,1,1,0 },
		{ 0,1,1,1,0 },
		{ 1,1,0,0,1 },
		{ 1,0,1,0,1 },
		{ 0,1,1,0,1 },
		{ 1,0,0,1,1 },
		{ 0,1,0,1,1 },
		{ 0,0,1,1,1 },
	};
	for (int i = 0;i < 10;i++) {
		long int v = 1;
		for (int j = 0;j < 5;j++) {
			if (flag[i][j] == 1)
				v *= date[j];
		}
		ans += v;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;
typedef pair<double,double> P;
int b[19][19];


int main(){
	
	map<string,string> ec;
	map<string,string> dc;
	
	ec[" "]="101";
	ec["'"]="000000";
	ec[","]="000011";
	ec["-"]="10010001";
	ec["."]="010001";
	ec["?"]="000001";
	ec["A"]="100101";
	ec["B"]="10011010";
	ec["C"]="0101";
	ec["D"]="0001";
	ec["E"]="110";
	ec["F"]="01001";
	ec["G"]="10011011";
	ec["H"]="010000";
	ec["I"]="0111";
	ec["J"]="10011000";
	ec["K"]="0110";
	ec["L"]="00100";
	ec["M"]="10011001";
	ec["N"]="10011110";
	ec["O"]="00101";
	ec["P"]="111";
	ec["Q"]="10011111";
	ec["R"]="1000";
	ec["S"]="00110";
	ec["T"]="00111";
	ec["U"]="10011100";
	ec["V"]="10011101";
	ec["W"]="000010";
	ec["X"]="10010010";
	ec["Y"]="10010011";
	ec["Z"]="10010000";
	
	dc["00000"]="A";
	dc["00001"]="B";
	dc["00010"]="C";
	dc["00011"]="D";
	dc["00100"]="E";
	dc["00101"]="F";
	dc["00110"]="G";
	dc["00111"]="H";
	dc["01000"]="I";
	dc["01001"]="J";
	dc["01010"]="K";
	dc["01011"]="L";
	dc["01100"]="M";
	dc["01101"]="N";
	dc["01110"]="O";
	dc["01111"]="P";
	dc["10000"]="Q";
	dc["10001"]="R";
	dc["10010"]="S";
	dc["10011"]="T";
	dc["10100"]="U";
	dc["10101"]="V";
	dc["10110"]="W";
	dc["10111"]="X";
	dc["11000"]="Y";
	dc["11001"]="Z";
	dc["11010"]=" ";
	dc["11011"]=".";
	dc["11100"]=",";
	dc["11101"]="-";
	dc["11110"]="'";
	dc["11111"]="?";
	
	string s;
	while(getline(cin,s)){
	
	string temp="";
	for(int i=0;i<s.size();i++){
		temp+=ec[s.substr(i,1)];
	}
	
	while(temp.size()%5!=0)
		temp+='0';
	
		string ans="";
		for(int i=0;i+5<=temp.size();i=i+5){
			ans+=dc[temp.substr(i,5)];
		}
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 3096
<?php
fscanf(STDIN, '%d', $cnt);
fscanf(STDIN, '%s', $str);
$arr = str_split($str);
$now = $arr[0];
$ans = 1;
for ($i=1; $i < $cnt; $i++) { 
    if ($arr[$i] !== $now) {
        $ans++;
        $now = $arr[$i];
    }
}
echo $ans;

Measured memory_bytes: 10872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<int> b(n - 1);
	for(int i = 0; i + 1 < n; ++i){
		if(a[i] < a[i + 1]){
			b[i] = 1;
		}else if(a[i] > a[i + 1]){
			b[i] = -1;
		}else{
			b[i] = 0;
		}
	}
	vector<int> c;
	for(int i = 0; i + 1 < n; ++i){
		if(i == 0 || b[i] != b[i - 1]){ c.push_back(b[i]); }
	}
	const int m = c.size();
	int answer[5] = { 0 };
	for(int i = 0; i + 2 < m; ++i){
		if(c[i] > 0 && c[i + 1] == 0 && c[i + 2] < 0){ ++answer[0]; }
		if(c[i] < 0 && c[i + 1] == 0 && c[i + 2] > 0){ ++answer[1]; }
		if(c[i] > 0 && c[i + 1] == 0 && c[i + 2] > 0){ ++answer[2]; }
		if(c[i] < 0 && c[i + 1] == 0 && c[i + 2] < 0){ ++answer[2]; }
	}
	for(int i = 0; i + 1 < m; ++i){
		if(c[i] > 0 && c[i + 1] < 0){ ++answer[3]; }
		if(c[i] < 0 && c[i + 1] > 0){ ++answer[4]; }
	}
	cout << answer[0] << " ";
	cout << answer[1] << " ";
	cout << answer[2] << " ";
	cout << answer[3] << " ";
	cout << answer[4] << endl;
	return 0;
}


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

class Main {
	int N;
	int C;
	int[] L;

	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		C = sc.nextInt();
		L = new int[N];
		for (int i = 0; i < N; ++i) {
			L[i] = sc.nextInt();
		}
		Arrays.sort(L);
		int[] ord = new int[N - 1];
		for (int i = 0; i < ord.length; ++i)
			ord[i] = i;

		double ans = 0;
		long[][] dp = new long[N * C + 1][1 << N - 1];
		do {
			for (int i = 0; i < dp.length; ++i)
				for (int j = 0; j < dp[i].length; ++j)
					dp[i][j] = 0;
			dp[L[N - 1] * N - 1][0] = 1;
			for (int i = 0; i < N * C; ++i) {
				if (i % N == 0)
					continue;
				for (int s = 0; s < 1 << N - 1; ++s) {
					for (int j = i - 1; j <= N * C; ++j) {
						if ((s >> i % N - 1) % 2 == 0) {
							dp[Math.min(N * C, Math.max(j, L[ord[i % N - 1]] * N + i - 1))][s
									^ (1 << i % N - 1)] += dp[j][s];
						}
					}
				}
			}
			ans += dp[N * C][(1 << N - 1) - 1];
		} while (nextPermutation(ord));

		for (int i = 2; i <= N - 1; ++i) {
			ans /= i;
		}

		for (int i = 0; i < N - 1; ++i) {
			ans /= C;
		}

		System.out.printf("%.40f", ans);
	}

	boolean nextPermutation(int[] ord) {
		int n = ord.length;
		int i = n - 1;
		while (i > 0 && ord[i - 1] > ord[i])
			--i;
		if (i == 0)
			return false;
		int j = i;
		while (j + 1 < n && ord[i - 1] < ord[j + 1])
			++j;
		{
			ord[i - 1] ^= ord[j];
			ord[j] ^= ord[i - 1];
			ord[i - 1] ^= ord[j];
		}
		int s = i;
		int t = n - 1;
		while (s < t) {
			ord[s] ^= ord[t];
			ord[t] ^= ord[s];
			ord[s] ^= ord[t];
			++s;
			--t;
		}
		return true;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 25124
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int x,n;
  cin>>x>>n;
  vector<long long int> p(n);
  map<long long int,long long int> hoge;
  long long int sa=999999999;
  long long int ans;
  for(long long int i=0; i<n; i++){
    cin>>p.at(i);
    hoge[p.at(i)]++;
  }

  for(long long int i=-1000; i<=1000; i++){
    if(hoge.count(i)==false){
      if(abs(x-i)<sa){
        sa=abs(x-i);
        ans=i;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  rep(k,2) {
    rep(l,2) {
      int a[n];
      memset(a,-1,sizeof(a));
      a[0]=k;
      a[1]=l;
      string t="";
      REP(i,1,n+4) {
        if(a[(i+1)%n]!=-1) {
          if(s[i%n]=='o') {
            if(a[i%n]&&a[(i-1+n)%n]==a[(i+1)%n]) goto next;
            if(!a[i%n]&&a[(i-1+n)%n]!=a[(i+1)%n]) goto next;
          } else {
            if(a[i%n]&&a[(i-1+n)%n]!=a[(i+1)%n]) goto next;
            if(!a[i%n]&&a[(i-1+n)%n]==a[(i+1)%n]) goto next;
          }
        }
        if(s[i%n]=='o') {
          if(a[i%n]) a[(i+1)%n]=a[(i-1+n)%n]^1;
          else a[(i+1)%n]=a[(i-1+n)%n];
        } else {
          if(a[i%n]) a[(i+1)%n]=a[(i-1+n)%n];
          else a[(i+1)%n]=a[(i-1+n)%n]^1;
        }
      }
      rep(i,n) {
        if(a[i]) t+='W';
        else t+='S';
      }
      pr(t);
      return;
    next:;
    }
  }
  pr(-1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1104
#include <stdio.h>
int main(){
	int a,b,c,d,t,time;
	scanf("%d%d%d%d",&a,&b,&c,&d);

	if(a<=c){
		if(b>=d)
			time=d-c;	
		else if(b<=c)
			time=0; 
		else if(b>c)
			time=b-c;	
	}
	if(a>c){
		t=a;
		a=c;
		c=t;
		t=b;
		b=d;
		d=t;
		if(b>=d)
			time=d-c;	
		else if(b<=c)
			time=0; 
		else if(b>c)
			time=b-c;		
	}
	printf("%d",time);
	
	
	
	
	
	
	
	return 0;
} 

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

int N;
vector<ll> A;
vector<vector<int> > G;

//vからたどる。親はp
ll dfs(int v, int p) {
    if (G[v].size() == 1) {
        return A[v];
    }
    ll ret = 2 * A[v];

    vector<ll> child;

    for (auto e : G[v]) {
        if (e != p) {
            child.push_back(dfs(e, v));
            ret -= child.back();
        }
    }

    if (ret < 0) {
        cout << "NO" << endl;
        exit(0);
    }

    if (ret > A[v]) {
        cout << "NO" << endl;
        exit(0);
    }


    ll max_child = *max_element(all(child));
    ll parent = A[v];
    if(max_child > parent){
        cout << "NO" << endl;
        exit(0);
    }


    return ret;
}

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

    cin >> N;
    A.resize(N);
    G.resize(N);

    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if (N == 2) {
        if (A[0] == A[1]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    }

    int root = -1;
    for (int i = 0; i < N; ++i) {
        if (G[i].size() > 1) {
            root = i;
            break;
        }
    }
    if (root == -1) {
        return -1;
    }

    ll val = dfs(root, -1);

    if (val == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 17152
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int need[MAXN];
int main()
{
	int n,q;
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		ans+=a;
		need[a]++;
	}
	scanf("%d",&q);
	while(q--)
	{
		int b,c;
		scanf("%d %d",&b,&c);
		int x=c-b;
		ans+=(1ll*x*need[b]);
		need[c]+=need[b];
		need[b]=0;
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  vector<pair<int,int>> vec(n);
  for(i=0;i<n;i++){
    int a;
    cin >> a;
    vec.at(i)=make_pair(a,i+1);
  }
  int count=0;
  for(i=0;i<n;i++){
    if(vec.at(vec.at(i).first-1).first==vec.at(i).second){
      count++;
    }
  }
  cout << count/2;
}

Measured memory_bytes: 1024