akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps=1e-10;
double adj[21][21];
double hero[20];
bool visited[20]={false};
#define MAOU 20

bool backTrack(int last,double r,int now,int n,
	   bool *visited){
  rep(i,n){
    if ( visited[i]==false && adj[MAOU][i]<=r)return false;
    if ( visited[i]==false &&  adj[MAOU][i]<=r+adj[last][i])return false;
  }
  if ( now == n)return true;
  
  rep(i,n){
    if ( visited[i]==true)continue;
    visited[i]=true;
    if ( backTrack(i,r+adj[last][i],now+1,n,visited))return true;
    visited[i]=false;
  }
  return false;
}

double dist(int x,int y){
  return sqrt(x*x+y*y);
}

int solve(int n,int *x,int *y,int rx,int ry,int mx,int my){
  rep(i,n){
    adj[i][i]=0;
    adj[MAOU][i]=adj[i][MAOU]=dist(x[i]-rx,y[i]-ry);
    REP(j,i+1,n){
      adj[i][j]=adj[j][i]=dist(x[i]-x[j],y[i]-y[j]);
    }
    hero[i]=dist(mx-x[i],my-y[i]);
    if ( hero[i]>=adj[MAOU][i])return false;
    visited[i]=false;
  }
  
  rep(i,n){
    visited[i]=true;
    if ( backTrack(i,hero[i],1,n,visited))return true;
    visited[i]=false;
  }
  return false;
}

main(){
  int n,mx,my,rx,ry;
  while(scanf("%d%d%d%d%d",&n,&mx,&my,&rx,&ry) && n){
    int x[n],y[n];
    rep(i,n)scanf("%d%d",&x[i],&y[i]);
    if ( solve(n,x,y,rx,ry,mx,my))puts("YES");
    else puts("NO");
  }
}

Measured memory_bytes: 852
#include <iostream>

using namespace std;

int main() {
  int out[10005] = {};
  for (int x=1; x < 100; x++) {
    for (int y=1; y < 100; y++) {
      for (int z=1; z < 100; z++) {
        int idx = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);
        if (10004 >= idx) {
          out[idx]++;
          /*
          if (out[idx]!=0) continue;
          if (x==y && y==z) out[idx] = 1;
          else if(x==y || y==z || z==x) out[idx] = 3;
          else out[idx] = 6;
          */
        }
      }
    }
  }
  int N; cin >> N;
  for (int i=1; i <= N; i++) cout << out[i] << endl;

  return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int pa[100001]={};
int ra[100001]={};

int find(int xx){
	if(pa[xx]==xx)return xx;
	return pa[xx]=find(pa[xx]);
}
int same(int xx,int yy){
	return 	find(xx)==find(yy);
}
void unite(int xx,int yy){
	xx=find(xx);
	yy=find(yy);
	if(ra[xx]<ra[yy]){
		pa[xx]=yy;
	}else{
		pa[yy]=xx;
		if(ra[xx]==ra[yy])ra[xx]++;
	}
	return;
}
int main() {
	int n;

	cin>>n;
	P x[100001]={};
	P y[100001]={};
	for(int i=0;i<n+1;++i)pa[i]=i;


	for(int i=0;i<n;++i){
		int x1,y1;
		cin>>x1>>y1;
		x[i]=P(x1,i+1);
		y[i]=P(y1,i+1);
	}
	sort(x,x+n);
	sort(y,y+n);
	P2 d[200001]={};
	for(int i=0;i<n-1;++i){
		d[i]=P2(abs(x[i].first-x[i+1].first),P(x[i].second,x[i+1].second));
		d[i+n-1]=P2(abs(y[i].first-y[i+1].first),P(y[i].second,y[i+1].second));
	}
	sort(d,d+2*n-2);
	ll t=0;
	for(int i=0;i<2*n-2;i++){
		P2 p1=d[i];
		int cost=p1.first;
		P p3=p1.second;
		int x1=p3.first;
		int y1=p3.second;
		if(!same(x1,y1)){
			t+=(ll)cost;
			unite(x1,y1);
		}
	}
	cout<<t<<endl;
	return 0;
}


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

