akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll h;
    cin >> h;
    int bit = 0;
    ll ans=0;
    while (h > 0) {
        h /= 2;
        ans += pow(2, bit);
        bit++;
    }
    cout << ans << endl;


	return 0;
}



Measured memory_bytes: 512
// C - : (Colon)
#include <bits/stdc++.h>
using namespace std;

int main(){
	double A,B,H,M; cin>>A>>B>>H>>M;
	double h_deg, m_deg, deg, rad, c2;
	double PI = acos(-1);
	// 時針:30度/1時間 0.5度/1分
	h_deg = H*30 + M*0.5; // H時M分後の時針の角度(deg)
	// 分針:6度/1分
	m_deg = M*6; // M分後の分針の角度(deg)
	deg = h_deg - m_deg;
	rad = deg * PI / 180;
	c2 = A*A + B*B - 2*A*B*cos(rad);
	cout<<setprecision(20)<<fixed<< sqrt(c2) <<endl;
}


Measured memory_bytes: 4076
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int cnt[200010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,K;
	int A[200010];
	cin >> N >> K;
	REP(i, N) {
		cin >> A[i];
		cnt[A[i] - 1]++;
	}
	sort(cnt, cnt + N);
	int ans = 0;
	REP(i, N - K) {
		ans += cnt[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

void solve(){
	ll n;cin>>n;
	vector<ll>p(n);
	rep(i,n)cin>>p[i];
	
	vector<ll>a(n,4*pow(10,4));
	vector<ll>b(n,4*pow(10,4));
	rep(i,n-1){
		a[i+1]=a[i]+4*pow(10,4);
		b[i+1]=b[i]+4*pow(10,4);
	}
	reverse(all(b));
	rep(i,n){
		p[i]--;
		b[p[i]]-=4*pow(10,4);
		b[p[i]]+=i+1;
	}
	rep(i,n)cout<<a[i]<<" ";
	cout<<endl;
	rep(i,n)cout<<b[i]<<" ";
	cout<<endl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size() > k)cout << s.substr(0,k) << "..." << endl;
  else cout << s << endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  int cnt = 1;
  int trg = a[0];
  for(int i = 1; i < N; i++) {
    if(a[i] != a[i - 1]) {
      if(trg > cnt) {
        ans += cnt;
      } else {
        ans += cnt - trg;
      }
      trg = a[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  if(trg > cnt) {
    ans += cnt;
  } else {
    ans += cnt - trg;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
 
#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
 
using namespace std;
bool check(string s){
	int l = s.length();
	if(l%2) return false;
	if(s.substr(0, (l+1)/2) != s.substr((l+1)/2)) return false;
	else return true;
}
int main() {
	string s;
	cin >> s;
	int l = s.length();
	FOR(i, 1, l){
		if(check(s.substr(i)) || check(s.substr(0, l-i))){
			cout << l-i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


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

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    int max = 0;
    for (int i = 0; i <= pow(n, 0.5); i++) {
        if (pow(i, 2) > max) {
            max = pow(i, 2);
        }
    }
    cout << max << endl;
    return 0;
}

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


using namespace std;

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

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

	for (int i = 0;i < n;i++) {
		cout << (sum ^ a[i]) << endl;
	}

	return 0;
}


//DDDDDDDDDDDDDD
//
//int main() {
//	int n,q;
//	long long sum = 0;
//	vector<int> num(100005);
//	cin >> n;
//
//	vector<int> a(n);
//	for (int i = 0;i < n;i++) {
//		cin >> a[i];
//		sum += a[i];
//		num[a[i]]++;
//	}
//
//	cin >> q;
//	vector<int> b(q);
//	vector<int> c(q);
//
//	for (int i = 0;i < q;i++) {
//		cin >> b[i] >> c[i];
//	}
//
//	for (int i = 0;i < q;i++) {
//		sum -= (long long)b[i] * (long long)num[b[i]];
//		sum += (long long)c[i] * (long long)num[b[i]];
//		num[c[i]] += num[b[i]];
//		num[b[i]] = 0;
//		cout << sum << endl;
//	}
//
//
//	return 0;
//}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define all(c) (c).begin(), (c).end()
const int INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;

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

  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> pos(10);

  for (int i = 0; i < n; ++i) {
    pos[s[i] - '0'].push_back(i);
  }
  for (int i = 0; i < 10; ++i) {
    pos[i].push_back(INF);
    pos[i].push_back(INF + 1);
    pos[i].push_back(INF + 2);
  }

  int ans = 0;
  for (int i = 0; i < 1000; ++i) {
    int a, b, c;
    a = i / 100, b = (i % 100) / 10, c = i % 10;
    int ax = *upper_bound(all(pos[a]), -1);
    int bx = *upper_bound(all(pos[b]), ax);
    int cx = *upper_bound(all(pos[c]), bx);
    if (cx < INF) ++ans;
  }

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const long mod = 1e9+7;
const int size=1e5;
const long INF=1e14;
long fact[size+2]={};
long inv(long x,long n){
	long res=1;int i=0;
	while(n>=(1<<i)){
		if(n&(1<<i)) (res*=x)%=mod;
		x=(x*x)%mod;
        i++;
  	}return res;
}
void modfact(long n){
  	fact[0]=1;long res=1;
	rep(i,1,n+2) fact[i]=(fact[i-1]*i)%mod;
  	return;
}
long modcomb(long n,long r){
  	if(n<r) return 0;
  	long res=fact[n];
 	(res*=inv(fact[r],mod-2))%=mod;
  	(res*=inv(fact[n-r],mod-2))%=mod;
   	return res;
}
int main(){
  	long n;cin>>n;
  	modfact(n);
  	int cnt[n]={};int a;
  	long d;
  	rep(i,0,n+1){
    	cin>>a;a--;
    	if(cnt[a]==0) cnt[a]=i+1;
    	else{ d=cnt[a]+n-i; break; }
  	}//cout<<d<<endl;
  	rep(k,1,n+2){
    	cout<<(modcomb(n+1,k)-modcomb(d-1,k-1)+mod)%mod<<endl;
  	}
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];
ll a[201010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
	}
	rep(j, k) {
		vector<ll>light(n);
		rep(i, n) {
			if (i - a[i] < 0) {
				light[0]++;
			}
			else {
				light[i - a[i]]++;
			}
			if (i + a[i] + 1 <= n - 1) {
				light[i + a[i] + 1]--;
			}
		}
		rep(i, n-1) {
			light[i + 1] += light[i];
		}
		rep(i, n) {
			a[i] = light[i];
		}
		bool flag = true;
		rep(i, n) {
			if (light[i] != n)flag = false;
		}
		if (flag) {
			break;
		}

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


Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

template <typename T> 
const T& clamp(const T &t, const T &low, const T &high) { 
    if(t < low) {
        return low;
    } else if(high < t) {
        return high;
    } else {
        return t;
    }
}

template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    ll cnta = 0, cntb = 0, cntd = 0;
    for(ll i = 0; i < N; i++) {
        string S;
        cin >> S;
        char pre = S[0];
        for(ll j = 1; j < S.size(); j++) {
            if(pre == 'A' && S[j] == 'B') ans++;
            pre = S[j];
        }
        bool fb = S[0] == 'B', ba = S.back() == 'A';
        if(ba && fb) cntd++;
        else if(ba) cnta++;
        else if(fb) cntb++;
    }

    if(cntd) {
        ans += cntd - 1;
        if(cnta) {
            ans++;
            cnta--;
        }
        if(cntb) {
            ans++;
            cntb--;
        }
    }
    ans += min(cnta, cntb);
    cout << ans << endl;
    return 0;
}


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

int main () {
  string s;
  cin >> s;
  int count = 0;
  for (int i= 0; i<s.size()/2;i++)
    if(s.at(i) != s.at(s.size()-1-i)) {
      count++;
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <float.h>

int main()
{
    int i;
    long int n, a;
    long int sum = 0;
    long int num[200000] = {};
    scanf("%ld", &n);

    for(i=1; i<n; i++)
    {
        scanf("%ld", &a);
        num[a-1]++;
    };
    for(i=0; i<n; i++)
    {
        printf("%ld\n", num[i]);
    }

    return 0;
}



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

int main(){
  long a, b, c, x, y, ans = 1e13;
  cin >> a >> b >> c >> x >> y;
  
  for(long i=max(x, y)*2; i>=0; i-=2){
    long price = c*i + a*max(0L, x-i/2) + b*max(0L, y-i/2);
    ans = min(ans, price);
  }

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


Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for (int k = 0; k < n; k++) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == b) {
                    a[i][j] = -1;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int j = 0; j < 3; j++) {
        if (a[0][j] == -1 && a[1][j] == -1 && a[2][j] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) {
        cout << "Yes" << endl;
        return 0;
    }
    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){
    return power(x,mod-2,mod);
}


int32_t main() {

    fast

    string s, t;
    cin >> s >> t;

    int maxLen = 0;
    int j;
    for(int i = 0; i < s.size(); i++) {
        int curr = 0;
        for(j = 0; j < t.size() && i + j < s.size(); j++) {
            if(s[i + j] == t[j]) {
                curr++;
            }
        }
        if(j == t.size())
            maxLen = max(maxLen, curr);
    }
    cout << (t.size() - maxLen);


    return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<queue>
#include<functional>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,pair<int,int> > P;
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
int R,C;
string board[100];
pair<int,int> S,RR;
priority_queue<P,vector<P>,greater<P> >que;
int SS[100][100];
int main()
{
	scanf("%d%d",&R,&C);
	for(int i=0;i<R;i++)cin >> board[i];
	for(int i=0;i<R;i++)for(int j=0;j<C;j++){if(board[i][j]=='S'){S.second=j;S.first=i;}else if(board[i][j]=='G'){RR.second=j;RR.first=i;}}
	board[S.first][S.second]='.';board[RR.first][RR.second]='.';
	for(int i=0;i<R;i++)for(int j=0;j<C;j++)SS[i][j]=100001;
	que.push(P(0,S));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(SS[p.second.first][p.second.second]<=p.first)continue;
		SS[p.second.first][p.second.second]=p.first;
		//printf("x:%d y:%d %d\n",p.second.second,p.second.first,p.first);
		for(int k=0;k<4;k++){
		
			if(p.second.second+dx[k]>=0&&p.second.second+dx[k]<C&&p.second.first+dy[k]>=0&&p.second.first+dy[k]<R){
				int XX=p.second.second+dx[k];int YY=p.second.first+dy[k];
				pair<int,int> next;next.second=XX;next.first=YY;
				if(board[YY][XX]=='o')que.push(P(p.first+1,next));
				else if(board[YY][XX]=='#')continue;
				else{
					if(board[YY][XX]=='.')que.push(P(p.first+2,next));
					else que.push(P(p.first+3,next));
					XX+=dx[k];YY+=dy[k];
					next.second=XX;next.first=YY;
					if(XX>=0&&XX<C&&YY>=0&&YY<R){
						if(board[YY][XX]=='#')continue;
						if(board[YY-dy[k]][XX-dx[k]]=='.'&&board[YY][XX]=='o')que.push(P(p.first+3,next));
						else que.push(P(p.first+4,next));
						XX+=dx[k];YY+=dy[k];
						next.second=XX;next.first=YY;
						if(XX>=0&&XX<C&&YY>=0&&YY<R){
							if(board[YY][XX]=='#')continue;
							if(board[YY-2*dy[k]][XX-2*dx[k]]=='.'&&board[YY][XX]=='o'&&board[YY-dy[k]][XX-dx[k]]=='o')que.push(P(p.first+4,next));
							else que.push(P(p.first+5,next));
							
						}
					}
				}
			}
		}
	}
	printf("%d\n",SS[RR.first][RR.second]);
	return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1e5+5;

int n, m, a[10];
int main(){
    cin >> n >> m;

    memset(a, -1, sizeof a);
    int x, y, f=1;
    while(m--){
        cin >> x >> y;
        if(a[x] != -1 && a[x] != y) f = 0;
        else a[x] = y;
    }
    if(f==0 || (n>1 && a[1]==0)) puts("-1");
    else {
        if(n>1 && a[1]==-1) a[1] = 1;
        for(int i=1; i<=n; i++) cout << max(0,a[i]); cout << endl;
    }
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Console.ReadLine();
		var N = S.Length;
		var s = S.Select(c => c - '0').ToArray();
		var bit = new BinaryIndexedTree(s);
		int k = 0, l = 0, r = N;
		while (true)
		{
			var t = bit.Sum(l, r);
			if (t == 0 || t == r - l) break;
			bit.Add(l, -s[l]);
			bit.Add(r - 1, -s[r - 1]);
			l++; r--; k++;
		}
		Console.WriteLine(N - k);
	}
}
class BinaryIndexedTree
{
	public readonly int Size;
	readonly int[] bit;
	public BinaryIndexedTree(int size)
	{
		Size = size;
		bit = new int[size + 1];
	}
	public BinaryIndexedTree(int[] array) : this(array.Length)
	{
		for (var i = 0; i < Size; i++) bit[i + 1] = array[i];
		for (var i = 1; i < Size; i++) if (i + (i & (-i)) <= Size) bit[i + (i & (-i))] += bit[i];
	}
	public void Add(int index, int value) { for (var i = index + 1; i <= Size; i += i & (-i)) bit[i] += value; }
	int Sum(int to) { var sum = 0; for (var i = to; i > 0; i -= i & (-i)) sum += bit[i]; return sum; }
	public int Sum(int from, int to) => Sum(to) - Sum(from);
}


Measured memory_bytes: 13396
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.dedup();
    let n = a.len();

    let mut b = vec![];
    if n > 1 && a[0] < a[1] {
        b.push(a[0]);
    }
    for i in 1..n - 1 {
        if (a[i - 1] < a[i] && a[i] > a[i + 1]) || (a[i - 1] > a[i] && a[i] < a[i + 1]) {
            b.push(a[i]);
        }
    }
    if n > 1 && a[n - 2] < a[n - 1] {
        b.push(a[n - 1]);
    }
    // eprintln!("{:?}", a);
    // eprintln!("{:?}", b);

    let mut money = 1000;
    for i in (0..b.len()).step_by(2) {
        money += (b[i + 1] - b[i]) * (money / b[i]);
    }
    println!("{}", money);
}


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

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

vector<long long> L(N+1);


if(N == 0) cout << 2;
else if(N == 1) cout << 1;
else{
  L.at(0) =2;
  L.at(1) =1;
  for(int i = 2;i<=N;i++){
    L.at(i) = L.at(i-1)+L.at(i-2);
  }
cout << L.at(N);  
}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,sum1=0,sum2=0,sum3=0;
	scanf("%d %d %d",&a,&b,&c);
	sum1 = a+b;
	sum2 = b+c;
	sum3 = a+c;
	if(sum1<=sum2 && sum1<=sum3){
		printf("%d",sum1);
	}
	else if(sum2<=sum1 && sum2<=sum3){
		printf("%d",sum2);
	}
	else if(sum3<=sum1 && sum3<=sum2){
		printf("%d",sum3);
	}
	else if(sum1==sum2 && sum1==sum3){
		printf("%d",sum1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	int x;
	int i = 1;

	while(true)
	{
		cin >> x;
		if (x == 0)
		{
			break;
		}
		printf("Case %d: %d\n", i, x);
		i++;
	}

	return 0;
}

Measured memory_bytes: 1144
n, q = map(int, input().split())
s = input()
ans = [0]*n
for i in range(1, n):
    if s[i-1]=="A" and s[i]=="C": ans[i] += 1
    ans[i] += ans[i-1]
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r-1]- ans[l-1])

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

char asd[1005][1005];
long long ans[1005][1005];
const long long mod=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int z,x;
	cin>>z>>x;
	for(int q=1;q<=z;q++)
	{
		for(int w=1;w<=x;w++)cin>>asd[q][w];
	}
	for(int q=1;q<=z;q++)
	{
		for(int w=1;w<=x;w++)
		{
			if(q==1 && w==1)
			ans[q][w]=1;
			else
			{
				if(q-1>=1 && asd[q-1][w]=='.')ans[q][w]=((ans[q][w]%mod)+(ans[q-1][w]%mod))%mod;
				if(w-1>=1 && asd[q][w-1]=='.')ans[q][w]=((ans[q][w]%mod)+(ans[q][w-1]%mod))%mod;
			}
		}
	}
	cout<<ans[z][x]<<endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
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;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};



#define pb push_back
#define F first
#define S second
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define gap ' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///

 int main()
 { ll x;
 cin>>x;
 if(x==0)cout<<"1"<<endl;
 else if(x==1)cout<<"0"<<endl;

 return 0;


}


///Thanking you by Roxy





Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	set<int> a;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		a.insert(x);
	}

	println(a.size());
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-b)<=d && abs(b-c)<=d)||(abs(a-c)<=d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {

    	Scanner s = new Scanner(System.in);
    	String zString = s.next();
    	int n = zString.length();
    	if (o(zString) && o(zString.substring(0, (n - 1) / 2)) && o(zString.substring((n+3)/2 - 1))) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    	}
   static boolean o(String s) {
    	return new StringBuilder(s).reverse().toString().equals(s);
    }

    }


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
const int N=2050,mod=924844033;
int n,m,k,ans,jc[N]= {1},f[N*2][N][2];
bool ed[N],vis[N][2];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1; i<=n; i++)
		for(int j=0; j<2; j++)
			if(!vis[i][j])
			{
				int cnt=0;
				for(int x=i,y=j; x<=n; x+=k,y^=1)
				{
					cnt++;
					vis[x][y]=true;
				}
				m+=cnt;
				ed[m]=true;
			}
	f[1][0][0]=1;
	for(int i=1; i<=m; i++)
		for(int j=0; j<=n; j++)
		{
			f[i+1][j][0]=f[i][j][0]+f[i][j][1]<mod?f[i][j][0]+f[i][j][1]:f[i][j][0]+f[i][j][1]-mod;
			if(!ed[i])
				f[i+1][j+1][1]=f[i][j][0];
		}
	for(int i=1; i<=n; i++)
		jc[i]=1LL*jc[i-1]*i%mod;
	ans=jc[n];
	for(int i=1; i<=n; i++)
		if(i&1)
			ans=(ans-1LL*(f[m][i][0]+f[m][i][1])%mod*jc[n-i]%mod+mod)%mod;
		else
			ans=(ans+1LL*(f[m][i][0]+f[m][i][1])%mod*jc[n-i]%mod)%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int MAX_N = 105;

int sums[4][MAX_N];
vector< int > values[4];

int calc_value(int cnt, int w) {
	return sums[w][values[w].size() - cnt];
}

int main() {
	int n, w;
	scanf(" %d %d", &n, &w);
	
	int delta;
	for(int i = 0; i < n; i++) {
		int weight, value;
		scanf(" %d %d", &weight, &value);
		
		if(i == 0) {
			delta = weight;
		}

		values[weight - delta].pb(value);
	}

	for(int i = 0; i <= 3; i++) {
		sort(values[i].begin(), values[i].end());

		sums[i][values[i].size()] = 0;
		for(int j = values[i].size() - 1; j >= 0; j--) {
			sums[i][j] = sums[i][j + 1] + values[i][j];
		}
	}
	
	int ans = 0;
	for(int a = 0; a <= values[0].size(); a++) {
		for(int b = 0; b <= values[1].size(); b++) {
			for(int c = 0; c <= values[2].size(); c++) {
				for(int d = 0; d <= values[3].size(); d++) {
					if(1ll * delta * a + 1ll * (delta + 1) * b + 1ll * (delta + 2) * c + 1ll * (delta + 3) * d <= 1ll * w) {
						ans = max(ans, calc_value(a, 0) + calc_value(b, 1) + calc_value(c, 2) + calc_value(d, 3));
					}
				}
			}	
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

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

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

#define gc getchar_unlocked
inline void getll(ll &x){
  int sgn=1;x=0;
  char c=gc();
  while(c!='-'&&(c<'0'||c>'9'))c=gc();
  if(c=='-') sgn=-1; else x=c-'0';
  c=gc();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=gc();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
// inline void read(char *s){char *t=s;char c;while((c=gc())==' '||c=='\n');while(c!=' '&&c!='\n'){*t++=c;c=gc();}}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int n,a,b;
char s[125252];
int main(){
  read(n,a,b,s);
  REP(i,n){
    if(s[i]=='a'){
      if(a+b>0){
        puts("Yes");
        --a;
      }else{
        puts("No");
      }
    }else if(s[i]=='b'){
      if(a+b>0 && b>0){
        puts("Yes");
        --b;
      }else{
        puts("No");
      }
    }else{
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        
        if (a <= 9) {
            System.out.println(a);
        } else if (10 <= a && a <= 99) {
            System.out.println(9);
        } else if (100 <= a && a <= 999) {
            System.out.println(a - 99 + 9);
        } else if (1000 <= a && a <= 9999) {
            System.out.println(909);
        } else if (10000 <= a && a <= 99999) {
            System.out.println(a - 9999 + 909);
        } else {
            System.out.println(90909);
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M, Q;
vector<P> G[100][2];
int dist[100][100][2];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> M >> N) {
    if (M == 0 && N == 0) break;
    rep(i, N) rep(k, 2) G[i][k].clear();
    rep(i, N) rep(j, N) rep(k, 2) dist[i][j][k] = INF;
    rep(i, M) {
      int a, b, c, t;
      cin >> a >> b >> c >> t;
      a--, b--;
      G[a][0].pb(P(b, c));
      G[b][0].pb(P(a, c));
      G[a][1].pb(P(b, t));
      G[b][1].pb(P(a, t));
    }
    rep(k, 2) {
      rep(s, N) {
        priority_queue<P, vector<P>, greater<P> > q;
        dist[s][s][k] = 0;
        q.push(P(0, s));

        while (!q.empty()) {
          int x = q.top()._2, r = q.top()._1;
          q.pop();
          if (dist[s][x][k] < r) continue;
          for (P p : G[x][k]) {
            int t = p._1, l = p._2;
            if (dist[s][t][k] > r+l) {
              dist[s][t][k] = r+l;
              q.push(P(r+l, t));
            }
          }
        }
      }
    }
    cin >> Q;
    rep(i, Q) {
      int p, q, r;
      cin >> p >> q >> r;
      p--, q--;
      cout << dist[p][q][r] << "\n";
    }
  }
  return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> X(m);
  for(int i = 0;i < m;i++){
    cin >> X.at(i);
  }
  vector<int> x(m-1);
  sort(X.begin(),X.end());
  for(int i = 0;i < X.size()-1;i++){
    x.at(i) = X.at(i+1) - X.at(i);
  }

  sort(x.begin(),x.end());
    
  if(n >= m){
    cout << 0 << endl;
  }else{
	int ans = 0;
    for(int i = 0;i < m-n;i++){
      ans += x.at(i);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int N,W;
  cin >> N >> W;
  int v[100],w[1000];
  for(int i=0;i<N;i++){
    cin >> v[i] >> w[i];
  }
  int DP[N+1][W+1];

  for(int j=0;j<=W;j++){
    DP[0][j] = 0;
  }

  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j] = DP[i-1][j];
      }
      else{
        if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
          DP[i][j] = DP[i-1][j];
        }
        else{
          DP[i][j] = DP[i-1][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout << DP[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7032
#include <iostream>
using namespace std;
int N,C,D[31][31],c,X[3][31];
long long ans=1e18,num;
int main(){
    cin>>N>>C;
    for(int i=1;i<=C;i++)for(int j=1;j<=C;j++)cin>>D[i][j];
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>c,X[(i+j)%3][c]++;
    for(int i=1;i<=C;i++){
        for(int j=1;j<=C;j++){
            if(i==j)continue;
            for(int k=1;k<=C;k++){
                if(i==k||j==k)continue;
                int Y[3]={i,j,k};
                num=0;
                for(int a=0;a<3;a++){
                    for(int b=1;b<=C;b++){
                        num+=D[b][Y[a]]*X[a][b];
                    }
                }
                ans=min(ans,num);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    for i in range(1, N):
        if A[i - 1] > A[i]:
            return "No"
        elif A[i] != A[i - 1]:
            A[i] -= 1
    return "Yes"
print(main())


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

int main()
{
	int N, K, l[50];

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	sort(l, l+N, greater<int>());

	int length = 0;
	for (int i = 0; i < K; i++) {
		length += l[i];
	}
	cout << length << endl;
	return 0;
}

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

int main() {

    int N,cnt=0;
    cin >> N;
    vector<pair<int,int>>A(N);
    for (int i = 0; i < N; i++) {
      cin >> A.at(i).first>>A.at(i).second;
                                 A.at(i).first+=A.at(i).second;
                                 A.at(i).second=(A.at(i).first-2*A.at(i).second); }
  sort(A.begin(),A.end());
  int i=0;
  int tmp;
  while(i<N-1){
    tmp=i;
    while(A.at(tmp).first>A.at(i+1).second){i++;cnt++;if(i==N-1)goto end;}
    i++;
  }
  end :     cout<<N-cnt<<endl;

}
    

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if (H == 0 && W == 0) { break; }
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ( (i+j)%2==0 ) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					
				}
				System.out.println();
			}
			System.out.println();

		}
		
		sc.close();
	}
}



Measured memory_bytes: 33128
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, a[100000], b[100000], c[100000], dp[100000][3];
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i=1; i<n; ++i) {
		dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
		dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
		dp[i][2] = max(dp[i-1][1]+c[i], dp[i-1][0]+c[i]);
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << '\n';
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        //cout<<(int(i*1.08))<<" ";

        if(int(i*1.08) == n)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<":(";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int N=200005;
bool a[N*2];
char s[N];
int main(){
	int n,k;
	scanf("%d%d\n%s",&n,&k,s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'A';
	int l=1,r=n,t=0;
	for (;k && l<=n;k--)
		if (a[l]^t) l++,a[++r]=(t^=1);
			else a[l]^=1;
	if (k&1 && n&1) a[l]^=1;
	for (int i=l;i<=r;i++) printf("%c",'A'+(a[i]^t));
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;
 
int main() {
	int N,K;
  	cin >> N >> K;
  	vi l(N);
  	rep(i,N) cin >> l[i];
	sort(l);
  	riverse(l);
  	int ans = 0;
  	rep(i,K)ans += l[i];
  	cout << ans << endl;
}

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

int main() {
int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y;
  cin >> x >> y;
  cout <<(a[x] == a[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    for(int u=0;u<n;u++){
        cin>>s;
        bool a=true,b=true;
        if(s[0]!='>'||s.size()%2!=0||s.size()<6)a=false,b=false;
        if(s[1]!='\''||s[s.size()-1]!='~')a=false;
        if(s[1]!='^'||s[s.size()-1]!='~'||s[s.size()-2]!='~')b=false;
        if(a){
            if(s[s.size()/2]!='#')a=false;
            int count=0;
            for(int i=2;i<s.size()-1;i++)if(s[i]!='=')count++;
            if(count!=1)a=false;
            if(a)cout<<"A"<<endl;
        }
        if(b){
            for(int i=2;i<s.size()-2;i++){
                if(i%2==0&&s[i]!='Q')b=false;
                if(i%2==1&&s[i]!='=')b=false;
            }
            if(b)cout<<"B"<<endl;
        }
        if(!a&&!b)cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f)
    {
        double y = (c*d - a*f) / (b*d - a*e);
        double x = (c - b*y) / a;
        printf("%.3lf %.3lf\n", x, y);
    }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  sort(v.begin(), v.end());
  vector<int> vs(n, 0);
  for (int i = 1; i < n; i++) {
    vs.at(i) = v.at(i) - v.at(i - 1);
  }

  vector<int> vr(n);
  for (int i = 1; i < n; i++) {
    vr.at(i) = vr.at(i - 1) + vs.at(i);
  }
  int ans = 1000000000;
  int p = -1;
  for (int i = 0; i < n - k + 1; i++) {
    int tmp = vr.at(i + k - 1) - vr.at(i);
    if (ans > tmp) {
        ans = tmp;
        p = i;
    }
  }

  cout << v.at(p + k - 1) - v.at(p) << endl;

}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  int n,x,y,b,p,total1,total2;
  cin >> n;
  for(int t=0;t<n;t++){
    cin >> x >> y >> b >> p;

    int ret = 100000000;
    for(int i=b;i<10;i++){
      int foo = x * i;
      for(int j=p;j<10;j++){
	int foo2 = foo + y * j;
	if(i>=5&&j>=2)foo2 *= 0.8;
	if(ret > foo2) ret = foo2;
      }
    }
    cout << ret << endl;
  }
}

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

int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;
    for (int r = 0; r <= N / R; r++)
    {
        for (int g = 0; g <= (N - R * r) / G; g++)
        {
            if ((N - R * r - G * g) % B == 0)
            {
                res++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
/*input
SUN
*/
/**
    Author: Kristopher Paul
    Date Created: 23-11-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    map<string,int> cnt;
    cnt["SUN"] = 1;
    cnt["MON"] = 2;
    cnt["TUE"] = 3;
    cnt["WED"] = 4;
    cnt["THU"] = 5;
    cnt["FRI"] = 6;
    cnt["SAT"] = 7;
    int v = cnt[s];
    cout << 8-v << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    ll rn = 0;
    ll rg = 0;
    ll rb = 0;

    for(int i=0; i<N; i++){
        if(S[i] == 'R') rn++;
        if(S[i] == 'G') rg++;
        if(S[i] == 'B') rb++;
    }

    ll ans = rn * rg * rb;

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int k = j + (j - i);
            if(k >= N) continue;

            if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k]){
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long long int n; cin>>n;
    long long int init=100;
    int c=0;
    while(init<n){
        init=init+(init/100);
        c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 3648