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

using namespace std;

vector<pair<char, int> > CountOfChar;

int main() {
	int n, size, sum, start, pos;
	string str;

	while (cin >> n, n) {
		cin >> str;
		for (int i = 0; i < n; ++i) {
			CountOfChar.clear();
			size = str.size();
			start = 0;
			while (start < size) {
				sum = 1;
				for (pos = start + 1; pos < size; ++pos) {
					if (str[pos] != str[pos-1]) {
						break;
					}
					++sum;
				}
				CountOfChar.push_back({ str[start],sum });
				start = pos;
			}
			stringstream ss;
			str = "";
			size = CountOfChar.size();
			for (int k = 0; k < size; ++k) {
				ss << CountOfChar[k].second << CountOfChar[k].first;
			}
			str = ss.str();
		}
		cout << str << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>v;
  int n;cin>>n;
  for(int i=0;i<n;i++){
    int temp; cin>>temp;
    v.push_back(temp);
  }
  sort(v.begin(),v.end());
  int maxi=-1;
  int ans=0;
  for(int i=0;i<n;i++){
    if(maxi<v[i]){
      maxi=v[i];
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
static const ll LINF = 9123456789123456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
ll n, k, x[50], y[50], xs[50], ys[50];

bool solve(ll x1, ll y1, ll x2, ll y2) {
	ll cnt = 0;
	REP(i, n) if (x[i] >= x1 && x[i] <= x2 && y[i] >= y1 && y[i] <= y2) ++cnt;
	return cnt >= k;
}

int main(int argc, char **argv) {
	cin >> n >> k;
	REP(i, n) cin >> x[i] >> y[i];
	REP(i, n) {
		xs[i] = x[i];
		ys[i] = y[i];
	}
	sort(xs, xs + n);
	sort(ys, ys + n);
	ll res = LINF;
	REP(i1, n) FOR(i2, i1, n) {
		ll x1 = xs[i1], x2 = xs[i2];
		ll j1 = 0, j2 = 0;
		while (j2 < n) {
			ll y1 = ys[j1], y2 = ys[j2];
			if (solve(x1, y1, x2, y2)) {
				res = min(res, (x2 - x1) * (y2 - y1));
				++j1;
			}
			else {
				++j2;
			}
		}
	}
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
// C以降はintじゃなくてllを使え
// これかな？は確証なくても5分で考えられなさそうなら出せ
// 極端なテストケースも試せ
int main(){
    ll N,D;
    cin >> N >> D;
    vector<ll> X(N),Y(N);
    ll ans=0;
    for(ll i=0; i<N; i++){
        cin >> X.at(i) >> Y.at(i);
        ll d=X.at(i)*X.at(i)+Y.at(i)*Y.at(i);
        if(d<=D*D) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define pll  pair<ll,ll>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

void solve()
{/*
	ll x,y;
	cin>>x>>y;
	ll a,b;
	ll arr[7]={1,3,5,7,8,10,12};
	ll ar2[4]={4,6,9,11};
	if(x==2 && y==2)
	{
		cout<<"Yes";
		return;
	}
	// cout<<arr[6];
	for(ll i=0;i<7;i++)
	{
		if(x==arr[i])
			a=1;
		if(y==arr[i])
			b=1;
	}
	// cout<<ar2[3]<<ar2[0];
	for(ll i=0;i<4;i++)
	{
		if(x==ar2[i])
			a=2;
		if(y==ar2[i])
			b=2;
	}
	if(a==b)
		cout<<"Yes";
	else
		cout<<"No";*/
		
	ll h,w;
	cin>>h>>w;
	vector<string>s(h);
	for(ll i=0;i<h;i++)
		cin>>s[i];
	for(ll i=0;i<=w+1;i++)
		cout<<"#";
	cout<<endl;
	for(ll i=0;i<h;i++)
	{
		cout<<"#";
		cout<<s[i];
		cout<<"#"<<endl;;
	}
	for(ll i=0;i<=w+1;i++)
		cout<<"#";
		
	
    return;
}            
int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main()
{
  int L, N;
  cin >> N >> L;

  priority_queue<string, vector<string>, greater<string>> pq;

  for (int i = 0; i < N; i++)
  {
    string tmp;
    cin >> tmp;
    pq.push(tmp);
  }

  for (int i = 0; i < N; i++)
  {
    cout << pq.top();
    pq.pop();
  }
  cout << endl;
}

Measured memory_bytes: 3500
#include<stdio.h>

int main(void){
	
	int a, b, c, s;
	scanf("%d %d %d", &a, &b, &c);

	if(a > b){
		s = a;
		a = b;
		b = s;
	}
	if(b > c){
		s = b;
		b = c;
		c = s;	
	}
        if(a > b){
		s = a;
		a = b;
		b = s;
	}

	printf("%d %d %d\n", a, b, c);


	return 0;

}

Measured memory_bytes: 1812
A, B, C = map(int, input().split())

if A%2==1 or B%2==1 or C%2==1:
  print(0)
elif A==B and B==C:
  print(-1)
else:
  count = 0
  while True:
    if A%2==1 or B%2==1 or C%2==1:
      break
    count+=1
    A_tmp = B/2 + C/2
    B_tmp = A/2 + C/2
    C = A/2 + B/2
    A = A_tmp
    B = B_tmp
  print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    vector<int> niz(n);
    for (int i = 0; i < n; i++)
        cin >> niz[i];

    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (niz[i] > niz[i - 1] && niz[i] < niz[i + 1] || niz[i] < niz[i - 1] && niz[i] > niz[i + 1])
            cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

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

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

	int ans = 0;
	for (auto x: a) {
		while (x % 2 == 0) {
			x /= 2;
			ans++;
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

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

	if (s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}

Measured memory_bytes: 3624
using System;

class Program
{
	static void Main(string[] args)
	{
		int i, j;

		string[] strInput = Console.ReadLine().Split(' ');
		int n = int.Parse(strInput[0]);
		Int64 k = Int64.Parse(strInput[1]);

		int[] a = new int[n];
		int[] loopChk = new int[n];

		strInput = Console.ReadLine().Split(' ');
		
		for (i = 0; i < n; i++)
		{
			a[i] = int.Parse(strInput[i]);
		}

		//何回でループに入るか調べる。
		int now = 0;
		int offset = 0;

		while (true)
		{
			if (loopChk[now] == 0)
			{
				loopChk[now] = 1;
			}
			else
			{
				loopChk[now] = 2;   //ループの始点
				now = a[now] - 1;
				break;
			}
			now = a[now] - 1;
			offset++;
		}

		int period = 1;

		while (true)
		{
			if (loopChk[now] == 2)
			{
				break;
			}
			now = a[now] - 1;
			period++;
		}

		offset -= period;

		if(k > offset)
		{
			k = ((k - offset) % period) + offset;
		}

		now = 0;
		for(i = 0; i < k; i++)
		{
			now = a[now] - 1;
		}

		Console.WriteLine(now + 1);
		return;
	}
}

Measured memory_bytes: 43088
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string A;
        cin >> A;
        if (A == "E869120"){
            count++;
        }
    }
    cout << count << endl;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    string str;
    unordered_set<string> s;
    for(int i = 0; i < n; i++) {
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
}

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

int main(void) {
    int i, n, x;
    cin >> n;
    int d[n];
    for(i=0; i<n; i++)
        cin >> d[i];
    sort(d, d+n);
    x=d[n/2]-d[n/2-1];
    cout << x << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=1005;
char s[N][N];
int n,m,sx,sy,ex,ey;
bool vis[N][N];
int dis[N][N];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
struct node
{
    int x,y,v;
    node(int x=0,int y=0,int v=0):x(x),y(y),v(v){}
    bool operator<(const node&o)const
    {
        return v>o.v;
    }
};
priority_queue<node>q;
int main()
{
    scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&ex,&ey);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    memset(dis,inf,sizeof(dis));
    q.push(node(sx,sy,dis[sx][sy]));
    dis[sx][sy]=0;
    while(!q.empty())
    {
        int x=q.top().x,y=q.top().y;q.pop();
        if(vis[x][y]) continue;
        vis[x][y]=true;
        for(int i=0;i<4;i++)
        {
            int xx=dx[i]+x;
            int yy=dy[i]+y;
            if(xx<1||xx>n||yy<1||yy>m||s[xx][yy]=='#') continue;
            if(dis[xx][yy]>dis[x][y])
            {
                dis[xx][yy]=dis[x][y];
                q.push(node(xx,yy,dis[xx][yy]));
            }
        }
        for(int dx=-2;dx<=2;dx++)
            for(int dy=-2;dy<=2;dy++)
        {
            int xx=dx+x;
            int yy=dy+y;
            if(xx<1||xx>n||yy<1||yy>m||s[xx][yy]=='#') continue;
            if(dis[xx][yy]>dis[x][y]+1)
            {
                dis[xx][yy]=dis[x][y]+1;
                q.push(node(xx,yy,dis[xx][yy]));
            }
        }
    }
    if(dis[ex][ey]==inf) dis[ex][ey]=-1;
    printf("%d\n",dis[ex][ey]);
}


Measured memory_bytes: 9660
#include <bits/stdc++.h>
using namespace std;
int a[110];
int main(){
	int n, sum = 0;
	cin >> n;
	for(int i=1; i<n; i++){
		cin >> a[i];
	}
	sum += a[1]+a[n-1];
	for(int i=1; i<n-1; i++){
		sum += min(a[i], a[i+1]);
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S;
    cin>>S;
    bool ok=false;
    rep(i, S.size()-1){
        if(S[i]=='A' && S[i+1]=='C')  ok=true;
    }
    cout<<(ok ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, ans = INF; cin >> N;
    vector<int> W;
    rep (i, 0, N) {
        int w; cin >> w;
        W.push_back(w);
    }
    rep (i, 1, W.size()) {
        int a = accumulate(W.begin(), W.begin()+i, 0);
        int b = accumulate(W.begin()+i, W.end(), 0);
        ans = min(ans, abs(a-b));
    }
    cout << ans << endl;
}

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

int main(){
  long long int a,b,x;
  scanf("%lld %lld %lld",&a,&b,&x);
     if ((a%x == 0 && b%x == 0) || (a%x == 0))
      printf("%lld\n", b/x - a/x + 1);
  	else printf("%lld\n", b/x - a/x);
  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s[3];
    rep(i, 3) { cin >> s[i]; }
    if (s[0][s[0].size() - 1] == s[1][0] && s[1][s[1].size() - 1] == s[2][0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

int main() {
  int N, X, T;
  int count=0;
  cin >> N >> X >> T;
  
  while (N>X){
    N -= X;
    count++;
  }
  
  cout << (count+1)*T << endl;
  return 0;
}

Measured memory_bytes: 3620
S = input()
f = ""
b = ""

rev = False

for i in range(int(input())):
  t = input().split()
  if t[0] == "1":
    rev ^= True
    tmp = f
    f = b
    b = tmp
  elif t[1] == "1":
    f += t[2]
  else:
    b += t[2]

if rev: S = S[::-1]

f = f[::-1]
print(f + S + b)


Measured memory_bytes: 4460
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    AIN(ll, A, M);
    ll ans = N;
    FOR(a, A)
    {
        ans -= a;
    }
    OUT(max(ans, -1LL));
}

Measured memory_bytes: 3676
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
			/  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

	string s;
	cin>>s;
	ll ans=0;
	int na=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]=='A'){
			na++;
		} else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=na;
			i++;
		} else {
			na=0;
		}
	}
	fin(ans);
	
}


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

using ll=long long;

ll n,a,b;

int main()
{
    ios::sync_with_stdio(false);
	
	cin>>n>>a>>b;
	
	if (n==1 && a==b) return 0*puts("1");
	else if (n==1 && a!=b) return 0*puts("0");
	else if (n==2 && a<=b) return 0*puts("1");
	else if (a>b) return 0*puts("0");
	else cout<<max(0ll,(b*(n-2) - a*(n-2))+1ll);
	return 0;
	
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int n = int.Parse(ReadLine());
         string s = ReadLine();

         List<int> R = new List<int>();
         List<int> G = new List<int>();
         List<int> B = new List<int>();

         for(int i = 0; i < n; i++){
             if(s[i] == 'R') R.Add(i);
             else if(s[i] == 'G') G.Add(i);
             else B.Add(i);
         }

         long ans = (long)R.Count * (long)G.Count * (long)B.Count;

         for(int i = 0; i < n; i++){
             for(int j = i + 1; j < n; j++){
                 var k = j + (j - i);
                 if(k >= n) continue;
                 if(s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
             }
         }

         WriteLine(ans);
      }
   }
}

Measured memory_bytes: 27768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> s(n);
    rep(i,n) cin>>s[i];
    int q;
    cin>>q;
    vector<ll> t(q);
    rep(i,q) cin>>t[i];

    ll ans=0;
    rep(i,q){
        if(upper_bound(all(s),t[i])-lower_bound(all(s),t[i])>0) ans++;
    }

    cout<<ans<<endl;
}
    





Measured memory_bytes: 3896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(0,a-2*b)<<"\n";
	
	return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int f(int n) {
    int ret = 0;
    while (n > 0) {
        n %= __builtin_popcount(n);
        ret++;
    }
    return ret;
}

int add(int a, int b, int mod) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b, int mod) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mul(int a, int b, int mod) {
    return (long long) a * b % mod;
}

int power[200005][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    for (int i=0; i<n; i++)
        cnt += (s[i] == '1');

    power[0][0] = power[0][1] = 1;
    for (int i=1; i<n; i++) {
        if (cnt - 1 > 0) power[i][0] = power[i-1][0] * 2 % (cnt - 1);
        power[i][1] = power[i-1][1] * 2 % (cnt + 1);
    }

    int tot0 = 0, tot1 = 0;
    for (int i=0; i<n; i++) {
        if (cnt - 1 > 0) tot0 = (2 * tot0 + (s[i] == '1')) % (cnt - 1);
        tot1 = (2 * tot1 + (s[i] == '1')) % (cnt + 1);
    }

    for (int i=0; i<n; i++) {
        if (s[i] == '0')
            cout << f(add(tot1, power[n-i-1][1], cnt + 1)) + 1 << "\n";
        else
            cout << (cnt == 1 ? 0 : f(sub(tot0, power[n-i-1][0], cnt - 1)) + 1) << "\n";
    }

    return 0;
}


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

int main() {
    int K,X; cin >> K >> X;
    for(int i = max(-1000000,X-K+1); i <= min(X+K-1,1000000); ++i){
        cout << i << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
bool f [100001];
int c [100002];
int N ,L , R ;
int main ()
{
  for ( int i =2; i <=100000; i ++)
    if (! f [ i ])
      for ( int j = i + i ;j <=100000; j += i )
        f[ j ]= true ;
  for ( int i =3; i <=100000; i +=2)
    if (! f [ i ]&&! f [( i +1)/2]) c [ i ]++;
  for ( int i =3; i <=100000; i ++) c [ i ]+= c [i -1];
  scanf ("%d" ,&N );
  while (N--)
    {
      scanf ("%d%d " ,&L ,& R );
      printf ("%d\n" , c [ R ] - c [L -1]);
 }
  return 0;
}

Measured memory_bytes: 1024
<?php

class IO {

	//input
	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}

	//output
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$io = new IO();


$N = $io->nextInt();
$A = $io->nextInt();

$io->println($N * $N - $A);

?>


Measured memory_bytes: 4728
#include <algorithm>
#include <iostream>
using namespace std;
int N, S;
int main() {
	while (cin >> N && N>0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1001;
		for (int i=0; i<N; ++i) {
			cin >> S;
			largest = max(largest,S);
			smallest = min (smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import os
import sys
from atexit import register
from io import BytesIO

import heapq

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

x,y,z,k = (int(x) for x in input().split())
a = sorted((int(i) for i in input().split()), reverse=True)
b = sorted((int(i) for i in input().split()), reverse=True)
c = sorted((int(i) for i in input().split()), reverse=True)


h = []
heapq.heappush(h, (-a[0]-b[0]-c[0],(0,0,0)))
visited = dict()
cnt = 0
while True:
    cost, node = heapq.heappop(h)
    if visited.get(node, False):
        continue
    visited[node] = True
    cnt += 1
    print(-cost)
    if cnt == k:
        break
    if node[0] + 1 != x:
        heapq.heappush(h,(cost+a[node[0]] - a[node[0] + 1], (node[0]+1, node[1], node[2])))
    if node[1] + 1 != y:
        heapq.heappush(h,(cost+b[node[1]] - b[node[1] + 1], (node[0], node[1]+1, node[2])))
    if node[2] + 1 != z:
        heapq.heappush(h,(cost+c[node[2]] - c[node[2] + 1], (node[0], node[1], node[2]+1)))


Measured memory_bytes: 104500
# coding: utf-8
# Your code here!
import math

n=int(input())

S=[]

NowT=0
Dist=0
Sx=0
Sy=0

for i in range(n):
    S.append(list(map(int,input().split())))

for i in range(n):
    NowT=S[i][0]-NowT
    Dist=abs(S[i][1]-Sx)+abs(S[i][2]-Sy)
    if NowT>=Dist and NowT%2 ==Dist%2:
        pass
    else:
        
        print("No")
        exit()
    NowT=S[i][0]
    Sx=S[i][1]
    Sy=S[i][2]
    
print("Yes")



Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=4e5+5;
vi pos[N];
int n , m ;
struct segTree{
	int mx[N<<2],b[N<<2],add[N<<2];
	void Build(int l ,int r,int rt){
		add[rt] = 0;
		if(l == r){ mx[rt] = r - m - 1;return;}
		int m = ( l + r)/2;
		Build(l,m,rt<<1);
		Build(m + 1, r,rt<<1|1);
		mx[rt] = max(mx[rt<<1],mx[rt<<1|1]);
		
	}
	void upd(int L,int R,int c,int l,int r,int rt){
		if( L <= l && r <= R){
			add[rt] += c;
			return ;
		}
		int m = ( l + r)/2;	
		if(L <= m)upd(L,R,c,l,m,rt<<1);
		if(R  > m)upd(L,R,c,m + 1,r,rt<<1|1);
		mx[rt] = max(mx[rt<<1] + add[rt<<1],mx[rt<<1|1] + add[rt<<1|1]);
	//	dd(l),dd(r),de(mx[rt]+add[rt]);
	}
	int qry(int L,int R,int l ,int r,int rt){
		if(L > R)return 0;
		if(L <= l && r <= R){
			return mx[rt] + add[rt];
		}
		int m = ( l + r)/2;
		int ans = -1e8;
		if(L <= m )ans = max(ans,qry(L,R,l,m,rt<<1));
		if(R  > m )ans = max(ans,qry(L,R,m + 1,r,rt<<1|1));
	//	dd(l),dd(r),dd(ans),de(add[rt]);
		return ans + add[rt];
	}
}sg;
int main()
{
	cin>>n>>m;
	int l , r;
	rep(i , 1 , n + 1){
		cin>>l>>r;	
		pos[l].pb(r);	
	}
	sg.Build(1 , m + 1, 1);
	
	int ans = 0;
	rep(i , 0 , m + 1){
		for(auto v:pos[i]){
			sg.upd(1,v,1,1,m + 1,1);
		//	de(v);
		}
	//	dd(i),dd(sg.mx[1] + sg.add[1]),de(sg.qry(i + 1,m + 1,1,m + 1,1));
		ans = max(ans,sg.qry(1,m + 1,1,m + 1,1) - i);
	}
	ans = max(ans,n - m);
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 21760
import math
X = int(input())
a1 = math.ceil(X**(1/5))
N = int(1e10)
c = 0
b = 0
while c <= N:
    if b**5 < -X:
        b2 = b + 1
        break
    b -= 1
c = 0
while c <= N:
    c += 1
    b1 = math.floor((a1**5-X)**(1/5))
    a2 = math.floor((X+b2**5)**(1/5))
    if a1**5 - b1**5 == X:
        print(a1, b1)
        break
    elif a2**5 - b2**5 == X:
        print(a2, b2)
        break
    a1 += 1
    b2 += 1

Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll n,a,b,m,h[N];
bool check(ll mid)
{
	ll pnt=0;
	for(ll i=0;i<n;i++)
	{
		ll lc=h[i];
		lc-=mid*b;
		if(lc<=0)continue;
		pnt+=lc/m;
		if(lc%m!=0)pnt++;
	}
	return pnt<=mid;
}
int main()
{
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++)cin>>h[i];
	m=a-b;
	ll l=0,r=1e9;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	cout<<r+1<<endl;
	return 0;
} 

Measured memory_bytes: 1024
n = int(input())
lst = [[] for i in range(n+1)]
for i in range(n-1):
    ai, bi = map(int, input().split())
    lst[ai].append(bi)
    lst[bi].append(ai)

tf = [0 for i in range(n+1)]
tf[1] = 1
iro = 1
queue = lst[1]
while queue != []:
    iro = -iro
    new_queue = []
    for i in queue:
        tf[i] = iro
        for j in lst[i]:
            if tf[j] == 0:
                new_queue.append(j)
    queue = new_queue

n_minus = tf.count(-1)
n_plus = tf.count(1)
ans = [0 for i in range(n)]

if n_minus <= n//3:
    bai = 1
    for i in range(1, n+1):
        if tf[i] == -1:
            ans[i-1] = 3 * bai
            bai += 1
    kouho = 1
    for i in range(1, n+1):
        if tf[i] == 1:
            if bai <= n//3:
                ans[i-1] = 3 * bai
                bai += 1
            else:
                ans[i-1] = kouho
                kouho += 1
                if kouho % 3 == 0:
                    kouho += 1

elif n_plus <= n//3:
    bai = 1
    for i in range(1, n+1):
        if tf[i] == 1:
            ans[i-1] = 3 * bai
            bai += 1
    kouho = 1
    for i in range(1, n+1):
        if tf[i] == -1:
            if bai <= n//3:
                ans[i-1] = 3 * bai
                bai += 1
            else:
                ans[i-1] = kouho
                kouho += 1
                if kouho % 3 == 0:
                    kouho += 1

else:
    bai = 1
    kouho1 = 1
    kouho2 = 2
    for i in range(1, n+1):
        if tf[i] == 1:
            if kouho1 <= n:
                ans[i-1] = kouho1
                kouho1 += 3
            else:
                ans[i-1] = 3 * bai
                bai += 1
        else:
            if kouho2 <= n:
                ans[i-1] = kouho2
                kouho2 += 3
            else:
                ans[i-1] = 3 * bai
                bai += 1

print(' '.join(map(str, ans)))

Measured memory_bytes: 64736
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> inline int sod_L(T n){
  int res=0;
  while(n){
    res += n%10;
    n /= 10;
  }
  return res;
}
int N;
int main(){
  rd(N);
  if(N%sod_L(N)){
    wt_L("No");
    wt_L('\n');
  }
  else{
    wt_L("Yes");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N;
// {
//   rd(N);
//   wt( if[N%sod(N),"No","Yes"] );
// }


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

unsigned _gcd(unsigned a, unsigned b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (!b)
            break;
        a %= b;
    }
    return a;
}
int main()
{
    int k;
    int ans=0;
    cin >> k;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int l = 1; l <= k; l++){
                ans += _gcd(_gcd(i, j), l);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

#define MOD 1000000007

int a[100005]={0};

long long int repeated_squaring(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int b;
        cin >> b;
        a[b]++;
    }

    for(int i=(n % 2 == 0 ? 1 : 0);i<n;i+=2){
        if(n%2 == 1 && i == 0 && a[i] != 1 || i != 0 && a[i] != 2){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << repeated_squaring(2, n/2) << endl;

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(int(i) for i in input().split())

hai = 0
tya = 0
midori = 0
mizu = 0
ao = 0
ki = 0
daidai = 0
aka = 0

niji = 0

for i in range(n):
    if 1 <= a[i] and a[i] <=399:
        hai = 1
    elif 400 <= a[i] and a[i] <= 799:
        tya = 1
    elif 800 <= a[i] and a[i] <= 1199:
        midori = 1
    elif 1200 <= a[i] and a[i] <=1599:
        mizu = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        ao = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        ki = 1
    elif 2400 <= a[i] and a[i] <=2799:
        daidai = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        aka = 1
    elif 3200 <= a[i]:
        niji += 1

mincolor = hai + tya + midori + mizu + ao + ki + daidai + aka

if mincolor == 0:
    mincolor += 1
    niji -= 1

maxcolor = mincolor + niji

#if maxcolor >= 9:
#    maxcolor = 8

print(mincolor, maxcolor)


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

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

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;

int rec(int n, bool x3, bool x5, bool x7) {
  if (n > N * 10) return 0;
  int res = 0;
  res += rec((n + 3) * 10, true, x5, x7);
  res += rec((n + 5) * 10, x3, true, x7);
  res += rec((n + 7) * 10, x3, x5, true);

  if (n <= N * 10 && n != 0 && x3 && x5 && x7) res++;
  return res;
}

signed main() {
  cin >> N;
  cout << rec(0, false, false, false) << endl;
  return 0;
}


Measured memory_bytes: 256
def ans():
    tmp = -9999999999999
    N = int(input())
    F = [list(map(int, input().split())) for i in range(N)]
    P = [list(map(int, input().split())) for i in range(N)]

    def calculate(B):
        v = []
        for n in range(N):
            mcnt = 0
            for k in range(10):
                if B[k] == '1' and F[n][k] == 1:
                    mcnt += 1
            v.append(P[n][mcnt])
        return sum(v)

    for i in range(1, 1 << 10):
        bi = bin(i)
        bi = bi[2:]
        bi = '0' * (10 - len(bi)) + bi
        tmp = max(tmp, calculate(bi))
    return print(tmp)


ans()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  // dp[i][j] := iビット目まで見た時の
  // XがK以下だと確定している(j=1の時) or していない(j=0の時)とした時の f(X)の最大値

  vector<vector<ll>> dp(53, vector<ll>(2));
  for_each(dp.begin(), dp.end(), [](auto &vec){ vec[1] = -1; });

  for (int i = 50; i >= 0; i--) {
    ll bit_cnt = count_if(A.begin(), A.end(), [i](ll n) -> bool {return n & 1LL<<i;});

    // 未確定->未確定 KのiビットとXのiビットが一致
    cmax(dp[i][0], dp[i+1][0] + (K & 1LL<<i ? N-bit_cnt : bit_cnt) * (1LL<<i));
    // 未確定->確定 Kのiビットが1とXのiビットが0
    if (K & 1LL<<i) {
      cmax(dp[i][1], dp[i+1][0] + bit_cnt * (1LL<<i));
    }
    // 確定->確定 f(X)を最大化する
    if (dp[i+1][1] != -1) {
      cmax(dp[i][1], dp[i+1][1] + max(N-bit_cnt, bit_cnt) * (1LL<<i));
    }
  }

  cout << max(dp[0][0], dp[0][1]) << endl;
}


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

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima){
					ima = all[j].second;
				} else if(all[j].second == ima){
					ima = all[j].first;
				}
			}
			cout<<ima<<endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
int main(void)
{
  int n, a, b;
  int t = 0;
  std::cin >> n >> a >> b;
  while(true){
    if(t % 2 == 0){
      if(a == 1 && b == 2){
        std::cout << "Borys" << std::endl;
        return 0;
      }else if(b != a + 1){
        a += 1;
      }else{
        a -= 1;
      }
    }else{
      if(a == n - 1 && b == n){
        std::cout << "Alice" << std::endl;
        return 0;
      }else if(b != a + 1){
        b -= 1;
      }else{
        b += 1;
      }
    }
    t++;
  }
  std::cout << "draw" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}
template <typename T> void cout_join(vector<T> &v,string d=" "){REP(i,v.size()){if(i>0)cout<<d;cout<<v[i];}cout<<endl;}

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

  int n, t, a; cin >> n >> t >> a;
  vector<int> h(n);
  REP(i,n) cin >> h[i];

  vector<double> x(n);
  REP(i,n){
    x[i] = fabs((1.0*t-h[i]*0.006) - a);
  }

  cout << min_element(ALL(x)) - x.begin() + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i]-1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if(a == b)
		printf("a == b\n");
	else

	if(a < b)
		printf("a < b\n");
	else

	if(a > b)
		printf("a > b\n");

	return 0;

}

Measured memory_bytes: 580
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   N = int(stdin.readline())
   A = map(int, stdin.readline().split())

   for x in A:
      if (x % 2) == 0:
         if (x % 3) != 0 and (x % 5) != 0:
            print('DENIED')
            return 0
   print('APPROVED')

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
#include<iostream>
using namespace std;
int main(){
	int n;
	long long int s=0;
	int i,j,k;
	long long int a=0,b=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		if(a==0){
			b=0;
			continue;
		}
		a+=b;
		s+=a/2;
		b=a%2;
	}
	cout<<s<<endl;
	return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int A, B, C, K; cin >> A >> B >> C >> K;
  cout << (K>A+B ? A - (K-A-B) : min(K,A)) << endl;
}


Measured memory_bytes: 3656
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B, C = map(int, rl().split())
    K = int(rl())
    
    while K:
        if A < B:
            break
        B *= 2
        K -= 1
    while K:
        if B < C:
            break
        C *= 2
        K -= 1
    
    print('Yes' if A < B < C else 'No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		String a = sc.nextLine();
		String[] b = new String[a.length()];
		for(int i = 0;i < a.length(); i++) {
			String kigou = String.valueOf(a.charAt(i));
			if("+".equals(kigou)) {
				sum += 1;
			} else if("-".equals(kigou)) {
				sum -= 1;
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 22868
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int dp[2][2020]; 
int main(){
	string str;
	ll ans=0;
	cin>>str;
	for(int i=0;i<str.length();i++)
	{
		for(int j=0;j<2019;j++)
		{
			dp[(i+1)%2][j]=0;
		}
		int k=str[i]-'0';
		dp[(i+1)%2][k]=1;
		for(int j=0;j<2019;j++)
		{
		dp[(i+1)%2][(j*10+k)%2019]+=dp[i%2][j];	
		}
		ans+=dp[i%2][0];
	}
	ans+=dp[str.length()%2][0];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3732
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

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

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n) {
	return 0;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	const ll MIN = -2000000;
	const ll MAX = 2000000;
	ll k, x;
	cin >> k >> x;
	ll start = max(MIN, x - k + 1);
	ll goal = min(MAX, x + k);
	rep(i, start, goal)cout << i << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256