long long a,b,c,d;
long long lcm;

inline long long find(long long x){
    return x/c + x/d - x/lcm;
}

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

    cin >> a >> b >> c >> d;
    lcm = c*d/__gcd(c,d);
    cout << (b-a+1) - (find(b) - find(a-1)) << '\n';


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, k) sum += a[i];
  rep2(i, k, n) {
    ll next_sum = sum + a[i] - a[i - k];

    if (next_sum > sum)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    sum = next_sum;
  }
  return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    string s;
    cin>>s;
    bool tmp1=false,tmp2=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C')tmp1=true;
        if(s[i]=='F'&&tmp1==true)tmp2=true;
    }
    if(tmp2==true)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main(){
  while(1){
    int H;
    int W;
    scanf("%d %d", &H, &W);
    if(W == 0 && H == 0)break;
    int h ,w;
    for(h = 1 ; h <= H ; h++){
      for(w = 1 ; w < W ; w++){
	printf("#");
      }
      printf("#\n");
    }
    printf("\n");
  }
  return 0;
}



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

int main() {
	// your code goes here
	string s;
	int a, b;
	cin >> a >> b >> s;
	int cond = 1;
	if(s[a] != '-') cond = 0;
	for(int i = 0; i < s.size(); i++){
		if(i == a) continue;
		if(s[i] < '0' || s[i] > '9') cond = 0;
	}
	if(cond) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)


    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()

"""
97928732	

"""

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

int main() { 
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  if(A==0) cout << 0 << endl;
  else{
  int64_t a = N/(A+B)*A;
  int64_t b = min(N%(A+B),A);
  
  cout << a+b << endl;
  }
  
}

Measured memory_bytes: 3656
n, a=$<.map{|m|m.split.map(&:to_i)}
maxs = a[0]
maxr = - a[0]
a[1..-2].each do |ai|
  tmaxs = maxs
  tmaxr = maxr

  maxs = [tmaxs + ai, tmaxr - ai].max
  maxr = [tmaxs - ai, tmaxr + ai].max
end
maxs += a[-1]
maxr -= a[-1]
p [maxr, maxs].max


Measured memory_bytes: 11140
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define MOD 1000000007
#define endl "\n"
bool visited[100005];
typedef long long ll;
using namespace std;
vector<int>adj[100005];
void dfs(int i){
	visited[i]=true;

	for(auto j:adj[i]){
		if(!visited[j])
			dfs(j);
	}
}

int main(){

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll n, m,a,b; cin>>n>>m;
REP(i,1,m+1){
	cin>>a>>b;
	adj[a].push_back(b);
	adj[b].push_back(a);
}
ll count=0;
REP(i,1,n+1){
	if(!visited[i]){
		dfs(i);
	    count++;}
}

cout<<count-1<<endl;


}	


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    char b;
    int sum = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      	b = s.at(i);
        if (isdigit(b)) {
            sum += b - '0';
        }
    }
    if (sum % 9 == 0) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


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

using namespace std;

int p[55];

int main(){
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i ++){
		scanf("%d", &p[i]);
	}
	
	int temp = 0;
	for(int i = 1; i <= N; i ++){
		temp += (p[i] != i);
	}
	
	if(temp == 0 || temp == 2){
		printf("YES");
	}else{
		printf("NO");
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
bool b[N];
int arr[N];
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;
cin>>s;
int n=s.length();

int cnto=0,cnte=0;
int x=0;
for(int i=0;i<n;i++)
{
	if(s[i]=='L')
	{
//cout<<cnte<<" "<<cnto<<endl;
arr[i]	+=cnte;
//cout<<i<<" "<<arr[i]<<" a"<<endl;
	arr[i+1]+=cnto;
	cnto=0,cnte=0;
	x=0;}
	else
	{
		if(!x)
		cnte+=1;
		else
		cnto+=1;
		x^=1;
	}
	
}
//cout<<arr[1]<<" "<<endl;
x=0;
for(int i=n-1;i>=0;i--)
{
	if(s[i]=='R')
	{

	arr[i+2]+=cnte;
	arr[i+1]+=cnto;
	cnto=0,cnte=0;
	x=0;}
	else
	{
		if(!x)
		cnte+=1;
		else
		cnto+=1;
		x^=1;
	}

}
rep(i,1,n+1)
cout<<arr[i]<<" ";
}

