akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int main()
{
    int N; 
    cin >> N;
    vector<int> A(N);
    ll ki=0,gu=0,tmp=1;
    REP(i,N){
        cin >> A[i];
        if(A[i]%2==0){
            tmp*=2;
        }else{
            tmp*=1;
        }
    }
    ll ans=llpow(3,N);
    cout << ans - tmp << endl;
    return 0;
}


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

const int N = 100 + 5;
const int M = 1e5 + 5;
int n, we;
ll w[N], v[N];
ll dp[N][M];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> we;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    for (int i = 0; i <= n; i++)
        for (int j = 0; j < M; j++)
            dp[i][j] = INT_MAX;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = 0;
        for (int j = 1; j < M; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i - 1] >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
        }
    }

    for (int i = 1e5; i >= 1; i--) {
            for (int j = 1; j <= n; j++)
                if (dp[j][i] <= we)
                    return cout << i, 0;
    }
    return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>
#define N 100005
#define NIL -1

struct Node{
  int p, left, right;
};
struct Node T[N];
int n;

void inorder(int p){
  if(p != NIL) {
    inorder(T[p].left);
    printf(" %d", p);
    inorder(T[p].right);
  }
}

void postorder(int p){
if(p != NIL) {
    postorder(T[p].left);
    postorder(T[p].right);
    printf(" %d", p);
  }
}

void preorder(int p){
if(p != NIL) {
  printf(" %d", p);
  preorder(T[p].left);
  preorder(T[p].right);
  }
}



main(){
  int i, id;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].left = T[i].p = T[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d %d", &T[id].left, &T[id].right);
      T[T[id].left].p = id;
      T[T[id].right].p = id;
    }    

  printf("Preorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      preorder(i);
    }
  }
  printf("\nInorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      inorder(i);
    }
  }
  printf("\nPostorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      postorder(i);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 620
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        System.out.println(
            calcDebt(100000.0, new Scanner(System.in).nextInt())
        );

    }

    private static int calcDebt(double firstDebt, int nWeeks) {
        double debt = firstDebt;
        for(int i = 0; i< nWeeks; i++) {
            debt = Math.ceil(debt * 0.00105) * 1000.0;
        }
        return (int)debt;
    }
} 

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

int main() {
  ll n; cin >> n;
  set <ll> s;
  rep(i, n) {
    ll a; cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] team = new int[n+1];
		
		for(int i =0;i< n*(n-1)/2;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			if(c > d){
				team[a]+=3;
			}else if(c < d){
				team[b]+=3;
			}else{
				team[a]+=1;
				team[b]+=1;
			}
		}
		
		for(int i =1;i<=n;i++){
			int c = 1;
			for(int k=1;k<=n;k++){
				if(team[i]<team[k]){
					c++;
				}
			}
			System.out.println(c);
		}

	}

}

