akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
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;
}

int main() {

    int n, m;
    cin >> n >> m;

    vector<vector<int>> v(n);
    vector<P> g;
    rep(i, m){
        int p, y;
        cin >> p >> y;
        p--;
        g.emplace_back(p, y);
        v[p].push_back(y);
    }

    rep(i, n){
        sort(all(v[i]));
    }

    rep(i, m){
        cout << setfill('0') << right << setw(6) << g[i].first + 1;
        cout << setfill('0') << right << setw(6) << 
            (int)(lower_bound(v[g[i].first].begin(), v[g[i].first].end(), g[i].second) - v[g[i].first].begin()) + 1<< endl;
    }
    

    return 0;
}

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

struct Dice{
  Dice(vector<int>& dice) : dice_(dice) {
    east_.push_back(4);    east_.push_back(2);
    east_.push_back(1);    east_.push_back(6);
    east_.push_back(5);    east_.push_back(3);
    north_.push_back(2);    north_.push_back(6);
    north_.push_back(3);    north_.push_back(4);
    north_.push_back(1);    north_.push_back(5);
    south_.push_back(5);    south_.push_back(1);
    south_.push_back(3);    south_.push_back(4);
    south_.push_back(6);    south_.push_back(2);
    west_.push_back(3);    west_.push_back(2);
    west_.push_back(6);    west_.push_back(1);
    west_.push_back(5);    west_.push_back(4);
  }

  void East(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[east_[i]-1];
  }

  void North(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[north_[i]-1];
  }

  void South(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[south_[i]-1];
  }

  void West(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[west_[i]-1];
  }

  void Ans(int x, int y){
    if(dice_[2]!=x && dice_[3]!=x){
      while(dice_[0] != x)
	North();
    }
    else{
      while(dice_[0] != x)
	East();
    }
    while(dice_[1] != y || dice_[0] != x){
      East();
      South();
      West();
    }
      cout << dice_[2] << endl;
  }

  vector<int> dice_;
  vector<int> east_;
  vector<int> north_;
  vector<int> south_;
  vector<int> west_;
};

