akhauriyash/Code-Regression huggingface dataset:
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;

// defines
#define int long long
typedef long long ll;
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define debug(x) cout << #x << " = " << (x) << endl
#define debug2(x, y) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<< endl
#define debug3(x, y, z) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

//permanent constants
const long long INF64 = 1e18; const int INF32 = 1e9; const int BIG = (int)(1e9 + 239);
const int MOD = 998244353; //1e9 + 7;  const ll MOD2 = (ll)MOD * (ll)MOD;
const double PI = 2.0*acos(0.0); //acos(-1.0L);
const double EPS = static_cast<double>(1e-10);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0};
//const ll INF = (ll)(1e18 + 239);

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO()   {freopen("in.txt", "w", stdout);}
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

void solve() {
	int n; cin >> n;
	if(n==1) {cout << 1 << endl; return;}
	int k = floor(log10(n))+1; // so chu so cua n
	
//	debug(k);
	
	int ans = 0;
	FORE(i, 1, k-1) {if(i%2==1) ans += (int)pow(10, i)-(int)pow(10, i-1);
	
//	debug3(i, ans, (int)pow(10, i-1));
	
	}
	if(k%2==1) ans += n-(int)pow(10, k-1)+1;
	
//	debug3(k, (int)pow(10, k-1), ans);
	
	cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//  int test = 0;
//  int t; cin >> t;
//  while(t--)
  {
//	  cout << "Case " << ++test << ": ";
	  solve();
  }

//  auto endProgram = chrono::steady_clock::now();
//  cout << chrono::duration_cast<chrono::milliseconds>(endProgram - beginProgram).count() << " ms" << endl;

  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define mp make_pair
    #define pb push_back
    #define CLEAR(a) memset(a,0,sizeof a)
    #define REP(i,n) for(int i=0;i<n;i++)
    #define FOR(i,a,b) for(int i=a;i<=b;i++)
    #define fr freopen("input.txt", "r", stdin);
    #define fw freopen("output.txt", "w", stdout);
    #define int long long 
    typedef long long LL;
    typedef pair<int,int> pii;
    const int MOD = 1e9 + 7;
    const int MAX = 1e5 + 5;
    int a[MAX], b[MAX];
     
     main() {
        int n;
        cin >> n;
        REP(i, n) cin >> a[i] >> b[i];
        int ret = 0;
        for(int i=n-1;i>=0;i--){
          a[i] += ret;
          if(a[i]%b[i] == 0) continue;
          ret += b[i] - a[i]%b[i];
        }
        cout << ret <<"\n";
        return 0;
    }

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int cnt=0;
  for(i=0;i<n;i++){
    int j=i+1;
    while(j<n && a[i]==a[j]) j++;
    if(j==n){
      cnt++;
      break;
    }
    if(a[j]>a[i]){
      while(j<n && a[j-1]<=a[j]) j++;
    } else {
      while(j<n && a[j-1]>=a[j]) j++;
    }
    i=j-1;
    cnt++;
  }
  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    int f = (x[0]+y[0])&1;
    rep(i, n){
        if(((x[i]+y[i])&1) != f) {cout << -1 << endl; return 0;}
        if(!f) x[i]--;
    }
    vll d(1, 0);
    repr(i, 1, 32){
        d.emplace_back(powint(2, i-1));
    }
    if(f){
        cout << 31 << endl;
        repr(i, 1, 32){
            cout << d[i] << (i+1==32?"\n":" ");
        }
    }else{
        cout << 32 << endl;
        repr(i, 1, 32){
            cout << d[i] << " ";
        }
        cout << 1 << endl;
    }
    rep(i, n){
        ll U_i = x[i] + y[i];
        ll V_i = x[i] - y[i];
        repr(j, 1, 32){
            int a = ((U_i + powint(2, 31) - 1) >> (j))&1;
            int b = ((V_i + powint(2, 31) - 1) >> (j))&1;
            if(a && b) cout << 'R';
            if(a && !b) cout << 'U';
            if(!a && b) cout << 'D';
            if(!a && !b) cout << 'L';
        }
        if(!f) cout << 'R';
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int list[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << list[k - 1] << endl;

  return 0;
}


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

vector<string> jfen2table(const string &jfen) {
    string jeffen = jfen + "/";
    vector<string> table;
    string q;
    for (const char &c : jeffen) {
        if (c == '/') {
            table.push_back(q);
            q = "";
        } else if (c == 'b') {
            q += 'b';
        } else {
            q += string(c - '0', '.');
        }
    }
    return table;
}

string table2jfen(const vector<string> &table) {
    string jfen = "";
    for (const string &line : table) {
        for (const char &c : line) {
            if (c == '.') {
                if (!jfen.empty() && '1' <= jfen.back() && jfen.back() < '9') {
                    jfen.back()++;
                } else {
                    jfen += "1";
                }
            } else {
                jfen += "b";
            }
        }
        jfen += "/";
    }
    jfen.pop_back();
    return jfen;
}

int main() {

    string ans = "";

    for (string s; cin >> s, (s != "#"); ) {

        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;

        auto tbl = jfen2table(s);
        tbl[a][b] = '.';
        tbl[c][d] = 'b';

        ans += table2jfen(tbl);
        ans += "\n";

    }

    cout << ans;

}


Measured memory_bytes: 3184
N = int(input())
H = list(map(int, input().split()))

dp = [0]*N

dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] =  min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))