Measured memory_bytes: 41948
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
999999
)");
#define cin input
#endif

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

	cout << ((n - 1) / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
//In The Name Of Godd
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forr(i, n) for (ll i = n; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define inf 100000000000
#define eps 1e-9

const ll maxn = 310;
double dp[maxn][maxn][maxn];
ll one = 0, two = 0, three = 0;
double tot;

double solve(int a, int b, int c) {
  if(a + b + c == 0) return 0;
  double &cur = dp[a][b][c];
  if(cur >= -eps) return cur;
  cur = 0;
  double cur_tot = a + b + c;
  double succ = tot / cur_tot;
  cur = succ;
  if(a) cur += solve(a - 1, b, c) * (a / cur_tot);
  if(b) cur += solve(a + 1, b - 1, c) * (b / cur_tot);
  if(c) cur += solve(a, b + 1, c - 1) * (c / cur_tot);
  return cur;
}

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    forn(i, n) {
      int cur; cin >> cur;
      one += cur == 1;
      two += cur == 2;
      three += cur == 3;
    }
    tot = one + two + three;
    forn(i, maxn) forn(j, maxn) forn(k, maxn)
      dp[i][j][k] = -1;
    cout << fixed << setprecision(10) << solve(one, two, three) << endl;
}


Measured memory_bytes: 233088
function bubble_sort(a, compare) {
    for (let i = 0; i < a.length; ++i) {
        for (let j = a.length - 1; j > i; --j) {
            if (compare(a[j - 1], a[j]) > 0) {
                [a[j - 1], a[j]] = [a[j], a[j - 1]];
            }
        }
    }
}

function selection_sort(a, compare) {
    for (let i = 0; i < a.length; ++i) {
        let min_j = i;
        for (let j = i + 1; j < a.length; ++j) {
            if (compare(a[j], a[min_j]) < 0) {
                min_j = j;
            }
        }
        [a[i], a[min_j]] = [a[min_j], a[i]];
    }
}

new Promise(function(resolve, reject) {
    let cin = "";
    process.stdin
        .on("data", chunk => { cin += chunk; })
        .on("end", () => { resolve([cin, process.stdout]); });
}).then(function([cin, cout]) {
    const [n, ...d] = cin.split(/[ \n]/);

    const convert = (function(d, n) {
        return d.slice(0, n).map((elt, idx) => [elt, idx]);
    })

    const is_stable = (function(a, compare) {
        for (let i = 1; i < a.length; ++i) {
            if (compare(a[i - 1], a[i]) === 0 && a[i][1] < a[i - 1][1])
                return false;
        }
        return true;
    });

    const compare = (function(a, b) {
        a = parseInt(a[0].slice(1));
        b = parseInt(b[0].slice(1));
        if (a < b) return -1;
        if (b < a) return 1;
        return 0;
    });

    const bubble_a = convert(d, parseInt(n));
    bubble_sort(bubble_a, compare);
    cout.write(`${bubble_a.map(elt => elt[0]).join(" ")}\n`);
    if (is_stable(bubble_a, compare)) {
        cout.write("Stable\n");
    } else {
        cout.write("Not stable\n");
    }

    const selection_a = convert(d, parseInt(n));
    selection_sort(selection_a, compare);
    cout.write(`${selection_a.map(elt => elt[0]).join(" ")}\n`);
    if (is_stable(selection_a, compare)) {
        cout.write("Stable\n");
    } else {
        cout.write("Not stable\n");
    }
});



Measured memory_bytes: 16556
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    ll a[100001]; INITA(a, 0, 100000, 0);
    ll b[100001]; INITA(b, 0, 100000, 0);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
    ll res = 0;
    FORD(i, n-1, 0) {
        a[i] += res;
        if (a[i] % b[i] != 0) {
            res += b[i] - (a[i] % b[i]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5136
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dy[4] = {0, 1, 0, -1};
//const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    ll n; cin >> n;
    ll mini = 10000000000000000;
    REP(i, 5){
        ll in; cin >> in;
        mini = min(mini, in);
    }
    ll res = 4 + n/mini;
    if(n%mini != 0) res++;
    cout << res << endl;
}

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

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll q;cin>>q;
  vl a(q),b(q);
  rep(i,q)cin>>a[i]>>b[i];
  rep(i,q){
    ll x=min(a[i],b[i]);
    ll y=max(a[i],b[i]);
    ll ans=x-1;
    long double k=sqrt(x*y-0.75)-x-0.5+1;
    ll lk=k;
    ans+=k+(x*y-1)/(x+k);
    if(a[i]==b[i])cout<<ans<<endl;
    else cout<<ans-1<<endl;
  }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		SqrtDecomposition sq = new SqrtDecomposition(n);
		sq.update(0, n, Integer.MAX_VALUE);
		for(int i = 0; i < q; i++){
			int type = sc.nextInt();

			if(type == 0){
				int s = sc.nextInt();
				int t = sc.nextInt();
				int x = sc.nextInt();

				sq.update(s, t + 1, x);
			}
			else {
				int index = sc.nextInt();

				System.out.println(sq.get(index));
			}

//			for(int j = 0; j < n; j++){
//				System.out.print(sq.get(j)+" ");
//			}
//			System.out.println();
		}
	}

}

class SqrtDecomposition {
	int N, K;
	long[] data;
	long[] bucketLazyUpdate;
	static final int sqrtN = 512;
	static final int INF = Integer.MIN_VALUE;

	public SqrtDecomposition(int n) {
		N = n;
		K = (N + sqrtN - 1) / sqrtN;
		data = new long[K * sqrtN];
		bucketLazyUpdate = new long[K];
		Arrays.fill(bucketLazyUpdate, INF);
	}

	void update(int s, int t, int x) {
		for (int k = 0; k < K; ++k) {
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
//				System.out.println("all");
				bucketLazyUpdate[k] = x;
			} else {
//				System.out.println("each");
				if(bucketLazyUpdate[k] != INF){
					for(int i = l; i < r; i++){
						data[i] = bucketLazyUpdate[k];

					}
					bucketLazyUpdate[k] = INF;
				}
				for (int i = Math.max(s, l); i < Math.min(t, r); ++i) {
//					System.out.println("update index "+i);
					data[i] = x;
				}
			}
		}
	}

	long get(int s) {
		int k = s / sqrtN;
//		System.out.println(s+" "+k);
		if(bucketLazyUpdate[k] != INF){
//			System.out.println("all");
			return bucketLazyUpdate[k];
		}
		else {
//			System.out.println("direct");
			return data[s];
		}
	}
}


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