int main(){
  vector<int> a(6);
  int q, x, y;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> q;
  Dice dice(a);
  while(q--){
    cin >> x >> y;
    dice.Ans(x, y);
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline void chmax(T& a, T b) { if (a < b) {a = b;}}
template<class T> inline void chmin(T& a, T b) { if (a > b) {a = b;}}
using namespace std;
typedef pair<int64_t, int64_t> P;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, 0, N) cin >> A[i] >> B[i];
    
    vector<vector<int>> dp(N+1, vector<int>(H+1, INF));
    dp[0][0] = 0;
    rep(i, 0 ,N){
        rep(j, 0, H + 1){
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+A[i], H)], dp[i+1][j] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

bool tanku(const V& a, int s) {
    const V li = {5, 7, 5, 7, 7};
    int w = 0, p = 0;
    for (int i = s; p < 5; i++) {
        w += a[i];
        if (w == li[p]) {
            w = 0;
            p++;
        } else if (w > li[p]) {
            return false;
        }
    }
    return true;
}

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

    int n;
    while (cin >> n, n) {
        V a;
        rep(i, n) {
            string s;
            cin >> s;
            a.emplace_back(s.size());
        }

        rep(i, n) {
            if (tanku(a, i)) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e3+10;
const int MAX_V=5e5+10;

int N,v,e;
int id[MAX][MAX];

int h[MAX_V];

vi G[MAX_V];
vi ans;
void input(){
    cin>>N;
    v=N*(N-1)/2;
    e=N*(N-2);
    int ni=0;
    rep1(i,N)rep1(j,N)if(i<j){
        id[i][j]=ni;
        ni++;
    }
    rep1(i,N)rep1(j,N)if(i>j){
        id[i][j]=id[j][i];
    }
    rep1(i,N){
        vi od(N-1);
        rep(j,N-1){
            cin>>od[j];
        }
        rep(j,N-2){
            int v1=id[i][od[j]];
            int v2=id[i][od[j+1]];
            G[v1].pb(v2);
            h[v2]++;
        }
    }
}

int dp[MAX_V];
int dfs(int V){
    if(dp[V]!=-1)return dp[V];
    int tmp=0;
    rep(i,sz(G[V])){
        int u=G[V][i];
        tmp=max(tmp, dfs(u));
    }
    dp[V]=tmp+1;
    return tmp+1;
}

void solve(){
  //入次数が0の頂点の集合
  stack<int> st;
  //入次数が0の頂点であればstに追加
  rep(i, v) if(h[i] == 0) st.push(i);
  //stがなくなるまでループ
  while(st.size()) {
    //stの集合のから一つ取り出す
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: G[i]) {
      //隣接する頂点の入次数をマイナス1
      h[j]--;
      //これによって入次数が0になればstに追加
      if(h[j] == 0) st.push(j);
    }
  }
  //ansを順に出力

    if(sz(ans)!=v)cout<<-1<<endl;
    else{
        rep(i,v)dp[i]=-1;
        int x=0;
        rep(i,v){
            x=max(x, dfs(i));
        }
        cout<<x<<endl;
    }
}
void output(){
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 37624
unittest
{
	assert( [ "1", "3 7" ].parse.expand.solve == "2" );
	assert( [ "4", "13 13", "7 11", "7 11", "2017 2017" ].parse.expand.solve == "1\n0\n0\n1" );
	assert( [ "6", "1 53", "13 91", "37 55", "19 51", "73 91", "13 49" ].parse.expand.solve == "4\n4\n1\n1\n1\n2" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto q = input.front.to!( long );
	auto lrs = new long[ 2 ][ q ];
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	return tuple( lrs );
}

auto solve( long[ 2 ][] lrs )
{
	// 累積和表を作成
	const M = 10L ^^ 5;
	auto cs = new long[ M + 1 ];
	auto ps = M.primes;
	bool[ long ] pps;
	for( auto n = 2L; n < cs.length; n++ )
	{
		cs[ n ] = cs[ n - 1 ];
		if( ps.empty || n < ps.front ) continue;
		if( ( n + 1 ) / 2 in pps ) cs[ n ]++;
		pps[ ps.front ] = true;
		ps.popFront;
	}
	
	// クエリを処理
	auto anss = new long[ lrs.length ];
	foreach( ref ans, lr; lockstep( anss, lrs ) )
	{
		ans = cs[ lr[ 1 ] ] - cs[ lr[ 0 ] - 1 ];
	}
	return anss.to!( string[] ).join( "\n" );
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

vector <ll> color(100, 0);
vector <vector <ll>> m(100, vector <ll> (100, INF));
vector <ll> d(100, INF);
vector <ll> p(100, -1);

ll prim(ll n) {
  d.at(0) = 0;
  while (true) {
    ll mincost = INF;
    ll u;
    rep(i, n) {
      if (color.at(i) != 2 && d.at(i) < mincost) {
        mincost = d.at(i);
        u = i;
      }
    }
    if (mincost == INF) {
      break;
    }
    color.at(u) = 2;
    rep(i, n) {
      if (color.at(i) != 2 && m.at(u).at(i) != INF) {
        if (m.at(u).at(i) < d.at(i)) {
          d.at(i) = m.at(u).at(i);
          p.at(i) = u;
          color.at(i) = 1;
        }
      }
    }
  }
  ll sum = 0;
  rep(i, n) {
    if (p.at(i) != -1) sum += m.at(p.at(i)).at(i);
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  rep(i, n) {
    rep(j, n) {
      ll a;
      cin >> a;
      if (a != -1) {
        m.at(i).at(j) = a;
      }
    }
  }
  cout << prim(n) << endl;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for (int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    int x[n],y[n],h[n];
    rep(i,n){
      cin>>x[i]>>y[i]>>h[i];
    }
    rep(cx,101)rep(cy,101){
      bool f=true;
      int ch,i=0;
      while(h[i]==0)i++;
      ch=h[i]+abs(cx-x[i])+abs(cy-y[i]);
      for(int i=0;i<n;i++){
        if(h[i]!=max(ch-abs(cx-x[i])-abs(cy-y[i]),0)){
          f=false;
          break;
        }
      }
      if(f) {
        cout<<cx<<" "<<cy<<" "<<ch<<endl;
        return 0;
      }
    }

    return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int n, t;
    cin >> n >> t;
    vector< P > ab(n);
    rep (i, n)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(), ab.end());

    int dp[n + 1][t + 1];
    rep (i, n + 1) rep (j, t + 1) dp[i][j] = 0;

    rep (i, n)
    {
        rep (j, t + 1)
        {
            if (j < ab[i].first)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else
            {
                dp[i + 1][j] = MAX(dp[i][j], dp[i][j - ab[i].first] + ab[i].second);
            }
        }
        dp[i + 1][t] = MAX(dp[i][t], dp[i][t - 1] + ab[i].second);
    }

    cout << dp[n][t] << "\n";
    return 0;
}



Measured memory_bytes: 35456
// abc139_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int a,b,ans=0;
  cin>>a>>b;
  for(int i=0;;++i) {
    if (b<=a*i-(i-1)) {
      ans=i;
      break;
    }
  }

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


Measured memory_bytes: 256
// 11192019.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

char a[3005][3005];
long long dpo[3005][3005] = { 0 };
long long dpi[3005][3005] = { 0 };

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) cin >> a[i][j];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == 'O') dpo[i][j]++;
			if(j>=1) dpo[i][j] += dpo[i][j - 1];
		}
	}
	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++) {
			if (a[i][j] == 'I') dpi[i][j]++;
			if (i >= 1) dpi[i][j] += dpi[i - 1][j];
		}
	}
	long long ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == 'J') {
				ans += (dpi[h - 1][j] - dpi[i][j]) * (dpo[i][w - 1] - dpo[i][j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll  INF = 1e18;
const ld  PI = acos((ld) -1);
template<class T> inline void array_input(T a[], size_t n){for(size_t i = 0; i < n; i++)cin >> a[i];}

ll BinExp(ll a, ll b, ll MOD){
    ll p = 1;

    while(b){
        if(b % 2) p = p * a % MOD;
        b /= 2;
        a = a * a % MOD;
    }
    return p;
}
//#define FILE

int main(){
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // 0

    ll n;
    cin >> n;
    if(n == 1) cout << 0 << '\n';
    else{
        ll ans = (BinExp(10, n, MOD) + BinExp(8, n, MOD))%MOD;
        ll a = BinExp(9, n, MOD) * 2 % MOD;

        cout << (ans - a + MOD) % MOD << '\n';
    }

    return 0;
}


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

int main(void){
 int n;
 cin>>n;
 vector<int>a(n,0);
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
 sort(a.begin(),a.end(),greater<int>());
 int alice=0,bob=0;
 for(int i=0;i<a.size();i++){
     if(i%2){
         bob+=a[i];
     }else{
         alice+=a[i];
     }
 }
 cout<<alice-bob<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

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

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

Measured memory_bytes: 3640
m,d = map(int,input().split())
count = 0
if ( m < 4 ) or (d < 22):
         print(count)
else:
         for i in range(22,d+1):
                  ii = str(i)
                  i1= int(ii[-1])
                  i10= int(ii[-2])
                  if i1 * i10 <= m and i1 >= 2 and i10 >= 2:
                           count += 1
         else:
                  print(count)


Measured memory_bytes: 3060
from functools import reduce

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a % b)
    
def lcm(a,b):
    return (a * b) // gcd(a, b)

def gcd_list(numbers):
    return reduce(gcd, numbers)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
    
N = int(input())
times = [int(input()) for i in range (N)]

print(lcm_list(times))

Measured memory_bytes: 3572
S = gets.chomp

def a(s)
  case s.to_i
  when 1..12
    :month
  else
    :year
  end
end

puts case [a(S[0..1]), a(S[2..3])]
     when [:month, :month]
       'AMBIGUOUS'
     when [:year, :month]
       'YYMM'
     when [:month, :year]
       'MMYY'
     else
       'NA'
     end


Measured memory_bytes: 1788
/*  I love Cara Delevingne */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e6 + 5;

ll n, a[MAXN];
vll v;

ll get_pos(int x) {
	int l = 0, r = sz(v) - 1;
	while (l <= r) {
		int m = (l + r) >> 1;
		if (v[m] == x) return m + 1;
		else if (v[m] > x) r = m - 1;
		else l = m + 1; 
	}
	return -1;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		v.pb(a[i]);
	}
	sort(all(v));
	for (int i = 1; i <= n; i++) {
		a[i] = get_pos(a[i]);
	}
	int ct = 0;
	for (int i = 1; i <= n; i++) {
		if (abs(a[i] - i) % 2 == 1) {
			ct++;
		}						
	}
	cout << (ct >> 1);
}


int main() {

    int tt = 1;
	while (tt--) {
		solve();	
	}
	return 0;
}


Measured memory_bytes: 1912
# -*- coding: utf-8 -*-

from collections import Counter
import re

def pow(a, x):
        y = 1
        p = a % mask
        n = x
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:   
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)

tmp = 1 
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

counter = Counter(a)
dup = counter.most_common(1)[0][0]
left = a.index(dup)
right = a[left+1:].index(dup) + left + 1

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i]))

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1])
        print ans % mask


