akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int MAX = 55;
char rm[MAX][MAX], lm[MAX][MAX];
int w, h;

struct Point{
    int x,y;
};
bool u[MAX][MAX][MAX][MAX];
bool ans;

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

void bfs(Point a, Point b){
    queue<pair<Point,Point>> q;
    q.push(make_pair(a, b));

    auto f = [](Point p, char m[MAX][MAX]){
        if(p.y < 0 || p.y >= h || p.x < 0 || p.x >= w) return 1;
        if(m[p.y][p.x] == '#') return 1;
        return 0;
    };

    while(not q.empty()){
        Point rp = q.front().first;
        Point lp = q.front().second;
        //cout << lp.x << ' ' << lp.y << "  /  " << rp.x << ' ' << rp.y << endl;
        q.pop();

        if(rm[rp.y][rp.x] == '%' && lm[lp.y][lp.x] == '%'){
            ans = true;
            return;
        }
        if(rm[rp.y][rp.x] == '%' || lm[lp.y][lp.x] == '%') continue;
        rep(i,4){
            Point l,r;
            l = Point{lp.x + dx[i], lp.y + dy[i]};
            r = Point{rp.x - dx[i], rp.y + dy[i]};
            if(f(l, lm)) l = lp;
            if(f(r, rm)) r = rp;

            if(u[r.y][r.x][l.y][l.x]) continue;
            u[r.y][r.x][l.y][l.x] = true;
            q.push(make_pair(r,l));
        }
    }
}

