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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int d, w;
        cin >> d >> w;
        if(d == 0) break;
        vector<vector<int>> e(d, vector<int>(w));
        for(int i = 0; i < d; ++i){
            for(int j = 0; j < w; ++j){
                cin >> e[i][j];
            }
        }
        vector<vector<int>> a(d+1, vector<int>(w+1));
        for(int i = 1; i <= d; ++i){
            for(int j = 0; j < w; ++j){
                a[i][j+1] = a[i][j] + e[i-1][j];
            }
        }
        for(int i = 0; i < d; ++i){
            for(int j = 1; j <= w; ++j){
                a[i+1][j] += a[i][j];
            }
        }
        int ans = 0;
        for(int he = 3; he <= d; ++he){
            for(int wi = 3; wi <= w; ++wi){
                for(int y = 0; y <= d-he; ++y){
                    for(int x = 0; x <= w-wi; ++x){
                        int inner_max = 0, outer_min = INF;
                        for(int i = 0; i < he-2; ++i){
                            for(int j = 0; j < wi-2; ++j){
                                inner_max = max(inner_max, e[y + i + 1][x + j + 1]);
                            }
                        }
                        for(int i = 0; i < he; ++i){
                            if(e[i+y][x] <= inner_max) goto END;
                            if(e[i+y][x+wi-1] <= inner_max) goto END;
                            outer_min = min({outer_min, e[i+y][x], e[i+y][x+wi-1]});
                        }
                        for(int i = 0; i < wi; ++i){
                            if(e[y][x+i] <= inner_max) goto END;
                            if(e[y+he-1][x+i] <= inner_max) goto END;
                            outer_min = min({outer_min, e[y][x+i], e[y+he-1][x+i]});
                        }
                        ans = max(ans, (wi-2)*(he-2)*outer_min - (a[y+he-1][x+wi-1] - a[y+he-1][x+1] - a[y+1][x+wi-1] + a[y+1][x+1]));
                        END:;
                    }
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> b(N);
	bool ng = false;
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		if (b[i] > i + 1) {
			ng = true;
		}
	}
	if (ng) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> res;
	for (int i = 0; i < N; i++) {
		int pos = -1;
		for (int j = b.size() - 1; j >= 0; j--) if (b[j] == j + 1) {
			pos = j + 1;
			b.erase(b.begin() + j, b.begin() + j + 1);
			break;
		}
		res.push_back(pos);
	}
	reverse(res.begin(), res.end());
	for (auto p : res) {
		printf("%d\n", p);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

struct edge{int u,v,cost;};

int par[100000],rank[100000],V,E;
edge es[100000];

void init(int n){for(int i=0;i<n;i++){par[i]=i;rank[i]=0;}}
int find(int x){if(par[x]==x)return x;else return find(par[x]);}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rank[x]<rank[y])par[x]=y;else{par[y]=x;if(rank[x]==rank[y])rank[x]++;}}
bool same(int x,int y){return find(x)==find(y);}

bool comp(const edge e1,const edge e2){return e1.cost<e2.cost;}

int kruskal(){
	sort(es,es+E,comp);
	init(V);
	int res=0;
	rep(i,E){
		edge e=es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			res+=e.cost;
		}
	}
	return res;
}

