akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define M 1000000000
#define N 500001
void Merge(int Arr[],int left,int mid,int fuck);
void MergeSort(int Arr[], int left, int right);

int count = 0;

int main(){
  int Arr[N];
  int i;
  int n;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&Arr[i]);
  }
      MergeSort(Arr, 0, n);
      for(i = 0; i < n; i++){
    if(i == n-1)    printf("%d\n",Arr[i]);
    else printf("%d ",Arr[i]);
      }
      printf("%d\n",count);
      return 0;
}

void Merge(int Arr[],int left,int mid,int right){

  int i,k;
  int j = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];

  for (i = 0; i < n1; i++){
    L[i] = Arr[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = Arr[mid + i];
  }
  L[n1]= M;
  R[n2]= M;
  i = 0;

  for(k = left; k < right; k++){
    count++;
    if (L[i] <= R[j]){
      Arr[k] = L[i];
    i = i + 1;
}
else {
      Arr[k] = R[j];
      j = j + 1;
      }
    }
  }

void MergeSort(int Arr[], int left, int right){
  int mid = 0;
  if(left + 1 < right){
    mid = (left + right)/2;
    MergeSort(Arr, left, mid);
    MergeSort(Arr, mid, right);
    Merge(Arr, left, mid, right);
  }
}

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

