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

using ll = long long ;
int n;
ll a[300010]; 
ll f[300010];
ll ans;
ll ret;
priority_queue<ll> q;

int main()
{
    ios::sync_with_stdio(false);

	cin>>n;
	for (int i=1;i<=3*n;i++) cin>>a[i];
	
	for (int i=1;i<=n;i++) 
	{
		q.push(-a[i]);
		ans+=a[i];
		f[i]=ans;
	}
	for (int i=n+1;i<=2*n;i++) 
	{
		if (a[i]>-q.top()) 
		{
			ans+=a[i]+q.top();
			q.pop();
			q.push(-a[i]);
		}
		f[i]=ans;
	}
	
	
	while (!q.empty()) q.pop();
	ans=0;
	for (int i=3*n;i>2*n;i--) 
	{
		q.push(a[i]);
		ans+=a[i];
	}
	ret=f[2*n]-ans;
	for (int i=2*n;i>n;i--) 
	{
		if (a[i]<q.top()) 
		{
			ans-=q.top();
			ans+=a[i];
			q.pop();
			q.push(a[i]);
		}
		ret=max(ret,f[i-1]-ans);
	}
	cout<<ret;
}

Measured memory_bytes: 5364
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  int memo = 1e5;
  int n,l;
  cin >> n >> l;
  int ans = 0;
  int val;
  for(int i = 1; i <= n; i++){
    ans += l + i - 1;
    if(memo > abs(l+i-1)){
      memo = abs(l+i-1);
      val = l+i-1;
    }
  }
  printf("%d\n", ans-val);
  return 0;
}


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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

vector<vector<ll>> g;
ll n,q;
vector<ll> score;

void dfs(ll v, ll p){
    for(ll nv:g[v]){
        if(nv==p) continue;
        score[nv]+=score[v];
        dfs(nv,v);
        
    }
}

int main(){
    cin >> n >> q;
    g.resize(n);
    score.resize(n);

    rep(i,n-1){
        ll a,b; cin >> a >> b;
        g[a-1].PB(b-1);
        g[b-1].PB(a-1);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        score[p-1]+=x;
    }
    dfs(0,-1);
    rep(i,n) cout << score[i] << ' ';
    cout << endl;

}

Measured memory_bytes: 24320
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n,m;
vector<int> vs[100005];

int gb[100005];
vector<int> gvs[100005];

int dn=0;
int gn=0;
int dang[100005]={};
int gone[100005]={};

int uni[100005];

int find(int p){
	if(p==uni[p])return p;
	else return (uni[p]=find(uni[p]));
}

int mer(int p,int q){
	p = find(p); q=find(q);
	uni[p]=q;
}

bool same(int p,int q){
	p = find(p); q=find(q);
	return p==q;
}




void dfs(int no,int be){
	gone[no]=1;
	rep(i,vs[no].size()){
		int to=vs[no][i];
		if(to==be)continue;
		if(gone[to]){
			dang[to]++;
			dn++;
			continue;
		}
		int mdn = dn;
		dfs(to,no);
		if(mdn!=dn){
			//printf("%d %d :: %d %d\n",to,no,mdn,dn);
			mer(to,no);
		}
		dn -= dang[no];
		dang[no]=0;
	}
}

int w[100005];
int gw[100005]={};


//lli ans=-1;

lli sol(int no){
	gone[no]=1;
	lli ma=0;
	rep(i,gvs[no].size()){
		int to=gvs[no][i];
		if(gone[to])continue;
		lli nm=sol(to);
		ma = max(ma,nm);
	}
	//ans=max(ans,ma+mb+gw[no]);
	//printf("%d %lld\n",no,ma);
	return ma+gw[no];
}