int main(){
	while(cin>>V>>E&&V){
		rep(i,E)cin>>es[i].u>>es[i].v>>es[i].cost;
		cout<<kruskal()<<endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int n, m;
    
    cin >> n >> m;
    
    cout << (n - 1) * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  string s;
  cin >> s;
  if((s[0]-'0')*10 + (s[1]-'0') > 12){
    if((s[2]-'0')*10 + (s[3]-'0') <= 12 && (s[2]-'0')*10 + (s[3]-'0') >= 1 ){
      cout << "YYMM";return 0;
    }
    else{
      cout << "NA";return 0;
    }
  }
  else if((s[0]-'0')*10 + (s[1]-'0') == 0){
    if((s[2]-'0')*10 + (s[3]-'0') <= 12 && (s[2]-'0')*10 + (s[3]-'0') >= 1){
      cout << "YYMM";return 0;
    }
    else{
      cout << "NA";return 0;
    }
  }
  else {
    if((s[2]-'0')*10 + (s[3]-'0') <= 12 && (s[2]-'0')*10 + (s[3]-'0') >= 1){
      cout << "AMBIGUOUS";return 0;
    }
    else if((s[2]-'0')*10 + (s[3]-'0') == 0){
      cout << "MMYY";return 0;
    }
    else{
      cout << "MMYY";return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef vector<int> sequence;

sequence shop(int value) {
  sequence seq(4);
  seq[0] = value / 500; value -= 500 * seq[0];
  seq[1] = value / 100; value -= 100 * seq[1];
  seq[2] = value / 50; value -= 50 * seq[2];
  seq[3] = value / 10;
  return seq;
}

int main() {
  int value;
  bool flag = false;
  while (cin >> value and value) {
    if (flag) { cout << endl; } else { flag = true; }
    sequence seq(4);
    REP(i, 4) {
      cin >> seq[3-i];
    }
    int total = seq[0]*500 + seq[1]*100 + seq[2]*50 + seq[3]*10;
    sequence ret = shop(total - value);
    
    int values[4] = {500, 100, 50, 10};

    for (int i = 3; i >= 0; i--) {
      int coins = max(0, seq[i] - ret[i]);
      if (coins) {
        cout << values[i] << " " << coins << endl;
      }
    }
  }
}

Measured memory_bytes: 1192
#include <vector>
using namespace std;

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x)==root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

#include <iostream>

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(M);
    vector<int> B(M);
    for (int i=0; i<M; i++)
    {
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }

    long long c = (long long)N*(N-1)/2;
    UnionFind UF(N);
    vector<long long> ans(M);
    ans[M-1] = c;
    for (int i=M-1; i>=1; i--)
    {
        if (!UF.same(A[i], B[i]))
        {
            c -= (long long)UF.size(A[i]) * UF.size(B[i]);
            UF.unite(A[i], B[i]);
        }
        ans[i-1] = c;
    }
    for (int i=0; i<M; i++)
    {
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int[] numbers = new int[n];
	  int counter = 0;

	  for(int i = 0; i < n; i++) {
		  numbers[i] = sc.nextInt();
	  }
	  while(true) {
		  boolean isKisuu = false;
		  for(int j = 0; j < n; j++) {
			  if (numbers[j] % 2 == 1) {
				  isKisuu = true;
				  break;
			  } else {
				  numbers[j] /= 2;
				  counter = counter + 1;
			  }
		  }

		 if (isKisuu) {
			 break;
		 }


	  }

	  System.out.println(counter / n);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
void Read ( LL &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
const LL maxn = 1e5+5 ;
LL n, m, a[maxn], h[maxn], l[maxn] ;
int main() {
	LL i ;
	Read(n) ;
	for ( i = 1 ; i <= n ; i ++ ) Read(a[i]) ;
	h[n+1] = l[n+1] = 2 ;
	for ( i = n ; i ; i -- ) {
		h[i] = h[i + 1]/a[i] ;
		l[i] = ceil(l[i+1]*1.0/a[i]) ;
		l[i] *= a[i], h[i] *= a[i] ;
		h[i] += a[i]-1 ;
		if (l[i] > h[i]) {
			puts("-1") ;
			return 0 ;
		}
	}
	if (l[1] <= h[1]) cout << l[1] << " " << h[1] << endl ;
	else puts("-1") ;
	return 0 ;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;

int main(){
    int N, C;
    cin >> N >> C;
    vector<P> sc(N+1), tc(N+1);
    for(int i = 1;i <= N;i++){
        int si, ti, ci;
        cin >> si >> ti >> ci;
        sc[i] = P(si, ci);
        tc[i] = P(ti, ci);
    }
    sort(sc.begin(), sc.end());
    sort(tc.begin(), tc.end());
    vector<vector<bool>> map(31, vector<bool>(1e5+1, false));
    int sid = 1;
    int tid = 1;
    int ans = 0;
    int count = 0;
    bool f = false;
    while(sid <= N || tid <= N){
        int s, t, scc, tcc;
        if(sid == N+1){
            s = 1e6;
            scc = -1;
        }else{
            s = sc[sid].first;
            scc = sc[sid].second;
        }
        if(tid == N+1){
            t = 1e6;
            tcc = -1;
        }else{
            t = tc[tid].first;
            tcc = tc[tid].second;
        }
        if(s < t){
            count++;
            sid++;
            ans = max(ans, count);
        }else if(t < s){
            if(f){
                int count2 = 0;
                while(true){
                    int tt = tc[tid].first;
                    int ttcc = tc[tid++].second;
                    if(map[ttcc][tt])   count--;
                    else    count2++;
                    if(tid == N+1 || tc[tid].first > t) break;
                }
                f = false;
                ans = max(ans, count);
                count -= count2;
            }else{
                count--;
                tid++;
            }
        }else{
            while(true){
                int ss = sc[sid].first;
                int sscc = sc[sid++].second;
                map[sscc][ss] = true;
                count++;
                if(sid == N+1 || sc[sid].first > ss)  break;
            }
            f = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
# input
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))

# process
dp = [[100]*(W+1) for _ in range(H+1)]
dp2 = [[True]*(W+1) for _ in range(H+1)]
dp[0][1] = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            x = dp[i][j+1]+1 if dp2[i][j+1] else dp[i][j+1]
            y = dp[i+1][j]+1 if dp2[i+1][j] else dp[i+1][j]
            dp2[i+1][j+1] = False
        else:
            x = dp[i][j+1]
            y = dp[i+1][j]
            dp2[i+1][j+1] = True
        dp[i+1][j+1] = min(dp[i+1][j+1], x, y)

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


Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, Q;
int S, T, X;
size_t pos = 0;

int main() {
    scanf("%d %d\n", &N, &Q);
    set<int> C;
    vector<int> D(Q);
    vector<pair<int, int>> E(2 * N);
    REP(i, N) {
        scanf("%d %d %d\n", &S, &T, &X);
        E[i*2] = make_pair(S - X, X);
        E[i*2+1] = make_pair(T - X, -X);
    }
    REP(i, Q) scanf("%d", &D[i]);
    sort(ALL(E));
    REP(i, Q) {
        while(pos < 2 * N && E[pos].first <= D[i]) {
            if(E[pos].second > 0) C.insert(E[pos].second);
            else C.erase(C.find(-E[pos].second));
            pos++;
        }
        printf("%d\n", C.empty() ? -1 : *C.begin());
    }
 	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int x;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> x;
	cout << 1 - x << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl x(n+1), y(n+1), z(n+1);
    rep(i, n) {
        if(s[i] == 'R') {
            x[i+1] = x[i] + 1;
            y[i+1] = y[i];
            z[i+1] = z[i];
        }
        else if(s[i] == 'G') {
            x[i+1] = x[i];
            y[i+1] = y[i] + 1;
            z[i+1] = z[i];
        }
        else if(s[i] == 'B') {
            x[i+1] = x[i];
            y[i+1] = y[i];
            z[i+1] = z[i] + 1;
        }
    }

    ll ans = 0;
    exrep(i, 0, n-3) {
        exrep(j, i+1, n-2) {
            ll k = 2*j - i;
            if( (s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R') ) {
                ans += z[n] - z[j+1];
                if(k < n && s[k] == 'B') {
                    ans--;
                }
            } 
            else if( (s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G') ) {
                ans += x[n] - x[j+1];
                if(k < n && s[k] == 'R') {
                    ans--;
                }
            } 
            else if( (s[i] == 'B' && s[j] == 'R') || (s[i] == 'R' && s[j] == 'B') ) {
                ans += y[n] - y[j+1];
                if(k < n && s[k] == 'G') {
                    ans--;
                }
            } 
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 10000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<int> s, t;
    s.push_back(-INF2); s.push_back(-INF2);
    rep(i, A) {
        int e; cin >> e;
        s.push_back(e);
    }
    s.push_back(INF2); s.push_back(INF2);
    t.push_back(-INF2); t.push_back(-INF2);
    rep(i, B) {
        int e; cin >> e;
        t.push_back(e);
    }
    t.push_back(INF2); t.push_back(INF2);

    while(Q--) {
        int x; cin >> x;
        auto itr1 = lower_bound(s.begin(), s.end(), x);
        auto itr2 = lower_bound(t.begin(), t.end(), x);
        int ans = INF2;
        REP(i, -1, 1) {
            REP(j, -1, 1) {
                int x1 = *(itr1 + i);
                int x2 = *(itr2 + j);
                ans = min(ans, abs(x - x1) + abs(x1 - x2));
                ans = min(ans, abs(x - x2) + abs(x2 - x1));
            }
        }
        cout << ans << endl;
    }

    return 0;
}


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

bool w[3005],s[3005];

int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    //水を全探索
    rep(i,35)rep(j,35){
        int x=a*i*100+b*j*100;
        if(x<=3000)w[x]=true;
    }
    //砂糖を全探索
    rep(i,3005)rep(j,3005){
        int x=c*i+d*j;
        if(x<=3000)s[x]=true;
    }
    double per=-1;
    int answs=0,anss=0;
    //あり得る組み合わせについて全探索
    for(int i=100; i<=3000; ++i){
        for(int j=0; j<=3000; ++j){
            if(!w[i]||!s[j]||i+j>f)continue;
            if(j*100.0/(i+j)>per){
                if(j*100>i*e)continue;
                per=j*100.0/(i+j);
                answs=i+j;
                anss=j;
            }
        }
    }
    cout<<answs<<" "<<anss<<endl;
}

Measured memory_bytes: 3636
n, m, l = map(int, input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = list(map(int, input().split()))
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    for j in range(l):
        print(c[i][j], end="")
        if j != l-1:
            print(" ", end="")
    print("")


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
string S;

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

  if (N % 2 != 0){
    No(); return 0;
  }

  for (int i = 0; i < N / 2; i++){
    if (S[i] != S[i + N / 2]){
      No(); return 0;
    }
  }
  Yes();

  return 0;
}


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

using   namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define  all(v)       (v).begin(),(v).end()
#define  rall(v)      (v).rbegin(),(v).rend()
#define  pb           push_back  
#define  eb           emplace_back
#define  mp           make_pair
#define  ff           first
#define  ss           second
#define  pf           push_front
#define  bs           binary_search
#define  lb           lower_bound
#define  ub           upper_bound
#define  umap         unordered_map
#define  uset         unordered_set
#define  dec(x)       fixed<<setprecision(x)
#define  lcm(a,b)    (a*b/__gcd(a,b))

typedef  priority_queue<ll>  pq;
typedef  priority_queue<ll,vector<ll>,greater<ll>> pqmn;
typedef  pair<ll,ll> pll;

const    ll inf=LLONG_MAX;
const    ll mod=1e9+7;
const    ld pi=acos(-1);
                    
void solution(){
ll n;
cin>>n;
ll d;
cin>>d;
ll val=0;
while(n--){
    ll a,b;
    cin>>a>>b;
    ll ans=ceil(1.0*sqrt(a*a+b*b));
    if(ans<=d){
        val++;
    }
}
cout<<val;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  long long num[3],K;
  cin >> num[0] >> num[1] >> num[2] >> K;
  if(K % 2 )    cout << num[1] - num[0] << endl;
  else          cout << num[0] - num[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h);
  rep(i, h) {
    a[i].reserve(w+1);
  }
  vector<vector<int>> b(w);
  rep(i, w) {
    b[i].reserve(h+1);
  }
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '#') {
        a[i].push_back(j);
        b[j].push_back(i);
      }
    }
    a[i].push_back(w);
  }
  rep(j, w) {
    b[j].push_back(h);
  }

/*
  rep(i, h) {
    for (auto v : a[i]) {
      cerr << v << " ";
    }
    cerr << endl;
  }
  rep(i, w) {
    for (auto v : b[i]) {
      cerr << v << " ";
    }
    cerr << endl;
  }
*/

  vector<vector<int>> aa(h, vector<int>(w+1, 0));
  rep(i, h) {
    int pos = -1;
    for (int j = 0; j < a[i].size(); j++) {
      int v = a[i][j] - pos - 1;
      for (int k = pos + 1; k < a[i][j]; k++) {
        aa[i][k] = v;
      }
      pos = a[i][j];
    }
  }
/*
  rep(i, h) {
    rep(j, w) cerr << aa[i][j] << " ";
    cerr << endl;
  }
*/
  vector<vector<int>> bb(w, vector<int>(h+1, 0));
  rep(i, w) {
    int pos = -1;
    for (int j = 0; j < b[i].size(); j++) {
      int v = b[i][j] - pos - 1;
      for (int k = pos + 1; k < b[i][j]; k++) {
        bb[i][k] = v;
      }
      pos = b[i][j];
    }
  }
/*
  rep(i, w) {
    rep(j, h) cerr << bb[i][j] << " ";
    cerr << endl;
  }
*/
  ll ans = 0;
  rep(i, h) {
    rep(j, w) {
      ll tmp = ll(aa[i][j]) + bb[j][i] - 1;
      chmax(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 63104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
namespace ztd{
    using namespace std;
    #define reg register
    #define ms(a) memset(a,0,sizeof(a))
    typedef long long ll;
    typedef unsigned long long ull;
    typedef unsigned int uint;
    typedef double db;
    //basic I/O
    template<typename T> inline T read(T& t) {//fast read
        t=0;short f=1;char ch=getchar();double d = 0.1;
        while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
        while (ch>='0'&&ch<='9') t=t*10+ch-'0',ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t*=f;
        return t;
    }}
using namespace ztd;
double n, x; ll t;
signed main(){
    read(n); read(x); read(t);
    printf("%lld\n", (long long)(ceil(n/x)) * t);
    // cout << (ll)(ceil(n/x)) * t << endl;
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  ans1(n%10==9||n/10==9);


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <iostream>

const int STEP_NUM = 4;
const int STEP[STEP_NUM][STEP_NUM] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

const int MAX_SIZE = 1000;
char field[MAX_SIZE + 1][MAX_SIZE + 1];

const int MAXN = 10;
int locationsX[MAXN];
int locationsY[MAXN];
 
int H, W, N;

int get_shortest_distance(int current_HP)
{
	int sx = locationsX[current_HP-1];
	int sy = locationsY[current_HP-1];
	int ex = locationsX[current_HP];
	int ey = locationsY[current_HP];

	bool is_visit[H + 1][W + 1]={};
	/*
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			is_visit[i][j]=false;
	*/
	std::set<std::pair<int,int>> frontier;
	frontier.insert(std::pair<int,int>{sx,sy});
	int nx,ny;
	for(int step=0;step<100000000;step++)
	{
		for(auto p:frontier)
		{
			if(p.first==ex && p.second==ey)	return step;
			is_visit[p.first][p.second] = true;
		}
		std::set<std::pair<int,int>> next_frontier;
		for(auto p:frontier)
		{
			for(int i=0;i<STEP_NUM;i++)
			{
				nx = p.first+STEP[i][0];
				ny = p.second+STEP[i][1];
				if(nx<0 || H<=nx) 		continue;
				if(ny<0 || W<=ny) 		continue;
				if(field[nx][ny]=='X') 	continue;
				if(is_visit[nx][ny]) 	continue;
				next_frontier.insert(std::make_pair(nx,ny));
			}
		}
		frontier = next_frontier;
	}
	return -1;
}

int solve()
{
	int total_step = 0;
	for(int i=1;i<N+1;i++)
		total_step += get_shortest_distance(i);
	return total_step;
}

int main()
{
	scanf("%d %d %d", &H, &W, &N);
	for(int i=0; i<H; i++)
		scanf("%s", field[i]);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			int HP=-1;
			if(field[i][j]=='S')	HP=0;
			if(field[i][j]=='1')	HP=1;
			if(field[i][j]=='2')	HP=2;
			if(field[i][j]=='3')	HP=3;
			if(field[i][j]=='4')	HP=4;
			if(field[i][j]=='5')	HP=5;
			if(field[i][j]=='6')	HP=6;
			if(field[i][j]=='7')	HP=7;
			if(field[i][j]=='8')	HP=8;
			if(field[i][j]=='9')	HP=9;
			if(HP!=-1)
			{
				locationsX[HP]=i;
				locationsY[HP]=j;
			}
		}
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 5104
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  int[] A = new int[N]; //生徒の出席番号を出席した順番に記録
	  for(int i=1; i<=N; i++) {
		  int n = sc.nextInt();
		  A[n-1] = i; 
	  }
	  for(int i=0; i<N; i++) {
		  int n = A[i];
		  out.print(n + " ");
	  }

	  }	  
  }	

Measured memory_bytes: 61176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 666
ll M,f[N][N],s[N][N],ans,C[N][N];
ll n,K;
int main(){
    scanf("%lld%lld%lld",&n,&K,&M);
    C[0][0]=1;
    for (ll i=1;i<=n;i++){
        C[i][0]=1;
        for (ll j=1;j<=i;j++) 
            (C[i][j]=C[i-1][j-1]+C[i-1][j])%=M;
    }
    for (ll i=0;i<=K;i++) f[1][i]=1,s[1][i]=i;
    for (ll i=2;i<=n+1;i++)
        for (ll j=0;j<=K;j++){
            ans=0;
            for (ll sz=1;sz<i;sz++)   
                (ans+=(C[i-2][sz-1]*f[i-sz][j]%M*((s[sz][K]-s[sz][j]+M)%M)%M)%M)%=M;
        	(ans+=M)%=M;
            f[i][j]=ans;
            s[i][j]=ans;
            if (j) (s[i][j]+=s[i][j-1])%=M;
            (s[i][j]+=M)%=M;
        }
    printf("%lld\n",f[n+1][0]);
    return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 1; i < s.size(); ++i) if(s[i - 1] != s[i]) ++cnt;;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'
#define fi first
#define se second

string s;
void run(){
    cin >> s;
    DEBUG(s + (s[s.size()-1] == 's' ? "es" : "s"));
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios_base::sync_with_stdio(false);

    run(); return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int inf = 1e6;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string a,b;
	cin >> a >> b;
	if(a != b && count(all(b), '1')==0){
		cout << -1 << endl;
		return 0;
	}
	int n = sz(a);
	b = b + b;

	vi pr(n, inf), nx(n, inf);
	rep(i,0,n) if(b[i]=='1')
		pr[i] = nx[i] = 0;
	rep(i,1,n) pr[i] = min(pr[i], 1 + pr[i-1]);
	pr[0] = min(pr[0], 1+pr[n-1]);
	rep(i,1,n) pr[i] = min(pr[i], 1 + pr[i-1]);

	rrep(i,1,n) nx[i-1] = min(nx[i-1], 1 + nx[i]);
	nx[n-1] = min(nx[n-1], 1+nx[0]);
	rrep(i,1,n) nx[i-1] = min(nx[i-1], 1 + nx[i]);

	int ans = inf;
	rep(ofs,0,n){
		int sfo = (n-ofs)%n;
		int dif = 0;
		vector<pii> ps;
		rep(i,0,n) if(a[i] != b[i+ofs]){
			++dif;
			if(a[i]=='1') ps.emplace_back(pr[i],nx[i]);
		}
		if(ofs == 0) ans = min(ans, dif + n);
		sort(all(ps));
		vi mx(sz(ps)+1);
		rrep(i,0,sz(ps)) mx[i] = max(mx[i+1], ps[i].second);
		rep(i,0,sz(ps)+1){
			int le = i ? ps[i-1].first : 0;
			int ri = mx[i];
			ans = min(ans, dif + le*2 + ofs + 2*max(0,ri-ofs));
			ans = min(ans, dif + ri*2 + sfo + 2*max(0,le-sfo));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
M = 10**9 + 7
a = [1] + [0] * 12
p = 1
for c in reversed(input()):
    x, y = (0, p * 10) if c == '?' else (p * int(c), p * int(c) + 1)
    a = [sum(a[(i - j) % 13] for j in range(x, y, p)) % M for i in range(13)]
    p = p * 10 % 13
print(a[5])


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

using namespace std;

using Pos = pair<double, double>;

double dist(const Pos &a, const Pos &b) {
  return hypot(a.first - b.first, a.second - b.second);
}

double max_dist(const Pos &a, vector<Pos> &vp) {
  double res = 0;
  for (auto &p : vp) {
    res = max(res, dist(a, p));
  }

  return res;
}

double min_dist(vector<Pos> &vp, double x) {
  double l = 0, r = 1000;
  for (int i = 0; i < 80; ++i) {
    double c1, c2;
    c1 = (l * 2 + r) / 3;
    c2 = (l + r * 2) / 3;
    if (max_dist({x, c1}, vp) > max_dist({x, c2}, vp)) {
      l = c1;
    } else {
      r = c2;
    }
  }

  return max_dist({x, l}, vp);
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<Pos> vp(n);
  for (auto &p : vp) {
    cin >> p.first >> p.second;
  }

  double l = 0, r = 1000;
  for (int i = 0; i < 80; ++i) {
    double c1, c2;
    c1 = (l * 2 + r) / 3;
    c2 = (l + r * 2) / 3;
    if (min_dist(vp, c1) > min_dist(vp, c2)) {
      l = c1;
    } else {
      r = c2;
    }
  }

  cout << setprecision(9) << min_dist(vp, l) << '\n';
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll s;
    cin>>s;
    ve <ve <ll>> dp(s+1,ve <ll>(s+1,0));
    rep (i,3,s+1)
    {
        dp[1][i]=1+dp[1][i-1];
        dp[1][i]%=rem;
    }
    if (s<3)
    {
        cout<<"0\n";
        return 0;
    }
    ll ans=1;
    rep (i,2,s+1)
    {
        rep (j,3*i,s+1)
        {
            dp[i][j]=dp[i][j-1]+dp[i-1][j-3];
            dp[i][j]%=rem;
            if (j==s)
            {
                ans+=dp[i-1][j-3];
                ans%=rem;
            }
        }
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 34596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

bool dp[100005];

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];
  dp[0]=false;
  for(int i = 1;i<=k;i++){
    rep(j,n){
      if(i-a[j]>=0)dp[i] = dp[i] | !dp[i-a[j]];
    }
  }
  if(dp[k])cout << "First" << endl;
  else cout << "Second" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 300010;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 6; i <= n; i++){
        if(is_prime[i] && (i % 7 == 1 || i % 7 == 6)){
            prime[p++] = i;
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}


signed main(){
    int n;
    int sz = sieve(300010);
    while(1){
        cin >> n;
        if(n == 1) break;
        vector<int> ans;
        rep(i, 0, sz){
            if(n % prime[i] == 0){
                ans. push_back(prime[i]);
            }
        }
        cout << n << ":";
        rep(i, 0, ans.size()){
            cout << " " << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3716
#include<stdio.h>

int main(){
	int time, hour, minute, second;

	
	scanf("%d", &time);

	hour = time / 3600;	

	minute = (time - (3600 * hour)) / 60;

	second = time - (hour * 3600) - (minute * 60); 

	printf("%d:%d:%d\n", hour, minute, second);

	return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple {
    private string S;
    void Solve() {
        //input
        S = io.String;
        //cal
        Func <int, bool> f = (n) => {
            var l = S.Length;
            if((l - n) % 2 != 0)
                return false;
            var a = S.Substring(0, (l - n) / 2);
            var b = S.Substring((l - n) / 2, (l - n) / 2);
            return a == b;
        };
        //cal
        for(int i = 1; i < S.Length; ++i) {
            if(f(i)) {
                //ret
                WriteLine(S.Length - i);
                return;
            }
        }
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 13140
DOM = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def leap?(y)
  return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)
end

def doy(y, m, d)
  sum = d
  for i in (1...m)
    sum += DOM[i]
  end
  sum += 1 if m > 2 && leap?(y)

  return sum
end

while true
  y1, m1, d1, y2, m2, d2 = gets.chomp.split(" ").map{|s| s.to_i}
  break if y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0

  days = doy(y2, m2, d2) - doy(y1, m1, d1)
  for y in (y1...y2)
    days += leap?(y) ? 366 : 365
  end

  puts days
end

Measured memory_bytes: 6108
#include<iostream>
#include<string>

using namespace std;

long long two[100005];
long long three[100005];
long long MOD = 1000000007;

void init(){
    long long tw = 1;
    long long th = 1;
    for (int i=0;i<100005;i++) {
        two[i] = tw;
        three[i] = th;
        tw = (tw*2LL) % MOD;
        th = (th*3LL) % MOD;
    }
}

int main() {
    string s;
    cin>>s;
    init();
    int len = (int)s.size();
    int one = 0;
    long long ans = 0LL;
    for (int i=0;i<len;i++) {
        if (s[i] == '0') continue;
        long long tmp = two[one];
        tmp = (tmp * three[len - i - 1]) % MOD;
        ans = (ans + tmp) % MOD;
        one++;
    }
    ans = (ans + two[one]) % MOD;
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();

  vector<int> count(26);
  REP(_, N) {
    string s; cin >> s;
    vector<int> v(26);
    for (char ch : s) {
      v[ch-'a']++;
    }
    if (_ == 0) { count = v; }
    else {
      REP(i, 26) {
        count[i] = min(count[i], v[i]);
      }
    }
  }
  string ans = "";
  REP(i, 26) {
    ans += string(count[i], 'a'+i);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M,ans = 0;
  	cin >> N;
    vector<string> s(N);
    for(int i = 0;i < N;i ++){
        cin >> s[i];
    }
    cin >> M;
  	vector<string> t(M);
    for(int i = 0;i < M;i ++){
        cin >> t[i];
    }
  	for(int i = 0;i < N;i ++){
        int cnt = 0;
        for(int j = 0;j < N;j ++){
            if(s[i] == s[j]) cnt ++;
        }
        for(int j = 0;j < M;j ++){
            if(s[i] == t[j]) cnt --;
        }
        if(cnt > ans) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Create time: 2019-10-05  19:59:00
#include <bits/stdc++.h>
#define rint register int
typedef long long LL;

using namespace std;

int a[205], G[205][205];
queue <int> q;

int main() {

    int n; cin >> n;
    for (rint i = 1; i <= n; ++i)
        for (rint j = 1; j <= n; ++j) {
            char ch = getchar();
            while (ch != '0' && ch != '1') ch = getchar();
            if (ch == '1') G[i][j] = 1;
        }
    int ans = 0;
    for (rint i = 1; i <= n; ++i) {
        memset(a, 0, sizeof(a));
        a[i] = 1;
        q.push(i);
        while (!q.empty()) {
            int t = q.front(); q.pop();
            for (rint i = 1; i <= n; ++i)
                if (G[t][i]) {
                    if (!a[i]) a[i] = a[t] + 1, q.push(i);
                    else if (abs(a[i] - a[t]) != 1) return puts("-1"), 0;
                }
        }
        for (rint j = 1; j <= n; ++j)
            ans = max(ans, a[j]);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 384
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

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

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
vector<ll> v;

void init()
{
}

void solve()
{
    vector<ll> vv(v);
    sort(ALL(vv));
    ll med1 = vv[N/2-1], med2 = vv[N/2];
    REP(i, N){
        cout << (v[i] > med1 ? med1 : med2) << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    REP(i, N) cin >> v[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5376
N=int(input())
A=list(map(int, input().split()))
d = [0]*N
for i in reversed(range(1,N+1)):
    n=1
    t=0
    while i*n<=N:
        t+=d[i*n-1]
        n+=1
    d[i-1]=(t+A[i-1])%2
res = [i+1 for i,x in enumerate(d) if x]
print(len(res))
print(*res)

Measured memory_bytes: 98512
from sys import stdin

N,K=map(int,input().split())
A = []
for i in range(K):
    d=int(input())
    tmp = list(map(int, input().split())) 
    for j in range(d):
        if not tmp[j] in A:
            A.append(tmp[j])

print(N-len(A))


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

struct card
{
  char picture;
  int value;
};

int partition (card A[], int p, int r)
{
  int x = A[r].value;
  int i = p - 1;
  for (int j = p; j < r; j++)
    {
      if (A[j].value <= x)
	{
	  i = i + 1;
	  // hacked
	  swap(A[i],A[j]);
	  /*-card tmp = A[i];
	  A[i] = A[j];
	  A[j] = tmp;
	  */
	}
    }
  //hacked
  swap(A[i+1],A[r]);
  /*card tmp = A[r];
  A[r] = A[i + 1];
  A[i + 1] = tmp;*/
  return i + 1;
}

void quicksort (card A[], int p, int r)
{
  if (p < r)
    {
      int q = partition (A, p, r);
      quicksort (A, p, q - 1);
      quicksort (A, q + 1, r);
    }
}

void MergeSort (card S[], int B, int T)
{
  if (B >= T)
    return;

  int mid = (B + T) / 2;
  MergeSort (S, B, mid);
  MergeSort (S, mid + 1, T);

  card *buf = new card[T - B + 1];

  int j = 0;
  for (int i = B; i <= mid; i++)
    buf[j++] = S[i];
  for (int i = T; i >= mid + 1; i--)
    buf[j++] = S[i];

  int l = 0;
  int r = T - B;
  int k = B;
  while (l <= r)
    {
      if (buf[l].value <= buf[r].value)
	S[k++] = buf[l++];
      else
	S[k++] = buf[r--];
    }
  delete[]buf;
}

void merge(card n[], int left, int mid, int right)
{
	int num = right - left;
	card *tmp = new card[num];

	int iw = 0;
	int il = left;
	int ir = mid;

	while (il < mid && ir < right)
	{
		if (n[il].value <= n[ir].value)
		{
			tmp[iw++] = n[il++];
		}
		else {
			tmp[iw++] = n[ir++];
		}
	}

	while (il < mid) tmp[iw++] = n[il++];
	while (ir < right) tmp[iw++] = n[ir++];

	for (int i = 0; i<num; i++) n[left + i] = tmp[i];

	delete[] tmp;
}


void merge_sort_sub(card n[], int left, int right)
{
	if (right - left <= 1) return;

	int mid = left + (right - left) / 2;
	merge_sort_sub(n, left, mid);
	merge_sort_sub(n, mid, right);

	merge(n, left, mid, right);
}


void merge_sort(card n[], int len)
{
	merge_sort_sub(n, 0, len);
}

int main()
{
	int num = 0;
	cin >> num;
	card* cards = new card[num];
	card* cardscopy = new card[num];
	for (int i = 0; i < num; i++)
	{
		cin >> cards[i].picture >> cards[i].value;
		cardscopy[i].picture = cards[i].picture;
		cardscopy[i].value = cards[i].value;
	}

	/*for (int i = 0; i < num; i++)
	  {
		cardscopy[i] = cards[i];
	  }
	*/
	quicksort(cards, 0, num - 1);
	merge_sort(cardscopy,num);
	bool flag = true;
	int i = 0;
	//while((flag)&&(i<num)){
	//if((cards[i].value != cardscopy[i].value) || (cards[i].picture != cardscopy[i].picture))
	while (i < num)
	{
		if (cards[i].picture != cardscopy[i].picture) {
			flag = false;
			break;
		}

		//if(!flag)
		//cout << (int)cards[i].picture << " " << cards[i].value <<" " <<(int)cards[i].picture << " " << cards[i].value<<endl;
		i++;
	}

	if (flag)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;

	for (int i = 0; i < num; i++) {
		cout << cards[i].picture << " " << cards[i].value << endl;
		//cout << cardscopy[i].picture << " " << cardscopy[i].value << endl;
	}
  return 0;
}

Measured memory_bytes: 5460
N, A, B = gets.split.map(&:to_i)
@h = N.times.map { gets.to_i }

def enough?(n)
  @h.map do |i|
    t = i - (B * n)
    if t <= 0
      0
    else
      (t / (A - B).to_f).ceil
    end
  end.inject(:+) <= n
end

p (1..(10**9 / B.to_f).ceil).bsearch { |i| enough?(i) }


Measured memory_bytes: 26108