print(dp[N-1])

Measured memory_bytes: 13928
N = int(input())
Pi = []
for i in range(N):
    d = list(map(int, input().split()))
    Pi.append(d)
 
# validation
for p in Pi[1:]:
    if (p[0] + p[1]) % 2 != (Pi[0][0] + Pi[0][1]) % 2:
        print(-1)
        exit()
 
# create arms
Ai = []
if (Pi[0][0] + Pi[0][1]) % 2 == 0:
    Ai.append(1)
for i in range(0, 32):
    Ai.append(2 ** i)
 
def find_arm_pattern(arms, target_x, target_y):
    result = ""
    x = 0
    y = 0
    for a in arms:
        dx = target_x - x
        dy = target_y - y
        if abs(dx) >= abs(dy):
            if dx > 0:
                result += "R"
                x += a
            else:
                result += "L"
                x -= a
        else:
            if dy > 0:
                result += "U"
                y += a
            else:
                result += "D"
                y -= a
    if x == target_x and y == target_y:
        return result
    return None
 
 
arms = list(reversed(Ai))
results = []
for p in Pi:
    r = find_arm_pattern(arms, p[0], p[1])
    results.append(r)
txt = str(arms)
print(len(arms))
print(txt[1:-1].replace(",", ""))
for r in results:
    print(r)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