int main(void){
	scanf("%d%d",&n,&m);
	rep(i,n)uni[i]=i;
	rep(i,n)scanf("%d",&w[i]);
	rep(i,m){
		int a,b; 
		scanf("%d%d",&a,&b); a--; b--;
		vs[a].push_back(b);
		vs[b].push_back(a);
	}
	
	dfs(0,0);
	
	rep(no,n){
		int ng = find(no);
		rep(i,vs[no].size()){
			int tg=find(vs[no][i]);
			if(ng!=tg){
				//printf("%d %d\n",no,vs[no][i]);
				gvs[ng].push_back(tg);
			}
		}
		gw[ng] += w[no];
	}
	
	memst(gone,0);
	
	
	printf("%lld\n",sol(find(0)));
	return 0;
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  for(int i = 1; i <= n; i++){
    int sum = 0, temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2*1e5+10;
int w[N],d[N],cnt[20],res,n,st,sxr[N];
bool book[N];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n-1){ri u=read()+1,v=read()+1,va=read();w[u]^=va;w[v]^=va;}rp(i,1,n)cnt[w[i]]++;
	for(int i=1;i<=15;i++)res+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);  
	for(int i=1;i<(1<<15);i++)d[i]=d[i>>1]+(i&1);
	for(int i=1;i<(1<<15);i++)d[i]-=1;
	for(int i=1;i<(1<<15);i++)
		for(int j=0;j<15;j++)if((i>>j)&1)sxr[i]^=(j+1);
	for(int i=1;i<(1<<15);i++)
	{
		if(sxr[i]!=0)continue;
		for(int k=(i-1)&i;k;k=(k-1)&i)
			if(sxr[k]==0)d[i]=min(d[i],d[k]+d[i^k]);
	}printf("%d",res+d[st]);return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    rp(i, 0, n) cin >> a[i];
    ll so[3];
    za(3, so);
    rp(i, 0, n)
    {
        if (a[i] % 4 == 0)
        {
            so[2]++;
        }
        else
        {
            if (a[i] % 2 == 0)
            {
                so[1]++;
            }
            else
            {
                so[0]++;
            }
        }
    }
    //ca(3, so);
    if (so[1] == 0)
    {
        if (so[0] - 1 <= so[2])
        {
            ce("Yes");
        }
        else
        {
            ce("No");
        }
    }
    else
    {
        if (so[0] <= so[2])
        {
            ce("Yes");
        }
        else
        {
            ce("No");
        }
    }
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = (1<<11) + 10;

int n, m, tot;
int obj[130];
int f[N][N];

int solve(int ask, int ans)
{
	if(f[ask][ans] != -1) return f[ask][ans];
	int cnt = 0;
	for(int i = 1; i <= n; i++)
		cnt += (ask & obj[i]) == ans;
	if(cnt <= 1) return f[ask][ans] = 0;
	int &tmp = f[ask][ans]; tmp = m;
	for(int j = 0; j < m; j++) if(!(ask & (1 << j)))
		tmp = std::min(tmp, std::max(solve(ask|(1<<j), ans)+1, solve(ask|(1<<j), ans|(1<<j))+1));
	return tmp;
}

int main()
{
	while(scanf("%d%d", &m, &n) == 2 && (n || m))
	{
		tot = (1 << m);
		for(int i = 1; i <= n; i++)
		{
			obj[i] = 0;
			for(int j = 0; j < m; j++)
			{
				int x; scanf("%1d", &x);
				if(x) obj[i] |= (1 << j);
			}
			//printf("%d\n", obj[i]);
		}
		memset(f, -1, sizeof(f));
		printf("%d\n", solve(0, 0));
	}
	return 0;
}

Measured memory_bytes: 17580
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N, M;
	cin >> N >> M;
	//int count = (N + 1) * N / 2;

	vector<lint> divisor;
	for (lint i = 1; i <= sqrt(M); i++)
	{
		if (M % i == 0)
		{
			divisor.push_back(i);
			divisor.push_back(M / i);
		}
	}

	sort(all(divisor), greater<lint>());

	for (auto out : divisor)
	{

		if (out * N <= M)
		{
			cout << out << endl;
			return;
		}
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

const int maxn(2e5 + 10);
int n, val[maxn], f[maxn], cnt[20], ans, S, sum[maxn];

int main()
{
	scanf("%d", &n);
	for (int i = 1, a, b, c; i < n; i++)
		scanf("%d%d%d", &a, &b, &c), val[a] ^= c, val[b] ^= c;
	for (int i = 0; i < n; i++) ++cnt[val[i]];
	for (int i = 1; i <= 15; i++) ans += (cnt[i] >> 1), S |= (cnt[i] & 1) << (i - 1);
	for (int i = 1; i < (1 << 15); i++) f[i] = f[i >> 1] + (i & 1);
	for (int i = 1; i < (1 << 15); i++) --f[i];
	for (int i = 1; i < (1 << 15); i++)
		for (int j = 0; j < 15; j++) if (i & (1 << j)) sum[i] ^= (j + 1);
	for (int i = 1; i < (1 << 15); i++) if (!sum[i])
		for (int j = (i - 1) & i; j; j = (j - 1) & i)
			if (!sum[j]) f[i] = std::min(f[i], f[j] + f[i ^ j]);
	printf("%d\n", ans + f[S]);
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	int n;
	scanf("%d", &n);
	n %= 10;
	if (n == 3)printf("bon");
	else if (n == 0 || n == 1 || n == 6 || n == 8)printf("pon");
	else printf("hon");
}

Measured memory_bytes: 1736
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int h,w;
    char fld[64][64];
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)scanf("%s",fld[i]);
    int dp[64][64];
    fill(*dp,*dp+64*64,1<<25);
    dp[0][1]=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dp[i+1][j+1]=min(dp[i+1][j],dp[i][j+1])+fld[i][j]-'0';
        }
    }
    printf("%d\n",dp[h][w]);
    return 0;
}

