akhauriyash/Code-Regression huggingface dataset:
#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>;

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



int pcnt(int x) {
  return __builtin_popcount(x);
}
int f(int x){
    if(x == 0) return 0;
    return f(x%pcnt(x))+1;
}


//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;
    string xs;
    cin >> xs;
    vector<int> X(N);
    int pc0=0;
    rep(i,N){
        X[i] = xs[i]-'0';
        pc0 += X[i];
    }

    vector<int> ans(N);
    rep(b,2){
        int pc = pc0;
        if(b==0) pc++; else pc--;
        if(pc <= 0) continue;

        int Xm = 0; 
        rep(i,N){
            Xm = (Xm*2)%(pc);
            Xm += X[i];
        }

        int p2ni = 1;
        int Xi;
        for(int ni = N-1; ni>=0 ; --ni){
            if(X[ni]==b){
                if(b==0) Xi = (Xm + p2ni)%pc;
                else Xi = (Xm - p2ni + pc)%pc;
                ans[ni] = f(Xi)+1;   
            }
            p2ni = (p2ni*2)%pc;
        }
    }

    rep(i,N){
        cout << ans[i] << endl;
    }

 
   return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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


string addzero(string s){
  while(s.size()<6){s.insert(0,"0");}
  return s;
}

int main() {
  int n,m;cin>>n>>m;
  vector<tuple<ll,ll,ll>> c(m);
  reps(i,m){
    ll p,y;cin >> p>>y;
    tuple<ll,ll,ll> t=make_tuple(p,y,i);
    c[i-1]=t;
  }

  sort(ALL(c));

  ll p=get<0>(c[0]);
  ll cnt=0;
  rep(i,m){
    if(p==get<0>(c[i])){cnt++;}
    else cnt=1;
    p=get<0>(c[i]);
    c[i]=make_tuple(get<2>(c[i]),get<0>(c[i]),cnt);
  }
  sort(ALL(c));
  for(auto x:c){
    string s=to_string(get<1>(x));
    string t=to_string(get<2>(x));
    cout << addzero(s)+addzero(t)<< endl;
  }
}

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

int main() {
  string s;
  int count = 0;
  cin >> s;

  rep(i, 3) {
     if (s.at(i) == s.at(i + 1)) {
       count++;
     }
  }

  if (count > 0) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
n = list(map(int, input().strip().split(' ')))
b = n[1]
h = 100000
c = 100000
int(c)
a = []
for i in range(n[0]):
  a.append(list(map(int, input().split())))
  if a[i][1] <= n[1] and a[i][0] <= c:
    h = a[i][1]
    c = a[i][0]
    

if h <= n[1]:
  print(c)
else:
    print("TLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int from,to;
  ll cost;
}edge;
const int V_MAX = 2510,E_MAX = 5010;
int V,E;
ll P;
vector<edge>es(E_MAX);
vector<vector<int> >G1(V_MAX);
vector<vector<int> >G2(V_MAX);
vector<bool> canmove1(V_MAX,false);
vector<bool> canmove2(V_MAX,false);
vector<ll> d(V_MAX,MAX_I);

//ゴールまで行ける場所
int dfs(int g,vector<vector<int> > &G, vector<bool> &canmove){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G[g]){
    dfs(e,G,canmove);
  }
  return 0;
}