using namespace std;

int main()
{
    int n, u, v, m;
    static int rab[512][512], cat[512][512];
    static int doner[512][512], donec[512][512];
    static pair<int, int> rabpos[1000001], catpos[1000001];
    scanf("%d %d %d %d", &n, &u, &v, &m);
    
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            scanf("%d", &rab[i][j]);
            rabpos[rab[i][j]] = make_pair(i, j);
        }
    }
    
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            scanf("%d", &cat[i][j]);
            catpos[cat[i][j]] = make_pair(i, j);
        }
    }
    
    for (int i = 1; i <= m; i++){
        int x;
        scanf("%d", &x);
        pair<int, int> r = rabpos[x];
        doner[r.first][r.second] = i;
        r = catpos[x];
        donec[r.first][r.second] = i;
    }
    
    vector<int> rabmin, catmin;
    
    for (int i = 0; i < 13; i++){
        rabmin.push_back(1000000000);
        catmin.push_back(1000000000);
    }
    
    for (int i = 1; i <= n; i++){
        int rabmax = 0, catmax = 0;
        bool rabok = 1, catok = 1;
        for (int j = 1; j <= n; j++){
            rabmax = max(rabmax, doner[i][j]);
            catmax = max(catmax, donec[i][j]);
            rabok &= (!!doner[i][j]);
            catok &= (!!donec[i][j]);
        }
        if (rabok) rabmin.push_back(rabmax);
        if (catok) catmin.push_back(catmax);
        
        if (n != 1){
            rabmax = 0, catmax = 0;
            rabok = 1, catok = 1;
            for (int j = 1; j <= n; j++){
                rabmax = max(rabmax, doner[j][i]);
                catmax = max(catmax, donec[j][i]);
                rabok &= (!!doner[j][i]);
                catok &= (!!donec[j][i]);
            }
            if (rabok) rabmin.push_back(rabmax);
            if (catok) catmin.push_back(catmax);
        }
    }
    
    if (n != 1){
        int rabmax = 0, catmax = 0;
        bool rabok = 1, catok = 1;
        for (int i = 1; i <= n; i++){
            rabmax = max(rabmax, doner[i][i]);
            catmax = max(catmax, donec[i][i]);
            rabok &= (!!doner[i][i]);
            catok &= (!!donec[i][i]);
        }
        if (rabok) rabmin.push_back(rabmax);
        if (catok) catmin.push_back(catmax);
        
        rabmax = 0, catmax = 0;
        rabok = 1, catok = 1;
        for (int i = 1; i <= n; i++){
            rabmax = max(rabmax, doner[i][n - i + 1]);
            catmax = max(catmax, donec[i][n - i + 1]);
            rabok &= (!!doner[i][n - i + 1]);
            catok &= (!!donec[i][n - i + 1]);
        }
        if (rabok) rabmin.push_back(rabmax);
        if (catok) catmin.push_back(catmax);
    }
    
    sort(rabmin.begin(), rabmin.end());
    sort(catmin.begin(), catmin.end());
    
    --u; --v;
    if (rabmin[u] == catmin[v] || min(rabmin[u], catmin[v]) > m){
        return (!printf("DRAW\n"));
    }
    printf("%s\n", rabmin[u] < catmin[v] ? "USAGI" : "NEKO");
    
    return (0);
}

