akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    mint power = 1;
    for (int i = 1; i <= n; ++i) {
        power *= i;
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,m,q,i,j,a[200005],l[200005][19],r[200005][19];
long long f[200005][19],g[200005][19];
int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	r[n+1][0]=n+1;
	l[n+1][0]=n+1;
	rep(i,n){
		r[i][0]=max(i,r[i-1][0]);
		while(r[i][0]<=n&&a[r[i][0]]-a[i]<m) r[i][0]++;
	}
	for(i=n;i>=1;i--){
		l[i][0]=min(i,l[i+1][0]);
		while(l[i][0]>=1&&a[i]-a[l[i][0]]<m) l[i][0]--;
	}
	rep(j,18)rep(i,n+1){
		l[i][j]=l[l[i][j-1]][j-1];
		r[i][j]=r[r[i][j-1]][j-1];
	}
	rep(i,n){
		f[i][0]=l[i][0];
		g[i][0]=r[i][0];
	}
	rep(j,18)rep(i,n){
		f[i][j]=f[i][j-1]+f[l[i][j-1]][j-1];
		g[i][j]=g[i][j-1]+g[r[i][j-1]][j-1];
	}
	cin>>q;
	while(q--)
	{
		int x,y,xx,yy;cin>>x>>y;xx=x;yy=y;
		long long ans=y-x+1;
		for(i=18;i>=0;i--){
			if(r[x][i]<=yy){
				ans+=(1<<i);
				ans-=g[x][i];
				x=r[x][i];
			}
			if(l[y][i]>=xx){
				ans+=f[y][i];
				y=l[y][i];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

#define fastread std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;

int main()
{
	fastread;
	
	ll n, i;

    cin>>n;

    ll ar[n], dp[n];

    for(i=0 ; i<n ; ++i)
        cin>>ar[i];
    
    dp[0] = 0;
    dp[1] = abs(ar[0] - ar[1]);
    for(i=2 ; i<n ; ++i)
        dp[i] = min((dp[i-2] + abs(ar[i-2] - ar[i])), (dp[i-1] + abs(ar[i-1] - ar[i])));
    
    cout<<dp[n-1];
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	ll N;
	cin>>N;
	ll keta;
	keta=log10(N)+1;
	vector<int> a(keta-2);
	FDS(i,keta-2){
	    ll k;
		k=(N/pow(10,keta-3-i));
		a[i]=k%1000;
	}
	int ans=9999;
	FDS(i,keta-2){
		int t=0;
		t=abs(a[i]-753);
		ans=min(ans,t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

X, = map(int, input().split())
N, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

print(({1, 2, 3} - {X} - {N}).pop())

Measured memory_bytes: 3316
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)
max = 10 ** 18

a_arr.each do |a|
  if a == 0
    puts 0
    exit
  end
end

result = 1
a_arr.each do |a|
  result *= a
  if result > max
    puts -1
    exit
  end
end

puts result


Measured memory_bytes: 23432
//
//  main.cpp
//  programs
//
//  Created by Arunesh Sarker on 18/11/19.
//  Copyright © 2019 Arunesh Sarker. All rights reserved.
//

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define mod 1000000007
    // 60 60 30 40 5 5
     
  // Function to return LCM of two numbers
 ll gcd(ll a, ll b)
 {
     if (a == 0)
         return b;
     return gcd(b % a, a);
 }
   
 // Function to find gcd of array of
 // numbers
 int findGCD(int arr[], int n)
 {
     int result = arr[0];
     for (int i = 1; i < n; i++)
     {
         result = gcd(arr[i], result);
   
         if(result == 1)
         {
            return 1;
         }
     }
     return result;
 }
// 2 3 4 4 18 24
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    int ctr=1;int fl=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==ctr)
        {
            ctr++;fl=1;
        }
        
    }
    if(fl==0)
        cout<<-1<<"\n";
    else
        cout<<n-ctr+1<<"\n";
}


Measured memory_bytes: 1024
N = int(input())
S = [input()for _ in range(N)]

AC, WA, TLE, RE = (0,0,0,0)

for s in S:
    if s == 'AC':
        AC += 1
    elif s == 'WA':
        WA += 1
    elif s == 'TLE':
        TLE += 1
    elif s == 'RE':
        RE += 1

print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))


Measured memory_bytes: 16332
#include <bits/stdc++.h>
#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() {
  string N;
  cin >> N;

  int s = 0;
  rep(i, N.size()) {
    s += N[i] - '0';
    s %= 9;
  }
  
  if(s  == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    FOR(i,1,1000) {
        if (C-B*i <= 0) {
            cout << "Yes" << endl;
            break;
        }
        if (A-D*i <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}


int main() {
	string s,t; cin >> s >> t;
	int n = s.size(), m = t.size();
	V<string> dp(2*(m+1),"");
	REP(i,n) {
		REP(j,m) {
			if(s[i]==t[j]){
			dp[((i+1)%2)*(m+1)+j+1] = dp[(i%2)*(m+1)+j] + s[i];
			}
			else{
				if(dp[(i%2)*(m+1)+j+1].size()>=dp[((i+1)%2)*(m+1)+j].size()){
					dp[((i+1)%2)*(m+1)+j+1] = dp[(i%2)*(m+1)+j+1];
				}
				else{
					dp[((i+1)%2)*(m+1)+j+1] = dp[((i+1)%2)*(m+1)+j];
				}
			}
		}
	}
	cout << dp[(n%2)*(m+1)+m] << endl;
	return 0;	
}



Measured memory_bytes: 16924
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define PRINT(x) std::cout << x << std::endl
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const double MOD = 1e9+7;

using ll = long long;

int main(int argc, char* argv[]){
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int prev_val, count=0;
  REP(i, 1, n) {
    prev_val = a[i-1];
    if(a[i] == prev_val){
      //cout << "i:" << i << endl;
      if(i < n-1 && a[i+1] != i+1){
	a[i] = i+1;
      }else{
	a[i] = 10000-i;
      }
      count++;
    }
  }
  /*
  rep(i, n) cout << a[i] << " ";
  cout << endl;
  */
  
  PRINT(count);
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

ll MOD;

int calc_lg(ll x) {
  int res = 0;
  while (x > 0) {
    ++res;
    x /= 10;
  }
  return res;
}

ll calc_ten(int e) {
  ll v = 1;
  for (int i = 0; i < e; i++) v *= 10;
  return v;
}

ll power(ll x, ll e) {
  x %= MOD;
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

typedef vector<ll> Vec;
typedef vector<Vec> Mat;

Mat eye(int n) {
  Mat I(n, Vec(n));
  for (int i = 0; i < n; ++i)
    I[i][i] = 1;
  return I;
}
Mat mul(Mat A, const Mat& B) {
  for (int i = 0; i < A.size(); ++i) {
    Vec x(A[0].size());
    for (int k = 0; k < B.size(); ++k)
      for (int j = 0; j < B[0].size(); ++j)
        (x[j] += A[i][k] * B[k][j] % MOD) %= MOD;
    A[i].swap(x);
  }
  return A;
}
Mat pow(Mat A, ll k) {
  Mat X = eye(A.size());
  for (; k > 0; k /= 2) {
    if (k & 1) X = mul(X, A);
    A = mul(A, A);
  }
  return X;
}
Vec mul(const Mat& A, const Vec& b) {
  Vec y(A.size());
  for (int i = 0; i < A.size(); ++i)
    for (int j = 0; j < A[0].size(); ++j)
      (y[i] += A[i][j] * b[j] % MOD) %= MOD;
  return y;
}

ll solveSub(ll A, ll B, ll L, ll ten) {
  A %= MOD;
  B %= MOD;
  ten %= MOD;
  Mat M = {
      {ten, 1, B, 0},
      {0, 1, 0, 0},
      {0, 0, 1, 1},
      {0, 0, 0, 1}};
  vector<ll> init = {0, A, 0, 1};
  auto goal = mul(pow(M, L), init);
  return goal[0];
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll L, A, B;
  while (cin >> L >> A >> B >> MOD) {
    ll goal = A + B * L;
    ll res = 0, cur = 0;
    while (A < goal) {
      int lg = calc_lg(A);
      ll ten = calc_ten(lg);
      // x >= (ten - A) / B
      ll x = min(L - cur, (ten - A + B - 1) / B);
      res = res * power(ten, x) % MOD;
      res += solveSub(A, B, x, ten);
      res %= MOD;
      cur += x;
      A += B * x;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=gets.strip.to_i
a = gets.strip.split.map(&:to_i)

sorted = a.sort
grouped = sorted.group_by {|x| x }
counted = grouped.map {|_,v| v.count }


if n==1 && counted==[1]
  p 1
  exit
end


if n.odd? && counted.shift!=1 || counted.uniq!=[2]
  p 0
  exit
end

div=10**9+7

result = 1
(n/2).floor.times do |num|
  result = result*2%div
end

p result



Measured memory_bytes: 19832
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#define int long long
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
char aa[123456];
signed main() {
	int n, d; cin >> n >> d;
	cout << n * d / gcd(n, d) << endl;
}

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

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a, b;
    top = 0;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
    
    return 0;
}


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

int main(void){
    int n;
    deque<int> deq;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        if(i%2==0){
            deq.push_front(a);
        }else{
            deq.push_back(a);
        }
    }
    rep(i,n){
        cout<<(n%2==1 ? deq[i] : deq[n-1-i])<<(i<n-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
A = list(map(int,input().split()))
m = int(input())
B = list(map(int,input().split()))

T = [[0]*2001 for i in range(n)]

T[0][0] = 1
T[0][A[0]] = 1
for i in range(1,n):
    for j in range(2001):
        T[i][j] = T[i-1][j]
        if (j - A[i] >=0) and (T[i-1][j-A[i]] == 1):
            T[i][j] = 1
    
for i in range(m):
    if T[n-1][B[i]] == 1: print("yes")
    else: print("no")



Measured memory_bytes: 5932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in2(a, b);
  c = a + b;
  if(a % 3 == 0 || b % 3 == 0 || c % 3 == 0)
    out("Possible");
  else
    out("Impossible");
  memi;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
/*beginner contest 161C*/

//さの絶対値を取り続けたときの最小値
int main(){
	//整数入力
	long long int n,m;
	cin >> n >> m;
	long long temp,temp2;

	//結局 n%m か abs(n%m-m)が最小になるのでは？
	temp = n % m;
	temp2 = (n%m-m) * -1;

	if(temp < temp2)
		cout << temp << endl;
	else
		cout << temp2 << endl;

	return 0;
}

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

#define int long long
using namespace std;
bool is_ok(int a,int b){
	string s = to_string(b);
	int d1 = s[1] - '0';
	int d10 = s[0] - '0';
	return (d1 >= 2 && d10>=2 && d1 * d10 == a);
}
main(){
	int m,d;
	cin >> m >> d;
	int ans =0 ;
	for(int i=1;i<=m;i++){
		for(int j=11;j<=d;j++){
			if(is_ok(i,j)) ans++;
		}
	}
	cout << ans << endl;

}

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

int main() {
  int H, W;
  
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    
    for (int i = 0; i < H; i++) {
        
      for (int j = 0; j < W; j++) {
          
        if (!(i == 0 || i == H - 1) && !(j == 0 || j == W - 1)) {
          cout << '.';
        } else {
          cout << '#';
        }
        
      }
      cout << '\n';
      
    }
    cout << endl;
    
  }
  
  return 0;
}


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

int main(){
    int n,h,w;
    cin >> n >> h >> w;
    int ans = 0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >>  a >> b;
        if(a>=h&&b>=w)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define lINF (1ll<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int q;
    cin >> q;
    ll l_sum = 0;
    ll r_sum = 0;
    priority_queue<int> l;
    priority_queue<int,vector<int>,greater<int>> r;
    ll b_sum = 0;
    rep(i,q){
        int type;
        cin >> type;
        if(type==1){
            int a,b;
            cin >> a >> b;
            b_sum += b;
            if(l.size()>r.size()){
                int t = l.top();
                if(t<=a){
                    r.push(a);
                    r_sum += a;
                }else{
                    l.pop();
                    l.push(a);
                    l_sum += a-t;
                    r.push(t);
                    r_sum += t;
                }
            }else{
                if(l.empty())l.push(a),l_sum+=a;
                else{
                    int t = r.top();
                    if(t>=a){
                        l.push(a);
                        l_sum += a;
                    }else{
                        r.pop();
                        r.push(a);
                        r_sum += a-t;
                        l.push(t);
                        l_sum += t;
                    }
                }
            }
        }else{
            int x = l.top();
            ll v = (x*l.size()-l_sum)+(r_sum-x*r.size())+b_sum;
            cout << x << " " << v << endl;
        }
    }
}

Measured memory_bytes: 3452
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int cnt[2][101010];
int main(){
    int n;cin>>n;
    rep(i,n){
        int x;cin>>x;
        cnt[i%2][x]++;
    }
    int ma1=-1,ma2=-1,res1,res2;
    rep(i,101010){
        if(cnt[0][i]>ma1){
            ma1=cnt[0][i];
            res1=i;
        }
        if(cnt[1][i]>ma2){
            ma2=cnt[1][i];
            res2=i;
        }
    }
    if(res1!=res2)cout<<(n-ma1-ma2)<<endl;
    else{
        int maa1=0,maa2=0;
        rep(i,n){
            if(i!=res1&&cnt[0][i]>maa1)maa1=cnt[0][i];
            if(i!=res2&&cnt[1][i]>maa2)maa2=cnt[1][i];
        }
        cout<<min(n-ma1-maa2,n-maa1-ma2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
//============================================================================
// Name        : b
// Date        : Tue Feb 19 22:18:46 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = (int) 1e9 + 7;
void solve() {
    int n, k;
    cin >> n >> k;
    vi aa(n, 0), dp(n, inf);
    fori (i, 0, n) {
        cin >> aa[i];
    }

    dp[0] = 0;
    fori (i, 0, n) {
        fori (j, i + 1, i + k + 1) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(aa[j] - aa[i]));
            }
        }
    }
    output(dp[n - 1]);
}

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



Measured memory_bytes: 1024
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
revA = [a - K for a in A[1:]]
S = revA + A

dis = []
for i in range(N):
  st = S[i]
  ed = S[i + N - 1]
  dis.append(max(st, ed) - min(st, ed))
  
print(min(dis))

Measured memory_bytes: 32692
my $N = <>;
my $hash = {};
for (1..$N) {
    my $key = <>;
    chomp $key;
    $hash->{$key}++;
}
my @sorted = sort {$hash->{$b} <=> $hash->{$a}} keys %$hash;
my $max;
my @result;
for (@sorted) {
    last if $max > $hash->{$_};
    push @result, $_;
    $max = $hash->{$_};
}
print "$_\n" for sort {$a cmp $b} @result; 



Measured memory_bytes: 51196
#include<iostream>
#include<algorithm>

using namespace std;

int w,h;
int g[51][51];

void dfs(int x,int y){
  g[y][x]=0;
  for(int dy=-1;dy<=1;dy++){
    for(int dx=-1;dx<=1;dx++){
      int nx=x+dx,ny=y+dy;
      if(0<=nx && nx<w && 0<=ny && ny<h && g[ny][nx]==1)
	dfs(nx,ny);
    }
  }
}

int main(void){

  while(cin >> w >> h, w|h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> g[i][j];
    
    int cnt=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(g[i][j]==1)cnt++,dfs(j,i);

    cout << cnt << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3220
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String arufa = sc.next();

        if(Character.isUpperCase(arufa.charAt(0))){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 26952
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  int N,i,j;scanf("%d",&N);
  int a[N+1],ans[N+1],sum;
  for(i=1;i<=N;i++) scanf("%d",&a[i]);
  for(i=N;i>=1;i--){
    sum = 0;
    for(j=i+i;j<=N;j+=i) sum ^= ans[j];
    ans[i] = sum^a[i];
  }
  printf("%d\n",accumulate(ans+1,ans+N+1,0));
  for(i=1;i<=N;i++){
    if(ans[i]) printf("%d ",i);
  }
  printf("\n");
}


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

int main()
{
	string s;
	cin >> s;
	map<char, long> mp;
	long n = s.size(), ans = 0;
	for(int i=0; i < n; i++){
		mp[s[i]]++;
		if(s[i] == 'W')ans += mp['B'];
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
 
ll n,l,t;
ll x[100001],w[100001],afx[100001],change[100001];
 
int main(void){
    scanf("%lld%lld%lld",&n,&l,&t);
 
    REP(i,n){
        scanf("%lld%lld",&x[i],&w[i]);
    }
 
    REP(i,n){
        ll a;
        if(w[i] == 1)
            a = 1;
        else
            a = -1;
        afx[i] = (x[i] + t * a) % l;
        if(afx[i] < 0)
            afx[i] += l;
    }
    
    FOR(i,1,n){
        if(w[0] == w[i]){
            change[i] = 0;
        }else{
            ll d = t * 2;
            
            ll b,c;
            
            if(w[0] == 1){
                b = x[0];c = x[i];
            }else{
                b = x[i];c = x[0];
            }
            change[i] = 0;
            if(c >= b){
                 d -= c - b;
            }else{
                d -= l - b +c;
            }
            if(d >= 0)
            change[i]++;
            else
                d = 0;
            change[i] += d / l;
        }
    }
    
    ll sum = 0;
    
    FOR(i,1,n){
        sum += change[i];
    }
    sum %= n;
    if(w[0] == 2)
        sum = (n - sum) % n;
        
    ll rem = afx[0];
    
    sort(afx,afx + n);
    
    ll start;
    afx[n] = -1000;
    REP(i,n){
        if(afx[i] == rem && afx[(i + 1) % n] != rem){
            start = i;
            break;
        }
        else if(afx[i] == rem && afx[(i + 1) % n] == rem){
            if(w[0] == 1)
                start = i  + 1;
            else
                start = i;
            break;
        }
    }
    
    start = (n + start - sum) % n;
    
    REP(i,n){
        printf("%lld\n",afx[start++]);
        if(start == n)
            start = 0;
    }
    
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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







int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    int ans = C - (A - B);
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ld ans = 0;
    cin >> N;
    rep(i, N) {
        ld x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000.0L;
    }
    cout << fixed << setprecision(-5) << ans << endl;
    return 0;
}


Measured memory_bytes: 3752
import Data.List

enc1 :: Char -> [Int]
enc1 c =
  case c of
    ' '  -> [1,0,1]
    '\'' -> [0,0,0,0,0,0]
    ','  -> [0,0,0,0,1,1]
    '-'  -> [1,0,0,1,0,0,0,1]
    '.'  -> [0,1,0,0,0,1]
    '?'  -> [0,0,0,0,0,1]
    'A'  -> [1,0,0,1,0,1]
    'B'  -> [1,0,0,1,1,0,1,0]
    'C'  -> [0,1,0,1]
    'D'  -> [0,0,0,1]
    'E'  -> [1,1,0]
    'F'  -> [0,1,0,0,1]
    'G'  -> [1,0,0,1,1,0,1,1]
    'H'  -> [0,1,0,0,0,0]
    'I'  -> [0,1,1,1]
    'J'  -> [1,0,0,1,1,0,0,0]
    'K'  -> [0,1,1,0]
    'L'  -> [0,0,1,0,0]
    'M'  -> [1,0,0,1,1,0,0,1]
    'N'  -> [1,0,0,1,1,1,1,0]
    'O'  -> [0,0,1,0,1]
    'P'  -> [1,1,1]
    'Q'  -> [1,0,0,1,1,1,1,1]
    'R'  -> [1,0,0,0]
    'S'  -> [0,0,1,1,0]
    'T'  -> [0,0,1,1,1]
    'U'  -> [1,0,0,1,1,1,0,0]
    'V'  -> [1,0,0,1,1,1,0,1]
    'W'  -> [0,0,0,0,1,0]
    'X'  -> [1,0,0,1,0,0,1,0]
    'Y'  -> [1,0,0,1,0,0,1,1]
    'Z'  -> [1,0,0,1,0,0,0,0]

enc1' [] = []
enc1' (s:sx) = (enc1 s) ++ (enc1' sx)

enc2 :: [Int] -> Char
enc2 c =
  case c of
    [0,0,0,0,0] -> 'A'
    [0,0,0,0,1] -> 'B'
    [0,0,0,1,0] -> 'C'
    [0,0,0,1,1] -> 'D'
    [0,0,1,0,0] -> 'E'
    [0,0,1,0,1] -> 'F'
    [0,0,1,1,0] -> 'G'
    [0,0,1,1,1] -> 'H'
    [0,1,0,0,0] -> 'I'
    [0,1,0,0,1] -> 'J'
    [0,1,0,1,0] -> 'K'
    [0,1,0,1,1] -> 'L'
    [0,1,1,0,0] -> 'M'
    [0,1,1,0,1] -> 'N'
    [0,1,1,1,0] -> 'O'
    [0,1,1,1,1] -> 'P'
    [1,0,0,0,0] -> 'Q'
    [1,0,0,0,1] -> 'R'
    [1,0,0,1,0] -> 'S'
    [1,0,0,1,1] -> 'T'
    [1,0,1,0,0] -> 'U'
    [1,0,1,0,1] -> 'V'
    [1,0,1,1,0] -> 'W'
    [1,0,1,1,1] -> 'X'
    [1,1,0,0,0] -> 'Y'
    [1,1,0,0,1] -> 'Z'
    [1,1,0,1,0] -> ' '
    [1,1,0,1,1] -> '.'
    [1,1,1,0,0] -> ','
    [1,1,1,0,1] -> '-'
    [1,1,1,1,0] -> '\''
    [1,1,1,1,1] -> '?'

enc2' :: [Int] -> String
enc2' [] = []
enc2' s =
  let d = take 5 s
      r = drop 5 s
  in
    (enc2 d):(enc2' r)

--enc :: String -> String
enc x =
  let e1 = enc1' x
      ln = (length e1) `mod` 5
      e' = if ln /= 0
           then e1 ++ (replicate (5-ln) 0)
           else e1
      e2 = enc2' e'
  in
    e2

main = do
  c <- getContents
  let i = lines c
      o = map (enc) i
  mapM_ putStrLn o

Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << "\n";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static final int OP = 105;
	static int[][][] field;
	static int[][] right_ref ={{},
		{0,0,3,5,2,4,0},
		{0,4,0,1,6,0,3},
		{0,2,6,0,0,1,5},
		{0,5,1,0,0,6,2},
		{0,3,0,6,1,0,4},
		{0,0,4,2,5,3,0}};

	static int Setting(int x, int y){
		for(int i=0;;i++){
			if(field[i][x][y]==0){
				return i;
			}
		}
	}

	static void Taosu(int floor, int top, int front, int right){
		int x=OP, y=OP;
		while(true){
			int un_floor = floor-1;
			int flag = 0;
			int max = 0;
			if(un_floor==-1){
				return;
			}
			if(field[un_floor][x-1][y]==0&&front>=4){
				flag = 1;
				max=front;
			}
			if(field[un_floor][x+1][y]==0&&front<=3){
				if(max<7-front){
					flag = 2;
					max=7-front;
				}
			}
			if(field[un_floor][x][y-1]==0&&right<=3){
				if(max<7-right){
					flag = 3;
					max = 7-right;
				}
			}
			if(field[un_floor][x][y+1]==0&&right>=4){
				if(max<right){
					flag = 4;
				}
			}
			if(flag==0){
				return;
			}
			else{
				int put = 0;
				if(flag==1){
					put = Setting(x-1,y);
					field[put][x-1][y] = 7-front;
					field[floor][x][y] = 0;
					int tmp = front;
					front = top;
					top = 7-tmp;
					x--;
				}
				else if(flag==2){
					put = Setting(x+1,y);
					field[put][x+1][y] = front;
					field[floor][x][y] = 0;
					int tmp = front;
					front = 7-top;
					top = tmp;
					x++;
				}
				else if(flag==3){
					put = Setting(x,y-1);
					field[put][x][y-1] = right;
					field[floor][x][y] = 0;
					int tmp = top;
					top = right;
					right = 7-tmp;
					y--;
				}
				else if(flag==4){
					put = Setting(x,y+1);
					field[put][x][y+1] = 7-right;
					field[floor][x][y] = 0;
					int tmp = top;
					top = 7-right;
					right = tmp;
					y++;
				}
				floor = put;
			}
		}	
	}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[] fall_top = new int[n];
			int[] fall_front = new int[n];
			field = new int[110][210][210];
			for(int i=0;i<n;i++){
				fall_top[i] = stdIn.nextInt();
				fall_front[i] = stdIn.nextInt();
			}

			for(int i=0;i<n;i++){
				int tmp = Setting(OP,OP);
				field[tmp][OP][OP] = fall_top[i];
				Taosu(tmp,fall_top[i],fall_front[i],right_ref[fall_top[i]][fall_front[i]]);
			}

			int[] output = new int[7];
			Arrays.fill(output, 0);
			for(int j=0;j<210;j++){
				for(int k=0;k<210;k++){
					for(int i=0;i<109;i++){
						if(field[i+1][j][k]==0&&field[i][j][k]!=0){
							output[field[i][j][k]]++;
						}
						else if(field[i][j][k]==0){
							break;
						}
					}
				}
			}
			for(int i=1;i<6;i++){
				System.out.print(output[i]+" ");
			}
			System.out.println(output[6]);
		}
	}
}

Measured memory_bytes: 83000
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		
		char[] s=S.toCharArray();
		char[] t=T.toCharArray();
		
		for(int i=0;i<N;i++) {
			System.out.print(s[i]);
			System.out.print(t[i]);
		}
		
		
	}
}


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

int pcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if (x == 0) return 0;
    return f(x % pcnt(x)) + 1;
}

int main() {
    int N;
    cin >> N;
    string X;
    cin >> X;

    int pc = 0;
    vi A(N);
    rep(i, N) {
        A[i] = X[i] - '0';
        if (A[i] == 1) pc++;
    }

    vi ans(N);
    rep(bit, 2) {
        int npc = pc;
        if (bit == 0) {
            npc++;
        } else {
            npc--;
        }
        if (npc <= 0) continue;

        int x = 0;
        int k = 1;
        for (int i = N - 1; i >= 0; i--) {
            x = (x + (A[i] * k)) % npc;
            k = (k * 2) % npc;
        }

        k = 1;
        for (int i = N - 1; i >= 0; i--) {
            if (bit == A[i]) {
                int y = x;

                if (bit == 0) {
                    y = (y + k) % npc;
                } else {
                    y = (y - k + npc) % npc;
                }

                ans[i] = f(y) + 1;

            }

            k = (k * 2) % npc;
        }
    }

    rep(i, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll a[n];
    rep(i,n)cin >> a[i];

    rep(i,n){
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;

    ll INF = 3001001001001001001;

    rep(i,n){
        if(INF/ans < a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    if(ans > 1000000000000000000){
        ans = -1;
    }
    
    cout << ans << endl;
    return 0;
}




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

int main() {
  int n; cin >> n;
  vector<int> vec(n*2);
  for (int i = 0; i < n*2; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int ans = 0;
  for (int i = 0; i < n*2; i+=2) {
    ans += min(vec.at(i), vec.at(i+1));
  }
  cout << ans << endl;
}



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

int main()
{
	int i, j, len;
	string s;
	cin >> s;
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'A') break;
	}
	for (j = s.size() - 1; j > i; j--) {
		if (s[j] == 'Z') break;
	}
	cout << j - i + 1 << endl;
	return 0;
}

Measured memory_bytes: 764
import java.util.Arrays;
import java.util.BitSet;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import java.util.Scanner;

class Main{
	private static final int n=1000001;
	static Scanner s=new Scanner(System.in);
	static int gInt() {return Integer.parseInt(s.next());}
	static long gLong() {return Long.parseLong(s.next());}

	public static void main(String[]$){
		BitSet p=new PrimeIterator(n).bs;

		int[]a=new int[n];
		for(int i=1;i<n;i+=2)
			if(p.get(i)&&p.get((i+1)/2))
				a[i]=1;
		Arrays.parallelPrefix(a,Integer::sum);
		for(int q=gInt();q>0;--q)
			System.out.println(-a[gInt()-1]+a[gInt()]);
	}
	public static class PrimeIterator implements Iterable<Integer>,PrimitiveIterator.OfInt{
		private BitSet	bs;
		private int		curv,limit;

		public PrimeIterator(int limit){
			curv=0;
			bs=new BitSet(limit+1);
			this.limit=limit;
			constructBS();
		}
		private final void constructBS(){
			bs.set(0,limit+1);
			bs.clear(0);
			bs.clear(1);
			if(limit<2) return;

			int i=1;
			while(sieve(i=bs.nextSetBit(i+1)))
				;
		}
		protected boolean sieve(int v){
			if((long)v*v>limit)
				return false;
			for(int i=v*v;i<=limit;i+=v)
				bs.clear(i);
			return true;
		}
		@Override
		public boolean hasNext(){
			int r=getNextValue();
			return 0<=r&&r<=limit;
		}
		private int getNextValue(){
			return bs.nextSetBit(curv+1);
		}
		@Override
		public int nextInt(){
			int r=getNextValue();
			if(r<0||limit<r) throw new NoSuchElementException();
			return curv=r;
		}
		@Override
		public OfInt iterator(){
			return this;
		}
		public BitSet getClonedBitSet(){
			return bs.get(0,limit+1);
		}
	}
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> flag(n, 0);
    REP(i, 0, k){
        int d; cin >> d;
        REP(i, 0, d){
            int a; cin >> a;
            a--;
            flag[a]++;
        }
    }
    int ans = 0;
    REP(i, 0, n){
        if(flag[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <array>

int main(void){
	std::array <int, 4> ansA;
	std::array <int, 4> ansB;

	while(std::cin >> ansA[0] >> ansA[1] >> ansA[2] >> ansA[3] >> ansB[0] >> ansB[1] >> ansB[2] >> ansB[3]){
		int hit = 0; //count hit
		int blow = 0; //count blow

		for(size_t i = 0; i < ansA.size(); ++i){ //judgment hit and blow
			for(size_t j = 0; j < ansB.size(); ++j){
				if(ansA[i] == ansB[j] && i == j){
					++hit;
				}else if(ansA[i] == ansB[j] && i != j){
					++blow;
				}
			}
		}

		std::cout << hit << " " << blow << std::endl; //output result
	}

	return 0;
}

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

const int P = 1000000007, inv2 = (P + 1) / 2;

int N, Q, A[3005], p1[3005][3005], p2[3005][3005];

int main() {
	scanf("%d%d", &N, &Q);
	for (int i = 1; i <= N; ++i) {
		scanf("%d", A + i);
		for (int j = 1; j < i; ++j) {
			p1[j][i] = A[j] < A[i];
			p2[j][i] = A[j] > A[i];
		}
	}
	int all = 1;
	for (int x, y; Q--;) {
		scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		for (int i = 1; i < x; ++i) {
			p1[i][y] = p1[i][x] = 1ll * inv2 * (p1[i][x] + p1[i][y]) % P;
			p2[i][y] = p2[i][x] = 1ll * inv2 * (p2[i][x] + p2[i][y]) % P;
		}
		for (int i = x + 1; i < y; ++i) {
			int tmp1 = p1[x][i], tmp2 = p1[i][y];
			p1[i][y] = 1ll * inv2 * (p1[i][y] + p2[x][i]) % P;
			p1[x][i] = 1ll * inv2 * (p1[x][i] + p2[i][y]) % P;
			p2[i][y] = 1ll * inv2 * (p2[i][y] + tmp1) % P;
			p2[x][i] = 1ll * inv2 * (p2[x][i] + tmp2) % P;
		}
		for (int i = y + 1; i <= N; ++i) {
			p1[x][i] = p1[y][i] = 1ll * inv2 * (p1[x][i] + p1[y][i]) % P;
			p2[x][i] = p2[y][i] = 1ll * inv2 * (p2[x][i] + p2[y][i]) % P;
		}
		p1[x][y] = p2[x][y] = 1ll * inv2 * (p1[x][y] + p2[x][y]) % P;
		all = 2 * all % P;
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i)
		for (int j = i + 1; j <= N; ++j)
			ans = (ans + p2[i][j]) % P;
	ans = 1ll * ans * all % P;
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    // sieve of eratosthenes
    vector<int> pnums(2000000,0);
    for(int i=2;i<2000000;i++) pnums[i]=1;
    for(int i=2;i*i<2000000;i++){
        if(pnums[i]){
            for(int j=i*i;j<2000000;j+=i){
                pnums[j]=0;
            }
        }
    }
    int a,d,n;
    while(cin>>a>>d>>n,a||d||n){
        int cnt=0,res=a;
        while(true){
            if(pnums[res]) cnt++;
            if(cnt==n){
                break;
            }
            res+=d;
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 10520
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, k] <- getIntList
  ps <- getIntList

  let ps' = sort ps
      ans = sum $ take k ps'

  print ans


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

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

const int MX = 2e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define re(x) cin >> x
#define ps(x) cout << x << "\n";
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {	
		ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); 
		// throws exception when do smth illegal
		// ex. try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

ll N;
map<ll, ll> cnt;

int main() {
	cin >> N;

	while (N % 2 == 0) {
		cnt[2]++;
		N /= 2;
	}

	for (int i = 3; i <= sqrt(N); i += 2) {
		while (N % i == 0) {
			cnt[i]++;
			N /= i;
		}
	}
	if (N > 2) cnt[N]++;

	int ans = 0;
	FOR(i, 1, 45) {
		for (auto &x: cnt) {
			if (x.s >= i) {
				//cout << x.f << " " << x.s << " " << i << "\n" ; 
				ans++;
				x.s -= i;
			}
		}
	}
	ps(ans);
}	







Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
string a;
int ans,hj;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out,"w",stdout);
	cin>>a;
    for(int i=0;i<a.size();i++)
    {
    	if(a[i]=='C')
    	{
    		for(int j=i+1;j<a.size();j++)
    		if(a[j]=='F')
    		{
    			cout<<"Yes"<<endl;
    			return 0;
			}
		}
    }
    
    cout<<"No"<<endl;
    
	return 0;
}


Measured memory_bytes: 256