Measured memory_bytes: 1044
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007


int main() {
	int a, b;
	cin >> a >> b;

	cout << b * 2 - a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <type_traits>
#include <algorithm>

using namespace std;
typedef long long int ll;


int main(){
    ll cnt=0;
		int n;
		cin>>n;
    vector<int> l(n);
    for(int i=0;i<n;++i){
      cin>>l[i];
    }
    sort(l.begin(), l.end() ,greater<int>());

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){
          if(l[i]<l[j]+l[k]){
            cnt++;
          }
        }
      }
    }


      cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
//#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int MAXN = 1e6;
int mark[MAXN];
int crivo(int x){
	for(int i=0;i<MAXN;i++)mark[i] = 1;
	for(int i=2;i<MAXN;i++){
		if(mark[i]){
			for(int j=2*i;j<MAXN;j+=i){
				mark[j] = 0;
			}
		}
	}
	
	
	for(int i=x;i<MAXN;i++){
		if(mark[i])return i;
	}
	return 0;
}


int32_t main(){
		int x;
		cin>>x;
		cout<<crivo(x)<<endl;
}

Measured memory_bytes: 8064
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
const int N=2e5+10;
char s[N],t[N];
int main()
{
    cin>>s+1>>t+1;
    int len=strlen(s+1);
    int ans=0;
    rep(i,1,len) if(s[i]!=t[i]) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3972
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<map>
#include<set>
using namespace std;
 
typedef long long ll;
 
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=10*x+ch-'0';ch=getchar();}
	return x*f;
}
void print(int x)
{if(x<0)putchar('-'),x=-x;if(x>=10)print(x/10);putchar(x%10+'0');}
 
const int N=300100;
 
int w,h,n;
 
struct point
{
	int x,y;
	
	friend bool operator<(const point &a,const point &b)
	{return a.x<b.x;}
	
}p[N];
 
struct segment_tree{int w,tag;}tr[N<<2];
 
inline void pushup(int k)
{tr[k].w=max(tr[k<<1].w,tr[k<<1|1].w);}
 
inline void pushdown(int k)
{
	if(tr[k].tag)
	{
		int tmp(tr[k].tag);
		tr[k<<1].w+=tmp,tr[k<<1].tag+=tmp,
		tr[k<<1|1].w+=tmp,tr[k<<1|1].tag+=tmp,
		tr[k].tag=0;
	}
}
 
inline void modify(int k,int l,int r,int x,int y,int val)
{
	if(l>=x && r<=y)
	{tr[k].w+=val,tr[k].tag+=val;return ;}
	int mid=(l+r)>>1;pushdown(k);
	if(x<=mid) modify(k<<1,l,mid,x,y,val);
	if(y>mid) modify(k<<1|1,mid+1,r,x,y,val);
	pushup(k);
}
 
//int query(int k,int l,int r,int x)
//{
//	if(l==r) return tr[k].w;
//	int mid=(l+r)>>1;pushdown(k);
//	return x<=mid ? query(k<<1,l,mid,x) : query(k<<1|1,mid+1,r,x);
//}
 
int Y[N];
 
int st[2][N],top[2];
 
int ans(0);
 
void solve()
{
	register int i;
	sort(p+2,p+1+n);
	
	top[0]=top[1]=0,
	st[0][0]=st[1][0]=1;
	modify(1,1,n,1,n,h<<1);
	for(i=2;i<=n;++i)
	{
		modify(1,1,n,1,i-1,(p[i].x-p[i-1].x)<<1);
		ans=max(ans,tr[1].w);
		if(p[i].y>=(h>>1))
		{
			modify(1,1,n,st[0][top[0]],i-1,(p[i].y-h)<<1);
			while(top[0] && p[st[0][top[0]]].y>=p[i].y)
				modify(1,1,n,st[0][top[0]-1],st[0][top[0]]-1,(p[i].y-p[st[0][top[0]]].y)<<1),
				top[0]--;
			st[0][++top[0]]=i;
		}
		else
		{
			modify(1,1,n,st[1][top[1]],i-1,-p[i].y<<1);
			while(top[1] && p[st[1][top[1]]].y<=p[i].y)
				modify(1,1,n,st[1][top[1]-1],st[1][top[1]]-1,(p[st[1][top[1]]].y-p[i].y)<<1),
				top[1]--;
			st[1][++top[1]]=i;
		}
	}
	memset(tr,0,sizeof(tr));
}
 