Measured memory_bytes: 25664
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int pt=0;
    int s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        if(s[s[i]-1]==i+1)pt++;
    }
    cout<<pt/2<<endl;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CColoringColorfully solver = new CColoringColorfully();
        solver.solve(1, in, out);
        out.close();
    }

    static class CColoringColorfully {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            boolean fl = true;
            int changes1 = 0, changes2 = 0;
            for (int i = 0, l = s.length(); i < l; i++, fl = !fl) {
                char cur = s.charAt(i);
                if (fl) {
                    if (cur == '0')
                        changes1++;
                    else
                        changes2++;
                } else {
                    if (cur == '1')
                        changes1++;
                    else
                        changes2++;
                }
            }
            out.println(Math.min(changes1, changes2));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}

Measured memory_bytes: 24532
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s;
	cin>>s;
	REP(i,s.size()){
		if(i%2==0){
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        
        long a1 = a * c;
        long a2 = a * d;
        long a3 = b * c;
        long a4 = b * d;
                
        long b1 = Math.max(a1, a2);
        long b2 = Math.max(a3, a4);
        long ans = Math.max(b1, b2);
        
        System.out.println(ans);      
        
    }
}

Measured memory_bytes: 27052
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,p = LI()
    a = LI()

    r = [0] * 5005
    r[0] = 1
    for c in a:
        for i in range(5000,c-1,-1):
            r[i] += r[i-c]

    rr = 0
    for i in range(5005):
        if i%2 == p:
            rr += r[i]

    return rr