bool bellmanford(int s){
  rep(i,V)d[i] = MAX_I;
  d[s] = 0;
  rep(i,V){
    bool update = false;
    for(const edge &e : es){
      if(!canmove1[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        update = true;
        if(i==V-1)return true;
      }
    }
    if(!update)break;
  }
  return false;
}


bool find_negative_loop(){
  rep(i,V)d[i] = 0;
  rep(i,V){
    for(const edge &e : es){
      if(canmove1[e.to] && canmove2[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1)return true;
      }
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> P;
  rep(i,E){
    int A,B;
    ll C;cin >> A >> B >> C;
    --A;--B;
    es.push_back({A,B,P-C});
    G1[B].push_back(A);
    G2[A].push_back(B);
  }
  dfs(V-1,G1,canmove1);
  dfs(0,G2,canmove2);
  if(bellmanford(0)){
    cout << -1 << endl;
    return 0;
  }
  cout << max(0ll,-d[V-1]) << endl;
  return 0;
}


Measured memory_bytes: 768
def resolve():
    import itertools
    import math
    n = int(input())
    a = tuple(map(int, input().split()))
    b = tuple(map(int, input().split()))
    alist = list(itertools.permutations(sorted(a)))
    for i in range(math.factorial(n)):
        if alist[i] == a:
            numa = i+1
        if alist[i] ==b:
            numb = i+1
    print(abs(numa-numb))
resolve()

Measured memory_bytes: 44784
abcd = gets.chomp

def main(expr, source)
  if source.length == 0
    if eval(expr) == 7
      puts "#{expr}=7"
      exit
    end
    return
  end
  %w{+ -}.each do |op|
    if expr == ""
      main("#{source[0]}#{op}#{source[1]}", source[2..-1])
    else
      main("#{expr}#{op}#{source[0]}", source[1..-1])
    end
  end
end

main("", abcd)

Measured memory_bytes: 1788
from bisect import bisect_left

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

    ball = []
    for i in range(N):
        a, b = map(int, input().split())
        ball.append([a,b,'r'])
    for i in range(N):
        c, d = map(int, input().split())
        ball.append([c,d,'b'])

    sort_ball = sorted(ball, key=lambda x:(-x[0],x[1]))
    ans = 0
    cand = []
    for i in range(2*N):
        if sort_ball[i][2] == 'b':
            cand.append(sort_ball[i][1])
        if sort_ball[i][2] == 'r':
            if not cand:
                continue
            cand.sort()
            b_y = bisect_left(cand, sort_ball[i][1])
            if b_y == len(cand):
                continue
            ans += 1
            cand.pop(b_y)

    print(ans)

        

    
    
    

if __name__ == "__main__":
    main()

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

// Tenki
int main()
{
    string s, t;
    cin >> s >> t;
    int count = 0;
    if (s[0] == t[0]) count++;
    if (s[1] == t[1]) count++;
    if (s[2] == t[2]) count++;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int n,m,s,t;

void dijkstra(int node, vector<vector<pair<int, ll> > > &path, vector<ll> &dist){
    priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;
    que.push(make_pair(0,node));
    int cnt=0;

    while((int) que.size()>0 && cnt<n){
        ll d=que.top().first;
        int node=que.top().second;
        que.pop();

        if(dist[node]<MOD*MOD){
            continue;
        }else{
            dist[node]=d;
            cnt++;
        }

        for(auto &x: path[node]){
            node=x.first;
            if(dist[node]<MOD*MOD)continue;
            else{
                que.push(make_pair(d+x.second, node));
            }
        }
    }
}

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    cin >> n >> m >> s >> t;
    s--;t--;

    vector<vector<pair<int, ll> > > pathA(n,vector<pair<int,ll> >(0));
    vector<vector<pair<int, ll> > > pathB(n,vector<pair<int,ll> >(0));

    for(int i=0; i<m; i++){
        int u,v;
        ll a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        pathA[u].push_back(make_pair(v,a));
        pathA[v].push_back(make_pair(u,a));

        pathB[u].push_back(make_pair(v,b));
        pathB[v].push_back(make_pair(u,b));
    }

    vector<ll> distA_from_s(n,MOD*MOD);
    vector<ll> distB_to_t(n,MOD*MOD);

    dijkstra(s, pathA, distA_from_s);
    dijkstra(t, pathB, distB_to_t);

    //cout_vec(distA_from_s);
    //cout_vec(distB_to_t);

    ll min_=MOD*MOD;
    vector<ll> ans(n,0);
    for(int i=n-1; i>=0; i--){
        min_=min(min_, distA_from_s[i]+distB_to_t[i]);
        ans[i]=1000000000000000-min_;
    }
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 19000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;


int main()
{ 
ll n,h;
cin >> n>>h; 
ll table[n];
ll maxa=0;
rep(i,n){
    ll temp=0;
    cin >> temp>>table[i];
    if(temp>maxa)maxa=temp;
}
sort(table, table + n, greater<ll>());
rep(i,n){
    if(table[i]<maxa)break;
    else{
        ans++;
        h-=table[i];
        if(h<=0){
            cout << ans << endl;
            return 0;
        }
    }
}
ans+=(h-1)/maxa+1;

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,f[1000005],sum[1000005],ans,Pow;
int main()
{
	long long i;
	scanf("%lld",&n);Pow=(n-1)*(n-1)%mod;
	f[0]=1;f[1]=1;f[2]=1;
	sum[0]=1;sum[1]=2;sum[2]=3;
	for(i=3;i<=n;i++)
	{
		f[i]=(f[i-1]+sum[i-3])%mod;
		sum[i]=(sum[i-1]+f[i])%mod;
	}
	for(i=2;i<=n;i++)ans=(ans+(Pow+n-i+1)*f[n-i]%mod)%mod;
	ans=((ans+(n-1)*f[n-1]%mod)%mod+f[n])%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15872
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll h, w, mn = INF, used[50][50];
queue<pp> q;
char m[55][55];
int main() {
	rep(i, 50)rep(j, 50)used[i][j] = INF;
	ll ct = 0;
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> m[i][j],ct+=(m[i][j]=='.'?1:0);
	q.push(pp{ 0,0 });
	used[0][0] = 0;
	while (!q.empty()) {
		pp p = q.front();
		q.pop();
		//cout << p.first << "," << p.second << endl;
		if (p.first < h - 1 && used[p.fi + 1][p.se] == INF && m[p.fi + 1][p.se] == '.') { q.push(pp{ p.fi + 1,p.se }); used[p.fi + 1][p.se] = used[p.fi][p.se] + 1; }
		if (p.first > 0 && used[p.fi - 1][p.se] == INF && m[p.fi - 1][p.se] == '.') { q.push(pp{ p.fi - 1,p.se }); used[p.fi - 1][p.se] = used[p.fi][p.se] + 1;}
		if (p.se < w - 1 && used[p.fi][p.se + 1] == INF && m[p.fi][p.se + 1] == '.'){q.push(pp{ p.fi ,p.se + 1 }); used[p.fi][p.se+1] = used[p.fi][p.se] + 1;}
		if (p.se > 0 && used[p.fi][p.se - 1] == INF && m[p.fi][p.se - 1] == '.') { q.push(pp{ p.fi ,p.se - 1 }); used[p.fi][p.se-1] = used[p.fi][p.se] + 1;}
	}
	cout << (used[h - 1][w - 1] == INF ? -1 : ct - used[h - 1][w - 1]-1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 200000+5;

int n;
vi G[N];

int main(){
	ri(n);
	for(int i=1; i<n; i++){
		int u, v;
		ri2(u, v);
		if(u > v) swap(u, v);
		G[v].emplace_back(u);
	}
	ll ans = 0LL;
	ll sum = 0LL;
	for(int i=1; i<=n; i++){
		sum += i;
		for(int v : G[i]){
			sum -= v;
		}
		ans += sum;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 14604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	ll n, in;
	cin >> n;
	vi d(13,0);
	rep(i, n) {
		cin >> in;
		d[in]++;
	}
	bool zero = false;
	rep(i, 13) {
		if (d[i] >= ((i == 0 || i == 12) ? (i==0?1:2) : 3))zero = true;
	}
	if (zero) {
		cout << 0 << endl;
	}
	else {
		int ans = 0;
		rep(i, 1<<11) {
			vi v;
			v.push_back(0);
			if (d[12])v.push_back(12);
			range(j, 1, 12) {
				if (d[j] == 0) {
					continue;
				}
				else if (d[j]==2) {
					v.push_back(j);
					v.push_back(24-j);
				}
				else {
					bool b = ((i >> j) & 1);
					v.push_back(b ? j : 24 - j);
				}
			}
			sort(all(v));
			v.push_back(24);
			int tmp = 500;
			rep(k, v.size() - 1) {
				tmp = min(tmp, v[k + 1] - v[k]);
			}
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;




int main(){FIN
    
    ll x,y;cin>>y>>x;
    if(x-2*y>=0 && (x-2*y)%2==0){
        if(y-(x-2*y)/2>=0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

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

	long long int arr[n];

	long long int max=-1;

	for(long long int i=0;i<n;i++)
	{
		cin >> arr[i];
		if(arr[i]>max)
			max=arr[i];
	}

	long long int hash[200005] = {0};

	for(long long int i=0;i<n;i++)
	{
		hash[arr[i]]++;
	}

	long long int dp[n];
	long long int tot = 0;
	long long int add;
	for(long long int i=1;i<=max;i++)
	{
		add=hash[i]*(hash[i] - 1)/2;
		tot+=add;
	}
	long long int sub;
	for(long long int i=0;i<n;i++)
	{
		if(hash[arr[i]])
		{
			sub = hash[arr[i]]-1;
		}

		else
			sub=0;

		dp[i] = tot - sub;
	}

	for(long long int i=0;i<n;i++)
	{
		cout << dp[i] << endl;
	}
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

int count (int n) {
  int ans = 0;
  REP(i, n) {
    if(n % (i+1) == 0) ans++;
  }
  return ans;
}

signed main () {
  int n; cin >> n;
  if(n%2 == 1) n++;
  int ans = 0;
  REP(i, n/2) {
    if(count(2*i + 1) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

 int main()
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 scanf("%d", &n);
for(i = 0; i < n; i++){
 scanf("%d", &a[i]);
 sum += a[i];
 }
 max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
 if(a[i] < min)min = a[i];
 }
 printf("%d %d %lld\n", min, max, sum);

 return 0;
 }


Measured memory_bytes: 2124
#include<stdio.h>

int main()
{
	int x, y;
	scanf("%d %d", &x, &y);

	if (y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1732
N,Y = [int(n) for n in input().split()]
flag = False
for noguchi in range(N + 1):

    for higuchi in range(N - noguchi + 1):
        yukichi = N - noguchi - higuchi
        if (noguchi * 1000 + higuchi * 5000 + yukichi * 10000) == Y:
            print(yukichi,higuchi,noguchi)
            flag = True
            break
    
    if flag:
        break
        
if not flag:
    print(-1,-1,-1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true){
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
            if(m == -1 && f == -1 && r == -1){
                break;
            }

            if(m == -1 || f == -1 || m + f <30){
                System.out.println("F");
            }else if(m + f >= 80){
                System.out.println("A");
            }else if(m + f >= 65 && m + f < 80){
                System.out.println("B");
            }else if(m + f >= 50 && m + f < 65){
                System.out.println("C");
            }else if(m + f >= 30 && m + f < 50){
                if(r >= 50 ){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }
        }
    }
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n,m,r;
  cin>>n>>m>>r;
  int p[r];
  for(int i=0;i<r;i++){
    int v;
    cin>>v;
    v--;
    p[i]=v;
  }
  ll d[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j]=10000000;
    }
  }
  for(int i=0;i<n;i++) d[i][i]=0;
  for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    d[a][b]=min(d[a][b],c);
    d[b][a]=d[a][b];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  sort(p,p+r);
  ll ans=1000000000;
  do{
    ll temp=0;
    for(int i=0;i<r-1;i++){
      temp+=d[p[i]][p[i+1]];
    }
    ans=min(temp,ans);
  }while(next_permutation(p,p+r));
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3888
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[300][300],b[300][300];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> a[i][j];
			if(i!=j) b[i][j]=1;
			else b[i][j]=0;
		}
	}
	long long ans=0;
	bool flag=true;
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(a[i][j]>a[i][k]+a[k][j]) flag=false;
				else if(a[i][j]==a[i][k]+a[k][j]) b[i][j]=b[i][k]+b[k][j];
			}
		}
	}
	if(!flag) cout << -1 << endl;
	else{
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(b[i][j]==1) ans+=a[i][j];
			}
		}
		cout << ans/2 << endl;
	}
	return 0;
}


Measured memory_bytes: 896
import sys
input = lambda: sys.stdin.readline().rstrip()
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())

ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(1, N+1):
            ans += gcd(i, j, k)

print(ans)

Measured memory_bytes: 69540
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MXN=100005;
vector<edge> G[MXN];
vector<bool> B(MXN,false);
vl ans(MXN);

void bfs(ll x,ll d){
  B[x]=true;
  ans[x]=d;
  ll k=G[x].size();
  rep(i,k){
    if(B[G[x][i].to]==false){
      bfs(G[x][i].to,G[x][i].cost+d);
    }
  }
}

  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  rep(i,N-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  ll Q,K;
  cin >> Q >> K;
  K--;
  bfs(K,0);
  rep(i,Q){
    ll x,y;
    cin >> x >> y;
    x--;y--;
    cout << ans[x]+ans[y] << endl;
  }
}


Measured memory_bytes: 14336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int P = sc.nextInt();
      int Q = sc.nextInt();
      int R = sc.nextInt();
      if(P>=Q && P>=R){
        System.out.println(Q+R);
      }else if(Q>=P && Q>=R){
        System.out.println(P+R);
      }else if(R>=P && R>=Q){
        System.out.println(P+Q);
      }
    }
}     

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

int main(){
  string s;
  cin>>s;
  int len =s.size();
  int cnt=0;
  for(int i=0;i<len;i++){
    if(s[i]=='o')cnt++;
  }
  cout<<(8-cnt<=15-len?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    REP(i, M)
    {
        cin >> s.at(i) >> c.at(i);
    }

    for (int i = 0; i <= 999; i++)
    {
        int digit = 0;
        // 0の桁は1
        if (i == 0)
        {
            digit = 1;
        }
        else
        { // 桁の計算
            int tmp = i;
            while (tmp)
            {
                tmp /= 10;
                ++digit;
            }
        }
        // 桁が違えばさよなら
        if (N != digit)
        {
            continue;
        }
        // 数値を文字列に
        string str = to_string(i);

        bool flag = true;
        REP(j, M)
        {
            // cout << i << endl;
            // cout << "s[j]: " << s[j] << endl;
            // cout << "str[s[j]-1]: " << str[s[j] - 1] << endl;
            // cout << "c[j]: " << c[j] << endl;
            if (str[s[j] - 1] != c[j])
            {
                flag = false;
                break;
            }
        }
        // cout << flag << endl;
        // cout << endl;
        if (flag)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
 
class prog{
  static void Main(){
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int ans = (input[0] + input[1]) % 2 == 0 ? (input[0] + input[1]) / 2 : (input[0] + input[1]) / 2 + 1;
    
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
char c[120];
int debug=0;
int sf(int l,int r)//不是回文return 1 
{
	int i;
	if(debug)printf("c.from %d to %d,i.from 0 to %d\n",l,r,(r-l)/2);
	for(i=0;i<(r-l)/2+1;i++)
	{
		if(debug)printf("Comparing:c[%d] and c[%d],%c and %c ,",l+i,r-i,c[l+i],c[r-i]);
		if(c[l+i]!=c[r-i])
			{
				if(debug)printf("不同！\n");
				return 1;
			}
		else if(debug)printf("相同\n");
	}	
	return 0;
}
int main()
{
	cin>>c;
	int lc=strlen(c);
	int i;
//	for(i=0;i<lc/2;i++)
//		if(c[i]!=c[n-i-1])
//			goto loop;
//	for(i=0;i<=(n+1)/4;i++)
//		if()
	if(sf(0,lc-1)||sf(0,(lc-1)/2-1)||sf((lc+3)/2-1,lc-1))
		goto loop;
	cout<<"Yes";
	return 0;
	loop:
		cout<<"No";
	return 0;
//	while(1)
//	{
//		int l,r;
//		cin>>c>>l>>r;
//		cout<<sf(l,r)<<endl;
//	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

string s;

signed main(){
	cin>>s;
	int n=s.size();
	int A=0,B=0;
	r(i,n){
		char c;
		if(i%2==0)c='0';
		else c='1';
		if(s[i]!=c)A++;
	}
	r(i,n){
		char c;
		if(i%2==1)c='0';
		else c='1';
		if(s[i]!=c)B++;
	}
	cout<<min(A,B)<<endl;
}


Measured memory_bytes: 512
"use strict";

function Main(input)
{
    // console.log(input);
    let arr = input.split('\n');
    let N = arr.shift();
    // console.log(N);
    // console.log(arr);
    let W = arr[0].split(' ').map(function(a) {
        return parseInt(a, 10);
    });
    
    let min = Math.abs(sum(W, 0, 1) - sum(W, 1, N));
    for(let T = 2; T < N; T++)
    {
        let diff = Math.abs(sum(W, 0, T) - sum(W, T, N));
        min = diff < min ? diff : min;
    }
    
    let result = min;
    console.log(result);
    return result;
}

function sum(W, from, to)
{
    let total = 0;
    for(let i = from; i < to; i++)
    {
        total += W[i];
    }
    return total;
}

// Main(require("fs").readFileSync("Task02_input01.txt", "utf8"));
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	ll n,m;
	cin>>n>>m;
	ll a[m];
	ll sum=0;
	for(int i=0; i<m; i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	n-=sum;
	if(n<0)
	{
		cout<<"-1\n";
	}
	else cout<<n<<endl;
}

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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int gcd(int x, int y){
	while (y){
		x %= y;
		swap(x, y);
	}
	return x;
}

const int mod = 1000000007;

long long pw(long long a, long long b){
	long long res = 1;
	while (b){
		if (b & 1ll)
			res = res * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main(){

	cin.sync_with_stdio(0);
	string s;
	cin >> s;

	int n = s.length();
	for (int i = 0; i < n - 1; i++){
		if (s[i] == s[i + 1]){
			cout << i + 1 << " " << i + 2 << "\n";
			return 0;
		}
	}

	for (int i = 0; i < n - 2; i++){
		if (s[i] == s[i + 2]){
			cout << i + 1 << " " << i + 3 << "\n";
			return 0;
		}
	}

	puts("-1 -1");

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,a,b;cin>>a>>b;
    a*=b;
    for(i=1;i<=3;i++){
        if((a*i)%2==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp
?????????: Red and Black
?????°
19:08:06 ??¶?´???????????????§Haskell??§??????????????????
19:17:53 ??¨??????????????????????????¨?????´??°??????bar???????£?????????????
19:32:19 ????????????
19:34:02 ??????fmap???????????????
19:35:56 AC??????????????£??????
19:36:06 ?????????????????¨????????????????????§????§£??¬????????????????????????
-}
import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
 [w,h] <- (map read . words) `fmap` getLine -- w??¨h??????
 when ((w,h) /= (0,0)) $ do -- (0,0)??§????????????????????°
  arr <- replicateM h getLine -- ??°?????????
  print $ foo arr
  main

type Stat = (Integer, [[Char]])



foo :: [[Char]] -> Int -- ??????????????????"@"?????£??\??????"."?????§????????????"@"??????????????????"@"????????°?????????
foo arr = sum $ map(length . (filter (=='@'))) $ snd $ repetitive bar (1,arr)

repetitive :: Eq t => (t -> t) -> t -> t --??????????????????????????§?????¨????????????????±???????
repetitive f s = if f s == s then s else repetitive f (f s)

bar :: Stat -> Stat -- "@"????????????"."???"@"?????????
bar = f . f
 where f = fmap transpose . bar1 ".@" . bar1 "@." -- ???????????????????????????????????????????????????????????¨??¢???

bar1 :: String -> Stat -> Stat -- replace all `bef` with "@@", while counting the num
bar1 bef (num, dat) = (num + sum(map fst d'), map snd d')
 where 
  d' = map f dat -- ???????????????????????¨?????°????????????????????§????¨?
  f :: String -> (Integer,String)
  f str
   | null str = (0,"") -- ??????????????????0???
   | bef `isPrefixOf` str = count $ ("@@" ++) `fmap` f(drop 2 str) -- ?????????2???????????´????????????????????¨???????????°?????°?¢???????
   | otherwise = (head str :) `fmap` f (tail str) -- ??¶???????????°?????????????????????????????°

count :: (Integer,a) -> (Integer,a)
count(a,b)=(a+1,b)

Measured memory_bytes: 5388
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int A , B;

int ask(int a,int b){
  printf("? %d %d\n",a,b);
  fflush(stdout);
  static char ch[3];
  scanf("%s",ch);
  return ch[0] == 'Y';
}

int main(){
  scanf("%d%d",&A,&B);
  if(A <= B) {
    puts("Impossible");
    fflush(stdout);
    return 0;
  }
  int n = A + B;
  vi v;
  rep(i,0,n) {
    if(!sz(v)) v.pb(i);
    else {
      if(ask(v.back(),i))
        v.pb(i);
      else
        v.pop_back();
    }
  }
  static char ans[4040];
  int honest = v.back();
  rep(i,0,n) ans[i]='0'+ask(honest,i);
  printf("! ");
  rep(i,0,n) putchar(ans[i]);
  puts("");
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int n;
  int k;

  cin >> n;
  cin >> k;
  vector<int> a = vector<int>(n, 0);

  int one_index;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) one_index = i;
  }

  int ans = (n - 2) / (k - 1) + 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
N = int(input())

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

import numpy as np

B_list = A_list.copy()

for i in range(1, len(A_list)):
    if A_list[i] < A_list[i-1]:
        A_list[i] = A_list[i-1]
        
A_array = np.array(A_list)
B_array = np.array(B_list)

print(np.sum(A_array - B_array))

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  bool approve = true;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0) {
      if (A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
        approve = false;
        break;
      }
    } 
  }
  if (approve) {
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main()
	{
		string s;
		while ((s = Console.ReadLine()) != "0 0")
		{
			string[] a = s.Split(' ');
			if (Int32.Parse(a[0]) < Int32.Parse(a[1]))
			{
				Console.WriteLine("{0} {1}", a[0], a[1]);
			}
			else
			{
				Console.WriteLine("{0} {1}", a[1], a[0]);
			}
		}
	}
}

Measured memory_bytes: 5500
n,m=gets.chomp.split(" ").map(&:to_i)
#p_arrに県piが現状幾つの市があるか入れる
p_arr= Array.new(n,0)
p_y = Array.new(m)
for i in 0..m-1 do
  p_y[i]=gets.chomp.split(" ").map(&:to_i)
  p_y[i].push(i)
end
#市をできた順番に並べる
p_y.sort!{ |a, b| a[1] <=> b[1] }
for i in 0..m-1 do
  p_arr[p_y[i][0]-1]+=1
  p_y[i].push(p_arr[p_y[i][0]-1])
end
#市を入力順に並べる
p_y.sort!{ |a, b| a[2] <=> b[2] }
for i in 0..m-1 do
  printf("%06d",p_y[i][0])
  printf("%06d",p_y[i][3])
  puts ""
end

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

int main() {
  int N, K;
  cin >> N >> K;
  int A = 1;
  
  for (int i=0; i<N; i++) {
 	 if (A > K) {
       A += K;
 	 }
	else {
      A *= 2;
	}
  }
  cout << A;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int dp[100000];

int main() {
    int h, w, d; cin >> h >> w >> d;
    map<int, pii> m;
    rep(i, h) {
        rep(j, w) {
            int a; cin >> a;
            m[a] = make_pair(i+1, j+1);
        }
    }

    for (int i = 1; i <= h*w; i++) {
        if (i+d <= h*w) {
            dp[i+d] = dp[i] + abs(m[i].first-m[i+d].first) + abs(m[i].second-m[i+d].second);
        }
    }

    int q; cin >> q;
    rep(i, q) {
        int l, r; cin >> l >> r;
        cout << dp[r] - dp[l] << endl;
    }
}


Measured memory_bytes: 7040
a, b = [int(c) for c in input().split(' ')]
num = 0
bdash = b
if b == 1:
    num = 0
    bdash = -1
while bdash > 0:
    if bdash == a:
        num = num+1
        break
    elif bdash > a:
        num = num+1
        bdash = bdash - (a - 1)
    elif bdash < a:
        num = num + 1
        break
print(num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    string s;
    cin >> s;
    vector<int> cnt(3);
    for (char c : s) cnt[c - 'a']++;
    cout << (*max_element(all(cnt)) - *min_element(all(cnt)) <= 1 ? "YES"
                                                                  : "NO")
         << endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	class DJSet {
		int n;
		int[] upper;

		public DJSet(int n_) {
			n = n_;
			upper = new int[n];
			Arrays.fill(upper, -1);
		}

		int root(int x) {
			return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
		}

		void setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (upper[x] < upper[y]) {
				x ^= y;
				y ^= x;
				x ^= y;
			}
			upper[y] += upper[x];
			upper[x] = y;
		}

		int cmpNum() {
			int ret = 0;
			boolean[] vis = new boolean[n];
			for (int i = 0; i < n; ++i) {
				if (vis[root(i)])
					continue;
				else {
					vis[root(i)] = true;
					++ret;
				}
			}
			return ret;
		}
	}

	@SuppressWarnings("unchecked")
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
		}
		DJSet ds = new DJSet(n);
		int cnt = 2 * (n - 1);
		int[] x = new int[m];
		int[] y = new int[m];
		boolean[] vis = new boolean[n];
		long[][] tmp = new long[n][2];
		for (int i = 0; i < tmp.length; ++i)
			for (int j = 0; j < tmp[i].length; ++j)
				tmp[i][j] = Integer.MAX_VALUE / 2;
		for (int i = 0; i < m; ++i) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			ds.setUnion(x[i], y[i]);
			cnt -= 2;
		}
		if (cnt > n) {
			System.out.println("Impossible");
			return;
		}
		for (int i = 0; i < n; ++i) {
			tmp[ds.root(i)][0] = Math.min(tmp[ds.root(i)][0], a[i]);
			if (tmp[ds.root(i)][0] == a[i])
				tmp[ds.root(i)][1] = i;
		}
		long ans = 0;
		if (cnt > 0) {
			for (int i = 0; i < n; ++i) {
				if (tmp[i][0] == Integer.MAX_VALUE / 2)
					continue;
				ans += tmp[i][0];
				vis[(int) tmp[i][1]] = true;
				--cnt;
			}
		}
		PriorityQueue<Integer> pq = new PriorityQueue();
		for (int i = 0; i < n; ++i) {
			if (vis[i])
				continue;
			pq.add(a[i]);
		}
		while (cnt-- > 0) {
			ans += pq.poll();
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 102424
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 A PICTURE 999.
       01 B PICTURE 999.
       01 X PICTURE 999.
       01 INp PICTURE X(21).
       01 temp picture 9999.
       01 S PICTURE 999.
       01 N PIC 999.
       01 tempb picture 9999.
       PROCEDURE DIVISION.
       MAIN.
       ACCEPT INp.
       PERFORM VARYING S FROM 1 BY 1 UNTIL INp(S:1)= SPACE
       END-PERFORM.
       move S TO temp.
       add -1 to temp.
       MOVE INp(1:temp) TO A.
       add 2 to temp
       PERFORM VARYING N FROM temp BY 1 UNTIL INp(N:1)= SPACE
       END-PERFORM.
       move N TO tempb.
       subtract S FROM tempb.
       MOVE INp(temp:tempb) TO B.
       MOVE N TO temp.
       add 1 to temp.
       PERFORM VARYING S FROM temp BY 1 UNTIL INp(S:1)= SPACE
       END-pERFORM.
       move S TO tempb.
       subtract N FROM tempb.
       MOVE INp(temp:tempb) TO X.
      	IF X >= A AND X<=A+B THEN
      		DISPLAY "YES"
      	ELSE
      		DISPLAY "NO"
      	END-IF.
      	STOP RUN.

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

int w[100], v[100];
int n, W;
long long dp[101][100001];

long long solve(int i, int j)
{
	if (dp[i][j] != -1)
		return dp[i][j];
	long long res;
	if (i == n)
		res = 0;
	else if (j < w[i])
		res = solve(i + 1, j);
	else 
		res = max(solve(i + 1, j), solve(i + 1, j - w[i])+v[i]);
	return dp[i][j] = res;
}

int main()
{
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	memset(dp, -1, sizeof(dp));
	long long ans = solve(0, W);
	cout << ans << endl;
}

Measured memory_bytes: 79104
import java.util.HashMap;
import java.util.Scanner;

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

        java.util.Map<Integer, Integer> oddMap = new HashMap<>();
        java.util.Map<Integer, Integer> evenMap = new HashMap<>();

        int currentKey = 0;
        for (int i = 0; i < n; i++) {
            currentKey = sc.nextInt();
            if (i % 2 == 0) {
                oddMap.put(currentKey, oddMap.getOrDefault(currentKey, 0) + 1);
            } else {
                evenMap.put(currentKey, evenMap.getOrDefault(currentKey, 0) + 1);
            }
        }

        int o1_k = 0;
        int e1_k = 0;
        int o2 = 0;
        int e2 = 0;

        int o1 = 0;
        int e1 = 0;

        for (java.util.Map.Entry<Integer, Integer> entry : oddMap.entrySet()) {
            if (entry.getValue() > o1) {
                o2 = o1;
                o1_k = entry.getKey();
                o1 = entry.getValue();
            } else if (entry.getValue() > o2){
                o2 = entry.getValue();
            }
        }

        for (java.util.Map.Entry<Integer, Integer> entry : evenMap.entrySet()) {
            if (entry.getValue() > e1) {
                e2 = e1;
                e1_k = entry.getKey();
                e1 = entry.getValue();
            } else if (entry.getValue() > e2){
                e2 = entry.getValue();
            }
        }

        if (o1_k == e1_k) {
            System.out.println(Math.min(n - o2 - e1, n - o1 - e2));
        } else {
            System.out.println(n - o1 - e1);
        }


    }
}

Measured memory_bytes: 61548
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;
using pe = pair<int, int>;

template<typename T>
class FasterFactorize{
private:
    // smallest prime factor
    vector<T> spf;
    int N;
public:
    FasterFactorize(){
    }

    void init(T N){
        this->N = N;
        spf.resize(N+1);
        iota(spf.begin(), spf.end(), 0);
        for (T i = 2; i*i <= N; i++)
        {
            if(spf[i] == i){
                for (T j = i*i; j <= N; j+=i)
                {
                    if(spf[j] == j)   {
                        spf[j] = i;
                    }
                }                
            }
        }
    }

    void check(){
        for (int i = 0; i < N+1; i++)
        {
            cout << "spf[" << i << "] = " << spf[i] << endl;
        }
        
    }

    map<T, int> factorize(T num){
        map<T, int> result;
        if(num > N){
            // Out of range
            return result;
        }

        while (num != 1)
        {
            result[spf[num]]++;
            num /= spf[num];
        }
        return result;
    }

};

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);

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

    FasterFactorize<int> ff;
    ff.init(1e6);

    map<int, int> prime_count;

    for (int i = 0; i < N; i++)
    {
        map<int, int> prims = ff.factorize(A[i]);// = prime_factorize(A[i]);

        for (auto const & elem : prims)
        {
            prime_count[elem.first]++;
        }
    }

    bool isPairwise = true;
    bool isSetwise = true;
    for (auto const& elem : prime_count)
    {
        if(elem.second !=1){
            isPairwise = false;
        }
        if(elem.second == N){
            isSetwise = false;
        }
    }

    if(isPairwise && isSetwise){
        cout << "pairwise coprime" << endl;
    } else if(isSetwise){
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

    return 0;
}


Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int ss = 0;
    int ans = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'S') ss++;
        else {
            if(ss == 0) ans++;
            else ss--;
        }
    }
    cout << ans+ss << endl;
}

Measured memory_bytes: 3728
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Problem:A F 
Algorithm:NC
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

const int INF=1e9+7;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}
	else if(a*b==15){
		cout<<"*"<<endl;
	}
	else{
		cout<<"x"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256