akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double n, odd;
	cin >> n;
	if ((int)n % 2 == 1)
		odd = (n + 1) / 2;
	else
		odd = n / 2;
	cout << fixed << setprecision(10) << odd / n;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    for(int i=0;i<b;i++){
      printf("%d",a);
    }
  }
  else{
    for(int i=0;i<a;i++){
      printf("%d",b);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int S;
    string S_tmp;
    for (int i=0;i<10;i++){
        char tmp;cin >> tmp;
        if (tmp!='/'){
            S_tmp += tmp;
        }
    }
    S = atoi(S_tmp.c_str());
    if (S <= 20190430){
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector> 
#include<string>
#include<math.h>
#include<algorithm>
#include<iomanip>


using namespace std;

int main(){
    long double x;
	int a,b;
    cin>>a>>b;
    vector<long double> vv(a);
    for(int i=0;i<a;i++){
        cin>>x;
        vv[i]=(x+1)/2.0;
    }
    long double temp=0,ans=0;
    for(int i=0;i<b;i++){temp+=vv[i];} 
    ans=temp;
    for(int i=0;i<a-b;i++){
        
        temp-=vv[i];
        temp+=vv[i+b];
        ans=max(temp,ans);

    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
  
}

Measured memory_bytes: 3328
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, W = map(int, input().split())
    dp = [-INF] * (W + 1)
    dp[0] = 0
    for _ in range(n):
        w, v = map(int, input().split())
        for w0 in range(W, -1, -1):
            if dp[w0] == INF:
                continue
            if w + w0 <= W:
                dp[w + w0] = max(dp[w + w0], dp[w0] + v)
    print(max(dp))
resolve()

Measured memory_bytes: 40208
n,q = map(int,raw_input().split(' '))
s = raw_input()
dp = [0] * len(s)
cumul = 0
for j in range(len(s)):
	if s[j - 1:j + 1] == 'AC': cumul +=1
	dp[j] = cumul 
"""
ac ac
 ^
    ^    
"""
for _ in range(q):
	u,v = map(int, raw_input().split(' '))
	u -=1
	v -=1
	print dp[v] - dp[u]


Measured memory_bytes: 80052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll H, N;
vi A, B;

int main()
{
    cin >> H >> N;
    A = vi(N);
    B = vi(N);
    REP(i, N)
    {
        cin >> A[i] >> B[i];
    }

    vi dp = vi(H + 1, INF);
    dp[0] = 0;
    REP(i, N)
    {
        for (ll j = A[i]; j <= H; ++j)
        {
            dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
        }
        for (ll j = max(0LL, H - A[i]); j < H; ++j)
        {
            dp[H] = min(dp[H], dp[j] + B[i]);
        }
    }
    ll ans = dp[H];

    OUT(ans);
}

Measured memory_bytes: 384
def main():
    n, l = (int(s) for s in input().strip().split(' '))
    an = [int (s) for s in input().strip().split(' ')]
    for i in range(1, n):
        if an[i-1] + an[i] >= l:
            print('Possible')
            index = i
            break
    else:
        print('Impossible')
        return
    for i in range(1, index):
        print(i)
    for i in range(n-1, index, -1):
        print(i)
    print(index)
 
main()

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

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

    string S;
    cin >> S;

    if( N %2 == 1){
        cout << "No" << endl;
    }else{
        string T1 = S.substr(0, N / 2);
        string T2 = S.substr(N / 2, N / 2);
        if(T1 == T2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
std::map<int,int> m;
int ma(){
    return m.rbegin()->fi;
}
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    
    rep(i,n){
        m[a[i]]++;
    }
    std::vector<int> po;
    rep(i,30)po.pb(pow(2,i+1));
   // std::cout << po[0] << std::endl;
    int ans=0;
    while (!m.empty()){
        //std::cout <<m.size() << std::endl;
        if(m[ma()]<=0)m.erase(ma());
        //std::cout << m.size() << std::endl;
        if(m.empty())break;
        int d=*ub(all(po),ma())-ma();
     //   std::cout << *ub(all(po),ma())<< " "<<ma() << std::endl;
        if(d==ma()){
        //    std::cout << d << std::endl;
            if(m[ma()]>=2){
                ans++;
                m[ma()]-=2;
            }
            else{
                m[ma()]--;
            }
        }
        else{
            if(m[d]>=1&&m[ma()]>=1){
                ans++;
                m[d]--;
                m[ma()]--;
                if(m[d]==0)m.erase(d);
                if(m[ma()]==0)m.erase(ma());
            }
            else m[ma()]--;
        }
        
        
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
	ll n;
	cin >> n;
	auto d = divisor(n);
	ll ans = 1LL<<60;
	rep(i, d.size()) {
		ll a = d[i]-1;
		ll b = d[d.size()-1-i]-1;
		ans = min(ans, a+b);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

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);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long k = in.nextLong();
			long[] array = new long[100010];
			for (int i = 0; i < n; i++) {
				int a = in.nextInt();
				long b = in.nextLong();
				array[a] += b;
			}

			while (k > 0) {
				for (int i = 1; i < array.length; i++) {
					k -= array[i];
					if (k <= 0) {
						out.print(i);
						return;
					}
				}
			}

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 45212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n, m, x; cin >> n >> m >> x;
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    for(ll i=0; i<n; ++i){
        cin >> c[i];
        for(ll j=0; j<m; ++j){cin >> a[i][j];}
    }
    ll res = 10000000;
    for(ll is=0; is<(1<<n); ++is){
        ll cost = 0;
        vector<ll> us(m, 0);
        for(ll i=0; i<n; ++i){
            if(is&(1<<i)){
                cost += c[i];
                for(ll j=0; j<m; ++j){us[j] += a[i][j];}
            }
        }

        for(ll j=0; j<m; ++j){
            if(us[j]<x){break;}
            if(j==m-1){res = min(res, cost);}
        }
    }
    if(res==10000000){cout << -1 << endl;}
    else{cout << res << endl;}
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#pragma warning(disable:4996)
int main(void) {
	int i, j;
	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 1776
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  int H, W, h, w; cin >> H >> W >> h >> w;

  print(H * W - h * W - H * w + h * w);


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#include<set>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
#define INF 1000000000000000LL

struct UnionFind{
    // d<0のときそのインデックスは親でその木のサイズd[i]*-1
    // d>0のときそのインデックスの親はd[i]
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if(x== y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){ return find(x) == find(y);}
    int size(int x){ return -d[find(x)];}
};

int main(){
    int n,m; cin>>n>>m;
    int a[m],b[m];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind t(n);
    rep(i,m){
        t.unite(a[i],b[i]);
    }
    set<int> s;
    rep(i,n){
        s.insert(t.find(i));
        //cout << "i="<<i << " p="<<t.find(i) << endl;
    }
    for(auto itr=s.begin(); itr!=s.end(); itr++){
        //cout << "parent "<<*itr << endl;
    }
    cout << s.size()-1 << endl;
}


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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define V vector<int>

using namespace std;
using ll = long long;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    V A(N);
    REP(i, M) IN(A[i]);
    int mr = 0, ml = 0;
    REP(i, M) {
        if(A[i] < X) {
            ml++;
        }
        else {
            mr++;
        }
    }
    OUT(min(ml, mr));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
	int N,h,i,l;
	string s,t;
	while (true) {
		cin >> s;
		if (s == "-")break;
		l = s.length();
		cin >> N;
		for (i = 0; i < N; i++) {
			cin >> h;
			t = s + s;
			s = t.substr(h, l);
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3184
// Last Change: 04/06/2019 21:29:53.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<ll> trans(5);
  ll N;
  cin >> N;
  for (int i = 0; i < 5; ++i) {
    cin >> trans[i];
  }

  sort(trans.begin(), trans.end());

  ll rissoku = trans[0];
  ll kaisu = N / rissoku + ((N % rissoku > 0) ? 1 : 0);
  ll ans = 5 + kaisu - 1;
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;

ll getVals(ll i, ll n) {
	string ii = to_string(i), nn = to_string(n);
	ll c = 0, j, k, d = 1, t, p;
	char f = ii[0], l = ii[ii.size() - 1];
	if (f == l)
		c++;
	
	for (j = 2; j <= (ll)nn.size(); j++) {
		if (j == (ll)nn.size()) {
			if (l < nn[0])
				c += d;
			else if (l == nn[0]) {
				if (nn.size() > 2) {
					t = 1;
					p = 0;
					for (k = nn.size() - 2; k >= 1; k--) {
						p += ((nn[k] - '0') * t);
						t *= 10;
					}
					if (f <= nn[nn.size() - 1])
						p++;
					c += p;
				} else if (f <= nn[nn.size() - 1])
					c++;
			}	
		} else
			c += d;
		d *= 10;
	}
	return c;
}

int main() {FIN
	
	ll n, c = 0, i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		if (i % 10 > 0) {
			c += getVals(i, n);
		}
	}
	cout << c << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    map<pair<ll, ll>, ll> mp;
    rep(i, N) {
        ll a;
        cin >> a;
        a--;
        mp[make_pair(min((ll)i, a), max((ll)i,a))]++;
    }
    ll cnt = 0;
    for(pair<pair<ll, ll>, ll> p : mp) {
        if (p.second > 1) {
            cnt++;
        }
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 6528
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int a, b;
int main() {
	cin >> a >> b;
	cout << (a - 1)*(b - 1) << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  double W,H;
  cin >> W >> H;
  int x,y;
  cin >> x >> y;
  double S;
  S = W*H;
  cout << S/2 << " ";
  if(x == W/2 && y == H/2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  string s; cin >> s;
  char now = s.at(0);
  int count = 1;
  for(int i=1;i<s.size();i++){
    if(s.at(i)!=now){
      count++;
      now = s.at(i);
    }
  }
  cout << count-1 << endl;
}


Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin>> A[i];
    ll k = 1;
    ll res = 0;
    REP(i, N){
        if(A[i]==k){
            k++;
        }
        else{
            res++;
        }
    }
    if(k==1) res = -1;
    cout << res << endl;
    return 0;
}

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

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

  int ans = 0;
  rep(i, n)
  {
    double x, y, dt;
    cin >> x >> y;
    dt = sqrt(x * x + y * y);
    if (dt <= d)
    {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3812
//https://blog.csdn.net/hesorchen
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define lowbit(a) (a & (-a))
#define INF 0x3f3f3f3f
#define MAX 1010
#define mod 1000000007
#define PI 3.1415926

struct node
{
    int a, b;
} p[500000];
int ct;
int ans;
int n, m;
int pre[500000];
int find(int x)
{
    if (pre[x] != x)
        return pre[x] = find(pre[x]);
    return x;
}
void intt()
{
    for (int i = 1; i <= n; i++)
        pre[i] = i;
}
int check(int x)
{
    int res = 0;
    for (int i = 1; i <= m; i++)
    {
        if (i == x)
            continue;
        if (find(p[i].a) != find(p[i].b))
        {
            pre[find(p[i].a)] = find(p[i].b);
            res++;
        }
        if (res == n - 1)
            break;
    }
    // cout << res << endl;
    if (res == n - 1)
        return 0;
    return 1;
}
int main()
{

    cin >> n >> m;
    // while (m--)
    for (int i = 1; i <= m; i++)
        cin >> p[i].a >> p[i].b;
    for (int i = 1; i <= m; i++)
    {
        intt();
        if (check(i))
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define MAX_V 5010
typedef vector<int> Vec;

int N, M;
Vec G[MAX_V];

bool visit(int v, Vec &order, Vec &color)
{
    color[v] = 1;
    for (int i = 0; i < (int)G[v].size(); i++) {
        int to = G[v][i];
        if (color[to] == 2) continue;
        if (color[to] == 1) return false;
        if (!visit(to, order, color)) return false;
    }
    order.push_back(v);
    color[v] = 2;
    return true;
}

bool topologicalSort(Vec &order)
{
    Vec color(N, 0);
    for (int i = 0; i < N; i++) {
        if (color[i] == 0 && !visit(i, order, color)) {
            return false;
        }
    }
    reverse(order.begin(), order.end());
    return true;
}

int main()
{
    int s, t;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> s >> t; s--; t--;
        G[s].push_back(t);
    }
    Vec order;
    if (topologicalSort(order)) {
        bool is_hamiltonian_path = 1;
        for (int i = 0; i < N-1; i++) {
            if (G[order[i]].size() == 0) {
                is_hamiltonian_path = 0;
            }
        }
        for (int i = 0; i < N; i++) {
            cout << order[i]+1 << endl;
        }
        cout << !is_hamiltonian_path << endl;
    }
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

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

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

int N, H;
vector<vi> w;
int ans = 0;

int main() {
  cin >> N >> H;
  rep(i,N) {
    int a, b;
    cin >> a >> b;
    w.push_back(vi({a, 0, i}));
    w.push_back(vi({b, 1, i}));
  }
  sort(w.rbegin(), w.rend());
  int h = H;
  set<int> used;
  rep(i,2*N) {
    if (w[i][1] == 0) {
      ans += ceil(1. * h / w[i][0]);
      cout << ans << endl;
      return 0;
    } else {
      h -= w[i][0];
      ans++;
      if (h <= 0) {
        cout << ans << endl;
        return 0;
      }
      used.insert(w[i][2]);
      if (used.size() == N) {
        rep(j,2*N) {
          if (w[j][1] == 0) {
            ans += ceil(1. * h / w[j][0]);
            cout << ans << endl;
            return 0;
          }
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17196
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll MOD=998244353;
const int MAX=200010;

struct UnionFind {
    vector< int > data;

    UnionFind() = default;

    explicit UnionFind(size_t sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return data[k] = find(data[k]);
    }

    int size(int k) {
        return -data[find(k)];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;cin>>n>>q;
    UnionFind uf(n);
    rep(tmp,q){
        ll i,u,v;cin>>i>>u>>v;
        if(i){
            ll ans=uf.same(u,v);
            cout<<ans<<endl;
        }else{
            uf.unite(u,v);
        }
    }
}

Measured memory_bytes: 3972
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		String result = "APPROVED";
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++) {
			int a = in.nextInt();
			if(a%2==0) {
				if(a%3==0 || a%5==0) {
					continue;
				}else {
					result = "DENIED";
					break;
				}
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
cnt = 0

for i in range(n):
  ans = 0
  for j in range(m):
    ans += a[i][j]*b[j]
  ans += c
  if ans > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  int n; cin >>n;
  int flag=0;
  rep(i,n){
    int a; cin >>a;
    if(a%2==0 and a%3 and a%5) flag=1;
  }
  printf("%s",(flag)?"DENIED":"APPROVED"); 

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    string s;
  	cin>>s;
  	if(s[2]==s[3]&&s[5]==s[4])
      cout<<"Yes\n";
  	else
    	cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
import sys
for number in sys.stdin.readlines():
   	ans = []
	n = int(number)
	for b in [512,256,128,64,32,16,8,4,2,1]:
		if n >= b:
			n -= b
			ans.append(b)
	ans.reverse()
	ans = map(str,ans)
	ans = ' '.join(ans)
	print ans

Measured memory_bytes: 4224
#include<cstdio>
#include<cmath>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int cmp(int a,int b){
   return a>b;
 }
int main(){
  int a[3];
  for(int i=0;i<3;i++){
        cin>>a[i];
  }
  sort(a,a+3,cmp);
  printf("%d",a[0]*10+a[1]+a[2]);
}


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

const int maxn=100010;
int n,m;
int a[maxn];
int maxx,last,num;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	last=a[1];
	maxx=0;
	num=0;
	for (int i=2;i<=n;i++)
	{
		int qaq=a[i]-last;
		if (qaq==maxx)
			num++;
		if (qaq>maxx)
		{
			maxx=qaq;
			num=1;
		}
		if (a[i]<last)	last=a[i];
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 640
K = int(input())
l_lun = [i for i in range(1, 10)]
nowp = 0
while(nowp < K):
  newp = len(l_lun)
  for i in range(nowp, newp):
    left = l_lun[i] % 10
    for j in range(left - 1, left + 2):
      if j < 0 or j >= 10:
        continue
      l_lun.append(l_lun[i] * 10 + j)
  nowp = newp
print(l_lun[K-1])

Measured memory_bytes: 30104
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
void chmax(ll a, ll b) {if(a<b) a=b;}
void chmin(ll a, ll b) {if(a>b) a=b;}
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

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

int main(void) {
    ll N;
    cin >> N;
    
    for(ll _=0; _<N; _++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        
        if(a<b || d<b) {
            pt("No");
        }else if(b-1<=c) {
            pt("Yes");
        }else {
            ll g=gcd(b, d);
            
            ll t=0;
            if(c>a) t=(c-a)/g+1;
            else t=-(a-c-1)/g;
            
            if(a+t*g<b) {
                pt("No");
            }else {
                pt("Yes");
            }
        }
        
    }
    
    
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool t[10];

bool dfs(int n)
{
	while(n>0)
	{
		if(t[n%10])
			return false;
		n/=10;
	}
	return true;
}
int main()
{
	int n,k,a;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>a;
		t[a]=true;
	}
	while(!dfs(n))
		n++;
	cout<<n;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;

    int x3, y3, x4, y4;

    x3 = x2 - y;
    y3 = y2 + x;
    x4 = x3 - x;
    y4 = y3 - y;

    cout << x3 << " ";
    cout << y3 << " ";
    cout << x4 << " ";
    cout << y4 << endl;

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define MAX 200000

int N;
vector<int> G[MAX];
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;
vector<P> bridge;

void dfs(int v,int prev){
	prenum[v]=lowest[v]=timer;
	timer++;
	visited[v]=true;

	int next;
	for(int i=0;i<G[v].size();i++){
		next=G[v][i];
		if(!visited[next]){
			parent[next]=v;
			dfs(next,v);
			lowest[v]=min(lowest[v],lowest[next]);
			if(prenum[v]<lowest[G[v][i]])bridge.push_back(P(min(v,G[v][i]),max(v,G[v][i])));
		}else if(next!=prev){
			lowest[v]=min(lowest[v],prenum[next]);
		}
	}
}


set<int> art_points(){
	for(int i=0;i<N;i++){
		visited[i]=false;
	}
	timer=1;
	dfs(0,-1);

	set<int> ap;
	int np=0;
	for(int i=1;i<N;i++){
		int p=parent[i];
		if(p==0)np++;
		else if(prenum[p]<lowest[i])ap.insert(p);
	}
	if(np>1)ap.insert(0);
	return ap;
}

int w[MAX];
vector<P> edge;
vector<P> n_bridge;
vector<int> ok_G[MAX];
int cnt;
bool used[100001];
int sum[100001];
int num[100001];
int siz[100001];
vector<int> graph[MAX];

void c_dfs(int v){
	used[v]=true;
	num[v]=cnt;
	siz[cnt]++;
	sum[cnt]+=w[v];
	for(int i=0;i<ok_G[v].size();i++){
		if(num[ok_G[v][i]]==-1){
			c_dfs(ok_G[v][i]);
		}
	}
}

int dp[100001];
int dp2[100001];

int solve2(int v,int p){
	if(dp2[v]!=-1)return dp2[v];
	int res=sum[v];
	int back=-1;
	for(int i=0;i<graph[v].size();i++){
		if(p!=graph[v][i]){
			int va=solve2(graph[v][i],v);
			if(va!=0){
				res+=va;
				back=0;
			}
		}
	}
	if(siz[v]>=3)back=0;
	dp2[v]=(back==0)?res:0;
	return dp2[v];
}

int solve(int v,int p){
	if(dp[v]!=-1)return dp[v];
	int res=0;
	for(int i=0;i<graph[v].size();i++){
		if(p!=graph[v][i]){
			int va=solve2(graph[v][i],v);
			if(va!=0)res+=va;
		}
	}
	int diff=0;
	for(int i=0;i<graph[v].size();i++){
		if(p!=graph[v][i]){
			int va=solve(graph[v][i],v);
			if(va-max(dp2[graph[v][i]],0)>diff){
				diff=va-max(0,dp2[graph[v][i]]);
			}
		}
	}
	res+=diff;
	return (dp[v]=(res+sum[v]));
}

int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&w[i]);
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
		edge.push_back(P(a,b));
	}
	N=n;
	art_points();
	sort(bridge.begin(),bridge.end());
	for(int i=0;i<m;i++){
		int v=lower_bound(bridge.begin(),bridge.end(),edge[i])-bridge.begin();
		if(!(v<bridge.size() && bridge[v]==edge[i])){
			ok_G[edge[i].first].push_back(edge[i].second);
			ok_G[edge[i].second].push_back(edge[i].first);
		}
	}
	memset(num,-1,sizeof(num));
	for(int i=0;i<n;i++){
		if(num[i]==-1){
			c_dfs(i);
			cnt++;
		}
	}
	for(int i=0;i<bridge.size();i++){
		P p=bridge[i];
		graph[num[p.first]].push_back(num[p.second]);
		graph[num[p.second]].push_back(num[p.first]);
	}
	memset(dp,-1,sizeof(dp));
	memset(dp2,-1,sizeof(dp2));
	printf("%d\n",solve(num[0],-1));
	return 0;
}

Measured memory_bytes: 39448
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
static inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
using ll = long long;
using ld = long double;

int main()
{
    fast_io();
    ll a, b;
    ll v, w;
    ll t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;
    if (a == b) {
        cout << "YES\n";
        return 0;
    }
    if (v <= w) {
        cout << "NO\n";
        return 0;
    }
    if (abs(v - w) >= abs(a - b) / double(t)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 3056
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a==1 && b==0 && c==0){
			System.out.println("Close");
		}else if(a==0 && b==1 && c==0){
			System.out.println("Close");
		}else if(a==1 && b==1 && c==0){
			System.out.println("Open");
		}else if(a==0 && b==0 && c==1){
			System.out.println("Open");
		}else if(a==0 && b==0 && c==0){
			System.out.println("Close");
		}
	}
}

Measured memory_bytes: 17172
#include <iostream>
#include <queue>
#include <vector>

struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, long long y) : dst(x), cost(y) {}
};

int prim(std::vector<std::vector<Edge>> &G) {
  const int V = (int)G.size();
  std::vector<bool> is_used(V, false);

  typedef std::pair<long long, int> PLI;
  std::priority_queue<PLI, std::vector<PLI>, std::greater<PLI>> que;
  que.push(std::make_pair(0LL, 0));

  int ret = 0;
  while (!que.empty()) {
    long long cost = que.top().first;
    int cur_v = que.top().second;
    que.pop();
    if (is_used[cur_v]) {
      continue;
    }
    is_used[cur_v] = true;
    ret += cost;
    for (int i = 0; i < (int)G[cur_v].size(); i++) {
      que.push(std::make_pair(G[cur_v][i].cost, G[cur_v][i].dst));
    }
  }
  return ret;
}

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

  std::vector<std::vector<Edge>> g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int a;
      std::cin >> a;
      if (a != -1) {
        g[i].push_back(Edge(j, a));
        g[j].push_back(Edge(i, a));
      }
    }
  }
  std::cout << prim(g) << std::endl;

  return 0;
}


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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n % 10;
  b = ((n - a) / 10) % 10;
  c = ((n - b * 10 - a) / 100) % 10;
  d = ((n - c * 100 - b * 10 - a) / 1000) % 10;
  
  if (((a == b) && (a == c)) || ((b == c) && (b == d))){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int counter = 0;
    string ans;
    cin >> ans;
    while(true) {
        string s;
        cin >> s;
        if(s == "END_OF_TEXT") break;
        for(int i = 0; i < s.size(); i++) {
            if('A' <= s.at(i) && s.at(i) <= 'Z') {
                s.at(i) = tolower(s.at(i));
            }
        }
        if(s == ans) counter++;
    }
    cout << counter << endl;
}


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


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

int main() {
  ll h,w,k;
  cin>>h>>w>>k;
  ll x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  x1--;x2--;y1--;y2--;
  vector<string> g(h);
  rep(i,h)cin>>g[i];

  vector<ll> dist(h*w*4,INF);
  ll start=((x1*w)+y1)*4;
  ll goal=((x2*w)+y2)*4;
//  cout<<start<<"s"<<goal<<"g"<<endl;
  priority_queue<P, vector<P>, greater<P>> q;
  rep(i,4){
    ll id=start+i;
    q.push(make_pair(0,id));
    dist[id]=0;
  }

  while(!q.empty()){
    auto Q=q.top();
    q.pop();
    ll d=Q.first;
    ll id=Q.second;
  //  cout<<id<<"id"<<d<<"d"<<dist[id]<<"dist"<<endl;
    if (dist[id]!=d)continue;
  //  dist[id]=d;
    ll vnow=id%4;
    ll jnow=(id-vnow)/4%w;
    ll inow=((id-vnow)/4-jnow)/w;
    ll D=((d+k-1)/k)*k;
    //cout<<D<<"D"<<endl;

    rep(i,4){
      ll idnow=(inow*w+jnow)*4+i;
      if (dist[idnow]>D){
        q.push(make_pair(D,idnow));
        //  cout<<D<<"D"<<idnow<<"ID"<<endl;
          dist[idnow]=D;
      }

      ll ni=inow+dx[i];
      ll nj=jnow+dy[i];
      if (i!=vnow)continue;
      if (ni<0 or ni>=h or nj<0 or nj>=w)continue;

      if (g[ni][nj]=='@')continue;
      if (dist[(ni*w+nj)*4+i]<=(d+1)) continue;
      q.push(make_pair(d+1,(ni*w+nj)*4+i));
  //    cout<<((ni*w+nj)*4+i)<<"nid"<<d+1<<"nd"<<endl;

      dist[(ni*w+nj)*4+i]=d+1;

    }

  }

ll ans=INF;
rep(i,4){
  ans=min(ans,dist[goal+i]);
}
//cout<<ans;
if (ans==INF)cout<<-1;
else{
//  cout<<ans<<endl;
  cout<<(ans+k-1)/k;
}
}


Measured memory_bytes: 44264
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t N;
	cin >> N;

	int32_t res = 0;
	for (int32_t i = 0; i < N; i++) {
		int32_t a;
		cin >> a;
		res += a - 1;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[[0,0] for _ in range(n+1)]
x=[]
for i in range(m):
    x.append(list(input().split()))
    x[i][0]=int(x[i][0])
for i in range(m):
    if x[i][1]=="AC":
        a[x[i][0]][1]=1
    else:
        if a[x[i][0]][1]==1:
            continue
        else:
            a[x[i][0]][0]+=1
c=0
d=0
for i in range(n+1):
    c+=a[i][1]
    if a[i][1]:
        d+=a[i][0]
print(c,d)

Measured memory_bytes: 35908
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vvi g;
vector<set<int>> ch;
vi a, p, pos, dep;
vi res;

void rot(int v) {
  res.push_back(v);
  int val = a[v], cur = p[v];
  while (cur >= 0) {
    swap(a[cur], val);
    pos[a[cur]] = cur;
    cur = p[cur];
  }
  a[v] = val;
  pos[a[v]] = v;
}

void rem(set<int>& v, int a) {
  v.erase(a);
}

const int DEBUG = 0;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n = 2000;
  if (!DEBUG) cin >> n;
  g.resize(n);
  ch.resize(n);
  a.resize(n);
  p.assign(n, -1);
  dep.assign(n, 0);
  pos.assign(n, 0);
  for (int i = 1; i < n; ++i) {
    if (!DEBUG) cin >> p[i];
    else p[i] = rand() % i;
    g[p[i]].push_back(i);
    dep[i] = dep[p[i]] + 1;
  }
  for (int i = 0; i < n; ++i) {
    if (!DEBUG) cin >> a[i];
    else a[i] = n-i-1;
  }
  if (DEBUG) random_shuffle(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    pos[a[i]] = i;
  }
  for (int i = n-1; i >= 0; --i) {
    if (ch[i].empty() && a[i] == i) continue;
    int cur = p[i];
    while (cur >= 0) {
      ch[cur].insert(i);
      cur = p[cur];
    }
  }
  while (!ch[0].empty()) {
    int v = a[0];
    if (ch[v].empty()) {
      rot(v);
      int cur = p[v];
      while (cur >= 0) {
        rem(ch[cur], v);
        cur = p[cur];
      }
    } else {
      int u = -1, ma = -1;
      for (int x : ch[v]) {
        if (ma < dep[pos[x]]) {
          u = pos[x];
          ma = dep[u];
        }
      }
      assert(u >= 0);
      rot(u);
    }
    assert(res.size() <= 25000);
  }
  cout << res.size() << endl;
  for (int x : res) cout << x << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

string t;

int main(){
    cin >> t;
    int L = t.size();
    int min_v = 1e9;
    for(int i=0;i<26;i++){
        string s = t;
        char c = 'a' + i;
        bool f = false;
        for(int j=0;j<L;j++) if(s[j] == c) f = true;
        if(!f) continue;
        for(int j=0;j<L;j++){
            f = true;
            for(int l=0;l<L-j;l++){
                if(s[l] != c) f = false;
            }
            for(int l=0;l<L-j-1;l++){
                if(s[l] == c || s[l+1] == c) s[l] = c;
            }
            if(f){
                min_v = min(min_v, j);
                break;
            }
        } 
    }
    cout << min_v << endl;
    return 0;
}

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

void solve()
{
    int n;cin>>n;
    
    vector<int>arr(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int ans=0;
    for(int i=1;i<=n;i+=2)
    {
        if(arr[i]%2==1)
        ans++;
    }
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
   int t=1;
   while(t--)
   solve();
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;
 
int main()
{
	long long int n, sum = 0, prosum = 0;
	cin >> n;
	long long int a[n];

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

	for (long long int i = 0; i < n; i++)
	{
		sum = sum - a[i];
		prosum+=(sum%M * a[i]%M)%M;
	}

	prosum = prosum%M;

	cout << prosum;

  	return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d){
        cout<<"Left";
    }
     else if(a+b==c+d){
         cout<<"Balanced";
    }
     else{
         cout<<"Right";
    }

    return 0;
}


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

long long gcd(long long a, long long b) {
  if(a < b) return gcd(b, a);
  long long r;
  while(r=a%b){
    a = b;
    b = r;
  }
  return b;
}

int main() {
  long long A, B;
  cin >> A >> B;
  long long gcdAB = gcd(A, B);
  vector<long long> r;
  for(long long i = 2; i <= sqrt(gcdAB); i++){
    if(gcdAB == 1) break;
    long long count = 0;
    bool canDivided = true;
    while(canDivided){
      if(gcdAB % i == 0){
        gcdAB /= i;
        count++;
      }else canDivided = false;
    }
    if(count == 0) continue;
    r.push_back(count);
    if(i % 2 != 0) i++;
  }
  if(gcdAB != 1) r.push_back(gcdAB);
  long long ans = r.size()+1;
  cout << ans << endl;
  
}

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

using namespace std;

int main()
{
	int n, n4 = 0, n2 = 0, n1 = 0;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x;

		cin >> x;
		
		if (x % 4 == 0)
			n4++;
		else if (x % 2 == 0)
			n2++;
		else
			n1++;		
	}
	
	if ((n1 + (n2 > 0)) <= n4 + 1)
		puts("Yes");
	else
		puts("No");
	
	return 0;
}

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

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

    int n;
    cin >> n;
    int v[n], c[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    
    int ans = 0;
    
    rep(i, n){
        if(v[i] > c[i]) ans += v[i] - c[i];
    }
    
    cout << ans << endl;

    return 0;
}

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

int n, r = -1, mc =0, counts = 0;
bool flag;
string s;
vector<int> a(400000);
vector<int> b(400000);
vector<int> c(400000);

int main() {
    cin >> n >> s;
    a.at(0) = 0;

    for (int i = 1; i < n+1; ++i)
    {
        int d;
        d = (s.at(i-1) == '#')? 1 : 0;
        a.at(i) = a.at(i-1) + d;
    } 

    b.at(n) = 0;

    for (int i = n-1; i >= 0; --i)
    {
        int d;
        d = (s.at(i) == '.')? 1 : 0;
        b.at(i) = b.at(i+1) + d;
    } 

    int mins = 10000000;
    for (int i = 0; i < n+1; ++i)
    {
        mins = min(mins, a.at(i) + b.at(i));
    }

    // for (int i = 0; i <= n; ++i) cout << a.at(i);
    // cout  << endl;
    // for (int i = 0; i <= n; ++i) cout << b.at(i);

    cout << mins << endl;

}

Measured memory_bytes: 5252
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import           Data.List.Split
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n,k,q] <- map read.words <$> getLine :: IO [Int]
    xs <- unfoldr (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k q xs

solve :: Int -> Int -> Int -> [Int] -> Int
solve n k q xs = minimum $ do
    l <- xs
    let removed = step l
    guard $ length removed == q
    return $! maximum removed - l
  where
    step l = take q . sort . concatMap take' $ splitWhen (<l) xs
    take' xs = take (length xs - k + 1) $ sort xs


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

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

int main() {
  ll n, x, mn, ans = 0;
  cin >> n;
  mn = INF;
  rep(i, n) {
    cin >> x;
    mn = min(mn, x);
    if (mn >= x) ans++;
  }

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


Measured memory_bytes: 256