akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
int w,h;
int s[35][35];
int cost[4];
int vx[4][4]={{1,0,-1,0},{0,1,0,-1},{-1,0,1,0},{0,-1,0,1}};
int vy[4][4]={{0,1,0,-1},{-1,0,1,0},{0,-1,0,1},{1,0,-1,0}};
int vv[4][4]={{0,3,2,1},{1,0,3,2},{2,1,0,3},{3,2,1,0}};

struct S{
	S(int ix,int iy,int iv,int ic){
		x=ix;y=iy;v=iv;c=ic;
	}
	int x,y,v,c;
};

bool operator<(S a,S b){
	return a.c>b.c;
}


S next(S a,int o){
	int c;
	//cout<<(s[a.y][a.x]==o)<<endl;
	if(o!=s[a.y][a.x]){
		c=a.c+cost[o];
	}else{
		c=a.c;
	}
	int x=a.x+vx[a.v][o];
	int y=a.y+vy[a.v][o];
	int v=vv[a.v][o];
	if(x<0||y<0||x>=w||y>=h)c=-1;
	return S(x,y,v,c);
}


int solve(){
	priority_queue<S> q;
	int use[35][35][4];
	for(int i=0;i<35;i++){
		for(int j=0;j<35;j++){
			for(int k=0;k<4;k++){
				use[i][j][k]=0;
			}
		}
	}
	
	q.push(S(0,0,0,0));
	while(!q.empty()){
		S now=q.top();q.pop();
		
		if(use[now.x][now.y][now.v])continue;
		use[now.x][now.y][now.v]=true;
		
		if(now.x==w-1&&now.y==h-1){
			return now.c;
		}
		
		for(int i=0;i<4;i++){
			S npos= next(now,i);
			if(npos.c!=-1){
				//cout<<npos.x<<" "<<npos.y<<" "<<npos.c<<endl;
				q.push(npos);
			}
		}
		
	}
	return 0;
}
bool input(){
	cin>>w>>h;
	if(!(w||h))return 0;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<4;i++){
		cin>>cost[i];
	}
	return 1;
}



int main(){
	while(input()){
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 1352
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================

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

	int n;
	cin >> n;

	LL ans = 0;
	REP3(i, 1, n) {
		ans += i;
	}

	cout << ans << "\n";
	return 0;
}

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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    cout << (N - 1 + K - 2) / (K - 1) << endl;
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int ct[100010];

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

  REP(i, n) {
    cin >> a;
    ct[a]++;
    if (a != 0) {
      ct[a - 1]++;
    }
    ct[a + 1]++;
  }

  int res = -1;
  REP(i, 100001) {
    res = max(res, ct[i]);
  }

  cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int alp = 26;
int D;
vector<long long> c(alp);
vector< vector< long long > > s;

long long score(vector<int>& t){
    if(t.size() != D) return 0;
    vector< int > last(alp, -1);
    long long res = 0;
    for(int i=0;i<D;i++){
        res += s[i][t[i]-1];
        last[t[i]-1] = i;
        for(int j=0;j<alp;j++){
            res -= c[j] * (i-last[j]);
        }
        cout << res << endl; // B
    }
    return res;
}

int main(void){
    cin >> D;
    for(int i=0;i<alp;i++) cin >> c[i];
    s.assign(D, vector<long long>(alp, 0));
    for(int i=0;i<D;i++){
        for(int j=0;j<alp;j++) cin >> s[i][j];
    }

    // B
    vector<int> t(D);
    for(int i=0;i<D;i++) cin >> t[i];
    score(t);
}


Measured memory_bytes: 3248
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    double d, x;
    cin >> n >> d >> x;
    double ans = 0.0;
    while (n){
        ans += d + (n - 0.5) * x;
        d += (2 * d + 5 * x) / (2 * n);
        x += 2 * x / n;
        n--;
    }
    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const ll mod = 998244353;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<mint>> dp(c+1, vector<mint>(d+1, 0));
    dp[a][b] = 1;
    for(int i = a+1; i <= c; ++i){
        dp[i][b] = dp[i-1][b] * b;
    }
    for(int j = b+1; j <= d; ++j){
        dp[a][j] = dp[a][j-1] * a;
    }
    for(int i = a+1; i <= c; ++i){
        for(int j = b+1; j <= d; ++j){
            dp[i][j] = dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1)*(j-1);
        }
    }
    cout << dp[c][d].x << endl;
    return 0;
}


