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

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  int Mina=1000000, Minb=1000000;
  vector<int> a(A), b(B), x(M), y(M), c(M);
  for(int i=0; i<A; i++){
    cin >> a.at(i);
    Mina=min(Mina, a.at(i));
  }
  for(int i=0; i<B; i++){
    cin >> b.at(i);
    Minb=min(Minb, b.at(i));
  }
  for(int i=0; i<M; i++){
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  int Ans=Mina+Minb;
  for(int i=0; i<M; i++){
    Ans=min(Ans, a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i));
  }
  cout << Ans << endl;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(void){
	int n;
  int max=0;
  int ans=0;
  int h[200];
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
  scanf("%d",&h[i]);
  }
    for(int i=1;i<=n;i++){
  	if(max<=h[i]){ans++;max=h[i];}
  }
  printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
mx = max(a)
a[a.index(mx)] = abs(mx)
evn = sum(max(0, i) for i in a[::2])
odd = sum(max(0, i) for i in a[1::2])
if mx < 0:
    print(mx)
else:
    print(max(evn, odd))
oe = int(evn < odd)
res = []
beg = 0
while beg%2!=oe or a[beg]<0:
    res.append(1)
    beg += 1
end = n-1
while end%2!=oe or a[end]<0:
    res.append(end-beg+1)
    end -= 1
while beg < end:
    if a[end-2] < 0:
        res.append(end-beg-1)
    else:
        res.append(end-beg)
    end -= 2
print(len(res))
for i in res:
    print(i)


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

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

	int ans = 700;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			ans += 100;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main = do
  [n, s] <- input (map read . words) :: IO [Int]
  when (n /= 0 || s /= 0) $ do print $ solve n s; main
  
solve :: Int -> Int -> Int
solve n s = length . filter (\x -> sum x == s) . filter (\x -> length x == n) $ filterM (\x -> [True,False]) [0..9]

input :: (String -> a) -> IO a
input f = f <$> getLine

Measured memory_bytes: 4184
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};

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

	int n, a, b, c, d, i, j, k;
	string s;
	bool ans;

	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	UnionFind uf(n);
	for (i = 0; i < n - 1; i++) {
		if ((s[i] == '.') && (s[i + 1] == '.')) uf.unionSet(i, i + 1);
	}
	for (i = 0; i < n - 2; i++) {
		if ((s[i] == '.') && (s[i + 2] == '.')) uf.unionSet(i, i + 2);
	}

	if (!uf.isSameSet(a, c) || !uf.isSameSet(b, d)) ans = false;
	else if ((b > c) || (c < d)) ans = true;
	else {
		ans = false;
		for (i = b - 1; i + 2 <= min(n - 1, d + 1); i++) {
			if ((s[i] == '.') && (s[i + 1] == '.') && (s[i + 2] == '.')) ans = true;
		}
	}
	if (ans) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

using namespace std;

#define FOR(i,l,r) for( int i = l ; i < r; i++ ) 
#define vi vector<int>
#define li long long int
#define vl vector<li>
#define vvl vector<vl>
#define pb push_back
#define lmi LLONG_MIN

int n;
vvl a;
vl dp;
vi po;
vl scores;

bool present( int mask, int pos ) {
    return (mask>>pos)&1;
}


void upd( li & a, li b ) {
    a = max(a,b);
}

void manage( int index, li score, vi & not_used, int mask, int Set ) {
    if( index == not_used.size() ) {
        upd(dp[mask],score+scores[Set]);
        return;
    }
    manage(index+1,score,not_used,mask,Set);
    manage(index+1,score,not_used,mask^po[not_used[index]],Set^po[not_used[index]]);
}

