akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>

using namespace std;

char dx[] = {-1,1,0,0};
char dy[] = {0,0,-1,1};
char dice[6][2] = {
	{4,2}, {3,5}, {5,0}, {1,4}, {0,3}, {2,1}
};

int board[9], goal[9];

void dfs(int x, int y, int px, int py, int step, int &res){
	if(step >= res) return;

	int dif = 0;
	for(int j=0;j<9;j++) dif += (goal[j]!=board[j]/2);
	if(dif==0){ res = step; return; }

	int space = 3*x+y;
	for(int i=0;i<4;i++){
		int nx = x + dx[i], ny = y + dy[i];
		if(nx<0||3<=nx||ny<0||3<=ny) continue;
		if(nx==px&&ny==py) continue;
		int mv = 3*nx+ny;
		int tmp = board[mv];
		dif -= (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		board[space] = dice[board[mv]][i/2];
		board[mv] = 6;
		dif += (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		if(step+dif-1<res) dfs(nx, ny, x, y, step+1, res);
		dif -= (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		board[space] = 6;
		board[mv] = tmp;
		dif += (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
	}
}

int main(){
	int x, y;
	while(cin >> y >> x, y){
		char c;
		for(int i=0;i<9;i++) {
			cin >> c;
			if(c=='W') goal[i] = 0;
			if(c=='B') goal[i] = 1;
			if(c=='R') goal[i] = 2;
			if(c=='E') goal[i] = 3;
		}
		memset(board,0,sizeof(board));
		board[3*(x-1)+y-1] = 6;
		int res = 31;
		dfs(x-1,y-1,-1,-1,0,res);
		cout << (res==31?-1:res) << endl;
	}
}

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

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

    int N;
    cin >> N;
    int ans = 0, count = 0, prev;
    cin >> prev;
    for (int i = 1, Hi; i < N; i++) {
        cin >> Hi;
        if (Hi <= prev)
            count++;
        else {
            ans = max(ans, count);
            count = 0;
        }
        prev = Hi;
    }
    cout << max(ans, count) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(all(v),greater<int>());
    ll test=0;
    test+=v[0];
    int cur=1;
    for(int i=3;i<=n;i++){
        test+=v[cur];
        i++;
        if(i<=n)
            test+=v[cur];
        cur++;
    }
    cout<<test<<endl;


    return 0;   
}


 
 


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

int main() {
  int N,K,x;
  cin >> N >> K;
  int A = 0;
  for(int i = 0;i < N;i++){
    cin >> x;
    if(x < K/2.0){
      A += 2*x;
    }
    else{
      A += 2*(K - x);
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
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; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



void func(){
  string S;
  cin >> S;
  LL N = S.length();
  LL cnt=0;
  for(LL i=0;i<N/2;i++){
    if(S[i]!=S[N-1-i]){
      cnt++;
    }
  }
  cout << cnt;

} 
int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 256
N, T = gets.chomp.split.map(&:to_i)
input = Array.new(N) { gets.chomp.split.map(&:to_i) }
new_input = input.select do |item|
  item[1] <= T
end
if new_input.size == 0
  puts 'TLE'
  exit
end
p new_input.map { |c, t| c }.min


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define MAXC 100000
int dp[100005],h[100005],n,k=2;
int main()
{
//	int n,k;
	memset(dp,0x3f3f,sizeof dp);
	dp[1]=0;
	h[0]=0;
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>h[i];
//	cin>>n>>k;int dp[n+1];int a[n+1]={0};
	for(int i=2;i<=n;++i){
		for(int j=1;j<=min(i,k);++j){
			dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
// 	for(int i=1;i<=n;++i) cin>>h[i];
//     for(int i=2;i<=n;++i) {
//         for(int j=1;j<=min(k,i);++j) {
//             dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
//         }
//     }
// 	for(int i=1;i<=n;i++) cout<<dp[i] <<" ";
	cout<<dp[n];
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

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

int h,w;
string s[300];
char rot1[600][600],rot2[600][600];
int cum_rot1[601][600],cum_rot2[601][600];
LL ret=0;


int main(){
  cin>>h>>w;
  REP(i,h)
    cin>>s[i];
  
  REP(i,600){
    REP(j,600){
      rot1[i][j]='.';
      rot2[i][j]='.';
    }
  }
  
  REP(i,h){
    REP(j,w){
      if((i+j)%2==0){
	rot1[(i+j)/2][(h-1)/2+(j-i)/2] = s[i][j];
      }else{
	rot2[(i+j)/2][(h-1)/2+(j-i+1)/2] = s[i][j];
      }
    }
  }
  
  REP(i,601){
    REP(j,600){
      cum_rot1[i][j]=0;
      cum_rot2[i][j]=0;
    }
  }
  
  REP(j,(h+1)/2+(w+1)/2){
    REP(i,(h+1)/2+(w+1)/2+1){
      if(i==0){
	cum_rot1[i][j]=0;
	cum_rot2[i][j]=0;
      }else{
	cum_rot1[i][j]=cum_rot1[i-1][j]+((rot1[i-1][j]=='#')?1:0);
	cum_rot2[i][j]=cum_rot2[i-1][j]+((rot2[i-1][j]=='#')?1:0);
      }
    }
  }
  /*
  REP(i,10){
    REP(j,10)
      cerr<<rot2[i][j];
    cerr<<endl;
  }
  REP(i,10){
    REP(j,10)
      cerr<<cum_rot2[i][j];
    cerr<<endl;
  }
  */
  
  REP(j,(h+1)/2+(w+1)/2){
    REP(i1,(h+1)/2+(w+1)/2){
      FOR(i2,i1+1,(h+1)/2+(w+1)/2){
	if(rot1[i1][j] == '#' && rot1[i2][j] == '#'){
	  if(j>=i2-i1)
	    ret+=cum_rot1[i2+1][j-(i2-i1)]-cum_rot1[i1][j-(i2-i1)];
	  if(600-j>i2-i1)
	    ret+=cum_rot1[i2+1][j+(i2-i1)]-cum_rot1[i1][j+(i2-i1)];
	}
	if(rot2[i1][j] == '#' && rot2[i2][j] == '#'){
	  if(j>=i2-i1)
	    ret+=cum_rot2[i2+1][j-(i2-i1)]-cum_rot2[i1][j-(i2-i1)];
	  if(600-j>i2-i1)
	    ret+=cum_rot2[i2+1][j+(i2-i1)]-cum_rot2[i1][j+(i2-i1)];
	}
      }
    }
  }

  REP(i,600){
    REP(j,600){
      rot1[i][j]='.';
      rot2[i][j]='.';
    }
  }

  REP(i,h){
    REP(j,w){
      if((i+j)%2==0){
	rot1[(h-1)/2+(j-i)/2][(i+j)/2] = s[i][j];
      }else{
	rot2[(h-1)/2+(j-i+1)/2][(i+j)/2] = s[i][j];
      }
    }
  }
  
  REP(i,601){
    REP(j,600){
      cum_rot1[i][j]=0;
      cum_rot2[i][j]=0;
    }
  }

  REP(j,(h+1)/2+(w+1)/2){
    REP(i,(h+1)/2+(w+1)/2+1){
      if(i==0){
	cum_rot1[i][j]=0;
	cum_rot2[i][j]=0;
      }else{
	cum_rot1[i][j]=cum_rot1[i-1][j]+((rot1[i-1][j]=='#')?1:0);
	cum_rot2[i][j]=cum_rot2[i-1][j]+((rot2[i-1][j]=='#')?1:0);
      }
    }
  }

  REP(j,(h+1)/2+(w+1)/2){
    REP(i1,(h+1)/2+(w+1)/2){
      FOR(i2,i1+1,(h+1)/2+(w+1)/2){
	if(i2-i1<2)continue;
	if(rot1[i1][j] == '#' && rot1[i2][j] == '#'){
	  if(j>=i2-i1)
	    ret+=cum_rot1[i2][j-(i2-i1)]-cum_rot1[i1+1][j-(i2-i1)];
	  if(600-j>i2-i1)
	    ret+=cum_rot1[i2][j+(i2-i1)]-cum_rot1[i1+1][j+(i2-i1)];
	}
	if(rot2[i1][j] == '#' && rot2[i2][j] == '#'){
	  if(j>=i2-i1)
	    ret+=cum_rot2[i2][j-(i2-i1)]-cum_rot2[i1+1][j-(i2-i1)];
	  if(600-j>i2-i1)
	    ret+=cum_rot2[i2][j+(i2-i1)]-cum_rot2[i1+1][j+(i2-i1)];
	}
      }
    }
  }
  
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>

int main(void)
{
	long long dp[101][21];
	int seq[101];
	int i, j;
	int n;

	scanf("%d", &n);
	for (i = 1; i <= n; i++){
		scanf("%d", &seq[i]);
	}
	
	memset(dp, 0, sizeof(dp));

	dp[1][seq[1]] = 1;
	for (i = 2; i <= n; i++){
		for (j = 0; j <= 20; j++){
			if (j  +  seq[i] <= 20){
				dp[i][j + seq[i]] += dp[i - 1][j];
			}
			if (j - seq[i] >= 0){
				dp[i][j - seq[i]] += dp[i - 1][j];
			}
		}
	}

	printf("%lld\n", dp[n - 1][seq[n]]);

	return (0);
}

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

using namespace std;

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

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

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    rep(i, N) {
        rep2(j, i + 1, N) {
            int a = L[i];
            int b = L[j];
            int idx = lower_bound(L.begin(), L.end(), a + b) - L.begin();
            ans += max(0ll, idx - (j + 1));
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<tuple<string,int,int>> R(N);
  for(int i=0;i<N;i++){
    string c;
    int g;
    cin>>c>>g;
    int G=100-g;
    R[i]=make_tuple(c,G,i);
  }
  sort(R.begin(),R.end());
 
  for(int j=0;j<N;j++){
    string c;
    int g;
    int i;
    tie(c,g,i)=R[j];
    cout<<i+1<<endl;
  }
}

Measured memory_bytes: 256
n = input()
l = map(int, raw_input().split())
max = l[0]
min = l[0]
s = 0
for i in range(n):
 if max < l[i]:
  max = l[i]
 if min > l[i]:
  min = l[i]
 s = s + l[i]
print min, max, s

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

#define mp       make_pair
#define mt	 make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
vector<int> data;
int main(){
  data.resize(3);
  for (auto &val : data){
    cin >> val;
  }
  sort(data.begin(), data.end());
  if (data[0] == 5 and data[1] == 5 and data[2] == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

int main()
{
	int n = 0;
	int k = 0;
	string str;
	int origin = 0;
	cin >> n;
	cin >> k;
	cin >> str;
	for (int i = 0; i < n - 1; ++i) {
		if (str[i] == str[i + 1]) { ++origin; }
	}
	cout << min(origin + 2 * k, n - 1);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#define N 2000001

void buildMaxHeap(int* a_p, int h);
void maxh(int* a_p, int ix, int h);
int parent(int i);
int left(int i);
int right(int i);
void swap(int *a_p, int *b_p);
void insert(int* a_p, int key, int* s_p);
void inc(int* a_p, int ix, int key);
int exmax(int* a_p, int* s_p);

int main(){
  int n, i, j;
  int ix;
  int key;
  int size = 1;
  char cmd[30];
  int a[N]; // 1-origin

  while(1){
    scanf("%s", cmd);
    if( cmd[0] == 'i'){
      scanf("%d" ,&key);
      insert( a, key, &size ); 
    }else if( cmd[0] == 'e' && cmd[1] == 'x' ){
      printf("%d\n", exmax( a, &size) );
    }else{ // end
      break;
    }  
  }

  return 0; // Don't forget return 0
}

void insert(int* a_p, int key, int* s_p){
  (*s_p)++;
  a_p[*s_p] = -1;
  inc( a_p, *s_p, key); 
}

void inc(int* a_p, int ix, int key){
  a_p[ix] =key;
  while( ix>1 && a_p[parent(ix)] < a_p[ix] ){
    swap( &(a_p[ix]), &(a_p[parent(ix)]) );
    ix = parent(ix);
  }
}

int exmax(int* a_p, int* s_p){
  int max = a_p[1];
  a_p[1] = a_p[*s_p];
  (*s_p)--;
  maxh( a_p, 1 ,*s_p);
  return max;
}

void buildMaxHeap(int* a_p, int h){
  int i;
  for( i=h/2 ; i>=1 ; i--){
    maxh( a_p ,i ,h );
  }
}

void maxh(int* a_p, int ix, int h){
  int largest;
  int l = left(ix);
  int r = right(ix);

  if( l<=h && a_p[l]>a_p[ix] ){
    largest = l;
  }else {
    largest = ix;
  }
  if( r <= h && a_p[r]>a_p[largest] ){
    largest = r;
  }

  if(largest!=ix){
    swap( &(a_p[ix]) ,&(a_p[largest]) );
    maxh( a_p ,largest ,h);
  }

}

int parent(int i){
  return floor(i/2);
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void swap(int *a_p, int *b_p){
  int k;
  k    = *a_p;
  *a_p = *b_p;
  *b_p = k;
}

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

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

    int n=s.length();
    vector<int> ans(n,0);
    
    int i=0;
    while(i<n){
        int Rcnt=0;
        while(s[i]=='R'){
            i++;
            Rcnt++;
        }
        int ni=i;
        ans[ni-1]=ans[ni-1]+(Rcnt+1)/2;
        ans[ni]=ans[ni]+Rcnt/2;

        int Lcnt=0;
        while(s[i]=='L'){
            i++;
            Lcnt++;
        }
        ans[ni-1]=ans[ni-1]+Lcnt/2;
        ans[ni]=ans[ni]+(Lcnt+1)/2;
    }
    for (int i = 0; i < n - 1; i++){
        cout << ans.at(i) << " ";
    }
    cout << ans.at(n - 1) << endl;
}



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int dp[101][4][4][4];

void input(){
    cin >> N; 
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    dp[0][3][3][3] = 1;

    for(int i=0;i<N;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                for(int l=0;l<4;l++){
                    if(dp[i][j][k][l] == 0) continue;
                    for(int a=0;a<4;a++){
                        if(a == 2 && j == 1 && k == 0) continue;
                        if(a == 2 && j == 0 && k == 1) continue;
                        if(a == 1 && j == 2 && k == 0) continue;
                        if(a == 2 && j == 1 && l == 0) continue;
                        if(a == 2 && k == 1 && l == 0) continue;

                        dp[i + 1][a][j][k] += dp[i][j][k][l];
                        dp[i + 1][a][j][k] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++) {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())

def solve(i, m):
 if m == 0:
  return True
 if i >= n or m > sum(A):
  return False
 res = solve(i+1, m) or solve(i+1, m-A[i])
 return res

for j in range(0, q):
 if solve(0, m[j]):
  print 'yes'
 else:
  print 'no'

Measured memory_bytes: 6452
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll a,b,c;
	cin>>a>>b>>c;
	if((a>=c&&b<=c)||(a<=c&&b>=c))
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a<=b&&a<=c)
           {
               if(b<=c)printf("%d\n",a+b);
                else printf("%d\n",a+c);
           }
        else if(b<=a&&b<=c)
        {
            if(c<=a)printf("%d\n",b+c);
            else printf("%d\n",b+a);
        }
        else if(c<=a&&c<=b)
        {
            if(b<=a)printf("%d\n",b+c);
            else printf("%d\n",c+a);
        }
    }
    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N, K; cin >> N >> K;
	if (K == 1) {
		cout << 0 << endl;
	} else {
		cout << N - K << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
double x1,y,x2,y2,ans;
int main(){
	cin>>x1>>y>>x2>>y2;
	ans=(y2-y)*(y2-y)+(x2-x1)*(x2-x1);
	cout<<fixed<< setprecision(6) << sqrt(ans)<< endl;

return 0;}
	


Measured memory_bytes: 1280
#include <stdio.h>

int main(void) {

   int a;
   int b;
   int c;

   scanf("%d %d %d", &a, &b, &c);

   if(a < b && b < c) {
       printf("Yes\n");
   }
   else {
       printf("No\n");
   }

   return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  int h,w;
  cin >> h >> w;
  int odd = (w+1)/2;
  int even = w/2;
  int oddCount = (h+1)/2;
  int evenCount = h/2;
  
  if(h == 1 || w == 1){
	cout << 1 << endl;
  }else{
     cout << (ll)odd*oddCount + (ll)even*(evenCount) << endl;
  }
  
 
  
  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define MOD ((long long)(1e9+7)) 
using namespace std;
int n;
vector<int> con[100005];
int x,y;
bool visited[100005];
int pre[100005];
bool post[100005];
vector<int> order;
pair<long long,long long> dp[100005];
int dfs(int x, int p) {
	visited[x]=true;
	pre[x]=p;
	order.push_back(x);
	for(int i=0; i<con[x].size(); i++) {
		if(!visited[con[x][i]]) {
			dfs(con[x][i],x);
			post[x]=true;
		}
	}
} 
int main() {
	scanf("%d",&n);
	for(int i=1; i<n; i++) {
		scanf("%d%d",&x,&y);
		con[x].push_back(y);
		con[y].push_back(x); 
	}
	for(int i=1; i<=n; i++) {
		dp[i]={1,1};
	}
	dfs(1,-1);
	// white, black
	for(int i=n-1; i>=0; i--) {
		if(pre[order[i]]==-1) continue;
		dp[pre[order[i]]].first *= (dp[order[i]].first+dp[order[i]].second);
		dp[pre[order[i]]].second *= dp[order[i]].first;
		dp[pre[order[i]]].first %= MOD;
		dp[pre[order[i]]].second %= MOD;
	}
	printf("%d\n",(dp[1].first+dp[1].second)%MOD);
}

Measured memory_bytes: 11128
N = int(input())
restaurants = []

for i in range(N):
    name, score = map(str, input().split())
    restaurants.append([name, int(score), i+1])

sorted_restaurants = restaurants.copy()
sorted_restaurants = sorted(sorted_restaurants, key=lambda x: (x[0], -x[1]))

for i in range(N):
    print(sorted_restaurants[i][2])


Measured memory_bytes: 9124
import sys

input = sys.stdin.readline

S = list(input())
T = list(input())
S.pop()
T.pop()

N = len(S)
M = len(T)

def main():
    store = []
    for i in range(N - M + 1):
        X = S[i:i+M]
        for j in range(M):
            if X[j] != T[j] and X[j] != "?":
                break
        else:
            store.append(i)
        
    if len(store) == 0:
        return 0
    else:
        index = store.pop()
        if index + M == N:
            ans = S[:index] + T
        else:
            ans = S[:index] + T + S[index + M:]

    for i in range(N):
        if ans[i] == "?":
            ans[i] = "a"
    return "".join(ans)

ans = main()
if ans:
    print(ans)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
struct card {
	char 	suit;
	int		num;
};

void bubbleSort (struct card C[], int N){
	bool flag = 1;
	for (int i = 0; flag; i++){
		flag = 0;
		for (int j = N-1; j >= i+1; j--){
			if (C[j].num < C[j - 1].num){
				swap(C[j], C[j-1]);
				flag = 1;
			}
		}
	}
}

void selectSort (struct card C[], int N){
	for (int i = 0; i < N; i++){
		int minj = i;
		for(int j = i + 1; j < N; j++){
			if (C[minj].num > C[j].num){
				minj = j;
			}
		}
		swap(C[i], C[minj]);
	}
}

bool isStable (struct card C1[], struct card C2[], int N){
	bool t = true;
	for ( int i = 0; i < N; i++){
		if ( C1[i].suit != C2[i].suit  ) t = false;
	}
	return t;
}

int main(){
	int N = 0;
	cin >> N;
	card C1[N];
	
	for (int i = 0; i < N;i++){
		cin >> C1[i].suit >> C1[i].num;
	}
	card bubble[N];
	card select[N];
	for (int i = 0;i < N; i++){
		bubble[i].suit = C1[i].suit;
		bubble[i].num = C1[i].num;
	}
	for (int i = 0;i < N; i++){
		select[i].suit = C1[i].suit;
		select[i].num = C1[i].num;
	}
	
	bubbleSort(bubble, N);
	selectSort(select, N);
	
	for (int i = 0; i < N; i++){
		if(i) cout << " ";
		cout << bubble[i].suit << bubble[i].num;
	}
	cout  << endl;
	
	if(isStable(bubble, bubble, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	for (int i = 0; i < N; i++){
		if (i) cout << " ";
		cout << select[i].suit << select[i].num;
	}
	cout << endl;
	if(isStable(bubble, select, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}


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

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

    vector<int> prof(N,0);
    int minVal = A[0];
    int maxProf = 0;
    for(int i=1; i<N; i++){
        prof[i] = max(0, A[i] - minVal);
        minVal = min(minVal, A[i]);
        maxProf = max(prof[i],maxProf);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        if(prof[i]==maxProf) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define Yay(s) s?cout << "Yay!" << endl:cout << ":(" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
//#define P pair<int,int>


signed main(){
    string S;int K;
    bool s_one_only=true;
    int first_couple=-1;
    cin >> S >> K;
    RREP(i,S.size()){
        if(S[i]!='1'){
            s_one_only=false;
            first_couple=i;
        }
    }
    if(K==1){
        cout << S[0] << endl;
        return 0;
    }
    if(s_one_only || first_couple>K-1){
        cout << '1' << endl;
        return 0;
    }
    cout << S[first_couple] << endl;
    
    
	return 0;
}

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

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  vector<ll> T(n);
  ll s = 0;
  for (int i = 0; i < n; i++) {
    cin >> T[i];
    if (i > 0) {
      s = lcm(s, T[i]);
    } else {
      s = T[i];
    }
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back

int main(){
    fast;
    ll n,k;
    cin>>n;
    vector<ll>v;
    for(ll i=0;i<n;i++){
        cin>>k;
        v.pb(k);
    }
    ll ans=1e17;
    for(ll i=1;i<=100;i++){
        ll c=0;
        for(ll j=0;j<n;j++){
            c+=(i-v[j])*(i-v[j]);
        }
        ans=min(ans,c);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        pw.println(Math.min(b/a,c));
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25420
class BIT2:
    # H*W
    def __init__(self, h, w):
        self.w = w
        self.h = h
        self.data = [{} for i in range(h+1)]

    # O(logH*logW)
    def sum(self, i, j):
        s = 0
        data = self.data
        while i > 0:
            el = data[i]
            k = j
            while k > 0:
                s += el.get(k, 0)
                k -= k & -k
            i -= i & -i
        return s

    # O(logH*logW)
    def add(self, i, j, x):
        w = self.w; h = self.h
        data = self.data
        while i <= h:
            el = data[i]
            k = j
            while k <= w:
                el[k] = el.get(k, 0) + x
                k += k & -k
            i += i & -i

    # [x0, x1) x [y0, y1)
    def range_sum(self, x0, x1, y0, y1):
        return self.sum(x1, y1) - self.sum(x1, y0) - self.sum(x0, y1) + self.sum(x0, y0)

h,w,T,Q = map(int,input().split())
ready = BIT2(h+1,w+1)
edible = BIT2(h+1,w+1)

from collections import deque

baking = deque([])

for i in range(Q):
    q = list(map(int,input().split()))
    while baking and baking[0][0] + T <= q[0]:
        t,x,y = baking.popleft()
        edible.add(x, y, 1)
    if q[1] == 0:
        x,y = q[2:]
        if ready.range_sum(x-1,x,y-1,y) == 0:
            ready.add(x ,y , 1)
            baking.append((q[0], x, y))
    if q[1] == 1:
        x,y = q[2:]
        if edible.range_sum(x-1,x,y-1,y) == 1:
            ready.add(x, y, -1)
            edible.add(x, y, -1)
    if q[1] == 2:
        x0,y0,x1,y1 = q[2:]
        ed = edible.range_sum(x0-1,x1,y0-1,y1)
        re = ready.range_sum(x0-1,x1,y0-1,y1)
        print(ed, re-ed)



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

int ans=0;

int main(void)
{
    //input
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    
    //calculate
    ans = a*x + b*y;
    for(int i=1; i<=100000; i++){
        ans = min(ans, a*max(0,x-i) + b*max(0,y-i) + 2*c*i);
    }
    //output    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define _LIBCPP_DEBUG 0
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;
//g++ -std=c++1z main.cpp
//.\a.exe


int main(void) {
ll n,m,s=0,t=0,r;
cin >> n >> m;
ll a[n],b[n];
for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
} 
r=m;
vector<pair<ll,ll>>p(n);

for(int i=0;i<n;i++){
    p[i]=make_pair(a[i],b[i]);
}

sort(p.begin(),p.end());
t = p[0].second;
for(int i=0;i<n;i++){
    if(t<r){
        s = s+p[i].first*p[i].second;
        r = r-p[i].second;
        t = p[i+1].second;
    }
    else{
        r = r*p[i].first;
        cout << r+s << endl;
        return 0;
    }
    }
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int a1=in.nextInt();
		int a2=in.nextInt();
		int a3=in.nextInt();
		if(a1+a2+a3>=22)
		{
			System.out.println("bust");
		}
		else
		{
			System.out.println("win");
		}
	}
}
	

Measured memory_bytes: 22604
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  var i,j,result;
  var a = line.split(' ');
  var b = parseInt(a[0],10);
  var c = parseInt(a[1],10);
  if(!b && !c)
    process.exit();
  for(i=0;i<b;i++){
    result="";
    for(j=0;j<c;j++){
      if(i==0 || i==b-1 || j==0 || j==c-1)
        result += "#";
      else
        result += ".";
    }
    console.log(result);
  }
  console.log("");
});
process.stdin.on('end', function () {
});

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

int main() {
  int K, S;
  int ans = 0;
  cin >> K >> S;
  for(int i = 0; i <= K; i++) {
    for(int j = 0; j <= K; j++) {
      if(S - (i + j) >= 0 && S - (i + j) <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    int x = a.back();
    auto it = lower_bound(ALL(a), x / 2);
    if (it == a.begin()) {
        cout << x << " " << *it << endl;
    } else if (it == a.end() - 1) {
        cout << x << " " << *(it - 1) << endl;;
    } else {
        int l = *(it - 1), r = *it;
        cout << x << " " << (x < l + r ? l : r) << endl;
    }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,k;
  string s;
  cin>>n>>k;
  cin>>s;
  ll ans=0;
  ll p=0;
  ll f=0;
  ll i;
  for(i=0;i<n;i++){
    if(s[i]=='0'){
      if(f==0)f++;
    }
    else{
      if(f!=0){
        f=0;
        p++;
      }
    }
    if(p>=k)break;
  }
  for(;i<n-1;i++){
    if(s[i+1]=='0')break;
  }
  if(i==n){
    cout<<n<<endl;
    return 0;
  }
  ans=i+1;
  ll j=0;
  ll q=0;
  ll ff=0;
  for(;i<n-1&&q<n-1;i++){
    f=0;
    for(;q<n;q++){
      if(s[q]=='1'){
        if(f!=0){
          break;
        }
      }
      else{
        f++;
      }
    }
    f=0;
    for(;i<n-1;i++){
      if(s[i+1]=='0'){
        if(f!=0){
          break;
        }
      }
      else{
        f++;
      }
    }
    ans=max(ans,i-q+1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d;
  cin>>n>>d;
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    int x,y;
    cin>>x>>y;
    double p=sqrt(pow(x,2)+pow(y,2));
    if(p<=(double)d)
      cnt++;
  }
  cout<<cnt;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a(vector<int> &A,int &N,int l,int r){
  if(l>=r)
    return 0;
  int mn=100;
  for(int i=l;i<r;i++)
    mn=min(mn,A[i]);
  vector<int> B={-1};
  for(int i=l;i<r;i++){
    A[i]-=mn;
    if(A[i]==0)
      B.push_back(i);
  }
  B.push_back(r);
  int ans=0;
  for(int i=1;i<B.size();i++)
    ans+=a(A,N,B[i-1]+1,B[i]);
  return ans+mn;
}
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)
    cin>>i;
  cout<<a(A,N,0,N)<<endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N;
int A[100010];
ll ans;
int main(){
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
    }
    sort(A,A+N);
    ans=1;
    REP(i,0,N/2){
        ans*=2;
        ans%=mod;
    }
    if(N%2){
        if(A[0]==0) {
            for(int i=1;i<N;i+=2) {
                if(A[i]==A[i+1]&&A[i]==i+1){
                    continue;
                }
                ans=0;
                break;
            }
        }
    }else{
        for(int i=0;i<N;i+=2) {
            if(A[i]==A[i+1]&&A[i]==i+1){
                continue;
            }
            ans=0;
            break;
        }
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 640
/*
      author : nishi5451
      created: 11.08.2020 01:21:48
*/

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


int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(auto c : s){
        if(c=='1') ans++;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3584
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Control.Monad (replicateM)

main = do
  [n,maxW] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  items <- replicateM n $ do
    [w,v] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (w, fromIntegral v :: Int64)
  print $ solve maxW items U.! maxW

solve :: Int -> [(Int, Int64)] -> U.Vector Int64
solve !maxW [] = U.replicate (maxW + 1) 0
solve !maxW ((!w,!v):xs)
  = let !a = solve maxW xs
    in U.generate (maxW + 1)
       $ \i -> if w <= i
               then max (a U.! i) (a U.! (i - w) + v)
               else a U.! i


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	//int d;
	int e;
	std::cin >> a >> b;
	if (a*b % 2 == 0) {
		cout << "Even" << "\n";
	}
	else {
		cout << "Odd" << "\n";
	}
	std::cin >> e;
}

Measured memory_bytes: 256
import * as fs from 'fs'

const getInput = (): string => {
  return (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
}

export const solveAbc096c = () => {
  const input = getInput()

  const arr = input.trim().split('\n').map(v => v.trim())
  // console.log(arr)

  const numbers = arr[0].trim().split(' ').map(Number)
  const H = numbers[0]
  const W = numbers[1]

  const grid = arr.slice(1).map(v => v.split(''))
  // console.log(grid)

  let extendedGrid = grid.slice()
  const dummy = [...Array(W)].map(_ => '.')
  extendedGrid = [dummy].concat(extendedGrid).concat([dummy])
  extendedGrid = extendedGrid.map(v => ['.'].concat(v).concat('.'))
  // console.log(extendedGrid)

  for (let i = 1; i <= H; i += 1) {
    for (let j = 1; j <= W; j += 1) {
      if (extendedGrid[i][j] === '.') {
        continue
      }

      let count = 0
      if (extendedGrid[i - 1][j] === '#') count += 1
      if (extendedGrid[i][j - 1] === '#') count += 1
      if (extendedGrid[i][j + 1] === '#') count += 1
      if (extendedGrid[i + 1][j] === '#') count += 1
      // console.log(count)
      if (count === 0) {
        console.log('No')
        return
      }
    }
  }

  console.log('Yes')
}

solveAbc096c()



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

long long N, X, p, l, c;
long long A[100100];

int main() {
    cin>>N;
    for(int i=1; i<=N; i++) {
        cin>>A[i];
    }
    sort(A+1,A+N+1);
    for(int i=N; i>=1; i--) {
        if(A[i]==A[i-1]) {
            p=A[i];
            c=i-2;
            break;
        }
    }
    for (int i=c; i>=1; i--) {
        if(A[i]==A[i-1]) {
            l=A[i];
            break;
        }
    }
    cout<<p*l<<endl;
}

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

int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  bool dance = true;
  rep(i,n){
    if(i%2==0){
       if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
         dance = false;
       }
    }
    if(i%2!=0){
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        dance = false;
      }
    }
  }
  if(dance){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

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

ll res = INF;
vector<int> vr;
bool ok;
void dfs(int cur, vector<int> v, ll t, string &s) {
    if (cur == s.size()) {
        ll sum = 0;
        int cur = 0;
        for (auto e : v) {
            ll sm = 0;
            for (int i = 0; i < e; i++) {
                sm = sm * 10 + (s[cur] - '0');
                cur++;
            }
            sum += sm;
        }
        if (sum > t) return;
        if (chmin(res, t - sum)) {
            ok = true;
            vr = v;
        }
        else if (res == t - sum) {
            ok = false;
        }
        return;
    }
    ll sum = 0; for (auto e : v) sum += e;
    /*{
        ll all = 0;
        int cur = 0;
        for (auto e : v) {
            ll sm = 0;
            for (int i = 0; i < e; i++) {
                sm = sm * 10 + (s[cur] - '0');
                cur++;
            }
            all += sm;
        }
        if (all > t) return;
    }*/
    int cnt = 0;
    for (int i = sum; i < s.size(); i++) {
        cnt++;
        v.emplace_back(cnt);
        dfs(sum + cnt, v, t, s);
        v.pop_back();
    }
}
void solve() {
    int t;
    string s; cin >> t >> s;
    res = INF; ok = true;
    if (t == 0 and s == "0") exit(0);
    vector<int> v;
    dfs(0, v, t, s);
    if (res == INF) puts("error");
    else if (!ok) puts("rejected");
    else {
        ll sum = 0; 
        int cur = 0;
        vector<ll> v;
        for (auto e : vr) {
            ll sm = 0;
            for (int i = 0; i < e; i++) {
                sm = sm * 10 + (s[cur] - '0');
                cur++;
            }
            v.emplace_back(sm);
            sum += sm;
        }
        printf("%lld", sum);
        for (int i = 0; i < v.size(); i++) printf(" %lld", v[i]);
        puts("");
    }
}

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

	int kkt = 89;
	while (kkt) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3284
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
    int v_n, h_n, start;
    while(cin >> v_n >> h_n >> start, v_n|h_n|start){
        vector<vector<pii>> lines(v_n + 1);
        REP(i, h_n){
            int h, p, q;
            cin >> h >> p >> q;
            lines[p].push_back({h, q});
            lines[q].push_back({h, p});
        }

        REP(i, v_n + 1) {
            RSORT(lines[i]);
        }

        int now_h = 10000;
        int now_v = start;
        while(1){
            bool update = false;
            for(auto h_line:lines[now_v]){
                if(now_h > h_line.first){
//                    LOG("move to %d -> %d\n", now_v, h_line.second);
                    now_h = h_line.first;
                    now_v = h_line.second;
                    update = true;
                    break;
                }
            }
            if(!update) break;
        }

        cout << now_v << endl;
    }
}

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<int,int>

const int N=1e6+10;
const ll maxN=1e18+10;
const double pi=3.14159265;

int n,m;
ll a[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    map <ll,ll> dd;
    cin >> n;
    FOR(i,2,n) {
        int h;
        cin >> h; dd[h]++;
    }
    FOR(i,1,n) cout << dd[i] << "\n";
}
    

Measured memory_bytes: 16168