int main()
{
	w=read(),h=read(),n=read()+1;
	register int i;
	for(i=2;i<=n;++i)
		p[i].x=read(),p[i].y=read();
	p[++n]=(point){w,h};
	
	solve();
	swap(w,h);
	for(i=1;i<=n;++i)
		swap(p[i].x,p[i].y);
	solve();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;;
    cin>>s;
    map<string,int> ans;
    ans["SAT"]=1;
    ans["FRI"]=2;
    ans["THU"]=3;
    ans["WED"]=4;
    ans["TUE"]=5;
    ans["MON"]=6;
    ans["SUN"]=7;

    puta(ans[s]);
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int x, y, k, s;
    cin >> k >> s;
    int ans = 0;
    REP (x,0,k) REP (y,0,k) {
        int z = s - x - y;
        if (z >= 0 && z <= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int n,b[3]={0},p=0,o=0;
	char s[8];
	scanf("%d",&n);
	while(scanf("%s",s)!=EOF)
	{
		if(!strcmp(s,"HIT"))
		{
			if(b[2])p++,b[2]=0;
			if(b[1])b[2]=1,b[1]=0;
			if(b[0])b[1]=1,b[0]=0;
			b[0]=1;
		}
		if(!strcmp(s,"HOMERUN"))
			p+=b[2]+b[1]+b[0]+1,b[0]=b[1]=b[2]=0;
		if(!strcmp(s,"OUT"))
			o++;
		if(o==3)printf("%d\n",p),o=0,p=0,b[0]=b[1]=b[2]=0;
	}
	return 0;
}

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

using namespace std;

int main()
{
    vector<vector<int>> c(3, vector<int>(3));
    vector<int> a(3), b(3);
    a[0] = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    a[0] = 0;
    b[0] = c[0][0] - a[0];
    a[1] = c[1][0] - b[0];
    b[1] = c[0][1] - a[0];
    a[2] = c[2][0] - b[0];
    b[2] = c[0][2];

    bool flag = true;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (c[i][j] != a[i] + b[j]) {
                flag = false;
                break;
            }
        }
        if (flag == false) break;
    }

    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a;
	int b;
	
	scanf("%d", &a);
	scanf("%d", &b);
	
	if(a<b){
	printf("a < b\n");
	}
	else if(a>b){
	printf("a > b\n");
	}
	else{
	printf("a == b\n");
	}
	

	return 0;
}

Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;
typedef vector<pair<ll,ll> > vpl;
typedef vector<pair<int,int> > vpi;
typedef vector<ll> vll;
typedef vector<int>vin;
typedef map<ll,ll> mp;
ll GCD(ll a,ll b)
{
    if(a == 0)
    {
        return b;
    }
    return GCD(b%a,a);
}
int main()
{
    FastIO;
    int q = 1;
//    cin >> q;
    while(q--)
    {
        ll a,b,c,d,res = -1*pow(10,18)-1;
        cin >> a >> b >> c >> d;
        res = max(a*c,res);
        res = max(b*d,res);
        res = max(a*d,res);
        res = max(b*c,res);
        cout << res << endl;
    }
}




Measured memory_bytes: 3588
import sys
readline = sys.stdin.readline

H,W = map(int,readline().split())

if H == 1 or W == 1:
  print(1)
  exit(0)
  