int main(){
    while(cin >> w >> h, w){
        ans = false;
        Point rp, lp;
        memset(u, 0, sizeof(u));
        rep(i,h) cin >> lm[i] >> rm[i];

        rep(i,h){
            rep(j,w){
                if(lm[i][j] == 'L') lp = Point{j,i};
                if(rm[i][j] == 'R') rp = Point{j,i};
            }
        }
        bfs(rp,lp);
        cout << (ans ? "Yes" : "No") << endl;
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF (ll)1e18



ll N,A[202020];
ll mk[202020];
ll i, j, k,ans;

void no(){
    printf("-1\n");
    exit(0);
}
pll calc(ll d,ll mx){
    if(d==N){
        //printf("a%lld,%lld\n", d, mx);
        if(mx<A[d])
            no();
        ans += A[d];
        return {(A[d] + 1) / 2, min(A[d], mx / 2)};
    }
    if(mx<=A[d])
        no();
    pll rt = calc(d + 1, min((mx - A[d]) * 2, (ll)1e18));
    //printf("a%lld,%lld ", d, mx);
    //printf("b%lld,%lld,%lld\n", ans, rt.first, rt.second);
    if(rt.first>rt.second){
        no();
    }
    ans += min(rt.second + A[d], mx);
    return {(rt.first + A[d] + 1) / 2, min(rt.second + A[d], mx / 2)};
}
int main(){
    scanf("%lld", &N);
    fornum(i,0,N+1){
        scanf("%lld", &A[i]);
    }
    if(N==0){
        if(A[0]==1){
            printf("1\n");
            return 0;
        }else{
            no();
        }
    }
    if(A[0]!=0)
        no();

    calc(0, 1);
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 7720
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,p;
  cin >> s >> p;
  s += s;
  for(unsigned long long i=0;i<s.size()-p.size()+1;++i){
    //ライブラリ使ってないです
    string t;
    for(int j=0;j<(int)p.size();++j){
      //このstringの+は後ろはcharでもstringでもok
      t += s.at(i+j);
    }
    if(t==p){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	LL H, W, N;
	cin >> H >> W >> N;
	map<PI, int> cnt;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		for (int j = -2; j <= 0; j++) {
			for (int k = -2; k <= 0; k++) {
				int A = a + j, B = b + k;
				if (A <= 0 || A > H-2 || B <= 0 || B > W-2) continue;
				cnt[MP(A, B)]++;
			}
		}
	}
	LL ans[10] = { 0 };
	int sum = 0;
	for (auto p : cnt) {
		ans[p.second]++;
		sum++;
	}
	ans[0] = (H - 2)*(W - 2) - sum;
	rep(i, 10) {
		cout << ans[i] << endl;
	}

}

Measured memory_bytes: 56448
import numpy as np

N = int(input())
a = np.array([int(input()) for i in range(N)])
max_val = np.max(a)

max_val_even = np.all(max_val%2==0)
max_val_odd = np.all(max_val%2!=0)
N_even = np.all(N%2==0)
N_odd = np.all(N%2!=0)
all_even = np.all(a%2==0)
all_odd = np.all(a%2!=0)

if max_val_odd:
  print("first")
else:
	if all_even:
	  	print("second")
	else:
 		print("first")
  



Measured memory_bytes: 17020
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k;
    char a[4];
    cin >> a;
    k = 0;
    for (i = 0; i < 3; i++)
    {
        if (a[i] == 'A')
            k++;
    }
    if (k == 1 || k == 2)
        cout << "Yes";
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vc> g(h + 2, vc(w + 2));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) cin >> g[i][j];
  vb hc(h + 2, false), wc(w + 2, false);
  rep2(i, 1, h + 1) {
    bool ok = true;
    rep2(j, 1, w + 1) if(g[i][j] == '#') ok = false;
    hc[i] = ok;
  }
  rep2(j, 1, w + 1) {
    bool ok = true;
    rep2(i, 1, h + 1) if(g[i][j] == '#') ok = false;
    wc[j] = ok;
  }
  rep2(i, 1, h + 1) {
    bool ok = false;
    rep2(j, 1, w + 1) {
      if(!hc[i] && !wc[j]) {
        cout << g[i][j];
        ok = true;
      }
    }
    if(ok) cout << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    int N=S.size();
    int ans=0;
    rep(i,N){
        int cand=0;
        FOR(j,i,N-1){
            if (!(S[j]=='A'||S[j]=='C'||S[j]=='G'||S[j]=='T')) break;
            cand++;
        }
        chmax(ans,cand);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
/*
 * A_frog1.h
 *
 *  Created on: 05-Feb-2019
 *      Author: abhimanyu
 */

#ifndef A_FROG1_H_
#define A_FROG1_H_

#include <bits/stdc++.h>
#define SUBMIT_A_FROG1 1
#define fo(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
using namespace std;

typedef vector<int> vi;

class Frog1{
private:
	int n;
	vi  stoneHeight;
public:
	Frog1(void);
	void takeInput(void);
	void solve(void);
	~Frog1(void);
};

/**
 * Constructor
 */
Frog1::Frog1(void){
	n = 0;
}

/**
 * Read input from stdin
 */
void Frog1::takeInput(void){
	cin>>n;
	stoneHeight.resize(n);
	fo(i,0,n){
		cin>>stoneHeight[i];
	}
}

/**
 * Solve problems
 */
void Frog1::solve(void){
	this->takeInput();
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(stoneHeight[1] - stoneHeight[0]);
	fo(i,2,n){
		dp[i] = min(dp[i-1] + abs(stoneHeight[i] - stoneHeight[i-1]), dp[i-2] + abs(stoneHeight[i] - stoneHeight[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

/**
 * Desctructor
 */
Frog1::~Frog1(void){

}

#if SUBMIT_A_FROG1
int main(){
	Frog1 a_frog1_obj; a_frog1_obj.solve();
	return 0;
}
#endif


#endif /* A_FROG1_H_ */


Measured memory_bytes: 1024
import collections as c
N = int(input())
A = []
for i in range(N):
	A.append(input())

B = c.Counter(A)

M = max(list(B.values()))

ans = []

for s,cnt in B.items():
	if cnt == M:
		ans.append(s)

ans.sort()

for a in ans:
	print(a)

Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<typename T>
vector<T> dijkstra(const vector<vector<pair<int, T>>> &graph, int root) {
  using P = pair<T, int>;
  vector<T> dists(graph.size(), numeric_limits<T>::max());
  priority_queue<P, vector<P>, greater<P>> que;
  dists[root] = 0;
  que.emplace(dists[root], root);
  while (!que.empty()) {
    P x = que.top(); que.pop();
    if (dists[x.second] < x.first) continue;
    for (auto e : graph[x.second]) {
      if (dists[e.first] > dists[x.second] + e.second) {
        dists[e.first] = dists[x.second] + e.second;
        que.emplace(dists[e.first], e.first);
      }
    }
  }
  return dists;
}

int main() {
  int n; cin>>n;
  vector<vector<pair<int, long long>>> g(n);
  rep(i, n-1) {
    int a, b, c; cin>>a>>b>>c;
    --a; --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int q, k; cin>>q>>k;
  --k;
  auto dists = dijkstra(g, k);
  rep(i, q) {
    int x, y; cin>>x>>y;
    --x; --y;
    print(dists[x]+dists[y]);
  }

  return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")

#define fi first
#define se second

const int N = 100100;

using namespace std;

namespace Dinic {

	using F = int;
	const F INF = 1e9+1e8;

	const int N = 220000;
	const int M = 1100000;

	int fst[N], nxt[M], to[M];
	F cap[M];
	int dis[N], q[N], ptr[N];
	int E;

	void init() {
		memset(fst, -1, sizeof fst);
		E = 0;
	}
	inline void add_edge(int u, int v, F c) {
		to[E] = v, cap[E] = c, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, nxt[E] = fst[v], fst[v] = E++;
	}
	inline bool bfs(int S, int T, int n) {
		memset(dis, -1, sizeof(int) * n);
		int h = 0, t = 0;
		dis[S] = 0, q[t++] = S;
		while (h < t) {
			int u = q[h++];
			for (int e = fst[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] == -1) {
				dis[to[e]] = dis[u] + 1, q[t++] = to[e];
				if (to[e] == T) return 1;
			}
		}
		return (dis[T] != -1);
	}
	F dfs(int u, int T, F f) {
		if (u == T) return f;
		for (int &e = ptr[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] > dis[u]) {
			F ret = dfs(to[e], T, min(f, cap[e]));
			if (ret > 0) {
				cap[e] -= ret, cap[e ^ 1] += ret;
				return ret;
			}
		}
		return 0;
	}
	F max_flow(int S, int T, int n) {
		F ret = 0;
		while (bfs(S, T, n)) {
			memcpy(ptr, fst, sizeof(int) * n);
			for (F cur; (cur = dfs(S, T, INF)) > 0; ret += cur);
		}
		return ret;
	}
};

int n;
int p[N];
int q[N];
int A[N];
int B[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 0; i < n; i++){
                cin >> p[i];
        }
        for(int i = 0; i < n; i++){
                cin >> q[i];
        }
        int G = 0;
        for(int i = 0; i < n; i++){
                if(A[i] == 0){
                        G += 1;
                        A[i] = G;
                        int j = p[i];
                        while(j != i){
                                A[j] = G;
                                j = p[j];
                        }
                }
                if(B[i] == 0){
                        G += 1;
                        B[i] = G;
                        int j = q[i];
                        while(j != i){
                                B[j] = G;
                                j = q[j];
                        }
                }
        }
        G += 1;
        Dinic::init();

        int res = n;
        for(int i = 0; i < n; i++){
                if(p[i] == i && q[i] == i){
                        res -= 1;
                } else if(p[i] == i){
                        Dinic::add_edge(B[i], G, 1);
                } else if(q[i] == i){
                        Dinic::add_edge(0, A[i], 1);
                } else{
                        Dinic::add_edge(B[i], A[i], 1);
                        if(p[i] == q[i]){
                                Dinic::add_edge(A[i], B[i], 1);
                        }
                }
        }
        res -= Dinic::max_flow(0, G, G + 1);

        cout << res << '\n';
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int e[4];
    for (int i=0; i<4; i++) {
        cin>>e[i];
    }
    sort(e, e+4);
    if (e[0]==e[1]&&e[2]==e[3])cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

Measured memory_bytes: 3056
<?php
  
  $a = (int)fgets(STDIN);
$b = explode(" ", fgets(STDIN));

$tmp = [];
$order = [];

for($i=0; $i<$a; $i++){
  if((int)$b[$i] !== $i+1){
    array_push($order, $i+1);
    array_push($tmp, (int)$b[$i]);
  }
}

if(count($order) === 2 && $order[1] === $tmp[0] || count($order) === 0){
  echo "YES";
}else{
  echo "NO";
}
  

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

int main()
{
	long long a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if(a==b)
	{
		puts("YES");
		return 0;
	}
	if((v-w)*t>=abs(a-b))puts("YES");
	else puts("NO");
}

Measured memory_bytes: 3632
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

int p[20005];
int q[20005];
int a[20005], b[20005];

int main(){
    //freopen("b3.in", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &p[i]);
        q[p[i]] = i;
    }
    int lsum = 1, rsum = 1;
    for (int i = 1; i <= n; ++i) {
        lsum += q[i];
        a[i] = lsum + i;
    }
    for (int i = n; i > 0; --i) {
        rsum += q[i];
        b[i] = rsum + (n+1-i);
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d%c", a[i], i == n ? '\n' : ' ');
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d%c", b[i], i == n ? '\n' : ' ');
    }

    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll a,b,c;

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

  cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

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

  if(400 <= x && x<=599){
    cout << 8 << endl;

  }else if(600 <= x && x<=799){
    cout << 7 << endl;

  }else if(800 <= x && x<=999){
    cout << 6 << endl;
    
  }else if(1000 <= x && x<=1199){
    cout << 5 << endl;
    
  }else if(1200 <= x && x<=1399){
    cout << 4 << endl;
    
  }else if(1400 <= x && x<=1599){
    cout << 3 << endl;
    
  }else if(1600 <= x && x<=1799){
    cout << 2 << endl;
    
  }else if(1800 <= x && x<=1999){
    cout << 1 << endl;
    
  }
}

Measured memory_bytes: 3632
use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();

    let n: i32 = buf.trim().parse().unwrap();

    for i in 1..(n + 1) {
        let mut x = i;
        if x % 3 == 0 {
            print!(" {}", i);
            continue;
        }
        loop {
            if x % 10 == 3 {
                print!(" {}", i);
                break;
            }
            x /= 10;
            if x != 0 {
                continue;
            }
            break;
        }
    }
    println!();
}


Measured memory_bytes: 5024
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
bool vis[N];vvi a(N);int n,m,u,v;vi dp(N,0); 
void dfs(int i){
  vis[i]=1;
  for(auto u:a[i]){
    if(vis[u]==0LL)dfs(u);
    dp[i]=max(dp[i],1LL+dp[u]);
  }
}
void solve(){
  cin>>n>>m;
  rep(i,1,m){
    cin>>u>>v;
    a[u].pb(v);
  }
  rep(i,1,n)if(vis[i]==0)dfs(i);
  cout<<*max_element(dp.begin(), dp.end());
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

string s, cur, pre;
int ans;

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		cur += s[i];
		if (cur != pre) {
			pre = cur;
			cur = "";
			++ans;
		}
	}
	write(ans);
	putchar('\n');
	return 0;
}

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

#define fo(i,s,t) for(int i = s;  i<= t; ++ i)
const int maxn = 200050;
typedef long long ll;
const ll lim = 2000000000000000ll;

int nd[maxn*80], ls[maxn*80], rs[maxn*80], rt[maxn];
int n, k, a[maxn], tot;
ll s[maxn], ans, delta;

void insert(int &now,int pre,ll l,ll r,ll x)
{
	now = ++ tot;
	nd[now] = nd[pre] + 1;
	if(l == r) return;
	ll mid = l + r >> 1;
	if(x <= mid) insert(ls[now],ls[pre],l,mid,x), rs[now] = rs[pre];
	else insert(rs[now],rs[pre],mid+1,r,x), ls[now] = ls[pre];
}

int ask(int now,int pre,ll l,ll r,ll al,ll ar)
{
	if(!now) return 0; 
	if(al <= l && r <= ar) return nd[now]-nd[pre];
	ll mid = l + r >> 1;
	if(ar <= mid) return ask(ls[now],ls[pre],l,mid,al,ar);
	else if(al > mid) return ask(rs[now],rs[pre],mid+1,r,al,ar);
	else return ask(ls[now],ls[pre],l,mid,al,mid)+ask(rs[now],rs[pre],mid+1,r,mid+1,ar);  
}

int main()
{
	scanf("%d%d",&n,&k);
	fo(i,1,n) scanf("%d",&a[i]), a[i] -= k;
	fo(i,1,n) s[i] = s[i-1] + a[i], insert(rt[i],rt[i-1],-lim,lim,s[i]);
	fo(i,1,n) ans += ask(rt[n],rt[i-1],-lim,lim,s[i-1],lim);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 131456
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

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

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int a, b, c;
	cin >> a >> b >> c;

	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);

	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int i=(l); i<(r); ++i)
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int i=(r)-1; i>=(l); --i)
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>n>>q; Int ans=0; Int a[n];
  rep(i,n)cin>>a[i];
  rep(i,n-1)ans+=min(q,a[i+1]-a[i]);
  ans+=q;
  END
}


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

int main(){
	string s;
	cin >> s;
	int ans=0;
	int l=0,r=s.size()-1;
	while(r-l>0){
		if(s[l]==s[r]){
			l++;
			r--;
		}
		else if(s[l]=='x'){
			ans++;
			l++;
		}
		else if(s[r]=='x'){
			ans++;
			r--;
		}
		else{
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		double R = sc.nextDouble();
		System.out.printf("%.8f %.8f", R * R * Math.PI, 2 * R * Math.PI);
	}
}


Measured memory_bytes: 27908
from collections import Counter
import sys
N=int(input())
v=[int(i) for i in input().split()]
A=[]
B=[]
for i in range(N):
    if i%2==0:
        A.append(v[i])
    else:
        B.append(v[i])
S=Counter(A).most_common(2)+[(0,0)]
T=Counter(B).most_common(2)+[(0,0)]
if S[0][0]!=T[0][0]:
    print(N-S[0][1]-T[0][1])
    sys.exit()
a=S[0][1]+T[1][1]
b=S[1][1]+T[0][1]
c=max(a,b)
print(N-c)



Measured memory_bytes: 63724
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;

  cout << max(max(a+b, a-b), a*b) << endl;
  
  return 0;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  sort($a);

  $sum = array_sum($a);

  if($sum-$a[$n-1]*2 > 0){
    echo "Yes";
  }else{
    echo "No";
  }

Measured memory_bytes: 16144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>

using namespace std;

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

	int n, d, x;
	int a[110];
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++)  cin >> a[i];

	int ans = x + n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; ; j++) {
			if (a[i] * (j + 1) + 1 > d)  break;
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
cout<<fixed<<setprecision(12);
double r;
cin>>r;
double p=3.14159265359;
double s=r*r*p;
double l=2*r*p;
cout<<s<<" "<<l<<endl;
return 0;
}


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

void insertionSort (int array[], int array_size) {
    int i, j, k;

    for (i = 1; i < array_size; i++) {
        k = array[i];
        j = i - 1;

        while ((j >= 0) && (array[j] > k)) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = k;
    }

}

int main(void){
    // Your code here!
    int n,k;
    int p[1000];
    cin >> n >> k;
    for (int i=0;i<n;++i){
        cin >> p[i];
    }
    insertionSort(p, n);
    
    
    
    int ans = 0;
    for (int i=0;i<k;++i){
        ans += p[i];
    }
    cout << ans<< endl;
    
    
   
   
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

//#include <map>

using namespace std;

class data {
public:
	int a,b;
	char op;
};

int main()
{
	int a, b;
	char op;

	vector<data> vData;

	while (1)
	{
		cin >> a >> op >> b;
		if (op == '?')break;
		data d;
		d.a = a;
		d.op = op;
		d.b = b;
		vData.push_back(d);
	}

	int ans;

	for (int i = 0; i < vData.size(); i++)
	{
		a = vData.at(i).a;
		b = vData.at(i).b;

		switch (vData.at(i).op)
		{
			case '+':ans = a + b; break;
			case '-':ans = a - b; break;
			case '*':ans = a * b; break;
			case '/':ans = a / b; break;
			default:break;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
#import sys

#input = sys.stdin.readline

#import heapq
import math
#import fractions

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=4
    k=1
    count=0

    if a>b:
        a,b=b,a
    sosu={1}
#    a = fractions.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c and m!=1:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    sosu.add(a)
#    print(sosu)

    for i in sosu:
        if b%i==0:
            count+=1
    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll dp[1<<20], cost[1<<20];

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

    ll N; cin >> N;
    vvll a(N, vll(N));
    rep(i, N) rep(j, N) cin >> a[i][j];

    rep(s, 1ll<<N) {
        rep(i, N) rep(j, N) {
            if(i >= j) continue;
            if(s>>i&1 && s>>j&1) cost[s] += a[i][j];
        }
    }

    rep(s, 1ll<<N) {
        for(ll t = s; t > 0; t = (t-1)&s) {
            chmax(dp[s], dp[s-t] + cost[t]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
}


Measured memory_bytes: 2816
x=0
N=int(input())
S=[input() for _ in range(2)]
mod=10**9+7

l=[]
while x<N:
    if S[0][x]==S[1][x]:
        l.append(1)
        # たて
        x+=1
    else:
        l.append(0)
        # 横
        x+=2

v=1
for i,j in enumerate(l):
    if not i:
        v=3 if j else 6
    else:
        if l[i-1]:
            v*=2
        elif not j:
            v*=3
    v%=mod

print(v)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define rep(i,n) for(int64_t i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr int64_t INF=(1ll<<60);
constexpr int64_t mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Graph G;
ll n;

void bfs(vector<ll> &dist,queue<ll> que,ll start){
    vector<bool> visit(n,false);
    que.push(start);

    while(!que.empty()){
        ll now=que.front();
        que.pop();
        visit[now]=true;
        for(ll next:G[now]){
            if(visit[next]==true) continue;

            visit[next]=true;
            que.push(next);

            dist[next]=dist[now]+1;
        }
    }

    return;
}

int main(){
    ll u,v;cin>>n>>u>>v;
    u--;v--;
    G.resize(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<ll> que;
    vector<ll> takahashi(n),aoki(n);

    bfs(takahashi,que,u);
    bfs(aoki,que,v);

    ll ans=0,key=0;
    rep(i,n){
        if(aoki[i]>takahashi[i]){
            chmax(ans,aoki[i]);
        }
    }

    ans--;

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

Measured memory_bytes: 10740
""" Created by Jieyi on 10/31/16. """
import io
import sys
import heapq

# Simulate the redirect stdin.
from collections import defaultdict

if len(sys.argv) > 1:
    filename = sys.argv[1]
    inp = ''.join(open(filename, "r").readlines())
    sys.stdin = io.StringIO(inp)


def input_data():
    while True:
        tickets, vertices, edges, start, end = map(int, input().split())
        if 0 == tickets + vertices + edges + start + end:
            break

        shortest_path = [[sys.maxsize for _ in range(vertices + 1)] for _ in range(tickets + 1)]
        for i in range(tickets + 1):
            shortest_path[i][start] = 0
        g = defaultdict(list)
        h = []
        # Generate a map.
        for _ in range(edges):
            i, j, fare = map(int, input().split())
            g[i].append((j, fare))
            g[j].append((i, fare))
        # (price, vertices, remainder ticket)
        heapq.heappush(h, (0, start, tickets))

        while True:
            if 0 == len(h):
                break
            ori_price, vertex, remain_ticket = heapq.heappop(h)
            for v, price in g[vertex]:
                if shortest_path[remain_ticket][v] > ori_price + price:
                    shortest_path[remain_ticket][v] = min(shortest_path[remain_ticket][v], ori_price + price)
                    heapq.heappush(h, (shortest_path[remain_ticket][v], v, remain_ticket))
                if remain_ticket and shortest_path[remain_ticket - 1][v] > ori_price + int(price / 2):
                    shortest_path[remain_ticket - 1][v] = min(shortest_path[remain_ticket - 1][v], ori_price + int(price / 2))
                    heapq.heappush(h, (shortest_path[remain_ticket - 1][v], v, remain_ticket - 1))

        cheapest = sys.maxsize
        for i in range(tickets):
            cheapest = min(shortest_path[i][end], cheapest)
        print(cheapest)


def main():
    input_data()


if __name__ == '__main__':
    main()

Measured memory_bytes: 8100
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;



int main(void) {
    double L, a, b, c, V;

    cin >> L;

    a = L / 3;
    b = a;
    c = L - a - b;
    V = a * b * c;
    cout << fixed << setprecision(20) << V << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mod 100000
typedef pair<int, int> P;
int n, m, s, ans;
int dp[2][2001][3001];
int main()
{
	while(cin >> n >> m >> s && n)
	{
		memset(dp, 0, sizeof(dp));
		dp[0][0][0] = 1;
		for(int i = 0; i < n * n; ++i)
		{
			for(int j = 0; j < m; ++j)
				for(int k = j; k < s; ++k)
					dp[1][j + 1][k + 1] = (dp[1][j][k]  + dp[0][j][k - j]) % mod;
			for(int j = 0; j <= m; ++j)
			{
				for(int k = 0; k <= s; ++k)
				{
					dp[0][j][k] = dp[1][j][k];
					dp[1][j][k] = 0;
				}
			}
		}
		ans = 0;
		for(int i = 0; i <= m; ++i)
		{
			ans += dp[0][i][s];
			ans %= mod;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 49996
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;++i){
			a[i]=sc.nextInt();
		}
		TreeSet<Integer> seen=new TreeSet<>();
		seen.add(-1);
		seen.add(n);
		int[] w=new int[n];
		for(int i=0;i<n;++i){
			w[a[i]-1]=i;
		}
		long res=0;
		for(int i=0;i<n;++i){
			seen.add(w[i]);
			int prev=seen.headSet(w[i], false).last();
			int next=seen.tailSet(w[i], false).first();
			res+=(w[i]-prev)*(long)(next-w[i])*(i+1);
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 98952
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
    int a,b,c,buff;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>c){
        buff=a;
        a=c;
        c=buff;
    }
    
    if(a>b){
        buff=a;
        a=b;
        b=buff;
    }
    
    if(b>c){
        buff=b;
        b=c;
        c=buff;
    }
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> card(N);
  for (int i=0; i<N ; i++){
    int a;
    cin >> a;
    card.at(i) = a;
  }
  int p_Alice = 0;
  for (int i=0; i<N ; i++){
    int max =0;
    for (int j=0; j<N ; j++){
      if ( card.at(j) > max){
        max =card.at(j);
      }
    }
    for (int j=0; j<N ; j++){
      if ( card.at(j) == max ){
        card.at(j) = 0;
        break;
      }
    }
    if ( i%2 == 0){
      p_Alice += max;
    }
    if ( i%2 == 1){
      p_Alice -= max;
    }
  }
  cout << p_Alice << endl;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;in(n);
	LL d;inl(d);
	d = d*d;
	int cnt = 0;
	for(int i=0;i<n;i++) {
		LL x, y;
		inl2(x, y);
		LL d1 = x*x + y*y;
		if(d1<=d) cnt++;
	}
	cout<<cnt<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int a; string s;
    cin >> a >> s;

    if(a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	LL ans = 1;
	int N;
	cin >> N;
	map<int,int> mp;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		mp[tmp]++;
	}

	bool flag = true;
	int i = 0;
	if(N % 2 == 1) {
		mp[0]++;
		for (auto&& var : mp) {
			if(var.first != i || var.second != 2 || var.first > N) {
				flag = false;
				break;
			}
			i += 2;
		}
	}
	else {
		i = 1;
		for (auto&& var : mp) {
			if (var.first != i || var.second != 2 || var.first > N) {
				flag = false;
				break;
			}
			i += 2;
		}
	}

	if (flag) {
		for (int i = 0; i < N/2; i++) {
			ans = ans*2;
			ans = ans % MOD;
		}
		cout << ans << endl;
	}

	else {
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
let cost k cs xs y =
    let rec cost_sub k cs xs y m =
        match cs, xs with
        | c :: cs', x :: xs' when k > 0 ->
                cost_sub (k - 1) cs' xs' y (min m (c + abs (y - x)))
        | _ -> m
    in cost_sub k cs xs y max_int

let rec solve k cs xs ys =
    match ys with
    | y :: ys' ->
            let c = cost k cs xs y in
            solve k (c :: cs) (y :: xs) ys'
    | [] -> List.hd cs

let () =
    let line = read_line () in
    let k = Scanf.sscanf line "%d %d" (fun _ k -> k) in
    let h =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    match h with
    | x :: xs ->
            print_int (solve k [0] [x] xs);
            print_newline ()
    | _ -> ()


Measured memory_bytes: 18176
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

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

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    int N,X,T;
    int time=0;
    cin >> N >> X >> T;
    time = N/X;
    if(N%X != 0) time++;
    time = time * T;
    cout << time << endl;
    
    /////////////////////


    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(!((a < b)&&(b < c)))
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
using namespace std;
 
int main() 
{
#ifdef YUUKILP
  freopen("in.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 1), y(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (x[i] > y[i]) {
      ans += 2 * (x[i] - y[i]);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1152
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

import numpy as np

n,m,k = iim()
a = iil()
cuma = [0]
for i in a:
    cuma.append(cuma[-1]+i)
b = iil()
cumb = [0]
for i in b:
    cumb.append(cumb[-1]+i)

best = m
ans = 0
for i in range(n+1):
    if cuma[i] > k:
        break
    while cumb[best] > k-cuma[i]:
        best -= 1
    ans = max(ans,best+i)

print(ans)


Measured memory_bytes: 68372
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

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

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

    int w,h,x,y;
    cin>>w>>h>>x>>y;
    
    int answer=(x*2==w && y*2==h)?1:0;
    
    cout.precision(10);
    cout<<fixed;

    cout<<((double)w*(double)h)/(double)2<<" "<<answer;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 1
r, g, b = 0,0,0
for i in range(n):
    ans *= [r,g,b].count(a[i])
    ans%=mod
    if r == a[i]:r+=1
    elif g == a[i]:g+=1
    elif b == a[i]:b+=1
    else:
        print(0)
        exit()
 


print(ans)

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<vector<int>> com;
LL dp[20][2];

void combination(int n,int r,int k,vector<int> v){
    if(r==k){
        com.push_back(v);
        return;
    }
    for(int i=(k==0?0:v[k-1]+1);i<=n-r+k;i++){
        v.push_back(i);
        combination(n,r,k+1,v);
        v.erase(v.end()-1);
    }
}

vector<LL> inv;

LL rec(int k,bool t,string s,vector<int> ss){
    if(k==s.length()&&!t) return 1;
    int x=s[k]-'0';
    int mx=t?x:9;
    LL res=0LL;
    if(t){
        for(int i=0;i<=mx;i++){
            if(ss[i]==0) continue;
            ss[i]--;
            res+=rec(k+1,t&&i==mx,s,ss);
            ss[i]++;
        }
    }
    else{
        res=inv[s.length()-k];
        for(int i=0;i<10;i++) res/=inv[ss[i]];
    }
    return dp[k][t]=res;
}


int main(){
    string s;cin >> s;
    int n=s.length();
    memset(dp,-1,sizeof(dp));
    LL t0=1,sum0=0;
    for(int i=0;i<n;i++){
        t0*=s[i]-'0'+1;
        sum0+=s[i]-'0';
    }
    LL c=1;
    for(int i=1;i<16;i++){
        inv.pb(c);
        c*=i;
    }
    combination(n+9,9,0,vector<int> (0));
    LL ans=0;
    for(int i=0;i<com.size();i++){
        com[i].pb(n+9);
        LL t=1,sum=0,k=inv[n]/inv[com[i][0]];
        vector<int> ss(10,0);
        ss[0]=com[i][0];
        for(int j=0;j<com[i].size()-1;j++){
            LL x=com[i][j+1]-com[i][j]-1;
            sum+=x*(j+1);
            k/=inv[x];
            ss[j+1]=x;
            while(x--) t*=j+2;
        }
        if(sum<sum0) ans+=k;
        else if(sum==sum0&&t<t0) ans+=k;
        else if(sum==sum0&&t==t0){
            ans+=rec(0,true,s,ss);
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll a;
        string s;
        cin>>a>>s;
        ll d=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
        cout<<(a*d)/100;

    }
    return 0;
}


Measured memory_bytes: 3524
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = r * g * b

for x in range(N-2):
    for y in range(x+1, N-1):
        z = 2 * y - x
        if z >= N:
            break
        if S[x] != S[y] and S[y] != S[z] and S[x] != S[z]:
            ans -= 1
print(ans)


Measured memory_bytes: 67784
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    ll a, b;
    while(cin >> a >> b) {
        cout << GCD(a, b) << " " << LCM(a, b) << endl;
    }
}


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

using namespace std;

int
main(int argc, char* argv[]) {
  int n, count;
  count = 0;

  cin >> n;

  count += n / 100;
  n = n % 100;
  count += n / 10;
  n = n % 10;
  count += n / 1;

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256