print(main())





Measured memory_bytes: 8252
while True:
    d, w, h = [int(x) for x in input().split()]
    minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)
    if minrad == 0:
        break
    n = int(input())
    for i in range(n):
        r = int(input())
        if 4*r*r > minrad:
            print('OK')
        else:
            print('NA')

Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int h,w;
  cin >> h>>w;
  
  string m;
  
  //端っこを0としておく
  char c[h+2][w+2];
  for(int i=0;i<w+2;i++){
    c[0][i]='.';
    c[h+1][i]='.';
  }
  for(int i=0;i<h+2;i++){
    c[i][0]='.';
    c[i][w+1]='.';
  }
  
  //cにすべてインプットする
  for(int i=0;i<h;i++){
    cin >>m;
    for(int j=0;j<w;j++){
      c[i+1][j+1]=m.at(j);
    }
  }
   for(int i=0;i<h;i++){
    //爆弾のにすべて変える
    for(int j=0;j<w;j++){
      if(j<w-1){
        if(c[i+1][j+1]=='.'){
          int a=0;
          if(c[i][j]=='#'){a++;}
          if(c[i][j+1]=='#'){a++;}
          if(c[i][j+2]=='#'){a++;}
          if(c[i+1][j]=='#'){a++;}
          if(c[i+1][j+2]=='#'){a++;}
          if(c[i+2][j]=='#'){a++;}
          if(c[i+2][j+1]=='#'){a++;}
          if(c[i+2][j+2]=='#'){a++;}
          cout << a ;
        }else if(c[i+1][j+1]=='#'){
          cout << '#';
        }
      }else {
         if(c[i+1][j+1]=='.'){
          int a=0;
          if(c[i][j]=='#'){a++;}
          if(c[i][j+1]=='#'){a++;}
          if(c[i][j+2]=='#'){a++;}
          if(c[i+1][j]=='#'){a++;}
          if(c[i+1][j+2]=='#'){a++;}
          if(c[i+2][j]=='#'){a++;}
          if(c[i+2][j+1]=='#'){a++;}
          if(c[i+2][j+2]=='#'){a++;}
          cout << a <<endl;
        }else if(c[i+1][j+1]=='#'){
          cout << '#'<<endl;
         }
      }
    }
   }
}
  

      
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    string t; cin >> t;
    int count = 0;
    for(int i = 0; i <= n-3; ++i){
        if(t[i] == 'A' && t[i+1] == 'B' && t[i+2] == 'C') count++;
    }
    cout << count;
    return 0;
    }



Measured memory_bytes: 256
#include <cstdio>

#define MOD 1000000007

typedef long long ll;

ll comb[2222][2222];

