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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int K, N;
int A[220000];
signed main() {
    cin >> K >> N;
    rep(i, N) { cin >> A[i]; }
    int ans = K;
    rep(i, N - 1) { chmin(ans, K - (A[i + 1] - A[i])); }
    chmin(ans, A[N - 1] - A[0]);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  long double ans=0;
  cin >> N >> K;
  map<ll, ll>cnt;
  rep(i, N){
    ll n = ceil(log2(K/(i+1.0)));
    //cout << i+1 << " " << n << endl;
    cnt[n]++;
    //if(n<=0)ans += 1.0/N;
    //else ans += 1.0/N/powf(2,n+1);
  }
  for(auto ic:cnt){
    if(ic.first<=0){
      ans += ic.second;
    }else{
      ans += ic.second/powf(2, ic.first);
    }
  }
  cout << setprecision(16)<<ans*1.0/N;

  //cout << ans;
  return 0;
}


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

const ll mod = 1e9 + 7;

int front(int x){
    while (x / 10 > 0) x /= 10;
    return x;
}

int back(int x){
    return x % 10;
}

int main(){
    int n;
    cin >> n;
    
    vector<vector<int>> a(9, vector<int>(9));
    for(int i = 1; i <= n; i++){
        if (back(i)) 
            a[front(i) - 1][back(i) - 1]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        if (back(i)) ans += a[back(i) - 1][front(i) - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
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 x = lin();
  ll ans = 0, a = 100;
  while (a < x) {
    a += a/100;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;
LL a[114514], ru[114514];

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

	ru[0] = a[0];

	LL sp = 0, sm = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2) {//plus
			if (ru[i] < 1) {
				sp += 1 - ru[i];
				ru[i] = 1;
			}
		if(i!=n-1)	ru[i + 1] = ru[i] + a[i + 1];
		}
		else {
			if (ru[i] > -1) {
				sp += ru[i] + 1;
				ru[i] = -1;
			}
			if(i!=n-1)ru[i + 1] = ru[i] + a[i + 1];
		}
	}
//	for (int i = 0; i < n; i++)cout << ru[i] << ' ';
	//cout << endl;

	ru[0] = a[0];
	for (int i = 0; i < n; i++) {
		if (i % 2) {
			if (ru[i] > -1) {
				sm += ru[i] + 1;
				ru[i] = -1;
			}
			if(i!=n-1)ru[i + 1] = ru[i] + a[i + 1];
		}
		else {
			if (ru[i] < 1) {
				sm += 1 - ru[i];
				ru[i] = 1;
			}
		if(i!=n-1)	ru[i + 1] = ru[i] + a[i + 1];
		}
	}
//	for (int i = 0; i < n; i++)cout << ru[i] << ' ';
//	cout << endl;
//	cout << sp << ' ' << sm << endl;
	cout << min(sp, sm) << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

template <class T>
struct MP {
  int n;
  vector<int> a;
  T t;

  MP(const T& arr) {
    n = arr.size();
    a = vector<int>(n + 1);
    t = arr;

    a[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
      while (j >= 0 && t[j] != t[i]) j = a[j];
      j++;
      a[i + 1] = j;
    }
  }

  vector<int> findAll(const T& s) {

    vector<int> res;
    int j = 0;
    for (int i = 0; i < s.size(); i++) {
      while (j >= 0 && t[j] != s[i]) j = a[j];
      j++;
      if (j == n) {
        res.push_back(i-j+1);
        j = a[j];
      }
    }
    return res;
  }
};


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<u64> as(N), bs(N);
  F0R(i, N) {
    cin >> as[i];
  }
  F0R(i, N) {
    cin >> bs[i];
  }

  // 全探索 O(N^2)
#if 0
  F0R(k, N) {

    u64 x = as[k] ^ bs[0];
    bool match = true;
    FOR(i, 1, N) {
      int ik = i + k;
      if (ik > N - 1) ik -= N;

      if ((as[ik] ^ bs[i]) != x) {
        match = false;
        break;
      }
    }

    if (match) {
      cout << k << ' ' << x << newl;
    }
  }
#endif

  // 数列の、前後の数のxorをとる

  // A = a0^a1, a1^a2 ... aN-1^a0
  // B = b0^b1, b1^b2 ... bN-1^b0

  // すると、 A[i] == B[(i+k)%N] になるパターンを探せば良いだけになる

  // さて複数位置一致する場合は、AもBもともに、ある数列の n 回の繰り返しになっていないといけない
  // A = C x n, B = D x n
  // C[i] == B[(i+l)%(N/n)]

  vector<u64> cs(N), ds(N);
  cs[0] = as.back()^as[0];
  F0R(i, N-1) {
    cs[i+1] = as[i] ^ as[i + 1];
  }
  ds[0] = bs.back() ^ bs[0];
  F0R(i, N - 1) {
    ds[i+1] = bs[i] ^ bs[i + 1];
  }

  //Print(ds);
  MP<vector<u64>> mp(ds);
  //Print(mp.a);

  cs.insert(cs.end(), rng(cs));
  //Print(cs);

  auto r = mp.findAll(cs);
  for (auto i : r) {
    if (i >= N) continue;
    cout << i << " " << (bs[0] ^ as[i]) << newl;
  }
}
#endif


Measured memory_bytes: 15460
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
r.sort()
G = [[10**9 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    a,b,c = map(int,input().split())
    G[a][b] = min(G[a][b],c)
    G[b][a] = G[a][b]
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(1,N+1):
        for i in range(1,N+1):
            for j in range(1,N+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
warshall_floyd(G)
import itertools
ans = 10**9
for v in itertools.permutations(r):
    v = list(v)
    a = 0
    s = v.pop(0)
    for i in range(R-1):
        t = v[i]
        a += G[s][t]
        s = t
    ans = min(a,ans)
print(ans)


Measured memory_bytes: 46956
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    ll l[87];
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=n;i++){
        l[i]=l[i-2]+l[i-1];
    }
    cout<<l[n]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string field[H];
  for (int i=0;i<H;i++){
    cin >> field[i];
  }
  int dh[8]={-1,-1,-1,0,0,1,1,1};
  int dw[8]={-1,0,1,-1,1,-1,0,1};
  
  for (int h=0;h<H;h++){
    for (int w=0;w<W;w++){
      if (field[h][w]=='.'){
        int count=0;
        for (int i=0;i<8;i++){
          int nh=h+dh[i];
          int nw=w+dw[i];
          if (nh<0||nh>H-1||nw<0||nw>W-1){
            continue;
          }
          else if (field[nh][nw]=='#'){
            count++;
          }
        }
        field[h][w]=count+'0';
      }
    }
  }
  for (int i=0;i<H;i++){
    cout << field[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int N;
	int a = 4, b = 7;

	cin >> N;

	for (int i = 0; i <= N; i++){
		int x = i;
		int y = N - i;
		if (x % a == 0 && y % b == 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main()
{
	char a[105];
		cin>>a;
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++)
		if(a[i]=='1') continue;
		else{
			cout<<a[i]<<endl;
			break;
		}
	if(i==n) cout<<"1"<<endl;
	return 0;
}


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

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m, v, p;
  cin >> n >> m >> v >> p;

  vector<int> a(n);
  for(auto& x : a)
    cin >> x;

  sort(a.begin(), a.end(), greater<int>());

  int ans = p;
  int last = -1;
  int need = a[p - 1];
  ll sum = need;

  for(int i = p; i < n; ++i) {
    int lf =  p - 1;
    int rg = n - i;
    if(v <= p) {
      ans += (a[i] + m >= need);
    } else if(a[i] == need || a[i] == last) {
      ans++;
    } else if(lf + rg >= v) {
      if(a[i] + m >= need) {
        last = a[i];
        ans++;
      }
    } else if(a[i] + m >= need) {
      int left = v - (lf + rg);
      int accepted = a[i] + m;
      int middle = n - (lf + rg);
      if(left < middle) {
        ll fill = 1ll * middle * accepted;
        if(sum + 1ll * m * left <= fill) {
          ans++;
          last = a[i];
        }
      }
    }
    sum += a[i];
  }

  cout << ans << '\n';
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n, x = map(int, input().split())
ls = list(map(int, input().split()))

flag = True
d = 0
for i in range(n):
    d = d + ls[i]
    if d > x:
        flag = False
        break

if flag:
    print(i + 2)
else:
    print(i + 1)

Measured memory_bytes: 38384
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let x: u64 = s.trim().parse().unwrap();

    let r = x / 11;
    let m = x % 11;

    println!("{}",
        if m == 0 {
            r * 2
        }
        else if m > 6 {
            r * 2 + 2
        }
        else {
            r * 2 + 1
        }
    );
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	void Solve() {
		ULL N; cin >> N;
		ULL A, B; cin >> A >> B;
		ULL S = A + B;
		ULL T = N / S;
		ULL ans = T * A;
		N %= S;
		ans += min(A, N);
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int cnt[10];

int main(void){
	scanf("%d",&n);
	int res=0,v=0;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if(a>=3200)v++;
		else{
			cnt[a/400]++;
			if(cnt[a/400]==1)res++;
		}
	}
	printf("%d %d\n",max(1,res),res+v);
	return 0;
}


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

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

using namespace std;
using lint=long long;

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

	if(a>b) return puts("0"),0;

	if(n==1){
		puts(a==b?"1":"0");
	}
	else{
		printf("%lld\n",(a+(n-1)*b)-((n-1)*a+b)+1);
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
slist = [input() for _ in range(N)]
cnt = 0
bnum = 0
anum = 0
banum = 0
for s in slist:
    cnt+= s.count('AB')
    if s[0]=='B':
        bnum+=1
        if s[-1]=='A':
            banum+=1
    if s[-1]=='A':
        anum+=1
if banum == anum == bnum:
    if banum==0:
        print(cnt)
    else:
        print(cnt+banum-1)
else:
    print(cnt+min(bnum,anum))

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    map<string,ll>m;
    ll maxi=0;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]++;
        maxi=max(m[s],maxi);
    }
    map<string,ll>::iterator itr;
    vector<string>ans;
    for(itr=m.begin();itr!=m.end();itr++)
    {
        if(itr->second==maxi)
            ans.pb(itr->first);
    }
    sort(ans.begin(),ans.end());
    for(ll i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 25584
#include<iostream>
//#include<string>
using namespace std;
int main(){
	string row;
	getline(cin,row);
	for(int i=0;i<row.size();i++){
		if(islower(row[i])!=0){
			row[i]=toupper(row[i]);
		}
		else {
			row[i]=tolower(row[i]);
		}
	}
	cout<<row<<endl;
	return 0;
}


Measured memory_bytes: 3132
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        if (a + b >= 10) {
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }
    }
}


Measured memory_bytes: 20564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
    return 0;
}


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

using namespace std;

int main()
{
	long long n,m;
	cin >> n >> m;
	vector<long long> l(n),r(n);
	set<long long> S;
	map<long long,long long> M;
	for(long long i=0;i<n;i++)
	{
		cin >> l[i] >> r[i];
		S.insert(l[i]); S.insert(r[i]);
	}
	long long idx=0;
	for(auto it=S.begin(); it!=S.end(); it++){
		M[*it] = idx++;
	}
	vector<long long> imos(S.size()+1,0);
	for(long long i=0;i<n;i++){
		long long left = M[l[i]];
		long long right = M[r[i]];
		imos[left]++;
		imos[right+1]--;
	}

	long long mx=imos[0];
	for(long long i=0;i<imos.size()-1;i++)
	{
		imos[i+1]=imos[i+1]+imos[i];
		if(imos[i+1]>mx)
			mx=imos[i+1];
	}
	long long lll=m+5,rrr=-1;
	for(long long i=0;i<n;i++)
	{
		if(imos[M[l[i]]]==mx)
			if(l[i]<lll)lll=l[i];
				
		if(imos[M[r[i]]]==mx)
			if(r[i]>rrr)rrr=r[i];
	}
	
	cout << (mx-1)*m+(mx%2==0 ? m-lll:rrr) << endl;
//	cout << mx << endl;
//	cout << lll << " " << rrr << endl;

}


Measured memory_bytes: 52732
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet{
public:
    vector<int> p,rank;
    
    DisjointSet();
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i = 0;i < size;++i){
            makeSet(i);
        }
    }
    
    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
    
    bool same(int x,int y){
        return findSet(x) == findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(void){
    int n,q,x,y,c;
    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);
    
    for(int i = 0;i < q;++i){
        cin >> c >> x >> y;
        switch(c){
            case 0:
                ds.unite(x, y);
                break;
            case 1:
                cout << ds.same(x, y) << endl;
                break;
        }
    }
}


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

using namespace std;

#define endl '\n'

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

    int N, W;
    cin >> N >> W;

    vector<int> v;
    vector<int> w;

    for (int i = 0; i < N; ++i){
    	int vi, wi, mi;
    	cin >> vi >> wi >> mi;
    	int p = 1;
    	while (p < mi){
    		v.push_back(vi * p);
    		w.push_back(wi * p);
    		mi -= p;
    		p = p << 1;
    	}
    	v.push_back(vi * mi);
		w.push_back(wi * mi);
    }

    N = v.size();
    vector<int> dp(W + 1);

    for (int i = N - 1; i >= 0; --i){
    	vector<int> tmp(W + 1);
    	for (int j = 0; j <= W; ++j){
    		tmp[j] = dp[j];
    		if (j >= w[i])
    			tmp[j] = max(tmp[j], dp[j - w[i]] + v[i]);
    	}
    	dp.swap(tmp);
    }

    cout << dp[W] << endl;
}



Measured memory_bytes: 3312
function Main(input) {
  var arr = input.match(/1/g);
  if (arr !== null) {
    console.log(arr.length);
  } else {
    console.log(0);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> i >> j;
    if(abs(i-j)%2==0){
        cout << min(i,j) + abs(i-j)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

int main(){
    solve();
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

shokin = [300000, 200000, 100000]

total = 0
if X <= 3:
  total += shokin[X-1]
if Y <= 3:
  total += shokin[Y-1]
if X == 1 and Y == 1:
  total += 400000

print(total)

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2000005;




void solve()
{
	int s;
	cin >> s;
	long double x = (double)s / 3;
	long double p = x * x * x;
	cout << setprecision(12) << fixed << p;
	//bug(x);
	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
using namespace std;





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll tests=1;
   // cin>>tests;
    while(tests--)
    {
       ll n,i;
       string s;
       cin>>n;
       cin>>s;
       ll ans=0;
       i=0;
       while(i<n)
       {
           if(s[i]=='A')
           {
               i++;
               if(i<n && s[i]=='B')
               {
                   i++;
                   if(i<n && s[i]=='C')
                   {i++;ans++;}
               }
           }
           else
           i++;
       }
        cout<<ans;
    }
    
    return 0;
}


Measured memory_bytes: 256
<?php

    // AtCoder Beginner Contest 161
    // A - ABC Swap

    list($x, $y, $z) = in_ints();
    out($z . ' ' . $x . ' ' . $y);
    
    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }



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

struct RollingHash2D{
  typedef unsigned long long ull;
  
  struct RollingHash{
    typedef unsigned long long ull;
    string S;
    ull B;
    Int len;
    vector<ull> hash,p;
    RollingHash(){}
    RollingHash(string S_,ull B_=1000000007LL):
      S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
      hash[0]=0;p[0]=1;
      for(Int i=0;i<len;i++){
	hash[i+1]=hash[i]*B+S[i];
	p[i+1]=p[i]*B;
      }
    }
    //S[l,r)
    ull find(Int l,Int r){
      return hash[r]-hash[l]*p[r-l];
    }
  };
  
  vector<string> S;
  Int h,w,r,c;
  ull B;
  vector<ull> p;
  vector<vector<ull> > hash;
  vector<RollingHash> rh;
  RollingHash2D(){}
  RollingHash2D(vector<string> S_,Int r_,Int c_,ull B_=1000000009LL):
    S(S_),h(S_.size()),w(S_[0].size()),r(r_),c(c_),B(B_),
    p(h+1),hash(h+1,vector<ull>(w-c+1,0)),rh(h){
    for(Int i=0;i<h;i++) rh[i]=RollingHash(S[i]);
    p[0]=1;
    for(Int i=0;i<h;i++) p[i+1]=p[i]*B;
    for(Int j=0;j<w-c+1;j++){
      hash[0][j]=0;		    
      for(Int i=0;i<h;i++)
	hash[i+1][j]=hash[i][j]*B+rh[i].find(j,j+c);
    }
  }
  //[i,i+r) * [j,j+c)
  ull find(Int i,Int j){
    return hash[i+r][j]-hash[i][j]*p[r];
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<string> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  for(Int i=0;i<n;i++) s[i]=s[i]+s[i];
  for(Int i=0;i<n;i++) s.emplace_back(string(s[i]));
  vector<string> t(s);
  for(Int i=0;i<n*2;i++)
    for(Int j=0;j<n*2;j++)
      t[i][j]=s[j][i];

  RollingHash2D rs(s,n,n);
  RollingHash2D rt(t,n,n);

  Int ans=0;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      ans+=rs.find(i,j)==rt.find(j,i);

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


Measured memory_bytes: 16896
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

struct LazySegmentTree{
   int n;
   vector<ll> node,lazy,flag;
public:
   LazySegmentTree(int sz,ll init){
       n=1;
       while(n<sz)n*=2;
       node.resize(2*n-1,init);
       lazy.resize(2*n-1,0);
   }

   void eval(int k,int l,int r){
       if(lazy[k]!=0){
           node[k]+=lazy[k];
       if(r-l>1){
            lazy[2*k+1]+=lazy[k];
           lazy[2*k+2]+=lazy[k];
       }
       }
       lazy[k]=0;
    }
       //[a,b)にxを加算
    void update(int a,int b,ll x,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
           lazy[k]+=x;
           eval(k,l,r);
        }
        else {
           update(a,b,x,2*k+1,l,(l+r)/2);
           update(a,b,x,2*k+2,(l+r)/2,r);
           node[k]=min(node[2*k+1],node[2*k+2]);
        }
    }
   //[a,b)での和を返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return longinf;
       if(a<=l&&r<=b)return node[k];
       ll xl=get(a,b,2*k+1,l,(l+r)/2);
       ll xr=get(a,b,2*k+2,(l+r)/2,r);
       return min(xl,xr);
   }
};
int main(){
   int n,q;
   cin>>n>>q;
   LazySegmentTree sg(n,0);
   rep(i,q){
       int t;cin>>t;
       if(t){
           int a,b;
           cin>>a>>b;
           b++;
           cout<<sg.get(a,b)<<endl;
       }
       else {
           int a,b,c;
           cin>>a>>b>>c;
           sg.update(a,b+1,c);
       }
   }
   return 0;
}


Measured memory_bytes: 7052
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

//int a[1001][1001] //aise global me hi

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string
//memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find()    // sort(v.begin(),v.end(),compare)

void solve()
{
  int a[3][3];
  f(i,0,3)
  f(j,0,3) cin>>a[i][j];
  bool out=false;
int n;cin>>n;
unordered_map<int,int> m;
while(n--)
{
int x;cin>>x;m[x]++;
}

f(i,0,3)
{bool u=true;
	f(j,0,3)
	{
		if(m.count(a[i][j])==0) u=false; 
	}
	if(u) out=u;
}


f(i,0,3)
{bool u=true;
	f(j,0,3)
	{
		if(m.count(a[j][i])==0) u=false; 
	}
	if(u) out=u;
}

if(m.count(a[0][0])!=0&&m.count(a[2][2])!=0&&m.count(a[1][1])!=0)
out=true;
if(m.count(a[1][1])!=0&&m.count(a[0][2])!=0&&m.count(a[2][0])!=0)
out=true;

if(out) cout<<"Yes";
else cout<<"No";


}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
long int a,b,c,d;
long int e[4];
long int max;

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

e[0]=a*c;
e[1]=a*d;
e[2]=b*c;
e[3]=b*d;

max=e[0];

for(int i=1;i<=3;i++){
if(e[i]>max) max=e[i];
}

printf("%ld\n", max);

  return 0;

}


Measured memory_bytes: 1736
*_, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse
b = gets.split.map(&:to_i).sort.reverse
c = gets.split.map(&:to_i).sort.reverse
puts a.product(b).map { |x, y| x + y }.sort.reverse[0, k].product(c).map{ |x, y| x + y }.sort.reverse[0, k] * "\n"

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

int j, y;

// あり得る得点状況なら0、さらにそれが終着点ならば1、あり得ないなら2
int isFinish(string s){
    int a = count(s.begin(), s.end(), 'A');
    int b = count(s.begin(), s.end(), 'B');

    // 与えられた得点状況に達した場合
    if(a == j && b == y)    return 1;
    
    // 与えられた得点状況には達していないが試合が終わってしまった場合
    bool base = a <= j && b <= y;
    if(!base)   return 2;

    if(min(a,b) <= 3 && max(a,b) == 5)  return 2;
    if(max(a,b) == 6)   return 2;
    if(a == b && a == 5)    return 2;

    return 0;
}

void dfs(string s){
    int x = isFinish(s);
    if(x == 0){
        if(isFinish(s+"A") <= 1)    dfs(s+"A");
        if(isFinish(s+"B") <= 1)    dfs(s+"B");
    }else if(x == 1){
        cout << s << endl;
        return;
    }
}

int main(){
    cin >> j >> y;
    dfs("");
    return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
int main()
{
    int A,B,T,i,t,b=0;
    scanf("%d %d %d",&A,&B,&T);
    if(A>=1 && B>=1 && T>=1 && A<=20 && B<=20 && T<=20){
        for(i=1;;i++){
            t=i*A;
             if(t>T+.5)break;
            b=b+B;

        }
    }
    printf("%d\n",b);
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


bool dp[310][310];
int dplen[310];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  while(cin>>N,N){
	VI xs(N);
	REP(i,N) cin >> xs[i];
	fill((bool*)dp, (bool*)dp+310*310, false);
	fill(dplen, dplen+310, 0);

	REP(i,N+1) dp[i][i] = true;
	for(int l=2;l<=N;l+=2){
	  for(int b=0,e=b+l;e<=N;++b,++e){
		dp[b][e] = dp[b][e] || (dp[b+1][e-1] && abs(xs[b]-xs[e-1]) <= 1);
		if(dp[b][e]) continue;
		for(int i=b+2;i<e;i+=2)
		  dp[b][e] = dp[b][e] || (dp[b][i] && dp[i][e]);
	  }
	}

	for(int i=0;i<N;++i){
	  maxi(dplen[i+1], dplen[i]);
	  for(int j=i+2;j<=N;j+=2)
		if(dp[i][j])
		  maxi(dplen[j], dplen[i] + j-i);
	}
	cout << dplen[N] << endl;
  }

  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        vector<int> d(n);
        REP(i, n) {
            cin >> d[i];
        }
        sort(ALL(d));
        ll ans = 0;
        if (n % 2 == 0) {
            ans = accumulate(d.begin() + n / 2, d.end(), 0ll) * 2 - accumulate(d.begin(), d.begin() + n / 2, 0ll) * 2 - d[n / 2] + d[n / 2 - 1];
        } else {
            ans = accumulate(d.begin() + n / 2, d.end(), 0ll) * 2 - accumulate(d.begin(), d.begin() + n / 2, 0ll) * 2 - d[n / 2] - d[n / 2 + 1];
            ans = max(ans, accumulate(d.begin() + n / 2 + 1, d.end(), 0ll) * 2 - accumulate(d.begin(), d.begin() + n / 2 + 1, 0ll) * 2 + d[n / 2] + d[n / 2 - 1]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n, r;
	cin >> n >> r;
	if (n < 10) {
		cout << r + 100 * (10 - n) << endl;
	}
	else {
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int mod = 1e9 + 7;
	int n;
	cin >> n;
	vll a(n),b(n);
	REP(i, 1, n+1) {
		cin >> a[i-1];
		b[i-1] = abs((i - 1) - (n - i));
	}
	/*rep(i, n)
	{
		//cout << a[i] << " " << b[i] << endl;
	}*/
	sort(all(a));
	sort(all(b));
	if (a != b) {
		cout << 0 << endl;
		return 0;
	}
	ll sum = 1;
	rep(i, n/2)
		sum = (sum*2) % mod;
	cout << sum << endl;
	return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	int ac = 0, wa = 0, tle = 0, re = 0;
	for(int i = 0; i < n; i ++)
	{
		char s[5];
		scanf("%s", s);
		if(s[0] == 'A') ac++;
		else if(s[0] == 'W') wa++;
		else if(s[0] == 'T') tle++;
		else re++;
	}
	printf("AC x %d\n", ac);
	printf("WA x %d\n", wa);
	printf("TLE x %d\n", tle);
	printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 1732
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String W = br.readLine().toLowerCase();
    int count = 0;

    while (true){
      String line = br.readLine();
      if (line.equals("END_OF_TEXT")) {break;}
      line = line.toLowerCase();
      String[] words = line.split(" ");
      for (int i = 0; i < words.length; i++){
        if (W.equals(words[i])) {count++;}
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 24388
// atcoder/abc123/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, a, b, c, d, e;
  while (cin >> n >> a >> b >> c >> d >> e) {
    lli m = min({a, b, c, d, e});
    cout << (n + m - 1) / m + 4 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define double long double
using namespace std;
typedef pair<ll, ll>P;
double mypow(double x, ll y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1) * x;
	else return mypow(x, y / 2) * mypow(x, y / 2);
}
signed main() {
	double n, k;
	cin >> n >> k;
	double p = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		ll q = i;
		while (q < k) {
			q *= 2;
			p++;
		}
		ans += mypow((double)1 / 2, p);
		p = 0;
	}
	cout << setprecision(15) << ans / (double)n << endl;
	ggr
}

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

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N; cin >> N;
  vector<double> v(N);
  REP(i, N) cin >> v[i];
  sort(ALL(v));
  REP(i, N-1){
    double tmp = (v[0]+v[1])/2;
    v.erase(v.begin()); v.erase(v.begin());
    v.pb(tmp);
    sort(ALL(v));
  }
  coutdb << v[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    multiset<int>b;
    rep(i,n){
        if(i==0){
            b.insert(-a[i]);
            continue;
        }
        auto itr = b.upper_bound(-a[i]);
        if(itr==b.end()){
            b.insert(-a[i]);
        }else{
            b.erase(itr);
            b.insert(-a[i]);
        }
        
    }
    cout << b.size() << endl;
    // for(auto x:b){
    //     cerr << x << endl;
    // }
    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;


int main(){
  int n;cin >> n;
  int ans = MAX;
  rep(i,0,n+1){
    int cc = 0;
    int t = i;
    while(t > 0){
      cc += t%6;
      t /= 6;
    }
    t = n-i;
    while (t>0) {
      cc += t%9;
      t /= 9;
    }
    ans = min(ans, cc);
  }
  std::cout << ans << '\n';

}


Measured memory_bytes: 256
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
    	cin >> a[i];
    	sum += a[i];
    }
   // cout << sum << endl;
    sort(all(a));
    vector<ll> div;
	for (ll i = 1; i * i <= sum; ++i) {
		if (sum % i == 0) {
			div.pb(i);
			div.pb(sum / i);
		}
	}
	sort(all(div));
	reverse(all(div));
	for (ll cur : div) {
		vector<ll> temp;
		ll tot_sum = 0;
		for (int i = 0; i < n; ++i) {
			temp.pb(a[i] % cur);
			if (cur == 7) {
				//cout << a[i] % cur << endl;
			}
			tot_sum += (a[i] % cur);
		}
		sort(all(temp));
		reverse(all(temp));
		ll done = 0;
		for (ll j : temp) {
			if (!tot_sum) break;
			ll left = cur - j;
			done += left;
			tot_sum -= cur;
			//if (!tot_sum) break; 
		}
		if (done <= k) {
			cout << cur << endl;
			exit(0);
		}
	} 
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {
	
	

	int a, b;cin >> a >> b;
	cout << a * b << endl;
	

	


	return 0;
}


Measured memory_bytes: 3636