Measured memory_bytes: 20388
N = int(input())
A = []
judge = 0

for i in range(N):
    A.append(input())

B = set(A)

if len(B) != N:
    judge = 1

for i in range(N-1):
    C = list(A[i])
    D = list(A[i+1])
    if C[-1] != D[0]:
        judge = 1

if judge == 0:
    print('Yes')
else :
    print('No') 

Measured memory_bytes: 3064
import collections

n = int(input())
v = [int(i) for i in input().split()]

odd = []
even = []
for i, num in enumerate(v):
    if (i+1) % 2 != 0:
        odd.append(num)
    else:
        even.append(num)

odds = collections.Counter(odd).most_common()
evens = collections.Counter(even).most_common()

cnt_odd = 0
cnt_even = 0

ans = 0
if odds[0][0]  == evens[0][0]:
    if len(evens) == 1 and len(odds) == 1:
        ans = evens[0][1]
        print(ans)
        exit()

    ans1 = 10 ** 5
    ans2 = 10 ** 5

    if len(evens) > 1:
        for i, e in enumerate(evens):
            if i != 1:
                cnt_even += e[1]
        for i, o in enumerate(odds):
            if i > 0:
                cnt_odd += o[1]
        ans1 = cnt_even + cnt_odd
        cnt_even, cnt_odd = 0,0
    if len(odds) > 1:
        for i, e in enumerate(evens):
            if i > 0:
                cnt_even += e[1]
        for i, o in enumerate(odds):
            if i != 1:
                cnt_odd += o[1]
        ans2 = cnt_even + cnt_odd
    ans = min(ans1, ans2)
    print(ans)
    exit()

for i, o in enumerate(odds):
    if i > 0:
        cnt_odd += o[1]
for i, e in enumerate(evens):
    if i > 0:
        cnt_even += e[1]
ans = cnt_odd + cnt_even

print(ans)        


Measured memory_bytes: 21212
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, string S){
    vector<int> e(N, 0);
    vector<int> w(N, 0);
    if(S[0] == 'W') w[0] = 1;
    if(S[N-1] == 'E') e[N-1] = 1;
    for (int i = 1; i < N; i++) {
        if (S[i] == 'W') {
            w[i] = w[i-1] + 1;
        } else {
            w[i] = w[i-1];
        }
        if (S[N-1-i] == 'E') {
            e[N-1-i] = e[N-i] + 1;
        } else {
            e[N-1-i] = e[N-i];
        }
    }
    long long ret = 10000000;
    if (e[1] < ret) {
        ret = e[1];
    }
    if (w[N-2] < ret) {
        ret = w[N-2];
    }
    for (int i = 1; i < N-1; i++) {
        if (e[i+1] + w[i-1] < ret) {
            ret = e[i+1] + w[i-1];
        }
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    string S;
    long long N;
    scanf("%lld",&N);
    cin >> S;
    solve(N, S);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

int main(){
    int h,w;
    int masu;
    cin >> h >> w;
    masu=h*w;
    vector <string> s(h);
    string s2;
    vector <vector <int>> m(h,vector <int> (w,10000));
    rep(i,h){
        cin >> s[i];
        rep(j,w){
            s2=s[i][j];
            if(s2=="#"){
                m[i][j]=-1;
                --masu;
            }
        }
    }

    m[0][0]=0;
    queue <vector <int>> q;
    q.push({0,0,0});
    vector <int> qq;
    int l;
    int ans=-1;

    while(q.size()!=0){
        qq=q.front();
        q.pop();
        if(qq[0]==(h-1) and qq[1]==(w-1)){
            ans=qq[2];
        }

        if(qq[0]!=0){
            if(m[qq[0]-1][qq[1]]>qq[2]+1){
                m[qq[0]-1][qq[1]]=qq[2]+1;
                q.push({qq[0]-1,qq[1],qq[2]+1});
            }
        }

        if(qq[0]!=(h-1)){
            if(m[qq[0]+1][qq[1]]>qq[2]+1){
                m[qq[0]+1][qq[1]]=qq[2]+1;
                q.push({qq[0]+1,qq[1],qq[2]+1});
            }
        }


        if(qq[1]!=0){
            if(m[qq[0]][qq[1]-1]>qq[2]+1){
                m[qq[0]][qq[1]-1]=qq[2]+1;
                q.push({qq[0],qq[1]-1,qq[2]+1});
            }
        }


        if(qq[1]!=(w-1)){
            if(m[qq[0]][qq[1]+1]>qq[2]+1){
                m[qq[0]][qq[1]+1]=qq[2]+1;
                q.push({qq[0],qq[1]+1,qq[2]+1});
            }
        }
    }

    if(ans>-1){
    cout << masu-ans-1 << endl;
    }
    else{
        cout << -1 << endl;
    }

    

    return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 081 C Not so Diverse
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]

def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K), 'N, K')
    A = getIntList()
    d.dmp((A), 'A')
    dic = {}
    for e in A:
        if e in dic:
            dic[e] += 1
        else:
            dic[e] = 1
    d.dmp(dic,'dic')
    val = list(dic.values())
    count = 0
    val.sort()
    d.dmp(val,'val')
    for i in range(len(val)-K):
        count += val[i]
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


