akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
bool ispal(string s){
	string b = s;
	reverse(all(b));
	return s.compare(b)==0;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,a,b;
	cin>>s;
	for(int i=0;i<=s.size()/2-1;i++){
		a.pb(s[i]);
	}
	if(ispal(a)&&ispal(s)){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}

	return 0;
}







Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100000

int n,len[2],ans;
int Max[2][2];
int kind[2][2];
int a[2][MAXN/2+3];

void Update(int k,int val,int typ) {
	if(val>Max[k][0]) {
		Max[k][1]=Max[k][0],kind[k][1]=kind[k][0];
		Max[k][0]=val,kind[k][0]=typ;
	}
	else if(val>Max[k][1])
		Max[k][1]=val,kind[k][1]=typ;
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i%2][i/2]);
	len[0]=n/2+n%2;len[1]=n/2;
	sort(a[0],a[0]+len[0]);
	sort(a[1],a[1]+len[1]);
	for(int t=0;t<=1;t++) {
		int cnt=1;
		for(int i=1;i<len[t];i++) {
			if(a[t][i]==a[t][i-1])
				cnt++;
			else {
				Update(t,cnt,a[t][i-1]);
				cnt=1;
			}
		}
		Update(t,cnt,a[t][len[t]-1]);
	}
	if(kind[0][0]!=kind[1][0])
		printf("%d\n",n-(Max[0][0]+Max[1][0]));
	else printf("%d\n",n-max(Max[0][0]+Max[1][1],Max[0][1]+Max[1][0]));
	return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007