int main() {
    cin>>n;
    po.assign(n+4,0); FOR(i,0,n+4) po[i] = (1ll<<i);
    a.assign(n,vl(n,0));
    FOR(i,0,n) FOR(j,0,n) cin>>a[i][j];
    dp.assign(po[n],lmi);
    int ma = po[n];
    dp[0] = 0;
    scores.assign(ma,0);
    FOR(i,0,ma) {
        FOR(j,0,n) {
            if( !present(i,j) ) continue;
            FOR(k,j+1,n) {
                if( !present(i,k) ) continue;
                scores[i] += a[j][k];
            }
        }
    }
    FOR(i,0,ma) {
        vi not_used;
        FOR(j,0,n) {
            if( !present(i,j) ) not_used.pb(j);
        }
        manage(0,dp[i],not_used,i,0);
    }
    cout<<dp[ma-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1280
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

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

int main() {
  ll a, b;

  cin >> a >> b;

  ll x, y;
  x = max(a, b);
  y = min(a, b);

  ll g = gcd(y, x);

  ll ans = b*a/g;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
count = 0

B = list(map(int, input().split()))
for i in range(N):
    A = list(map(int, input().split()))
    
    total = sum([A[i]*B[i] for i in range(M)]) + C

    if total > 0:
        count += 1
print(count)        


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,k;
bool ban[10];
bool check(int nu)
{
	while(nu)
	{
		if(ban[nu%10]==1)return 0;
		nu/=10;
	}
	return 1;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		ban[x]=1;
	}
	while(1)
	{
		if(check(n))break;
		n++;
	}
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>


int main()
{
    int q,ope;
    long long num;
    std::cin>>q;
    std::set<long long> S;
    
    for(int i = 0; i < q; i++)
    {
        std::cin>>ope>>num;
        if(ope){std::cout<<S.count(num)<<std::endl;}
        else{S.insert(num);std::cout<<S.size()<<std::endl;}
    } 
    return 0;

}



Measured memory_bytes: 12488
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define writeln printf("\n")
using namespace std;
typedef long long LL;
typedef double DB;
const int MAXN = 100010;
inline LL in()
{
	LL x = 0, flag = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
	return x * flag;
}
LL n, m, ans;
LL a[MAXN];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) a[i] = in();
    LL bg = a[1], ed = a[m], sum = ed - bg;
    ans = sum + min(abs(bg), abs(ed));
    for (int i = m + 1; i <= n; i ++) 
    {
        sum -= abs(a[i - m + 1] - bg);
        bg = a[i - m + 1];
        sum += abs(a[i] - ed);
        ed = a[i];
        ans = min(ans, sum + min(abs(bg), abs(ed)));
    }
    cout << ans << endl;
    return 0;
}
/*
*/

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll comb(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
vector<vector<pair<int, int>>> G;
vector<int> edge;
void dfs(int v, int pc) {
	int c = 1;
	for (auto e : G[v]) {
		if (edge[e.second])continue;
		if (c == pc)c++;
		edge[e.second] = c;
		dfs(e.first, c);
		c++;
	}
}
int main(void) {
	int n, ans_num = 0, a, b;
	cin >> n;
	G.resize(n);
	edge.resize(n);
	rep(i, 0, n - 1) {
		cin >> a >> b;
		a--, b--;
		G[a].push_back(make_pair(b, i));
		G[b].push_back(make_pair(a, i));
		ans_num = max(ans_num, (int)max(G[a].size(), G[b].size()));
	}
	dfs(0, -1);
	printf("%d\n", ans_num);
	rep(i, 0, n - 1) {
		printf("%d\n", edge[i]);
	}
	return 0;
}


Measured memory_bytes: 6912
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
//#include<unordered_map>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=2e5+5;
int digit[25];
int d[25][222][2];
int dfs(int len,int limit,int pre,int last,int ok){
    if(!len)return ok;
    if(!limit&&!pre&&d[len][last][ok]!=-1)return d[len][last][ok];
    int ans=0;
    int ma=(limit?digit[len]:9);
    for(int i=0;i<=ma;i++){
        ans+=dfs(len-1,limit&&i==ma,pre&&i==0,i,ok&&(pre||abs(i-last)<=1));
    }
    if(!limit&&!pre){
        d[len][last][ok]=ans;
    }
    return ans;
}
int solve(int x){
    int len=0;
    while(x){
        digit[++len]=x%10;
        x/=10;
    }
    return dfs(len,1,1,0,1);
}
int check(int mid){
    return solve(mid)-solve(0);
}
signed main(){
    memset(d,-1,sizeof d);
    int k=re;
    int l=1,r=1e15;
    int ans=-1;
    while(l<=r){
        int mid=(l+r)/2;
        int t=check(mid);
        if(t>=k){
            ans=mid;
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    pr(ans);
    return 0;
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();
    int n;
    cin >> n;
    while(n--)cout << "ACL";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
  int n;
  cin >> n;
  int v;
  int a[50000], b[50000];
  int asize = 0, bsize = 0;
  for(int i = 0;i < n;i++){
    cin >> v;
    if(i % 2){
      b[i / 2] = v;
      bsize++;
    }else{
      a[i / 2] = v;
      asize++;
    }
  }
  sort(a, a + asize);
  sort(b, b + bsize);
  int count = 1;
  int amax = 0, bmax = 0, amax2, bmax2;
  priority_queue<int> aq, bq;
  for(int i = 1;i < asize;i++){
    if(a[i] == a[i - 1]){
      count++;
    }else{
      aq.push(count);
      if(amax < count){
        amax = count;
        amax2 = a[i - 1];
      }
      count = 1;
    }
  }
  aq.push(count);
  if(amax < count){
    amax = count;
    amax2 = a[asize - 1];
  }
  count = 1;
  for(int i = 1;i < bsize;i++){
    if(b[i] == b[i - 1]){
      count++;
    }else{
      bq.push(count);
      if(bmax < count){
        bmax = count;
        bmax2 = b[i - 1];
      }
      count = 1;
    }
  }
  bq.push(count);
  if(bmax < count){
    bmax = count;
    bmax2 = b[bsize - 1];
  }
  int a2, b2;
  if(amax2 != bmax2){
    cout << (n - (amax + bmax)) << endl;
  }else{
    aq.pop();
    if(aq.empty()){
      a2 = 0;
    }else{
      a2 = aq.top();
    }
    bq.pop();
    if(bq.empty()){
      b2 = 0;
    }else{
      b2 = bq.top();
    }
    cout << min(n - (amax + b2), n - (a2 + bmax)) << endl;
  }
}

Measured memory_bytes: 1148
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 15 August 2020 01:23:32 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;
    int k = (n*100)/108;
    //cout<<k<<endl;
    if(((int)(k*(1.08))) == n){
        cout<<k<<endl;
        return;
    }
    //cout<<(int)((k+1)*(1.08))<<endl;
    if((int)((k+1)*(1.08)) == n){
        cout<<k+1<<endl;
        return;
    }
    cout<<":("<<endl;
    
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



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

int main(){
    int N, X[110], i, cnt;
    int ans = 10000000;
    cin >> N;
    for(i = 0; i < N; i++) cin >> X[i];
    sort(X, X + N);

    for(int j = X[0]; j <= X[N - 1]; j++){
        cnt = 0;
        for(i = 0; i < N; i++) cnt += pow((X[i] - j), 2);
        if(ans > cnt) ans = cnt;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long H, long long W, std::vector<std::vector<long long>> c, std::vector<std::vector<long long>> A){
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(i, H){
        rep(j, W){
            if(A[i][j]!=-1)
                ans += c[A[i][j]][1];
        }
    }
    cout << ans << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::vector<long long>> c(9-0+1, std::vector<long long>(9-0+1));
    for(int i = 0 ; i < 9-0+1 ; i++){
        for(int j = 0 ; j < 9-0+1 ; j++){
            scanf("%lld",&c[i][j]);
        }
    }
    std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(H, W, std::move(c), std::move(A));
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
int prime[100005],cnt,n;
ll a[100005],b[100005];
bool isprime[100005];
map<ll,int> mp;
void init(){
	for(int i=2;i<=100002;i++){
		if(!isprime[i]) prime[++cnt]=i;
		for(int p=1;p<=cnt&&prime[p]*i<=100002;p++){
			isprime[prime[p]*i]=1;
			if(i%prime[p]==0) break;
		}
	}
}
void pan(ll &x,ll &w){
	w=1;ll o=1;
	for(int i=1;i<=cnt&&1LL*prime[i]*prime[i]*prime[i]<=x;i++){
		int g=0;
		while(x%prime[i]==0) g++,x/=prime[i];
		g%=3;
		if(g==1) w*=prime[i]*prime[i],o*=prime[i];
		if(g==2) w*=prime[i],o*=prime[i]*prime[i];
		if(x==1) break;
	}
	ll g=sqrt(x);
	if(g*g==x) o*=x,w*=g;
	else{
		o*=x;
		if(x<=100000) w*=x*x;
		else w=0;
	}
	if(mp.find(o)==mp.end()) mp[o]=0;
	mp[o]++;
	x=o;
}
int main(){
	init();
	scanf("%d",&n);
	ll x;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		pan(a[i],b[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(mp.find(b[i])==mp.end()){
			ans+=mp[a[i]];
			mp[a[i]]=0;
		}else{
			if(a[i]==b[i]){
				if(mp[a[i]]) ans++,mp[a[i]]=0;
				continue;
			}
			ans+=max(mp[a[i]],mp[b[i]]);
			mp[a[i]]=mp[b[i]]=0;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		char c[]=s.toCharArray();
		int count=0;
		long total=0;
			for(int i=c.length-1;i>=0;--i) {
				if(c[i]=='B') {
					total+=c.length-1-i-count;
					++count;
				}
			}
		
		System.out.println(total);
	}
}


Measured memory_bytes: 27092
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


def solve():
    N, M = map(int, input().split())
    UF = UnionFind(N)
    for i in range(M):
        _a, _b = map(int, input().split())
        UF.union(_a-1, _b-1)
    rt_l = UF.roots()
    ans = 0
    for _rt in rt_l:
        _len = UF.size(_rt)
        if ans < _len:
            ans = _len

    print(ans)


solve()


Measured memory_bytes: 18496
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 500

int n, m;
int d[N][N];
int c[N];
bool vv;
vector<int>e[N];
void init(void) {
	f(i, N) {
		f(j, N)d[i][j] = (10000*N);
		d[i][i] = 0;
	}
	return;
}

void Warshall_Floyd(void) {
	f(k, n) {
		f(i, n) {
			f(j, n) {
				if (d[i][j] > d[i][k] + d[k][j]) {
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
	return;
}

void dfs(int k, int cc) {
	if (c[k] == -1)c[k] = cc;
	cc = (cc + 1) % 2;
	f(i, e[k].size()) {
		if (c[e[k][i]] == -1)dfs(e[k][i], cc);
		else if (c[e[k][i]] != cc)vv = false;
		if (!vv)return;
	}
	return;
}

int main() {
	char a[N + 1];
	int k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	init();
	scanf("%d", &n);
	f(i, n) {
		f(i, N + 1)a[i] = 0;
		scanf("%s", a);
		f(j, n) {
			if (a[j] == '1') {
				d[i][j] = 1;
				e[i].push_back(j);
			}
		}
	}
	Warshall_Floyd();
	f(i, N) {
		c[i] = -1;
	}
	vv = true;
	f(i, n) {
		if (c[i] == -1)dfs(i, 0);
	}
	f(i, n) {
		f(j, n) {
			if (d[i][j] < 10000) {
				ans = max(ans, d[i][j]);
			}
		}
	}
	if(vv)printf("%d\n", ans+1);
	else printf("-1\n");


	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,mn=INT_MAX,i,x,j,a=0,t,k,b=-1,mx=-1,cnt=0,c=0; 
 st s,str; char strn;
//cin>>n; //a=n; n-=1; 
//ll ara[n+1],bra[n+1],taj[n+1];

//for(i=1;i<=n;i++) cin>>ara[i]; 
  for(i=1;i<=5;i++)
   {
     cin>>x;
    if(x==0)a=i;
   }      
              

        
     cout<<a<<endl;
    
 
    rt;
}

Measured memory_bytes: 3512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

const int MAX_N = 110, MAX_V = 1e5+10;
LL w[MAX_N],v[MAX_N];
LL dp[MAX_N][MAX_V];

LL N,W;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    cin >> N >> W;
    REP(i,N){
        cin >> w[i] >> v[i];
    }
    REP(i,MAX_N) REP(j,MAX_V){
        dp[i][j] = LINF;
    }

    dp[0][0] = 0;
    REP(i,N){
        REP(j,MAX_V){
            if(j-v[i] >= 0){
                chmin(dp[i+1][j],min(dp[i][j-v[i]]+w[i],dp[i][j]));
            }else{
                chmin(dp[i+1][j],dp[i][j]);
            }
        }
    }
    for(int i = MAX_V-1; i >= 0; i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
        
    }

}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
int main() {
	int m, d; cin >> m >> d;
	int res = 0;
	for (int i = 1; i <= d; i++)
	{
		int x = i % 10, y = i / 10;
		if(x >= 2 && y >= 2){
			if(x * y <= m) res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
package main
 
import (
  "fmt"
)

func main() {
  var s string
  fmt.Scan(&s)
  
  switch s {
  case "Sunny":
    fmt.Println("Cloudy")
  case "Cloudy":
    fmt.Println("Rainy")
  case "Rainy":
    fmt.Println("Sunny")
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n; cin>>n;
    map<char,int> m;
    for(int i=0; i<n; i++){
        string s; cin>>s;
        if(i == 0){
            for(char c : s)
                m[c]++;
        }
        else{
            map<char, int> temp;
            for(char c : s)
                temp[c]++;
            for(auto p : m){
                if(temp[p.first])
                    m[p.first] = min(p.second, temp[p.first]);
                else
                    m[p.first] = 0;
            }
        }
    }
    string ans = "";
    for(auto p : m){
        for(int i=0; i<p.second; i++)
            ans += p.first;
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
int cnt[3];

int main(){
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++){
        cnt[(int)((char)s[i]-'a')]++;
    }
    if(cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
use itertools::iproduct;
use proconio::{input, marker::Usize1};

fn main() {
    input!(r: usize, c: usize, goods: [(Usize1, Usize1, u64)]);

    let mut val = array![0; r, c];
    for &(r, c, v) in &goods {
        val[r][c] = v;
    }

    let mut dp = array![0; r+1, c + 1, 4];
    for (i, j, k) in iproduct!(0..=r, 0..=c, (0..=3).rev()) {
        if i < r {
            max_assign!(dp[i + 1][j][0], dp[i][j][k]);
        }
        if j < c {
            max_assign!(dp[i][j + 1][k], dp[i][j][k]);
        }
        if i < r && j >= 1 {
            max_assign!(dp[i + 1][j][1], dp[i][j][k] + val[i][j - 1]);
        }
        if j < c && i >= 1 && k < 3 {
            max_assign!(dp[i][j + 1][k + 1], dp[i][j][k] + val[i - 1][j]);
        }
    }

    println!("{}", dp[r][c].iter().max().unwrap())
}

#[macro_export]
macro_rules! array {
    ($v:expr; $l:expr, $($r:expr),*) => { vec![array!($v; $($r),*); $l] };
    ($v:expr; $l:expr) => { vec![$v; $l] };
    () => { vec![] };
}

#[macro_export]
macro_rules! max_assign {
    ($x:expr, $y:expr) => {{
        let rhs = $y;
        if $x < rhs {
            $x = rhs;
            true
        } else {
            false
        }
    }};
}


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

int main()
{
	long long int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(a<=k)
	{	
		sum+=a;
		k=k-a;
	}
	else
	{
		sum=k;
		k=0;
	}
	
	if(b<=k)
		k=k-b;
	else
		k=0;
	
	if(c<=k)
		sum-=c;
	else
		sum-=k;
	
	cout<<sum;

	
}


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

int abs(int n){
	if(n > 0){
		return n;
	}else{
		return -n;
	}
}

int min(int a[],int n){
	int min = a[0];
	
	for(int i = 0; i < n; i++){
		if(min > a[i]){
			min = a[i];
		}
	}
	
	return min;
}
		

int main(void)
{
	char s[11];
	
	scanf("%s",s);
	
	int a = strlen(s);
	
	int suuti[1000];
	
	for(int i = 0; i < a - 2; i++){
		suuti[i] = (s[i] - '0')*100 + (s[i + 1] - '0')*10 + (s[i + 2] -'0');
		
		suuti[i] =abs(753 - suuti[i]);
		
	}
	
	int ans = min(suuti,a - 2);
	
	printf("%d\n",ans);
	
	return 0;
}
	
	
	
		
		
		
		
		
		
	
	

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        long[] a = new long[n];
        long nmin = 1000000001;
        int ncount = 0;
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextLong();
            if (Math.Abs(a[i]) < nmin) nmin = Math.Abs(a[i]);
            if (a[i] < 0) ncount++;
        }
        long ans = 0;
        for (int i = 0; i < n; i++) ans += Math.Abs(a[i]);
        if (ncount % 2 != 0)
        {
            ans -= nmin * 2;
        }
        Console.WriteLine(ans);
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 29408
#import<iostream>
using namespace std;long long N,a,n=1,i,j,p[1000];main(){cin>>N;for(i=1;++i<=N;)if(!p[i])for(j=i*2;j<=N;j+=i)p[j]=1;for(i=1;++i<=N;a=0){if(p[i])continue;for(j=i;j<=N;j*=i)a+=N/j;n=n*(++a)%1000000007;}cout<<n<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
set<char> st;
rep(i,N) {
    char c;
    cin >> c;
    st.insert(c);
}

if(st.size() == 4) puts("Four");
else puts("Three");

return 0;
}

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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int k;
    vector<int> a(3);
    REP(3){
        cin >> a[i];
    }
    cin >> k;

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

    cout << a[0]+a[1]+a[2]*pow(2,k) << endl;

    
   
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				/* input */
				String[] s = new String[4];
				s[0] = br.readLine();
				if(s[0].charAt(0)=='-'){
					break;
				}
				s[1] = br.readLine();
				s[2] = br.readLine();
				s[3] = "";
				
				int[] c = {0,0,0,1};
				for(int i=0;i<s[0].length()+s[1].length();i++){
					if(s[2].charAt(c[2])==(s[c[3]].charAt(c[c[3]]))){
						//System.out.println("HIT:" + s[c[3]].charAt(c[c[3]]));
						c[c[3]]++;
						c[3] = 0;
						c[2]++;
					} else {
						//System.out.println("ADD:" + s[c[3]].charAt(c[c[3]]));
						s[3] = s[3] + s[c[3]].charAt(c[c[3]]);
						c[c[3]]++;
						c[3] = 1;
					}
					if(c[2]>=s[2].length()){
						s[3] = s[3] + s[c[3]].charAt(c[c[3]]) + s[1].substring(c[1]);
						break;
					}
				}
				System.out.println(s[3]);
			}
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
}

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

const int MOD = 998244353;

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

long long modinv(long long a) {
    return modpow(a, MOD - 2);
}


int main() {
    int N, S; cin >> N >> S;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<ll>> memo(N, vector<ll>(S+1, 0));

    memo[0][0] = modpow(2, N);
    ll modinv2 = modinv(2);
    if (A[0] <= S) memo[0][A[0]] = (memo[0][0] * modinv2) % MOD;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            memo[i][j] = memo[i-1][j];
            if (j - A[i] >= 0) {
                memo[i][j] += memo[i-1][j-A[i]] * modinv2;
            }
            if (memo[i][j] > MOD) memo[i][j] %= MOD;
        }
    }
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j <= S; j++) {
    //         cout << memo[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << memo[N-1][S] << endl;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[200202];
    Scs(s);
    int N = strlen(s);

    Rep(i,N){
        if( s[i] == '?' ) s[i] = 'D';
    }

    printf ("%s\n", s );

    return 0;
}



Measured memory_bytes: 3852
n,k=map(int,input().split())
a=list(map(int,input().split()))
cntin=0
cntot=0
mod=10**9+7
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]<a[j]:
      cntot+=1
    elif a[i]>a[j]:
      cntin+=1
print((cntin*((k*(k+1))//2)%mod+cntot*((k*(k-1))//2)%mod)%mod)

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

using namespace std;

int main(){
	
	string str;
	int a,i,j,k;
	
	while(cin >> str){
		
	j=0;
	k=0;
	
	
	a = str.size();
	
	for(i=0;i<a-2;i++){
		
		if(str[i]=='J' && str[i+1]=='O' && str[i+2]=='I') j++;
		if(str[i]=='I' && str[i+1]=='O' && str[i+2]=='I') k++;
		
	}
	
	cout << j <<endl << k << endl;
	
	}
	
	

	

	
	return 0;
	
}
	

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    cout << (h % a) * w + h * (w % b) - (h % a) * (w % b) << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

template < typename T > void coutVector(vector<T> v){for(int i=0;i<int(v.size());++i){if(i>0)cout<<" "<<v[i];else cout<<v[i];}cout<<endl;}
template < typename T > void coutVectorWithEndl(vector<T> v){for(int i=0;i<int(v.size());++i){cout<<v[i]<<endl;}}
template < typename T > vector<T> cinVector(int n) {vector<T> res(n);for(int i=0;i<n;++i){cin>>res[i];}return res;}


const ll MOD = 1e9+7;
int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll num_of_all_comb = modPow(2,n,MOD) - 1;

    ll ya = 1, xa = 1;
    repp(i,1,a+1) {ya *= i; ya %= MOD;}
    repp(i,n-a+1,n+1) {xa *= i; xa %= MOD;}
    ll num_of_a_comb = (xa * modPow(ya, MOD-2, MOD) % MOD);

    ll yb = 1, xb = 1;
    repp(i,1,b+1) {yb *= i; yb %= MOD;}
    repp(i,n-b+1,n+1) {xb *= i; xb %= MOD;}
    ll num_of_b_comb = (xb * modPow(yb, MOD-2, MOD)) % MOD;

    ll res = (num_of_all_comb - num_of_a_comb - num_of_b_comb) % MOD;
    if (res < 0) res += MOD;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    if(N < 10)
    {
        cout<<N<<endl;
    }
    else if(N < 100)
    {
        cout<<9<<endl;
    }
    else if(N < 1000)
    {
        cout<<9 + N - 100 + 1<<endl;
    }
    else if(N < 10000)
    {
        cout<<9 + 900<<endl;
    }
    else if(N < 100000)
    {
        cout<<9 + 900 + N - 10000 + 1<<endl;
    }
    else
    {
        cout<<9+900+90000<<endl;
    }
    return 0;
}


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

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

    switch (s[0])
    {
        case 'A':
            putchar('T');
            break;

        case 'C':
            putchar('G');
            break;

        case 'G':
            putchar('C');
            break;

        case 'T':
            putchar('A');
            break;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  while(cin>>n>>m){
    cout<<__gcd(n,m)<<' '<<n/__gcd(n,m)*m<<'\n';
  }
}


Measured memory_bytes: 3120
from itertools import product

S=input()
N=len(S)
a=product(["+",""],repeat=N-1)
ans=0

for i,p in enumerate(a):
  bun = S[0]
  for j in range(N-1):
    bun += p[j]+S[j+1]
  nums=bun.split("+")
  tmp=0
  for num in nums:
    tmp+=int(num)
  ans+=tmp
print(ans)

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

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<ll> Size;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n + 1);
    rank.resize(n + 1);
    Size.resize(n + 1);
    for (int i = 0; i <= n; ++i)
      par[i] = i, rank[i] = 0, Size[i] = 1;
  }

  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    Size[x] += Size[y];
    return true;
  }

  ll size(int x) { return Size[root(x)]; }
};

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

  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, 0, m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.merge(x, y);
  }

  unordered_set<int> unos;
  rep(i, 0, n) unos.insert(uf.root(i));

  cout << unos.size() << endl;
}


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

using namespace std;

inline void read() {}
template <class S>
inline void read(S &arg) {
  cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    read(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void read(S &arg, T &... rest) {
  read(arg);
  read(rest...);
}

inline void write() {}
template <class S>
inline void write(S arg) {
  cout << arg;
}
template <class S>
inline void writeA(S Lptr, S Rptr) {
  if (Lptr != Rptr) {
    write(*Lptr);
    Lptr++;
  }
  while (Lptr != Rptr) {
    write(' ');
    write(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void write(S arg, T... rest) {
  write(arg);
  write(' ');
  write(rest...);
}

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

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

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 1e9 + 7;
constexpr int N = 1e6 + 10;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}

ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n, m;
vector<pii> adj[N];
bitset<N> mark;
int dist[N];

void dfs(int v) {
  mark[v] = true;
  for (auto e : adj[v]) {
    if (!mark[e.first]) {
      dist[e.first] = dist[v] + e.second;
      dfs(e.first);
    }
    if (dist[e.first] - e.second != dist[v]) {
      write("No\n");
      exit(0);
    }
  }
}

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  read(n, m);
  rep(i, 0, m) {
    int l, r, d;
    read(l, r, d);
    adj[l].pb({r, d});
    adj[r].pb({l, -d});
  }

  rep(i, 1, n + 1) if (!mark[i]) dfs(i);

  write("Yes\n");

  return 0;
}


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

using namespace std;

int main() {
    int a, b; cin >> a >> b;
    if(a < 0 && b > 0) cout << "Zero\n";
    else if(a > 0 && b > 0) cout << "Positive\n";
    else {
        if(b >= 0) {
            if(a % 2 == 0) cout << "Positive\n";
            else cout << "Negative\n";
        }
        else {
            if(abs(a+b) % 2 != 0) cout << "Positive\n";
            else cout << "Negative\n";
        }
    }
    return 0;
    
}


Measured memory_bytes: 256
from math import pi, cos
A, B, H, M = map(int, input().split())


fun_shin = M/60 * 2*pi
ji_shin = (60*H+M)/(12*60) * 2*pi

a2 = A**2 + B**2 - 2*cos(fun_shin-ji_shin) * A*B
print(a2**.5)

Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int a[6], b[6], c[6];
int aa[3], ab[3], ac[3];

void f(int a[])
{
	int tmp;
	tmp = a[5] - a[2];
	if (tmp < 0){
		a[5] += 60;
		a[4]--;
	}
	tmp = a[4] - a[1];
	if (tmp < 0){
		a[4] += 60;
		a[3]--;
	}
}


int main()
{
	REP(i, 6) cin >> a[i];
	REP(i, 6) cin >> b[i];
	REP(i, 6) cin >> c[i];

	f(a);
	f(b);
	f(c);

	REP(i, 3){
		if (i < 2) cout << a[i+3] - a[i] << " ";
		else cout << a[i+3] - a[i] << endl;
	}
	REP(i, 3){
		if (i < 2) cout << b[i+3] - b[i] << " ";
		else cout << b[i+3] - b[i] << endl;
	}
	REP(i, 3){
		if (i < 2) cout << c[i+3] - c[i] << " ";
		else cout << c[i+3] - c[i] << endl;
	}
	
}


Measured memory_bytes: 3104
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
"""
def resolve():
    a,b,c=pin()
    from math import sqrt
    cond =(c-a-b)>sqrt(a*b)*2
    print(["No","Yes"][cond])
"""
def resolve():
    N,=pin()
    from collections import deque
    from collections import Counter
    ans=deque([["a",1]])
    L=1
    abc="abcdefghij"
    #("str",chars in str)のリスト？
    if N>1:
        for i in range(2,N+1):
            while(len(ans[0][0])<N):
                temp=ans.popleft() 
                string,types=temp
                for y in range(types+1):
                    temp2=string
                    temp2+=abc[y]
                    count=Counter(temp2)
                    
                    ans.append([temp2,len(count)])
                    
    for A in ans:
        print(A[0])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
if __name__=="__main__":resolve()

Measured memory_bytes: 77144
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;

lli X, A, B;
lli pp(lli x){
    return x * x * x * x * x;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> X;
    for(A = -200; A < 0 || pp(A) <= X; ++A){
        for(B = -200; B < 0 || pp(A) - pp(B) <= X; ++B){
            if(pp(A) - pp(B) == X){
                cout << A << " " << B;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652