akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

#define fi first
#define se second

typedef pair<int,int> pii;
const int INF = 1e9;

struct s {
	int ps,pp;
	int idx;
	s(){}
	s(int ps_, int pp_, int idx_) {
		ps = ps_; pp = pp_; idx = idx_;
	}
};

bool operator<(s a, s b) {
	return a.pp > b.pp;
}

int main() {
	int n, w, d;
	vector<pii> v;
	cin >> n >> w >> d;
	for(int i = 0; i < n; i++) {
		int x, y;
		char f;
		int nx, ny;
		cin >> x >> y >> f;
		switch(f) {
			case 'N':
				nx = w-x;
				ny = d-y;
				break;
			case 'W':
				nx = w + d-y;
				ny = x;
				break;
			case 'S':
				nx = w+d + x;
				ny = y;
				break;
			case 'E':
				nx = w+d+w + y;
				ny = w-x;
				break;
		}
		int ps, pp;
		ps = nx - ny;
		pp = nx + ny;
		v.push_back(pii(ps,pp));
	}

	sort(v.begin(), v.end());
	int res = 10000;
	for(int k = 0; k < 2; k++) {
	for(int i = 0; i < v.size(); i++) {
		vector<pii> vv;
		vector<int> pushed(n,0);

		vv.resize(v.size());
		for(int j = 0; j < v.size(); j++) {
			vv[j].fi = (v[(i+j)%n].fi - (k?v[i].se:v[i].fi) + 4*(w+d)) % (2*(w+d));
			vv[j].se = (v[(i+j)%n].se - (k?v[i].se:v[i].fi) + 4*(w+d)) % (2*(w+d));
			if(vv[j].fi > vv[j].se) vv[j].se += 2*(w+d);
		}
		sort(vv.begin(), vv.end());
		/*
		for(int j = 0; j < vv.size(); j++)
			cout << vv[j].fi << "," << vv[j].se << " " ;
		cout << endl;
		// */

		for(int j = 0; j < vv.size(); j++) {
			if(2*(w+d) <= vv[j].se || vv[j].fi == 0) {
				pushed[j] = 1;
			}
		}

		/*
		for(int i = 0; i < pushed.size(); i++)
			cout << pushed[i] << " ";
		cout << endl;
		// */

		priority_queue
 pq;
		int tmp = 1;
		for(int j = 0; j < vv.size(); j++)  {
			if(!pushed[j]) {
				if(pq.empty() || vv[j].fi <= pq.top().pp) {
					pq.push(s(vv[j].fi,vv[j].se,j));
					pushed[j] = 1;
				}
				else {
					while(pq.size()) pq.pop();
					tmp++;
					pq.push(s(vv[j].fi,vv[j].se,j));
					pushed[j] = 1;
				}
			}
		}
		if(pq.size()) tmp++;
		res = min(res,tmp);

		/*
		for(int i = 0; i < pushed.size(); i++)
			cout << pushed[i] << " ";
		cout << endl;
		// */

	}
	}
	cout << res << endl;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
	int n; IN(n);
	int t = ceil_div(n,2);
	double ans = (double)t/n;
	printf("%.10f",ans);
	return 0;
}


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

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

using namespace std;

#define MAX 100000
typedef long long ll;
typedef pair<int,int> ii;

struct Data {
  ll x,index, l_index;
  bool operator < ( const Data &data ) const {
    return x < data.x;
  }
};

int N, Q, sum[MAX+1];
ll T;
vector<Data> ps[2];
ii mp[MAX];

void compute() {
  if( ps[0].empty() || ps[1].empty() ) {
    int which = (ps[0].size()?0:1);
    rep(i,Q) {
      int tmp;
      cin >> tmp;
      --tmp;
      cout << ps[which][tmp].x + ( which ? -T : T ) << endl;
    }
    return;
  }
  rep(i,2) sort(ps[i].begin(),ps[i].end());
  vector<ll> collision_point;
  vector<ll> collision_time;
  rep(i,(int)ps[0].size()) {
    int p = lower_bound(ps[1].begin(),ps[1].end(),ps[0][i]) - ps[1].begin();
    if( p == (int)ps[1].size() ) continue;
    Data L = ps[0][i], R = ps[1][p];
    assert( L.x < R.x );
    int cnt = sum[R.l_index-1] - sum[L.l_index];
    if( cnt ) continue;
    collision_point.push_back( ( L.x + R.x ) / 2LL );
    collision_time.push_back( collision_point.back() - L.x );
  }
  rep(i,Q) {
    int tmp;
    cin >> tmp;
    --tmp;
    ii index = mp[tmp];
    Data &e = ps[index.first][index.second];
    ll ans = e.x + ( index.first ? -T : T );
    rep(j,(int)collision_point.size()) {
      if( collision_time[j] > T ) continue;
      if(  index.first && collision_point[j] > e.x ) continue;
      if( !index.first && collision_point[j] < e.x ) continue;
      ll tmp_p = e.x + ( index.first ? -1LL : 1LL ) * collision_time[j];
      bool collision = false;
      if(  index.first && collision_point[j] <= tmp_p ) collision = true;
      if( !index.first && collision_point[j] >= tmp_p ) collision = true;
      if( !collision ) continue;
      ll c_diff = llabs(ans-e.x);
      ll n_diff = llabs(collision_point[j]-e.x);
      if( c_diff > n_diff ) ans = collision_point[j];
    }
    cout << ans << endl;
  }
}