int main(){
    iosetup;
    int N; cin >> N;
    vector<int> p(N+1);
    rep(i, 1, N + 1) cin >> p[i];
    int ans = 0;
    rep(i, 1, N + 1){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> sunuke(n,0);
  for(int i=0; i<k; i++){
    int d;
    cin>>d;
    for(int i=0; i<d; i++){
      int a;
      cin>>a;
      sunuke.at(a-1)++;
    }
  }
  int ans=0;
  for(int i=0; i<n; i++){
    if(sunuke.at(i)==0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
    int N; cin>>N;
    int now, last = 0;
    unsigned long long res = 0;
    while(N--) {
        cin>>now;
        if (now<last) {
            res += last-now;
            now += last-now;
        }
        last = now;
    }
    cout<<res<<endl;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	string s ;
	cin >> s;
	if(n%2==1)cout <<"No";
	else{
		int i;
		for(i=0;i<n/2;i++){
			if(s[i]!=s[i+n/2])break;
		}
		if(i==n/2)cout<<"Yes";
		else cout << "No";
		
		
	}
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<int> l(q), r(q);
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
		l[i]--, r[i]--;
	}
	vector<int> cnt(n);
	for (int i = 1; i < n; i++) {
		cnt[i] = cnt[i - 1];
		if ((i < n) && s[i - 1] == 'A' && s[i] == 'C')
			cnt[i]++;
	}

	// for (auto e : cnt)
	// 	cout << e << " ";

	for (int i = 0; i < q; i++) {
		cout << cnt[r[i]] - cnt[l[i]] << "\n";
	}

}

Measured memory_bytes: 2256
#include<bits/stdc++.h>
using namespace std;
int c[3][3];
int main()
{
	int i,j,s=0,f=0;
	for(i=0;i<=2;i++)
	  for(j=0;j<3;j++)
	  {
	  	cin>>c[i][j];
	  	s+=c[i][j];
	  }
	if(s%3!=0) 
	{cout<<"No";
	return 0;
	}
	if(c[0][2]-c[0][1]==c[1][2]-c[1][1] && c[1][2]-c[1][1]==c[2][2]-c[2][1]) ;
	else f=1;
	if(c[0][1]-c[0][0]==c[1][1]-c[1][0]&&c[1][1]-c[1][0]==c[2][1]-c[2][0]) ;
	else f=1;
	
	if(c[2][0]-c[1][0]==c[2][1]-c[1][1]&&c[2][1]-c[1][1]==c[2][2]-c[1][2]) ;
	else f=1;
	if(c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][1]-c[0][1]==c[1][2]-c[0][2]) ;
	else f=1;
	
	if(f==1) cout<<"No";
	else cout<<"Yes";
	return 0;
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return acos(-1.0);
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	string ss,ans;
	int r=0;
	while(cin>>ss){
		int e=size(ss);
		for(int i=0;i<e;i++){
			if(ss[i]=='@'){
				for(int x=0;x<10;x++){
					if(ss[i+1]=='0'+x){
						r=x;
						break;
					}
				}
				for(int x=0;x<r;x++){
					cout<<ss[i+2];
				}
				i+=2;
			}
			else{
				cout<<ss[i];
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1172
n,m,k = map(int,input().split())
l = []
for i in range(n,n+k):
    if n <= i <= m:
        l.append(i)
for i in range(m,m-k,-1):
    if n <= i <= m:
        l.append(i)
l = sorted(set(l))
for i in range(len(l)):
    print(l[i])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define mst(a, b) memset(a, b, sizeof(a))
#define X first
#define Y second
#define lowbit(x) (x&(-x))
const int maxn = 100+10;
const int maxm = 10000+10;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
//int sg[maxn][maxn];
//int get_sg(int x,int y){
//    if (x>y) swap(x,y);
//    if (~sg[x][y]) return sg[x][y];
//    bool f[100]={0};
//    for (int i=2;i<=x;i+=2){
//        f[get_sg(x-i,y+i/2)]=true;
//    }
//    for (int i=2;i<=y;i+=2){
//        f[get_sg(x+i/2,y-i)]=true;
//    }
//    for (int i=0;;i++) if (!f[i]) return i;
//}
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
//    mst(sg,-1);
//    int n=10;
//    for (int i=0;i<=n;i++) for (int j=i;j<=n;j++){
//        cout<<i<<" "<<j<<" "<<get_sg(i,j)<<"\n";
//    }
    ll x,y; cin>>x>>y;
    if (x>y) swap(x,y);
    if (x==y || x+1==y) cout<<"Brown\n"; else cout<<"Alice\n";
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n, a[2000];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("bst.in", "r", stdin);
	//freopen("bst.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			int pos = lower_bound(a, a + n, a[i] + a[j]) - a - 1;
			ans += max(0, pos - j);
		}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            print(i, j, N-i-j)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)


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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)	
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

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

	int n, m;

	cin >> n >> m;

	vi v(n);
	rep(i, n) cin >> v[i];

	ll sum = accumulate(begin(v), end(v), 0LL);
	int cnt = 0;
	for (auto e : v) cnt += 4 * m * e >= sum;

	cout << (cnt >= m ? "Yes\n" : "No\n");


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

#include <random>
vector<int> edg[100003];
bool used[100003];
int deg[100003];
vector<int> ans;
random_device rnd;
mt19937 mt(rnd());

bool func(int start, int pos) {
	for (int i = 0; i < (int)edg[pos].size(); ++i) --deg[edg[pos][i]];

	if (deg[start] == 0 && deg[pos] == 0) {
		ans.push_back(pos);
		return true;
	}
	used[pos] = true;
	for (int i = 0; i < (int)edg[pos].size(); ++i) {
		if (used[edg[pos][i]]) continue;
		if (func(start, edg[pos][i])) {
			ans.push_back(pos);
			return true;
		}
	}
	used[pos] = false;
	for (int i = 0; i < (int)edg[pos].size(); ++i) ++deg[edg[pos][i]];
	return false;
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		edg[a].push_back(b);
		edg[b].push_back(a);
		++deg[a]; ++deg[b];
	}
	set<int> s;
	int pos;
	do {
		do {
			pos = mt() % n;
		} while (s.count(pos));
		s.insert(pos);
	} while (!func(pos, pos));
	cout << ans.size() << endl;
	for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 << (i == 0 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 10624
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 3050, MOD = 998244353;

int n,k;
int a[N];
ll dp[N][N];

ll go(int id, int rem){
	ll &ans = dp[id][rem];
	if(ans != -1) return ans;
	if(rem == 0) return ans = n-id+1;
	if(id == n) return ans = 0;
	ans = go(id+1,rem);
	if(rem-a[id] >= 0) ans = (ans + go(id+1,rem-a[id])) % MOD;
	return ans;
}

int main(){

	fastio;
	cin >> n >> k;
	REP(i,0,n) cin >> a[i];

	ll ans = 0;
	fill(dp,-1);
	for(int i = 0; i < n; ++i){
		if(k-a[i] >= 0){
			ans = (ans + ((go(i+1,k-a[i])*(i+1))%MOD)) % MOD;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 73088
#include <bits/stdc++.h>
using namespace std;
int main() {
     int n; cin >> n;
     string s; cin >> s;
     int ans = 0;
     for(int i = 1; i < n; i++){
          int cnt = 0;
          for(char c = 'a'; c <= 'z'; c++){
               bool left = false, right = false;
               for(int j = 0; j < i; j++){
                    if(s[j] == c) left = true;
               }
               for(int j = i; j < n; j++){
                    if(s[j] == c) right = true;
               }
               if(left && right) cnt++;
          }
          if(ans < cnt) ans = cnt;
     }
     cout << ans << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n; 
	vector<int> v;
	v.push_back(1);
	v.push_back(1);
	for (int i = 2; i <= n; i++) v.push_back(v[i - 1] + v[i - 2]);
	cout << v[n] << endl;
}

Measured memory_bytes: 3156
#include<cctype>
#include<stdio.h>
#include<cstdio>
using namespace std;
int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if('a'<=ch && ch<='z'){
            printf("%c",ch-32);
        }else if('A'<=ch && ch<='Z'){
            printf("%c",ch+32);  
        }else {
            printf("%c",ch);
        }
        if ( ch == '\n' ) break;
    }
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(ll i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    //解は[l,r]に存在
    ll l = -1e18, r = 1e18;
    while(l < r){
        ll n = (l+r)/2;
      	if(l+r < 0 && 2*n != l+r) n--;
        //n以下になるものが何個あるか判定
        ll sum = 0;
        rep(i, N){
            if(A[i] < 0){
                ll x = n/A[i];
                rep2(j, x-1, x+1){
                    if(A[i]*j <= n){
                        sum += A+N - lower_bound(A, A+N, j);
                        break;
                    }
                }
            }
            elif(A[i] == 0){
                if(n >= 0) sum += N;
            }
            else{
                ll x = n/A[i];
                rep3(j, x+1, x-1){
                    if(A[i]*j <= n){
                        sum += N-(A+N - lower_bound(A, A+N, j+1));
                        break;
                    }
                }
            }
            if(A[i]*A[i] <= n) sum--;
        }
        sum /= 2;
        if(sum < K) l = n+1;
        else r = n;
    }
    cout << l << endl;
}

Measured memory_bytes: 1792
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int x[110][110];
int main(){
	int a;scanf("%d",&a);
	if(a==2){
		printf("-1\n");return 0;
	}else if(a%2){
		for(int i=0;i<a;i++){
			for(int j=0;j<a-1;j++){
				x[i][j]=(i+j+1)%a;
			}
		}
	}else{
		for(int i=0;i<a;i++){
			if(i<a/2){
				x[i][0]=i+a/2;
				x[i][1]=(i+1)%a;
			}else{
				x[i][1]=i-a/2;
				x[i][0]=(i+1)%a;
			}
			int t=1;
			for(int j=2;j<a-1;j++){
				t++;
				if(t==a/2)t++;
				x[i][j]=(i+t)%a;
			}
		}
	}

	for(int i=0;i<a;i++){
		for(int j=0;j<a-1;j++){
			if(j)printf(" ");
			printf("%d",x[i][j]+1);
		}
		printf("\n");
	}
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int nums[] = new int[n];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}

		boolean result = true;

		for (int i = 0; i < n; i++) {
			int before = 0;
			if (i != 0) {
				before = nums[i - 1];
			}
			if (nums[i] < before) {
				result = false;
				break;
			}
			if (nums[i] != before) {
				nums[i]--;
			}
		}

		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 50728
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        index = bisect.bisect_right(L, L[i] + L[j]-1)
        ans += index - j - 1

print(ans)





Measured memory_bytes: 3188
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [n, m] <- readInts
  edges <- fmap concat $ replicateM m $ do
    [a, b] <- readInts
    return [(a-1, b-1), (b-1, a-1)]
  let graph = createGraph n edges
  print $ solve n graph

type Graph = [[Int]]

createGraph :: Int -> [(Int, Int)] -> Graph
createGraph n edges = foldr (uncurry updateGraph) (replicate n []) edges
  where updateGraph i v graph = concat [take i graph, [v : (graph !! i)], drop (i+1) graph]

solve :: Int -> Graph -> Int
solve n graph = dfs 0 1 [0]
  where dfs i depth visited
          | depth == n = 1
        dfs i depth visited
          | nexts == [] = 0
          | otherwise = sum $ flip map nexts $ \w -> dfs w (depth+1) (w:visited)
            where nexts = filter (not . (`elem` visited)) $ graph !! i

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#include<deque>
#define itn int
#define coder goodboy
using namespace std;
typedef long long LL;typedef unsigned long long ULL;
string a,b,c;
int Main(){
	cin>>a;cin>>b;cin>>c;
	//cout<<a<<" "<<b<<" "<<c<<endl;
	int lena=a.size(),lenb=b.size(),lenc=c.size();
	//printf("%c %c",a[lena-1],b[0]);
	if (a[lena-1]==b[0]&&b[lenb-1]==c[0]){
		puts("YES");
	}
	else puts("NO");
	return 0;
}
int main(){;}
int goodboy=Main();

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

using namespace std;

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

	string s;
	int c = 0;

	cin >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == '1')
			c++;
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <math.h>
using namespace std;
#define MAX 100000

long long int M[MAX+1];
long long int L[MAX+1];
long long int R[MAX+1];
int N;

int main() {
  priority_queue<int, std::vector<int>, std::greater<int> > lq;
  priority_queue<int> rq;
  cin >> N;
  for (int i = 0; i < 3*N; i++) {
    int a;
    cin >> a;
    if (i < N) {
      lq.push(a);
      L[0] += a;
    } else if (i >= N && i < 2*N) {
      M[i-N] = a;
    } else {
      rq.push(a);
      R[0] += a;
    }
  }

  for (int i = 0; i < N; i++) {
    lq.push(M[i]);
    L[i+1] = L[i] - lq.top() + M[i];
    lq.pop();
  }

  for (int i = 0; i < N; i++) {
    rq.push(M[N-i-1]);
    R[i+1] = R[i] - rq.top() + M[N-i-1];
    rq.pop();
  }

  long long int maxv = L[0] - R[N];
  for (int i = 1; i <= N; i++) {
    maxv = max(maxv, (L[i] - R[N - i]));
  }
  cout << maxv << endl;
}


Measured memory_bytes: 3448
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

typedef pair<double,double>vec;

vec operator + (vec v1,vec v2){
    return make_pair(v1.first+v2.first,v1.second+v2.second);
}
vec operator - (vec v1,vec v2){
    return make_pair(v1.first-v2.first,v1.second-v2.second);
}
vec operator * (double v,vec v2){
    return make_pair(v*v2.first,v*v2.second);
}
vec operator / (vec v1,double d){
    return make_pair(v1.first/d,v1.second/d);
}

double norm2(vec v1,vec v2){
    return (v1-v2).first*(v1-v2).first+(v1-v2).second*(v1-v2).second;
}

int main(){
    double x1,x2,x3,y1,y2,y3,n,r;
    cin>>n;
    while(n--){
        cin>>x1>>y1>>x2>>y2>>x3>>y3;
        vec A = make_pair(x1,y1);
        vec B = make_pair(x2,y2);
        vec C = make_pair(x3,y3);
        double a2,b2,c2,a,b,c,cosA,cosB,cosC,sinA,sinB,sinC,cos2A,cos2B,cos2C,sin2A,sin2B,sin2C;
        a2=norm2(B,C);
        b2=norm2(A,C);
        c2=norm2(A,B);
        a=sqrt(a2);
        b=sqrt(b2);
        c=sqrt(c2);
        cosA=(b2+c2-a2)/(2*b*c);
        cosB=(a2+c2-b2)/(2*c*a);
        cosC=(b2+a2-c2)/(2*b*a);
        sinA=sqrt(1-cosA*cosA);
        sinB=sqrt(1-cosB*cosB);
        sinC=sqrt(1-cosC*cosC);
        r=(a/sinA)/2;
        cos2A=cosA*cosA-sinA*sinA;
        cos2B=cosB*cosB-sinB*sinB;
        cos2C=cosC*cosC-sinC*sinC;
        sin2A=2*sinA*cosA;
        sin2B=2*sinB*cosB;
        sin2C=2*sinC*cosC;
        
        vec v=(sin2A*A+sin2B*B+sin2C*C)/(sin2A+sin2B+sin2C);
        printf("%.3f %.3f %.3f\n",v.first,v.second,r);
    }
    

}

Measured memory_bytes: 1240
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int n; cin >> n;
	vector<string> s(n);
	int x[50][50] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].size(); j++) {
			int y = s[i][j];
			x[i][y-'a']++;
		}
	}

	vector<int> mi(30, 10000);
	for (int i = 0; i <='z'-'a'; i++) {
		for (int j = 0; j < n; j++) {
			mi[i] = min(mi[i], x[j][i]);
		}
	}
	string ans;
	for (int i = 0; i <= 'z'-'a'; i++) {
		for (int j = 0; j < mi[i]; j++) {
			ans.push_back((char)(i+'a'));
		}
	}
	cout << ans << endl;
}



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

