akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;
long long a[10000][10000],N,M,k,i,j;
long long x[1010],y[1010],z[1010],count;
const int mod=1e10;
int main()
{
    while(cin>>N>>M)
    {
       count=M;
       for(i=1;i<=N;i++)
        {
           for(j=1;j<=N;j++)
           {
               a[i][j]=mod;
               if(i==j) a[i][j]=0;
           }
        }
       for(i=1;i<=M;i++)
       {
           cin>>x[i]>>y[i]>>z[i];
           a[x[i]][y[i]]=z[i];
           a[y[i]][x[i]]=z[i];
       }
       for(k=1;k<=N;k++)
       {
           for(i=1;i<=N;i++)
           {
               for(j=1;j<=N;j++)
               {
                   a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
               }
           }
       }
       for(i=1;i<=M;i++)
       {
           k=0;
           for(j=1;j<=N;j++)
           {
               if(a[j][x[i]]+z[i]==a[j][y[i]])
                k=1;
           }
           if(k==1) count--;
       }
       cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>


using namespace std;


char a;



int main()
{
	cin >> a ;
	if ( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}


	//system("pause");

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v;
  rep(i,h)
  {
    string s;
    cin >> s;
    int f = 0;
    rep(j,s.size())
    {
      if (s[j] == '#') {
        f = 1;
        break;
      }
    }
    if (f)
      v.push_back(s);
  }
  for (int i = w - 1; i >= 0; i--) {
    int f = 0;
    rep(j,v.size())
    {
      if (v[j][i] == '#') {
        f = 1;
        break;
      }
    }
    if (!f)
      rep(j,v.size())
        v[j].erase(i, 1);
  }
  rep(i,v.size())
    cout << v[i] << endl;
  return 0;
}

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

using namespace std;

void solve();

int main() {
#ifdef OFFLINE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

#define forn(i, n) for (int i=0; i<n; i++)

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

const int N = 2000;
int a[N];

#define idx second

void solve() {
	int n, x; cin >> n >> x;
	forn(i, n)
		cin >> a[i];

	lint res = LLONG_MAX;
	
	multiset<int> wndw;
	for (int k=0; k<n; k++) {
		for (int i=n-k; i<n; i++)
			wndw.insert(a[i]);

		lint cur_res = 0;
		for (int i=0; i<n; i++) {
			wndw.insert(a[i]);
			cur_res += *wndw.begin();
			int ihead = i - k;
			if (ihead < 0)
				ihead += n;
			wndw.erase(a[ihead]);
		}
		res = min(res, cur_res + (lint)x * k);
		wndw.clear();
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll ans = 0, n, k;std::cin >> n >> k;
  vll a(n);re(i, n) std::cin >> a[i];
  sort(all(a));
  reverse(all(a));
  for(int i=0;i<n;i++){
    if(i<k) continue;
    ans += a[i];
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 2424
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>

const int maxn = 1e5 + 50;

int N;
int V[maxn], K;
int P[maxn];
bool sub[maxn];
int L[maxn], R[maxn];
std::vector<int> G[maxn];
bool vp[maxn];
bool ans;

void getinterval(int a,int f)
{
	for(int i = 0; i < G[a].size(); i++)
		if(G[a][i] != f)
		{
			getinterval(G[a][i], a);
			
			if(sub[G[a][i]])
			{
				int l = L[G[a][i]] - 1;
				int r = R[G[a][i]] + 1;				

				if(sub[a])
				{
					if(r < L[a] || l > R[a] || ((l & 1) ^ (L[a] & 1))) ans = false;
					
					L[a] = std::max(L[a], l);
					R[a] = std::min(R[a], r);
				}
				else
				{
					L[a] = l;
					R[a] = r;
					sub[a] = true;
				}
			}
		}
	
	if(vp[a] == true)
	{
		if(sub[a] && (P[a] < L[a] || P[a] > R[a] || ((P[a] & 1) ^ (L[a] & 1)))) ans = false;
		
		L[a] = R[a] = P[a];
		sub[a] = true;
	}
}
void getvalue(int a,int f)
{
	if(a == 1)
	{
		P[a] = L[a];
	}
	else
	{
		if(P[f] - 1 >= L[a])
		{
			P[a] = P[f] - 1;
		}
		else
		{
			P[a] = P[f] + 1;
		}
	}
	
	for(int i = 0; i < G[a].size(); i++)
		if(G[a][i] != f)
		{
			getvalue(G[a][i], a);
		}
}
int main()
{
	scanf("%d", &N);
	for(int i = 1, x, y; i < N; i++)
	{
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	
	scanf("%d", &K);
	for(int i = 1; i <= K; i++)
	{
		scanf("%d", &V[i]);
		scanf("%d", &P[V[i]]);
	}
	
	for(int i = 1; i <= K; i++)
	{
		vp[V[i]] = true;
	}
	
	ans = true;
	getinterval(1, 0);
	getvalue(1, 0);
	
	if(ans)
	{
		puts("Yes");
		
		for(int i = 1; i <= N; i++)
		{
			printf("%d\n", P[i]);
		}
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

int main()
{
    int n;
    double xa;
    double ya;
    double ra;
    double xb;
    double yb;
    double rb;
    
    cin >> n;
    for(int i=0; i<n; i++)
    {
        int ans;
        double dist;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        dist = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
        if(islessequal(dist, ra+rb))
        {
            if(isgreater(ra, dist+rb))
            {
                ans = 2;
            }
            else if(isgreater(rb, dist+ra))
            {
                ans = -2;
            }
            else
            {
                ans = 1;
            }
            
        }
        else
        {
            ans = 0;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define mod 10e9
using namespace std;
void cicada()
{
    ll i,j,k,l,m,n;
    cin>>n;
    j=0,k=1;
    while(n>0)
    {
        n/=2;
        j+=k;
        k*=2;
    }
    cout<<j;
}
int main()
{
    ll test=1;
    while(test--)
    {
        cicada();
    }
}

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

int main(){
int N,K;
cin>>N>>K;
int d[110]={};
for(int i=0; i<K; i++){
    int q;
    cin>>q;
    for(int j=0; j<q; j++){
        int t;
        cin>>t;
    
    d[t-1]=1;
    
}
}
int counter=0;
    for(int i=0; i<N; i++){
        if(d[i]==0) counter++;
    }
    cout<<counter<<endl;
}

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

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

using namespace std;

int main() {
  string s;
  std::cin >> s;

  uint64_t count = 0;
  uint64_t black = 0;
  rep(i, s.size()) {
    if (s[i] == 'W') {
      count += black;
    } else {
      black++;
    }
  }

  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3708
// https://atcoder.jp/contests/dp/tasks/dp_i

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2999;
const int P_I_MAX = 1;

int N;
double p[N_MAX];

double dp[2][N_MAX + 1];

void solve() {
  double *cur = dp[0];
  double *nxt = dp[1];

  cur[0] = 1.0;
  REP(i, N) {
    fill(nxt, nxt + N + 1, 0);
    REP(j, i + 1) {
      nxt[j    ] += cur[j] * (1.0 - p[i]);
      nxt[j + 1] += cur[j] * p[i];
    }
    swap(cur, nxt);
  }
  double ans = 0.0;
  FOR(j, N / 2 + 1, N) ans += cur[j];
  printf("%.10lf\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%lf", p + i);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

int f(int num) {
	int ans = 0;
	while (1) {
		ans += num % 10;
		num /= 10;
		if (num == 0)break;
	}
	return ans;
}

signed main() {
	int N;
	cin >> N;
	if (N % f(N) == 0)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    klist = defaultdict(int)
    for i in range(n):
        for j in range(i+1, n):
            if (i <= x and j <= x) or (y <= i and y <= j):
                k = j - i
                klist[k] += 1
            elif i <= x and x < j <= y:
                k = min(j - i, (x - i + y - j) + 1)
                klist[k] += 1
            elif i <= x and y <= j:
                k = (j - i) - (y - x) + 1
                klist[k] += 1
            else:
                k = min((j - i), ((i - x) + abs(y - j) + 1))
                klist[k] += 1
    for i1 in range(1, n):
        print(klist[i1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 9772
#include <stdio.h>

int main(void)
{
	int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0){
			break;
		}

		if(x < y){
			printf("%d %d\n", x, y);
		}else{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

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

 
int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	for(int i=0; i<n; i++){
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());
	double ans = v.at(0);
	for(int i=0; i<n; i++){
		ans = (ans + v.at(i))/2;
	}
	cout << fixed << setprecision(10) << ans << endl;

}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 300010, M = 62, mod = 1e9 + 7;

int n;
LL a[N];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++ ) scanf("%lld", &a[i]);
	
	int res = 0;
	for (int i = 0; i < M; i ++ )
	{
		int one = 0, zero = 0;
		for (int j = 0; j < n; j ++ )
			if (a[j] & 1LL << i) one ++ ;
			else zero ++ ;
		res = ((LL)res + (1LL << i) % mod * (LL)one % mod * zero) % mod;
	}
	
	printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
ll k;
int main() 
{
  while(cin>>s>>k)
  {
    int n=s.length();
    if(s==string(n,s[0]))cout<<1ll*k*n/2<<endl;
    else
    {
      int ans1=0;
      for(int i=0;i+1<n;i++)
      {
        if(s[i]==s[i+1])ans1++,i++;
      }
      int ans2=0;
      for(int i=0;i+1<2*n;i++)
      {
        if(s[i%n]==s[(i+1)%n])ans2++,i++;
      }
      cout<<ans1+(ans2-ans1)*(k-1)<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define Exit (puts("No"),exit(0),0)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=300300;
int n,mx,mi,a[N],b[N],c[2];
int main(){
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d",&a[i]),b[i]=a[i]==i;
	for(int l=1,r;r=l,l<=n;l=r+1){
		if(b[l]) continue;
		while(r+1<n && b[r+1] && !b[r+2]) r+=2;
		mi=n;mx=1;
		FOR(i,l,r) mi=min(mi,a[i]),mx=max(mx,a[i]);
		if(mi!=l || mx!=r) Exit;
		c[0]=c[1]=0;
		FOR(i,l,r)if(!b[i]) a[i]<c[i<a[i]]?Exit:c[i<a[i]]=a[i];
	}puts("Yes");
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 4e5+100;
const ll MOD = 1e9+7;
string s,t;
ll tree[N];

void build(ll node,ll l,ll r)
{
	if(l==r)
	{
		tree[node] = (s[l-1] == t[r-1]);
	}
	else
	{
		ll mid = (l + r) >> 1LL;
		build(node*2,l,mid);
		build(2*node+1,mid+1,r);
		tree[node] = tree[node*2] + tree[node*2+1];
	}
}

ll query(ll node,ll st,ll en,ll l,ll r)
{
	if(r < st || l> en) return 0;
	if(st >= l && en <= r) return tree[node];
	ll mid = (st + en)/2;
	ll p1 = query(node*2,st,mid,l,r);
	ll p2 = query(node*2+1,mid+1,en,l,r);
	return p1 + p2;
}
ll dp[1000005];
ll pre[1000005];
int main()
{
	ll n;
	cin >> n;
	if(n==1) return cout<<n << endl,0;
	if(n==2) return cout <<  (n *n) %MOD << endl,0;
	dp[0] = 1;
	dp[1] = 1;
	ll ans = (n-1 + (n-1) * (n-1) * 2) %MOD;
	for(ll k  =2,i = 1;k<n;k++)
	{
		dp[k] = (i % MOD);
		ll xx;
		if(k==n-1) xx = 1;
		else xx = n-1;
		ans = (ans + dp[k] * (n-1) % MOD * (xx) % MOD ) %MOD;	
		ans = (ans + (n-1) * dp[k-1] %MOD)	%MOD;
		i = (i + dp[k] + dp[k-2] - dp[k-1] + MOD) %MOD;
	}
	ans++;
	if(ans < MOD) ans += MOD;ans%=MOD;
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    set<Pi> st;//(今の位置,出発地点)
    multiset<int> mst;
    rep(i,w){
        st.insert(Pi(i,i));
        mst.insert(0);
    }
    rep(i,h){
        int l,r;
        cin>>l>>r;
        l--,r--;
        auto itr=st.lower_bound(Pi(l,-1));
        int ne=-1;
        while(itr!=st.end() && itr->fi<=r){//今の地点が[l[i],r[i]]のときは開始位置が大きいやつをr[i]+1に残せばok
            chmax(ne,itr->se);
            mst.erase(mst.find(itr->fi-itr->se));
            st.erase(itr);
            itr=st.lower_bound(Pi(l,-1));
        }
        if(ne!=-1 && r+1<w){
            st.insert(Pi(r+1,ne));
            mst.insert(r+1-ne);
        }
        if(mst.empty()) cout<<-1<<endl;
        else cout<<(i+1)+*mst.begin()<<endl;
    }
}

Measured memory_bytes: 22364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i=0;
  int a=1;
  int N,K;
  cin>>N>>K;
  for (i; i < N; i++) {
    a*=2;
    if(a>K){
      break;
    }
  }
  int b=a;
  for (int j=0;j<N-i-1;j++){
    b+=K;
  }
  cout<<b<<endl;
}
  

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="SUN")cout<<7<<endl;
    else if(s=="SAT")cout<<1<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<sstream>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
    int n;
    cin >>n;
    int num,ans = 0,maxx = 0;
    while(n--)
    {
        cin >> num;
        maxx = max(maxx,num);
        ans += num;
    }
    ans -= maxx/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int p[100];
    vector<int> q;
    int sum = 0;

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


    sort(q.rbegin(), q.rend());



    for(int i = 1; i < n; i++){
        sum += q[i];
    }

    if(q[0] < sum){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import sys

def main():
    num = int(sys.stdin.readline())
    
    input = [None] * num

    for i in range(num):
        read = sys.stdin.readline().split()
        input[i] = [i+1, read[0], int(read[1])]

    input.sort(key=lambda x:(x[1], -x[2]))

    for restaurant in input:
        print(restaurant[0])

if __name__ == "__main__":
    main()


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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007


int main(){
	NINJA;

	int n; cin >> n;

	mp m;
	fo(i,n-1){
		int x; cin >>x;
		m[x]++;
	}

	Fo(i,1,n+1){
		cout << m[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 13000
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string s;
    cin >> s;

    ll change = 0;
    char prev = s[0];
    REP(i, s.size() - 1){
        if(s[i] != prev){
            change++;
            prev = s[i];
        }
    }

    cout << change << endl;

    return 0;
}

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

A_sum = sum(A)
TH = A_sum/(4*M)

count=0
for i in A:
    if i >= TH:
        count += 1

if count >= M:
    print('Yes')
else:
    print('No')


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 3e5 + 5;

int r, c, n;
int cnt1[N], cnt2[N];
vector<int> v[N];

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

    cin >> r >> c >> n;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cnt1[x]++;
        v[x].push_back(y);
        cnt2[y]++;
    }

    vector<int> mx1, mx2;

    for (int i = 1; i < N; i++) {
        if (mx1.empty() or cnt1[mx1.back()] < cnt1[i]) {
            mx1.clear();
            mx1.push_back(i);
        }
        else if (cnt1[mx1.back()] == cnt1[i])
            mx1.push_back(i);

        if (mx2.empty() or cnt2[mx2.back()] < cnt2[i]) {
            mx2.clear();
            mx2.push_back(i);
        }
        else if (cnt2[mx2.back()] == cnt2[i])
            mx2.push_back(i);
    }

    int ans = cnt1[mx1.back()] + cnt2[mx2.back()] - 1;
    sort(mx2.begin(), mx2.end());

    for (int x : mx1) {
        int c = 0;
        for (int y : v[x]) {
            if (binary_search(mx2.begin(), mx2.end(), y))
                c++;
        }
        if (c != mx2.size()) {
            ans++;
            break;
        }
    }

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

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

using namespace std;

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

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

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

    int n, k;
    cin >> n >> k;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<vi> prefs(n + 1), suffs(n + 1);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            prefs[j].push_back(a[i]);
        }

        for (int j = n - i; j <= n; ++j) {
            suffs[j].push_back(a[i]);
        }
    }

    for (int i = 0; i <= n; ++i) {
        sort(all(prefs[i]));
        sort(all(suffs[i]));
    }

    // left[i][j] best score you can get by taking i from the left and dropping j
    vector<vi> lefts(n + 1, vi(k + 1, 0));
    vector<vi> rights(n + 1, vi(k + 1, 0));

    for (int i = 1; i <= n; ++i) {
        for (int x : prefs[i])
            lefts[i][0] += x;

        for (int x : suffs[i])
            rights[i][0] += x;

        for (int j = 1; j <= k; ++j) {
            if (j - 1 < prefs[i].size() and prefs[i][j - 1] < 0) {
                lefts[i][j] = lefts[i][j - 1] - prefs[i][j - 1];
            } else {
                lefts[i][j] = lefts[i][j - 1];
            }

            if (j - 1 < suffs[i].size() and suffs[i][j - 1] < 0) {
                rights[i][j] = rights[i][j - 1] - suffs[i][j - 1];
            } else {
                rights[i][j] = rights[i][j - 1];
            }
        }
    }

    int ans = 0;
    for (int drop = 0; drop <= n; ++drop) {
        int take = min(n, k - drop);
        if (take < drop) break;

        for (int l = 0; l <= take; ++l) {
            int r = take - l;
            for (int dl = 0; dl <= drop; ++dl) {
                int dr = drop - dl;
                ans = max(ans, lefts[l][dl] + rights[r][dr]);
            }
        }
    }

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
lli mod = 1e9 + 7, func[2000050];
lli mypow(lli x, lli y)
{
	lli res = 1, tmp = x;
	while(y)
	{
		if(y & 1) res = (res * tmp) % mod;
		tmp = (tmp * tmp) % mod;
		y >>= 1;
	}
	return res;
}
lli C(lli n, lli m)
{
	if(n * m == 0 || n == m) return 1;
	if(m == 1) return n;
	lli one = func[n];
	lli two = mypow(func[n - m], mod - 2);
	lli three = mypow(func[m], mod - 2);
	return ((one * two) % mod * three) % mod;
}
int main()
{
	int a; cin >> a;
	string str; cin >> str;
	func[1] = 1;
	for(lli i = 2; i <= 2000000; i++)
		func[i] = func[i - 1] * i % mod;
	lli res = 0;
	for(int i=str.size(); i <= a + str.size(); i++)
	{
		lli front = mypow(26, a + str.size() - i);
		lli back = mypow(25, i - str.size());
		lli comb = C(i - 1, str.size() - 1);
		res += ((front * back) % mod * comb) % mod;
		if(res >= mod) res -= mod;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 20004
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int bomb_cnt(vector<string> S, int y, int x) {
  if (y < 0 || y >= S.size()) return 0;
  if (x < 0 || x >= S[y].size()) return 0;

  if (S[y][x] == '#') return 1;
  else return 0;
}

char bombs(vector<string> S, int y, int x) {
  int b = 0;
  b += bomb_cnt(S, y-1, x-1);
  b += bomb_cnt(S, y-1, x);
  b += bomb_cnt(S, y-1, x+1);

  b += bomb_cnt(S, y, x-1);
  b += bomb_cnt(S, y, x+1);

  b += bomb_cnt(S, y+1, x-1);
  b += bomb_cnt(S, y+1, x);
  b += bomb_cnt(S, y+1, x+1);

  return b + '0';
}

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  rep(i, H) {
    cin >> S[i];
  }

  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '.') S[i][j] = bombs(S, i, j);
    }
  }

  rep(i, H) {
    cout << S[i] << endl;
  }

  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 998244353;
ll N, M;
ll a[302][302];
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1) {
        ans = ans * a % mod;
    }
    return ans;
}

ll Rank(ll index) {
    if(index > min(N, M)) return 0;
    int nonzero_i = -1;
    int nonzero_j = -1;
    for(int i = index; i <= N; i++) {
        for(int j = index; j <= M; j++) {
            if(a[i][j] == 1) {
                nonzero_i = i;
                nonzero_j = j;
            }
        }
    }
    if(nonzero_i == -1) return 0;
    for(int i = index; i <= N; i++) {
        swap(a[i][nonzero_j], a[i][index]);
    }
    for(int j = index; j <= M; j++) {
        swap(a[nonzero_i][j], a[index][j]);
    }
    for(int i = index + 1; i <= N; i++) {
        if(a[i][index] == 0) continue;
        for(int j = index; j <= M; j++) {
            a[i][j] = (a[i][j] + a[index][j]) % 2;
        }
    }
    for(int j = index + 1; j <= M; j++) {
        a[index][j] = 0;
    }
    return Rank(index + 1) + 1;
}

int main() {
    //cout.precision(10);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++) {
            cin >> a[i][j];
        }
    }
    ll R = Rank(1);
    ll ans = (beki(2, R) - 1) * (beki(2, R - 1)) % mod;
    ans = ans * (beki(2, N - R)) % mod;
    ans = ans * (beki(2, M - R)) % mod;
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,F = 0,num;
  cin >> N;
  for(int i = 0;i < 8;i++)
   	F +=  (N % (int)pow(10,i+1) - N % (int)pow(10,i)) / pow(10,i); //i+1桁目の数値を求める
  if(N % F == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

const int N = 1e5 + 5;

int n;
array<int, N> a, front_gcd, back_gcd;

int main() {
    cin >> n;
    for (int i = 1, cum_gcd; i <= n; i++) {
        cin >> a[i];
        if (i == 1) {
            cum_gcd = a[i];
        } else {
            cum_gcd = __gcd(cum_gcd, a[i]);
        }
        front_gcd[i] = cum_gcd;
    }
    
    for (int i = n, cum_gcd = a[n]; i >= 1; i--) {
        cum_gcd = __gcd(cum_gcd, a[i]);
        back_gcd[i] = cum_gcd;
    }
    front_gcd[0] = back_gcd[2];
    back_gcd[n + 1] = front_gcd[n - 1];

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, __gcd(front_gcd[i - 1], back_gcd[i + 1]));
    }

    cout << ans << endl;
}



Measured memory_bytes: 4712
import java.util.Scanner;

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

		int k = sc.nextInt();
		String s = sc.next();

		if (s.length() > k) {
			System.out.println(s.substring(0, k) + "...");
		} else {
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 38592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret);
  return (ret);
}

int main() {
    int n,m;
    cin>>n>>m;
    vector<ll> a=divisor(m);
    for(int i=a.size()-1;i>=0;i--){
        if(a[i]*n<=m){
            cout<<a[i]<<endl;
            return 0;
        }
    }
    return 0;
  }










Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int a, b;

    cin >> a >> b;
    cout << (a <= 9 && b <= 9 ? a * b : -1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
typedef unsigned long ul;
const ul INF=1LL<<60;
const ul MAX_N=111;
const ul MAX_V=1000000;
ul N,W,w[MAX_N],v[MAX_N],dp[MAX_N][MAX_V],i,j,ans;
inline void solve(){
  IN2(N,W);
  REP(i,N){
    IN2(w[i],v[i]);
  }
  REP(i,MAX_N)REP(j,MAX_V)dp[i][j]=INF;
  dp[0][0]=0;
  REP(i,N){
    REP(j,MAX_V){
      if(j+v[i]<=MAX_V)dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      // if(j-v[i]>=0)dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    }
  }
  DW(j,MAX_V-1,0){
    if(dp[N][j]<=W){
      OUT(j);
      return;
    }
  }
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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


int a,b;
char s[13];

int main(){
  scanf("%d %d",&a,&b);
  scanf("%s",s);
  REP(i,a+b+1){
    if(i!=a && s[i]-'0'>=0 &&  s[i]-'0'<=9) continue;
    if(i==a&&s[i]=='-') continue;
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  return 0;
}


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

vector<int> input(int N) {
  vector<int> res(N);
  for (int i = 0; i < N; i++)scanf("%d", &res[i]);
  return res;
}

int main(){
    int N;
    scanf("%d", &N);
    vector<int> h(N);
    h = input(N);
    vector<int> dp(N, 0);
    dp[1] = abs(h[0] - h[1]);
    for(int i = 2; i < N; i++)dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    printf("%d\n", dp[N - 1]);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		String s = Integer.toString(n);
		int nn = 0;
		for(int i=0; i<s.length(); i++){
			nn += Integer.parseInt(s.charAt(i) + "");
		}
		if(n%nn==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    string s;
    cin >> s;
    bool c = false;
    bool cf = false;

    rep(i, s.length()) {
        if (s[i] == 'C') c = true;
        else if (s[i] == 'F' && c) {
            cf = true;
            break;
        }
    }
    Yes(cf);

    return 0;
}

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

main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  vector<int> ra(n+1);
  ra[0]=0;
  for(int i=1; i<=n; i++){
    ra[i]=ra[i-1]+a[i-1];
  }
  int ans=1;
  for(int i=n-1; i>=1; i--){
    if(ra[i]*2 < a[i]) break;
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4848
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    long long a;
    double b;
    cin >> a;
    cin >> b;
    long long b_long = (b * 100 + 0.001);
    cout << setprecision(0) << a * b_long / 100 << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    vint H(N);
    rep(i, N)
    {
        cin >> H[i];
        if (i == 0)
            H[i]--;
        else if (H[i] > H[i - 1])
        {
            H[i]--;
        }
    }
    bool ok = true;
    rep(i, N)
    {
        if (H[i] < H[i - 1])
            ok = false;
    }
    ok ? cout << "Yes" : cout << "No";
    return 0;
}

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

int main(void)
{
  int H, W;
  cin >> H >> W;
  string S[50];
  
  for (int i=0;i<H;i++){
    cin >> S[i];
  }
  
  int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
  int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
  
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (S[i][j] != '#'){
        int num = 0;
        for (int k=0;k<8;k++){
          int ni = i + dy[k];
          int nj = j + dx[k];
          
          if (ni<0 || ni==H) continue;
          if (nj<0 || nj==W) continue;
          if (S[ni][nj] == '#'){
            num++;
          }
        }
        S[i][j] = num + '0';
      }
    }
  }
  
  for (int i=0;i<H;i++){
    cout << S[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll X;
    cin>>X;
    ll Ans=0;
    Ans+=X/500*1000;
    X%=500;
    Ans+=X;
    Ans-=X%5;
    cout<<Ans<<endl;

}



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



int main() {
  string S,T,U;
  int A,B;
  cin>>S>>T>>A>>B>>U;
  if(S==U){cout<<A-1<<" "<<B<<endl;}
  else{cout<<A<<" "<<B-1<<endl;}
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <math.h>

#define INT_MAX       2147483647

using namespace std;

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

	vector<string> words(n);
	set<string> uniq_words;
	cin >> words[0];
	uniq_words.insert(words[0]);
	for (int i = 1; i < n; i++) {
		cin >> words[i];
		if (words[i][0] != words[i - 1].back())
		{
			cout << "No" << endl;
			return;
		}
		if (uniq_words.find(words[i]) != uniq_words.end())
		{
			cout << "No" << endl;
			return;
		}
		else
		{
			uniq_words.insert(words[i]);
		}
	}
	cout << "Yes" << endl;
}

int main()
{

	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long sum = 0;
        int max = -1000000;
        int min = 1000000;
        
        for (int i = 0; i < n; i++) {
            int a = scan.nextInt();
            sum = sum + a;
            if( max < a ){
                max = a;
            }
            if( min > a ){
                min = a;
            }
        }

        System.out.println(min + " " + max +" " + sum);
    }
}



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

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int a[n];
      int ans=0;
      for(int i=0;i<n;i++){
        cin>>a[i];
        ans=__gcd(ans,a[i]);
      }
      cout<<ans;
}
/* If today were the last day of my life,would I want to do what I'm about to do today? */

Measured memory_bytes: 640
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn abs(x:i64)-> i64{if x < 0 { -x } else { x } }

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let a: Vec<i64> = sc.vec(n);
    let length: i64 = a.iter().sum();
    let mut ac = 0;
    let mut ans = length ;
    for i in 0..n-1 {
        ac += a[i];
        let b = length - ac;
        // trace!(ac, b);
        ans = min!(ans, abs(b - ac));
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}
	

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

int main()
{
    string s;
    cin >> s;

    bool flag=false;
    int n=s.size();
    s.insert(0,"0");
    for(int i=1;i<=n/2;i++){
        if(s.at(i)==s.at(n-i+1)){
            if(i==n/2)
              flag=true;
        }
        else
        {
            flag=false;
            break;

        }
        
    }

    if(flag){
    for(int i=1;i<=(n-1+2)/4;i++){
        if(s.at(i)==s.at((n-1)/2-i+1)){
            if(i==(n-1+2)/4)
              flag=true;
        }
        else
        {
            flag=false;
            break;
        }
        
    }}

    if(flag){
    for(int i=(n+3)/2;i<=(n-3+2)/4+(n+3)/2;i++){
        if(s.at(i)==s.at(n-i+(n+3)/2)){
            if(i==(n-3+2)/4+(n+3)/2)
              flag=true;
        }
        else
        {
            flag=false;
            break;
        }
        
    }}



    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : January 12 2020 11:57:15 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int k,x;
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N;
    cin >> N;
    int d;
    vector<int> D;
    rep(i, N) {
        cin >> d;
        D.push_back(d);
    }

    sort(all(D));

    prints(D[N / 2] - D[N / 2 - 1]);

    return 0;
}



Measured memory_bytes: 892
from itertools import combinations

n, k = map(int, input().split())
xlist, ylist, xy = [], [], []
for _ in range(n):
  x, y = map(int, input().split())
  xlist.append(x)
  ylist.append(y)
  xy.append((x, y))

xlist.sort()
ylist.sort()
ans = (xlist[-1] - xlist[0]) * (ylist[-1] - ylist[0])
for x1, x2 in combinations(xlist, r=2):
  for y1, y2 in combinations(ylist, r=2):
    tmpk = 0
    for i in range(n):
      if x1 <= xy[i][0] <= x2 and y1 <= xy[i][1] <= y2:
        tmpk += 1

      if tmpk >= k:
        tmp_ans = (x2 - x1) * (y2 - y1)
        if ans > tmp_ans:
          ans = tmp_ans

print(ans)


Measured memory_bytes: 49116
NUM = 10 ** 9 + 7

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

A.sort(reverse=True)

length = len(A)
if not length % 2 == 0:
    length -= 1

for i in range(0, length, 2):
    if not A[i] == A[i + 1]:
        print(0)
        exit()

print((2 ** (length // 2)) % NUM)

Measured memory_bytes: 13880