akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i = 0; i < 3*n; i++)    cin >> a[i];
    vector<ll> be(3*n), af(3*n);
    priority_queue<int> pq;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        pq.push(-a[i]);
    }
    be[n-1] = sum;
    for(int i = n; i < 3*n; i++){
        int val = -pq.top();
        if(a[i] > val){
            sum += a[i]-val;
            pq.pop();
            pq.push(-a[i]);
        }
        be[i] = sum;
    }
    while(!pq.empty())  pq.pop();
    sum = 0;
    for(int i = 3*n-1; i >= 2*n; i--){
        pq.push(a[i]);
        sum += a[i];
    }
    af[2*n] = sum;
    for(int i = 2*n-1; i >= 0; i--){
        int val = pq.top();
        if(a[i] < val){
            sum -= val-a[i];
            pq.pop();
            pq.push(a[i]);
        }
        af[i] = sum;
    }
    ll ans = -(1ll<<60);
    for(int i = n-1; i <= 2*n-1; i++){
        ans = max(ans, be[i]-af[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6780
#include<map>
#include<cstdio>

using namespace std;

int main()
{
	bool ans[31]={false};
	map<int,int> data;
	int id,score;
	for(int i=0;~scanf("%d,%d",&id,&score),id||score;i++){
		ans[score]=true;
		data.insert(make_pair(id,score));
	}

	int rank[31];
	for(int i=30,r=1;i>=0;i--){
		if(ans[i])	rank[i]=r++;
	}

	while(~scanf("%d",&id))printf("%d\n",rank[data[id]]);

	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(" ").map { it.toInt() }
    val ct = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    val ans = ct.filter { it.last() <= t }.minBy { it.first() }

    ans?.let { println(ans[0]) } ?: println("TLE")
}

Measured memory_bytes: 37868
n=int(input())
xy=[[] for i in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    x-=1
    xy[i].append((x,y))
ans=0
for i in range(1<<n):
  cnt=bin(i).count("1")
  if cnt<=ans:continue
  for j in range(n):
    if i&(1<<j):
      for x,y in xy[j]:
        if y==1 and i&(1<<x):continue
        if y==0 and i&(1<<x)==0:continue
        break
      else:
        continue
      break
  else:
    ans=cnt
print(ans)






Measured memory_bytes: 9104
#include <string>
#include<queue>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<map>
#include<tuple>

using namespace std;

typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;
typedef tuple<int,int,int,int> t4;

const int MX = 205;

int D[MX];
vector<int> L[MX];
int R[MX];
int vst[MX], t = 1;

int dfs(int x){
	if( vst[x] == t ) return 0;
	vst[x] = t;
	for(int c : L[x]){
		if( !R[c] || dfs(R[c])){
			R[c] = x;
			return 1;
		}
	}
	return 0;
}

int is_prime(int a){
	if( a < 0) a = -a;
	if( a == 1 ) return false;
	for(int i = 2; i*i <= a; i++) if( a%i == 0 ) return false;
	return true;
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d", D+i);
	}

	int M = 1, E[MX] = {0, D[1]};
	for(int i = 2; i <= N; i++){
		if( D[i-1] != D[i]-1){
			E[++M] = D[i-1]+1;
			E[++M] = D[i];
		}
	}
	E[++M] = D[N]+1;

	int a = 0, b = 0;
	for(int i = 1; i <= M; i++){
		if( E[i]%2 == 0) a++;
		else b++;
	}
	for(int i = 1; i <= M; i++){
		for(int j = 1; j <= M; j++){
			if( E[i]%2 == 0 && E[j]%2 == 1 );
			else continue;
			if( is_prime(E[i] - E[j]) ) L[i].push_back(j);
		}
	}
	int ans = 0;
	for(int i = 1; i <= M; i++){
		t++; if(dfs(i)) ans++, a--, b--;
	}
	ans += (a/2 + b/2) * 2;
	if( a%2 == 1 ) ans += 3;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include<queue>
#define rep(i,n) for (int i=0; i<(n);++i)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
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; }

int main() {
	int N;
	cin >> N;
	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
		cout << "hon" << endl;
	}
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>

typedef long long ll;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

const ll MAX = 1000000000000001;

int main()
{
  std::vector<ll> vx(1, 0LL);
  ll num = 1LL;
  ll sum = 0LL;
  while (sum < MAX) {
    num *= 26;
    vx.push_back(num + sum);
    sum += num;
  }

  ll N;
  std::cin >> N;

  ll cnt = 0LL;
  std::vector<ll> vn;
  for (ll i = 1LL; i < (ll)vx.size(); i++) {
    if (N <= vx[i]) {
      cnt = N - vx[i-1];
      vn = std::vector<ll>(i, 0LL);
      break;
    }
  }

  N = cnt - 1;

  ll idx = 0LL;
  while (N > 0) {
    ll x = N % 26;
    N /= 26;
    vn[idx] = x;
    idx++;
  }

  std::reverse(vn.begin(), vn.end());
  for (auto n : vn) {
    char c = 'a' + n;
    std::cout << c;
  }
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 3604
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;
const ll MOD = 1e9+7;

int main() {
	int N;
	cin>>N;
	ll a1 = 1;
	for (int i = 0;i < N;++i) {
		a1 *= 10;
		a1 %= MOD;
	}

	ll a2 = 1;
	for (int i = 0;i < N;++i) {
		a2 *= 9;
		a2 %= MOD;
	}

	a2 *= 2;
	a2 %= MOD;

	ll a3 = 1;
	for (int i = 0;i < N;++i) {
		a3 *= 8;
		a3 %= MOD;
	}

	a1 = a1 - a2;
	if (a1 < 0) {
		a1 = MOD - (abs(a1));
	}

	cout<<(a1+a3)%MOD<<endl;
	return 0;
}


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

leftWest = 0
rightEast = list(S).count("E")

ans = 10 ** 6
for i in range(len(S)):
    if S[i] == "E":
        rightEast -= 1
    
    ans = min(ans, leftWest + rightEast)

    if S[i] == "W":
        leftWest += 1

print(ans)

Measured memory_bytes: 6044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[100001];
vi adj[100001];
int h[100001];
int ans, k;

void dfs(int u, int p)
{
	h[u] = 0;
	if(adj[u].empty())
	{
		h[u] = 1;
	}
	//cout << u << ' ' << h[u] << '\n';
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		dfs(v, u);
		h[u] = max(h[u], h[v] + 1);
	}
	if(u != 1 && p != 1 && h[u] >= k)
	{
		ans++;
		//cout << "CLEAR : " << u << ' ' << h[u] << '\n';
		h[u] = 0;
	}
	//cout << u << ' ' << h[u] << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	ans = 0;
	if(a[1] != 1)
	{
		a[1] = 1;
		ans++;
	}
	for(int i = 2; i <= n; i++)
	{
		adj[a[i]].pb(i);
		//cout << a[i] << ' ' << i << '\n';
	}
	//now we have a tree
	dfs(1, -1);
	cout << ans;
}	


Measured memory_bytes: 14336
import math
a, b, h, m = map(int, input().split())
A = h*30 + m*0.5
B = m*6
if abs(B-A) == 180:
    print(a+b)
elif abs(B-A) < 180:
    print((a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(B-A))))**0.5)
else:
    c = 360 - B + A
    print((a**2 + b**2 - 2*a*b*math.cos(math.radians(c)))**0.5)

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

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

	long long N, C;
	scanf("%lld %lld", &N, &C);

	vector<long long> x(N);
	vector<long long> v(N);
	vector<long long> clockwise_sum(N);
	vector<long long> clockwise_sum_max(N);
	vector<long long> clockwise_sum_return_max(N);
	vector<long long> counter_sum_max(N);
	vector<long long> counter_sum_return_max(N);
	// vector<long long> counter_sum(N);

	scanf("%lld %lld", &x[0], &v[0]);
	clockwise_sum[0] = v[0];
	clockwise_sum_max[0] = max((long long)0, v[0] - x[0]);
	clockwise_sum_return_max[0] = max((long long)0, v[0] - x[0] * 2);

	for (int i = 1; i < N; i++)
	{
		scanf("%lld %lld", &x[i], &v[i]);
		clockwise_sum[i] = clockwise_sum[i - 1] + v[i];
		clockwise_sum_max[i] = max(clockwise_sum_max[i - 1], clockwise_sum[i] - x[i]);
		clockwise_sum_return_max[i] = max(clockwise_sum_return_max[i - 1], clockwise_sum[i] - x[i] * 2);
	}

	long long all_sum = clockwise_sum[N - 1];
	counter_sum_max[N - 1] = max((long long)0, v[N - 1] - (C - x[N - 1]));
	counter_sum_return_max[N - 1] = max((long long)0, v[N - 1] - (C - x[N - 1]) * 2);
	for (int i = N - 2; i >= 1; i--)
	{
		counter_sum_max[i] = max(counter_sum_max[i + 1], all_sum - clockwise_sum[i - 1] - (C - x[i]));
		counter_sum_return_max[i] = max(counter_sum_return_max[i + 1], (all_sum - clockwise_sum[i - 1]) - (C - x[i]) * 2);
	}
	counter_sum_max[0] = max(counter_sum_max[1], all_sum - (C - x[0]));
	counter_sum_return_max[0] = max(counter_sum_return_max[1], all_sum - (C - x[0]) * 2);

	long long result = max(max(clockwise_sum_max[N - 1], counter_sum_max[0]), (long long)0);
	// cout << "start " << result << "\n";
	for (int i = 0; i < N - 1; i++)
	{
		long long i_max = max(clockwise_sum_max[i] + counter_sum_return_max[i + 1], clockwise_sum_return_max[i] + counter_sum_max[i + 1]);
		if (result < i_max)
		{
			// cout << i << ":" << clockwise_sum_max[i] << " " << counter_sum_return_max[i + 1] << " or " << clockwise_sum_return_max[i] << " " << counter_sum_max[i + 1] << "\n";
			result = i_max;
		}
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int n;
	cin >> n;
	string s;
	cin >> s;
	ll r = 0, g = 0, b = 0;
	rep(i, n) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}
	ll ans = r * g * b;
	rep(i, n) {
		rep(k, n) {
			if ((i + k) & 1 || i >= k) continue;
			int j = (i + k) / 2;
			set<char> st;
			st.insert(s[i]);
			st.insert(s[j]);
			st.insert(s[k]);
			if (st.size() == 3) ans--;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3632
#include<iostream>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1000000007;
const string YES = "Yes";
const string NO = "No";
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll a[100100];

ll modpow(ll a, ll x){
    if(x == 0)return 1;
    if(x % 2 == 0){
        ll t = modpow(a, x/2);
        return t * t % mod;
    }
    return a * modpow(a, x-1) % mod;
}

int main() {
    int n, k;
    cin >> n >> k;
    
    for(int i=k;i>=1;i--){
        ll t = k / i;//iの倍数の数
        a[i] = modpow(t, n);
        if(a[i]<0){
            cout << NO;
        }

        for(int j=i+i;j<=k;j+=i){
            a[i] -= a[j];
            if(a[i] < 0)a[i] += mod;
        }   
    }
    ll ans = 0;
    for(int i=1;i<=k;i++) {
        ans += a[i] * i;
        ans %= mod;
    }
    cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(0);
  
  int n;
  cin >> n;
  string s;

  int cnt[5] = {0,0,0,0,0};
  
  for (int i=0; i<n; i++) {
    cin >> s;
    if (s.at(0) == 'M') cnt[0]++;
    if (s.at(0) == 'A') cnt[1]++;
    if (s.at(0) == 'R') cnt[2]++;
    if (s.at(0) == 'C') cnt[3]++;
    if (s.at(0) == 'H') cnt[4]++;
  }
  long long ans=0,tmp;
  int cnt2;
  for (int i=0; i<(1<<5); i++) {
    cnt2=0;
    for (int j=0; j<5; j++) {
      if (i & (1<<j))
	cnt2++;
    }
    if (cnt2 == 3) {
      tmp=1;
      for (int j=0; j<5; j++) {
	if (i & (1<<j))
	  tmp *= cnt[j];
      }
      ans += tmp;
    }
  }


  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9


int main(){
    int h,w;
    cin>>h>>w;
    bool black[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            black[i][j]=false;
        }
    }
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    
    queue<pair<int,int>> q;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
               black[i][j]=true;
               q.push(make_pair(i,j));
            }
        }
    }
    int cnt_q=q.size(),cnt=0;
    int ans=0;
    while(!q.empty()){
        if(cnt==cnt_q){
            ans++;
            cnt=0;
            cnt_q=q.size();
        }
        pair<int,int> p=q.front();
        q.pop();
        int i=p.first;
        int j=p.second;
        if(i-1>=0 && !black[i-1][j]){
            black[i-1][j]=true;
            q.push(make_pair(i-1,j));
        }
        if(j-1>=0 && !black[i][j-1]){
            black[i][j-1]=true;
            q.push(make_pair(i,j-1));
        }
        if(j+1<w && !black[i][j+1]){
            black[i][j+1]=true;
            q.push(make_pair(i,j+1));
        }
        if(i+1<h && !black[i+1][j]){
            black[i+1][j]=true;
            q.push(make_pair(i+1,j));
        }
        cnt++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10512
import sys

def calc_floor(A, B, X):
    return (int(A * X / B) - A * int(X / B))

A, B, N = map(int, sys.stdin.readline().split())
if N >= B - 1:
    print(calc_floor(A, B, B - 1))
else:
    print(calc_floor(A, B, N))

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


int main() {
  int N, K;
  cin >> N >> K;
  long long pattern = 1;

  for(int i = 1; i < N; ++i){
    pattern *= K - 1;
  }
  cout << pattern * K << endl;

  return 0;
}



Measured memory_bytes: 3588
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let a = scan "%d" id

let () =
  Printf.printf "%d" @@ a + Int.pow a 2 + Int.pow a 3


Measured memory_bytes: 5428
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repe(i, n) for(int i = 0; i <= (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#define elif else if
typedef long long ll;

int main(){
  int N;
  cin>>N;
  int A[105];
  rep(i,N)cin>>A[i];
  int ans=0;
  rep1(i,N){
    if(A[i-1]==A[i]){
      ans++;
      A[i]=-1;	
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S,T;
  cin>>S>>T;
  int Q;
  cin>>Q;
  VI A(Q),B(Q),C(Q),D(Q);
  rep(i,Q) cin>>A[i]>>B[i]>>C[i]>>D[i];
  VI X(S.size()+1),Y(T.size()+1);
  rep(i,S.size()) X[i+1]=X[i]+1+(S[i]=='B');
  rep(i,T.size()) Y[i+1]=Y[i]+1+(T[i]=='B');
  rep(i,Q) cout<<(((X[B[i]]-X[A[i]-1])%3==(Y[D[i]]-Y[C[i]-1])%3)?"YES":"NO")<<endl;
}

Measured memory_bytes: 3200
package main
 
import "fmt"
 
func main() {
	var n, ans, i, j int64
	ans = 0
	fmt.Scanf("%d", &n)
 
	for i = 1; i*i <= n; i++ {
		if n%i == 0 {
			j = n / i
			ans = i + j - 2
		}
	}
	fmt.Printf("%d", ans)
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int count = 0;
  int size = s.size();
  
  rep(i, size) {
    if (s.at(i) == '1') {
      count++;
    }
  }
  cout << count << endl;
}
  

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int n, M;
    cin >> n >> M;
    cout << (n-1)*(M-1) << "\n";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
min_x=sum(x)/n
int_x=int(min_x)
if min_x-int_x <= int_x+1-min_x:
    mp=int_x
else:
    mp=int_x+1
ans=0
for i in range(n):
    ans+=(x[i]-mp)**2
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/7/2018
 
 14:00-14:04 analysis
 14:11 1WA
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
//const int MAX_N=1e5+1;
int N;
LL H;
vector<LL> A,B;
void solve() {
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  
  vector<LL> cum(N+1,0);
  REP(i,N)cum[i+1]=cum[i]+B[i];
  
  LL res=1e9+100;
  REPE(i,N) {
    LL h=max(0LL,H-cum[i]);
//    LL h=H-cum[i];
    LL x=i;
    x+=(h+A.front()-1)/A.front();
//    dump2(i,x);
    SMIN(res,x);
  }
  cout<<res<<endl;
}

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


Measured memory_bytes: 2560
"use strict";

const main = arg => {
    const N = arg.split("\n")[0].split("");
    const R = N.slice(0, N.length);
    
    console.log(N.join("") == R.reverse().join("") ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7496
s = input()

if s[0] != "A":
    print("WA")
    exit()

if s[2:-1].count("C") != 1:
    print("WA")
    exit()

if s[1:].replace("C", "").lower() == s[1:].replace("C", ""):
    print("AC")
else:
    print("WA")

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

int main(){

    int x, a, b, A, B;

    cin >> x >> a >> b;

    A = x - a;

    if(A < 0){
        A *= -1;
    }

    B = x - b;

    if(B < 0){
        B *= -1;
    }

    if(A <= B){
        cout << "A" << endl;
    }
    else{
        cout << "B" << endl;
    }

    return 0;

}



Measured memory_bytes: 3628
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let a: Vec<usize> = (0..m).map(|_| input()).collect();
    const MOD: i64 = 1000000007;

    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    let mut j = 0;
    for i in 1..n + 1 {
        if j < m && a[j] == i {
            dp[i] = 0;
            j += 1;
        } else {
            dp[i] += dp[i - 1];
            if i > 1 {
                dp[i] += dp[i - 2];
            }
            dp[i] %= MOD;
        }
    }

    println!("{}", dp[n]);
}


Measured memory_bytes: 6396
#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;

  return 0;
}



Measured memory_bytes: 3864
#include <iostream>

using namespace std;
using ll = long long;

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

    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int len;
    string s;
    cin>>s;
    len=s.length();
    int l=0,r=len+1;
    while(r-l>1)
    {
        int k=(l+r)>>1,f=1;
        for(int i=len-k; i<k-1; i++)
        {
            if(s[i]!=s[i+1])
                f=0;
        }
        if(f)
            l=k;
        else
            r=k;
    }
    cout<<l<<endl;

    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll mod=(int)1e9+7;

int main()
{
	ios;
	set<int> s;
	int n,k,p,i;
	cin>>k>>n;
	for(i=0;i<n;i++) 
	{
		cin>>p;
		s.insert(p);
	}
	p=0;
	while(true)
	{
		if(s.find(k-p)==s.end()) { cout<<k-p; break;}
		else if(s.find(k+p)==s.end()) { cout<<k+p; break;}
		p++;
	}

	
	return 0;
}


Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
      	int Y = sc.nextInt();
      	int xset[] = new int[N];
      	int yset[] = new int[M];
      	for(int i=0;i<N;i++){
        	xset[i] = sc.nextInt();
        }
      	for(int i=0;i<M;i++){
        	yset[i] = sc.nextInt();
        }
		Arrays.sort(xset);
      	Arrays.sort(yset);
      	if(xset[N-1]<yset[0] &&xset[N-1]>= X && yset[0] <= Y){
        	System.out.println("No War");
        }else{
        	System.out.println("War");
        }      
    }
}

Measured memory_bytes: 21844
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef double                      ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 4e3 + 10;
const ll MX5 = 4e5 + 10;
const ll MX6 = 1e6 + 10;
const ll LOG = 20;
const ll INF = 1e15;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7;// 998244853

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}
ll h, w, n, x, y, men;
ll dp[MXN], F[MX5], I[MX5];
vector<pll> A;
void init(){
    F[0] = 1, I[0] = 1;
    for(int i = 1; i < MX5; i ++) F[i] = (F[i - 1] * i) % MOD;
    for(int i = 1; i < MX5; i ++) I[i] = (I[i - 1] * power(i, MOD - 2, MOD)) %  MOD;
}
ll C(ll n, ll r){
    if(r > n || r < 0) return 0;
    return (((F[n] * I[r]) % MOD) * I[n - r]) % MOD;
}
ll Cal(ll dx, ll dy){
    return C(dx + dy, dx);
}
int main(){
    fast_io
    //file_io
    init();
    cin >> h >> w >> n;
    for(int i = 0; i < n; i ++) cin >> x >> y, A.pb({x, y});
    A.pb({h, w});
    Sort(A);
    for(int i = 0; i <= n; i ++){
        dp[i] = Cal(A[i].F - 1, A[i].S - 1), men = 0;
        for(int j = 0; j < i; j ++){
            if(A[j].S > A[i].S) continue;
            ll now = (Cal(A[i].F - A[j].F, A[i].S - A[j].S) * dp[j]) % MOD;
            men = (men + now) % MOD;
        }
        dp[i] = (dp[i] - men + MOD) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}
/*
        Pain
        You made me a, you made me a believer, believer
        Pain
        You break me down, you build me up, believer, believer
*/
//! N.N


Measured memory_bytes: 6656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define XMAX 1000000000

int main(){
  int n, i, j, k, x, q;
  char buf[32];
  unsigned int *a;
  a = (unsigned int *)malloc(XMAX/8);
  for (i=0; i<XMAX/8/sizeof(int); i++)
    a[i] = 0;
  
  int count=0;
  unsigned int bit[32];
  unsigned int u = 1;
  for (i=0; i<32; i++) {
    bit[i] = u;
    u *= 2;
  }
  
  fgets(buf, 32, stdin);
  n = atoi(buf);
  for (i = 0; i < n; i++){
    fgets(buf, 32, stdin);
    q = atoi(buf);
    x = atoi(strchr(buf, ' '));
    
    if (q==0) {
      if ((a[x/32] & bit[x%32]) == 0) {
	a[x/32] |= bit[x%32];
	count++;
      }
      
      k = count;
      if (k==0) {
	putc_unlocked('0', stdout);
      } else {
	if (k<0) {
	  putc_unlocked('-', stdout);
	  k=-k;
	}
	for (j=1; j*10<=k; j*=10);
	for (;j>0; j/=10) {
	  putc_unlocked('0'+k/j, stdout);
	  k %= j;
	}
      }
      putc_unlocked('\n', stdout);
      
    } else { // q==1
      if ((a[x/32] & bit[x%32]) == 0)
	putc_unlocked('0', stdout);
      else
	putc_unlocked('1', stdout);
      putc_unlocked('\n', stdout);
    }
  }
  return 0;
}



Measured memory_bytes: 123732
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N=100000+10;
int n;
LL k,a[N];

int main()
{
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	
	LL ans=0;
	for (int i=60;i>=0;i--) {
		int cnt=0;
		for (int j=1;j<=n;j++)
			if (a[j]&(1LL<<i)) cnt++;
		if (cnt<n-cnt)
			if (ans+(1LL<<i)<=k) ans+=(1LL<<i);	 	
	}
	LL sum=0;
	for (int i=1;i<=n;i++) sum+=ans^a[i];
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 1024
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    string str;
    cin >> str;
    int n = str.size();
    
    if (str[n-1] == 's')str += "es";
    else str += 's';
    cout << str << endl;


    return 0;
}

Measured memory_bytes: 3124
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := getInt(), getInt()
	fmt.Println(math.Ceil(float64(1 + (float64(n-k) / float64(k-1)))))
}


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

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

#define pb push_back
#define mp make_pair
#define endl '\n'
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define read(v, a, b) for(int i=(a); i<(b); i++) cin>>v[i]
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl
#define _ << " " <<

const int maxn = 450;
const ll inf = 0x3f3f3f3f3f3f3f3f;

int a[maxn];
ll dp[maxn][maxn], sum[maxn];

ll solve(int l, int r){
	if(l >= r) return 0;
	if(dp[l][r] != -1) return dp[l][r];
	
	ll ans = inf;
	
	rep(i,l,r){
		ans = min(ans, solve(l, i) + solve(i+1, r));
	}
	
	return dp[l][r] = ans + sum[r] - sum[l-1];
}

int main(){
	int n; scanf("%d", &n);
	
	rep(i,1,n+1){
		scanf("%d", &a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	
	clr(dp, -1);
	
	printf("%lld\n", solve(1, n));
}


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

using namespace std;

char s[200005];
int main() {
    scanf("%s", s);
    int n = strlen(s);
    stack<char> stac;
    for (int i = 0; i < n; ++i) {
        if (!stac.empty() && stac.top() == 'S' && s[i] == 'T') stac.pop();
        else stac.push(s[i]);
    }

    printf("%d\n", stac.size());
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin >> s;
    bool a[26] = {false};
    REP(i,s.size()){
        a[s[i]-'a'] = true;
    }
    REP(i,26){
        if(!a[i]){
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
nums = list(map(int, input().split()))

res =0 
for i in range(60, -1, -1):
  zeros = 0
  ones = 0
  for x in nums:
    if x >> i & 1:
      ones += 1
    else:
      zeros += 1
  res += zeros*ones << i
print(res%(10**9+7))

Measured memory_bytes: 122808
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int H,W;
    cin >> H >> W;
    string S[H][W];
    rep(i,H) rep(j,W) cin >> S[i][j];
    rep(i,H) rep(j,W) if(S[i][j]=="snuke") cout << (char)('A'+j) << i+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
ll p[N];
void init(){
    p[0]=1;
    for(int i=1;i<=1e5;i++)p[i]=(p[i-1]*i)%mod;
}
int n,m;
int main(){
    init();
    cin>>n>>m;
    if(abs(n-m)>=2){
        puts("0");
    }else{
        if(n<m)swap(n,m);
        if(n-m==0){
            cout<<(p[n]*p[m]%mod*2)%mod<<endl;
        }else{
            cout<<(p[n]*p[m])%mod<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
////////////////////////////////////////////////////////////////////

int n,a[110000];
int v[110000];
signed main(){
  cin>>n;rep(i,n)cin>>a[i];
  bool b = true;
  if(n % 2)v[0]++;
  rep(i,n){
    if(n % 2){
      if(a[i] % 2){
        b = false;break;
      }
      v[a[i]/2]++;
    }else{
      if(a[i] % 2 == 0){
        b = false;break;
      }
      v[a[i]/2]++;
    }
  }
  rep(i,(n-1)/2){
    if(v[i] != 2)b = false;
  }
  if(b)cout << modpow(2, n/2, MOD) << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define p printf("bug\n");
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,q,i,sq,j;
int ans[MAX],freq[MAX],arr[MAX];
struct block
{
    int l,r,pos;
} query[MAX];
bool cmp(block a,block b)
{
    if((a.l/sq)<(b.l/sq))
        return 1;
    if((a.l/sq)>(b.l/sq))
        return 0;
    if(a.r<b.r)
        return 1;
    else
        return 0;
}
int main()
{
//freopen("output.txt", "w", stdout);
    scanf("%d %d",&n,&q);
    sq=sqrt(n);
    for(i=0; i<n; i++)
        scanf("%d",&arr[i]);
    for(i=0; i<q; i++)
    {
        scanf("%d %d",&query[i].l,&query[i].r);
        query[i].pos=i;
    }
    sort(query,query+q, cmp);
    int st,en,cnt=0;
    st=query[0].l-1;
    en=query[0].r-1;
    for(i=st; i<=en; i++)
    {
        freq[arr[i]]++;
        if(freq[arr[i]]==1)
            cnt++;
    }
    ans[query[0].pos]=cnt;
    for(i=1; i<q; i++)
    {
        int l=query[i].l-1;
        int r=query[i].r-1;
        int pos=query[i].pos;
        if(l<st)
        {
            for(j=st-1; j>=l; j--)
            {
                freq[arr[j]]++;
                if(freq[arr[j]]==1)
                    cnt++;
            }
            st=l;
        }
        else
        {
            for(j=st; j<l; j++)
            {
                freq[arr[j]]--;
                if(freq[arr[j]]==0)
                    cnt--;
            }
            st=l;
        }
        if(r>en)
        {
            for(j=en+1; j<=r; j++)
            {
                freq[arr[j]]++;
                if(freq[arr[j]]==1)
                    cnt++;
            }
            en=r;
        }
        else
        {
            for(j=en; j>r; j--)
            {
                freq[arr[j]]--;
                if(freq[arr[j]]==0)
                    cnt--;
            }
            en=r;
        }
        // cout<<l<<"   "<<r<< "      " <<cnt<<endl;
        ans[pos]=cnt;
    }
    for(i=0; i<q; i++)
        printf("%d\n",ans[i]);

    return 0;
}


Measured memory_bytes: 15536
N, K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

ans = 0
hands = ["" for _ in range(N)]

for k in range(K):
  if T[k] == "r":
    ans += P
    hands[k] = "p"
  elif T[k] == "s":
    ans += R
    hands[k] = "r"
  else:
    ans += S
    hands[k] = "s"
    
    
for n in range(K,N):
  if T[n] == "r":
    if hands[n-K] != "p":
      ans += P
      hands[n] = "p"
    else:
      hands[n] = "x"
      
  elif T[n] == "s":
    if hands[n-K] != "r":
      ans += R
      hands[n] = "r"
    else:
      hands[n] = "x"
      
  else:#T[n] == "p"
    if hands[n-K] != "s":
      ans += S
      hands[n] = "s"
    else:
      hands[n] = "x"

print(ans)


Measured memory_bytes: 10236
#include <stdio.h>
#include <math.h>

int main(void)
{
  int n, in, i, max = 0, min = 0;
	long sum = 0;
	scanf("%d\n", &n);
	for(i=0;i<n;i++){
		scanf("%d\n", &in);
		if(i==0){
			max=in;
			min=in;
			sum=in;

		}else{
			if(max < in) max = in;
			if(min > in) min = in;
			sum += in;
		}
	}
	printf("%d %d %ld\n", min, max, sum );

  return 0 ;
}

Measured memory_bytes: 604
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    int Q;
    R(Q);
    int rev=0;
    string t[2];
    REP(i,Q){
        int ty;
        R(ty);
        if(ty==1)rev^=1;
        else{
            int x;
            string c;
            R(x,c);
            x=2-x;
            t[x^rev]+=c;
        }
    }
    string res;
    for(int i=SZ(t[1])-1;i>=0;i--)res+=t[1][i];
    res+=s+t[0];
    if(rev)reverse(ALL(res));
    W(res);
    return 0;
}


Measured memory_bytes: 1476
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>

using lli = long long int;
const lli mod=1000000007;

std::vector<std::tuple<lli, lli>> factorize(lli x){
  std::vector<std::tuple<lli, lli>> ans;
  lli nmax = static_cast<lli>(std::sqrt(x))+1;
  for(int i = 2; i < nmax; i++){
    if(x%i == 0){
      lli ni = 0;
      while(x%i == 0){
        ni++;
        x /= i;;
      }
      ans.push_back(std::make_tuple(i, ni));
    }
    //if(x == 1) break;
  }
  if(x > 1) ans.push_back(std::make_tuple(x, 1));
  return ans;
}

constexpr lli mod_inv(lli a){
  lli b=mod, u=1, v=0, tmp=0;
  while(b){
    lli t = a/b;
    a -= t*b;
    tmp = a; a = b; b = tmp; //swap(a, b);
    u -= t*v;
    tmp = u; u = v; v = tmp; //swap(u, v);
  }
  return ((u%mod)+mod)%mod;
}

constexpr lli fac_pre_num = 100100;
struct fac_pre_struct{
  lli fac[fac_pre_num], finv[fac_pre_num];
  constexpr fac_pre_struct() : fac{}, finv{} {
    fac[0] = fac[1] = finv[0] = finv[1] = 1;
    for(int i = 2; i < fac_pre_num; i++) fac[i] = i*fac[i-1] % mod;
    finv[fac_pre_num-1] = mod_inv(fac[fac_pre_num-1]);
    for(int i = fac_pre_num-1; i > 2; i--) finv[i-1] = i*finv[i] % mod;
  }
};
constexpr fac_pre_struct fac_pre;

std::tuple<lli, lli, lli> fac_3_mod(lli a, lli b, lli c){
  lli t = 1;
  lli tb=1, tc=1;
  for(int i = 1; i <= a; i++){
    t = (t*i)%mod;
    if(i == b) tb = t;
    if(i == c) tc = t;
  }
  return std::make_tuple(t, tb, tc);
}

lli mod_comb(lli n, lli k){
  if(n < k || k < 0 || n < 0) return 0;
  if(n < fac_pre_num) return fac_pre.fac[n] * (fac_pre.finv[k] * fac_pre.finv[n-k] % mod) % mod;
  lli fn, fk1, fk2;
  std::tie(fn, fk1, fk2) = fac_3_mod(n, k, n-k);
  return fn * (mod_inv(fk1) * mod_inv(fk2) % mod) % mod;
}

int main(){
  lli N,M;
  std::cin >> N >> M;

  lli ans=1;

  auto f_arr = factorize(M);

  for(auto&& it: f_arr){
    ans = (ans * mod_comb(std::get<1>(it)+N-1, std::get<1>(it))) % mod;
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
import sys

p = 0
s = 0
for line in sys.stdin:
    ls = line.strip('\n')
    if ls == 'END_OF_TEXT': break
    ls = ls.lower()
    if p == 0:
        w = ls
        p = 1
    else:
        for word in ls.split():
            if word == w: s += 1
print s

Measured memory_bytes: 4224