Measured memory_bytes: 32868
#include<stdio.h>
int main(){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S/60)-(h*60);
	s=S-(h*3600)-(m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>

int main()
{
  long long n;
  scanf("%lld", &n);
  long long a[100002];
  a[0] = 0;
  long long sum = 0;
  for (long long i = 1; i <= n; ++i)
  {
    scanf("%lld", a + i);
    sum += std::abs(a[i] - a[i - 1]);
  }
  a[n + 1] = 0;
  sum += std::abs(a[n]);
  for (long long i = 1; i <= n; ++i)
  {
    printf("%lld\n", sum - std::abs(a[i] - a[i - 1]) - std::abs(a[i] - a[i + 1]) + std::abs(a[i - 1] - a[i + 1]));
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, k; cin >> n >> k;

    if(n >= k) {
        cout << min(n%k, k - (n%k)) << endl;
    } else {
        cout << min(n, k - n) << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	(b>=100?a*1000+b:(b>=10?a*100+b:a*10+b))==pow(int(sqrt(b>=100?a*1000+b:(b>=10?a*100+b:a*10+b))),2)?puts("Yes"):puts("No");
	return 0;
}

Measured memory_bytes: 128
input()
X = [int(x) for x in input().split()]
input()
Y = [int(x) for x in input().split()]

flag = [False]* 2000
for j in range(1 << len(X)):
    n = 0
    for i in range(len(X)):
        if 1 & (j >> i) == 1:
            n += X[i]
    flag[n] = True

for m in Y:
    print("yes" if flag[m] else "no")


Measured memory_bytes: 5640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll sx,sy, tx, ty; cin >> sx >> sy >> tx >> ty;

	rep(i, ty - sy) cout << "U";
	rep(i, tx - sx) cout << "R";
	rep(i, ty - sy) cout << "D";
	rep(i, tx - sx) cout << "L";
	cout << "L";
	rep(i, ty - sy + 1) cout << "U";
	rep(i, tx - sx + 1) cout << "R";
	cout << "D";
	cout << "R";
	rep(i, ty - sy + 1) cout << "D";
	rep(i, tx - sx + 1) cout << "L";
	cout << "U" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    deque<int> b;
    for(int i=0; i<n; ++i){
        if(i % 2 == 0)
            b.push_back(a[i]);
        else
            b.push_front(a[i]);
    }
    if(n % 2 != 0)
        reverse(b.begin(), b.end());

    cout << b[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << b[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
/*
##题意:
n种配料,求多少个集合满足每种配料至少出现两次.

##分析:
dp[x]表示有x种酱不合法的方案数

然后令f[x][y]表示x碗面,有y不合法的酱,注意这x碗都是不合法的,那么有
f[x][y]=f[x][y-1]*(x+1)			+f[x-1][y-1]
		扔到之前的碗里或者不扔	开一个新的碗
(x<=n&&y<=n)//其实差不多就是斯特林数

然后再来考虑可以随便放的酱
那么
f[x][y]*2^(2^(n-y)*(x+1));

*/
ll ksm(ll a,ll b,ll mo){
	ll res=1;
	for (;b;b>>=1){
		if (b&1)res=res*a%mo;
		a=a*a%mo;
	}
	return res;
}
#define M 3005
ll f[M][M*2],mo,c[M][M],res;
int n;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n); read(mo);
	int i,j;
	ll g;
	f[0][0]=1;
	for (i=1;i<M;i++){
		for (j=1;j<2*M;j++){
			f[i][j]=(f[i-1][j]*j%mo+f[i-1][j-1])%mo;
		}
	}
	c[0][0]=1;
	for (i=1;i<=n;i++){
		c[i][0]=1;
		for (j=1;j<=n;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mo;
		}
	}
	for (i=0;i<=n;i++){
        g=0;
        for (j=0;j<=i;j++){
            g+=ksm(ksm(2,n-i,mo),j,mo)*f[i+1][j+1];
        	g%=mo;
        }
        g=g*ksm(2,ksm(2,n-i,mo-1),mo)%mo*c[n][i]%mo;
    	if (i&1)res-=g;
    	else res+=g;
    }
	res=(res%mo+mo)%mo;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 211840
# -*- coding: utf-8 -*-
"""
Osenbei
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0525

"""
import sys
from itertools import product


def solve(osenbei, row, col):
    ans = 0
    for bits in product([0, 1], repeat=row):
        res = 0
        sen = [[] for _ in range(row)]
        for i, b in enumerate(bits):
            sen[i] = [[1, 0][o] for o in osenbei[i]] if b else osenbei[i]
        for z in zip(*sen):
            t = sum(z)
            res += max(t, row-t)
        ans = max(ans, res)
    return ans


def main(args):
    while True:
        r, c = map(int, input().split())
        if r == 0 and c == 0:
            break
        osenbei = [[int(j) for j in input().split()] for i in range(r)]
        ans = solve(osenbei, r, c)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 7428
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}

int n, tmp, res = 0;
string s;
main(){
    INCANT;
    in(n);
    int l = 1, r = n;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(summation(mid) > n){
            r = mid;
        }else{
            l = mid;
        }
    }
    rep(i, 1, r + 1){
        if(summation(r) - n != i){
            print(i);
        }
    }
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  ll X;
  cin >> X;
  ll count=0;
  ll yokin=100;
  while(yokin<X){
    yokin*=1.01;
    count++;
  }
  cout << count;
}

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

#define int long long
const int INF = 1e9;

signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];    
  }

  vector<int> a = A;
  int ans = INF;
  int cnt = 0;
  bool now = 0;
  for ( int i = 0; i < N-1; i++ ) {    
    if ( now ) { // 増加
      if ( a[i] > a[i+1] ) {
	if ( i < N-2 && a[i] < a[i+2] ) {
	  swap(a[i+1], a[i+2]);	  
	} else {
	  swap(a[i], a[i+1]);	 
	}
	cnt++;	
      }
    } else { // 減少
      if ( a[i] < a[i+1] ) {
	if ( i < N-2 && a[i] > a[i+2] ) {
	  swap(a[i+1], a[i+2]);	  
	} else {
	  swap(a[i], a[i+1]);	 
	}
	cnt++;	
      }
    }
    now = !now;    
  }
  
  ans = cnt;

  a = A;
  cnt = 0;
  now = 1;
  for ( int i = 0; i < N-1; i++ ) {
    if ( now ) { // 増加
      if ( a[i] > a[i+1] ) {
	if ( i < N-2 && a[i] < a[i+2] ) {
	  swap(a[i+1], a[i+2]);	  
	} else {
	  swap(a[i], a[i+1]);	 
	}
	cnt++;	
      }
    } else { // 減少
      if ( a[i] < a[i+1] ) {
	if ( i < N-2 && a[i] > a[i+2] ) {
	  swap(a[i+1], a[i+2]);	  
	} else {
	  swap(a[i], a[i+1]);	 
	}
	cnt++;	
      }
    }
    now = !now;    
  }

  cout << min(ans, cnt) << endl;
  
  return 0;
}