int main(void)
{
	ll n, k, i, j;

	scanf("%lld %lld" ,&n, &k);

	for (i = 0; i <= n; i++)
	{
		comb[i][0] = 1;
		for (j = 1; j <= i; j++)
			comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
	}

	for (i = 1; i <= k; i++)
		printf("%lld\n" ,comb[k - 1][i - 1] * comb[n - k + 1][i] % MOD);
	return 0;
}

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

int main(){
    const double EPS = 1e-12;
    double x[4];
    double y[4];
    double s;
    double t;
    double u;
    double v;
    double m;
    int n;
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

        s = x[1] - x[0];
        t = y[1] - y[0];
        u = x[3] - x[2];
        v = y[3] - y[2];

        if(s * v - t * u > 0){
            m = s * v - t * u;
        }
        else{
            m = t * u - s * v;
        }

        if(m < EPS){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long h, w;
    cin >> h >> w;
    vector<vector<char>> as(h, vector<char>(w));
    vector<vector<char>> bs;
    vector<int> badh(h);
    vector<int> badw(w);
    for (int i = 0; i < h; i++) {
        int hgood = 0;
        int wgood = 0;
        for (int j = 0; j < w; j++) {
            cin >> as[i][j];
            if (as[i][j] == '#') {
                hgood++;
            }
        }
        if (hgood == 0) {
            badh[i]++;
        }
    }
    // // cout << "hogrider" << endl;
    for (int j = 0; j < w; j++) {
        int hgood = 0;
        int wgood = 0;
        for (int i = 0; i < h; i++) {
            // cout << i << " " << j << endl;
            if (as[i][j] == '#') {
                wgood++;
            }
        }
        if (wgood == 0) {
            badw[j]++;
        }
    }
    // // cout << "hogrider" << endl;
    for (int i = 0; i < h; i++) {
        int a = 0;
        for (int j = 0; j < w; j++) {
            // cout << h << " " << w << endl;
            // cout << "hogrider" << endl;
            if (badh[i] == 0 && badw[j] == 0) {
                cout << as[i][j];
                a++;
                // cout << "hogrider" << endl;
            }
        }
        if (a > 0) {
            cout << endl;
        }
    }
    // cout << "hogrider" << endl;
    // for (int i = 0; i < bs.size(); i++) {
    //     for (int j = 0; j < bs[i].size(); j++) {
    //         cout << bs[i][j] << endl;
    //         // cout << "hogrider" << endl;
    //     }
    // }
    // cout << "hogrider" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= H && A[r] > A[largest] ) largest = r;

  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}


Measured memory_bytes: 6508
import java.util.*

data class Node(val id: Int, val edges: List<Edge>, var visited: Boolean = false)
data class Edge(val nodeId: Int, val weight: Int)

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: 0
    val nodeList = List(n) { i ->
        val input = readLine()?.split(" ".toRegex())?.filterNot { it.isBlank() }?.map(String::toInt) ?: listOf()
        val edges = input.mapIndexed { index, w -> Edge(index, w) }.filter { it.weight != -1 }
        Node(i, edges)
    }
    var node = nodeList.first().apply { visited = true }
    val nextEdges = PriorityQueue<Edge>(compareBy { it.weight })
    nextEdges.addAll(node.edges)
    var weight = 0
    while (nextEdges.isNotEmpty()) {
        val nextEdge = nextEdges.poll()
        node = nodeList.first { it.id == nextEdge.nodeId }
        if (!node.visited) {
            weight += nextEdge.weight
            node.visited = true
            nextEdges.addAll(node.edges)
        }
    }
    println(weight)
}


Measured memory_bytes: 41404
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

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

	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);

	ll moves = min(x / d, k);
	ll res = x - moves * d - ((k - moves) % 2) * d;

	if (k >= moves + 1)
	{
		moves++;
		ll res2 = x - moves * d + ((k - moves) % 2) * d;
		if (abs(res2) < abs(res))
			res = res2;
	}

	cout << abs(res) << '\n';

	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	long t = sc.NextInt();
    	long res = 0;
    	long start = sc.NextInt();
    	long stop = start + t;
    	for (int i = 1; i < n; i++)
    	{
    		int x = sc.NextInt();
    		if (x >= stop)
    		{
    			res += stop - start;
    			start = x;
    		}
    		stop = x + t;
    	}
    	res += stop - start;
    	Console.WriteLine(res);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 28256