int main() {
    int N;
    cin >> N;
    int A[N-1];
    int B[N-1];
    B[0] = 0;
    for (int i=1; i<N; i++) {
        cin >> A[i];
        B[i] = 0;
    }
    for (int i=1; i<N; i++) {
        B[A[i]-1]++;
    }
    for (int i=0; i<N; i++) {
        cout << B[i] << endl;
    }
    return 0;

}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string  n; cin >> n;
    rep(i,3){
        cout << ((n[i] == '1') ? 9 : 1);
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<pair<double, double>> items(N);
    vector<ll> P;
    rep(i, N) {
        P.push_back(i);
    }
    rep(i, N) cin >> items[i].first >> items[i].second;
    double ans = 0;
    double m = 1;
    rep(i, N) {
        m *= i + 1;
    }
    do {
        ll p = P[0];
        double px = items[p].first;
        double py = items[p].second;
        rep2(i, 1, N) {
            ll p = P[i];
            double x = items[p].first;
            double y = items[p].second;
            double t = abs(x - px) * abs(x - px) + abs(y - py) * abs(y - py);
            ans += pow(t, 0.5);
            px = x;
            py = y;
        }
    } while (next_permutation(P.begin(), P.end()));
    cout << ans / m << '\n';
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main() {
    int N;
    long long D;
    cin >> N >> D;
    int res = 0;
    while (N--) {
        long long X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
 
using ll = long long;
const ll mod = 998244353;
 
 
ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}

Measured memory_bytes: 215168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int divCount(int n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int N; cin >> N;
    int i, j, k;
    ll ans = 0;
    for(i = 1; i < N; i++){
        int w = N - i;
        ll e = (ll)divCount(w);
        ans += e;
    }
    cout << ans;
}

Measured memory_bytes: 3656
N,W=map(int,input().split(' '))
w=[0]*N ; v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split(' '))
S=sum(v)
A=0
dp=[[sum(w)]*S for _ in range(N+1)]
for i in range(N):
    for j in range(S):
        if j<v[i]:
            dp[i+1][j]=min(dp[i][j],w[i])
        else:
            dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
        if dp[i+1][j]>W:
            A=j
            break
        if j==S-1:
          A=j+1
print(A)

Measured memory_bytes: 120940
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	ll K;
	cin >> K;

	if (K == 0) {
		cout << 2 << endl;
		cout << "1 1" << endl;
	}
	else if (K == 1) {
		cout << 2 << endl;
		cout << "0 2" << endl;
	}
	else if (K <= 50) {
		cout << K << endl;
		FOR(i, 1, K-1) {
			cout << i << " ";
		}
		cout << K << endl;
	}
	else {
		ll p = K / 50;
		ll q = K % 50;
		vl ans(50);
		REP(i, 50) {
			ans[i] = i + 1 + (p - 1);
		}
		FOR(i, 50-q, 50 - 1) {
			ans[i]++;
		}
		cout << 50 << endl;
		REP(i, 49) {
			cout << ans[i] << " ";
		}
		cout << ans[49] << endl;
	}
	
	return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;

	deque<int> d;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		d.push_back(a);
	}

	sort(d.begin(), d.end());

	int n = d.back();
	d.pop_back();

	int id = -1;
	double mindiff = 1e9;
	for(int i = 0; i < d.size(); i++){
		double diff = abs((double)n / 2 - d[i]);
		if(mindiff > diff){
			mindiff = diff;
			id = i;
		}
	}

	cout << n << " " << d[id] << endl;
}


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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> ans(n,1);
	rep(i,k){
		int d;
		cin >> d;
		rep(j,d){
			int a;
			cin >> a;
			ans[a-1] = 0;
		}
	}
	int sum = 0;
	rep(i,n) sum += ans[i];
	cout << sum << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n;
	cin>>n;
	int cnt[100010]={};
	int a[100010];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	ll ans=1;
	for(int i=0; i<n; i++){
		if(a[i]==0){
			ans*=(3-cnt[0]);
			ans%=MOD;
		}else{
			if(cnt[a[i]-1]<=cnt[a[i]]){
				cout<<0<<endl;
				return 0;
			}
			ans*=(cnt[a[i]-1]-cnt[a[i]]);
			ans%=MOD;
		}
		cnt[a[i]]++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 1;
int n, m;
vector<int> mp[MAX_N];
bool vis[MAX_N];
int main()
{
    scanf("%d%d", &n, &m);
    int u, v;
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &u, &v);
        mp[u].push_back(v);
        mp[v].push_back(u);
    }
    for (int i = 0; i < mp[1].size(); i++) vis[mp[1][i]] = 1;
    for (int i = 0; i < mp[n].size(); i++) {
        if (vis[mp[n][i]]) {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 12144
#!/usr/bin/env python3
#!/usr/bin/env pypy3

from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)
    from sys import stdin, stdout, stderr
    input = stdin.readline

    #import numpy as np
    #import scipy as sp

    # Python 3 modules: https://docs.python.org/3/library/

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    # Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
    # Before Python 3.5.  Import from math after it.
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')

    def lcm(a, b):
        return a * b // gcd(a,b)

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    ############################################################################


    S = input()
    dprint(S)
    for i in range(len(S) - 1):
        dprint(S[i])
        if S[i] == S[i+1]:
            print('Bad')
            return
    print('Good')


if __name__ == '__main__':
    main()


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    ll n;
    cin>>n;

    vector<ll> count(n+1);
    vector<ll> arr;

    for(int i=0;i<n;i++) {
        ll num;
        cin>>num;

        count[num]++;
        arr.push_back(num);
    }

    ll total=0;

    for(int i=1;i<=n;i++) {
        if(count[i]!=0) {
            total+=(count[i]*(count[i]-1))/2;
        }
    }

    for(int i=0;i<n;i++) {
        cout<<total-count[arr[i]]+1<<endl;
    }


    
}


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

int main () {
  int N, Y;
  cin >> N >> Y;
  
  Y /= 1000;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      int k = N - i - j;
      if (10 * i + 5 * j + k == Y && 0 <= k && k <= N) {
        cout << i << " " << j << " " << k;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vector<pll> s(n);
  vector<ll> a(n);
  vector<ll> b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
    s[i]=pll(a[i]+b[i],i);
  }
  sort(s.rbegin(),s.rend());
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(i%2) {
      ans-=b[s[i].second];
    }
    else {
      ans+=a[s[i].second];
    }
  }
  cout << ans << endl;
}

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