Measured memory_bytes: 1104
#include <stdio.h>

int main(void)
{
	int i, a, b, sum;
	
	while(1) {
		if(scanf("%d %d", &a, &b) == EOF)
			break;
		
		sum = a + b;
	
		for (i = 0; sum > 0; i++) 
			sum = sum / 10;
		
		printf("%d\n", i);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if ((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a)) {
    ans = "Yes";
  }
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  int i,j;
  for(i=0;i<n;i++) cin >> h[i];
  vector<int> a(m);
  vector<int> b(m);
  for(i=0;i<m;i++) {
    cin >> a[i] >> b[i];
  }
  vector<bool> c(n,true);
  for(i=0;i<m;i++){
    if(h[a[i]-1]>=h[b[i]-1]) c[b[i]-1] = false;
    if(h[a[i]-1]<=h[b[i]-1]) c[a[i]-1] = false;
  }
  int cnt = 0;
  for(i=0;i<n;i++) {
    if(c[i]==true) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    map<int, int> dic;
    for (int i=0; i<K; i++) {
        int d;
        cin >> d;
        for (int j=0; j<d; j++) {
            int x;
            cin >> x;
            dic[x] = 1;
        }
    }
    cout << N - dic.size() << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;

ll gg[N];
int main() {
 	// freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,d,i,j,k,a,b,c,x,y,z;
	sc(n);sc(d);sc(x);
	z=x;
	for(i=1;i<=n;i++){
		sc(gg[i]);
		j=1;
		while(j<=d){
			if(j<=d){
				z++;
			}
			j+=gg[i];
		}
	}
	pr(z);

}

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

int main(){
    int N,M;
    cin>>N>>M;
    Graph G(M);
    rep(i,N){
        int A,B;
        cin>>A>>B;
        if(A<=M){
            A--;
            G[A].push_back(B);
        }
    }
    ll sum=0;
    priority_queue<ll>list;
    rep(i,M){
        if(G[i].size()>0){
            rep(j,G[i].size()){
                list.push(G[i][j]);  
            }
        }
        if(list.size()>0){
            sum=sum+list.top();
            list.pop();
        }       
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 5632
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000000)

class check():
    def __init__(self):
        readline=sys.stdin.readline
        n,q=map(int, readline().rstrip().split())
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=map(int, readline().rstrip().split())
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=map(int, readline().rstrip().split())
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print(" ".join(map(str,self.ans)))

def resolve():
    readline=sys.stdin.readline

    dfs=check()
    dfs.do(-1,0)
    dfs.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 234696
N = int(input())
T,A = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
avg = 0
# diff = []
index,clst = 0,500
for i in range(len(H)):
	avg=(T-H[i]*0.006)
	# diff.append(avg-A)
	if abs(avg-A) <= clst:
		clst = abs(avg-A)
		index = i 
# print(diff)
print(index+1)	  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N,M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<pair<ll,ll>> v(M);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    ll b,c;
    for ( int i = 0; i < M; i++ ) {
        cin >> b >> c;
        v[i] = make_pair(c,b);
    }
    sort(A.begin(), A.end());
    sort(v.begin(), v.end(), greater<pair<ll,ll>>());

    int i = 0, k = 0;
    b = c = 0;
    b = v[0].second;
    c = v[0].first;
    while ( i < N ) {
        if ( A[i] < c ) A[i] = c;
        i++;
        b--;
        if ( b == 0 ) {
            k++;
            c = 0;
            if ( k < M ) {
                b = v[k].second;
                c = v[k].first;
            }
        }
    }

    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ans += A[i];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N;
    cin >> N;
    vector<string> str(2);
    cin >>str[0] >> str[1];
    ll cnt = 1;
    ll now = 0;
    bool yoko = true;
    if(str[0][0] == str[0][1]){
        yoko = true;
        cnt = 6;
        now = 2;
    }
    else{
        yoko = false;
        cnt = 3;
        now = 1;
    }
    while(now != N){
        //if(now == N)break;
        if(str[0][now] == str[1][now]){
            if(yoko){
               yoko = false;
               now++;
            }
            else{
                cnt *= 2;
                cnt %= mod;
                yoko = false;
                now++;
            }
        }
        else{
            if(yoko){
                cnt *= 3;
                cnt %= mod;
                now+=2;
                yoko = true;
            }
            else{
                cnt *= 2;
                cnt %= mod;
                now+=2;
                yoko = true;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let w: Vec<char> = input::<String>().chars().collect();
    let mut v = vec![0; 26];
    for c in w {
        let i = (c as u8 - b'a') as usize;
        v[i] += 1;
    }
    println!(
        "{}",
        if v.iter().filter(|&&c| c % 2 == 1).count() == 0 {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4476
A = int(input())  # 500 - 10
B = int(input())  # 100 - 2
C = int(input())  # 50 - 1
X = int(input())

count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1
print(count)


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {

    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int sp[3]={0,0,0};
    int next=0;

    while(true){
        if(sp[next]>=s[next].size()){
            cout<<(char)('A'+next)<<endl;
            break;
        }
        char nch=s[next][sp[next]];
        sp[next]++;
        next=nch-'a';
    }




    return 0;
}



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

using namespace std;
using ll = long long;

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

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

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n+1, a);
    Cins(int, n, b);
    
    ll ans = 0;
    
    For(i, n){
        if(a[i] + a[i+1] < b[i]){
            ans += a[i] + a[i+1];
            a[i] = a[i+1] = 0;
        }
        else if(a[i] < b[i]){
            ans += b[i];
            a[i+1] -= b[i] - a[i];
            a[i] = 0;
        }
        else{
            ans += b[i];
            a[i] -= b[i];
        }
    }
    Cout(ans);
}

Measured memory_bytes: 1024
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int n;
    cin >> n;
    int size = log10(n);
    

    int last;
    REP(i,size){
        int x =  pow(10, size - i);
        n %= x; 
    }

    if(n == 3){
        cout << "bon";
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon";
    }else{
        cout << "hon";
    }
 
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3900
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, a, b, c, d]: number[] = tmp[0].split(" ").map(Number);
    if (c == d) {
      return "No";
    }
    const s: string[] = tmp[1].split("").slice(0, n);
    let prevIsRock = false;
    for (let i = a; i < c; ++i) {
      if (s[i] == "#") {
        if (prevIsRock) {
          return "No";
        }
        prevIsRock = true;
      } else {
        prevIsRock = false;
      }
    }
    prevIsRock = false;
    let prevIsNoRock = true;
    let intervalCount = 1;
    let intervalCountMax = 1;
    for (let i = b; i < d; ++i) {
      if (s[i] == "#") {
        if (intervalCount > intervalCountMax) {
          intervalCountMax = intervalCount;
        }
        intervalCount = 0;
        if (prevIsRock) {
          return "No";
        }
        prevIsRock = true;
      } else {
        ++intervalCount;
        prevIsRock = false;
      }
    }
    if (intervalCount > intervalCountMax) {
      intervalCountMax = intervalCount;
    }
    if (c < d) {
      return "Yes";
    } else {
      if (intervalCountMax >= 3) {
        return "Yes";
      }
      if (s[b - 2] == "." && s[b] == ".") {
        return "Yes";
      }
      if (s[d - 2] == "." && s[d] == ".") {
        return "Yes";
      }
      return "No";
    }
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 12492
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int N;
double a,b,c,d;
double EPS = 1e-5;
double EPS2 = 1e-8;
 
double func(double x){
    return a*x*x*x + b*x*x + c*x + d;
}
 
int pl,mn;
 
bool is_zero(double x){
    if(abs(x) < EPS) return true;
    return false;
}
 
bool fis_zero(double x){
    if(abs(x) < EPS2) return true;
    return false;
}
 
void add(double x){
    if(is_zero(x)) return;
    if(x > 0) pl++;
    else if(x < 0) mn++;
    return;
}
 
void bisearch(double x, double y){
    if(func(y) < func(x)) swap(x,y);
    if(fis_zero(func(x))){ add(x); return;}
    if(fis_zero(func(y))){ add(y); return;}
    double mid;
    int ct = 0;
    rep(i,100){
        mid = (x+y)/2;
        if(fis_zero(func(mid))) break;
        if(func(mid) > 0) y = mid;
        else if(func(mid) < 0) x = mid;
        ct++;
    }
    if(ct == 100) return;
    add(mid);
    return;
}
 
int main(){
    int N;
    cin >> N;
    rep(i,N){
        cin >> a >> b >> c >> d;
        b /= a, c /= a, d /= a, a = 1;
        pl = 0, mn = 0;
        double D = b*b - 3*a*c;
        double xl,xs;
         
        if(D < 0) bisearch(-10000,10000);
        else{
            xs = (-b-sqrt(D))/(3*a);
            xl = (-b+sqrt(D))/(3*a);
            bisearch(-10000,min(xs,xl));
            bisearch(min(xs,xl),max(xs,xl));
            bisearch(max(xs,xl),10000);
        }
         
        cout << pl << " " << mn << endl;
    }
     
}


Measured memory_bytes: 3184
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

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

    int a = N / 2;

    cout << a * (N - a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
	/*
	//数あて
	int n;
	cin >> n;
	int p[200][3];

	for(int i=0;i<n;i++)
	{
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}

	int _p;
	for(int k=0;k<3;k++)
	{
		for(int i=0;i<n;i++)
		{
			_p = p[i][k];
			for(int j=i+1;j<n;j++)
			{
				if(_p == p[j][k])
				{
					p[i][k] = 0;
					p[j][k] = 0;
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		cout << p[i][0] + p[i][1] + p[i][2] << endl;
	}
	*/

	/*
	//得点
	int ai,am,as,ae,bi,bm,bs,be;
	cin >> ai >> am >> as >> ae >> bi >> bm >> bs >> be;
	int answer=ai+am+as+ae;
	if(answer < bi+bm+bs+be)
	{
		answer=bi+bm+bs+be;
	}
	cout << answer << endl;
	*/
	
	//おつり
	int onum;
while(true){
		int N;
		cin >> N;
		if(N == 0) break;
		onum=0;
		int oturi = 1000-N;
		if(oturi >= 500)
		{
			onum++;
			oturi -= 500;
		}
		while(oturi>=100)
		{
			onum++;
			oturi -= 100;
		}
		if(oturi >= 50)
		{
			onum++;
			oturi -= 50;
		}
		while(oturi>=10)
		{
			onum++;
			oturi -= 10;
		}
		if(oturi >= 5)
		{
			onum++;
			oturi -= 5;
		}
		while(oturi>=1)
		{
			onum++;
			oturi -= 1;
		}
		 cout << onum << endl;
	}
   
	
	return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
char a[10005],b[10005];
int main() 
{
	//freopen("1.txt","w",stdout);
	scanf("%s%s",a,b);
	int n=strlen(a),m=strlen(b);
	int ans=0;
	if(n<m) ans=-1;
	else if(n>m) ans=1;
		 else
		 {
		 	for(int i=0;i<n;++i)
		 	{
		 		if(a[i]>b[i]) {ans=1;break;}
		 		else if(a[i]<b[i]) {ans=-1;break;}
		 			 else continue;
		 	}
		 }
	if(ans>0) printf("GREATER\n");
	else if(ans<0) printf("LESS\n");
		 else printf("EQUAL\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B,C;cin>>A>>B>>C;
    cout<<min(C,B/A)<<endl;
}


Measured memory_bytes: 3600
function main(input) {
  const inputs =input.split('\n')
  const A = inputs.slice(0, 3).map(e => e.split(' ').map(Number))
  const [N] = inputs.slice(3, 4).map(Number)
  const B = inputs.slice(4).map(Number)

  let t = Array.from(A)
  for (let i = 0; i < B.length; i++) {
    t.forEach(e => {
      let ind = e.indexOf(B[i])
      if (ind !== -1) {
        e[ind] = 0
      }
    })
  }
  if (t[0][1] + t[0][0] + t[0][2] === 0 ||
    t[1][0] + t[1][1] + t[1][2] === 0 ||
    t[2][0] + t[2][1] + t[2][2] === 0 ||
    t[0][2] + t[1][2] + t[2][2] === 0 ||
    t[0][0] + t[1][1] + t[2][2] === 0 ||
    t[0][1] + t[1][1] + t[2][1] === 0 ||
    t[0][2] + t[1][1] + t[2][0] === 0 ||
    t[0][0] + t[1][0] + t[2][0] === 0
  ) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld ans=0,cou=0;
lld n;
lld pre[21][21];
lld dp[22][1<<21];
lld rec(lld man,lld mask)
{
    if(mask==0&&man==-1)
    {
        return 1;
    }
    if(dp[man][mask]!=-1)
        return dp[man][mask];
    lld ans=0;
    rep(j,0,n-1)
    {
       if((pre[man][j])&&(mask&(1<<j)))
       {
           ans=(ans+(rec(man-1,mask^(1<<j))))%mod;
          // cout<<mask<<"  "<<i<<" "<<j<<" "<<ans<<endl;
       }
    }
    return dp[man][mask]=ans;//dp[mask]=ans;
}
int main()
{
     ios;
     cin>>n;
     memset(dp,-1,sizeof(dp));
     rep(i,0,n-1)
     {
         rep(j,0,n-1)
            cin>>pre[i][j];
     }
     ans=rec(n-1,(1<<n)-1);
     cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 360704
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
  using namespace std;
using namespace __gnu_pbds;
  #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define double long double
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const double PI = acos(-1);
  const int N = 1e6 + 7;
  int mod = 1e9 + 7;
 
int32_t main()
{


    int n, k;
    cin >> n >> k;

    int a[n+1];

    rep(i,1,n)
    {
      cin >> a[i];
    }

    int dp[n+1];

    dp[1] = 0;

    rep(i,2,n)
    {
      dp[i] = 1e9;
    }

    rep(i,1,n)
    {
      rep(j,i+1,min(n,i+k))
      {
        dp[j] = min(dp[j],dp[i] + abs(a[i] - a[j]));
      }
    }

    cout << dp[n];

   return 0;
}       


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

int main(){
    int x, n;
    vector<int> p;

    cin >> x >> n;
    rep (i, n) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    if(find(p.begin(), p.end(), x) == p.end()) {
        cout << x << endl;
    } else {
        int left=x, right=x;
        while( find(p.begin(), p.end(), left) != p.end()){
            left--;
        }
        while( find(p.begin(), p.end(), right) != p.end()){
            right++;
        }

        cout << (abs(x - left) <= abs(x - right) ? left : right )<< endl;
    }
    

    return 0;
}


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

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

	int seq = 0;
	char bre;
	REP(i, s.size()){
		if(s[i] == '1')seq++;
		else {
			bre = s[i];
			break;
		}
	}

	if(k <= seq){
		cout << 1 << endl;
	}else{
		cout << bre << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){

  int N,a[100],c,d;

  while(scanf("%d",&N) != EOF){
    
    c=0;
    d=0;
    
    for(int i=0 ; i < N ; i++){
      cin >>a[i]; 
    }
    
    sort(a,a+N);

    for(int i=0 ; i < N  ; i++){
      c+=a[i]+d;
      d+=a[i];
    }
    
    cout <<c<<endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 1260
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;

template <class Monoid>
struct segment_tree {
    typedef typename Monoid::type T;
    int n;
    vector<T> a;
    Monoid mon;
    segment_tree() = default;
    segment_tree(int a_n, Monoid const & a_mon = Monoid()) : mon(a_mon) {
        n = 1; while (n < a_n) n *= 2;
        a.resize(2*n-1, mon.unit);
    }
    void point_update(int i, T z) { // 0-based
        a[i+n-1] = z;
        for (i = (i+n)/2; i > 0; i /= 2) {
            a[i-1] = mon.append(a[2*i-1], a[2*i]);
        }
    }
    T range_concat(int l, int r) { // 0-based, [l, r)
        T lacc = mon.unit, racc = mon.unit;
        for (l += n, r += n; l < r; l /= 2, r /= 2) { // loop, 2x faster than recursion
            if (l % 2 == 1) lacc = mon.append(lacc, a[(l ++) - 1]);
            if (r % 2 == 1) racc = mon.append(a[(-- r) - 1], racc);
        }
        return mon.append(lacc, racc);
    }
};
struct plus_t {
    typedef int type;
    const int unit = 0;
    int append(int a, int b) { return a + b; }
};

int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<int> l(n), r(n); repeat (i,n) { scanf("%d%d", &l[i], &r[i]); ++ r[i]; }
    vector<int> length_order(n);
    whole(iota, length_order, 0);
    whole(sort, length_order, [&](int i, int j) { return r[i] - l[i] < r[j] - l[j]; });
    vector<int> result(m+1);
    segment_tree<plus_t> segtree(m+2); // or a binary indexed tree
    int i = 0;
    repeat_from (d,1,m+1) {
        result[d] += n - i;
        for (int x = 0; x <= m; x += d) {
            result[d] += segtree.range_concat(0, x+1);
        }
        for (; i < n and r[length_order[i]] - l[length_order[i]] <= d; ++ i) {
            int li = l[length_order[i]];
            int ri = r[length_order[i]];
            segtree.point_update(li, segtree.range_concat(li, li+1) + 1);
            segtree.point_update(ri, segtree.range_concat(ri, ri+1) - 1);
        }
    }
    repeat_from (d,1,m+1) {
        printf("%d\n", result[d]);
    }
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>

using namespace std;

int n;
int a[21];
int res;

int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 1; i < n - 1; i++) {
		if (a[i] < a[i - 1] && a[i] > a[i + 1]) res++;
		else if (a[i] > a[i - 1] && a[i] < a[i + 1]) res++;
	}
	cout << res;
	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int n;
string s;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> s;
  int c = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R') c++;

  if (c > n-c)
    cout << "Yes\n";
  else
    cout << "No\n";


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N, C;
    cin >> N >> C;
    int D[C][C];
    rep(i,C){
        rep(j,C){
            cin >> D[i][j];
        }
    }
    int c[N][N];
    map<int, int> mp0, mp1,mp2;
    rep(i,N){
        rep(j,N){
            cin >> c[i][j];
            --c[i][j];
            if((i+j)%3==0){
                mp0[c[i][j]]++;
            }
            else if((i+j)%3==1){
                mp1[c[i][j]]++;
            }
            else if((i+j)%3==2){
                mp2[c[i][j]]++;
            }
        }
    }
    int ans = INF;
    rep(i,C){
        int cnt0 = 0;
        for(auto e : mp0){
            cnt0 += D[e.first][i] * e.second;
        }
        for(int j=0;j<C;j++){
            if(i == j) continue;
            int cnt1 = 0;
            for(auto e : mp1){
                cnt1 += D[e.first][j] * e.second;
            }
            for(int k=0;k<C;k++){
                if(i == k || j == k) continue;
                int cnt2 = 0;
                for(auto e : mp2){
                    cnt2 += D[e.first][k] * e.second;
                }
                chmin(ans, cnt0+cnt1+cnt2);
            }
        }
    }
    cout << ans << endl;
}

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


int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,6) {
        if(s[i] == '1') {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n;
double x,ans;

main(){
	cin>>n;
	rep(i,n){
		string s;
		cin>>x>>s;
		if(s=="JPY")ans+=x;
		else ans+=x*380000.0;
		//dans;
	}
	printf("%.4lf\n",ans);
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll n; cin>>n;
	if(n%2) {
		cout<<0<<"\n";
		return 0;
	}
	n/=2;
	ll ret=0;
	while(n)
		ret+=n/5, n/=5;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256