int getRatedContest(int x_r) {
    if (x_r < 1200) {
        return 0;
    } else if (x_r < 2800) {
        return 1;
    } else {
        return 2;
    }
}
int main(void) {
    int r;
    const string contest[3] = {"ABC", "ARC", "AGC"};

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> r;
    cout << contest[getRatedContest(r)] << "\n";
    return 0;
}

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

int main(void) {
    int N;cin>>N;
    vector<int> score;
    for (int i = 0; i < N; i++) {
        int d;cin>>d;
        score.push_back(d);
    }
    sort(score.begin(), score.end());
    if (N % 2 != 0) cout << 0 << endl;
    else {
        int lower_index = N / 2 - 1;
        int uppper_index = N / 2;
        cout << score.at(uppper_index) - score.at(lower_index) << endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include<iostream>

const static int INF = 1001001001;

int main(void){
    int n, p, min, ans = 0;
    min = INF;
    std::cin >> n;
    for(int i = 0; i < n; i++){
	std::cin >> p;
	if(min >= p){
	    min = p;
	    ans++;
	}
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	double W,H,x,y;
	cin>>W>>H>>x>>y;
	cout<<W*H/2<<endl;
	if(W/2==x&&H/2==y)cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N;
    
        
            cout <<N*N <<endl;
        
    

    
    

    return 0;
    
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
constexpr int mod = 1e9+7, MAX = 1e5+30;
int_fast64_t fac[MAX], finv[MAX], inv[MAX];
void cmb_init() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
int_fast64_t cmb(int n, int k){
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
map<int_fast64_t, int> P;
void primef(int_fast64_t n) {
    int_fast64_t tmp = n;
    for (int i = 2; i*i <= n; i++) {
        while (tmp%i == 0) {
            P[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1) P[tmp]++;
}
void Main(){
    int_fast64_t ans = 1;
    int N = read(), M = read();//N 1e5 M 1e9
    primef(M);
    cmb_init();
    for (auto p:P) {
        ans *= cmb(p.second+N-1, p.second);
        ans %= mod;
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


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

int main(){
    vector<int> v;
    for(int i=0;i<3;i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout << v.at(0) << ' ' <<  v.at(1) << ' ' <<  v.at(2) << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';
ll S, S_size;

ll Size(ll S) {
  ll cnt=1;
  while(S/=10) cnt++;
  return cnt;
}

ll cut(ll l,ll r) {
  return (S / (ll)pow(10,S_size-r)) % (ll)pow(10, r-l+1);
}

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

  cin >> S;
  S_size = Size(S);
  
  ll ans=0;
  
  rep(i, 2 << (S_size-2)) {
    ll l=1, r=1;
    for(ll j=S_size-2; j>=0; j--){
      if(i & (1LL << j)) {ans += cut(l, r); r++; l=r;}
      else r++;
    }
    ans += cut(l, r);
  }
  
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(0, N+1):
    for y in range(0, N+1):
        z = N - x - y
        if z < 0:
            continue
        if x + y + z == N and 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit(0)
print(-1, -1, -1)


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

int main(){
    ll n; cin>>n;
    vector<ll> p(n);
    vector<ll> a(n);
    vector<ll> b(n);

    for(int i=0; i<n; i++){
        cin>>p[i]; p[i]--;
    }

    for(int i=0; i<n; i++){
        a[i] = i*M+1;
    }

    for(int i=0; i<n; i++){
        b[i] = (n-i)*M+1;
    }

    for(int i=0; i<n; i++){
        a[p[i]] += i;
    }

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

     for(int i=0; i<n; i++){
        cout<<b[i]<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <algorithm>
#include <complex>

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a + b > c + d)
        printf("Left\n");
    else if (a + b == c + d)
        printf("Balanced\n");
    else
        printf("Right\n");
 
    return 0;
}

Measured memory_bytes: 128
class BinHeap
  def initialize(buf=nil)
    @buf=buf||[nil]
    @max=@buf.size
  end
  def add(n)
#    print :add_s,n
    a=@buf[i=@max]=n
    @max+=1
    while i>1 && a>b=@buf[i/2]
      @buf[i]=b
      i/=2
    end
    @buf[i]=a
#    print :add_e,n
  end
  def get
#    print :get_s
    ret=@buf[1]
    a=@buf[i=1]=@buf[l=@max-=1]
    while (c=i*2)<l
      c+=1 if c+1<l && @buf[c]<@buf[c+1]
      if a<b=@buf[c]
        @buf[i]=b
        i=c
      else
        break
      end
    end
    @buf[i]=a
#    print :get_e,ret
    ret
  end
  def dup
    BinHeap.new(@buf[0..@max-1])
  end
  def buf
    @buf
  end
  def print(*arg)
    p arg*" "
    i=s=1
    while i<@max
      p @buf[i,s]
      i+=s
      s*=2
    end
  end
end

pq=BinHeap.new
while gets
  op,arg = $_.split
  case op
  when "insert"
    pq.add arg.to_i
  when "extract"
    p pq.get
  when "end"
  end
end

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        ll a[n];
        REP(i,0,n)
        {
            ll t;
            cin>>t;
            a[i]=t;
        }
        sort(a,a+n);
        double x=a[0];
        REP(i,1,n)
        {
            x=(a[i]+x)/2;
        }
        printf("%.12f",x);
    }

    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            for (auto d : irange(1L, r + 1L)) {
                auto w = j + d;
                for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                    auto b = c + d;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
    }

    cout << ans % M << "\n";
}


Measured memory_bytes: 3908
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=10005,mod=1000000000+7;
int Add(int a,int b){a+=b; return a>=mod ? a-mod : a;}
int Sub(int a,int b){a-=b; return a>=0 ? a : a+mod;}
int Mul(int a,int b){return 1LL*a*b%mod;}
void add(int &a,int b){a=Add(a,b);}
void sub(int &a,int b){a=Sub(a,b);}
void mul(int &a,int b){a=Mul(a,b);}
int qpow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) mul(ans,a);
		b>>=1;
		mul(a,a);
	}
	return ans;
}
int s,fac[N],inv_fac[N];
int C(int n,int m)
{
	if (n<m) return 0;
	return Mul(fac[n],Mul(inv_fac[n-m],inv_fac[m]));
}
void init()
{
	read(s);
	fac[0]=1;
	for (int i=1;i<=2000;++i) fac[i]=Mul(fac[i-1],i);
	inv_fac[2000]=qpow(fac[2000],mod-2);
	for (int i=1999;i>=0;--i) inv_fac[i]=Mul(inv_fac[i+1],i+1);
}

void solve()
{
	int ans=0;
	for (int i=1;i<=s/3;++i)
	{
		int tmp=s-2*i;
		add(ans,C(tmp-1,i-1));
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	solve();
	return 0;
}


Measured memory_bytes: 3792