int main() {
  cin >> N >> T >> Q;
  vector<ll> vec;
  rep(i,N) {
    ll a,b;
    cin >> a >> b;
    mp[i] = ii(b-1,(int)ps[b-1].size());
    ps[b-1].push_back((Data){a,i,-1});
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  rep(i,2) rep(j,(int)ps[i].size()) {
    ps[i][j].l_index = lower_bound(vec.begin(),vec.end(),ps[i][j].x) - vec.begin();
  }
  rep(i,2) rep(j,(int)ps[i].size()) {
    ++sum[ps[i][j].l_index];
  }
  REP(i,1,(int)vec.size()+1) sum[i] += sum[i-1];
  compute();
  return 0;
}

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

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int x=100;
    //long long int klk=0;
    long long int k=0;
    while(x<n)
    {
        x=x+x/100;
        k++;
    }
    cout<<k<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n, m; cin >> n >> m;
    if(n > m) swap(n,m);
    for (int i = 0; i < m; ++i) {
        cout << n;
    }
    cout << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

using namespace std;

const int K = 1e9+1;

int main(){
  int N; cin >> N;
  
  vector<int> a(N),b(N);
  
  for(int i = 0; i < N; i++){ 
    a[i] = N*(i+1); b[i] = -N*(i+1);
  }
  
  for(int i = 0; i < N; i++){ 
    int p; cin >> p; p--;
    a[p] += i;
  }
  
  for(int i = 0; i < N; i++){ cout << a[i] << " ";}
  cout << endl;
  for(int j = 0; j < N; j++){ cout << b[j]+N*N+1 << " ";}
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<vector<int>> v;
    v.emplace_back(vector<int>());

    REP(i,n) {
        vector<int> v2(n-1);
        REP(j,n-1) cin >> v2[j];
        v.emplace_back(v2);
    }

    int ans = 0;
    vector<int> cnt(n+1,0);
    bool loop = true;
    int total = 0;
    int mx = (n-1LL) * n / 2;
    vector<vector<int>> played(n+1,vector<int>(n,0));
    vector<bool> noplay(mx+1,false);

    while (loop)
    {
        int count = 0;
        FOR(i,1,n) {
            if (cnt[i] == n-1) continue;
            int t = v[i][cnt[i]];
            if (v[t][cnt[t]] == i) {
                
                int di = (cnt[i] == 0) ? 1: played[i][cnt[i]-1] +1;
                int dt = (cnt[t] == 0) ? 1: played[t][cnt[t]-1] +1;
                int d = max(di,dt);
                //cerr << i << " " << t << " " << di << " " << dt << endl;
                noplay[d] = true;
                played[i][cnt[i]] = d;
                played[t][cnt[t]] = d;
                //cerr << played[i][cnt[i]] << endl;
                cnt[i]++;
                cnt[t]++;
                count++;
            }
        }

        //cerr << count << endl;
        if (count == 0) {
            loop = false;
            ans = -1;
        } else {
            total += count;
            if (total == mx)  {
                FOR(i,1,n+1) {
                    ans = max(ans,played[i][n-2]);
                    //cerr << played[i][n-2] << endl;
                }
                loop = false;
                FOR(i,1,ans+1) {
                    if (!noplay[i]) ans = -1;
                }
            }
        }
    }
    //REP(i,n-1) cerr << played[1][i];
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 8192
n,x = map(int,input().split())
a = list(map(int,input().split()))

#n,x = 3,30
#a = [20,30,10]

suma = sum(a)

ans = 0
if suma == x:
  ans = n
elif x > suma:
  ans = n -1
else:
  a = sorted(a)
  nokori = x
  for i in a:
    nokori -= i
    if nokori == 0:
      ans += 1
      break
    elif nokori < 0:
      break
    else:
      ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
const int mod=1e9+7;
int h,w;
string s[1001];
int f[1001][1001];

int main(){
	cin>>h>>w;
	for (int i=0;i<h;i++){
		cin>>s[i];
	}
	memset(f,0,sizeof(f));
	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			if (s[i][j]=='#') {f[i][j]=0;}
			else{
				if (i==0 && j==0) f[i][j]=1;
				else if (i==0) f[i][j]=f[i][j-1]%mod;
				else if (j==0) f[i][j]=f[i-1][j]%mod;
				else f[i][j]=(f[i-1][j]+f[i][j-1])%mod;
			}
		}
	}
	cout<<f[h-1][w-1]%mod<<endl;
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  vector<long long> div(L);
  for(int i=0; i<L; i++){
    div.at(i) = S.at(L-1-i)-'0';
  }
  long long ans = 0;
  for(int i=0; i<pow(2,L-1); i++){
    int temp=i;
    vector<int> bit(L-1);
    for(int j=0; j<L-1; j++){
      bit.at(j)=temp%2;
      temp/=2;
    }
    int cnt=0;
    ans+=div.at(0);
    for(int j=0; j<L-1; j++){
      if(bit.at(j)==0) cnt++;
      else cnt=0;
      ans+=div.at(j+1)*pow(10,cnt);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace 
std;int main() {
  
  int N,uke;
  cin >> N;
  
  vector<int> vec(N);
  for(int i = 0; i < N - 1; i++){
    cin >> uke;
    vec.at(uke - 1)++;
  }
  for(int i = 0; i < N; i++){
    cout << vec.at(i) << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int m = 1;
    int count = 0;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        m *= a.at(i);
        count += a.at(i) - 1;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nab[0];
        var a = nab[1];
        var b = nab[2];

        var max = Math.Min(a, b);
        var min = Math.Max(0, a + b - n);
        Console.WriteLine(string.Join(" ", new[] { max, min }));
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main(){
    int a, b, n, s;
    
    while(scanf("%d %d %d", &a, &b, &n) != EOF){
        s = 0;
            
        while(n--){
            a %= b;
            s += (a *= 10) / b;
        }
        
        printf("%d\n", s);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> as;
vector<int> bs;

int f(const int target, const int a, const int N, const vector<int> &ns) {
    int left = -1, right = N, mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2;
        int b = ns[mid];
#ifdef DEBUG
        printf("left: %d, right: %d, mid: %d, a: %d, b: %d\n", left, right, mid, a, b);
#endif
        if (a + b < target) {
            left = mid;
        } else {
            right = mid;
        }
    }
    return right;
}

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> bs[i];
    }

    vector<int> ans_bits;
    vector<int> bs2(N);

    // TODO: why failed if bit < 28
    for (int bit = 0; bit < 29; bit++) {
        for (int i = 0; i < N; i++) {
            bs2[i] = bs[i] % (1 << (bit + 1));
        }
        sort(bs2.begin(), bs2.end());

        ll cnt = 0;
        for (auto orig_a : as) {
            int a = orig_a % (1 << (bit + 1));
            int T = 1 << bit;
            {
#ifdef DEBUG
                printf("[%d, %d): \n", (1 << bit), 2 * (1 << bit));
#endif
                int left = f(T, a, N, bs2);
                int right = f(2 * T, a, N, bs2);
#ifdef DEBUG
                printf("bit: %d, a: %d, left: %d, right: %d\n", bit, a, left, right);
#endif
                cnt += right - left;
            }
            {
#ifdef DEBUG
                printf("[%d, %d): \n", 3 * (1 << bit), 4 * (1 << bit));
#endif
                int left = f(3 * T, a, N, bs2);
                int right = N;
                // int right = f(bit, 4 * (1 << bit), a, N, bs2);
#ifdef DEBUG
                printf("bit: %d, a: %d, left: %d, right: %d\n", bit, a, left, right);
#endif
                cnt += right - left;
            }
        }
        if (cnt % 2 == 0) {
            ans_bits.push_back(0);
        } else {
            ans_bits.push_back(1);
        }
    }


    reverse(ans_bits.begin(), ans_bits.end());
    ll ans = 0;
    for (auto bit : ans_bits) {
        ans = ans * 2 + bit;
    }
    cout << ans << endl;

    return 0;
}


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

int cx,cy;

int absolute(int a,int b){
    if(a<b) return b-a;
    else
        return a-b;
}

int tempH(int x,int y,int h){
    int H1=h+absolute(x,cx)+absolute(y,cy);
    return H1;
}

int main(){
    int n;
    cin>>n;
    int x[n],y[n],h[n],H[n];
    for(int i=0;i<n;i++)
        cin>>x[i]>>y[i]>>h[i];
    int cxf=0,cyf=0,Hf=0;
    cx=0;
    for(;cx<=100;cx++){
        cy=0;
        part1:
        for(;cy<=100;cy++){
            int k=0,i=0;
            for(;i<n;i++){
                if(h[i]!=0)
                    H[k++]=tempH(x[i],y[i],h[i]);
            }
            int j=1;
            while(j<k&&H[j]==H[j-1])
                j++;
            if(j==k){
                cxf=cx;cyf=cy;Hf=H[0];
                if(k==n) goto part2;
                else{
                    int i=0;
                    for(;i<n;i++){
                        if(h[i]==0){
                            if((Hf-absolute(cxf,x[i])-absolute(cyf,y[i]))>0) {cy++;goto part1;}
                            else continue;
                        }
                    }
                    if(i==n) goto part2;
                }
            }
        }
    }
    part2:
    cout<<cxf<<' '<<cyf<<' '<<Hf;
    return 0;
}


Measured memory_bytes: 256
val = list(input())
alp = ["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"]

val2 = set(val)
for i in val2:
    if i in alp:
        alp.remove(i)
try:
    print(alp[0])
except IndexError:
    print("None")

Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
ll func(ll a){
	if(a<100){
		ll xo=0;
		for(int i=0;i<=a;i++)
			xo^=i;
		return xo;
	}
	if(a%4==0)
		return a;
	if(a%4==1)
		return 1;
	if(a%4==2)
		return a+1;
	if(a%4==3)
		return 0;
}
int main() {
	ll A,B;
	cin>>A>>B;
	cout<<(func(max(0LL,A-1))^func(B))<<endl;
    return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {cin >> p[i];}
  vector<bool> res(n-1);
  for (int i = 0; i < n - 1; i++) {
    res[i] = p[i+1] > p[i];
  }
  int cnt = 0;
  for (int i = 0; i < n - 2; i++) {
    cnt += res[i+1] == res[i];
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static int minCost(int stones[], int k) {
		int cost[] = new int[stones.length];
		cost[0] = 0;
		cost[1] = Math.abs(stones[1] - stones[0]);
		for (int i = 2; i < stones.length; i++) {
			cost[i] = Integer.MAX_VALUE;
			for (int j = 1; j <= k; j++) {
				if (i - j >= 0) {
					cost[i] = Math.min(Math.abs(stones[i - j] - stones[i]) + cost[i - j], cost[i]);
				}
			}
		}
		return cost[stones.length - 1];
	}

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n, k;
		String array[] = br.readLine().split(" ");
		n = Integer.valueOf(array[0]);
		k = Integer.valueOf(array[1]);
		int stones[] = new int[n];
		array = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			stones[i] = Integer.valueOf(array[i]);
		}
		System.out.println("" + minCost(stones, k));

	}

}

Measured memory_bytes: 39840
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s;
  ll x=0;
  cin >> s;
  for(auto c:s){
    x += c - '0';
    x %= 9;
  }
  if(x) cout <<"No\n";
  else cout <<"Yes\n";
}


Measured memory_bytes: 3740
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}



int main() {
   int n; cin >> n; 
   int score = 0;
   int runner = 0;
   int out = 0;
   for (; n != 0; ) {
       string s; cin >> s;
       if (s == "HIT") runner++;
       if (runner == 4) {
           score++;
           runner--;
       }
       if (s == "HOMERUN") {
           score += runner + 1;
           runner = 0;
       }
       if (s == "OUT") out++;
       if (out == 3) {
           runner = 0;
           cout << score << endl;
           score = 0;
           out = 0;
           n--;
       }
   }

    return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
ll res[(int)1e6 + 1];
ll f(int n) {
    if (res[n] != 0) return res[n];
    ll cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) cnt+= i;
    }
    return res[n] = cnt;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    cout << f(n) <<endl;
    return 0;
}

