akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

bool space[100];
int W,Q;

void fillSpace(int id,int pos,int wid,map<int,P>& data){
	for(int i=pos;i<pos+wid;i++){
		space[i] = true;
	}
	data[id]=P(pos,wid);
}

void eraseSpace(int id,int pos,int wid){
	for(int i=pos;i<pos+wid;i++){
		space[i] = false;
	}
}

bool stay(int id,int wid,map<int,P>& data){
	for(int i=0;i<W;i++){
		bool isok = true;
		if(i+wid > W) isok = false;
		for(int j=i;j<i+wid && j<W;j++){
			if(space[j]) {
				isok = false;
				break;
			}
		}
		if(isok){
			fillSpace(id,i,wid,data);
			printf("%d\n",i);
			return true;
		}
	}

	return false;
}


int main(){
	while(~scanf("%d %d",&W,&Q)){
		if(W==0 && Q==0) break;
		string sw;
		map<int,P> data;
		memset(space,0,sizeof(space));

		for(int i=0;i<Q;i++){
			cin >> sw;
			if(sw == "s"){
				int id,wid;
				scanf("%d %d",&id,&wid);
				if(!stay(id,wid,data)){
					printf("impossible\n");
				}
			}
			else{
				int id;
				scanf("%d",&id);
				eraseSpace(id,data[id].first,data[id].second);
			}
		}
		printf("END\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n, q; cin >> n >> q;
  fenwick_tree<ll> fw(n);
  rep(i,n) {
    int a; cin >> a; fw.add(i, a);
  }
  rep(i,q) {
    int t; cin >> t;
    if (t == 0) {
      int p, x; cin >> p >> x;
      fw.add(p, x);
    } else {
      int l, r; cin >> l >> r;
      pl(fw.sum(l, r));
    }
  }
  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int H,W,h,w;
    while(cin >> H >> W >> h >> w) {
        cout << H*W - H*w - h*W + w*h << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  constexpr int pow[] = {1, 2, 4, 8, 16, 32, 64};

  int N;
  cin >> N;
  int ans = 1;
  for (auto e : pow) {
    if (e <= N)
      ans = e;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, y; cin >> n >> y;
	int a = -1, b = -1, c = -1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int k = n - i - j;
			if (0<=k&&k <= n && 10000 * i + 5000 * j + 1000 * k == y) {
				a = i, b = j, c = k; 
			}
		}
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

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

using namespace std;

int main(){
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<int64_t>> A(r, vector<int64_t>(c));

    for (int i = 0; i < k; i++){
        int a, b, v;
        cin >> a >> b >> v;
        A[--a][--b] = v;
    }

    vector<vector<vector<int64_t>>> DP(r + 1, vector<vector<int64_t>>(c + 1, vector<int64_t>(4)));

    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            for (int k = 0; k <= 3; k++){
                if (k < 3){
                    DP[i][j + 1][k + 1] = max(DP[i][j + 1][k + 1], DP[i][j][k] + A[i][j]);
                    DP[i + 1][j][0] = max(DP[i + 1][j][0], DP[i][j][k] + A[i][j]);
                }
                DP[i + 1][j][0] = max(DP[i + 1][j][0], DP[i][j][k]);
                DP[i][j + 1][k] = max(DP[i][j + 1][k], DP[i][j][k]);
            }
        }
    }

    cout << DP[r][c - 1][0] << endl;

}

Measured memory_bytes: 707156
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL
#define chmax(x , y) (x) = max((x) , (y))

int main() {
	ll		a,b,r,c,d,w,h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	cin >> r >> c >> k;
	vector<vector<ll>> v(r+1 , vector<ll>(c+1));
	for(i=0;i<k;i++) {
		cin >> x >> y;
		cin >> v[x][y];
	}
	vector<vector<vector<ll>>>  dp(r+2, vector<vector<ll>>(c+2, vector<ll>(4)));

	for(i=1;i<=r;i++) {
		for(j=1;j<=c;j++) {
			chmax(dp[i][j][0] , dp[i][j-1][0]);
			chmax(dp[i][j][1] , dp[i][j-1][1]);
			chmax(dp[i][j][2] , dp[i][j-1][2]);
			chmax(dp[i][j][3] , dp[i][j-1][3]);
			if (v[i][j]>0) {
				chmax(dp[i][j][1] , dp[i][j-1][0] + v[i][j]);
				chmax(dp[i][j][2] , dp[i][j-1][1] + v[i][j]);
				chmax(dp[i][j][3] , dp[i][j-1][2] + v[i][j]);
			}
			chmax(dp[i][j][0] , dp[i-1][j][0]);
			chmax(dp[i][j][0] , dp[i-1][j][1]);
			chmax(dp[i][j][0] , dp[i-1][j][2]);
			chmax(dp[i][j][0] , dp[i-1][j][3]);
			if (v[i][j]>0) {
				chmax(dp[i][j][1] , dp[i-1][j][0] + v[i][j]);
				chmax(dp[i][j][1] , dp[i-1][j][1] + v[i][j]);
				chmax(dp[i][j][1] , dp[i-1][j][2] + v[i][j]);
				chmax(dp[i][j][1] , dp[i-1][j][3] + v[i][j]);
			}
		}
	}
	ans = dp[r][c][0];
	chmax(ans , dp[r][c][1]);
	chmax(ans , dp[r][c][2]);
	chmax(ans , dp[r][c][3]);
	cout << ans << endl;
/*
	for(k=0;k<=3;k++) {
		cout << k << ':' << endl;
		for(i=1;i<=r;i++) {
			for(j=1;j<=c;j++) {
				cout << dp[i][j][k] << ' ';
			}
			cout << endl;
		}
	}
*/
	return 0;
}


Measured memory_bytes: 707452
#include <stdio.h>
int main()
{
	int A;
	int B;
	scanf("%d %d",&A,&B);
	if(A==1||B==1)
	{
		if(A==B)printf("Draw");
		else if(A==1)printf("Alice");
		else printf("Bob");
	}
	else
	{
		if(A>B)printf("Alice");
		else if(A<B)printf("Bob");
		else printf("Draw");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define ull unsigned long long int

int main() {

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

    if (n % 2) cout << double(n / 2 + 1) / n << endl;
    else cout << double(0.5) << endl;

    return 0;
}
 

Measured memory_bytes: 256
//https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_b
//B - Path
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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() {
    ll e=3,n=4;
    vector<ll> num(n+1);
    REP(i,e){
        ll a,b; cin>>a>>b;
        num.at(a)++;
        num.at(b)++;
    }
    bool ans=true;
    FOR(i,1,n+1){
        if(num.at(i)>2)ans=false;
    }
    cout<<(ans?"YES":"NO")<<endl;
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    print(0);
  } else if (a <= 12) {
    print(b / 2);
  } else {
    print(b);
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
lst = list(map(int, input().split()))
cst = [float('inf')] * n
cst[0] = 0
for _ in range(0, n):
    m = min(n-(_+1),k)
    for i in range(0, m+1):   
      cst[_+i] = min(cst[_] + abs(lst[_+i] - lst[_]),cst[_+i])
print(cst[n-1])

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

using namespace std;

int main () {

    int N, Q;
    cin >> N >> Q;
    string str;
    cin >> str;

    string AC = "AC";

    int ac[100000];
    int sum[100001];

    for (int j = 0; j < N; ++j) {
        if (str[j] == 'A' && str[j+1]== 'C') {
            ac[j] = 1;
        } else {
            ac[j] = 0;
        }
    }

    sum[0] = 0;
    for (int j = 1; j < N; ++j) {
        sum[j] = sum[j-1] + ac[j-1];
    }


    for(int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << sum[r-1]-sum[l-1] << endl;
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

using plll = pair<ll, pair<ll, ll>>;

int main(){
	int n;
	cin >> n;
	vector<ll> ans(n+1, INFLL);
	vvector<pll> addr(n+1);
	vvector<ll> remover(n+1);
	ans[1] = 0;
	remover[1].emplace_back(0);
	int m;
	cin >> m;
	rep(i, m){
		ll a, b, c;
		cin >> a >> b >> c;
		addr[a].emplace_back(b, c);
	}
	multiset<ll> mul;
	mul.insert(0);
	ll nfast = 0;
	for(int i=1;i<=n;++i){
		if(mul.empty()){
			cout << -1 << endl;
			return 0;
		}
		ll n_time = *mul.begin();
		foreach(j, addr[i]){
			mul.insert(n_time+j.second);
			remover[j.first].emplace_back(n_time+j.second);
		}
		if(i==n){
			if(mul.empty()){
				cout << -1 << endl;
				return 0;
			}
			cout << *mul.begin() << endl;
			return 0;
		}
		foreach(j, remover[i]){
			mul.erase(mul.find(j));
		}
	}

	return 0;
}



Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 400200
#define ll long long int 
using namespace std; 

const ll inf = 3000000000000000000ll;

ll n, a[maxn], up[maxn]; 

int main(){
	scanf("%lld", &n);
	rep(i, 0, n) scanf("%lld", a + i);
	if (!n){	
		if (a[0] == 1) printf("1");
		else printf("-1");
		return 0;
	} 
	up[0] = 1;
	if (up[0] < a[0]) {printf("-1"); return 0;}
	rep(i, 1, n){	
		up[i] = (up[i - 1] << 1) - (a[i - 1] << 1);
		if (up[i] > inf) up[i] = inf;
		if (i == n){
			if (up[i] < a[i]) {printf("-1"); return 0;}
		}
		else {
			if (up[i] <= a[i]) {printf("-1"); return 0;}
		} 
	}
	//rep(i, 0, n) cerr << up[i] << ' ';
	ll ans = 0;
	ll now = a[n];
	ans += now;
	per(i, n - 1, 0){
		now = now + a[i];
		now = min(now, up[i]);
		ans += now;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5392
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int> > vvi;
#define rep(i,n) for (int i=0;i<n;i++)

ll mod = 1e9+7;

int ans = 0;
vvi _ab;
vvi ab;
vector<bool> visit;

void dfs(int pos,int x){
    bool visited = true;
    rep(i,visit.size()){
        if (!visit[i]){
            visited = false;
            break;
        }
    }
    if (visited){
        ans++;
        return;
    }
    rep(i,ab[pos].size()){
        if (_ab[x][0]==pos  && _ab[x][1]==ab[pos][i]) continue;
        if (visit[ab[pos][i]]==true) continue;
        visit[i] = true;
        dfs(ab[pos][i],x);
    }
    return;
}

int main(){
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i=0;i<N;i++) cin >> a[i];
    ll ans = 0;
    for (int i=1;i<N;i++){
        if (a[i]+a[i-1]>x){
            ll eat = (a[i]+a[i-1])-x;
            ans += eat;
            if (eat>a[i]){
                a[i-1] = eat-a[i];
                a[i] = 0;
            } else {
                a[i] -= eat;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[][] range = new int[m][2];
        for(int i=0;i<m;i++){
            range[i][0] = Integer.parseInt(sc.next());
            range[i][1] = Integer.parseInt(sc.next());
        }

        Arrays.sort(range,new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[1] - o2[1];
			}
        });
        int f = 0,ans = 0;
        for(int i=0;i<m;i++){
            if(range[i][0]>=f){
                ans++;
                f = range[i][1];
            }
        }
        System.out.print(ans);
        System.out.flush();
    }
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  forll(i, 1, 100)
	if(a * i % b == c){
	  cout << "YES" << endl;
	  return 0;
	}
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll                long long int
#define ld                long double
#define pb                push_back
#define mk                make_pair
#define vi                vector<ll>
#define vii               vector<pair<ll,ll>>
#define vpp               vector<pair<ll,pair<ll,ll>>>
#define vll               vector<ll>
#define vc                vector<char>
#define vs                vector<string>
#define mll               map<ll,ll>
#define mci               map<char,ll>
#define msi               map<string,ll>
#define in(i,a,n)         for(ll i=0;i<n;++i) cin>>a[i];
#define out(i,a,n)        for(ll i=0;i<n;++i) cout<<a[i]<<" ";
#define sz(c)             (ll)c.size()
#define len(c)            (ll)c.length()
#define hell              (ll)1000000007
#define all(c)            c.begin(), c.end()
#define rall(c)           c.rbegin(), c.rend()
#define trav(a,i)         for(auto& i: a)
#define loop(i,a,b)       for(ll i=a;i<b;i++)
#define rloop(i,a,b)      for(ll i=a;i>b;i--)
#define invect(v,n)       for(ll i=0;i<n;i++ ){ll arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        forloop(n){ll aset;cin>>aset;s.insert(aset);}
#define F                 first
#define S                 second
#define pii               pair<ll,ll>
#define PB                pop_back
#define copy(a,b)         copy(all(a),back_inserter(b));
#define section(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define sp(n)             setprecision(n)
#define fin               freopen( "input.txt", "r", stdin );
#define fout              freopen( "output.txt", "w", stdout );
#define outall(a)         loop(i,0,sizeof(a)/sizeof(a[0])) cout<<a[i]<<" "; cout<<endl
#define endl "\n"
const ll N=300001;
const ll MOD = 1000 * 1000 * 1000 + 7;
ll mod(ll n) {
    return (n % MOD + MOD) % MOD;
}

//vector<ll> v;
 /*ll powm(ll a,ll b, ll m){
    if(b==0) return 1;
    ll t=powm(a,b/2,m);
    if(b%2) return a*t%m*t%m;
    return t*t%m;
 }
 */
/*ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}*/
 
/*int bs(int a[],int low, int high, int val)
{
    int mid=(low+high)/2;
    if(low>high) return -1;
    if(a[mid]>val) bs(a,low,mid-1,val);
    else if(a[mid]<val) bs(a,mid+1,high,val);
    else return mid;
}*/
 
void solve(){
    ll n,l,r,i,j,sum=0,count=0,max_sum=INT_MIN,max_value=INT_MIN;
    cin>>n;
    while(n){
        if(n%10==7) { cout<<"Yes\n"; return; }
        n/=10;
    }
    cout<<"No\n";
}

signed main(){
    //fin fout
    fast
    ll t=1; //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll r;
    cin>>r;
    ll x = 3*r*r;
    print(x);
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;
 

int N, K;
const int MAX_N = 1.0e5;
int h[MAX_N];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];
    sort(h, h+N);  
    int diff[N-1];
    for (int i = 0; i < N-1; i++) diff[i] = h[i+1] - h[i];
    int min = INF;
    for (int i = 0; i < N-K+1; i++) {
        int sum = 0;
        for (int j = i; j < i+K-1; j++) sum += diff[j];
        if (sum < min) min = sum;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	for (int i=1; i<=9; i++) {
		for (int j=1; j<=9; j++) {
			if (n==i*j) { 
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3600
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

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

			int n =in.nextInt();
			long x = in.nextLong();
			long[] a = in.nextLongArray(n);

			long[][] b = new long[n][n];
			long ans = Long.MAX_VALUE;
			for (int k = 0; k < n; k++) {
				long res = 0;
				for (int i = 0; i < n; i++) {
					if (k == 0) {
						b[k][i] = a[i];
					} else {
						b[k][i] = min(b[k-1][i], a[(i+n-k)%n]);
					}
					res += b[k][i];
				}
				ans = min(res+k*x, ans);
			}
			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

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

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

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

	}

}


Measured memory_bytes: 84648
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
 int n;
  cin>>n;
  string ans="No";
  rep(i,9){
    rep(j,9){
      if((i+1)*(j+1)==n){
        ans="Yes";
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<unsigned long> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  if(data.at(0) == 0){
    cout << 0 << endl;
    return 0;
  }
  unsigned long ans = data.at(0);
  for(int i = 1; i < N; i++){
    if(1000000000000000000 / data.at(i) < ans){
      cout << -1 << endl;
      return 0;
    } else ans *= data.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{

  string s;
  cin>>s;
  int n=s.size();
  int d=10;
  vector<int> T(n);
  T[n-1]=(s[n-1]-'0')%2019;
  for (int i = n-2; i >= 0; --i)
  {
    T[i]=((s[i]-'0')*d+T[i+1])%2019;
    d*=10;
    d%=2019;
  }
  map<int,int> mp;
  for (int i = 0; i < T.size(); ++i)
  {
    mp[T[i]]++;
  }
  mp[0]++;
  ll ans=0;
  for(const auto& e: mp) 
  {
    ans+=e.second*(e.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4364
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int co;
int p,q,a,n;
double t,nt;
void f(int sum,int b,int c){
  if(c==n)return;
  for(int i=b;sum*i<=a;i++){
    if(nt+EPS<t+1./i)continue;
    if(abs(t+1./i-nt)<EPS){
      co++;
    }
    t+=1./i;
    f(sum*i,i,c+1);
    t-=1./i;
  }
}
int main(){
  while(cin>>p>>q>>a>>n,p+q+a+n){
    co=0;
    nt=(double)p/q;
    t=0;
    f(1,1,0);
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int ans;
string s[10],r[10];
string t1[5],t2[5];
bool b[11];
bool check(int p){
  r(i,5)if(t1[i][p]==t2[p][i])return 0;
  return 1;
}
void dfs2(int d){
  if(d==5)ans++;
  else{
    r(i,10)if(!b[i]){
      b[i]=1;
      t2[d]=s[i];
      if(check(d))dfs2(d+1);
      t2[d]=r[i];
      if(check(d))dfs2(d+1);
      b[i]=0;
    }
  }
}
void dfs(int d){
  if(d==5)dfs2(0);
  else{
    r(i,10)if(!b[i]){
      b[i]=1;
      t1[d]=s[i];
      dfs(d+1);
      t1[d]=r[i];
      dfs(d+1);
      b[i]=0;
    }
  }
}
main(){
  while(cin>>s[0],s[0]!="END"){
    memset(b,0,sizeof(b));
    ans=0;
    r[0]=s[0];
    reverse(r[0].begin(),r[0].end());
    r(i,9){
      cin>>s[i+1];
      r[i+1]=s[i+1];
      reverse(r[i+1].begin(),r[i+1].end());
    }
    int p=0;
    r(i,10)if(s[i]==r[i])p++;
    dfs(0);
    cout<<ans/(pow(2,p)*8)<<endl;
  }
}

Measured memory_bytes: 3344
import sys
input = sys.stdin.readline
S = input().strip()
Sr=''.join(list(reversed(S)))
N=len(S)
S1=S[:int((N-1)/2)]
S1r=''.join(list(reversed(S1)))
S2=S[int((N+3)/2)-1:]
S2r=''.join(list(reversed(S2)))
if S==Sr and S1 ==S1r and S2==S2r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n,x = map(int, input().split())
a = sorted([int(z) for z in input().split()])

ret = 0
flag = False
for i in range(n):
    if x-a[i]>=0:
        ret += 1
        x = x-a[i]
    else:
        flag = True
        break
# print(i,x,flag)
if i==n-1 and not flag and x>0:
    ret = max(0,ret-1)
print(ret)


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

int main()
{
  int N, A[100][100];
  cin >> N;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  long long ret = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      ret += min(A[i][j], A[j][i]);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    ll ans = N;
    for (ll i = 1; i*i <= N; i++) {
        if(N % i == 0){
            ll n = N/i;
            ans = min(ans, i+n-2);
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
s = input()
l = ['dream', 'dreamer', 'erase', 'eraser']
pos = 0
flg = True
can = False
while flg:
    flg = False
    for i in range(len(l)):
        st = len(l[i])+pos
        if st<=len(s):
            if s[st*(-1):len(s)-pos] == l[i]:
                pos += len(l[i])
                if pos == len(s):
                    can = True
                    break
                flg = True
if can == True:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
n, m = gets.chomp.split(' ').map(&:to_i)

free = (1..m).to_a

jobs = []
n.times do |i|
    a, b = gets.chomp.split(' ').map(&:to_i)
    next if a > m

    jobs << [a, b]
end
jobs.sort!{|a, b| b[1] <=> a[1]}

r = 0
jobs.each do |cost, reward|
    i = free.bsearch_index{|f| f >= cost}
    next if i.nil?

    free.delete_at(i)
    r += reward
end
puts r

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 200005;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

int n, k, a[MAXN];
int qmx[MAXN], hmx, tmx, qmn[MAXN], hmn, tmn;

inline void push_mx(int x) {
	while (hmx <= tmx && x > qmx[tmx]) {
		--tmx;
	}
	qmx[++tmx] = x;
}

inline void pop_mx(int x) {
	if (hmx <= tmx && qmx[hmx] == x) ++hmx;
}

inline void push_mn(int x) {
	while (hmn <= tmn && x < qmn[tmn]) {
		--tmn;
	}
	qmn[++tmn] = x;
}

inline void pop_mn(int x) {
	if (hmn <= tmn && qmn[hmn] == x) ++hmn;
}

void init() {
	read(n); read(k);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
}

void solve() {
	int ans = 0, flag = 0, sor = 0;
	hmx = hmn = 1;
	for (int i = 1; i < k; ++i) {
		sor += (a[i] < a[i + 1]);
		push_mx(a[i]);
		push_mn(a[i]);
	}
	for (int i = k; i <= n; ++i) {
		if (sor == k - 1) {
			flag = 1;
		} else if (i == k || (a[i - k] > qmn[hmn] || a[i] < qmx[hmx])) {
			++ans;
			//printf("%d\n", i);
		}
		sor -= (a[i - k + 1] < a[i - k + 2]);
		sor += (a[i] < a[i + 1]);
		pop_mx(a[i - k + 1]);
		pop_mn(a[i - k + 1]);
		push_mx(a[i]);
		push_mn(a[i]);
	}
	printf("%d\n", ans + flag);
}

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


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 105
using namespace std;
int mapp[maxn][maxn],h,w,n,a[maxn*maxn],tail;
bool visit[maxn][maxn];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	int x=1,y=1;
	for(int i=1;i<=h*w;++i)
	{
		if(a[tail]==0) ++tail;
		mapp[x][y]=tail;a[tail]--;
		visit[x][y]=true;
	if(y+1<=w&&!visit[x][y+1]) y=y+1;
	else if(y-1>=1&&!visit[x][y-1]) y=y-1;
	else if(x+1<=h&&!visit[x+1][y]) x=x+1;
	else if(x-1>=1&&!visit[x-1][y]) x=x-1;
	}
	for(int i=1;i<=h;++i){
	for(int j=1;j<=w;++j)
	cout<<mapp[i][j]<<' ';
	cout<<endl;
	}
}

Measured memory_bytes: 384
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V

main :: IO ()
main = do
  let
    units = V.fromList . map T.pack $ ["pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"] :: V.Vector T.Text
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  T.putStrLn $ units V.! (n `mod` 10)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int mod = 1e9 + 7;
const int N = 200005;

ll f[N], inv[N], finv[N];

void init() {
	f[0] = f[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
		finv[i] = (finv[i - 1] * inv[i]) % mod;
	}
}

ll nCr(ll n, ll r) {
	return (f[n] * ((finv[r] * finv[n - r]) % mod)) % mod;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	init();
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	ll res = nCr(n + m - 2, n - 1);
	ll prv = 0;
	for (int i = a; i > 0; i--) {
		int r = n - i;
		ll x = nCr(r + b - 1, r);
		ll y = nCr(i - 1 + m - b, i - 1);
		ll cur = ((x - prv + mod) * y) % mod;
		res = (res - cur + mod) % mod;
		prv = x;
	}
	cout << res << endl;
	return 0;
}


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

int main(){
 
  int N;
  cin >> N;
  
  int Keta = 0, _N = N, Sum = 0;
  while(_N != 0){
    _N /= 10;
    Keta++;
  }
  
  for(int i = 1; i < Keta; i += 2) Sum += 9 * pow(10, i - 1);
  
  if(Keta % 2 != 0){
    Sum += N - pow(10, Keta - 1) + 1;
  }
    
  cout << Sum << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nab = readln.split.to!(int[]);
    auto N = nab[0];
    auto A = nab[1];
    auto B = nab[2];
    auto S = readln.chomp;
    int b, n;
    foreach (c; S) {
        switch (c) {
            case 'a':
                if (n < A+B) {
                    writeln("Yes");
                    ++n;
                } else {
                    writeln("No");
                }
                break;
            case 'b':
                if (n < A+B && b < B) {
                    ++b;
                    ++n;
                    writeln("Yes");
                } else {
                    writeln("No");
                }
                break;
            default:
                writeln("No");
        }
    }
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s = "", t = "";
  rep(i, n){
    char c;
    cin >> c;
    s.push_back(c);
  }
  rep(i, n){
    char c;
    cin >> c;
    t.push_back(c);
  }
  string p = "";
  rep(i, n)p.push_back('0'+i+1);
  int ans = -1, co = 0;
  if(s == t){
    cout << 0 << endl;
    return 0;
  }
  do{
    co++;
    if(p == s || p == t){
      if(ans == -1) ans = co;
      else {
        cout << co - ans << endl;
        break;
      }
    }
  }while(next_permutation(ALL(p)));
  return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int h,w,a,b;
  cin>>h>>w>>a>>b;
  bool s[1000][1000]={};

  for(int r=0;r<h;r++){
    for(int c=0;c<w;c++){
      if((r<b&&c<a)||(b<=r&&a<=c)){
        s[r][c]=true;
      }
    }
  }

  for(int r=0;r<h;r++){
    for(int c=0;c<w;c++){
      cout<<(s[r][c]?'1':'0');
    }
    cout<<endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
   int n,M;
   cin>>n>>M;
   vector<int>r(n+1);
   vector<int>w(n+1);
   for(int i=0;i<M;i++){
    int p;string s;
    cin>>p>>s;
    if(s=="AC"&&r[p]==0)r[p]+=1;
    else if(s=="WA"&&r[p]==0)w[p]+=1;
   }
   int R=0,W=0;
   for(int i=1;i<=n;i++){
    R+=r[i];
    if(r[i]>0)W+=w[i];
   }
   cout<<R<<' '<<W<<endl;
}


Measured memory_bytes: 1024
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed

buildTable :: BS.ByteString -> V.Vector (UArray Char Int)
buildTable s = let s' = V.generate (BS.length s) $ \i -> BS.index s i
               in V.scanr (\(i,c) a -> a // [(c,i)]) (array ('a','z') [(c,-1) | c <- ['a'..'z']]) (V.indexed s')

main = do
  s <- BS.getLine
  t <- BS.getLine
  let s_table = buildTable s
  let loop :: Int64 -> Int -> BS.ByteString -> Int64
      loop !i !j t = case BS.uncons t of
                       Nothing -> i
                       Just (c, t') ->
                         let k = (s_table V.! j) ! c
                         in if k == -1
                            then let l = V.head s_table ! c
                                 in if l == -1
                                    then -1
                                    else loop (i + fromIntegral (l + BS.length s - j) + 1) (l+1) t'
                            else loop (i + fromIntegral (k - j) + 1) (k+1) t'
  print $ loop 0 0 t


Measured memory_bytes: 49532
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const long long int inf = 1 << 29 ;

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

	int ans = 0;
	char pre_s = '_';
	rep(i, n) {
	  char s;
		cin >> s;

		if (s != pre_s) {
		  ans++;
			pre_s = s;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5;
int n, m;
int W[2][N], ans[N], o, d[N], rev;
char t[N];
int main() {
	cin >> n; scanf("%s", t+1);
	m = strlen(t + 1);
	int qc = 1;
	for(int i=1;i<=n;i++)qc=qc*3;
	int ful = 3;
	for(int e = 1; e <= n; e++, ful *= 3) {
		rev = 0;
		int lasful = ful / 3;
		for(int i = 0; i < ful; i++) d[i] = i / (lasful);
		for(int i = 1; i <= m; i++) {
			if (t[i] == 'S') {
				rev ^= 1;
			} else {
				for(int z = 0, s = 0; z < 3; z++, s += lasful) {
					int x = s + W[o][i];
					if (rev == 0 && d[x] == 2 || rev == 1 && d[x] == 1) {
						W[1 - o][i] = x;
					}

					int t = d[x];
					if (rev == 1) {
						if (t == 1) t = 2; else
						if (t == 2) t = 1;
					}

					t = (t + 1) % 3;
					if (rev == 1) {
						if (t == 1) t = 2; else
						if (t == 2) t = 1;
					}
					d[x] = t;
				}
			}
		}
		for(int i = 0; i < qc; i++) {
			int g=d[i%ful];
			if(rev){
				if(g==1)g=2;else if (g==2)g=1;
			}
			ans[i]+=lasful*g;
		}
		o = 1 - o;
	}
	for(int i=0;i<qc;i++)printf("%d ",ans[i]);
}


Measured memory_bytes: 9876
N, K = map(int, input().split())
lst = []

for _ in range(N):
	a, b = map(int, input().split())
	lst.append([a, b])
	
lst.sort(key = lambda x : -x[0])

tot = 0
while True:
	val, num = lst.pop()
	tot += num
	if tot >= K:
		print(val)
		break

Measured memory_bytes: 64344
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<tuple<ll, ll, ll>> cakes;
  REP(i, n){
    ll x, y, z;
    cin >> x >> y >> z;
    cakes.emplace_back(x, y, z);
  }

  ll ans = 0;
  REP(i, 1<<3){
    ll a[] = {1, 1, 1};
    REP(j, 3) if(i & (1<<j)) a[j] = -1;
    vector<ll> s(n);
    REP(j, n){
      ll x, y, z;
      tie(x, y, z) = cakes[j];
      s[j] = a[0]*x+a[1]*y+a[2]*z;
    }
    sort(ALLr(s));
    ll sum = 0;
    REP(j, m) sum += s[j];
    chmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

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

const int sz = 1 << 18;

// Lazy Segment Tree
long long data[sz << 1], lazy[sz << 1];
inline void eval(int k) {
    data[k] += lazy[k];
    if(k < sz) {
        lazy[k << 1] += lazy[k];
        lazy[k << 1 | 1] += lazy[k];
    }
    lazy[k] = 0;
}
inline void add(int a, int b, long long x, int k = 1, int l = 0, int r = sz) {
    eval(k);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
        lazy[k] += x;
        eval(k);
    } else {
        add(a, b, x, k << 1, l, l + r >> 1);
        add(a, b, x, k << 1 | 1, l + r >> 1, r);
        data[k] = max(data[k << 1], data[k << 1 | 1]);
    }
}
inline long long getmax(int a, int b, int k = 1, int l = 0, int r = sz) {
    if(b <= l || r <= a) return -1LL << 60;
    eval(k);
    if(a <= l && r <= b) return data[k];
    long long vl = getmax(a, b, k << 1, l, l + r >> 1);
    long long vr = getmax(a, b, k << 1 | 1, l + r >> 1, r);
    return max(vl, vr);
}

int N, M;

vector<pair<int, int>> P[200009];

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int l, r, a;
        cin >> l >> r >> a;
        P[r].push_back(make_pair(l, a));
    }

    for(int i = 1; i <= N; i++) {
        add(i, i + 1, getmax(0, i));
        for(auto p : P[i]) {
            int l = p.first;
            int a = p.second;
            add(l, i + 1, a);
        }
    }

    cout << getmax(0, N + 1) << endl;

    return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
    using namespace std;
    #define PAIN___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < ll, ll >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 100005
   /* string with spaces   getline(cin,s);*/

int main(){
    PAIN___;
	ll n;
	cin>>n;
	cout<<3*n*n<<endl;
}


Measured memory_bytes: 256