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

int build[20][40];

void printbuild() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 40; j++) {
      if (build[i][j]) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
}

void makeOut() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 40; j++) {
      build[i][j] = 1 - build[i][j];
    }
  }
}

bool touchingSun(long h, long i, double c, long r) {
  return hypot(19 - h - c, i - 20) < r || hypot(19 - h - c, i - 19) < r;
}

bool touchingSunAll(double c, long r) {
  for (int h = 0; h < 20; h++) {
    for (int i = 0; i < 40; i++) {
      if (build[h][i] && touchingSun(h, i, c, r)) {
        return true;
      }
    }
  }
  return false;
}

void reset() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 40; j++) {
      build[i][j] = 0;
    }
  }
}

void fillbuild(long l, long r, long h) {
  for (int i = 19; i >= 20 - h; i--) {
    for (int j = l + 20; j < r + 20; j++) {
      build[i][j] = 1;
    }
  }
}

void solve(long n, long r) {
  reset();
  long l, rr, h;
  for (int i = 0; i < n; i++) {
    cin >> l >> rr >> h;
    fillbuild(l, rr, h);
  }
  makeOut();
  // printbuild();
  double c = -r;
  double step = 0.5;
  int cnt = 0;
  while (step > 0.00001) {
    if (!touchingSunAll(c, r)) {
      c += step;
    } else {
      c -= step;
      step /= 2;
    }
    cnt++;
    if (cnt > 10000) break;
   }
  printf("%.4f\n", min(c + r, 20.0));
}

