akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<63)-1
#define MAX 1000000000
signed main(){
    int N; cin>>N;
    vii A(N,vi(N));
    int me=1;
    REP(k,1,60){
        rep(i,0,N-1){
            rep(j,i+1,N){
                int X=j-i;
                if(X%me==0&&X/me%2==1) A[i][j]=k;
            }
        }
        me*=2;
    }
    rep(i,0,N-1){
        rep(j,i+1,N) cout<<A[i][j]<<" ";
        cout<<endl;
    }
}

Measured memory_bytes: 2432
import java.util.*;

class Main {
	static final int[] P;
	static {
		List<Integer> primes = new ArrayList<>();
		for (int i = 2; i <= 1000; i++) {
			int n = (int)Math.sqrt(i);
			int j = 2;
			for (; j <= n; j++) if (i%j == 0) break;
			if (j > n) primes.add(i);
		}
		P = new int[primes.size()];
		for (int i = 0; i < P.length; i++) P[i] = primes.get(i);
		
	}
	Scanner sc;
	int N;
	int[] A;
	int[][] F;
	static final int MOD = 1000_000_007;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		for (int i = 0; i < N; i++) A[i] = sc.nextInt();
		Map<Integer, Integer> lcmf = new HashMap<>();
		for (int i = 0; i < N; i++) {
			int a = A[i];
			for (int j = 0; j < P.length; j++) {
				int p = P[j];
				int c = 0;
				while (a%p == 0) {
					a /= p;
					c++;
				}
				if (c > 0) lcmf.put(p, Math.max(c, lcmf.getOrDefault(p, 0)));
				if (p*p > A[i]) break;
			}
			if (a > 1) lcmf.put(a, Math.max(1, lcmf.getOrDefault(a, 0)));
		}
		long lcm = 1;
		for (int p : lcmf.keySet()) {
			int c = lcmf.get(p);
			for (int i = 0; i < c; i++) lcm = (lcm * p)%MOD;
		}
		
		long ans = 0;
		for (int i = 0; i < N; i++) {
			long b = lcm * inv(A[i]) % MOD;
			ans = (ans + b) % MOD;
		}
		System.out.println(ans);
	}
	
	private static long inv(long a) {
		long b = MOD;
		long aa = a, bb = b;
		long x0 = 1, x1 = 0;
		long y0 = 0, y1 = 1;
	
		while (b != 0) {
			long q = a / b;
			long r = a % b;
			long x2 = x0 - q * x1;
			long y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
		if (bb > 0 && x0 < 0) {
			long n = -x0/bb;
			if (-x0%bb != 0) n++;
			x0 += n*bb; y0 -= n*aa;
		}
	    return x0;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

using namespace std;

inline int read() {
	int f = 1;
	int x = 0;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) {
		f = (ch == '-') ? -1 : 1;
	}
	for (; isdigit(ch); ch = getchar()) {
		x = x * 10 + ch - '0';
	}
	return f * x;
}

const int N = 100 + 5;

long long a[N];

int main() {
	int n = read();
	long long x = read();
	for (int i = 0; i < n; ++i) {
		a[i] = read();
	}
	sort(a, a + n);
	int tot = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (x >= a[i]) {
			x -= a[i];
			++tot;
		} else {
			break;
		}
	}
	if (a[n - 1] == x) {
		++tot;
	}
	cout << tot << endl;
	return 0;
}

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