typedef long long ll;

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> x(n), y(m); rep(i,n) cin >> x[i]; rep(i,m) cin >> y[i];
    long long int ax=0,ay=0;
    rep(i,n-1) ax = (ax + (((i+1) * (n-i-1) * (x[i+1]-x[i])) % MOD)) % MOD;
    rep(i,m-1) ay = (ay + (((i+1) * (m-i-1) * (y[i+1]-y[i])) % MOD)) % MOD;
    cout << (ax*ay)%MOD << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  vector<int> r;
  while (!a.empty()) {
    bool b = true;
    for (int i = a.size() - 1; i >= 0; i--) {
      if (a[i] == i + 1) {
        a.erase(begin(a) + i);
        r.push_back(i + 1);
        b = false;
        break;
      }
    }
    if (b) break;
  }
  if (r.size() == n) {
    reverse(begin(r), end(r));
    for (auto e : r) {
      cout << e << endl;
    }
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n,s;
	while(cin>>n>>s,n||s){
		vint v(n);
		rep(i,n) cin>>v[i];
		sort(ALL(v));
		int ans=0;
		rep(i,n-1){
			reep(j,i+1,n){
				if(v[i]+v[j]>s) ans++;
			}
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define FORT(i, a, b) for(int i = a; i < (int) b; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

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

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

	int n, k; cin >> n >> k;
	int cnt = 0;
	while(n){
		cnt++;
		n/=k;
	}
	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B;

	cin >> A >> B;
	
	if (A > B+1) {
		cout << A + A - 1;
	}
	else if (B > A + 1) {
		cout << B + B - 1;
	}
	else {
		cout << A + B;
	}
	
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NMAX 200001

int a[NMAX], up[NMAX], bt[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int max(int a, int b) { 
    if(a > b) return a;
    else return b;
}

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

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++) {
            bt[i] = max(0, i - a[i]);
            up[i] = min(n, i + a[i] + 1);
        }
        for(int i = 0; i < n; i++){
            imos[bt[i]]++;
            imos[up[i]]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(long long i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll n;
cin>>n;

rep(i,1,3500)
{
	rep(j,1,3500)
	{
		ll num=4*i*j-(i+j)*n,den=n*i*j;
		if(num<=0)continue;
		ll gg=__gcd(num,den);
		num/=gg;den/=gg;
		if(num==1)
		{
			o2(i,j);os;ol(den);
			return 0;
		}
	}
}

return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  bool good = false;
  int N;
  int a[4];
  cin >> N;

  for (int i = 0; i < 4; ++i) {
    a[i] = N % 10;
    N = N / 10;
  }

  if (a[0] == a[1] && a[1] == a[2]) {
    good = true;
  } else if (a[3] == a[2] && a[1] == a[2]) {
    good = true;
  } 
  if (good) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template<class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define Cin(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define VecIn(T,name,n) vector<T> name(n); for(auto &i:name)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
template<> void out(double a) { printf("%.20f\n", a); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	Cin(int, n);
	out(n < 1000 ? "ABC" : "ABD");
}

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

struct ModInt {
    static const ll MOD = 1000000007;

    // constructors etc
    ModInt() :num(1ll) {}
    ModInt(ll num_) :num(num_% MOD) {}
    ModInt(const ModInt& modint) :num(modint.num% MOD) {}
    ll get()const { return num; }

    // operator etc
    // operator ll() const { return num; }
    // ll operator*() { return num; }
    ModInt& operator+=(const ModInt& r) { (num += r.num) %= MOD; return *this; }
    ModInt& operator-=(const ModInt& r) { (num += -r.num + MOD) %= MOD; return *this; }
    ModInt& operator*=(const ModInt& r) { (num *= r.num) %= MOD; return *this; }
    ModInt& operator/=(const ModInt& r) { (num *= r.inv().num) %= MOD; return *this; }
    ModInt pow(const ModInt& r)const {
        ll res = 1;
        ll x = num;
        ll n = r.num;
        while (n > 0) {
            if (n & 1)res = (res * x) % MOD;
            x = (x * x) % MOD;
            n >>= 1;
        }
        return res;
    }
    ModInt inv()const { return this->pow(MOD - 2); }

    ModInt operator+(const ModInt& r)const { return ModInt(*this) += r; }
    ModInt operator-(const ModInt& r)const { return ModInt(*this) -= r; }
    ModInt operator*(const ModInt& r)const { return ModInt(*this) *= r; }
    ModInt operator/(const ModInt& r)const { return ModInt(*this) /= r; }
    ModInt operator+(const ll& r)const { return *this + ModInt(r); }
    ModInt operator-(const ll& r)const { return *this - ModInt(r); }
    ModInt operator*(const ll& r)const { return *this * ModInt(r); }
    ModInt operator/(const ll& r)const { return *this / ModInt(r); }

private:
    ll num;
};
ostream& operator<<(ostream& stream, const ModInt& val) { stream << val.get(); return stream; }

struct Comb {
    static constexpr ll LIM = 2000010;
    static vector<ModInt> fact, inv;

    static void init() {
        fact.resize(LIM, 1);
        inv.resize(LIM, 1);

        REP(i, 1, LIM)fact[i] = fact[i - 1] * i;
        inv[LIM - 1] = fact[LIM - 1].inv();
        for (ll i = LIM - 2; i > 0; i--)inv[i] = inv[i + 1] * (i + 1);
    }

    static ll comb(ll n, ll k) {
        if (n < k)return 0ll;
        return (fact[n] * inv[k] * inv[n - k]).get();
    }
};
vector<ModInt> Comb::fact;
vector<ModInt> Comb::inv;


int main()
{
    ll X, Y;
    cin >> X >> Y;
    if (X > Y)swap(X, Y);

    ll D = Y - X;
    Y -= D * 2;
    X -= D;
    assert(X == Y);

    if (X < 0 || X % 3 != 0) {
        cout << 0 << endl;
    }
    else {
        ll L = X / 3;
        ll R = X / 3 + D;

        Comb comb;
        comb.init();
        cout<<comb.comb(L+R,L)<<endl;
    }
    return 0;
}


Measured memory_bytes: 31488
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 101001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
ll X[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

       // Main program
void solve() {
    ll  N,M;
    cin >> N;
    cin >> M;

    if (N == M) {
        for (ll i = 0; i < N; i++) {
            cout << N;
        }
    }
    else {
        ll big, mini;
        if (N < M) {
            big = M;
            mini = N;
        }
        else {
            big = N;
            mini = M;
        }

        for (ll i = 0; i < big; i++) {
            cout << mini;
        }
    }

       
    return;

}

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







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 1000000007;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

ll dp[410][410];
ll sm[410][410];


void solve(){
    int n;
    cin>>n;
    vl a(n);
    for(int i=0;i<n;i++){
        dp[i][i] = 0;
        cin>>a[i];
    }   

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k = i;k<=j;k++){
                sm[i][j]+=a[k];
            }
        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        for(int l = 0;l<=n-i;l++){
            dp[l][l+i] = 1e18L;
            for(int j=l;j<=l+i;j++){
                dp[l][l+i] = min(dp[l][l+i],dp[l][j]+dp[j+1][l+i]+sm[l][l+i]);
            }
        }
    }
    cout<<dp[0][n-1]<<'\n';
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const double EPS = 1e-3;
const double PI = 3.1415926535897932384626433832795028841971;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> pos(n);
    rep(i, n)
    {
        int t;
        cin >> t;
        pos[t - 1] = i;
    }
    if (n == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    rep(i, n - 1)
    {
        int tmp = 1;
        while (pos[i] < pos[i + 1])
        {
            i++;
            if (i == n)
                break;
            tmp++;
        }
        ans = max(ans, tmp);
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 4024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        h: i32,
        n: i32,
        a: [i32; n]
    }
    let s: i32 = a.iter().fold(0, |sum, a| sum + a);
    println!("{}", if h - s <= 0 {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
int N,x,y,b,p;
cin>>N;
for(int i=0;i<N;i++){
cin>>x>>y>>b>>p;
if(b>=5&&p>=2){cout<<(x*b+y*p)*0.8<<endl;}
else if(b>=5&&p<2&&x*b+y*p>(x*b+2*y)*0.8){cout<<(x*b+2*y)*0.8<<endl;}
else if(b<5&&p>=2&&x*b+y*p>(x*5+y*p)*0.8){cout<<(x*5+y*p)*0.8<<endl;}
else cout<< x*b+y*p<<endl;
}
return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val r = mutable.ArrayBuffer.fill(n)(sc.nextInt())

    var j = 0
    var count = 0

    while (j < n) {
      for (i <- n - 1 to 1 by -1) {
        val x = r(i)
        val y = r(i - 1)
        if (x < y) {
          r(i - 1) = x
          r(i) = y
          count += 1
        }
      }
      j += 1
    }
    println(r.mkString(" "))
    println(count)

  }

}



Measured memory_bytes: 45192
#include <stdio.h>
#define MAX(maxN,m) ((maxN) > (m) ? (maxN) : (m))

int main(){
    int n;

    scanf("%d", &n);

    int maxN = 0, total = 0;
    for (int i = 0; i<n; i++) {
        int m;

        (void)scanf("%d", &m);

        maxN = MAX(maxN, m);
        total += m;
    }

    printf("%s", maxN < total - maxN ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >> a >> b;

  if(a+b>=10) puts("error");
  else cout << a+b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    string S;
    cin >> S;
    map<char,int> cnt;
    for(auto s:S){
        cnt[s]++;
    }
    char c;
    if(cnt['a'] != 0){
        c = 'a';
    }else if(cnt['b'] != 0){
        c = 'b';
    }else{
        c = 'c';
    }
    string ans = "NO";

    if(abs(cnt['a']-cnt['b'])<2 && abs(cnt['a']-cnt['c'])<2 && abs(cnt['c']-cnt['b'])<2){
        ans = "YES";
    }

    /*
    cnt[c]--;
    REP(i,S.size()-1){
        if('a' == c){
            if(cnt['b'] != 0){
                c = 'b';
                cnt[c]--;
            }else if(cnt['a' != 0]){
                c = 'a';
                cnt[c]--;
            }else{
                ans = "NO";
                break;
            }
        }else if('b' == c){
            if(cnt['c'] != 0){
                c = 'c';
                cnt[c]--;
            }else if(cnt['b' != 0]){
                c = 'b';
                cnt[c]--;
            }else{
                ans = "NO";
                break;
            }
        }else{
            if(cnt['a'] != 0){
                c = 'a';
                cnt[c]--;
            }else if(cnt['c' != 0]){
                c = 'c';
                cnt[c]--;
            }else{
                ans = "NO";
                break;
            }
        }
    }
    */
    cout << ans << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int N = int.Parse(input);
        input = Console.ReadLine();
        char[] S= input.ToCharArray();
        input = Console.ReadLine();
        int K = int.Parse(input);
        string ans = "";
        for(int i = 0; i < N; i++)
        {
            if (S[i] == S[K-1]) { ans += S[i]; }
            else { ans += "*"; }
        }
        Console.WriteLine(ans);
    }
}

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

const int MAX_N=1e5;

int N;
string S;

string ans;

void solve(){
	bool flg=false;
	REP(i,2){
		REP(j,2){
			ans.clear();
			ans.resize(N);
			if (i==0){
				ans[0]='S';
			}else{
				ans[0]='W';
			}
			if (j==0){
				ans[1]='S';
			}else{
				ans[1]='W';
			}
			flg=true;
			FOR(k,1,N-1){
				if (ans[k]=='S'){
					if (S[k]=='o'){
						ans[k+1]=ans[k-1];
					}else{
						if (ans[k-1]=='S'){
							ans[k+1]='W';
						}else{
							ans[k+1]='S';
						}
					}
				}else{
					if (S[k]=='x'){
						ans[k+1]=ans[k-1];
					}else{
						if (ans[k-1]=='S'){
							ans[k+1]='W';
						}else{
							ans[k+1]='S';
						}
					}
				}
			}
			REP(k,N){
				char ani1=ans[(k+N-1)%N],ani2=ans[(k+1)%N];
				if ((ans[k]=='S' && S[k]=='o') || (ans[k]=='W' && S[k]=='x')){
					if (ani1!=ani2){
						flg=false;
					}
				}else{
					if (ani1==ani2){
						flg=false;
					}
				}
			}
			if (flg){
				cout<<ans<<endl;
				return;
			}
		}
	}
	cout<<-1<<endl;
}

int main(){
	cin>>N>>S;
	solve();
	return 0;
}


Measured memory_bytes: 512
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int k;
	cin >> k;
	int a = 0;
	for(int i = 1; i <= k; i++) {
		a = (a*10+7)%k;
		if(!a)
			return cout << i << '\n', 0;
	}
	cout << "-1\n";

	return 0;
}


Measured memory_bytes: 3648
n,m = map(int,input().split())
broken = [0] * (n+1)
mod = 10**9+7
for i in range(m):
    broken[int(input())] = 1
dp = [0] * (n+1)
dp[0] = 1
if broken[1]:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(2,n+1):
    if not broken[i]:
        dp[i] = (dp[i-1] + dp[i-2])%mod
print(dp[n])


 

Measured memory_bytes: 13288
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	long long int N,ans=0;
	cin>>N;
	vector<long long int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			ans=max(ans,abs(A[i]-A[j]));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int s[101]={0};
	for(int i=1;i<=k;i++){
		int d;
		cin>>d;
		int a;
		for(int j=1;j<=d;j++){
			cin>>a;
			s[a]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!s[i])
			ans++;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	const ll INF=1LL<<60;
	
	int n,w_max; cin >> n >> w_max;
	
	vector<ll> w(n),v(n);
	rep(i,n) cin >> w[i] >> v[i];
	//sort(a.begin(),a.end());
	
	
	vector<vector<ll>> wei(n+1,vector<ll>(1000*n+1,INF));
	
	wei[0][0]=0;
	
	rep(i,n){
		rep(j,1000*n+1){
			
			
			if(j-v[i]>=0) chmin(wei[i+1][j],wei[i][j-v[i]]+w[i]);
			
			chmin(wei[i+1][j],wei[i][j]); // 
			
			//if(j-v[i]>=0) wei[i+1][j]=min(wei[i][j],wei[i][j-v[i]]+w[i]);
			//else wei[i+1][j]=wei[i][j];
			
		}
	}

	long long res = 0;
    for (int sum_v = 0; sum_v < 1000*n+1; ++sum_v) {
        if (wei[n][sum_v] <= w_max) res = sum_v;
    }
    cout << res << endl;
    
    return 0;

}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll h, n;
ll a[N];
ll b[N];

ll dp[1003][10004];
ll recur(ll pos, ll rem) {

  if (rem <= 0)
    return 0;
  if (pos == n + 1) {
    return inf;
  }
  ll &ans = dp[pos][rem];
  if (ans != -1)
    return ans;

  ans = min(recur(pos + 1, rem), b[pos] + recur(pos, rem - a[pos]));

  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> h >> n;

  for (ll i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }

  memset(dp, -1, sizeof(dp));
  cout << recur(1, h) << en;
  return 0;
}

Measured memory_bytes: 80640
//AtCoder
//AGC013B Hamiltonish Path

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int MAXN=100000+10;
int n,m;
vector<int> edge[MAXN];
int vis[MAXN];
vector<int> path1,path2;

void dfs(int t)
{
	vis[t]=1;
	path1.push_back(t);
	
	for(int i=0;i<edge[t].size();++i)
		if(!vis[edge[t][i]])
		{
			dfs(edge[t][i]);
			return;
		}
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>m;
	
	int x,y;
	for(int i=0;i<m;++i)
	{
		cin>>x>>y;
		
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	dfs(1);
	swap(path1,path2);
	dfs(1);
	
	cout<<path1.size()+path2.size()-1<<endl;
	
	for(int i=int(path2.size())-1;i>=1;--i)
		cout<<path2[i]<<' ';
	for(int i=0;i<path1.size();++i)
		cout<<path1[i]<<' ';
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 9976
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

vector<int> ul;
vector<int> vl;
vector<vector<int> > vec;

void udfs(int c,int p,int death){
	ul[c] = death;
	for(int i = 0;i < vec[c].size();i++){
		if(vec[c][i] != p){
			udfs(vec[c][i],c,death+1);
		}
	}
}

void vdfs(int c,int p,int death){
	vl[c] = death;
	for(int i = 0;i < vec[c].size();i++){
		if(vec[c][i] != p){
			vdfs(vec[c][i],c,death+1);
		}
	}
}

int main(){
	int n,u,v;
	cin >> n >> u >> v;
	u--;v--;
	vec = vector<vector<int> >(n);
	int x,y;
	rep(i,n-1){
		cin >> x >> y;
		x--;y--;
		vec[x].pb(y);
		vec[y].pb(x);
	}
	ul = vector<int>(n);
	vl = vector<int>(n);
	ul[u] = 0;
	vl[v] = 0;
	udfs(u,-1,0);
	vdfs(v,-1,0);
	ll ans = 0;
	rep(i,n){
		if(ans < vl[i]-1 && ul[i] < vl[i]){
			ans = vl[i] - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int n,x,i,j,r[200200];
bool u[200200];
void st(int x, int v) {
  r[x]=v; u[v]=true;
}
int main() {
  scanf("%d%d",&n,&x);
  if (x==1 || x==2*n-1) { puts("No"); return 0; }
  st(n,x);
  if (x==2) {
    st(n-1,1);
    st(n+1,3);
    if (n>2) st(n-2,4);
  } else {
    st(n-1,x+1);
    st(n+1,x-1);
    if (n>2) st(n-2,x-2);
  }
  puts("Yes");
  for (i=1; i<2*n; i++) if (r[i]==0) {
    for (j++; u[j]; j++);
    printf("%d\n",j);
  } else printf("%d\n",r[i]);
  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include<stdlib.h>

int parent[200005],size[200005];

int max(int a,int b){
    return a>b?a:b;
}

void make_set(int v){
    parent[v]=v;
    size[v]=1;
}

int find_sets(int v){
    if(parent[v]==v)
    return v;
    else return parent[v]=find_sets(parent[v]);
}

void union_sets(int a,int b){
    a=find_sets(a);
    b=find_sets(b);
    if(a!=b)
    {
        if(size[a]<size[b]){
            int t=a;
            a=b;
            b=t;
        }
        size[a]+=size[b];
        parent[b]=a;
    }
}

int main()
{
    int n,m,u,v,ans=1;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    make_set(i);
    while(m--)
    {
        scanf("%d %d",&u,&v);
        union_sets(u,v);
    }
    for(int i=1;i<=n;i++) ans=max(ans,size[parent[i]]);
    printf("%d",ans);
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll n,w;cin >> n >>w;
    vl cost(n),price(n);
    vvl dp(n+1,vl(w+1,0));
    rep(i,n)cin >> cost[i] >> price[i];
    rep(i,n){
        rep(sumw,w+1){
            if(sumw>=cost[i]){
                chmax(dp[i+1][sumw],dp[i][sumw-cost[i]]+price[i]);
            }
            chmax(dp[i+1][sumw],dp[i][sumw]);
        }
    }
    cout << dp[n][w] <<endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    long long int n, k; cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = k;
    for (int i = 1; i < n; i++) {
        if (a[i] - a[i - 1] < k) {
            ans += a[i] - a[i - 1];
        } else {
            ans += k;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4776
import numpy as np

def main():
    n, m = map(int,input().split())
    a = list(map(int,input().split()))
    lim = np.sum(a)/(4*m)
    k=0
    for i in a:
        if i>=lim:
            k+=1
    if k>=m:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 21632
#include <cstdio>

using namespace std;

long long aa;

long long f(long long a,long long b) {
	if (a==0) return -b;
	return 2*a*(b/a)+f(b%a,a);
}


int main () {
	long long n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",n+f(x,n-x));
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np

PI = 3.141592
P = 3.141592653589793238462643383279502884197169399
A, B, H, M = map(int, input().split())

A_ang = (30*H) + (0.5*M)
B_ang = 6 * M

angle = abs(A_ang - B_ang)
if angle > 180:
    angle = 360-angle

angle = (angle/360) * 2*P

a = (A*A) + (B*B) - (2*A*B*np.cos(angle))

a = np.sqrt(a)
print(a)


Measured memory_bytes: 27200
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

n = k()
a = l()
max_h = a[0]

for i in range(1,n):
    if max_h > a[i]:
        cnt += max_h-a[i]
    else:
        max_h = a[i] 

print(cnt)

Measured memory_bytes: 34516
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	int ans=1;
	
	for(int i=0;i<n;i++){
		ans=min(ans+k,2*ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char s[1000001];
int len;
int main() {
    scanf("%s",s);
    len=strlen(s);
    if (s[0]!='A') {
        printf("WA\n");
        return 0;
    }
    int loc=0,cnt=0;
    for (int i=2;i<=len-2;i++)
        if (s[i]=='C') {
            cnt++;
            loc=i;
        }
    if (cnt!=1) {
        printf("WA\n");
        return 0;
    }
    for (int i=1;i<len;i++) {
        if (i==loc) continue;
        if (s[i]>='A'&&s[i]<='Z') {
            printf("WA\n");
            return 0;
        }
    }
    printf("AC\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MAX = 1e5 + 5;
int MOD = 1e9 + 7;
////////////////////////////////

int n;
int a[3005];
int dp[3005][3005];

int best(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    
    if(l == r) return dp[l][r] = a[l];

    dp[l][r] = max(a[l] - best(l+1, r), a[r] - best(l, r-1));
    return dp[l][r];
}

int32_t main(){
    jai_shree_ram

    rep(i,0,3001,1) rep(j,0,3001,1) dp[i][j] = -1;
    
    cin >> n;
    rep(i,1,n,1) cin >> a[i];
    int sum = 0;
    rep(i,1,n,1) sum += a[i];

    int x = best(1, n);
    cout << x  << endl;
    return 0; 
}

Measured memory_bytes: 71040
from sys import stdin

input = stdin.readline

MAX_N = 300001

N = int(input())

S = input()


def main():
    # 東を向いている人の累積和
    E = [0] * N

    if S[0] == 'E':
        E[0] += 1

    for i in range(1, N):
        E[i] = E[i - 1]
        if S[i] == 'E':
            E[i] += 1

    ans = MAX_N

    for i in range(N):
        # 東を向いている人 西に向ける
        num = E[-1] - E[i]

        if (0 < i):
            # 西を向いている人 東に向ける
            num += i - E[i - 1]

        ans = min(ans, num)

    print(ans)
    return


main()


Measured memory_bytes: 15340
#include<iostream>
using namespace std;
typedef long long ll;
const int maxN = 2e5 + 2;
ll a[maxN], b[maxN], cnt;
int n;
ll minn(ll x, ll y){return x < y ? x : y;}
int main()
{
	ios::sync_with_stdio(false);
	ll tmp;
	cin >> n;
	for(int i = 0; i <= n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	for(int i = 0; i < n; i++)
	{
		tmp = minn(a[i],b[i]);
		a[i] -= tmp;
		b[i] -= tmp;
		cnt += tmp;
		tmp = minn(a[i+1],b[i]);
		a[i+1] -= tmp;
		b[i] -= tmp;
		cnt += tmp;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 1792
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
dp = [INF]*(2**n)
dp[0] = 0
for i in range(m):
    val,b = inpl()
    c = inpl()
    key = 0
    for j in c:
        key += 2**(j-1)
    for _ in range(2**n):
        dp[_|key] = min(dp[_|key], dp[_]+val)
        
res = dp[-1]
print(res if res != INF else -1)

Measured memory_bytes: 70504
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n, m; cin >> n >> m;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int sum = accumulate(all(a), 0);
  int cnt = 0;
  for(int i=0; i<n; i++) {
    if (a[i] * 4 * m >= sum) cnt++;
  }
  cout << (cnt >= m ? "Yes": "No") << endl;

}

// EOF


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

bool isleaf(Graph &tree, int node)
{
    return tree[node].size() == 1;
}

void DFS(Graph &tree, vector<bool> &seen, vector<int> &dist, int node)
{
    seen[node] = true;
    for (auto &&subnode : tree[node])
    {
        if (seen[subnode])
            continue;
        dist[subnode] = dist[node] + 1;
        DFS(tree, seen, dist, subnode);
    }
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;

    Graph tree(n + 1);

    for (int i = 1; i <= n; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<bool> useen(n + 1, false);
    vector<int> udist(n + 1, 0);
    vector<bool> vseen(n + 1, false);
    vector<int> vdist(n + 1, 0);
    DFS(tree, useen, udist, u);
    DFS(tree, vseen, vdist, v);

    int reachablefurthestnode = 0;
    int max_vdist = 0;
    bool is_owattoru = false;
    for (int i = 1; i <= n; i++)
    {
        if (udist[i] == 0)
        {
            is_owattoru = true;
        }

        if (udist[i] < vdist[i])
        {
            if (max_vdist < vdist[i])
            {
                max_vdist = vdist[i];
                reachablefurthestnode = i;
            }
        }
    }

    /*
    for (auto &&item : udist)
    {
        cout << item << " ";
    }
    cout << endl;
    for (auto &&item : vdist)
    {
        cout << item << " ";
    }
    cout << endl;
*/

    int ans = vdist[reachablefurthestnode];
    if ((vdist[reachablefurthestnode] - udist[reachablefurthestnode]) % 2 == 1)
        ans--;
    if (is_owattoru)
        ans = vdist[reachablefurthestnode] - 1;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a%2 != b%2){
        puts("IMPOSSIBLE");
    }else{
        cout<<((a+b)/2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	int n,m;
	cin>>n>>m;

	std::vector<string> v;

	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		v.pb(s);
	}

	sort(all(v));
	for(string i: v){
		cout<<i;
	}cout<<endl;

	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 256