int main() {
  long n, r;
  while (1) {
    cin >> r >> n;
    if (n + r) {
      solve(n, r);
    } else {
      return 0;
    }
  }
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n; cin>>n;
	vector< pair< int, int > > x,y;
	for(int i=0;i<n;i++){
		int tx,ty;
		char dir;
		cin>>tx>>ty>>dir;
		if( dir == 'U' ){
			x.pb(mp(0,tx));
			y.pb(mp(1,ty));
		}
		if( dir == 'D' ){
			x.pb(mp(0,tx));
			y.pb(mp(-1,ty));
		}
		if( dir == 'L' ){
			x.pb(mp(-1,tx));
			y.pb(mp(0,ty));
		}
		if( dir == 'R' ){
			x.pb(mp(1,tx));
			y.pb(mp(0,ty));
		}
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	vector< pair<int,int> > hx,hy;
	for(int i=0;i<n;i++){
		if( i == 0 || i == n-1){
			hx.pb( x[i] );
		}
		else if( x[i-1].first != x[i].first || x[i].first != x[i+1].first ){
			hx.pb( x[i] );
		}
	}
	for(int i=0;i<n;i++){
		if( i == 0 || i == n-1){
			hy.pb( y[i] );
		}
		else if( y[i-1].first != y[i].first || y[i].first != y[i+1].first ){
			hy.pb( y[i] );
		}
	}
	vector< double > turnp; turnp.pb(0.0);
	for(int i=0;i<hx.size();i++){
		for(int j=i+1;j<hx.size();j++){
			if(hx[i].first != hx[j].first){
				double ct = 1.0 * ( hx[j].second - hx[i].second ) / (hx[i].first -hx[j].first) ;
				if( ct > 0.0 )turnp.pb(ct);
			}
		}
	}
	for(int i=0;i<hy.size();i++){
		for(int j=i+1;j<hy.size();j++){
			if(hy[i].first != hy[j].first){
				double ct = 1.0 * ( hy[j].second - hy[i].second ) / (hy[i].first -hy[j].first) ;
				if( ct > 0.0 )turnp.pb(ct);
			}
		}
	}
	double res = 1.0 * LINF;
	for(int i=0;i<turnp.size();i++){
		double curt = turnp[i];
		double xmax = -1.0*LINF, xmin = 1.0*LINF, ymax = -1.0*LINF, ymin = 1.0*LINF;
		for(int j=0;j<hx.size();j++){
			xmax = max( xmax, 1.0 * ( hx[j].first * curt + hx[j].second ) );
			xmin = min( xmin, 1.0 * ( hx[j].first * curt + hx[j].second ) );
		}
		for(int j=0;j<hy.size();j++){
			ymax = max( ymax, 1.0 * ( hy[j].first * curt + hy[j].second ) );
			ymin = min( ymin, 1.0 * ( hy[j].first * curt + hy[j].second ) );
		}
		double tmp = (xmax - xmin) * (ymax - ymin);
		//cout<<"t="<<curt<<" "<<tmp<<endl;
		if( res > tmp ) res = tmp;
	}
	cout<<setprecision(14)<<res<<endl;
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
  int min_=1000000000;
  int i=0,ans=0;
  while(i<n)
  {
      if(arr[i]<=min_) ans++;
      min_=min(min_,arr[i]);
      i++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,a,n) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
 
 
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート
 
int main() {
  long long int n;
  cin >>n;
  long long int ans=0;
  
rep(i,1,n+1){
    rep(j,1,((n+1)/i)+1){
        if(i*j<n){ans++;
        //db2(i,j);
        }
    }
}

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

Measured memory_bytes: 3636
#include<stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(int *)a-*(int *)b;
}

int main()
{   int n;
    scanf("%d",&n);
    int a[n+1];
    
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    a[n+1]=0;
    int ans=0,cnt=1;
    for(int i=0;i<n;i++){
        if(a[i]==a[i+1]){
            cnt++;
        }else if(cnt%2==1){
            ans++;
            cnt=1;
        }else{
            cnt=1;
        }
        
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll n;
	cin >> n;
	vector<ll>l;
	unordered_map<ll, ll>cntr;
	unordered_map<ll, vector<ll> > r;
	for (ll i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		l.pb(i + x);
		r[i - x].pb(i);
		cntr[i - x]++;
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++)
	{
		if (cntr[l[i]])
		{
			auto it = upper_bound(r[l[i]].begin(), r[l[i]].end(), l[i]);
			ans += r[l[i]].end() - it;
		}
	}
	cout << ans << endl;
}



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

int main(){
	int A,B;
	cin>>A>>B;
	int ans=0;
	for(int i=0;i<2;++i){
		if(A>B){
			ans+=A;
			A--;
		}
		else{
			ans+=B;
			B--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long int ll;

ll MAX(ll a, ll b){return a>b?a:b;}
ll MIN(ll a, ll b){return a>b?b:a;}
int compare(const void* a, const void* b){return *(int*)a - *(int*)b;}
ll digits(ll a){ll tmp=a; ll cnt=0; while(tmp>0){tmp/=10; cnt+=1;} return cnt;}

int main(void){
    ll n;
    scanf("%lld", &n);
    
    ll ans = (ll)pow(10.0, 12.0);
    int limit_num = sqrt((double)n);

    for(int i=1; i<=limit_num; i++){
        if(n%i == 0){
            ll max = MAX(digits(i), digits(n/i));
            ans = MIN(ans, max);
        }
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
	long long int a,v,b,w,t;
	scanf("%lld%lld%lld%lld%lld", &a,&v,&b,&w,&t);
	if (abs(a - b) <= (v - w) * t) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 1700
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve()
{
    string s;cin>>s;
    if(s=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

#define INF 100100100
#define MOD 1000000007

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

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int H,W,N;
   cin>>H>>W>>N;
   vector<int>a(N);
   for (int i = 0; i < N; i++) cin>>a[i];
   vector<int>color(H*W);
   int fill=0;
   for(int i=0;i<N;i++){
      for(int j=fill;j<fill+a[i];j++){
         color[j]=i+1;
      }
      fill+=a[i];
   }
   for(int i=0;i<H;i++){
      if(i%2==0){
         for(int j=0;j<W;j++){
            cout<<color[i*W+j];
            if(j==W-1)cout<<endl;
            else cout<<" ";
         }
      } 
      else{
         for(int j=W-1;j>=0;j--){
            cout<<color[i*W+j];
            if(j==0)cout<<endl;
            else cout<<" ";
         }
      }
   }
   return 0;
}


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


void solve(long long X, long long A){
	 if (X < A) {
			cout << 0 << endl;
	 } else {
			cout << 10 << endl;
	 }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int h,w,x,y;
	cin >>h>>w>>x>>y;
	vector<vector<bool>> b(h,vector<bool>(w));
	rep(i,h)
		rep(j,w)
			if(i<x||j<y)
				b[i][j]=true;
	int cnt=0;
	rep(i,h)
		rep(j,w)
			if(!b[i][j])
				cnt++;
	cout <<cnt<<endl;

}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 1000000007
#define infll 2000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef long double ld;
typedef complex<ld> point;
typedef pair<point, point> line;
typedef pair<ld , point> Circle;
typedef pair<point, int> Point;
const int N = 205;


int n, last, num;




int main() {

    
    scanf("%d",&n);
    
    int ans = 0;
    lp(i, 1, n) {
        int a;
        scanf("%d",&a);
        if(a == last) ++num;
        else ans += num>>1, num = 1;
        last = a;
    }
    printf("%d\n",ans+num/2);
    return 0;
}

/*
 10
 4 2
 7 4
 2 6
 2 5
 4 8
 10 3
 2 9
 9 1
 5 10
 
 */

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
music = []
length = []
for i in range(n):
    ti,leng = map(str,input().split())
    music.append(ti)
    length.append(int(leng))
x = input()

num = music.index(x)
print(sum(length[num+1::]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  string t; cin >> t;
  bool n=false,e=false,s=false,w=false;
  rep(i,t.size()){
    char c = t.at(i);
    if(c=='N') n=true;
    if(c=='E') e=true;
    if(c=='S') s=true;
    if(c=='W') w=true;
  }
  if(n==s&&e==w) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    ll A,B,Q;
    ll ans = 1e9;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B), x(Q);
    for(ll i = 0; i < A; i++){
        cin >> s[i];
    }
    for(ll i = 0; i < B; i++){
        cin >> t[i];
    }
    for(ll i = 0; i < Q; i++){
        cin >> x[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for(ll i = 0; i < Q; i++){

    }

    for(ll i = 0; i < Q; i++){
        ans = 1e11;
        ll ws =0, es = 0, wt = 0, et = 0;
        auto it = upper_bound(s.begin(), s.end(), x[i]);
        ll index = it - s.begin();
        // cout << "s:"  << index << endl;
        if(index >= s.size()){
            es = -1;
            ws = s[index-1];
        }else if(index == 0){
            es = s[index];
            ws = -1;
        }else{
            es = s[index];
            ws = s[index-1];
        }

        auto itt = upper_bound(t.begin(), t.end(), x[i]);
        ll inde = itt - t.begin();
        // cout << "w:" << inde << endl;
        if(inde >= t.size()){
            et = -1;
            wt = t[inde-1];
        }else if(inde == 0){
            et = t[inde];
            wt = -1;
        }else{
            et = t[inde];
            wt = t[inde-1];
        }
        // cout << ws << wt << " e:" << et << es << endl;
        if(ws !=-1 && wt != -1){
            if(wt < ws){
                ans= min(x[i] - wt, ans);
            }else{
                ans= min(x[i] - ws, ans);
            }
        }
        if(es !=-1 && et != -1){
            if(et < es){
                ans= min(es - x[i], ans);
            }else{
                ans= min(et - x[i], ans);
            }
        }
        if(es !=-1 && wt != -1){
            ans = min(es - wt + min(x[i]-wt, es- x[i]), ans);
        }
        if(ws !=-1 && et != -1){
            ans = min(et - ws + min(x[i]- ws, et- x[i]), ans);
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n+1, 0);
    for(auto& val: arr)
        cin >> val;
    vector<ll> rem(n+1, 0);
    rem[0] = 1;
    
    for(int i = 0; i <= n; i++) {
        if (i > 0) rem[i] = rem[i-1]*2;
        rem[i] -= arr[i];
        if (rem[i] < 0) {
            cout << -1 << endl;
            return 0;
        } else if (rem[i] >= 1e14) {
            rem[i] = 1e14;
        }
    }
    ll ans = 0;
    for(int i = n; i >= 0; i--) {
        ll upper = rem[i] + arr[i];
        if (i < n)
            arr[i] += arr[i+1];
        arr[i] = min(arr[i], upper);
        // cout << "i = " << i << ", add " << arr[i] << endl;
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int ans = 0;
  
  for(int i=0;i<6;i++){
    if(s[i] == '1')
      ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> Childnum(200005,-1);
vector<vector<int>> Child(200005,vector<int>(0));
//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
int dp(int i){
    if (Childnum[i]!=-1){
        return Childnum[i];
    }
    if (Child[i].size()==0){
        Childnum[i]=0;
        return 0;
    }
    int res=0;
    for (auto&& j:Child[i]){
        res+=dp(j)+1;
    }
    Childnum[i]=res;
    return res;
}
int main(void){
    long long int mod=1000000007;
    int N;
    cin>>N;
    vector<vector<int>> G(N,vector<int>(0));
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    queue<int> q;
    q.push(0);
    vector<int> reached(N,0);
    while(!q.empty()){
        int r=q.front();q.pop();
        reached[r]=1;
        for(auto&& p:G[r]){
            if (reached[p]==1){
                continue;
            }
            Child[r].push_back(p);
            q.push(p);
        }
    }
    dp(0);
    long long int ans=(N*(1-modinv(modpow(2,N-1,mod),mod)))%mod;
    for (int r=0;r<N;r++){
        long long int tmp=0;
        for(auto&& p:Child[r]){
            long long int ai=Childnum[p]+1;
            tmp+=ai;
            long long int k1=(1-modinv(modpow(2,ai,mod),mod))%mod;
            long long int k2=modinv(modpow(2,N-1-ai,mod),mod);
            ans-=(k1*k2)%mod;
            ans%=mod;
        }
        long long int ai=N-1-tmp;
        long long int k1=(1-modinv(modpow(2,ai,mod),mod))%mod;
        long long int k2=modinv(modpow(2,N-1-ai,mod),mod);
        ans-=(k1*k2)%mod;
        ans%=mod;
    }
    cout<<((ans*modinv(2,mod))%mod)<<endl;
    
}


Measured memory_bytes: 29824
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>x>>y;
    if(abs(x-y)<=1)Cout("Brown");
    else Cout("Alice");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int x, y, z, nr;

int main(){

         cin>>x>>y>>z;

         nr=0;

         x -= z;
         while ( x > 0){
                  x -= y+z;
                  if( x >= 0)
                           nr++;
         }

         cout<<nr;

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  int p[10];
  int i;
  int pos = -1;
  int sum = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &p[i]);
    if ( pos < 0 ) {
      pos = 0;
    }
    else if ( p[pos] < p[i] ) {
      pos = i;
    }
  }
  for ( i = 0; i < n; i++ ) {
    if ( i == pos ) {
      sum += p[i] / 2;
    }
    else {
      sum += p[i];
    }
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
    int i, j;
    char T[1001] = {'\0'};
    char P[1001] = {'\0'};
    scanf("%s", T);
    scanf("%s", P);

    int lengtht = strlen(T);
    int lengthp = strlen(P);
    for (i = 0; i < lengtht; i++)
    {
        for (j = 0; j < lengthp && P[j] == T[i + j]; j++);
        if (j == lengthp)
        {
            printf("%d\n", i);
        }
    }
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

vi adj[200001];
int p[200001];
int d[200001];
int n;

// int dist[2001][2001];

void bfs(int start)
{
    queue<int> q;
    p[start] = 0;
    d[start] = 0;
    q.push(start);
    while(!q.empty())
    {
        int temp  = q.front();
        q.pop();
        for(auto u : adj[temp])
        {
            if(p[u] == -1)
            {
                p[u] = temp;
                d[u] = d[temp]+1;
                q.push(u);
            }
        }
    } 
}



void tree_read()
{
    int x,y;
    cin>>n>>x>>y;
    adj[x].pb(y);
    adj[y].pb(x);
    for(int i = 1 ; i < n ; i++)
    {
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    // for(int i = 1 ; i < n ; i++)
    // {
    //     int a,b;
    //     cin>>a>>b;
    //     adj[a].pb(b);
    //     adj[b].pb(a);
    // }
}



void solve()
{
    tree_read();
    map<ll,ll> m;
    for(int i = 1 ; i <= n ; i++)
    {
        // cout<<"for i = "<<i<<endl;
        for(int j = 1 ; j <= n ; j++)
        {
            p[j] = -1;
        }
        bfs(i);
        for(int j = 1 ; j < i ; j++)
        m[d[j]]++;
        for(int j = i+1 ; j <= n ; j++)
        m[d[j]]++;
    }
    for(int i = 1 ; i < n ; i++)
    cout<<m[i]/2<<endl;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    int total = 0;
    rep(i, n) total += a[i];

    if (a[m-1] * 4 * m >= total)  {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 3620
import math

n = int(input())

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

d = []

for i in range(n):
    for j in range(i+1,n):
        dist = math.sqrt((a[i][0]-a[j][0])**2 + (a[i][1]-a[j][1])**2)
        d.append(dist)

sm = sum(d)

def fact(n,mod):
   t = 1
   for i in range(1,n+1):
       t = (t * i) % mod
   return t


print(sm*2 /n)

Measured memory_bytes: 38732
#include <iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
	long long n,s;cin>>n>>s;
	vector<long long> x(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
		x[i]-=s;
		if(x[i]<0)x[i]*=-1;
	}
	sort(x.begin(),x.end());
//	long long max=x[0];
	long long ans=1;
	long long div=0;
	while(div<=sqrt(x[0])){
		div++;
		if(x[0]%div)continue;
		long long temp;
		int flag;
		temp=div;
		flag=1;
		for(int i=0;i<n;i++){
			if(x[i]%temp){
				flag=0;
				break;
			}
		}
		if(flag){
			if(ans<temp){
				ans=temp;
			}
		}
		temp=x[0]/div;
		flag=1;
		for(int i=0;i<n;i++){
			if(x[i]%temp){
				flag=0;
				break;
			}
		}
//		cout<<temp<<' '<<flag<<endl;
		if(flag){
			if(ans<temp){
				ans=temp;
			}
		}
	}
//	for(int i=0;i<n;i++){
//		cout<<x[i]<<endl;
//	}
	cout<<ans<<endl;


	return 0;
}


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

using namespace std;
#define double long double
#define int long long

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int xx1,yy1,xx2,yy2;
int n;
int X[252521], Y[252521];

signed main(){
  scanf("%lld%lld%lld%lld",&xx1,&yy1,&xx2,&yy2);
  scanf("%lld",&n);
  REP(i,n)scanf("%lld%lld",X+i,Y+i);
  // if(xx1==xx2){
  //   if(yy1>yy2)swap(yy1,yy2);
  //   bool hit = false;
  //   REP(i,n)if(X[i]==xx1 && yy1<Y[i] && Y[i]<yy2){
  //     hit = true;
  //   }
  //   double ans = (double)(yy2-yy1) * 100.0;
  //   if(hit){
  //     ans -= 20;
  //     ans += 10 * (atan(1)*4);
  //   }
  //   printf("%.13Lf\n",ans);
  //   return 0;
  // }
  // if(yy1==yy2){
  //   if(xx1>xx2)swap(xx1,xx2);
  //   bool hit = false;
  //   REP(i,n)if(Y[i]==yy1 && xx1<X[i] && X[i]<xx2){
  //     hit = true;
  //   }
  //   double ans = (double)(xx2-xx1) * 100.0;
  //   if(hit){
  //     ans -= 20;
  //     ans += 10 * (atan(1)*4);
  //   }
  //   printf("%.13Lf\n",ans);
  //   return 0;
  // }
  if(xx1>xx2){
    swap(xx1,xx2);
    swap(yy1,yy2);
  }
  if(yy1>yy2){
    yy1 = -yy1;
    yy2 = -yy2;
    REP(i,n)Y[i] = -Y[i];
  }
  vector<pii> po;
  REP(i,n){
    if(xx1<=X[i]&&X[i]<=xx2 && yy1<=Y[i]&&Y[i]<=yy2){
      po.push_back(pii(X[i],Y[i]));
    }
  }
  sort(ALL(po));
  vector<int> dp(n+1, 1e9);
  REP(i,po.size()){
    int yo = po[i].second;
    *lower_bound(ALL(dp), yo) = yo;
  }
  int hits = lower_bound(ALL(dp),1e9)-dp.begin();
  double ans = (double)(xx2-xx1 + yy2-yy1) * 100.0;
  ans -= 20.0 * hits;
  ans += hits * 5 * (atan(1)*4);
  int poyo = min(xx2-xx1,yy2-yy1)+1;
  if(hits == poyo){
    ans += 5 * (atan(1)*4);
  }
  printf("%.13Lf\n",ans);
  return 0;
}


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


int main(){
	string inputA,inputB,inputC;
	cin >> inputA >> inputB >> inputC;
	string A=inputA,B=inputB,C=inputC;
	for(int i=0;i<inputA.size();i++){
		A[i] = inputA[inputA.size() - 1 - i];
	}
	for(int i=0;i<inputB.size();i++){
		B[i] = inputB[inputB.size() - 1 - i];
	}
	for(int i=0;i<inputC.size();i++){
		C[i] = inputC[inputC.size() - 1 - i];
	}
	
	char nextTurn = 'a';
	while(true){
		switch(nextTurn){
			case 'a':
				if(A.size() == 0){
					cout << "A" << endl;
					return 0;
				}
				nextTurn = A[A.size() - 1];
				A.pop_back();
				break;
			case 'b':
				if(B.size() == 0){
					cout << "B" << endl;
					return 0;
				}
				nextTurn = B[B.size() - 1];
				B.pop_back();
				break;
			case 'c':
				if(C.size() == 0){
					cout << "C" << endl;
					return 0;
				}
				nextTurn = C[C.size() - 1];
				C.pop_back();
				break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int coins(int a,int b, int c,int x){
    int ans=0;
    for(int i = 0; i <= a; ++i){
    for(int j = 0; j <= b; ++j){
    for(int k = 0; k <= c; ++k){
    int tmp = i * 500 + j * 100 + k * 50;
    if(tmp == x)
        ans++;
    }
    }
    }
return ans;
}

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    cout<<coins(a,b,c,x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  string s;
  cin >> s;
  int n= s.size();
  char pre = '$';
  int ans =0;
  rep(i,n){
    if(pre == s[i]){
      if(i!=n-1){
        ans++;
        i++;
      }
      pre='$';
    }
    else{
      ans++;
      pre=s[i];
    }
  }

  cout << ans << endl;

  return 0;
    

}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i1,n) for(int i=(int)(i1);i<(int)(n);i++)
#define ll long long
#define vi vector<int>

int main() {
  int a=0;
  cin>>a;
  cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3628
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations
sys.setrecursionlimit(10**6)

n,m,l=map(int,input().split())
a=[[int(i) for i in input().split()]for _ in range(n)]
b=[[int(i) for i in input().split()]for _ in range(m)]
c=[[0 for i in range(l)] for j in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=a[i][k]*b[k][j]
    print(*c[i])


Measured memory_bytes: 7928
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 5555;
ll n,x[N],y[N],v[N],s[N],len;
ll Abs(ll x){return x>0?x:-x;}
void solve(ll x, ll y){
	ll tmpx=y;
	
	ll sum=0;rep(i,1,len)sum+=1LL<<s[i];sum-=x+y;sum/=2;
	bool fu[40]={0};rep(i,1,len)if((sum>>s[i])&1){sum^=(1LL<<s[i]);fu[i]=1;}
	bool fx[40]={0};rep(i,1,len)if(Abs(x)&(1LL<<s[i])){
		fx[i]=1;x-=(fu[i]?(-(1LL<<s[i])):1LL<<s[i]);
	}
	
	
	/*ll ck=0;rep(i,1,len)if(!fx[i])ck+=fu[i]?-(1LL<<s[i]):(1LL<<s[i]);
//	printf("GG %lld %lld\n",ck,tmpx);
	assert(ck==tmpx);*/
	
	
	rep(i,1,len){
		char c;
		if(fu[i]&&fx[i])c='L';
		if(!fu[i]&&fx[i])c='R';
		if(fu[i]&&!fx[i])c='D';
		if(!fu[i]&&!fx[i])c='U';
		printf("%c",c);
	}
	puts("");
}
int main() {
	read(n);rep(i,1,n)read(x[i]),read(y[i]);
	rep(i,1,n)v[i]=(Abs(x[i])^Abs(y[i]))&1;
	rep(i,2,n)if(v[i]!=v[1]){puts("-1");return 0;}
	if(v[1]==0)s[++len]=0;rep(i,0,33)s[++len]=i;
	printf("%lld\n",len);rep(i,1,len)printf("%lld ",1LL<<s[i]);puts("");
	rep(i,1,n)solve(x[i],y[i]);
	return 0;
}

Measured memory_bytes: 256
a=list(input())
b=list(input())
hantei=True
for i in range(len(a)):
	c=[]
	c.append(a[-1])
	for i in range(0,len(a)-1):
		c.append(a[i])
	a=c
	if c==b:
		hantei=True
		break
	else:
		hantei=False

if hantei==False:
	print("No")
else:
	print("Yes")


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

typedef long long ll;
const ll INF = 1ll<<60;

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

    vector<vector<pair<int, int>>> path(n);
    int a, b, c;
    for(int i = 1; i < n; i++){
        cin >> a >> b >> c;
        a--; b--;
        path[a].push_back({b, c});
        path[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    ll d[n];
    for(int i = 0; i < n; i++)  d[i] = INF;
    d[k] = 0ll;

    priority_queue<pair<ll,int>> pq;
    for(int i = 0; i < n; i++)  pq.push({-d[i], i});

    while(!pq.empty()){
        pair<ll,int> now = pq.top();   pq.pop();
        ll tmpdist = -now.first;
        int pos = now.second;
        if(d[pos] < tmpdist)    continue;
        d[pos] = tmpdist;
        for(pair<int,int> p : path[pos]){
            int next = p.first;
            int cost = p.second;
            if(d[next] > tmpdist + cost){
                pq.push({-(tmpdist+cost), next});
            }
        }
    }

    int x, y;
    while(q-- > 0){
        cin >> x >> y;
        cout << d[--x] + d[--y] << endl;
    }

    return 0;
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 300005;

set<pair<int,int>> t;
map<int,int> r;
map<int,int> c;

bool cmp1(const int &a, const int &b) {
	return r[a]>r[b];
}
bool cmp2(const int &a, const int &b) {
	return c[a]>c[b];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w;
	cin >> h >> w;
	
	int m;
	cin >> m;
	
	while(m--){
		int x, y;
		cin >> x >> y;
		t.insert({x,y});
		r[x]++;
		c[y]++;
	}
	
	vector<int> rows;
	vector<int> cols;
	
	for (auto &p : r) {
		rows.pb(p.F);
	}
	for (auto &p : c) {
		cols.pb(p.F);
	}	
	
	sort(rows.begin(),rows.end(),cmp1);
	sort(cols.begin(),cols.end(),cmp2);
	
	int ans = r[rows[0]]+c[cols[0]];
	
	bool found = false;
	
	FOR(i,0,SZ(cols)) {
		if (c[cols[i]]!=c[cols[0]]) {
			break;
		}
		if (!t.count({rows[0],cols[i]})) {
			found = true;
			break;
		}
	}
	
	if (! found) {
		FOR(i,0,SZ(rows)) {
			if (r[rows[i]]!=r[rows[0]]) {
				break;
			}
			if (!t.count({rows[i],cols[0]})) {
				found = true;
				break;
			}
		}
	}
	
	if (! found) {
		ans--;
	}
	
	cout << ans << "\n";
	
	
}


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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    int64_t a[5];
    int64_t ans = 0;
    rep(i, 5) {
        cin >> a[i];
        if ( a[i] == 0 ) {
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int n;
	string str;
	
	getline(cin, str, '\n');
	n = toInt(str);

	int pos;
	REP(i, n) {
		getline(cin, str, '\n');

		while((pos = str.find("Hoshino")) != string::npos) {
			str[pos+6] = 'a';
		}

		cout << str << endl;
	}

	return 0;
}

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

const int N=200005;

int main()
{
	int n,a[N];
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+1+n);
	int b=a[(n+1)/2];
	long long sum=0;
	for(int i=1;i<=n;i++) sum+=abs(a[i]-b);
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

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

type Comment struct {
	x, y int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	arr := make([][]Comment, N)
	for i := 0; i < N; i++ {
		A := sc.nextInt()
		ar := make([]Comment, A)
		for j := 0; j < A; j++ {
			x, y := sc.nextInt()-1, sc.nextInt()
			ar[j] = Comment{x, y}
		}
		arr[i] = ar
	}
	ans := 0
	for bit := 0; bit < 1<<uint(N); bit++ {
		trueList := make([]int, N)
		count := 0
		for i := 0; i < N; i++ {
			if 1<<uint(i)&bit > 0 {
				trueList[i] = 1
				count++
			}
		}
		ok := true
		for i, b := range trueList {
			if b == 1 {
				for _, comment := range arr[i] {
					x, y := comment.x, comment.y
					if trueList[x] != y {
						ok = false
						break
					}
				}
			}
		}
		if ok {
			if ans < count {
				ans = count
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 4864
#include <stdio.h>
int n;
char a[5010];
int DT[5010][5010];
int ans;
int min(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d",&n);
	scanf("%s",a);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]==a[j]) DT[i][j] = 1;
		}
	}
	for(int i=1;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(DT[i][j]) DT[i][j] = DT[i-1][j-1]+DT[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans = ans > min(j-i,DT[i][j]) ? ans : min(j-i,DT[i][j]);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 96768
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

//減少のことは考えないで最大をとる

int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            int input;
            cin >> input;
            // s[i][j] = make_pair(input,j);
            s[i][j] = input;
        }
    }  
    //答え
    vector<int> t(d);
    rep(i,d) cin >> t[i];
    vector<int> v(d);
    ll sum=0;
    vector<int> last(26);
    rep(i,d){
        sum+=s[i][t[i]-1];
        last[t[i]-1]=i+1;
        // cout << s[i][t[i]-1] << endl;
        //減少
        ll minus=0;
        rep(j,26){
            minus+=c[j]*(i+1-last[j]);
        }
        sum-=minus;
        v[i] = sum;
    }   
    rep(i,d) cout << v[i] << endl;
}


Measured memory_bytes: 3544
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>


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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

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

ll clz(ll x) {
	for (ll i = 31; i >= 0; i--) {
		if ((x >> i) & 1) {
			return 31 - i;
		}
	}
}

template< typename G >
struct DoublingLowestCommonAncestor {
	const int LOG;
	vector< int > dep;
	const G &g;
	vector< vector< int > > table;

	DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - clz(g.size())) {
		table.assign(LOG, vector< int >(g.size(), -1));
	}

	void dfs(int idx, int par, int d) {
		table[0][idx] = par;
		dep[idx] = d;
		for (auto &to : g[idx]) {
			if (to != par) dfs(to, idx, d + 1);
		}
	}

	void build() {
		dfs(0, -1, 0);
		for (int k = 0; k + 1 < LOG; k++) {
			for (int i = 0; i < table[k].size(); i++) {
				if (table[k][i] == -1) table[k + 1][i] = -1;
				else table[k + 1][i] = table[k][table[k][i]];
			}
		}
	}

	int query(int u, int v) {
		if (dep[u] > dep[v]) swap(u, v);
		for (int i = LOG - 1; i >= 0; i--) {
			if (((dep[v] - dep[u]) >> i) & 1) v = table[i][v];
		}
		if (u == v) return u;
		for (int i = LOG - 1; i >= 0; i--) {
			if (table[i][u] != table[i][v]) {
				u = table[i][u];
				v = table[i][v];
			}
		}
		return table[0][u];
	}
};

int main()
{
  int N, Q;
  scanf("%d", &N);
  vector<vector<int>> g(N);
  for(int i = 0; i < N; i++) {
    int k;
    scanf("%d", &k);
    while(k--) {
      int c;
      scanf("%d", &c);
      g[i].push_back(c);
    }
  }
  DoublingLowestCommonAncestor< vector<vector<int>> > lca(g);
  lca.build();
  scanf("%d", &Q);
  while(Q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", lca.query(x, y));
  }
	return 0;

}



Measured memory_bytes: 18444
import sys; readline = sys.stdin.readline
from collections import deque
sys.setrecursionlimit(1000000)

N, U, V = map(int, readline().split())
AB = [list(map(int, readline().split())) for i in range(N - 1)]

A = [a - 1 for a, b in AB]
B = [b - 1 for a, b in AB]

U, V = U - 1, V - 1

conn = {}
for a, b in zip(A, B):
    if not a in conn:
        conn[a] = []
    conn[a].append(b)

    if not b in conn:
        conn[b] = []
    conn[b].append(a)

t = [0 for i in range(N)]

def dfsU(u, parent, depth):
    t[u] = depth

    for _u in conn[u]:
        if _u != parent:
            dfsU(_u, u, depth + 1)

dfsU(V, -1, 0)

maxv = 0
maxu = U
def dfsV(v, parent, depth):
    global maxv
    global maxu
    if depth < t[v]:
        if t[v] > maxv:
            maxv = t[v]
            maxu = depth
        for _v in conn[v]:
            if _v != parent:
                dfsV(_v, v, depth + 1)

dfsV(U, -1, 0)
if (maxv - maxu) % 2 == 1:
    print(maxv - 1)
else:
    print(maxv - 1)

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

int main(){
  int n;
  cin >> n;
  int h[n];
  for(int i=0; i<n; ++i) cin >> h[i];
  int ans = 0;
  for(int i=1; i<=100; ++i){
    int lastover = -2;
    for(int j=0; j<n; ++j){
      if(h[j] >= i){
        if(j-lastover > 1) ans++;
        lastover = j;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int mat[110][2], dp[110][110];
const int INF = 1<<29;

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) REP(j, 2) cin >> mat[i][j];
  REP(i, N) REP(j, N) dp[i][j] = INF;
  REP(i, N) dp[i][i] = 0;
  for (int w = 1; w < N; w++) {
    for (int L = 0; L + w < N; L++) {
      int R = L + w;
      for (int i = L; i < R; i++)
	dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + mat[L][0] * mat[i][1] * mat[R][1]);
    }
  }
  cout << dp[0][N-1] << endl;
  return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int m,d;cin>>m>>d;){
		int res=0;
		for(int i=1;i<=m;i++){
			for(int j=1;j<=d;j++){
				if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
					res++;
			}
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int isEmpty(int);


int main(){

  int i=0,j,top;
  int str[200];
  char c[100];

  
  for(i=1;i<200;i++){
    if(scanf("%s",&c)==EOF)break;
    
    else if(isEmpty(i)==1){
	if(!strcmp(c,"+")){
	  str[i-2] = str[i-1]+str[i-2];
	  i=i-2;
	}
	else if(!strcmp(c,"-")){
	  str[i-2] = str[i-2]-str[i-1];
	  i=i-2;
	}
	else if(!strcmp(c,"*")){
	  str[i-2] = str[i-1]*str[i-2];
	  i=i-2;
	}  
	else str[i] =atoi(c);
    }
    else if(isEmpty(i-2)==0)break;
  }
      
  

  printf("%d\n",str[1]);

  return 0;
}


int isEmpty(int x){

  if(x==0) return 0;
  else return 1;
}

Measured memory_bytes: 548