int main() {
  int r, D, x[11];
  cin >> r >> D >> x[0]; //x[0] = x2000, x[i] = x2000+i
  for (int i = 0; i < 10; i++) {
    x[i + 1] = r * x[i] - D;
    cout << x[i + 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let it = buf.split_whitespace();
    let mut stack = Vec::new();
    for e in it {
        if e == "+" {
            let a = stack.pop().unwrap(); 
            let b = stack.pop().unwrap(); 
            stack.push(a + b);
        } else if e == "-"{
            let a = stack.pop().unwrap(); 
            let b = stack.pop().unwrap(); 
            stack.push(b - a);
        } else if e == "*"{
            let a = stack.pop().unwrap(); 
            let b = stack.pop().unwrap(); 
            stack.push(a * b);
        } else {
            stack.push(e.parse::<i64>().unwrap());
        }
        //println!("{:?}", stack);
    }
    //println!("{}", stack.len());
    println!("{}", stack.pop().unwrap());
}




Measured memory_bytes: 5028
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

long long x,y ;
cin >> x >> y ;

int cnt = 0 ;
while(x<=y)
{
    x = x*2 ;
    ++cnt ;
}
 cout << cnt << endl ;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    vector<int> a;
    main(){
    int n;
    cin >> n;

    int x=0;
    int t = 0;
    int ans = 0;
    while(n){


        x = n % 10;

        a.push_back(x);
        n /= 10;


    }
    int gg = 1;

    int maxe = 0;
    for(int i = 0 ; i < a.size();i++){
        if(a[i] == a[i+1]){gg++;maxe=max(maxe,gg);}
        else gg = 1;
        }

        if(maxe >= 3)cout <<"Yes";
        else cout <<"No";




    }


Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-23 21:07:54
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

set<int> to[26];
set<int> from[26];
string S, T;

int main()
{
  cin >> S >> T;
  int N = S.size();
  for (auto i = 0; i < N; i++)
  {
    int x = S[i] - 'a';
    int y = T[i] - 'a';
    to[x].insert(y);
    from[y].insert(x);
  }
  for (auto i = 0; i < 26; i++)
  {
    if (to[i].size() > 1 || from[i].size() > 1)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#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 FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };
ll n, k;
vector<int> x;
ll dis = 0;
signed main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	cin >> n >> k;
	ll tmp;
	REP(i, n) {
		cin >> tmp;
		x.push_back(tmp);
}

	REP(i, n) {
		if (abs(x[i]) < abs(k - x[i])) {
			dis += x[i] * 2;
		}
		else {
			dis += abs(k - x[i]) * 2;
		}
	}

	cout << dis<<endl;
	return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  i <- getContents
  let input = map parse . lines $ i
      (x, y, _) = foldl proc (0, 0, 0) input
  print $ truncate x
  print $ truncate y

parse :: String -> (Double, Double)
parse s = (read xs, read $ tail ys)
  where (xs, ys) = break (==',') s

proc :: (Double, Double, Double) -> (Double, Double) -> (Double, Double, Double)
proc (x, y, d) (a, d') = (x', y', d + d')
  where r = d * pi / 180
        x' = x + a * sin r
        y' = y + a * cos r

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n,m; cin >> n >> m;
    vector<int> p(m);
    arr<int> G(n);
    rep(i, m){
        int k; cin >> k;
        rep(j, k){
            int s; cin >> s;
            G[--s].push_back(i);
        }
    }
    rep(i, m) cin >> p[i];

    vector<int> on(m);
    int ans=0;
    rep(bit, 1<<n){
        rep(i, m) on[i] = 0;
        rep(i, n) {
            if(bit>>i & 1){
                for(int j: G[i]) on[j] = (on[j]+1)%2;
            }
        }

        bool flag = true;
        rep(i, m) {
            if(on[i] != p[i]) {
                flag = false;
                break;
            }
        }

        if(flag) {
            // cout << bitset<10>(bit) << endl;
            ans++;
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  int number;
  char sign;
}CARD;

void bubbleSort(CARD *,int);
void SelectionSort(CARD *, int);
int isStable(CARD *,CARD *);
void swap(CARD *,CARD *);
void Print(CARD *,int);

int n,answer;
CARD *C1,*C2;

int main(){
  int i,a;


  scanf("%d",&n);
  C1 = malloc(n*sizeof(CARD));
  C2 = malloc(n*sizeof(CARD));

  for(i=0;i<n;i++){
    scanf(" %c%d",&C1[i].sign,&C1[i].number);
    C2[i]=C1[i];
  }

  bubbleSort(C1,n);

  SelectionSort(C2,n);

  Print(C1,n);
  if(answer==0){
    printf("Stable\n");
  }
  else printf("Not stable\n");

  Print(C2,n);

  answer = isStable(C1,C2);

  if(answer==0){
    printf("Not stable\n");
  }
  else printf("Stable\n");

  free(C1);
  free(C2);

  return 0;

}

void bubbleSort(CARD *x,int n){
  int i,j,count=0,minj;
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(x[j].number < x[j-1].number){
        swap(&x[j],&x[j-1]);
        /*swap=x[j];
        x[j]=x[j-1];
        x[j-1]=swap;*/
      }
    }
  }

}

void SelectionSort(CARD *y, int n){
  int i,j,minj;
  for(i=0;i<=n-1;i++){
    minj=i;
    for(j=i;j<=n-1;j++){
      if(y[j].number<y[minj].number){
        minj =j;
        //swap(&y[i],&y[minj]);

      }
    }
    if(i!=minj){swap(&y[i],&y[minj]);}
  }


}

int isStable(CARD *in,CARD *out){
  int i;
  for(i=0;i<n;i++){
    if(in[i].sign!= out[i].sign){
      return 0;

    }
  }
  return 1;
}

void Print(CARD *x,int n){
  int i;

  for(i=0;i<n-1;i++){
    printf("%c%d ",x[i].sign,x[i].number);
  }
  printf("%c%d\n",x[n-1].sign,x[n-1].number);

}

void  swap(CARD *x, CARD *y)
{
  CARD  work;

  work = *x;
  *x = *y;
  *y = work;
}

Measured memory_bytes: 608
from collections import defaultdict, deque
import sys
input = sys.stdin.readline

N, M, L = map(int, input().split())
v = [[] for _ in range(N)]
for _ in range(M) :
    A, B, C = map(int, input().split())
    if C > L :
        continue
    v[A-1].append((B-1, C))
    v[B-1].append((A-1, C))
    
Q = int(input())

start = defaultdict(lambda : [])
for i in range(Q) :
    s, t = map(int, input().split())
    start[s-1].append((t-1, i))

INF = N * N
ret = [-1] * Q
for s, d in start.items() :
    # print(s, d)
    pre1 = [-1] * N
    pre2 = [INF] * N
    pre1[s] = L #のこりのガソリン
    pre2[s] = 0 #補充回数
    queue = deque([(s, L, 0)])
    
    while queue :
        # print(queue)
        cur, rest, cost = queue.popleft()
        if pre2[cur] < cost or (pre2[cur] == cost and pre1[cur] > rest):
            continue
            
        for nex, c in v[cur] :
            if rest >= c :
                nrest = rest - c
                ncost = cost
            else :
                nrest = L - c
                ncost = cost + 1
                
            if ncost < pre2[nex] or (ncost == pre2[nex] and nrest > pre1[nex]) :                    
                queue.append((nex, nrest, ncost))
                pre1[nex] = nrest
                pre2[nex] = ncost
                
    # print(pre1)
    # print(pre2)
    # print()
    
    for dest, i in d :
        if pre1[dest] == -1 :
            ret[i] = -1
        else :
            ret[i] = pre2[dest]
        
for r in ret :
    print(r)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int inf = 1e9 + 7;
const int maxN = 1e6 + 5;

int n, m, a, b, ans[maxN], z;
ll k;
vector<vector<ll>> A(105);
bool used[maxN];
int arr[maxN], arr1[maxN];
vi graph[maxN];
queue<int> Q;


int main() {
	scanf("%d",&n);
	REP(i, 2 * n) 
		scanf("%d",&arr[i]);
	sort(arr, arr + 2 * n);
	int sum = 0;
	for (int i = 0; i < 2 * n; i += 2){
		sum += arr[i];
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 24188
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/14 20:32:34
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=2e5+5;
int a[maxx*10],num[maxx*10],mx=0;
bool ans[maxx*10];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n=read();
	For(i,1,n){
		a[i]=read();
		num[a[i]]++;
		mx=max(mx,a[i]);
	}
	For(i,1,n){
		if(!num[a[i]]) continue;
		if(num[a[i]]>1){
			ans[a[i]]=1;
			num[a[i]]=0;
		}
		for(int j=2*a[i];j<=mx;j+=a[i])
			ans[j]=1;
	}
	int cnt=0;
	For(i,1,n)
		if(!ans[a[i]]){
		//	printf("%d ",i);
			++cnt;
		}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 9120
//
//  main.cpp
//  ITP1_6-A
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[])
{

    int n;
    int index = 0;
    cin >> n;
    
    int numList[n];
    
    while (true) {
        int temp;
        
        cin >> temp;
        numList[index] = temp;
        index++;
        
        if (index >= n){
            break;
        }
    }
    
    for (int i = index-1; i >= 0; i--) {
        
        if (i == 0){
            printf("%d",numList[0]);
            break;
        }
        
        printf("%d ",numList[i]);
    }
    
    printf("\n");
    
    
    return 0;
}

Measured memory_bytes: 1148
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

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

vector<int> enum_div(int n) {
   vector<int> ret;
   for (int i=1 ; i*i<=n ; ++i) {
      if (n%i == 0) {
         ret.push_back(i);
         if (i!=1 && i*i!=n) {
            ret.push_back(n/i);
         }
      }
   }
   return ret;
}

int main() {
   int A, B, K;
   cin >> A >> B >> K;
   int k = gcd(A, B);
   vector<int> ans;
   ans = enum_div(k);
   ans.push_back(k);
   sort(ans.rbegin(), ans.rend());
   cout << ans[K - 1] << endl;
   return 0;
}


Measured memory_bytes: 256
point = '.'
while 1:
	H, W = map(int, raw_input().split())
	if H == 0 and W == 0:
		break
	for h in xrange(H):
		if (h == 0) or (h == H - 1):
			print '#' * W
		else:
			print ('#' + point * (W - 2) + '#')
	print

Measured memory_bytes: 4204
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

void solve(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if(a < b || d < b){
        pt("No");
        return;
    }

    if(b <= c){
        pt("Yes");
        return;
    }

    ll g = gcd(b, d);
    ll m = (((a / g) + 1) * g - a);
    if (0 < m && m < b - c) pt("No");
    else pt("Yes");

}

int main(){
    ll T; cin >> T;
    while(T--){
        solve();
    }    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

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

    int c[3][3] = {0};
    rep(i,0,3){
        rep(j,0,3){
            int tmp;
            cin >> tmp;
            c[i][j] = tmp;
        }
    }
    bool flg = false;
    rep(i,0,c[0][0]+1){
        int a1 = i;
        int b1 = c[0][0] - i;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;
        if(a2 + b2 == c[1][1] && a2+b3 == c[1][2] && a3+b2 == c[2][1] && a3+b3 == c[2][2]){
            flg = true;
        }


    }
    if(flg){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
ans = 0
for i in range(N+1):
    for j in range(N+1):
        temp = N-(R*i+G*j)
        if temp>=0 and temp%B==0:
            ans += 1
print(ans)

Measured memory_bytes: 40812
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

struct Problem {
	int rank;
	int bonus;
	int num;
};
typedef vector<Problem> p_vec;

int evaluate(const p_vec ps, uint32_t take, int obj)
{
	int score = 0;
	int num   = 0;
	for (int i = 0; i < ps.size(); i++) {
		if (take & (1 << i)) {
			score += ps[i].rank * 100 * ps[i].num + ps[i].bonus;
			num += ps[i].num;
		}
	}

	for (int i = ps.size() - 1; 0 <= i; i--) {
		if (score >= obj) break;

		if (take & (1 << i)) continue;
		const Problem& cur = ps[i];
		int max_num  = cur.num - 1;
		int rem      = obj - score;
		int take_num = min(max_num, (rem + cur.rank * 100 - 1) / (cur.rank * 100));

		num   += take_num;
		score += take_num * cur.rank * 100;
	}

	if (score < obj) return -1;


	return num;
}

int seek_solve(const p_vec& ps, int obj) {
	int min_val = INT_MAX;
	for (uint32_t i = 0; i < (1 << ps.size()); i++) {
		int cur = evaluate(ps, i, obj);
		if (cur < 0) continue;
		
		min_val = min(min_val, cur);
	}

	return min_val;
}

int main()
{
	int d, obj; cin >> d >> obj;

	vector<Problem> pros(d);
	for (int i = 0; i < d; i++) {
		pros[i].rank = i + 1;
		cin >> pros[i].num;
		cin >> pros[i].bonus;
	}

	int val = seek_solve(pros, obj);
	cout << val << endl;

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(a + c, b + c)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long int r,d,x,i,sum=0;
    cin>>r;
    cin>>d;
    cin>>x;
    for(i=1;i<=10;i++)
    {
        sum=(r*x)-d;
        cout<<sum<<endl;
        x=sum;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;

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

int area[90][90];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int ans,n,m;

void dfs(int x,int y,int crash) {
  if(crash > ans) ans = crash;
  int i;
  rep(i,4) {
    if(x+dx[i] >= 0 && x+dx[i] < n && y+dy[i] >= 0 && y+dy[i] < m) {
      if(area[y+dy[i]][x+dx[i]] == 1) {
	area[y+dy[i]][x+dx[i]] = 0;
	dfs(x+dx[i],y+dy[i], crash+1);
	area[y+dy[i]][x+dx[i]] = 1;
      }
    }
  }
}

int main() {
  int i,j,k;
  while(scanf("%d %d", &n, &m), n|m) {
    memset(area, 0, sizeof(area));
    ans = 0;
    rep(i,m) {
      rep(j,n) {
	scanf("%d", &area[i][j]);
      }
    }

    rep(i,m) {
      rep(j,n) {
	if(area[i][j] == 1) {
	  area[i][j] = 0;
	  dfs(j,i,1);
	  area[i][j] = 1;
	}
      }
    }

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

Measured memory_bytes: 0
N=int(input())
L=[]
for i in range(N):
	L.append(int(input()))
count=0
ans=0
i=0
while(1):
	count+=1
	if count==N+100:
		print(-1)
		exit()
	i=L[i]-1
	ans+=1
	if i==1:
		print(ans)
		exit()

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define ret return
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
const int maxn = 2e5 + 10;
 
int main() {
    FAST
    ll a;
    long double b;
    cin >> a >> b;
    ll val = a * b;
    cout << val << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <map>
using namespace std;
const long long MOD = 1e9 + 7;

map<pair<long long, int>, long long> mm;

long long solve(long long N, int b)
{
  if (N < 0)
    return 0LL;
  if (b == -1)
    return 1LL;
  if (N > 4LL * (1LL << b))
    N = 4LL * (1LL << b);
  //cout << N << " " << b << endl;
  if (mm[{N, b}] != 0)
    return mm[{N, b}];
  mm[{N, b}] = (solve(N, b - 1) + solve(N - (1LL << b), b - 1) + solve(N - 2LL * (1LL << b), b - 1)) % MOD;
  return mm[{N, b}];
}

int main()
{
  long long n;
  cin >> n;
  cout << solve(n, 60);
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<Pii> ps(N);
    for (int i = 0; i < N; i++) {
        cin >> ps[i].first >> ps[i].second;
    }

    Vi xs(N), ys(N);
    for (int i = 0; i < N; i++) {
        xs[i] = ps[i].first;
        ys[i] = ps[i].second;
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());

    int num_x = (int)xs.size();
    int num_y = (int)ys.size();

    unordered_map<int, int> idx_x, idx_y;
    for (int i = 0; i < num_x; i++) {
        idx_x[xs[i]] = i;
    }
    for (int i = 0; i < num_y; i++) {
        idx_y[ys[i]] = i;
    }

    vector<Vi> csum(num_x + 1, Vi(num_y + 1));
    for (int i = 0; i < N; i++) {
        int ix = idx_x[ps[i].first];
        int iy = idx_y[ps[i].second];
        csum[ix + 1][iy + 1] = 1;
    }
    for (int i = 0; i < num_x; i++) {
        for (int j = 0; j < num_y; j++) {
            csum[i + 1][j + 1] += csum[i + 1][j] + csum[i][j + 1] - csum[i][j];
        }
    }

    ll ans = L_INF;
    for (int i = 0; i <= num_x; i++) {
        for (int j = 0; j <= num_y; j++) {
            for (int x = i + 1; x <= num_x; x++) {
                for (int y = j + 1; y <= num_y; y++) {
                    int cnt = csum[x][y] - csum[x][j] - csum[i][y] + csum[i][j];
                    if (cnt >= K) {
                        ll s = (ll)(xs[x - 1] - xs[i]) * (ll)(ys[y - 1] - ys[j]);
                        ans = min(ans, s);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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



int main() {
    
	long long k,n,c;
	cin>>n>>k;
	long long a[n][n];
	for(long long i=0;i<n;i++){
	        for(long long j=0;j<n;j++){
	            cin>>a[i][j];
	        }
	}
	
	long long dp[n][n],t[n][n];
	memset(dp,0,sizeof(dp));
	for(long long i=0;i<n;i++)
	       dp[i][i]=1;
	while(k){
	    if(k&1){
	        
	   for(long long i=0;i<n;i++)
	        for(long long j=0;j<n;j++)
	            t[i][j]=dp[i][j];
	    memset(dp,0,sizeof(dp));
	    for(long long i=0;i<n;i++)
	            for(long long j=0;j<n;j++)
	                for(long long k=0;k<n;k++)
	                   dp[i][j]=(dp[i][j]+t[i][k]*a[k][j])%1000000007;
	    }
	    for(long long i=0;i<n;i++)
	            for(long long j=0;j<n;j++)
	                t[i][j]=a[i][j];
	    memset(a,0,sizeof(a));
	    for(long long i=0;i<n;i++)
	            for(long long j=0;j<n;j++)
	                for(long long k=0;k<n;k++)
	                   a[i][j]=(a[i][j]+t[i][k]*t[k][j])%1000000007;
	    
	    k>>=1;
	}
	
	
	long long ans=0;
	for(long long i=0;i<n;i++)
	    for(long long j=0;j<n;j++)
	        ans=(dp[i][j]+ans)%1000000007;
	        
	cout<<ans;
	
}




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

#define _LL long long

char _map[2000][2000];
int _xcount[2000][2000];
int _ycount[2000][2000];

int main()
{
    int h, w;
    cin >> h >> w;

    for(int y = 0; y < h; y++ )
    {
        string s;
        cin >> s;
        for( int x = 0; x < w; x++ )  _map[x][y] = (( s[x] == '.' ) ? 0 : 1);
    }

    for( int y = 0; y < h; y++ )
    {
        int prex = 0;
        for( int x = 0; x < w; x++ )
        {
            if( _map[x][y] == 1 )
            {
                int count = x - prex;
                for( int x2 = prex; x2 < x; x2++ ) _xcount[x2][y] = count;
                _xcount[x][y] = 0;
                prex = x + 1;
            }
        }
        {
            int count = w - prex;
            for( int x2 = prex; x2 < w; x2++ ) _xcount[x2][y] = count;
        }
    }

    for( int x = 0; x < w; x++ )
    {
        int prey = 0;
        for(int y = 0; y < h; y++ )
        {
            if( _map[x][y] == 1 )
            {
                int count = y - prey;
                for( int y2 = prey; y2 < y; y2++ ) _ycount[x][y2] = count;
                _ycount[x][y] = 0;
                prey = y + 1;
            }
        }
        {
            int count = h - prey;
            for( int y2 = prey; y2 < h; y2++ ) _ycount[x][y2] = count;           
        }
    } 

    int ans = 0;
    for( int x = 0; x < w; x++ )
    {
        for(int y = 0; y < h; y++ )
        {
            ans = max(ans, _xcount[x][y] + _ycount[x][y] - 1);
        }
    }
    cout << ans;
}

Measured memory_bytes: 38780
#include<iostream>
using namespace std;
int main(){
char a[][11]={"null","one pair","two pair","three card","straight","full house","four card"};
long i,h,f,hh[14];
char c;
while(cin>>h){
for(i=0;i<13;i++)hh[i]=0;
hh[h-1]++;
for(i=1;i<5;i++){cin>>c>>h;hh[h-1]++;}
f=0;
for(i=0;i<13;i++){
if(hh[i]==4){
f=6;
}else if(hh[i]==3){
if(f==1)f=5;else f=3;
}else if(hh[i]==2){
if(f==3)f=5;
else if(f==1)f=2;
else f=1;
}
}
if(f==0){
  for(i=0;i<13;i++)if(hh[i]==1)break;
  if(i<9){
  if(hh[i+1]==1)
  if(hh[i+2]==1)
  if(hh[i+3]==1)
  if(hh[i+4]==1)f=4;
  }
  if(i==0){
  if(hh[i+9]==1)
  if(hh[i+10]==1)
  if(hh[i+11]==1)
  if(hh[i+12]==1)f=4;
  }
}
cout<<a[f]<<endl;
}
return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int a, b;
  cin >> a >> b;
  if (2*b <= a){
      cout << a-2*b;
  }else{
      cout <<0;
  }
  return 0; 
}


Measured memory_bytes: 256
import java.lang.Math.max
import java.lang.Math.min

fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val days = IntArray(360){0}
    repeat(n){
        val (m, d, v, s) = readLine()!!.trim().split(' ').map(String::toInt)
        val from = (m - 1) * 30 + d - 1
        val to = (from + v - 1) % 360
        for (diff in 0 until v){
            if (days[(from + diff) % 360] < s) days[(from + diff) % 360] = s
        }
        for (diff in v until 360){
            if (days[(from + diff) % 360] < max(0, s - min((from - (from + diff) + 360) % 360, (from + diff - to + 360) % 360))) {
                days[(from + diff) % 360] = max(0, s - min((from - (from + diff) + 360) % 360, (from + diff - to + 360) % 360))
            }
        }
    }
    println(days.min()!!)
}


Measured memory_bytes: 34568
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong(),count=0,sum=1;
		while(h!=1) {
			count++;
			h/=2;
			sum+=(long)Math.pow(2, count);
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 21972
import java.io.*;

class DISE
{
  public int[] roll(int[] f, char way)
  {
    int[] n = {f[0], f[1], f[2], f[3], f[4], f[5]};

    switch(way){
      case 'N':
        f[0] = n[1];
        f[1] = n[5];
        f[4] = n[0];
        f[5] = n[4];
        break;
      case 'S':
        f[0] = n[4];
        f[1] = n[0];
        f[4] = n[5];
        f[5] = n[1];
        break;
      case 'E':
        f[0] = n[3];
        f[2] = n[0];
        f[3] = n[5];
        f[5] = n[2];
        break;
      case 'W':
        f[0] = n[2];
        f[2] = n[5];
        f[3] = n[0];
        f[5] = n[3];
        break;
      default:
        break;
    }
    return f;
  }
}

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    String[] face = str.split(" ");
    int[] num = {0, 1, 2, 3, 4, 5};

    DISE dise = new DISE();
    int j;
    str = br.readLine();
    for(int i = 0; i < str.length(); i++){
      dise.roll(num, str.charAt(i));
    }
    System.out.println(face[num[0]]);
  }
}

Measured memory_bytes: 24456
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    vector <vector <int> > DP;
    DP.resize(s.size()+1, vector<int>(t.size()+1, 0));
    s = " " + s;
    t = " " + t;
    /*
        DP[i][j] = max(DP[i-1][j], DP[i][j-1])

    */

    for (int i = 1; i < s.size(); i++){
        for (int j = 1; j < t.size(); j++){
            DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            if (s[i] == t[j]){
                DP[i][j] = max(DP[i][j], DP[i-1][j-1] + 1);
            }
        }
    }
    
    string Res = "";
    int i = s.size()-1;
    int j = t.size()-1;
    while (i > 0 && j > 0){
        if (s[i] == t[j]){
            if (DP[i][j] == DP[i-1][j-1] + 1){
                Res += s[i];
                i--;
                j--;
            }
        }
        else{
            if (DP[i][j] == DP[i][j-1]){
                j--;
            }
            else{
                i--;
            }
        } 
    }
    reverse(Res.rbegin(), Res.rend());
    cout << Res;


}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
   long long  int ans = 1;
   for(int i = 1;i < N;i++){
       if(i * i <=  N) ans = i * i;
       else break;
   }
   cout << ans << endl;
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    string s;
    ll nn=0;
    cin >> s;
    for(ll i=0;i<s.size();i++)
    {

        ll x=s[i]- '0';
        nn+=x;
    }
    if(nn%9) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 3728