Measured memory_bytes: 3656
function *main() {
  
  const N = +(yield);
  const P = (yield).split(" ").map(s => +s);
  let m = 200001, ans = 0;
  for (let p of P) {
    if (p < m) ans++;
    m = Math.min(m, p);
  }
  console.log(ans);
  
}
const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin, output: process.stdout}).on("line", line => iter.next(line));


Measured memory_bytes: 50648
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

struct UnionFind
{
    std::vector<int> par; // par[a] = b ... a の親は b であるという意味. 根の場合は木の成分数に(-1)をかけた値.
    UnionFind(int n) : par(n, -1){} // 親なし(-1)として初期化

    // x の根を返す
    int root(int x)
    {
        // 親がいない場合 x 自身が根
        if (par[x] < 0) return x;
        // 親がいる場合はその親を辿り、再帰的に根を求める
        else return par[x] = root(par[x]);
    }

    // x と y が同じ木に属しているかどうか
    bool isSame(int x, int y)
    {
        return root(x) == root(y);
    }

    // x が属している木と y が属している木の結合
    void merge(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry) return; // 既に結合しているため
        
        if (par[rx] > par[ry]) std::swap(x, y);
        par[rx] += par[ry]; // 深さを更新
        par[ry] = rx;       // x の根 rx に y の根 ry を結合 

    }

    // x が属する木の深さを返す
    int size(int x)
    {
        return -par[root(x)];
    }
};


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    REP(i, M)
    {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    int ans = 0;
    UnionFind uf(N);
    REP(i, M)
    {
        if (!uf.isSame(A[i], B[i]))
            uf.merge(A[i], B[i]);
    }
    REP(i, N)
    {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S; cin >> S;
  string result = "Yes";

  if (S[0] == S[1] && S[1] == S[2]) result = "No";

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3592
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
	a = input()
	if   a[0] == '0': Q.append(a[2:])      # pushBack
	elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
	else:             Q.pop()              # popBack


Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
int a,b,maxv;

int main() {
	cin>>a>>b;
	int f=a+b;
	int k=a+a-1;
	int w=b+b-1;
	int l=max(f,k);
	int h=max(l,w);
	cout<<h<<endl;




	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(void){
  
  string input_text;
  int max_length = -1;
  int current_length = 0;
  
  //input
  cin >> input_text;
  
  //check
  for(int i = 0;i < input_text.length() ; ++i){
    if(input_text[i] != 'A' && input_text[i] != 'T' && input_text[i] != 'G' && input_text[i] != 'C')
    {
      current_length = 0;
    }else
    {
      ++current_length;
    }
    if(current_length > max_length) max_length = current_length;
  }
  
  cout << max_length << endl;
  
  return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] chars = s.toCharArray();
		String ans = "Good";
		for(int i = 0; i < 3; i++){
			if(chars[i] == chars[i+1]){
				ans = "Bad";
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans,shou,j=0;
  for(int i=1;i<=n;i++){
    while(1){
      shou=i/pow(10,j);
      if(shou!=0)j++;
      else if(shou==0)break;
    }
    if(j%2==1)ans++;
  }
  cout<<ans;
  return 0;
}


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

int main() {
  int a, b;

  cin >> a >> b;

  if ((a % 2 == 1) && (b % 2 == 1)){
    cout << "Odd" << endl;
  }

  else{
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,k;
cin>>a>>b>>c>>d>>e>>k;
  if(abs(b-a)<=k and abs(c-a)<=k and abs(c-b)<=k and abs(d-a)<=k and abs(d-b)<=k and abs(d-c)<=k and abs(e-a)<=k and abs(e-b)<=k and abs(e-c)<=k and abs(e-d)<=k)
    cout<<"Yay!"<<endl;
  else
    cout<<":("<<endl;
return 0;
}

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

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

    int64_t sum = 0;

    for(int i=1;i<N+1;i++){
        if(i%3 != 0 && i%5 != 0){
            sum = sum + i;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}


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

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    for (int i = b-(a-1); i <= b+(a-1); i++) {
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val n = readI()
    println(if (n % 1000 == 0) 0 else 1000 - (n % 1000))
}



Measured memory_bytes: 34564
def do_binary_search(target_value, target_list, target_list_length=None):
    if target_list_length:
        target_list_length = len(target_list)
   

    left = 0
    right = target_list_length

    while right - left > 0:
        mid = (right + left) / 2
        if target_list[mid] == target_value:
            return True
        elif target_value < target_list[mid]:
            right = mid
        else:
            left = mid + 1
    return False



def main():
    s_length = int(raw_input())
    s = [int(x) for x in raw_input().strip().split(' ')]
    t_length = raw_input()
    t = [int(x) for x in raw_input().strip().split(' ')]

    counter = 0
    for value in t:
        counter += int(do_binary_search(value, s, s_length))

    print counter 

if __name__ == '__main__':
    main()

Measured memory_bytes: 15184
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC171B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var k = int.Parse(input[1]);

            var input2 = Console.ReadLine().Split(' ');
            if (input2.Count() == n)
            {
                var price = new List<int>();
                for (var i = 0; i < input2.Count(); i++)
                {
                    price.Add(int.Parse(input2[i]));
                }
                price.Sort();
                var ans = 0;
                for (var i = 0; i < k; i++)
                {
                    ans += price[i];
                }
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 19452
#ABC42 A
#リストで書いた場合
myList=[]
myList_int=[]
myList=input().split() #split()でリストに入力をstrで入れる
myList_int=[int(s) for s in myList] #intに変換

#print(myList)

if myList_int== [7,5,5]:
    print("YES")
elif myList_int== [5,7,5] :
    print("YES")
elif myList_int== [5,5,7] :
    print("YES")
else:
    print("NO")

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

#define INF (10000)

const int x_mv[4] = {1, 0, 0, -1};
const int y_mv[4] = {0, 1, -1, 0};
char blocks[52][52];
int costs[52][52];

int main(void) {
	int H, W;
	cin >> H >> W;

	for (int h = 0; h <= 51; h++) {
		for (int w = 0; w <= 51; w++) {
			blocks[h][w] = '#';
			costs[h][w] = -1;
		}
	}


	int space = 0;
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			cin >> blocks[h][w];
			if (blocks[h][w]=='.') {
				space++;
				costs[h][w] = INF;
			}
		}
	}

	queue <pair <int, int>> que;
	que.push(make_pair(1, 1));
	costs[1][1] = 0;

	while (que.size() > 0) {
		pair <int, int> q = que.front();
		que.pop();
		int x = q.second;
		int y = q.first;
		for (int i = 0; i < 4; i++) {
			int nx = x + x_mv[i];
			int ny = y + y_mv[i];
			if (blocks[ny][nx]=='#') continue;
			if (costs[ny][nx] > (costs[y][x]+1)) {
				costs[ny][nx] = costs[y][x]+1;
				que.push(make_pair(ny, nx));
			}
		}
	}

	if (costs[H][W]==INF) {
		cout << -1 << endl;
	} else {
		cout << space - (costs[H][W]+1) << endl;
	}
  return 0;
}


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

int main()
{
    int x, y, z;
    cin >> x >> y >>z;
    
    cout << z << " "<< x << " "<< y << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
	for(T& x: vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){
		if(i) cout << ' ';
		os << v[i];
	}
	return os;
}

typedef tuple<int,int,int> T;

vector<vector<char>> room;
vector<vector<int>> c, on, off;
vector<vector<int>> pre;

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

int bfs(int h, int w, pair<int, int> s, pair<int, int> g){
	vector<vector<int>> dis(h, vector<int>(w, INF));
	vector<vector<bool>> used(h, vector<bool>(w,false));
	dis[s.first][s.second] = 0;

	queue<T> q;
	q.emplace(T(s.first, s.second, pre[s.first][s.second]));

	vector<vector<pair<int, int>>> preVer(h, vector<pair<int, int>>(w,make_pair(-1,-1)));
	while(not q.empty()){
		int y, x, time;
		tie(y, x, time) = q.front(); q.pop();
		used[y][x] = true;
		rep(d,4){
			int ny = y + dy[d];
			int nx = x + dx[d];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if(room[ny][nx] == '#' or used[ny][nx] == true) continue;

			int cost = dis[y][x] + on[ny][nx] + off[ny][nx];
			if(pre[ny][nx] != -1){
				cost = min(cost, dis[y][x] + (time + 1 - pre[ny][nx]) * c[ny][nx]);
			}
			if(dis[ny][nx] > cost){
				preVer[ny][nx] = make_pair(y,x);
				dis[ny][nx] = cost;
				q.emplace(ny, nx, time + 1);
			}
		}
	}

	vector<pair<int, int>> path;
	path.emplace_back(g);
	int time = pre[s.first][s.second];
	int y, x;
	tie(y,x) = g;
	while(preVer[y][x].first != -1){
		tie(y,x) = preVer[y][x];
		path.emplace_back(y,x);
	}
	for(auto i = path.rbegin(); i != path.rend(); i++){
		pre[i->first][i->second] = time++;
	}
	//for(auto i : pre){ cout << i << endl; }
	return dis[g.first][g.second];
}

int main(){
	int h, w, m;
	cin >> h >> w >> m;

	room = vector<vector<char>>(h, vector<char>(w,'.'));
	c = vector<vector<int>>(h, vector<int>(w,0));
	on = vector<vector<int>>(h, vector<int>(w,0));
	off = vector<vector<int>>(h, vector<int>(w,0));
	pre = vector<vector<int>>(h, vector<int>(w,-1));
	cin >> room >> c >> on >> off;

	vector<pair<int, int>> p(m);
	rep(i,m){
		cin >> p[i].first >> p[i].second;
	}

	int y, x;
	tie(y, x) = p[0];
	int ans = on[y][x] + off[y][x];
	pre[y][x] = 0;

	rep(i,m - 1){
		ans += bfs(h, w, p[i], p[i + 1]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    int n;
    cin>>n;

    int y = n % 1000;
    if(y == 0) cout<<y<<"\n";
    else cout<<1000-y<<"\n";

    return 0;
}

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

int main(){
    long long a;
    long double b;
    cin >> a >> b;

    int sei=b;
    long double shou=b-sei;

    long double seki = shou * a;

    long long ans = sei*a + seki;

    cout << ans << endl;
}

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long
#define INF 1000000007
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=m/n;i>=1;--i)
    {
        if(m%i==0)
        {
            int g=m/i;
            if(g>=n)
                return cout<<i<<endl,0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
a = {}
while True:
    try:
        n = int(raw_input())
        if n not in a:
            a[n] = 0
        a[n] += 1
    except EOFError:
        break
a = sorted(a.items(), key=lambda x:x[1], reverse = True)
for s in [k for k,v in a if v == a[0][1]]:
    print s

Measured memory_bytes: 4228
import networkx as nx
N, M = map(int, input().split())

G=nx.Graph()

for _ in range(M):
    a, b = map(int, input().split())
    G.add_edge(a,b)

tmp= list(nx.connected_components(G))

count=0

for i in tmp:
    count+=len(i)


print(N-count+len(tmp)-1)

Measured memory_bytes: 142476
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a == (a + b) / 2) {
    cout << c << endl;
  } else if (a == c) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

char S[100005];
vector<vector<ll> > dp(100005,vector<ll>(13));

int main(){
    cin >> S;
    ll n;
    n = strlen(S);

    dp[0][0] = 1;
    rep(i,n){
        int c;
        if(S[i] == '?') c = -1;
        else c = S[i] - '0';

        rep(j,10){
            if(c != -1 && c != j) continue;
            rep(ki,13){
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }
        rep(j,13){
        dp[i+1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 15616
S = input()

if S[-1] == "2" or S[-1] == "4" or S[-1] == "5" or S[-1] == "7" or S[-1] == "9":
    print("hon")
elif S[-1] == "0" or S[-1] == "1" or S[-1] == "6" or S[-1] == "8":
    print("pon")
else:
    print("bon")


Measured memory_bytes: 61636
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define int long long

void test_case(){
	int h,w,m;
	cin >> h >> w >> m;
	vector<int> H(h), W(w);
	set<pair<int,int>> s;

	while(m--){
		int r,c;
		cin >> r >> c;
		H[r-1]++;
		W[c-1]++;
		s.insert({r-1,c-1});
	}
	int mxh = *max_element(H.begin(), H.end());
	int mxw = *max_element(W.begin(), W.end());
	int r=0,c=0;
	for(int x : H) if(x==mxh) r++;
	for(int x : W) if(x==mxw) c++;

	int ans = mxw+mxh-1;
	int cnt=0;

	for(auto x : s){
		if(H[x.first]==mxh && W[x.second]==mxw ) cnt++; 
	}

	if(cnt<r*c) cout << ans+1 << endl;
	else cout << ans << endl;

}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}









Measured memory_bytes: 26676
#include<stdio.h>
#include<string.h>
int main(){
  char s[100000];
  gets(s);
  int c=0;
  for(int i=0;i<strlen(s);i++){
    if(s[i] == s[i+1]){
       	s[i+1]='1'-s[i+1]+'0';
		c++;
	}
  }
	printf("%d",c);
}

  

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

#define MAX 250

int parent(int i)
{
  return i / 2;
}
int left(int i)
{
  return 2 * i;
}
int right(int i)
{
  return 2 * i + 1;
}

int main()
{
  int H;
  int A[MAX + 1];

  cin >> H;
  for (int i = 1; i <= H; i++)
  {
    cin >> A[i];
  }

  for (int i = 1; i <= H; i++)
  {
    cout << "node " << i << ": key = " << A[i] << ", ";
    if (parent(i) >= 1)
    {
      cout << "parent key = " << A[parent(i)] << ", ";
    }
    if (left(i) <= H)
    {
      cout << "left key = " << A[left(i)] << ", ";
    }
    if (right(i) <= H)
    {
      cout << "right key = " << A[right(i)] << ", ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;ll cnt=0;
    for(int i=1;i<=n;i++){
        ll l=0;
        ll a=i;
        while(a>0){a/=10;l++;}
        if(l&1)cnt++;
    }
    cout<<cnt<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (((x - r) >= 0) && ((x + r) <= W) && ((y - r) >= 0) && ((y + r) <= H))
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


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


	cout << (N + 2*D) / (2 * D + 1) << endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
long long a[100010],b[100010],ans = 0;
vector<pair<long long,int>> v;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(i=0;i<n;i++){
		v.push_back({a[i] + b[i],i});
	}
	sort(v.begin(),v.end());
	for(i=0;i<n;i++){
		if(i%2==0) ans += a[v[n-1-i].second];
		else ans -= b[v[n-1-i].second];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<vector>

using namespace std;

int n,U;

vector<int> req;
vector<int> unit;

int main()
{
  while(scanf("%d%d", &n, &U), n || U) {
    req = vector<int>(n, 0);
    unit = vector<int>(n);
    int k,r;
    for(int i=0; i<n; ++i) {
      scanf("%d%d", &unit[i], &k);
      for(int j=0; j<k; ++j) {
			scanf("%d", &r);
			req[i] |= 1 << r;
      }
    }
    int j, sol = 100, u, c, skip;
    for(int i=0; i<(1<<n); ++i) {
      u = c = 0;
      for(j=n-1; j>=0; --j) {
			if(!(i&(1<<j))) continue;
			c++;
			if((i&req[j])!=req[j] || sol<c) {
				i += (((skip=((i&req[j])^req[j]|1<<j))&-skip)-1)&~i;
				break;
			}
			u += unit[j];
      }
      sol = j < 0 && u >= U ? min(sol, c) : sol;
    }
    printf("%d\n", sol);
  }
  return 0;
}

Measured memory_bytes: 816
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, A, B, C = get_ints
L = []
N.times do |i|
  L[i] = get_int
end

def search(cur, ans)
  return ans if cur == N

  none = search(cur+1, ans.dup)

  a_ans = ans.dup
  a_ans[3] += 10 if a_ans[0] > 0
  a_ans[0] += L[cur]
  a = search(cur+1, a_ans)

  b_ans = ans.dup
  b_ans[3] += 10 if b_ans[1] > 0
  b_ans[1] += L[cur]
  b = search(cur+1, b_ans)

  c_ans = ans.dup
  c_ans[3] += 10 if c_ans[2] > 0
  c_ans[2] += L[cur]
  c = search(cur+1, c_ans)

  if none[0].is_a? Array
    none + a + b + c
  else
    [none, a, b, c]
  end
end

ans = search(0, Array.new(4, 0))

min_point = A + B + C
test = nil
ans.each do |arr|
  next if arr[0] == 0 || arr[1] == 0 || arr[2] == 0
  res = (A-arr[0]).abs + (B-arr[1]).abs + (C-arr[2]).abs + arr[3]
  if res < min_point
    min_point = res
    test = arr
  end
end

puts min_point


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

int main(void){
  string bc;
  while(cin >> bc){
    string ac = "";
    for(int i = 0; i < bc.size(); i++){
      if(bc[i] == '@'){
        for(int j = 0; j < (bc[i+1] - '0'); j++) ac += bc[i+2];
        i += 2;
      }else{
        ac += bc[i];
      }
    }
    cout << ac << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
fn main() {
    let n = read::<usize>();
    let s = read::<String>();
    let s: &[u8] = s.as_bytes();
    let mut ans = 0;
    let candidates: Vec<String> = (0..1000)
        .map(|e| format!("{:0>3}", e.to_string()))
        .collect();
    for k in candidates {
        let k = k.as_bytes();
        let mut ok: bool = false;
        let mut cur: usize = 0;
        for l in 0..n {
            if s[l] == k[cur] {
                cur += 1;
            }
            if cur == 3 {
                ok = true;
                break;
            }
        }
        if ok {
            ans += 1
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair

vector<ll>v;
map<int, int>m;

int main() {
	int n;
	int ans = 0;
	cin >> n;
	REP(0, n) {
		int tmp;
		cin >> tmp;
		if (m[tmp] == 0) {
			m[tmp] = 1;
		}
		else {
			m[tmp] = 0;
		}
		v.push_back(tmp);
	}
	REP(0, v.size()) {
		if (m[v[i]] == 1) {
			ans++;
			m[v[i]] = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5748
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, y;
	cin >> n >> y;

	for (int i = 0; i <= 2000; ++i) {
		for (int j = 0; j <= 4000; ++j) {
			int bill_1000 = n - i - j;
			if (bill_1000 >= 0) {
				if (i * 10000 + j * 5000 + bill_1000 * 1000 == y) {
					cout << i << " " << j << " " << bill_1000 << "\n";
					return 0;
				} 
			}	
		}
	}

	cout << "-1 -1 -1\n";

	return 0;

}

Measured memory_bytes: 384
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort()

    new = []
    new = P[:X] + Q[:Y] + R
    new.sort(reverse=True)
    print(sum(new[: X + Y]))


main()


Measured memory_bytes: 23220