Measured memory_bytes: 4436
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x, y, z, tmp;
    
    scanf("%d %d %d" , &x, &y, &z);
    if (x>y) {
        tmp=x;
        x=y;
        y=tmp;
    }
    if (y>z) {
        tmp=y;
        y=z;
        z=tmp;
    }
    if (x>y) {
        tmp=x;
        x=y;
        y=tmp;
    }

    printf("%d %d %d\n",x, y, z);
    return 0;
    
}



Measured memory_bytes: 2040
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int seg_len;
int seg[10000000];

void add(int l, int r, int x){
	l += seg_len-1;
	r += seg_len-1;
	while(l<r){
		if(l % 2 == 1){seg[l] += x; ++l;}
		l /= 2;
		if(r % 2 == 1){seg[r-1] += x; --r;}
		r /= 2;
	}
}

int get(int i){
	int k = i+seg_len-1;
	int res = 0;
	while(k>0){
		res += seg[k];
		k /= 2;
	}
	return res;
}

int main(){
	int N,Q; cin>>N>>Q;
	seg_len = 1;
	while(seg_len <= N)seg_len *= 2;;
	int com, i, s, t, x;
	rep(_,Q){
		cin>>com;
		if(com == 0){
			cin>>s>>t>>x;
			add(s,t+1,x);
		}else{
			cin>>i;
			cout<<get(i)<<endl;
		}
	}
	// REP(j,seg_len*2-1){cout<<seg[j]<<endl;}
	return 0;
}