import numpy as np
N,K = map(int,input().split())
datas = np.zeros(N)
for i in range(K):
    n = int(input())
    A = list(map(int,input().split()))
    for a in A:
        datas[a-1] += 1
print(np.count_nonzero(datas == 0))

Measured memory_bytes: 27116
//     自己选择的路，跪着也要走完。朋友们，虽然这个世界日益浮躁起来，只
// 要能够为了当时纯粹的梦想和感动坚持努力下去，不管其它人怎么样，我们也
// 能够保持自己的本色走下去。                               ——陈立杰
/*************************************
 * @contest:      ABC172.
 * @user_name:    brealid/hkxadpall/zhaoyi20/jmoo/jomoo/航空信奥/littleTortoise.
 * @time:         2020-06-27.
 * @language:     C++.
*************************************/ 

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

namespace baseFastio {
    template <typename Int>
    inline Int read()       
    {
        Int flag = 1;
        char c = getchar();
        while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
        if (c == '-') flag = -1, c = getchar();
        Int init = c & 15;
        while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
        return init * flag;
    }

    template <typename Int>
    inline Int read(char &c)       
    {
        Int flag = 1;
        c = getchar();
        while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
        if (c == '-') flag = -1, c = getchar();
        Int init = c & 15;
        while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
        return init * flag;
    }

    template <typename Int>
    inline void write(Int x)
    {
        if (x < 0) putchar('-'), x = ~x + 1;
        if (x > 9) write(x / 10);
        putchar((x % 10) | 48);
    }  

    template <typename Int>
    inline void write(Int x, char nextch)
    {
        write(x);
        putchar(nextch);
    }
}

struct Reader {
    char endch;
    Reader() { endch = '\0'; }
    template <typename Int>
    Reader& operator >> (Int &i) {
        i = baseFastio::read<Int>(endch);
        return *this;
    }
    template <typename Int>
    inline Int get_int() {
        return baseFastio::read<Int>();
    }
    inline char get_nxt() {
        return endch;
    }
} read;

struct Writer {
    Writer& operator << (const char *ch) {
        // char *p = ch;
        while (*ch) putchar(*(ch++));
        return *this;
    }
    Writer& operator << (const char ch) {
        putchar(ch);
        return *this;
    }
    template <typename Int>
    Writer& operator << (const Int i) {
        baseFastio::write(i);
        return *this;
    }
} write;

// #define int int64

string s, t;

signed main()
{
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
        ans += (s[i] != t[i]);
    write << ans << '\n';
    return 0;
}

Measured memory_bytes: 3824
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