int main() {
    int N;
    std::cin >> N;
    std::vector<long long int> A(N);
    long long int sum = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
        sum += A[i];
    }
    sum /= 2;

    for (int i = 0; i < N; i++) {
        long long int val = 0;
        for (int j = i; j < N; j += 2) {
            val += A[j];
        }
        for (int j = i - 1; j >= 0; j -= 2) {
            val += A[j];
        }
        std::cout << (val - sum) * 2;
        if (i < N - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3960
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, a[1010], b[1010], c[1010];
int dp[1010][4500];
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		int in;
		rep(j, b[i]) {
			cin >> in;
			in--;
			c[i] += ((ll)1 << in);
		}
	}
	rep(i, m + 1) {
		rep(j, ((ll)1 << n))dp[i][j] = INF;
	}
	dp[0][0] = 0;
	rep(i, m) {
		rep(j, ((ll)1 << n)) {
			dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	if (dp[m][((ll)1 << n) - 1] == INF)cout << -1 << endl;
	else cout << dp[m][((ll)1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 35456
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = [int(raw_input().strip()) for _ in xrange(N)]

orderN(N,L,ices)

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

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

const long long MOD = 1000000007;

int main(){
  int n,a;
  int ma=0;
  string s;
  set<string> st;
  map<string , int> cnt;
  cin >> n;
  rep(i,n){
    cin >> s;
    if(cnt.count(s)) cnt.at(s)++;
    else{
      st.insert(s);
      cnt[s]=0;
    }
    if(cnt.at(s) > ma) ma=cnt.at(s);
  }
  
  for (auto s : st) {
    if(cnt.at(s)== ma) cout << s <<endl;
  }
}


Measured memory_bytes: 34560
#include <iostream>

using namespace std;
int main(){
        int N;
        int H;

        cin >> N;
        cin >> H;
        int cnt = 0;
        int max_cnt = 0;
        int prev = H;
        for(int i=1;i<N; ++i){
                cin >> H;
                //cout << H << endl;
                if(prev >= H){
                        cnt++;
                        //cout << "ADD" << endl;
                }else{
                        if(max_cnt < cnt) max_cnt = cnt;
                        cnt = 0;
                }
                prev = H;
        }
        if(max_cnt < cnt) max_cnt = cnt;
        cout << max_cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  int a = 0, b = 0, ab = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    if(*s[i].begin() == 'B' && *s[i].rbegin() == 'A') {
      ab++;
    } else if(*s[i].begin() == 'B') {
      b++;
    } else if(*s[i].rbegin() == 'A') {
      a++;
    }
    for(int j = 0; j < s[i].length() - 1; j++) {
      if(s[i][j] == 'A' && s[i][j + 1] == 'B') {
        ans++;
      }
    }
  }
  if(ab >= 1) {
    ans += ab - 1;
    if(a >= 1) {
      ans++;
      a--;
    }
    if(b >= 1) {
      ans++;
      b--;
    }
  }
  ans += min(a, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

int main(int argc, char const *argv[]) {
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1e7 + 5;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}
int Fac[N];
int Inv[N];

int Ckn(int n,int k)    {
    if (n < k)  return  0;
    if (k < 0)  return  0;

    return  mul(Fac[n],mul(Inv[k],Inv[n - k]));
}
int cal(int n,int m)    {
    if (n < m)  return  0;

    int ans = 0;

    add(ans,Ckn(n + m,m));
    sub(ans,Ckn(n + m,n + 1));

    return  ans;
}

typedef pair<int,int>   ii;

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int n;  cin >> n;
    int A;  cin >> A;
    int B;  cin >> B;

    if (A == 0 && B == 0)   {
        cout << 1;
        return  0;
    }
    int ans = 0;

    for(int i = 0 ; i < B && i < n - B && i <= A ; ++i)
        add(ans,mul(Ckn(A - i + n - B - i - 1,n - B - i - 1),cal(B - 1,i)));

    if (A + B == n)
        add(ans,cal(B - 1,A));

    cout << ans << endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<long long>A(N+1);
  vector<long long>B(N);
 for (int i=0;i<N+1;i++){
   cin >>A.at(i);
  }
 for (int i=0;i<N;i++){
    cin >>B.at(i);
  }
  long long s;
 for (int i=0;i<N;i++){
   if (A.at(i)>=B.at(i)){
     s+= B.at(i);
     B.at(i)=0;
   }
   if  (A.at(i)<B.at(i)){
      s+= A.at(i);
    B.at(i)-=A.at(i);
     if (A.at(i+1)<B.at(i)){
       s+=A.at(i+1);
       A.at(i+1)=0;
     }
     if (A.at(i+1)>=B.at(i)){
       s+=B.at(i);
       A.at(i+1)-=B.at(i);
     }
  }

 }
cout<<s<<endl;
}
         
     
       
     
     
      
         

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

#define MAXN 100003

int abs(int z)
{
    if (z<0)
        return -z;
    else
        return z;
}

int main(void)
{
    int N,i,j;
    int h[MAXN], p[MAXN];
    scanf("%d",&N);
    for (i=0;i<N;i++)
    {
        scanf("%d",h+i);
    }
    p[N-1]=0;
    p[N-2]=abs(h[N-2]-h[N-1]);
    for(i=N-3;i>=0;i--)
    {
        p[i]=min(p[i+1]+abs(h[i]-h[i+1]),p[i+2]+abs(h[i]-h[i+2]));
    }
    printf("%d\n",p[0]);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int n;
string s,name;
 
string solve();
 
int main(){
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> name >> s;
        cout << solve() << endl;
    }
    return 0;
}
 
string solve(){
    reverse(name.begin(),name.end());
    int nsize = name.size(), ssize = s.size(), half = s.size() / 2;
    for(int i = 0;i < nsize;++i){
        string tmp;
        switch(name[i]){
            case 'J':
                tmp = s[ssize-1] + s;
                tmp.pop_back();
                s = tmp;
                break;
            case 'C':
                for(int j = 1;j < ssize;++j)tmp += s[j];
                tmp += s[0];
                s = tmp;
                break;
            case 'E':
                for(int j = 0;j < half;++j)tmp += s[half + ssize % 2 + j];
                if(ssize%2)tmp += s[half];
                for(int j = 0;j < half;++j)tmp += s[j];
                s = tmp;
                break;
            case 'A':
                reverse(s.begin(),s.end());
                break;
            case 'P':
                for(int j = 0;j < ssize;++j)
                    if(s[j] >= '0' && s[j] <= '9')
                        s[j] = '0' + (s[j] - '0' + 9) % 10;
                break;
            case 'M':
                for(int j = 0;j < ssize;++j)
                    if(s[j] >= '0' && s[j] <= '9')
                        s[j] = '0' + (s[j] - '0' + 1) % 10;
                break;
            default:
                assert(0);
                break;
        }
    }
    return s;
}



Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int connectedNum(Graph g, int s) {
  int n = g.size();
  if (n <= 1) return true;
  vector<bool> visited(n);
  priority_queue<int> Q;
  int res = 0;
  for (Q.push(s); !Q.empty(); ) {
    int now = Q.top(); Q.pop();
    if (visited[now]) continue;
    visited[now] = 1;
    res++;
    FOR(f,g[now])
      if (!visited[f->dst])
        Q.push(f->dst);
  }
  return res;
}

int main() {
  int n;
  
  while(cin >> n, n) {
    Graph g(26);
    vector<int> v(26);              // m[hi Ìü
    set<int> se;
    REP(i, n) {
      string s;
      cin >> s;
      int a = s[0]-'a';
      int b = s[s.size()-1]-'a';
      g[a].push_back(Edge(a,b,1));
      v[b]++;
      se.insert(a);
      se.insert(b);
    }
    bool f = 0;
    int ma = 0;
    FOR(it, se) {
      ma = max(ma, connectedNum(g, *it));
    }
    if (ma == se.size()) {
      FOR(it, se) {
        if( g[*it].size() != v[*it] ) {
          f = 1;
          break;
        }
      }
    } else f = 1;
    if (f) cout <<"NG" <<endl;
    else cout << "OK" << endl;
  }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  tree_order_statistics_node_update>  ordered_set; 
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (long double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[100005];
void power()
{
    powe[0]=1;
    REP(i,1,100005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vll adj;
    ll waysblack;
    ll wayswhite;
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll tot=0;
    tot = min(a,k);
    k-=a;
    if(k>0)
    {
        k-=b;
    }
    if(k>0)
    {
        tot-=k;
    }
    cout<<tot<<"\n";
    return 0;
}




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

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

inline void Main() {
  // code
  int n;
  cin >> n;
  cout << (int)pow(n, 3) << endl;
}

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


Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    dump(A)

    D = []
    for i in range(1, len(A)):
        D.append(A[i] - A[i-1])
    D.sort()
    dump(D)

    if N>=M:
        print(0)
        return
    else:
        res = 0
        for i in range(M-N):
            res += D[i]
        print(res)


    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 123428
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 300;
typedef long long LL;
int H, W, D, q, l, r;
LL res[maxn * maxn + 10];
struct NOOD {
	int x, y;
}num[maxn * maxn + 10];
int main() {
	scanf("%d%d%d", &H, &W, &D);
	for(int i = 1; i <= H; i++)
		for(int j = 1; j <= W; j++) {
			int a;
			scanf("%d", &a);
			num[a].x = i, num[a].y = j;
		}
	scanf("%d", &q);
	if(D == 1) {
		res[1] = 0;
		for(int i = 2; i <= H * W; i++)
			res[i] = res[i - 1] + abs(num[i].x - num[i - 1].x) + abs(num[i].y - num[i - 1].y);
		while(q--) {
			scanf("%d%d", &l, &r);
			printf("%lld\n", res[r] - res[l]);
		}
	}
	else {
		LL sum;
		while(q--) {
			scanf("%d%d", &l, &r);
			sum = 0;
			l += D;
			for(int i = l; i <= r; i += D) {
				sum += (abs(num[i].x - num[i - D].x) * 1LL + abs(num[i].y - num[i - D].y) * 1LL);
			}
			printf("%lld\n", sum);
		}
	}
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans=Integer.MAX_VALUE;
        int s1=n/6,s2=n/9;
        int[] TS=new int[n+10];
        int[] TN=new int[n+10];
        for (int i = 0; i <= n; i+=6) {
            int temp=i;
            while (temp/6>0){
                temp/=6;
                TS[i]+=temp%6;
            }
            for (int j = 0; j < 6; j++) {
                if(i+j<=n)TS[i+j]=TS[i]+j;
            }
        }
        for (int i = 0; i <= n; i+=9) {
            int temp=i;
            while (temp/9>0){
                temp/=9;
                TN[i]+=temp%9;
            }
            for (int j = 0; j < 9; j++) {
                if(i+j<=n)TN[i+j]=TN[i]+j;
            }
        }
        for (int i = 0; i <= s1; i++) {
            for (int j = 0; j <= s2; j++) {
                int six=6*i;
                int nine=9*j;
                if(i*6+j*9<=n){
                    ans=min(ans,TS[six]+TN[nine]+n-six-nine);
                }
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 23124
s = input()
t = s.replace("x", "")

flag = 1
for i in range(len(t)):
    if t[i] != t[~i]:
        flag = 0

if flag == 0:
    print(-1)
else:
    ans = 0
    t = s[::-1]
    c = 0
    for i in range(len(s)):
        if c >= len(t):
            if s[i] == "x":
                ans += 1
            continue
        if t[c] == s[i]:
            c += 1
            continue
        else:
            if s[i] == "x":
                ans += 1
                continue
            else:
                while t[c] == "x":
                    ans += 1
                    c += 1
                else:
                    c += 1
    ans += len(t) - c
    print(ans//2)


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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n,h,w;
	cin>>n>>h>>w;
	long long ans=0;

	for(long long i=0;i<n;i++){
		for(long long j=0;j<n;j++){
			if(i+h-1<n && j+w-1<n) ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


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

int N; string s;
void input()
{
    cin >> N >> s;
}

void solve()
{
    int white=0,red=0;
    for (int i = 0; i < N; ++i){
        if(s[i]=='R') ++red;
        else ++white;
    }
    int cnt = 0;
    for (int i = 0; i < red; ++i){
        if(s[i]=='R') ++cnt;
    }
    cout << red - cnt << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3776
a, b, c, x = 4.times.map{ gets.to_i }
count = 0
(a + 1).times { | i |
  (b + 1).times { | j |
    (c + 1).times { | k |
      sum = 500 * i + 100 * j + 50 * k
      if sum == x
        count += 1
      end
    }
  }
}
puts count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=100000;
const ll INF=1e18+7107;
int n,w[100005],v[100005],ans;
ll f[100005],T;
int main()
{
	scanf("%d%lld",&n,&T);
	for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=MX;i++) f[i]=INF;
	f[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=MX;j>=1;j--)
		{
			if(j>=v[i]) f[j]=min(f[j],f[j-v[i]]+w[i]);
		}
	}
	for(int i=1;i<=MX;i++) if(f[i]<=T) ans=max(ans,i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long c1[] = new long[10000];
    long c2[] = new long[10000];
    long a=Long.MAX_VALUE;
    int g = 0;
    
    for(long i=1;i<(long)Math.sqrt(n)+1;i++){
    	if(n%i==0){
        	c1[g]=i;
          	c2[g]=n/i;
          	g++;
        }
    }
    
    for(int j=0;j<g;j++){
      a = Math.min(a,c1[j]+c2[j]-2);
    }
    System.out.println(a);
  }
}


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

void Main() {
    // input
    int N, M;
    cin >> N >> M;
    int num[N];
    // 左から桁数が多い
    for (int i = 0; i < N; i++) {
        num[i] = -1;
    }
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if (num[s-1] == -1) {
            num[s-1] = c;
        } else {
            if (num[s - 1] != c) {
                cout << "-1" << endl;
                return;
            }
        }
    }
    if (num[0] == 0 && N > 1) {
        cout << -1 << endl;
        return;
    }
    if (num[0] == -1) {
        if (N ==1) {
            num[0] = 0;
        } else {
            num[0] = 1;
        }
    }
    for (int i = 0; i < N; i++) {
        if (num[i] == -1) {
            num[i] = 0;
        }
    } 
    
    // output
    for (int i = 0; i < N; i++) {
        cout << num[i];
    }
    cout << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
using System;

    class Program
    {
        static void Main(string[] args)
        {
            double r, circleArea, circumference;
            string num = Console.ReadLine();
            r = double.Parse(num);

            circleArea = r * r * 3.141592653589;
            circumference = r * 2 * 3.141592653589;

            Console.Write("{0:0.00000}", circleArea + " ");
            Console.WriteLine("{0:0.00000}", circumference);

        }
    }



Measured memory_bytes: 9308
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAKS 1000000000000000LL

using namespace std;

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

int ar[101010];

int main()
{
    ios::sync_with_stdio(false);
    int n,l;
    cin>>n>>l;
    int left=-1,right=-1;
    for(int ctr1=0;ctr1<n;ctr1++){
        cin>>ar[ctr1];
        if(ar[ctr1]>=l)
            left=ctr1,right=ctr1+1;
        if(ctr1>0 && ar[ctr1]+ar[ctr1-1]>=l){
            left=ctr1-1,right=ctr1+1;
        }
    }
    if(left==-1){
        cout<<"Impossible\n";
        return 0;
    }
    cout<<"Possible\n";
    for(int ctr1=1;ctr1<=left;ctr1++)
        cout<<ctr1<<"\n";
    for(int ctr1=n-1;ctr1>=right;ctr1--)
        cout<<ctr1<<"\n";
    if(right-left>1)
        cout<<left+1<<"\n";
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/11/2018
 
 16:10-16:15 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=40+1;
const int MAX_V=410;
int N,MA,MB;
int A[MAX_N],B[MAX_N],C[MAX_N];
int dp[MAX_N][MAX_V][MAX_V];
const int Inf=1e5;
LL gcd(LL a, LL b) { return b==0?a:gcd(b,a%b); }
void solve() {
  REPE(i,N)REP(a,MAX_V)REP(b,MAX_V)dp[i][a][b]=Inf;
  dp[0][0][0]=0;
  REP(i,N)REP(a,MAX_V)REP(b,MAX_V) {
    int va=A[i],vb=B[i],c=C[i];
    if(a+va<MAX_V&&b+vb<MAX_V)SMIN(dp[i+1][a+va][b+vb],dp[i][a][b]+c);
    SMIN(dp[i+1][a][b],dp[i][a][b]);
//    if(a+va==3&&b+vb==3) dump4(i,a,b,dp[i+1][a+va][b+vb]);
  }
  int res=Inf;
  REP(a,MAX_V)REP(b,MAX_V) {
    int g=gcd(a,b);
    if(g==0) continue;
//    dump3(a,b,g);
    int aa=a/g,bb=b/g;
    if(aa==MA&&bb==MB) SMIN(res,dp[N][a][b]);
  }
  cout<<(res>=Inf?-1:res)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>MA>>MB;
  REP(i,N) cin>>A[i]>>B[i]>>C[i];
  solve();
  return 0;
}


Measured memory_bytes: 27136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, K, Q;
ll M;
ll A[MAX], pdiff[2*MAX], ch[2*MAX];

int main()
{
	int i, j, k;
	scanf("%d%lld", &N, &M);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
	}
	ll tot = 0;
	for (i = 2; i <= N; ++i) {
		ll l = A[i - 1];
		ll r = A[i];
		if (l > r) r += M;
		tot += r - l;
		pdiff[l + 1]++;
		pdiff[r + 1]--;
		ch[r + 1] -= r - l;
	}
	
	for (i = 1; i <= 2 * M; ++i) {
		pdiff[i] += pdiff[i - 1];
		ch[i] += ch[i - 1] + pdiff[i];
	}
	ll mini = tot;
	for (i = 1; i <= M; ++i) mini = min(mini, tot - ch[i] - ch[i + M] + pdiff[i] + pdiff[i + M]);
	printf("%lld", mini);
}

Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String[] list = new String[N];
        int answer = 0;
        int firstmatchcount = 0;
        int lastmatchcount = 0;
        int bothmatchcount = 0;
        for (int i = 0; i < N; i++) {
            String temp = scan.next();
            list[i] = temp;
            char[] data = temp.toCharArray();
            if (data[0] == 'B' && data[data.length-1] != 'A') {
                firstmatchcount += 1;
            }
            if (data[0] != 'B' && data[data.length-1] == 'A') {
                lastmatchcount += 1;
            }
            if (data[0] == 'B' && data[data.length - 1] == 'A') {
                bothmatchcount += 1;
            }
            answer += countAB(data);
        }
        int add = 0;
        if (bothmatchcount == 0) {
            add = Math.min(firstmatchcount, lastmatchcount);
        } else {
            if (0 == firstmatchcount + lastmatchcount) {
                add = bothmatchcount - 1;
            } else {
                add = bothmatchcount+Math.min(firstmatchcount, lastmatchcount);
            }
        }
        answer += add;
        System.out.println(answer);
    }
    private static int countAB(char[] data) {
        int count = 0;
        boolean foundA = false;
        for(char c : data) {
            if (c == 'A') {
                foundA = true;
                continue;
            }
            if (!foundA) {
                continue;
            }
            if (c == 'B') {
                count += 1;
            }
            foundA = false;
        }
        return count;
    }
}


Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
#define int1 long long
#define mm 1000000007
#define nn 100005
int main() {
    int1 n, w;
    cin >> n >> w;
    int1 arr[n][2];
    int1 i, j;
    for (i = 0; i < n; i++) {
        cin >> arr[i][0] >> arr[i][1];
    }
    int1 dp[n][nn];
    for (i = 0; i < n; i++) {
        for (j = 0; j < nn; j++) {
            dp[i][j] = mm;
        }
    }
    for (i = 0; i < n; i++) {
        dp[i][0] = 0;
    }
    dp[0][arr[0][1]] = arr[0][0];
    for (i = 1; i < n; i++) {
        for (j = 1; j < nn; j++) {
            int a1, a2;
            a1 = mm;
            a2 = dp[i - 1][j];
            
            if (j - arr[i][1] >= 0 && dp[i-1][j - arr[i][1] != mm]) {
                a1 = arr[i][0] +dp[i-1][j-arr[i][1]];
            }
            dp[i][j] = min(a1, a2);
        }
    }
    int m = 1;

    for (i = 2; i < nn; i++) {
        if (dp[n-1][i]<=w) {
            m = i;
        }
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 78336
//default
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
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=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  string S;
  cin >> S;
  int ans[S.size()]={};
  int init=0,norm;
  rep(i,S.size()){
    if(S[i]=='L'){
      if(S[i-1]=='R'){
        norm=i;
      }
      if(S[i+1]=='R' || i+1==S.size()){
        if((norm-init)%2==0){
          ans[norm-1]=(i-init+1)/2;
          ans[norm]=i-init-ans[norm-1]+1;
        }
        else{
          ans[norm]=(i-init+1)/2;
          ans[norm-1]=i-init-ans[norm]+1;
        }
        init=i+1;
      }
    }

  }
  rep(i,S.size()-1){
    cout << ans[i] << " ";
  }
  cout << ans[S.size()-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
 
const int N = 2e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)4e18 + 5;

inline int mul(int a, int b){
    return ((ll)a * b) % mod;
}

inline int add(int a, int b){
    int ans = a + b;
    if(ans >= mod) ans -= mod;
    return ans; 
}

// credits : codeforces :https://codeforces.com/blog/entry/54396
bool isprime(ll n){
    if(n<2) return false;
    for(ll i=2;i*i*i<=n;++i) if(n%i==0) return false;
    for(int it=0;it<1e2;++it){
        ll i = rand()%(n-1)+1;
        if(__gcd(i,n)!=1) return false;
        // if(mpow(i,n-1,n)!=1) return false;
    }
    return true;
}

ll fast_pow(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b){
        if(b&1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return ans;
}

struct seg_tree{
    vector<ll> seg;
    vector<ll> lzy;
    int n;

    seg_tree(int x) : n(x){
        seg.resize(4*n+5);
        lzy.resize(4*n+5);
    } 

    void update_lzy(int l, int r, int i){
        if(!lzy[i]) return;
        seg[i] += lzy[i];
        if(l != r) lzy[i*2+1] += lzy[i], lzy[i*2+2] += lzy[i];
        lzy[i] = 0;
    }

    void update(int x, int y, ll val, int l = 0, int r = -1, int i = 0){
        if(r == -1) r += n;
        update_lzy(l, r, i);
        if(r < x || l > y) return; 
        if(l >= x && r <= y){
            lzy[i] += val;
            return update_lzy(l, r, i);
        }
        int m = (l+r) >> 1;
        update(x, y, val, l, m, i*2+1);
        update(x, y, val, m+1, r, i*2+2);
        seg[i] = min(seg[i*2+1], seg[i*2+2]);
    }

    ll query(int x, int y, int l = 0, int r = -1, int i = 0){
        if(r == -1) r += n;
        update_lzy(l, r, i);
        if(r < x || l > y) return INF;
        if(l >= x && r <= y) return seg[i];
        int m = (l+r) >> 1;
        ll ans = min(query(x, y, l, m, i*2+1), query(x, y, m+1, r, i*2+2));
        return ans;
    }
};

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    ll total = 0;
    vector<pii> rgt[n+2];
    for(int j = 0; j < m; j++){
        int l, r, val;
        cin >> l >> r >> val;
        total += val;
        rgt[r].pb({l, val});
    }
    seg_tree seg(n+2);
    for(int j = 1; j <= n; j++){
        // put a '1' here
        ll prv_1 = seg.query(0, j-1);
        seg.update(j, j, prv_1);

        // put a '0' here
        for(auto i : rgt[j]){
            ll l = i.F, val = i.S;
            seg.update(0, l-1, val);
        }
    }
    cout << (total - seg.query(0, n)) << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;

struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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^(int b) {mint res = 1;while(b > 0) {if(b&1) {res = (res*(*this));}*this=(*this)*(*this);b>>=1;} return res;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;

vvm dp;
vvi G;
int N;

void dfs(int x,int par) {
  dp[x][0] = dp[x][1] = 1;
  if(sz(G[x])==0) return;
  if(sz(G[x])==1&&G[x][0]==par) return;
  rep(i,sz(G[x])) {
    int to = G[x][i];
    if(to==par) continue;
    dfs(to,x);
    dp[x][0] *= dp[to][0] + dp[to][1];
    dp[x][1] *= dp[to][0];
  }
}

int main() {
  cin >> N;
  G = vvi(N);
  rep(i,N-1) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dp = vvm(N,vm(2,0));
  dfs(0,-1);
  cout << (dp[0][0]+dp[0][1]).x << endl;
  return 0;
}

Measured memory_bytes: 16768
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}
int bsr(int x) { return 31 - __builtin_clz(x); }

using R = long double;
const R PI = acos(R(-1));

R solve(vector<R> v) {
    int n = (int)v.size();
    v.push_back(v[0]);
    R l = 0, r = PI, area;
    for (int fe = 0; fe < 50; fe++) {
        R md = (l+r)/2;
        R sm = md, th = md;
        area = v[0]*v[1]*sin(th);
        for (int i = 1; i < n; i++) {
            R x = cos(th)*v[i-1]/v[i+1];
            if (1 < x) {
                sm = 0;
                break;
            }
            if (x < -1) {
                sm = 3*PI;
                break;
            }
            th = acos(x);
            sm += th;
            area += v[i]*v[i+1]*sin(th);
        }
        if (sm < 2*PI) {
            l = md;
        } else {
            r = md;
        }
        if (abs(sm-2*PI) <= 1e-9) {
            return area/2;
        }
    }
    return 0;
}

int main() {
    int n;
    cin >> n;
    vector<R> r(n);
    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }
    R ans = 0;
    sort(begin(r), end(r));
    for (int i = 0; i < (1<<n); i++) {
        if (__builtin_popcount(i) < 3) continue;
        vector<R> v;
        for (int j = 0; j < n; j++) {
            if (i & (1<<j)) {
                v.push_back(r[j]);
            }
        }
        sort(v.begin(), v.end());
        do {
            ans = max(ans, solve(v));
        } while (next_permutation(v.begin()+1, v.end()));
    }
    printf("%.20Lf\n", ans);
    return 0;
}

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

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int w = sc.nextInt();
			int h = sc.nextInt();
			int[][] f = new int[h][w];
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				f[y][x] = 1;
			}
			int s = sc.nextInt();
			int t = sc.nextInt();

			int[][] sub = new int[h][w];
			sub[0][0] = f[0][0];
			for (int i = 1; i < h; i++) {
				sub[i][0] = f[i][0] + sub[i - 1][0];
			}
			for (int j = 1; j < w; j++) {
				sub[0][j] = f[0][j] + sub[0][j - 1];
			}
			for (int i = 1; i < h; i++) {
				for (int j = 1; j < w; j++) {
					sub[i][j] = f[i][j] + sub[i - 1][j] + sub[i][j - 1] - sub[i - 1][j - 1];
				}
			}

			int max = 0;
			for (int i = t - 1; i < h; i++) {
				for (int j = s - 1; j < w; j++) {
					int a = i - t;
					int b = j - s;
					int t1 = a < 0 ? 0 : sub[a][j];
					int t2 = b < 0 ? 0 : sub[i][b];
					int t3 = a < 0 || b < 0 ? 0 : sub[a][b];
					int t4 = sub[i][j] - t1 - t2 + t3;
					max = Math.max(max, t4);
				}
			}

			//			mapDebug(f);
			//			mapDebug(sub);

			System.out.println(max);
		}
	}

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

Measured memory_bytes: 39044
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		double ans = (double)(N - N/2) / (double)N;
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x; cin >> x;
  if(x == 1)
    cout << "0";
  else
    cout << "1";
}

Measured memory_bytes: 3524
package main
import "fmt"

var n int
	
func main(){
    fmt.Scan(&n)
    bits := make([]int, 0)
    
    for n != 0 {
        if abs(n)%2 == 1{
            bits = append(bits, 1)
            n--
        }else{
            bits = append(bits, 0)
        }
        n /= 2
        n *= -1
    }
    
    if len(bits) == 0 {
        fmt.Println(0)
        return
    }
    for i := len(bits); i > 0; i-- {
        fmt.Printf("%d", bits[i-1])
    }
    fmt.Print("\n")
}

func abs(n int) int {
    if n > 0{
        return n
    }else{
        return -n
    }
}

Measured memory_bytes: 512