if (H * W) % 2 == 1:
  print((H * W) // 2 + 1)
else:
  print((H * W) // 2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> W;
    vi w(N), v(N);
    REP(i, N) {
        cin >> w[i] >> v[i];
        if (i == 0)
            X = w[0];
        w[i] -= X;
    }
    vvvi dp(110, vvi(1010, vi(110, -1)));

    REP(i, N + 1) {
        REP(j, 1000) {
            REP(k, N + 1)
            dp[i][j][k] = -1;
        }
    }
    dp[0][0][0] = 0;
    REP(i, N + 1) {
        REP(j, 900) {
            REP(k, N + 1) {
                if (dp[i][j][k] != -1) {
                    dp[i + 1][j + w[i]][k + 1] = max(dp[i + 1][j + w[i]][k + 1], dp[i][j][k] + v[i]);
                    dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                }
            }
        }
    }
    dump(dp[N][0], X, W);
    REP(j, 1000) {
        REP(k, N + 1) {
            if ((ll)j + X * (ll)k <= W) {
                ans = max(ans, (ll)dp[N][j][k]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 54964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
/*
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}
*/
int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		ll n; cin>>n;
		string s; cin>>s;
		ll w[n+10],r[n+10]; 
		memset(w,0,sizeof(w));
		memset(r,0,sizeof(r));
		ll tw=0,tr=0;
		for(int i=1; i<=n; i++) {
			if(s[i-1]=='R') { r[i] = r[i-1] + 1; tr++; }
			else r[i] = r[i-1];
			
			if(s[i-1]=='W') { w[i] = w[i-1] + 1; tw++; }
			else w[i] = w[i-1];
		}

		ll ans = min(tr,tw);
		for(int i=1; i<=n; i++) {
			ll temp = 0;
			if(w[i] > tr - r[i]) {
				temp = tr - r[i];
				temp += w[i] - (tr - r[i]);
			}
			else {
				temp = w[i];
				temp += (tr - r[i] - w[i]);
			}
			
			ans = min(ans,temp);
		}
		cout<<ans;
	}
	return 0;
}



Measured memory_bytes: 6840
def main():
    N, K = map(int, input().split())
    D = list(input().split())
    
    for i in range(N,100000):
        a = str(i)
        flag = True
        for d in D:
            if d in a:
                flag = False
                break
        if flag:
            print(i)
            exit()



if __name__ == "__main__":
    main()

Measured memory_bytes: 73236
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    sum += 1.0 / x;
  }
  printf("%.15f\n", 1.0 / sum);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
          c[i][0]^=((qc+1)&1);
          c[i][1]^=((qc+1)&2);
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0]&&!c[1-i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e6+5;

int a[] = {
400,
599,
8,
600,
799,
7,
800,
999,
6,
1000,
1199,
5,
1200,
1399,
4,
1400,
1599,
3,
1600,
1799,
2,
1800,
1999,
1
};

int main() {
   int n;
   cin >> n;
   for(int i=0; ; i+=3) {
      if(a[i] <= n && n <= a[i+1]) {
         printf("%d\n", a[i+2]);
         exit(0);
      }
   }
}


Measured memory_bytes: 3740
def pow_r(x, n, P):
  if n == 0:
    return 1
  if n % 2 == 0:
    return pow_r(x ** 2 % P, n // 2, P)
  else:
    return x * pow_r(x ** 2 % P, n // 2, P) 

from fractions import gcd

N = int(input())
As = list(map(int, input().split()))
P = 10**9+7

if N == 1:
  print(1)
  exit()

lcm = As[0]*As[1]//gcd(As[0],As[1])
 
for i in range(2,N):
  c = gcd(lcm, As[i])
  lcm *= As[i]//c

rlt = 0
for a in As:
  rlt += lcm*pow_r(a, P-2, P) % P
  rlt %= P
print(rlt)

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



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

    
    ll x;
    cin >> x;

    ll a, b;
    cin >> a;
    cin.ignore();
    cin >> b;
    ll y = a * 100 + b;

    cout << (x * y) / 100 << endl;
    

    return 0;
}

Measured memory_bytes: 3644
import sys

n, k = map(int, input().split())
d = list(map(int, input().split()))

nums = [i for i in range(10)]
canuse = []

for i in nums:
    if i not in d:
        canuse.append(i)

for i in range(n,n*10):
    x = 0
    for j in str(i):
        if int(j) not in canuse:
            break
        else:
            x += 1
            if x == len(str(i)):
                print(i)
                sys.exit()



Measured memory_bytes: 73404
#define MAXN 100001
#define INF 0xfffffffffffffff

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

typedef unsigned long long int ull;

class path {
public:
	ull a,b,c;
	path(ull a_,ull b_,ull c_) {
		a = a_;
		b = b_;
		c = c_;
	}
	bool operator<(const path& e) const{
		if(e.a != this->a) return this->a < e.a;
		return this->b < e.b;
	}
};

ull n,a,b,c,q,k,x,y,d[MAXN];
vector<path> p;

void dfs(ull prev,ull cur) {
	auto itr1 = lower_bound(p.begin(),p.end(),path(cur,0,0));
	auto itr2 = upper_bound(p.begin(),p.end(),path(cur,INF,0));
	for(auto itr = itr1;itr != itr2;itr++) {
		if(itr->b != prev) {
			d[itr->b] = min(d[itr->b],d[cur] + itr->c);
			dfs(cur,itr->b);
		}
	}
}

int main(int argc,char** argv) {
	for(int i = 0;i < MAXN;i++) d[i] = INF;
	cin >> n;
	for(ull i = 0;i < n-1;i++) {
		cin >> a >> b >> c;
		p.push_back(path(a,b,c));
		p.push_back(path(b,a,c));
	}
	sort(p.begin(),p.end());
	cin >> q >> k;
	d[k] = 0;
	dfs(INF,k);
	for(ull i = 0;i < q;i++) {
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}
}


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

#define N 1000

int lcs(char x[], char y[]){
  int c[N + 1][N + 1];
  int i, j, m = strlen(x), n = strlen(y), maxl = 0;

  x[m + 2] = '\0';
  for(i = m + 1 ; i > 0 ; i--){
    x[i] = x[i - 1];
  }
  x[0] = ' ';

  y[n + 2] = '\0';
  for(j = n + 1 ; j > 0 ; j--){
    y[j] = y[j - 1];
  }
  y[0] = ' ';
 
  for(i = 0 ; i <= m ; i++) c[i][0] = 0;
  for(j = 0 ; j <= n ; j++) c[0][j] = 0;

  for(i = 1 ; i <= m ; i++){
    for(j = 1 ; j <= n ; j++){
      if(x[i] == y[j]){
	c[i][j] = c[i - 1][j - 1] + 1;
      }
      else{
	if(c[i - 1][j] >= c[i][j - 1]) c[i][j] = c[i - 1][j];
	if(c[i - 1][j] < c[i][j - 1]) c[i][j] = c[i][j - 1];
      }
      if(maxl < c[i][j]) maxl = c[i][j];
    }
  }
  return maxl;
}


int main(){
  char s1[N], s2[N];
  int n, i;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    scanf("%s %s", &s1, &s2);
    printf("%d\n", lcs(s1, s2));
  }
  return 0;
}


Measured memory_bytes: 5776
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans, tmp = 0, 0
for i in range(n):
    if a[i]<= tmp:
        ans += a[i]
        tmp = b[i]
    else:
        if a[i] >= b[i] + tmp:
            ans += b[i] + tmp
            tmp = 0
        else:
            ans += a[i]
            tmp = b[i] + tmp - a[i]
ans += min(a[n], tmp)
print(ans)

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

void solve() {
    int n;
    cin >> n;
    vector<pair<ll,ll>> robot(n);
    rep(i, n) {
        ll x, l;
        cin >> x >> l;
        // robot[i] = {x - l, x + l};
        // robot[i] = {l, x};
        robot[i] = {x + l, x - l};
    }

    sort(robot.begin(), robot.end());
    int ans = 0;
    ll r = -((ll)1e9 + 7);
    rep(i, n) {
        if (r <= robot[i].second) {
            ans++;
            r = robot[i].first;
        }
    }

    cout << ans << endl;
}

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


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

using namespace std;

bool OK(int N) {
  stringstream ss;
  ss << N;
  string str = ss.str();
  unordered_set<char> S(str.begin(), str.end());
  return S.size() == 1;
}

int main() {
  int N;
  cin >> N;
  for (; N < 1000; N++) {
    if (OK(N)) {
      cout << N;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int A[10000];
    int n,i,x,j,cnt=0;//cutはカウント用
    scanf("%d",&n);
    for(i=0;i<10000;i++){
        A[i]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d",&x);
        A[x]++;
    }
    for(i=0;i<10000;i++){
        for(j=0;j<A[i];j++){
            printf("%d",i);
            if(cnt<n-1){
                printf(" ");
                cnt++;
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2052
t = 0

def div(n):
    c = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            c += 2 if i != n // i else 1
    return c

for i in range(1, int(input()) + 1, 2):
    if div(i) == 8:
        t += 1

print(t)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int a,b,c,ans = 0,temp;
		String str = bf.readLine();
		String[] arrs = str.split(" ");
		a = Integer.parseInt(arrs[0]);
		b = Integer.parseInt(arrs[1]);
		c = Integer.parseInt(arrs[2]);

		if(b >= a*c) {
			ans = c;
		} else {
			ans = b/a;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
	int row, col;
	cin >> row >> col;
	char grid[row][col];
	for (int i = 0; i < row; i++) {
		for (int j = 0; j < col; j++) {
			cin >> grid[i][j];
		}
	}

	int dp[row][col];
	int i = 0;
	while (grid[i][0] != '#' && i < row) {
		dp[i][0]  = 1;
		i++;
	}
	while (i < row) {
		dp[i][0] = 0;
		i++;
	}
	i = 0;
	while (grid[0][i] != '#' && i < col) {
		dp[0][i]  = 1;
		i++;
	}
	while (i < col) {
		dp[0][i] = 0;
		i++;
	}

	for (int i = 1; i < row; i++) {
		for (int j = 1; j < col; j++) {
			if (grid[i][j] == '#') dp[i][j] = 0;
			else {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}

	cout << dp[row - 1][col - 1] << endl;

}

Measured memory_bytes: 8332
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

const int MN = 2 * 1e5 + 5;

int D[10][10][10]; // digit first last

int main()
{
	int N;
	scanf("%d", &N);
	
	int ten = 1, dig = 1;
	for (int i = 1; i <= N; i++)
	{
		if (i >= ten * 10) 
			ten *= 10, dig++;
		int fst = i / ten, last = i % 10;
		D[dig][fst][last]++;
	}
	ll ans = 0;
	for (int i = 0; i <= 9; i++)
	{
		for (int j = 0; j <= 9; j++)
		{
			for (int n = 1; n <= dig; n++)
			{
				for (int m = 1; m <= dig; m++)
				{
					ans += D[n][i][j] * D[m][j][i];
				}
			}
		}
	}
	printf("%lld", ans);

	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    if(N % 2 == 0){
        ll ans = 0;
        rep(i, 0, N/2-1) ans += A[i] * 2;
        ans += A[N/2 - 1] - A[N/2];
        rep(i, N/2+1, N) ans -= 2 * A[i];
        cout << ans << endl;
    }else{
        ll ans1 = 0, ans2 = 0;
        rep(i, 0, N/2-1) ans1 += A[i] * 2;
        ans1 += A[N/2 - 1] + A[N/2];
        rep(i, N/2+1, N) ans1 -= A[i] * 2;
        rep(i, 0, N/2) ans2 += A[i] * 2;
        ans2 -= A[N/2 + 1] + A[N/2];
        rep(i, N/2+2, N) ans2 -= A[i] * 2;
        cout << max(ans1, ans2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
    int l,A=0,d,i,j;
    vector<int> L = vector<int>();
    string in;
    cin>>in;
    for (i=0;i<in.size();i++) {
        switch (in[i]) {
        case '\\':
            l=1;d=1;
            for (j=i+1;j<in.size() && d>0;j++) {
                switch (in[j]) {
                case '\\':
                    l=l+d*2+1;
                    d++;
                    break;
                case '/':
                    l=l+d*2-1;
                    d--;
                    break;
                case '_':
                    l=l+d*2;
                    break;
                default:
                    break;
                }
            }
            if (d<1) {
                L.push_back(l);
                A += l;
                i = j-1;
            }
            break;
        case '/':
            break;
        case '_':
            break;
        default:
            break;
        } 
    }
    
    cout<<A/2<<endl;
    cout<<L.size();
    for (i=0;i<L.size();i++) cout<<" "<<L[i]/2;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3228
S = input()
S = S.replace("BC", "D")

S = list(S)

cnt1 = 0
cnt2 = 0
ans = 0
for i in range(len(S)):
    if S[i] == "A":
        cnt1 += 1
    elif S[i] == "D":
        cnt2 += 1
        ans += cnt1
    else:
        cnt1 = 0
        cnt2 = 0
print(ans)


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

#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;

#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define rep(i, k, n) for(int i = (int)k; i <= (int)n; ++i)
#define nrof(i, n) for(int i = (int)n - 1; i >= 0; --i)
#define x first
#define y second
#define mp make_pair
#define sz(a) (int)(a.size())
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6 + 9;
const int M = 2e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ll MOD = (ll) (1000000007);

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

void solve() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> cntx(h + 1, 0), cnty(w + 1, 0);
    set<pii> p;
    forn(i, m) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        ++cntx[x];
        ++cnty[y];
        p.insert({x, y});
    }

    vector<pii> tx(h + 1), ty(w + 1);

    forn(i, sz(cntx)) {
        tx[i] = mp(cntx[i], i);
    }
    
    forn(i, sz(cnty)) {
        ty[i] = mp(cnty[i], i);
    }

    sort(rall(tx));
    sort(rall(ty));

    while (tx[0].x > tx.back().x) tx.pop_back();
    while (ty[0].x > ty.back().x) ty.pop_back();

    forn(i, sz(tx)) {
        forn(j, sz(ty)) {
            if (!p.count({tx[i].y, ty[j].y})) {
                cout << tx[i].x + ty[j].x << endl;
                return;
            }
        }
    }

    cout << tx[0].x + ty[0].x - 1 << endl;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


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

#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int MN = 1e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    ll a, b; cin >> a >> b;
    ll d = gcd(a, b);
    int cnt = 1;
    for (ll x = 2; x <= sqrt(d); x++) {
        if (d % x == 0) {
            cnt++;
            while (d % x == 0) d /= x;
        }
    }
    if (d > 1) cnt++;
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
#define M_PI 3.1415
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

bool tenta(int idx, int idx2, vector<int> vec, vector<int> vec2){
  swap(vec[idx], vec[idx2]);
  return (vec == vec2);
}

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

  int n;
  cin >> n;
  vector<int> vec, vec2;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    vec.push_back(a);
    vec2.push_back(a);
  }

  sort(vec2.begin(), vec2.end());

  if(vec == vec2){
    cout << "YES" << endl;
    return 0;
  }

  for(int i=0;i<sz(vec);i++){
    for(int j=i+1;j<sz(vec);j++){
      if(tenta(i, j, vec, vec2)){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
string s;
int k;
vector<string> vt;
int main() {
	int i, j;
	cin>>s>>k;
	for(i=1; i<=min(k, (int)s.size()); i++) for(j=0; j<s.size()-i+1; j++) {
		vt.push_back(s.substr(j, i));
	}
	sort(vt.begin(), vt.end());
	k--;
	for(i=1; k; i++) if(vt[i] != vt[i-1]) k--;
	cout<<vt[i-1];
	return 0;
}

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N = int(input())
T = []
for _ in range(N) :
  T.append(int(input()))


def lcm(a):
  from fractions import gcd
  x = a[0]
  for i in range(1, len(a)):
      x = (x * a[i]) // gcd(x, a[i])
  return x
 
print(lcm(T))



Measured memory_bytes: 5152
#include <stdio.h>
 
int main(void)
{
	int a[101][101] = {0};
	int b[101] = {0};
	int d[101] = {0};
	int i,j,r,c;
	int x;
	int e = 0;

	scanf("%d %d" , &r,&c);
	for(j=0; j<r; j++) {
	for(i=0; i<c; i++) {
	scanf("%d",&x);
	a[j][i] = x;
	}
	}
	for(j=0; j<r; j++){
	for(i=0; i<c; i++) {
	b[i] += a[j][i];
	}
	}
	for(j=0; j<r; j++){
	for(i=0; i<c; i++){
		d[j] += a[j][i];
	}
}
	for(j=0; j<r; j++) {
    	for(i=0; i<c; i++) {
	printf("%d ",a[j][i]);
	}
	printf("%d\n", d[j]);
	}
	for(i =0; i<c; i++) {
	printf("%d " ,b[i]);
	e += b[i];
	}
printf("%d\n", e);
 
return 0;
}


Measured memory_bytes: 2100
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 2005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int a[2*MAXN];
char ch[2*MAXN][2];
int posb[MAXN],posw[MAXN];
int cntbb[MAXN][MAXN],cntbw[MAXN][MAXN],cntwb[MAXN][MAXN],cntww[MAXN][MAXN];
int dp[2*MAXN][MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++)
    {
        scanf("%s",ch[i]);
        scanf("%d",&a[i]);
        if(ch[i][0]=='B') posb[a[i]]=i; else posw[a[i]]=i;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cntbb[i][j]=cntbb[i][j-1];
            if(posb[j]>posb[i]) cntbb[i][j]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cntbw[i][j]=cntbw[i][j-1];
            if(posw[j]>posb[i]) cntbw[i][j]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cntwb[i][j]=cntwb[i][j-1];
            if(posb[j]>posw[i]) cntwb[i][j]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cntww[i][j]=cntww[i][j-1];
            if(posw[j]>posw[i]) cntww[i][j]++;
        }
    }
    for(int i=0;i<=2*n;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<2*n;i++)
    {
        for(int j=0;j<=min(i,n);j++)
        {
            int b=j,w=i-j;
            if(j<n) dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+cntbb[j+1][j+1]+cntbw[j+1][w]);
            if(w<n) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+cntww[w+1][w+1]+cntwb[w+1][b]);
        }
    }
    printf("%d\n",dp[2*n][n]);
    return 0;
}



Measured memory_bytes: 94592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll d=INF;
    ll M=-1;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n){
        M=max(M,a[i]);
        if(i==0) continue;
        if(a[i]==a[i-1]) continue;
        d=min(d,a[i]-a[i-1]);
    }
    bool flag=true;
    rep(i,n){
        if(a[i]%d!=0) flag=false; break;
    }
    if(k>M) cout << "IMPOSSIBLE" << endl;
    else if(flag && k%d!=0) cout << "IMPOSSIBLE" << endl;
    else{
        cout << "POSSIBLE" << endl;
    }
    return 0;
} 

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

int main () {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  vector<bool> c(N, false);
  for (int i = 0; i < M; i++) {
    if (a.at(i) == 1) {
      int x = b.at(i);
      c.at(x-1) = true;
    }
  }
  for (int i = 0; i < M; i++) {
    int y = a.at(i);
    if (c.at(y-1) == true && b.at(i) == N) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string x, z, y;
	int a, b;
	
	cin>>a>>b;
	
	for(int i = 0; i < b; i++){
		x += '0' + a;
	}
	for(int i = 0; i < a; i++){
		y += '0' + b;
	}
	if(x < y) cout<<x<<endl;
	else cout<<y<<endl;
	
	return 0;
}

Measured memory_bytes: 256