signed main()
{
	int A, B, T;
	cin >> A >> B >> T;
	int ans = 0;
	for (int t = 1; t <= T; t++)
	{
		if (t % A == 0)
		{
			ans += B;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;

}
    



    
        
    


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

vector<int> ch[100005];
int fr[100005];
int d[100005];
int n;

void dfs(int at)
{
	for (int u: ch[at]) if (u != fr[at])
	{
		d[u] = d[at]+1;
		fr[u] = at;
		dfs(u);
	}
}

vector<int> calc(const vector<int> &diam)
{
	vector<int> ans;
	int nval = 1;
	for (size_t i = 1;i < diam.size()-1;i++)
	{
		int here = 0;
		for (int u: ch[diam[i]]) if (u != diam[i-1] && u != diam[i+1])
		{
			if (ch[u].size() != 1)
			{
				printf("-1\n");
				exit(0);
			}
			here++;
		}
		for (int j = 1;j <= here;j++) ans.push_back(nval+j);
		ans.push_back(nval);
		nval += here;
		nval++;
	}
	return ans;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1;i < n;i++)
	{
		int a, b; scanf("%d%d", &a, &b);
		--a, --b;
		ch[a].push_back(b);
		ch[b].push_back(a);
	}
	for (int i = 0;i < n;i++) d[i] = 10000000, fr[i] = -1;
	d[0] = 0; dfs(0);
	int s = 0; for (int i = 1;i < n;i++) if (d[i] > d[s]) s = i;
	for (int i = 0;i < n;i++) d[i] = 10000000, fr[i] = -1;
	d[s] = 0; dfs(s);
	s = 0; for (int i = 0;i < n;i++) if (d[i] > d[s]) s = i;
	vector<int> diam;
	diam.push_back(-1);
	for (int at = s;at != -1;at = fr[at]) diam.push_back(at);
	diam.push_back(-1);
	vector<int> ans = calc(diam);
	reverse(diam.begin(), diam.end());
	vector<int> alt = calc(diam);
	ans = min(ans, alt);
	for (int u: ans) printf("%d ", u); printf("\n");
	return 0;
}


Measured memory_bytes: 13048
N = int(input())
A = list(map(int, input().split()))
 
eight = 0
one = 0
two = 0
 
 
for i in A:
    if i%4 == 0:
        eight = eight + 1
    if i == 1:
        one = one + 1
    if i % 2 == 0 and i % 4 != 0:
        two = two + 1
 
if len(A)//2 <= eight:
    print("Yes")
elif (len(A)//2) <= (eight + (two//2)):
    print("Yes")
 
elif (eight >= one) and (eight + one +(two//2)) > (len(A)//2):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 20028
#include<stdio.h>
int main(){
  int a[100001]={0},i,n,t;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);if(t>0)a[t-1]++;a[t]++;a[t+1]++;}
  t=0;for(i=0;i<100000;i++)t=t<a[i]?a[i]:t;
  printf("%d",t);
}


Measured memory_bytes: 2124
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

int main()
{
    lint X[4], Y[4];
    X[1] = Y[1] = 0;

    lint S;
    cin >> S;

    lint sqrtS = sqrt(S);

    if (sqrtS * sqrtS == S)
    {
        X[2] = Y[3] = sqrtS;
        X[3] = Y[2] = 0;
    }
//    else if (S <= sqrtS*(sqrtS + 1))
//    {
//        X[2] = sqrtS;
//        Y[3] = sqrtS + 1;
//        X[3] = sqrtS*(sqrtS + 1) - S;
//        Y[2] = 1;
//    }
    else
    {
        X[2] = sqrtS + 1;
        Y[3] = sqrtS + 1;
        X[3] = X[2] * Y[3] - S;
        Y[2] = 1;
    }

    reps (i, 3)
    {
        cout << X[i] << " " << Y[i] << ((i!=3)?" ":"\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int h,w,n; cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> prec(h*w);
    int k=0,l=0;
    while(k<h*w){
        rep(i,a[l]){
            prec[k] = l+1;
            k++;
        }
    l++;
    }

    int ans[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i%2==0){
                ans[i][j] = prec[i*w+j]; 
            }else{
                ans[i][w-j-1] = prec[i*w+j];
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
using System;

namespace ConsoleApplication{
    public class Program{
        public static void Main(string[] args){
            while(true){
                string shuffle = Console.ReadLine();

                if("-".Equals(shuffle)) break;

                int count = int.Parse(Console.ReadLine());

                for(int i=0; i<count; i++){
                    int shufflePlace = int.Parse(Console.ReadLine());
                    
                    shuffle = ShuffleCards(shuffle , shufflePlace);
                }
                Console.WriteLine(shuffle);
            }
        }

        ///??????????????????
        private static string ShuffleCards(string cards, int place){
            return cards.Substring(place) + cards.Substring(0, place);
        }

    }
}

Measured memory_bytes: 8872
h, w = map(int, input().split())
S = [str(input()) for _ in range(h)]

#g = [[] for _ in range(h*w)]

n = h*w

def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

par = [-1]* n
rank = [0]*n

for y in range(h):
    for x in range(w):
        idx1 = y*w+x
        for dy, dx in (-1, 0), (1, 0), (0, -1), (0, 1):
            ny, nx = y+dy, x+dx
            if 0 <= ny < h and 0 <= nx < w:
                idx2 = ny*w+nx
                if S[y][x] != S[ny][nx]:
                    Unite(idx1, idx2, par, rank)

ans = 0
#print(par)
X = [[0, 0] for _ in range(n)]
K = []

for i in range(n):
    y, x = divmod(i, w)
    if par[i] < 0:
        K.append(i)
        if S[y][x] == '#':
            X[i][0] += 1
        else:
            X[i][1] += 1
    else:
        if S[y][x] == '#':
            X[Find(i, par)][0] += 1
        else:
            X[Find(i, par)][1] += 1

ans = 0
for k in K:
    ans += X[k][0]*X[k][1]
print(ans)

Measured memory_bytes: 95172
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    double a, b;
    cin>>a>>b;
    long long int ans = -1;
    for(int i=1; i<8000; i++){
        if(floor(i*1.08)-i==a&&floor(i*1.10)-i==b){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26288