Measured memory_bytes: 73672
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

const ll mod = 998244353ll;
// const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5],rfact[fact_table + 5];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n, m, k, num, a, b, c, d, e, h, q, ans, sum;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

ll x[500005], y[500005];

string s, t;

void solve() {
    cin >> n;
    ll sum = 0;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        sum += x[i];
        y[x[i]] ++;
    }
    cin >> q;
    for(ll i=0;i<q;i++){
        cin >> b >> c;
        sum += y[b] * (c - b);
        y[c] += y[b];
        y[b] = 0;
        p(sum);
    }

    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n; cin >> n;
    vector<int> h(n+5, 0);
    repr(i, 1, n+1) cin >> h[i];

    vector<int> dp(n+5, 0);
    repr(i, 2, n+1){
        if(i==2) dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>

int main(){
    
    int a, b, c;

    scanf("%d %d %d\n", &a, &b, &c);

    if (a < b && b < c) {
      printf("Yes\n");
    }
    else {
      printf("No\n");
    }
   
    return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
    int n;
    cin>>n;
    map<int,int> m;
    vector<int> a(n+1);
    for(int i=1; i<n+1; i++){
        int aa;
        cin>>aa;
        a.at(i) = aa;
        if(m.count(i-aa)){
            m.at(i-aa)++;
        }
        else{
            m[i-aa] = 1;
        }
    }
    ll ans =0;
    for(int i=1; i<n+1; i++){
        if(m.count(a.at(i)+i) ){
            ans += m.at(a.at(i)+i);
        }
        m.at(i-a.at(i))--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12708
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}

int32_t main()
{
  io
int n;
cin>>n;int ans=0;
for(int i=1;i<=n;i++)
{
  if(!(i%3==0||i%5==0))
    ans+=i;
}
cout<<ans<<endl;

}

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

using namespace std;

void solve() {
    double d, t, s;
    cin >> d >> t >> s;

    if (d / s <= t) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3752
from sys import exit
N,K = [int(n) for n in input().split()]
K-=1
h = [int(input()) for _ in range(N)]
h = sorted(h)
minm = 10**9
# print(h)

for i in range(0,N-K):
    # print(h[i],h[i+K])
    if h[i+K]-h[i] < minm:
        minm = h[i+K]-h[i]
print(minm)
# S = str(input())
# L = len(S)
# T = str(input())
# exit()


Measured memory_bytes: 8280
#include<stdio.h>

int main(void){

    int A,B,C,Val,i;
    
    scanf("%d %d %d",&A,&B,&C);

    Val = A;
    for(Val = A;Val <= A * B;Val += A){
        if(Val % B == C){
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

vector<int> ans[100000];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N;
	cin >> N;
	for (int i = 2; 1LL * i*(i - 1) / 2 <= N; i++) {
		if (1LL * i*(i - 1) / 2 == N) {
			for (int j = 0; j < i; j++) {
				for (int k = 0; k < j; k++) {
					ans[j].push_back(N);
					ans[k].push_back(N--);
				}
			}
			cout << "Yes\n" << i << '\n';
			for (int j = 0; j < i; j++) {
				cout << ans[j].size();
				for (auto a : ans[j]) cout << ' ' << a;
				cout << '\n';
			}
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef double db;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

int H, W, n;
int xc, yc;
string s, t;

int main() {
	cin >> H >> W >> n >> xc >> yc >> s >> t;
	xc--; yc--;
	int L = 0, R = W-1;
	bool F = true;
	for (int i = n-1; i >= 0; i--) {
		if (t[i] == 'R') {
			L = max(L-1, 0);
		}
		if (t[i] == 'L') {
			R = min(R+1, W-1);
		}
		if (s[i] == 'L') {
			L++;
		}
		if (s[i] == 'R') {
			R--;
		}
		if (L > R) F = false;
	}
	if (yc < L || yc > R) F = false;

	L = 0, R = H-1;
	for (int i = n-1; i >= 0; i--) {
		if (t[i] == 'D') {
			L = max(L-1, 0);
		}
		if (t[i] == 'U') {
			R = min(R+1, H-1);
		}
		if (s[i] == 'U') {
			L++;
		}
		if (s[i] == 'D') {
			R--;
		}
		if (L > R) F = false;
	}
	if (xc < L || xc > R) F = false;
	if (F) puts ("YES"); else puts ("NO");
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

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

    vector<int> a;
    int dist = 0;
    REP(i, n)
    {
        int t;
        cin >> t;
        a.push_back(t);
    }
    rep(i, 1, n)
    {
        dist += abs(a[i] - a[i - 1]);
    }
    dist += abs(a[0] - 0);
    dist += abs(a[n - 1] - 0);

    REP(i, n)
    {
        int ans = dist;
        if (i > 0 && i < n - 1)
        {
            cout << ans + abs(a[i - 1] - a[i + 1]) - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) << endl;
        }
        else if (i == 0)
        {
            cout << ans + abs(0 - a[i + 1]) - abs(a[i] - 0) - abs(a[i] - a[i + 1]) << endl;
        }
        else
        {
            cout << ans + abs(a[i - 1] - 0) - abs(a[i] - a[i - 1]) - abs(a[i] - 0) << endl;
        }
    }
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 200010;
ll a[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n; 	
	cin >> n;

	for(int i = 0; i < n; i++) cin >> a[i];

	int min = INT_MAX, count = 0;
	for(int i = 0; i < n; i++){
		if(min > a[i]){
			min = a[i];
			count++;
		}
	}
	cout << count ;
}

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

const int mod = 1e9 + 7;
const int N = 5e3 + 10;

int k , n , dp[N][N];
char s[N];

int Add(int a , int b){
	return a + b > mod ? a + b - mod : a + b;
}

int Mul(int a , int b){
	return 1ll * a * b % mod;
}

int Pow(int a , int k){
	if(k == 1) return a;
	int S = Pow(a , k >> 1);
	if(k & 1) return Mul(a , Mul(S , S));
	else return Mul(S , S);
}

int main(){
	scanf("%d %s" , &k , s) , n = strlen(s);
	dp[0][0] = 1;
	for(int i = 0; i <= k; i++)
		for(int j = 0; j <= i; j++){
			dp[i + 1][j + 1] = Add(dp[i + 1][j + 1] , dp[i][j] * 2);
			dp[i + 1][max(j - 1 , 0)] = Add(dp[i + 1][max(j - 1 , 0)] , dp[i][j]);
		}
	printf("%d" , Mul(dp[k][n] , Pow(Pow(2 , n) , mod - 2)));
	return 0;
}

Measured memory_bytes: 70688
#include<bits/stdc++.h>
using namespace std;
int main ( )
{
	char a,b,c;
	cin>>a>>b>>c;
	if(a=='A'&&b=='B'&&c=='C')
	{
		cout<<"ARC";
	 } 
	 else
	 {
	 	cout<<"ABC";
	 }
	 return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int b[100002] = {};
    for(int i = 0; i < n; i++){
        int cur;
        cin >> cur;
        b[cur]++;
        b[cur - 1]++;
        b[cur + 1]++;
    }
    int max = 0;
    for(int i = 0; i < 100002; i++){
        if(max < b[i]) max = b[i];
    }
    cout << max << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, l, r);
    
    if(r+1-l >= 2019){
        Cout(0);
        return 0;
    }
    ll ans = 2019;
    for(ll i = l; i <= r; i ++){
        for(ll j = i+1; j <= r; j ++){
            Mini(ans, i*j % 2019);
        }
    }
    Cout(ans);
}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

    int N;
    cin >> N;
    vector<string> ss;
    vector<int> ts;
    for (int i=0; i<N; i++) {
        string s;
        int t;
        cin >> s >> t;

        ss.push_back(s);
        ts.push_back(t);
    }
    string X;
    cin >> X;

    bool asleep = false;
    int total = 0;
    for (int i=0; i<N; i++) {
        if (asleep) total += ts[i];

        if (ss[i] == X) asleep = true;
    }

    cout << total << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int n,a,b,c,a1,b2,c2;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		a1=pow(a,2);
		b2=pow(b,2);
		c2=pow(c,2);
		if(a1+b2==c2)
			cout<<"YES"<<endl;
		if(a1+c2==b2)
			cout<<"YES"<<endl;
		if(b2+c2==a1)
			cout<<"YES"<<endl;
		if(a1+b2!=c2&&a1+c2!=b2&&b2+c2!=a1)
			cout<<"NO"<<endl;
	}
				
	return 0;
}

Measured memory_bytes: 3080
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int K; cin >> K;
	ll now = 7;
	FOR(i, 1,1e7) {
		if (now%K == 0) {
			print(i); return;
		}
		now *= 10;
		now += 7;
		now %= K;
	}
	print(-1);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3644
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c = readInts()
print(min(abs((a//2) * b * c - (a-a//2) * b * c), abs(a * (b-b//2) * c - a* (b//2) * c), abs(a*b*(c-c//2) - a*b*(c//2))))


Measured memory_bytes: 10396
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,i=0,j=0,k=0,minj=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    ArrayList<Integer> SortArray = new ArrayList<Integer>();
    try{
      String line = reader.readLine();
      b = Integer.parseInt(line);
      line = reader.readLine();
      for(String splitted: line.split(" ")){
        SortArray.add(Integer.parseInt(splitted));
      }
		}catch(Exception e){
    }

    int sortArray[] = new int[b];
    for(k = 0;k < b; k++){
      sortArray[k] = SortArray.get(k);
    }

    for (i = 0; i < b - 1; i++) {
      minj = i;
      for (j = i + 1; j < b; j++) {
          if (sortArray[j] < sortArray[minj]) {
            minj = j;
            
          }
          
       }
       if (i == minj) {
        continue;
       }
       c++;
       a = sortArray[i];
       sortArray[i] = sortArray[minj];
       sortArray[minj] = a;
  }

  for(i = 0;i < b;i++){
    System.out.print(sortArray[i]);
    if(i == b - 1){

    }else{
      System.out.print(" ");
    }
  }

  System.out.print("\r\n");
  System.out.println(c);

  }
}


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

int main(){
 long h,w; cin >> h >> w;
 if(h%2==0&&w%2==0){
   cout << h*w/2 << endl;
 }
  if(h%2==0&&w%2!=0){
    if(w==1){
      cout << 1 << endl;
    }
    else{
      cout << h*(w-1)/2+h/2 << endl;
    }
  }
  if(h%2!=0&&w%2==0){
    if(h==1){
      cout << 1 << endl;
    }
    else{
      cout << (h-1)*w/2+w/2 <<endl;
    }
  }
  if(h%2!=0&&w%2!=0){
    if(h==1||w==1){
      cout << 1 << endl;
    }
    else{
      cout << (h-1)*(w-1)/2+(h-1)/2+(w-1)/2+1 << endl;
    }
  }
}


Measured memory_bytes: 256
class SegmentTree():
    """区間更新、一点取得クエリをそれぞれO(logN)で答えるデータ構造を構築する
    update: 区間[begin, end)をvalに更新する
    get_val: i番目の値を求める
    """
    def __init__(self, n):
        self.update_cnt = 0
        self.n = n
        self.size = 1
        INF = 2**32 - 1
        while self.size < n:
            self.size *= 2
        self.node = [(self.update_cnt, -1) for i in range(2*self.size - 1)]

    def update(self, begin, end, val):
        self.update_cnt += 1
        begin += (self.size - 1)
        end += (self.size - 1)
        while begin < end:
            if (end - 1) & 1:
                end -= 1
                self.node[end] = (self.update_cnt, val)
            if (begin - 1) & 1:
                self.node[begin] = (self.update_cnt, val)
                begin += 1
            begin = (begin - 1) // 2
            end = (end - 1) // 2

    def get_val(self, i):
        i += (self.size - 1)
        val = self.node[i]
        while i > 0:
            i = (i - 1) // 2
            val = max(val, self.node[i])
        return val[1]


n, m = map(int, input().split())
s = input()
st = SegmentTree(n+1)

for i in range(n+1)[::-1]:
    if s[i] == "0":
        st.update(i+1, min(i+1+m,n+1) , i)

pos = []
start = n
while True:
    if start == 0:
        break
        
    tmp = st.get_val(start)
    if tmp == -1:
        print(-1)
        exit()
    pos.append(start - tmp)
    start= tmp
print(*pos[::-1])

Measured memory_bytes: 63216
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int H, A, B, res = 0;
  cin >> H >> A >> B;

  for(int i=A; i<=B; ++i) {
    if(H%i==0) ++res;
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main()
{
    // std::cout << std::fixed << std::setprecision(10);
    int n; std::cin >> n;
    std::vector<int> w(n);
    std::cin >> w[0];
    for(int i=1; i<n; i++)
    {
        int temp;
        std::cin >> temp;
        w[i] = temp + w[i-1];
    }
    int ans = 1000000000;
    for(int i=0; i<n-1; i++)
    {
        int temp = (w[n-1] - w[i]) - w[i];
        if((w[n-1] - w[i]) < w[i])
            temp = -temp;
        ans = std::min(ans, temp);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long

ll n, q;
ll ans[200001];
queue<ll> que[200001];
ll ad[200001];

void add(ll p, ll x){
    ans[p] += x;
    int que_s = que[p].size();
    for(int k=0; k<que_s; k++){
        int s = que[p].front();
        que[p].pop();
        que[p].push(s);
        ad[s] += x;
    }
}

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

    for(int i=0; i<n-1; i++){
        int a, b;
        cin>>a>>b;
        que[a].push(b);
    }

    for(int i=0; i<q; i++){
        int p, x;
        cin>>p>>x;
        ad[p] += x;
    }

    for(int i=1; i<=n; i++){
        if(ad[i]>0){
            add(i, ad[i]);
        }
    }

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

    return 0;
}

Measured memory_bytes: 141440
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep(0, i, N)
    {
        cin >> T.at(i);
    }
    sort(all(T));

    ll due = T.at(0) + K, wait = 0, send = 0, ans = 0;
    rep(0, i, N)
    {
        if (due == T.at(i))
        {
            wait++;
            if (wait > C)
            {
                ans += wait / C;
                send += (wait / C) * C;
                wait = wait % C;
            }
            else
            {
                ans++;
                send += wait;
                wait = 0;
            }
            if (send < N)
            {
                due = T.at(send) + K;
            }
        }
        else if (due < T.at(i))
        {
            if (wait > C)
            {
                ans += wait / C;
                send += (wait / C) * C;
                wait = wait % C;
            }
            else
            {
                ans++;
                send += wait;
                wait = 0;
            }
            if (send < N)
            {
                due = T.at(send) + K;
            }
            wait++;
        }
        else
        {
            wait++;
        }
    }

    if (wait != 0)
    {
        ans += (wait + C - 1) / C;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	vector<string> W(N);
	for (int i = 0; i < N; ++i) {
		cin >> W[i];
	}

	char latest = W[0][W[0].size()-1];
	for (int i = 1; i < N; ++i) {
		for (int j = 0; j < i; ++j) {
			if (W[i] == W[j]) {
				cout << "No" << endl;
				return 0;
			}
		}

		if (W[i][0] != latest) {
			cout << "No" << endl;
			return 0;
		}
		latest = W[i][W[i].size() - 1];
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < K; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                list.add(sc.nextInt());
            }
        }

        int count = 0;
        for (int k = 1; k <= N; k++) {
            if(!list.contains(k)) {
                count += 1;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 46684
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= 1000; i++)
		if (a * i % b == c)
		{
			cout << "YES\n"; return 0;
		}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;int main(){int i,j;string s[i=8],t;for(;i-->0;)getline(cin,s[i]);t="90\n";for(;++i<8;){for(j=0;j<8;)t+=s[j++][i];t+="\n";}t+="180\n";for(;i-->0;){for(j=8;j-->0;)t+=s[7-i][j];t+="\n";}t+="270\n";for(;++i<8;){for(j=8;j-->0;)t+=s[j][7-i];t+="\n";}cout<<t;return 0;}

Measured memory_bytes: 0
a,b,k = gets.split.map(&:to_i)

k.times{|i|
  if i%2==0
    a -= 1 if a%2==1
    b += a/2
    a = a/2
  else
    b -= 1 if b%2==1
    a += b/2
    b = b/2
  end
}

puts [a,b]*" "

Measured memory_bytes: 1788
str1 = input()
str2 = [a for a in str1]
num1_list = []
num1_list.append(str2.count("K"))
num1_list.append(str2.count("U"))
num1_list.append(str2.count("P"))
num1_list.append(str2.count("C"))
num1_list.sort()
print(num1_list[0])


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    bool eq = true;
    ll ans = 0, mn = LINF;
    ll a[n], b[n];
    rep(i, n) {
        cin >> a[i] >> b[i];
        if (a[i] != b[i]) eq = false;
        if (a[i] > b[i]) mn = min(mn, b[i]);
        ans += b[i];
    }
    if (eq) cout << 0 << endl;
    else cout << ans - mn << endl;
    return 0;
}

Measured memory_bytes: 512
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47496
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <bitset>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<std::vector<int>> edges(n);
	for(int i = 1; i < n; i++) {
		int p;
		std::cin >> p;
		edges[p-1].push_back(i);
	}
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	std::vector<int> dp(n);
	const int ms = 5050;
	for(int i = n-1; i >= 0; i--) {
		std::bitset<ms> cur;
		cur[0] = 1;
		int bst = 0;
		int other = 0;
		for(auto j : edges[i]) {
			int u = a[j], v = dp[j];
			if(u > v) std::swap(u, v);
			bst += u;
			other += v - u;
			cur |= (cur << (v-u));
		}
		if(bst > a[i]) {
			std::cout << "IMPOSSIBLE\n";
			return 0;
		}
		int id = a[i] - bst;
		while(!cur[id]) id--;
		dp[i] = other - id;
	}
	std::cout << "POSSIBLE\n";
}

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

int cmp(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void){

  long n,k;
  scanf("%ld %ld", &n, &k);
  long h[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }

  qsort(h, sizeof(h) / sizeof(h[0]), sizeof(long), cmp);

  long attack = 0;
  for (long i = k; i < n; i++) {
    attack += h[i];
  }

  printf("%ld\n", attack);

  return 0;
}

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

using namespace std;

int main()
{
   
   long long a, b, c, k;
   cin >> a >> b >> c >> k;
   
   if(a+b >= k) {
       
       if(a == 0) {
           cout << 0 << endl;
       }
       else {
           if(a >= k) {
               cout << k <<  endl;
           }
           else {
               cout <<  a << endl;
           }
       }
   }
   else {
       k = k-(a+b);
       
       cout << a - (c <= k ?  c  : k) << endl;
   }
   
   
   
   
    
    
   
   return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    char c;
    c = getchar();
    long long int ans = 0;
    while(c!='\n'&&c){
        ans += c-'0';
        c = getchar();
    }
    if(ans%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	ll g;
	cin >> n >> g;
	g/=100;
	vector<int> v(n), c(n);
	rep(i,0,n){
		cin >> v[i] >> c[i];
		c[i]/=100;
	}
	const int inf = 1e9;
	int mn = inf;
	rep(msk,0,1 << n){
		rep(i,0,n){
			if((msk >> i)&1){
				int cnt = 0;
				ll val = 0;
				rep(j,0,n){
					if((msk >> j)&1){
						cnt += v[j];
						val += 1LL*(j+1)*v[j] + c[j];
					}
				}
				if(val >= g)gmin(mn, cnt);	
				cnt -= v[i];
				val -= 1LL*(i+1)*v[i] + c[i];
				rep(j,0,v[i]){
					if(val + (i+1) * j >= g){
						gmin(mn, cnt + j);
						break;
					}
				}
			}
		}
	}
	cout << mn << '\n';
}


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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int n;
    map <string ,int> m;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    cin >>n;
    for (int i=0; i<n; i++) {
        string s;
        cin >>s;
        m[s]++;
    }
    cout <<"AC x " <<m["AC"] <<n1;
    cout <<"WA x " <<m["WA"] <<n1;
    cout <<"TLE x " <<m["TLE"] <<n1;
    cout <<"RE x " <<m["RE"];


    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    int u = 0;
    int result = 0;
    for (char c : s) {
        if (c == 'g') {
            if (u) -- u, result ++;
            else ++ u;
        } else {
            if (u) -- u;
            else ++ u, result --;
        }
    }
    printf("%d\n", result);
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int D;
  cin >> D;
  cout << "Christmas";
  if (D <= 24) {
    cout << " Eve";
  }
  if (D <= 23) {
    cout << " Eve";
  }
  if (D <= 22) {
    cout << " Eve";
  }
  cout << '\n';
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <unordered_map>

#include <cassert>
using namespace std;


long long f_hs(long long a,long long b){
    return a*1000000000+b;
}
pair<long long,long long> i_hs(long long k){
    return pair<long long,long long>(k/1000000000,k%1000000000);
}
 
std::unordered_map<long long,bool> blacks, well_known;
std::vector<long long> result;

int main(void){
	result.assign(10,0);

	long long h=0,w=0,n=0;
	cin >> h>>w>>n;
	for(int ni=0;ni<n;ni++){
		long long ia,ib;
		cin >> ia>>ib;
		blacks[ f_hs(ia-1,ib-1) ] = true;
	}

	for(auto bitr : blacks){
		auto ip = i_hs(bitr.first);
		auto ia=ip.first,ib=ip.second;

		for(auto ca=ia-1;ca<=ia+1;ca++){
			if(ca+1>=h || ca-1<0){continue;}
			for(auto cb=ib-1;cb<=ib+1;cb++){
				if(cb+1>=w || cb-1<0){continue;}
				if(well_known[f_hs(ca,cb)]){continue;}

				long cnt=0;
				for(auto fa=ca-1;fa<=ca+1;fa++){
					for(auto fb=cb-1;fb<=cb+1;fb++){
						if(blacks.count(f_hs(fa,fb))!=0){cnt++;}
					}
				}
				result[cnt]++;
				well_known[f_hs(ca,cb)]=true;
			}
		}
	}

	result[0] = (h-2)*(w-2);
	for(int i=1;i<=9;++i){ result[0]-=result[i];}
	for(int i=0;i<=9;++i){ cout << result[i] << endl; }

	return 0;
}

Measured memory_bytes: 40720
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

const int NMAX = 1e5 + 5;
vector <lli> ar(NMAX);
int n;

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; i++) cin >> ar[i];
	sort(ar.begin(), ar.begin()+n);	
	cout << ar[n-1] << " ";
	auto it = lower_bound(ar.begin(), ar.begin()+n, ar[n-1]/2);
	int idx2 = it - ar.begin() - 1;
	int idx1 = it - ar.begin();

	if(idx1 == n-1){
		idx1 = idx2;
	}else
		if(abs(ar[n-1]/2 - ar[idx2]) < abs(ar[n-1]/2 - ar[idx1]))
			idx1 = idx2;
	cout << ar[idx1];
	return 0;
}

Measured memory_bytes: 1024