akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vi v(N), c(N);

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> c[i];
        ans += max(0, v[i] - c[i]);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
multiset<ll> msl;
multiset<ll> msr;
int main() {
    int q;
    cin >> q;
    ll sumb = 0;
    ll suma = 0;
    bool valid = true; //medがvalidか
    ll c1, a1, b1;
    cin >> c1 >> a1 >> b1;
    sumb+=b1;
    ll med = a1;
    ll suml = 0;
    ll sumr = 0;
    vector<ll> ans1;
    vector<ll> ans2;
    for (int i = 2; i <= q; i++) {
        int c;
        cin >> c;
        if (c == 1) {
            int a, b;
            cin >> a >> b;
            if (!valid) {
                //左右の個数が等しい
                if (*msl.rbegin() >= a) {
                    int x = *msl.rbegin();
                    msl.erase(msl.find(x));
                    msl.insert(a);
                    med = x;
                    suml = suml - x + a;
                }
                else if (*msr.begin() <= a) {
                    int x = *msr.begin();
                    msr.erase(msr.find(x));
                    msr.insert(a);
                    med = x;
                    sumr = sumr - x + a;
                }
                else {
                    med = a;
                }
                valid = true;
            }
            else {
                if (a <= med) {
                    msl.insert(a);
                    msr.insert(med);
                    suml += a;
                    sumr += med;
                }
                else {
                    msl.insert(med);
                    msr.insert(a);
                    suml += med;
                    sumr += a;
                }
                valid = false;
            }
            sumb+=b;
        }
        else {
            if (valid) {
                ans1.push_back(med);
                ans2.push_back(sumr - suml + sumb);
            }
            else {
                ans1.push_back(*msl.rbegin());
                ans2.push_back(sumr - suml + sumb);
            }
        }
    }
    for (int i = 0; i < ans1.size(); i++) {
        cout << ans1[i] << " " << ans2[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12952
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a,b, d, r;
    double f;

    cin >> a >> b;

    d =  a / b;
    r =  a % b;
    f = ((double)a )/ ((double)b);

    cout << d << " " << r << " ";
    printf("%.5lf\n", f);

    return 0;
}


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

int main(){
   int n,m,a,b;
   cin >> n >> m;
   int A[n][m];
   int B[m];

   for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
         cin >> a;
         A[i][j]=a;
      }
   }
   for(int i=0; i<m; i++){
      cin >> b;
      B[i]=b;
   }

   for(int i=0; i<n; i++){
      long int C=0;
      for(int j=0; j<m; j++){
         C+=A[i][j]*B[j];
      }
      printf("%ld\n",C);
   }
   return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s; cin >> s;
	string rev(s);
	reverse(rev.begin(), rev.end());
	int result = 0;
	for (unsigned int i = 0; i < s.size(); i++) {
		if (s[i] != rev[i]) result++;
	}
	cout << result / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    set<int> s;
    rep(i, N) {
        int d;
        cin >> d;
        s.emplace(d);
    }

    cout << s.size() << endl;
    
    return 0;
}

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

int n,m,num,selectable,arr[101],vote;