Measured memory_bytes: 3896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!(str = reader.readLine()).equals("0")) {
				int n = Integer.parseInt(str);
			
				str = reader.readLine();
				String[] score = str.split(" ");
			
				double s[] = new double[n];
				double m = 0;
				for (int i = 0; i < n; i++) {
					s[i] = Double.parseDouble(score[i]);
					m += s[i];
				}
				m /= n;
				double a2 = 0;
				for (int i = 0; i < n; i++) {
					a2 += Math.pow(s[i] - m, 2.0);
				}
				a2 /= n;
				double a = Math.sqrt(a2);
				System.out.println(a);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 26476
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a; int b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int partition(vector<int>& A, int p, int r)
{
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (A[j] <= x) {
      ++i;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1;
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  int ix = partition(A, 0, n - 1);
  for (int i = 0; i < n; ++i) {
    if (i) { fprintf(stdout, " "); }
    if (i == ix) {
      fprintf(stdout, "[%d]", A[i]);
    }
    else {
      fprintf(stdout, "%d", A[i]);
    }
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<cstdio>
using namespace std;
int k[10],n,l,p,i=1;
bool pd(int f)
{
	do
	{
		if(k[f%10]==1)
		return false;
		f/=10;
	}
	while(f>0);
	return true;
}
int main()
{
	scanf("%d%d",&n,&l);
	for(i=0;i<l;i++)
	{
		scanf("%d",&p);
		k[p]=1;
	}
	for(i=n;i<=2147483647;i++)
	{
		if(pd(i))
		{
			printf("%d",i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int m;
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i++){
    cin >> b[i];
  }
  bool res = true;
  for (int i = 0; i < m; i++){
    int tv = n;
    int fv = 0;
    while (tv - fv > 1){
      int mv = (tv + fv) / 2;
      if (a[mv] > b[i]){
        tv = mv;
      } else {
        fv = mv;
      }
    }
    if (a[fv] != b[i]){
      res = false;
    }
  }
  if (res){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


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

int main(){
  int N;
  int A, B;
  cin >> N;
  cin >> A >> B;
  int count=0;
  for(int i=1; i<=N; i++){
    int j=i;
    int k=0;
    k+=j/10000;
    j%=10000;
    k+=j/1000;
    j%=1000;
    k+=j/100;
    j%=100;
    k+=j/10;
    j%=10;
    k+=j;
    if(A<=k && k<=B)
      count+=i;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){


	int x,y;
	int a=0,b=0,c=0;

	cin>>x>>y;


	if(x==1){
		a++;
	}
	if(x==3){
		a++;
	}
	if(x==5){
		a++;
	}
	if(x==7){
		a++;
	}
	if(x==8){
		a++;
	}
	if(x==10){
		a++;
	}
	if(x==12){
		a++;
	}
	if(x==4){
		b++;
	}
	if(x==6){
		b++;
	}
	if(x==9){
		b++;
	}
	if(x==11){
		b++;
	}
	if(x==2){
		c++;
	}

	if(y==1){
		a++;
	}
	if(y==3){
		a++;
	}
	if(y==5){
		a++;
	}
	if(y==7){
		a++;
	}
	if(y==8){
		a++;
	}
	if(y==10){
		a++;
	}
	if(y==12){
		a++;
	}
	if(y==4){
		b++;
	}
	if(y==6){
		b++;
	}
	if(y==9){
		b++;
	}
	if(y==11){
		b++;
	}
	if(y==2){
		c++;
	}

	if(a==2){
		cout<<"Yes"<<endl;

	}else if(b==2){
		cout<<"Yes"<<endl;

	}else if(c==2){
		cout<<"Yes"<<endl;

	}else{
		cout<<"No"<<endl;
	}

	return 0;



}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int pa[333];

struct P{
  int m[3];
};

queue<P> que;

int main(void)
{
  while(1){
    int a,b,c;
    cin >> a >> b >> c;
    if(!a && !b && !c) break;
    fill(pa,pa+a+b+c+1,2);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
      P p;
      int r;
      cin >> p.m[0] >> p.m[1] >> p.m[2] >> r;
      if(r){
	pa[p.m[0]] = pa[p.m[1]] = pa[p.m[2]] = 1;
      }else{
	que.push(p);
      }
    }
    for(int i = 0; !que.empty(); i++){
      int co=0,p=-1;
      P q = que.front(); que.pop();

      for(int j = 0; j < 3; j++){
	if(pa[q.m[j]]==1){
	  co++;
	}else{
	  p = q.m[j];
	}
      }
      if(co == 2){
	pa[p] = 0;
      }    
    }    

    for(int i = 1; i <= a+b+c; i++){
      cout << pa[i] << endl;
    }
  }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
  string s;
  cin>>s;
  cout<<s[0]<<(s.size()-2)<<s.back()<<endl;
  return 0;
}


Measured memory_bytes: 256
data = STDIN.read.lines[1..-1].map(&:to_i)
min_elem = data[0]
max_diff = data[1] - data[0]
data[1..-1].each { |n|
  d = n - min_elem
  max_diff = d if (d > max_diff)
  min_elem = n if (n < min_elem)
}
puts max_diff

Measured memory_bytes: 22556
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;
ll a[3009][3009];
ll dp[3009][3009][4];
ll n,m;
ll sol(ll i,ll j,ll cur)
{

    if(dp[i][j][cur]!=-1)
    {
        return dp[i][j][cur];
    }
    //cout<<i<<" "<<j<<" "<<cur<<endl;
    ll res = 0;
    if(i==n-1 && j==m-1)
    {
        if(cur==3)
            return dp[i][j][cur] = 0;
        else return dp[i][j][cur] = a[i][j];
    }
    if(i==n-1)
    {
        if(cur!=3)
            res = max(res,sol(i,j+1,cur+1)+a[i][j]);
        res = max(res,sol(i,j+1,cur));
    }
    else if(j==m-1)
    {
        if(cur!=3)
            res = max(res,sol(i+1,j,0)+a[i][j]);
        res = max(res,sol(i+1,j,0));
    }
    else
    {
        if(cur!=3)
            res = max(res,sol(i,j+1,cur+1)+a[i][j]);
        res = max(res,sol(i,j+1,cur));
        if(cur!=3)
            res = max(res,sol(i+1,j,0)+a[i][j]);
        res = max(res,sol(i+1,j,0));
    }
    return dp[i][j][cur]  =res;
}
int main()
{
    ll i,t,k,j,x=0,y=0;
    cin>>n>>m>>k;
    for(i=0;i<k;i++)
    {
        cin>>x>>y>>j;
        a[x-1][y-1]  = j;
    }
    memset(dp,-1,sizeof dp);
    cout<<sol(0,0,0)<<endl;
    return 0;
}



Measured memory_bytes: 357348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main(void) {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for (int i = 0; i < k; i++) {
		int max_num = max({ a, b, c });
		if (max_num == a) a *= 2;
		else if(max_num == b) b *= 2;
		else c *= 2;
	}
	cout << (a + b + c) << endl;
	return 0;
}


Measured memory_bytes: 256