int main(){
	cin>>n>>m;
	for(int i = 1;i <= n;i++){
		cin>>num;
		vote = vote + num;
		arr[i] = num;
	}
	for(int i = 1;i <= n;i++){
		if(arr[i] * 4 * m >= vote){
			selectable++;
		}
	}
	if(selectable >= m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

using VC = vector<char>;
using P = pair<long, long>;
using VP = vector<P>;

void addVote(VP &v, int k) {
  for (auto &w: v) {
    if (w.second == k) w.first += 1;
  }
}

void solve(long n) {
  if (n == 1) {
    char c;
    cin >> c;
    cout << c << " " << 1 << endl;
    return;
  }
  VP cands;
  for (int i = 0; i < 26; i++) {
    cands.push_back(P(0, i));
  }
  vector<long> ks;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    ks.push_back(c - 'A');
  }
  for (int i = 0; i < n; i++) {
    addVote(cands, ks[i]);
    sort(cands.begin(), cands.end(), greater<P>());
    if (cands[0].first > cands[1].first + (n - i - 1)) {
      cout << char(cands[0].second + 'A') << " " << i + 1 << endl;
      return;
    }
  }
  cout << "TIE" << endl;
}

int main() {
  while (1) {
    long n;
    cin >> n;
    if (!n) {
      return 0;
    }
    solve(n);
  }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  int n,x,t; cin>>n>>x>>t;
  x = t * ((n + x - 1) / x);
  cout << x;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
 
// Longest Common Subsequence
int c[1005][1005];
int LCS(char *x, int m, char *y, int n)
{
    int i, j;
 
    for (i = 0; i <= m; i++)  c[i][0] = 0;
    for (j = 0; j <= n; j++)  c[0][j] = 0;
 
    for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) {
        if (x[i-1] == y[j-1]) c[i][j] = c[i-1][j-1] + 1;
        else if (c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
        else                             c[i][j] = c[i][j-1];
    }
    return c[m][n];
}
 
char x[1005], y[1005];
 
int main()
{
    int q, lx, ly;
    char *p;
 
    fgets(x, 10, stdin);
    q = atoi(x);
    while (q--) {
        fgets(p=x, 1005, stdin);
        while (*p > ' ') p++;
        *p = 0, lx = p-x;
 
        fgets(p=y, 1005, stdin);
        while (*p > ' ') p++;
        *p = 0, ly = p-y;
 
        printf("%d\n", LCS(x, lx, y, ly));
    }
    return 0;
}



Measured memory_bytes: 5596
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *STOI GDOI APIO CTS NOIP 2019 RP++                        *
 ***********************************************************/
//#pragma GCC optimize(3)
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 20020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (int)(1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}

template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}

inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
int n,fir[mn],nxt[mn],y[mn],a[mn],x,yy,tot,In[mn],ans,d[mn],now,mx,num,an[mn];
inline void adde(int x,int yy){
	nxt[++tot]=fir[x];fir[x]=tot;y[tot]=yy;++In[x];
}
struct node{
	int x,c;
};
inline bool operator<(const node &a,const node &b){return a.c<b.c;}
priority_queue<node>q[mn];
inline void dfs(int x,int fa){
	d[x]=a[now--];
	for(int i=fir[x];i;i=nxt[i])if(y[i]!=fa)q[x].push((node){y[i],In[y[i]]});
	int yy;
	while(!q[x].empty()){
		yy=q[x].top().x;q[x].pop();
		dfs(yy,x);
		num+=Min(d[x],d[yy]);
	}
}
signed main(){
	n=read();
	FOR(i,2,n)x=read(),yy=read(),adde(x,yy),adde(yy,x);
	FOR(i,1,n)a[i]=read();
	sort(a+1,a+1+n);
	FOR(i,1,n)mx=Max(mx,In[i]);
	FOR(i,1,n)if(In[i]==mx){
		now=n;num=0;
		dfs(i,0);
		if(num>ans){
			ans=num;
			FOR(j,1,n)an[j]=d[j];
		}
		break;
	}
	writeln(ans);
	FOR(i,1,n)write_(an[i]);puts("");
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

vector< LP > v, vr;

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

    for( int i = 0; i < n; ++i ) {
        LL a, b;
        cin >> a >> b;
        v.pb( MP( a, b ) );
        vr.pb( MP( b, a ) );
    }
    sort( v.begin(), v.end() );
    sort( vr.begin(), vr.end(), greater<>() );
    LL ans = 0, ansr = 0;
    LL tmp = m;
    for( int i = 0; i < n; ++i ) {
        if( tmp - v[i].S <= 0 ) {
            ans += v[i].F * tmp;
            break;
        } else {
            ans += v[i].F * v[i].S;
            tmp -= v[i].S;
        }
    }
    
    
    for( int i = 0; i < n; ++i ) {
        if( m - vr[i].F <= 0 ) {
            ansr += vr[i].S * m;
            break;
        } else {
            ansr += vr[i].F * vr[i].S;
            m -= vr[i].F;
        }
    }

    cout << min( ans, ansr ) << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll 	P[10], Q[10];
int main() {
    ll N, a, b; cin >> N;
    for (ll i = 0; i < N; i++) cin>> P[i];
    for (ll i = 0; i < N; i++) cin>> Q[i];
    vector<ll> num;
    for (ll i = 0; i < N; i++){
        num.push_back(i+1);
    }

    ll c = 0;
    do{
        for (ll i = 0; i < N; i++){
            if(num[i] != P[i]) break;
            if(i == N-1) a = c+1;
        }
        for (ll i = 0; i < N; i++){
            if(num[i] != Q[i]) break;
            if(i == N-1) b = c+1;
        }
        c++;
    }while(next_permutation(num.begin(),num.end()));

    printf("%lld\n", abs(a-b));
    
    return 0;
}

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

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


Measured memory_bytes: 4796
from fractions import Fraction

a=input()
a=a.split()

X=int(a[0])
Y=int(a[1])

x=Fraction(4*X-Y,2)
y=Fraction(Y-2*X,2)

if x-round(x)==0 and x >= 0:
  if y-round(y)==0 and y >= 0:
    print("Yes")
  else :
    print("No")
else:
  print("No")

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

int main() {

	vector<string> c = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s; cin >> s;
	int ans;
	if (s == c[0]) ans = 7;
	if (s == c[1]) ans = 6;
	if (s == c[2]) ans = 5;
	if (s == c[3]) ans = 4;
	if (s == c[4]) ans = 3;
	if (s == c[5]) ans = 2;
	if (s == c[6]) ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;
int arr[100005];
int main()
{

    int n,x;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> x;
        arr[x]++;
        arr[x+1]++;
        arr[x-1]++;
    }
    int mx=-1,mi;
    for (int i=0;i<100001;i++)
    {
        if (arr[i] > mx)
        {
            mx=arr[i];
            mi=i;
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF (1 << 30)
using namespace std;

int N, K, A;
vector<int> R, E[100000];
bool ans[100000];

int dfs(int v) {
  int depth = INF;
  for(int u : E[v]) depth = min(depth, dfs(u));
  if(depth == INF) depth = 0;
  if(depth < K) ans[v] = true;
  return depth + 1;
}

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) {
    cin >> A;
    if(A >= 1) E[A - 1].push_back(i);
    else R.push_back(i);
  }

  REP(i, 0, N) ans[i] = false;
  REP(i, 0, R.size()) ans[R[i]] = true, dfs(R[i]);

  int cnt = 0;
  REP(i, 0, N) if(ans[i]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 13316
from collections import Counter as C

_ = input()
a = C(map(int, input().split()))

b = []
for k, v in a.items():
    b.extend([k] * (v // 2))
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)

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

int main()
{
  ll x;
  cin >> x;

  for (int a = -118; a <= 119; a++)
  {
    for (int b = -119; b <= 118; b++)
    {
      if ((a * a * a * a * a) - (b * b * b * b * b) == x)
      {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

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

class dice
{
public:
    int F[6];
	int q;
    dice();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
};

dice::dice()
{
    for(int i = 0; i < 6; i++) cin >> F[i];
	q = 0;
}

void dice::roll_a()
{
    q = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = q;
    q = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = q;
}

void dice::roll_b()
{
    q = F[0]; F[0] = F[5]; F[5] = q;
    q = F[1]; F[1] = F[3]; F[3] = q;
    q = F[2]; F[2] = F[4]; F[4] = q;
}

bool dice::check(const dice& d)
{
	static int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

int main()
{
    dice d1 = dice();
    dice d2 = dice();
    bool eq = false;

    for(int i = 0; i < 2; i++){
        eq = d1.check(d2);
        if(!eq){ d1.roll_a(); eq = d1.check(d2); }
        if(!eq){ d1.roll_a(); eq = d1.check(d2); }
        if(eq || (i == 1)) break;
        d1.roll_b();
    }

	if(eq){ cout << "Yes" << endl; }else{ cout << "No" << endl; }

    return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += A.at(i).at(j) * B.at(j);
    }
    sum += C;
    if (sum > 0) {
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}




int main(){
	int n;
	vector<int> a;
	cin >> n;
	a.resize(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	multiset<int> ms;
	
	for(int i=0; i<n; i++) ms.insert(a[i]);
	set<int> s;
	for(multiset<int>::iterator itr=ms.begin(); itr!=ms.end(); itr++){
		s.insert(*itr);
	}
	int count=0;
	for(set<int>::iterator itr=s.begin(); itr!=s.end(); itr++){
		if(ms.count(*itr) >= *itr) count += *itr;
	}
	
	cout << n-count<<endl;
	
	return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int outlet = 1;
        int count = 0;
        if(B > 1){
            while(true){
                outlet += (A-1);
                count++;
                if(outlet >= B){
                    System.out.println(count);
                    break;
                }
            }
        }
        else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
void a()
{
    string s;
    cin >> s;
    map<char, int> count;
    for (int i = 0; i < 4; i++)
    {
        if (count.count(s[i]) == 0)
        {
            count.insert(make_pair(s[i], 1));
        }
        else
        {
            count.at(s[i]) += 1;
        }
    }
    if (count.size() == 2 && count.at(s[0]) == 2)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    return;
}
void b()
{
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if ((b - a) * (b - c) < 0)
        ans += 1;
    for (int i = 0; i < n - 3; i++)
    {
        int t;
        cin >> t;
        a = b;
        b = c;
        c = t;
        if ((b - a) * (b - c) < 0)
            ans += 1;
    }
    cout << ans;
}
void c()
{
    int n;
    cin >> n;
    vector<int> d;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        d.push_back(l);
    }
    sort(d.begin(), d.end());
    int ans;
    ans = abs(d[n / 2 - 1] - d[n / 2]);
    cout << ans;
}
int main(void)
{
    c();
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
vector<int> V[100010];
int q;
int v[100010];
int d[100010];
int c[100010];
int ans[100010];
vector<int> res[100010];
int max_paint_d[100010];
int max_paint_i[100010];

typedef tuple<int, int, int> state; // vert, dist, ind;
stack<state> S;

int main () {
  cin >> N >> M;
  for (auto i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  cin >> q;
  for (auto i = 0; i < q; ++i) {
    cin >> v[i] >> d[i] >> c[i];
    v[i]--;
    S.push(state(v[i], d[i], i));
  }
  fill(ans, ans+N, 0);
  fill(max_paint_d, max_paint_d+N, 0);
  while (!S.empty()) {
    int src = get<0>(S.top());
    int dist = get<1>(S.top());
    int ind = get<2>(S.top());
    S.pop();
    if (ans[src] == 0) {
      ans[src] = c[ind];
    }
    if (max_paint_d[src] < dist) {
      max_paint_d[src] = dist;
      max_paint_i[src] = ind;
      if (dist >= 1) {
        for (auto dst : V[src]) {
          S.push(state(dst, dist-1, ind));
        }
      }
    }
  }
  for (auto i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 13248
#include<iostream>
using namespace std;
int main(){
    int a,b;
    
    cin>>a;
    int insert[a];
    for(int i=0;i<a;i++){
        cin>>b;
        insert[i]=b;
    }
    
   
    for(int i=0;i<a;i++){
        int v = insert[i];
        int j = i - 1;
        while (j >= 0&& insert[j] > v){
            insert[j+1] = insert[j];
            j--;
            insert[j+1] = v;
            
        }
        for(int p=0;p<a;p++){
            if(p<a-1){
                cout<<insert[p]<<" ";
            }
            else if(p==a-1){
                cout<<insert[p]<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3088
class UnionFind[T] {

  private[this] var map = Map.empty[T, T];

  def addPair(parent: T, child: T): Unit = {
    val pr = fetchRoot(parent);
    val cr = fetchRoot(child);
    if (pr != cr) {
      map = map + (cr -> pr);
    }
  }

  def fetchRoot(elem: T): T = {
    @scala.annotation.tailrec
    def sub(elem: T, pendings: List[(T, T)]): T = {
      map.get(elem) match {
        case None =>
          pendings.foreach { case (c, p) =>
            map = map + (c -> elem);
          }
          elem;
        case Some(p) =>
          sub(p, (elem, p) :: pendings);
      }
    }
    sub(elem, Nil);
  }

}

object Main extends App {
  val sc = new java.util.Scanner(System.in);
  val n, m = sc.nextInt();
  val ps = Array.fill(n)(sc.nextInt());
  val xys = Array.fill(m)((sc.nextInt(), sc.nextInt()));

  val unionFind = new UnionFind[Int];
  xys.foreach { case (x, y) =>
    unionFind.addPair(y, x);
  }

  val answer = ps.zipWithIndex.count { case (p, i) =>
    unionFind.fetchRoot(p) == unionFind.fetchRoot(i + 1);
  }
  println(answer);
}

Measured memory_bytes: 90048
#include <bits/stdc++.h>
using namespace std;
#define long long int

signed main(){
	int x; cin>>x;
	if(x>=1800&&x<=1999)cout<<1<<endl;
	else if(x>=1600&&x<=1799)cout<<2<<endl;
	else if(x>=1400&&x<=1599)cout<<3<<endl;
	else if(x>=1200&&x<=1399)cout<<4<<endl;
	else if(x>=1000&&x<=1199)cout<<5<<endl;
	else if(x>=800&&x <= 999)cout<<6<<endl;
	else if(x>=600&&x<=799)cout<<7<<endl;
	else cout<<8<<endl;
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector< pair<int, int> > ab(M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b; --a; --b;
    ab[i] = make_pair(b, a);
  }

  sort(ab.begin(), ab.end());
  int ans = 1;
  int last = ab[0].first;
  for (int i = 1; i < M; ++i) {
    if (ab[i].second >= last) {
      ans++;
      last = ab[i].first;
    }
  }

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



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n >> m;
    vector<bool> connect1(n + 1, false), connectN(n + 1, false);
    rep (i, m) {
      int a, b;
      cin >> a >> b;
      if (a == 1) {
        connect1[b] = true;
      }
      if (b == n) {
        connectN[a] = true;
      }
    }
    rep (i, n + 1) {
      if (connect1[i] == true && connectN[i] == true) {
        cout << "POSSIBLE" << '\n';
        return 0;
      }
    }
    cout << "IMPOSSIBLE" << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int X = sc.nextInt();
		int last = 0;
		int i = 1;
		for (; i <= N; i++) {
			last += sc.nextInt();
			if (last > X) {
				System.out.println(i);
				break;
			} else if (last <= X && i == N) {
				System.out.println(N + 1);
			}
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 22996
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef vector<ll>vi;
typedef pair<ll,ll>pi;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
ll max(ll a,ll b){return (a>b?a:b);}
ll min(ll a,ll b){return (a<b?a:b);}
ll gcd(ll a,ll b)
{return (b?gcd(b,a%b):a);
}
void algo()
{
    string s1,s2;
    cin>>s1>>s2;
    for(ll i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(20);
    ll t=1;//cin>>t;
    while(t--)
    {
        algo();
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>

int main()
{
  int a, b, c;
  int tmp;
  int flag = 1;

  std::cin >> a >> b >> c;

  while (flag == 1)
  {
    flag = 0;
    if (a > b)
    {
      tmp = a;
      a = b;
      b = tmp;
      flag = 1;
    }
    if (b > c)
    {
      tmp = b;
      b = c;
      c = tmp;
      flag = 1;
    }
  }

  std::cout << a << " " << b << " " << c << '\n';
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {
	/*
	void Solve() {
		UL N, M, V, P; cin >> N >> M >> V >> P;

		UL ans = 0;
		UL A[100000];
		for (UL i = 0; i < N; i++) cin >> A[i];
		sort(A, A + N);
		if (V >= P) {
			N -= P - 1;
			V -= P - 1;
			ans += P;
			reverse(A, A + N);
			LL S = M;
			for (UL i = 1; i < N; i++) {
				if (A[i] + M < A[0]) break;
				S -= (A[i - 1] - A[i]) * i;
				if (V * M <= S + (N - i) * M) ans++;
				S += M + A[i] - A[i - 1];
			}
		}
		else {
			N -= P - 1;
			V = 1;
			ans += P;
			reverse(A, A + N);
			for (UL i = 1; i < N; i++) {
				if (A[0] <= A[i] + M) ans++;
			}
		}
		cout << ans << endl;
	}*/

	char buf[1000][1000];
	const char g4[4][5] = {
		"aabc",
		"ccbc",
		"abaa",
		"abcc"
	};
	const char g5[5][6] = {
		"caabb",
		"cbb.c",
		"a..bc",
		"a..ba",
		"bbcca"
	};
	const char g6[6][7] = {
		"caacc.",
		"c.c..a",
		"aac..a",
		"c..aac",
		"c..c.c",
		".aacaa"
	};
	const char g7[7][8] = {
		".aabbaa",
		"abbc...",
		"ac.c...",
		"bcbb...",
		"b...bbc",
		"a...c.c",
		"a...cbb"
	};
	void Solve() {
		UL N; cin >> N;
		rep(y, N)rep(x, N) buf[x][y] = '.';
		if (N == 2) cout << -1 << endl;
		else if (N == 3) {
			cout << "aac" << endl;
			cout << "c.c" << endl;
			cout << "caa" << endl;
		}
		else {
			UL n = N;
			while (n >= 8) {
				n -= 4;
				rep(y, 4) rep(x, 4) buf[x + n][y + n] = g4[x][y];
			}
			if (n == 4) rep(y, 4)rep(x, 4)buf[x][y] = g4[x][y];
			if (n == 5) rep(y, 5)rep(x, 5)buf[x][y] = g5[x][y];
			if (n == 6) rep(y, 6)rep(x, 6)buf[x][y] = g6[x][y];
			if (n == 7) rep(y, 7)rep(x, 7)buf[x][y] = g7[x][y];
			rep(y, N) {
				rep(x, N) cout << buf[x][y];
				cout << endl;
			}
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
  int Y=0;
  long X=0;
  int minx=1000000000;
  int N;
  cin>>N;
  
  vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
  
  for (int i = 0; i < N; i++) {
 // cout<< A.at(i)<<endl;
}
  
  for (int i = 0; i < N; i++) {
    if(A.at(i)>=0){
      X+=A.at(i);
     // cout<<X<<endl;
      minx=min(minx,A.at(i));
    }else{
      Y++;
      X+=A.at(i)*(-1);
      minx=min(minx,A.at(i)*(-1));
    }
  
}
  
  
 // cout<<X<<endl;
  
  if(Y%2==0){
  //  cout<<""<<endl;
    cout<<X<<endl;
  }else{
   // cout<<""<<endl;
    cout<<X-minx*2<<endl;
  }
 
}
  
  
  

Measured memory_bytes: 764
import sys

sx, sy, tx, ty = map(int, sys.stdin.readline().split())


dif_x = tx - sx
dif_y = ty - sy


ans_s = ''
route_1 = 'RU'
route_2 = 'LD'
route_3 = 'DRUL'
route_4 = 'ULDR'

for i in range(dif_x):
    ans_s += 'R'
for i in range(dif_y):
    ans_s += 'U'
for i in range(dif_x):
    ans_s += 'L'
for i in range(dif_y):
    ans_s += 'D'

ans_s += 'D'
for i in range(dif_x + 1):
    ans_s += 'R'

for i in range(dif_y + 1):
    ans_s += 'U'
ans_s += 'L'

ans_s += 'U'
for i in range(dif_x + 1):
    ans_s += 'L'
for i in range(dif_y + 1):
    ans_s += 'D'
ans_s += 'R'


print(ans_s)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var N, x int
var ans int

func main() {
	fmt.Scan(&N, &x)
	a := make([]int, N)
	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		reader.Scan()
		a[i], _ = strconv.Atoi(reader.Text())
	}

	for i := 0; i < N-1; i++ {
		if x < a[i]+a[i+1] {
			cnt := (a[i] + a[i+1]) - x
			ans += cnt
			a[i+1] = max(a[i+1]-cnt, 0)

		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


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

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n%2==0){
    cout<<n/2<<endl;
  }else{
    cout<<(n+1)/2<<endl;
  }

  return 0;
}




Measured memory_bytes: 256
open Batteries
module Myset = Set.Make(Int)

let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let x,y = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let c_lst = String.to_list s in

  let rec re_x cnt = function
      [] -> x-cnt, []
    | 'F'::tl -> re_x (cnt+1) tl
    | 'T'::tl -> (x-cnt), tl
  in

  let x,c_lst = re_x 0 c_lst in

  let rec aux xl yl cnt is_x = function
      [] -> if is_x then (cnt::xl),yl else xl,(cnt::yl)
    | 'F'::tl -> aux xl yl (cnt+1) is_x tl
    | 'T'::tl -> 
      if cnt = 0 then
        if is_x = true then aux xl yl 0 (not is_x) tl else
          aux xl yl 0 (not is_x) tl
      else
      if is_x = true then aux (cnt::xl) yl 0 (not is_x) tl else
        aux xl (cnt::yl) 0 (not is_x) tl
  in
  let xl,yl = aux [] [] 0 false c_lst in

  let xset = (Myset.add 0 Myset.empty) in
  let x_ans = List.fold_left (fun set1 dy -> 
      Myset.fold (fun el set2 -> 
          let retset = Myset.add (el-dy) (Myset.add (el+dy) set2) in retset
        ) set1 (Myset.empty)
    ) xset xl in

  let yset = (Myset.add 0 Myset.empty) in
  let y_ans = List.fold_left (fun set1 dy -> 
      Myset.fold (fun el set2 -> 
          let retset = Myset.add (el-dy) (Myset.add (el+dy) set2) in retset
        ) set1 (Myset.empty)
    ) yset yl in

  Printf.printf "%s\n" @@
  if (Myset.mem x x_ans) && (Myset.mem y y_ans) then "Yes" else "No"


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

int main() {
  int R;
  int G;
  double b;

  cin >> R;
  cin >> G;

  if (R < 0) {
    exit (1);
  }

  if (G > 4500) {
    exit (1);
  }

  if (G <= 0) {
    b = -1 * R;
  } else {
    b = 2 * G - R;
  }

  cout << b << endl;
}



Measured memory_bytes: 3784
#include<cstdio>

int g[8][8];
int dp[8][256];
int main()
{
  int n,m,u,v,s,k;scanf("%d%d",&n,&m);
  while(m--)scanf("%d%d",&u,&v),u--,v--,g[u][v]=g[v][u]=true;
  dp[0][1]=1,s=1<<n;
  for(k=1;k<s;k++)
	for(u=0;u<n;u++)
	  if(dp[u][k])
		for(v=0;v<n;v++)
		  if(g[u][v]&&~k&1<<v)
			dp[v][k|1<<v]+=dp[u][k];
  int ans=0;
  for(u=0;u<n;u++)ans+=dp[u][s-1];
  printf("%d\n",ans);
}

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

constexpr int MAXN = 100;
int G[MAXN][MAXN];
int D[MAXN];
int P[MAXN];
int C[MAXN];
int n;
constexpr int MAXINT = 2001;

#define FOR(i,a,b) for(int i = (a); i<(b); ++i)

int main() {

    std::cin >> n;
    FOR(i, 0, n)
    FOR(j, 0, n)
    {
        int v;
        std::cin >> v;
        if(v < 0) G[i][j] = MAXINT;
        else G[i][j] = v;
    }

    FOR(i, 0, n) D[i] = MAXINT;

    int r = 0;
    D[r] = 0;
    P[r] = -1;
    while (true) {
        int mincost = MAXINT;
        int t;
        for (int i = 0; i < n; i++) {
            if ((C[i] == 0) && (D[i] < mincost)) {
                mincost = D[i];
                t = i;
            }
        }
        if (mincost == MAXINT) {
            break;
        }

        C[t] = 1;
        P[t] = r;

        for (int i = 0; i < n; i++) {
            if ((C[i] == 0) && (G[t][i] < D[i])) {
                D[i] = G[t][i];
            }
        }
        r = t;
    }

    int sum = 0;
    FOR(i, 0, n) {
        sum += D[i];
    }
    std::cout << sum << std::endl;

}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int AB = sc.nextInt();
        int BC = sc.nextInt();
        int AC = sc.nextInt();

        sc.close();

        System.out.println((AB * BC / 2));
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

const int MAXN = 100;

int Pow(int x, int y) {
	int ret = 1;
	for (int i = 1; i <= y; i++)
		ret *= x;
	return ret;
}

int C(int n, int m) {
	if (m < 0) return 0;
	if (m == 0) return 1;
	if (m == 1) return n;
	if (m == 2) return std::max(n * (n - 1) / 2, 0);
	if (m == 3) return std::max(n * (n - 1) * (n - 2) / 6, 0);
}

char S[MAXN + 5];

int main() {
	scanf("%s", S + 1);
	int K; scanf("%d", &K);
	int cnt = strlen(S + 1), B = 0, Z = 0;
	for (int i = 1; i <= cnt; i++) {
		int x = S[i] - '0';
		B += (9 - x) * C(cnt - i, K - i + Z) * Pow(9, K - i + Z);
		if (!x)
			Z++;
	}
	int A = C(cnt, K) * Pow(9, K);
	printf("%d", std::max(A - B, 0));
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

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


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, n;
	cin >> h >> n;
	int sum = 0;
	rep(i, n){
		int x;
		cin >> x;
		sum += x;
	}
	cout << ((sum >= h) ? "Yes" : "No") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println( n * n * n / 27.0);
        }
    }

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

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}


Measured memory_bytes: 21204
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + max(V) + 1)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        s += i * dp[Y][i]
    print(int(s))

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = list(map(int, input().split()))
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

Measured memory_bytes: 10676
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] p = new int[n+1];
      Map<Integer, List<Integer>> graph = new HashMap<>();
      for(int i = 1; i <= n; i++){
        p[i] = sc.nextInt();
        graph.put(i, new ArrayList<>());
      }

      for(int i = 0; i < m; i++) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        graph.get(x).add(y);
        graph.get(y).add(x);
      }

      ArrayList<Set<Integer>> groups = new ArrayList<>();
      boolean[] visited = new boolean[n+1];
      for(int i = 1; i <= n; i++) {
        if(visited[i]) continue;
        Set<Integer> group = new HashSet<>();
        group.add(i);
        dfs(graph, visited, group, i);
        groups.add(group);
      }

      int cnt = 0;
      for(Set<Integer> group : groups) {
        for(int node : group) {
          if(group.contains(p[node])) cnt++;
        }
      }

      System.out.println(cnt);
  }

  private static void dfs(Map<Integer, List<Integer>> graph, boolean[] visited, Set<Integer> group, int curNode) {
    for(int adj : graph.get(curNode)) {
      if(!visited[adj]) {
        visited[adj] = true;
        group.add(adj);
        dfs(graph, visited, group, adj);
      }
    }
  }
}

Measured memory_bytes: 121132
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
   
    int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    if(op.equals("+"))System.out.println((a+b));
    if(op.equals("-"))System.out.println((a-b));
    if(op.equals("*"))System.out.println((a*b));
    if(op.equals("/"))System.out.println((a/b));
    if(op.equals("?"))break;
    }
}
}


Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
int gcd(int,int);
int main(void){
    int w,h,c;
    cin >> w >> h >> c;
    int d =gcd(w,h);
    cout << ((w/d)*(h/d))*c << endl;
    return 0;
}
int gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

void fail(int i) {
    printf("NO\n", i);
    exit(0);
}

int n, h;
struct block {
    int l, r;
    void scan() {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (c == 0) l = a << 1;
        else l = c << 1 | 1;
        if (d == 0) r = b << 1 | 1;
        else r = d << 1;
    }
} bs[100000];

int par[402];
int find(int x) {
    if (par[x] != x) return par[x] = find(par[x]);
    return x;
}

int cnt[402];
int ex[402];
int zr[402];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	for (int i = 0; i < 402; ++i) par[i] = i;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        bs[i].scan();
        ++cnt[bs[i].l];
        --cnt[bs[i].r];
        ex[bs[i].l] = 1;
        ex[bs[i].r] = 1;
        par[find(bs[i].l)] = find(bs[i].r);
    }
    for (int i = 0; i < 402; ++i) {
        if (cnt[i] < 0 && ((i ^ 1) & 1)) fail(0);
        if (cnt[i] > 0 && ((i ^ 0) & 1)) fail(1);
        if (cnt[i] != 0) zr[find(i)] = 1;
    }
    for (int i = 0; i < 402; ++i) {
        if (ex[i] == 0) continue;
        if (find(i) != i) continue;
        if (zr[i] == 0) fail(2);
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1024