akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int H,W;
  scanf("%d%d",&H,&W);
  getchar();
  char wether[H][W + 1];
  int wether_interval[H][W];
  int cloud_pointer = 0;
  for(int h = 0; h < H; h++){
    fgets(wether[h], sizeof wether[h], stdin);
    getchar();
    cloud_pointer = -1;
    for(int i = 0; i < W; i++){
      if(wether[h][i] == 'c'){
        wether_interval[h][i] = 0;
        cloud_pointer = 0;
      }else if(cloud_pointer < 0){
        wether_interval[h][i] = -1;
      }else{
        cloud_pointer++;
        wether_interval[h][i] = cloud_pointer; 
      }
    }
  }

  for(int h = 0;h < H; h++){
    for(int w = 0; w < W; w++){
      printf("%d",wether_interval[h][w]);
      if(w < W - 1) printf(" ");
    }
    printf("\n");
  }
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 3005;

int n, t;
ii dat[N];
int dp[N][N];

void fillTable() {
	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j <= t-1; j++) {
			dp[i][j] = max(dp[i+1][j], dat[i].se + dp[i+1][min(t, j + dat[i].fi)]);
		}
	}
}

int main() {
	scanf("%d %d", &n, &t);
	for (int i = 0; i < n; i++) scanf("%d %d", &dat[i].fi, &dat[i].se);
	sort(dat, dat+n);
	fillTable();
	printf("%d\n", dp[0][0]);
	return 0;
}

Measured memory_bytes: 35456
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  for(a;a<b+1;a++)
    {
      if(c%a==0)d++;
    }
  printf("%d\n",d);
  return 0;
}


Measured memory_bytes: 2140
b=input()
num=0
m=0

for i in b:
    if(i=="A"):
        num+=1
    elif(i=="T"):
        num+=1
    elif(i=="G"):
        num+=1
    elif(i=="C"):
        num+=1
    else:
        num=0

    m=max(m,num)


print(m)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int m, d, ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> m >> d;
	for(Int i=4; i<=m; ++i){
		for(Int j=2; j<=9; ++j){
			if(i % j == 0){
				Int k = i / j;
				if(2 <= k && k <= 9 && 10 * j + k <= d)
					++ans;
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

num = input()
num = int(num) - 1

if 0 <= num <= 31:
    print(a[num])
else:
    pass


Measured memory_bytes: 3060
// ------------------------------------
// Date:2018/ 3/17
// Problem:A B S e.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, Z, W;
  cin >> N >> Z >> W;
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  ll tmp1, tmp2;
  tmp1 = tmp2 = 0ll;
  tmp1 = abs(a[N - 1] - W);
  if (N > 1) tmp2 = abs(a[N - 2] - a[N - 1]);
  ll ans = max(tmp1, tmp2);

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



Measured memory_bytes: 256
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e5 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

void solve()
{
    ll n , b;
    cin >> n >> b;
    ll cnt = 0;
    while(n)
    {
        n /= b;
        cnt ++;
    }
    print(cnt);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


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


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

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

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








int main(){
    ll n, x;
    cin >> n >> x;
    if(x == 1 || x == 2 * n - 1){
        cout << "No" << endl;
        return 0;
    }
    if(n == 2){
        cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
        return 0;
    }
    if(x == 2){
        vector<ll> ans(2 * n - 1);
        ans[n - 1] = x;
        ans[n] = x - 1;
        ans[n - 2] = x + 1;
        ans[n + 1] = x + 2;
        int c = 5;
        for(int i = 0; i < n - 2; i++){
            ans[i] = c++;
        }
        for(int i = n + 2; i < 2 * n - 1; i++){
            ans[i] = c++;
        }
        cout << "Yes" << endl;
        REP(i, 2 * n - 1){
            cout << ans[i] << endl;
        }
        return 0;
    }
    vector<ll> ans(2 * n - 1);
    ans[n - 1] = x;
    ans[n] = x + 1;
    ans[n - 2] = x - 1;
    ans[n + 1] = x - 2;
    int c = 1;
    for(int i = 0; i < n - 2; i++){
        if(c == x - 2){
            c += 4;
        }
        ans[i] = c++;
    }
    for(int i = n + 2; i < 2 * n - 1; i++){
        if(c == x - 2){
            c += 4;
        }
        ans[i] = c++;
    }
    cout << "Yes" << endl;
    REP(i, 2 * n - 1){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#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 ll;
typedef pair<ll, ll> mp;



int main(void){
	int N;
	ll a[300001],L[300001],R[300001],ans=LLONG_MIN;
	priority_queue<int, vector<int>, greater<int> > left;
	priority_queue <ll> right;
	cin>>N;
	reg(i,1,N){
		cin>>a[i];
		L[N]+=a[i];
		left.push(a[i]);
	}
	reg(i,N+1,N*2){
		cin>>a[i];
	}
	reg(i,N*2+1,N*3){
		cin>>a[i];
		R[2*N+1]+=a[i];
		right.push(a[i]);
	}
	reg(k,N+1,2*N){//まずLeftの処理
		if(left.top()<a[k]){
			L[k]=L[k-1]+a[k]-left.top();
			left.push(a[k]);
			left.pop();//選択中のN+1個の中で一番小さいやつを選択から除外
		}else{
			L[k]=L[k-1];//忘れるな
		}
	}
	ireg(k,N+1,2*N){//次にRightの処理
		if(right.top()>a[k]){
			R[k]=R[k+1]+a[k]-right.top();
			right.push(a[k]);
			right.pop();//選択中のN+1個の中で一番大きいやつを選択から除外
		}else{
			R[k]=R[k+1];
		}
	}
	reg(k,N,2*N){
		if(ans<L[k]-R[k+1])ans=L[k]-R[k+1];
		// cout<<"L["<<k<<"]="<<L[k]<<",R["<<k+1<<"]="<<R[k+1]<<endl;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;
  int k;
  cin >> k;
  int mas [n];
  int e= 0;
  for (int i = 0 ; i < n; i++){
    cin >> mas[i];
     if ( mas[i] >= k ) {
      e++; } 
  }
  cout << e << endl; }

Measured memory_bytes: 640
import sys
input=sys.stdin.readline

N,Y = map(int, input().split())

for i in range(N,-1,-1):
    for j in range(N-i,-1, -1):
        k = N-i-j
        y = i*10000 + j*5000 + k*1000
        if y == Y:
            print(i,j,k)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 3060
package main

import "fmt"

var n, k int
var ans float64

func main() {
  fmt.Scanf("%d%d", &n, &k)
  
  for i := 1; i <= n; i++ {
    p := 1/float64(n)
    if i >= k {
      ans += p
      continue
    }
    now := i
    for now < k {
      p /= 2
      now *= 2
    }
    ans += p
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

vector <int> edges[100005];

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

    int n;
    cin >> n;

    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    ll c[n];
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        sm += c[i];
    }

    sort(c, c+n, greater<ll>());
    sm -= c[0];

    queue <int> q;
    q.push(0);

    vector <ll> ans(n, 0);

    int idx = 0;
    while (q.size()) {
        int node = q.front();
        q.pop();

        if (ans[node] > 0) continue;

        ans[node] = c[idx];
        idx++;

        for (auto nxt : edges[node]) {
            if (ans[nxt] == 0) {
                q.push(nxt);
            }
        }
    }

    cout << sm << "\n";
    for (int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var (
		a, b, c int
		x, y    int
	)
	fmt.Scan(&a, &b, &c, &x, &y)

	ans := (a * x) + (b * y)
	for i := 0; i < min(x, y); i++ {
		ans = min(ans, ans-a-b+c*2)
	}

	switch {
	case x > y:
		for i := 0; i < (x - y); i++ {
			ans = min(ans, ans-a+c*2)
		}
	case x < y:
		for i := 0; i < (y - x); i++ {
			ans = min(ans, ans-b+c*2)
		}
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
import math

n = int(input())
leaves = list(map(int, input().split()))
leaves.insert(0, None)

for i in range(1, n+1):
  detail = ""
  detail += "node {0}: ".format(i)

  key = leaves[i]
  detail += "key = {0}, ".format(key)

  if i / 2 >= 1:
    detail += "parent key = {0}, ".format(leaves[i // 2])

  if 2 * i <= n:
    detail += "left key = {0}, ".format(leaves[2 * i])

  if (2*i+1) <= n:
    detail += "right key = {0}, ".format(leaves[2 * i + 1])

  print(detail)


Measured memory_bytes: 5680
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
  cin>>a>>b;
  if(a<b)
  {
for(int i=0;i<b;i++)
  cout<<a;
  }
  else if(a>b)
  {
for(int i=0;i<a;i++)
  cout<<b;
  }
  else
  {for(int i=0;i<a;i++)
    cout<<a;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)


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

    int diff_min = INT32_MAX;    
    for(int i = 0; i < s.length() - 2; i++){
        string sp;
        sp = s.substr(i, 3);
        int diff = abs(753 - stoi(sp));
        diff_min = min(diff, diff_min);
    }
    cout << diff_min << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int ans[123][123];
int main(){
  int n,m,k;
  scanf("%d %d %d",&n,&m,&k);
  vector<pair<int,int> >path;
  for(int i=0;i<n;i++){
    if(i%2==0)for(int j=0;j<m;j++)path.push_back({i,j});
    else for(int j=m-1;j>=0;j--)path.push_back({i,j});
  }
  int at=0;
  for(int i=1;i<=k;i++){
    int x;
    scanf("%d",&x);
    while(x--){
      ans[path[at].first][path[at].second]=i;
      at++;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      printf("%d ",ans[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 512
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            c = x - a - b
            if b < c <= n:
                count += 1
    print(count)



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int H[100100];

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

  std::cin >> N;

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

  H[0] -= 1;

  for(int i=1;i<N;++i){
      if(H[i-1] < H[i]){
          H[i] -= 1;
      }
  }

  bool ok = true;

  for(int i=1;i<N;++i){
      if(H[i-1] > H[i]){
          ok = false;
          break;
      }
  }

  if(ok){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 3");
            WillReturn.Add("1 2");
            WillReturn.Add("1 3");
            WillReturn.Add("2 3");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7 7");
            WillReturn.Add("1 3");
            WillReturn.Add("2 7");
            WillReturn.Add("3 4");
            WillReturn.Add("4 5");
            WillReturn.Add("4 6");
            WillReturn.Add("5 6");
            WillReturn.Add("6 7");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct JyoutaiDef
    {
        internal int CurrNode;
        internal HashSet<int> VisitedSet;
        //internal string Log;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int N = wkArr[0];

        bool[,] EdgeArr = new bool[N + 1, N + 1];

        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            EdgeArr[wkArr[0], wkArr[1]] = true;
        }

        var Stk = new Stack<JyoutaiDef>();
        JyoutaiDef WillPush;
        WillPush.CurrNode = 1;
        WillPush.VisitedSet = new HashSet<int>() { 1 };
        //WillPush.Log = "1";
        Stk.Push(WillPush);

        int AnswerCnt = 0;
        while (Stk.Count > 0) {
            JyoutaiDef Popped = Stk.Pop();

            //クリア判定
            if (Popped.VisitedSet.Count == N) {
                AnswerCnt++;
                //Console.WriteLine(Popped.Log);
                continue;
            }

            for (int I = 1; I <= N; I++) {
                //再訪不可
                if (Popped.VisitedSet.Contains(I)) continue;

                Action<int> PushSyori = (pNewNode) =>
                {
                    WillPush.CurrNode = pNewNode;
                    WillPush.VisitedSet = new HashSet<int>(Popped.VisitedSet);
                    WillPush.VisitedSet.Add(pNewNode);
                    //WillPush.Log = Popped.Log + "," + pNewNode.ToString();

                    Stk.Push(WillPush);
                };

                if (EdgeArr[Popped.CurrNode, I]) {
                    PushSyori(I);
                }
                if (EdgeArr[I, Popped.CurrNode]) {
                    PushSyori(I);
                }
            }
        }
        Console.WriteLine(AnswerCnt);
    }
}


Measured memory_bytes: 17628
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

ll sum(ll x){return x*(x+1)/2;}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    
    ll x;cin >> x;
    ll left=0,right=x;
    ll mid;
    while(left<right){
        mid = (left+right)/2;
        if(sum(mid)<x) left = mid+1;
        else right = mid;
    }
    cout << left << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(gcd(a,b),c)
print(ans)

Measured memory_bytes: 68676
#include <bits/stdc++.h>
using namespace std;
int main(){
  int y,m,d;
  char c1,c2;
  cin>>y>>c1>>m>>c2>>d;
    if(m>4){
      cout<<"TBD";
      return 0;
    }
    else{
      cout<<"Heisei";
      return 0;
    }
}


Measured memory_bytes: 256
n, d = map(int, input().split())

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

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        cnt = 0
        for y, z in zip(x[i], x[j]):
            cnt += abs(y-z)**2
        if cnt ** 0.5 % 1 == 0:
            ans += 1

print(ans)


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

using namespace std;

int main() {
    int n;
    cin>>n;
    int x=n%10;
    if(x==2||x==4||x==5||x==7||x==9)
    cout<<"hon"<<endl;
    else if(x==0||x==1||x==6||x==8)
    cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
}

Measured memory_bytes: 3636
def get_num(n, x):
    ans = 0
    for n3 in xrange(min(n, x - 3), (x + 2) / 3, -1):
        for n2 in xrange(min(n3 - 1, x - n3 - 1), (x - n3) / 2, -1):
            if n3 + min(n2 - 1, x - n3 - n2):
                ans += 1
    return ans


data = []
while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    # if x < 3:
    #     print(0)
    # else:
    print(get_num(n, x))

Measured memory_bytes: 6420
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int_fast32_t i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int_fast32_t i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int SZ = 1e4;

// 約数の個数 (１の倍数＋２の倍数＋３の倍数＋...)
template <int N> struct Approx {
    int d[N + 1] = {0};
    constexpr Approx() : d() {
        for (int_fast64_t i = 1; i <= N; ++i) {
            for (int_fast64_t j = i; j <= N; j += i)
                d[j]++;
        }
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    constexpr auto ap = Approx<SZ>();
    int ans = 0;
    for (int i = 105; i <= N; i += 2) {
        ans += (ap.d[i] == 8);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
 
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
#nの中の要素数からmの中の要素数を引いたものと0のうち大きい方を出力


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

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    long ans = 0;
    for (int i = 0; i < n-k; i++)
    {
        ans += (long)h[i];
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

vector <int> v;


bool isPrime(int a){
    bool res=1;
    for (int i=2;i*i<=a;i++){
        if (a%i==0) res=0;
    }

    return res;
}

int fak(int t,int a){
    int res=0;
    int kal=a;
    while (t/a>0){
        res+=t/a;
        a*=kal;
    }

    return res+1;
}

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

    int n;
    cin >> n;

    for (int i=2;i+i<=n;i++){
        if (isPrime(i)){
            int tm=fak(n,i);
        //    cerr << i << " " << tm << el;
            if (tm>2) v.pb(tm);
        }
    }

    int len=v.size();
    ll cnt=0;

    for (int i=0;i<len-1;i++){
        for (int j=i+1;j<len;j++){
            for (int k=0;k<len;k++){
                if (k==i || k==j) continue;

                if (v[i]>=5 && v[j]>=5 && v[k]>=3) cnt++;
            }
        }
    }

    for (int i=0;i<len;i++){
        for (int j=0;j<len;j++){
            if (i==j) continue;
            if (v[i]>=25 && v[j]>=3) cnt++;
            if (v[i]>=15 && v[j]>=5) cnt++;
        }
    }

    for (int i=0;i<len;i++){
        if (v[i]>=75) cnt++;
    }

    cout << cnt << el;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
	string s;
	int n,i;
	i = 0;
	cin >> s;
	while (s[i] != '\0') {
		i++;
	}
	i--;
	int a, b;
	a = 0; b = i;
	while (s[a] != 'A') {
		a++;
	}
	while (s[b] != 'Z') {
		b--;
	}
	cout << b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int f[105],a[105],t[105],x[105],y[105];
int sq(int x){return x*x;}
int main()
{
	int N;
	scanf("%d",&N);
	rep(i,N)scanf("%d %d %d %d %d",&f[i],&a[i],&t[i],&x[i],&y[i]);
	int ans[2]={-1,-1},mt[2]={INF,INF};
	rep(i,N-1)
	{
		if(t[i]==t[i+1]&&a[i]!=a[i+1])
		{
			ans[t[i]] = max(ans[t[i]],sq(x[i+1]-x[i])+sq(y[i+1]-y[i]));
		}
	}
	rep(i,N-1)
	{
		if(t[i]==t[i+1]&&a[i]!=a[i+1])
		{
			if(sq(x[i+1]-x[i])+sq(y[i+1]-y[i])==ans[t[i]])
			{
				mt[t[i]] = min(mt[t[i]],f[i+1]-f[i]);
			}
		}
	}
	rep(i,2)
	{
		if(ans[i]==-1)printf("-1 -1\n");
		else printf("%.12f %.12f\n",sqrt(ans[i]),mt[i]/60.0);
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
using namespace std;

int A[500005],T[500005];
int n,sum=0;

int meso(int *A,int *T,int x,int y){
	int m=x+(y-x)/2;
	int p=x,q=m+1,i=x;
	if(y-x>1){
		//i zong pleft qriht
		meso(A,T,x,m);
		meso(A,T,q,y);
	}
		while(i<=y){
		if(y!=x) sum++;
		if(q>y||(A[p]<=A[q]&&p<=m)) 
		T[i++]=A[p++];
		else 
		T[i++]=A[q++];
	}
	    for(int j=x;j<=y;j++){
	    	A[j]=T[j];
	    }
	    
}

int main(){
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>A[i];
	}
	meso(A,T,1,n);
	for(int k=1;k<=n-1;k++)
	cout<<A[k]<<" ";
	cout<<A[n]<<endl;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 6888
#include<stdio.h>
int main(void){
	int a,b,c,d,e,k;
	scanf("%d\n%d\n%d\n%d\n%d\n%d\n",&a,&b,&c,&d,&e,&k);
	if(e-a<=k){
		printf("Yay!\n");
	}else{
		printf(":(\n");
	}
	return 0;
}

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

int main(){
  int N;
  int K;
  cin >>N>>K;
  int count=0;
  int h;
  for(int i=0;i<N;i++){cin >>h;
      if(h>=K){count++;}}
  
  cout <<count<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()

seq = 0
pre = ""
lr_num = []
for i in s:
    if i == pre:
        seq += 1
    else : 
        pre = i
        lr_num.append(seq)
        seq = 0
lr_num.append(seq)
lr_sum = sum(lr_num)
lr_len = len(lr_num)-1
if lr_len%2 == 1:
    print(lr_sum + 2*min(k,lr_len//2))
else:
    if k >= lr_len//2:
        print(lr_sum + 2*lr_len//2 -1 )
    else:
        print(lr_sum + 2*k)

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, x=0;
	cin >> n;
	vi a(n+2);
	a.pb(0);
	REP(i, 1,n+1) {
		cin >> a[i];
		x += abs(a[i - 1] - a[i]);
	}
	a.pb(0);
	x += abs(a[n]);
	//cout << x << endl;
	/*rep(i, n + 2)
		cout << a[i] << endl;*/
	REP(i, 1, n + 1) {
		ll ans = x;
		ans -= abs(a[i - 1] - a[i]);
		//cout << abs(a[i - 1] - a[i]) << endl;
		ans -= abs(a[i] - a[i+1]);
		//cout << abs(a[i] - a[i + 1]) << endl;
		ans += abs(a[i - 1] - a[i + 1]);
		//cout << abs(a[i - 1] - a[i + 1]) << endl;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1656
//
//  Sorting_Three_Numbers.c
//  AOJ
//
//  Created by admin on 2014/07/12.
//
//

#include <stdio.h>

void swap(int *,int *);

main()
{
    int a,b,c;
    int memory;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a > b){
        swap(&a,&b);
    }
    
    if(b > c){
        swap(&b,&c);
    }
    
    if(a > b){
        swap(&a,&b);
    }
    
    printf("%d %d %d\n",a,b,c);
    
    return 0;
    
}

void swap(int *a, int *b)
{
    int memory;
    
    memory = *b;
    *b = *a;
    *a = memory;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    ll T = 0;  // 現在予選の通過が確定した参加者
    ll U = 0;  // 海外の学生
    for (int i = 0; i < N; i++) {
        int s = S[i] - 'a';
        bool yes = true;
        if (s == 0 && T < A + B) {
            T++;
        } else if (s == 1 && T < A + B && U < B) {
            T++;
            U++;
        } else
            yes = false;

        if (yes)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i=0; i<N; i++) cin >> x.at(i);
    int sum=0;
    for (int i=0; i<N; i++) {
        sum += min(x.at(i), abs(K-x.at(i)))*2;
    }
    cout << sum << "\n";
}

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

using namespace std;
typedef long long ll;

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

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
    FOR(i, 1, n + 1)
    cin >> t[i] >> x[i] >> y[i];
    bool res = true;
    REP(i, n)
    {
        ll dt = t[i + 1] + t[i];
        ll dx = abs(x[i + 1] - x[i]);
        ll dy = abs(y[i + 1] - y[i]);
        if (dt < dx + dy)
        {
            // 制限時間内に到達不可能
            res = false;
            break;
        }
        if (dt % 2 != (dx + dy) % 2)
        {
            // 余った時間で(x, y)と(x + 1, y)の間を往復不可
            res = false;
            break;
        }
    }
    cout << (res ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt()
	fInit(N)
	for i := 1; i <= N; i++ {
		fmt.Printf("%d\n", f(i))
	}
}

var fAns []int

func fInit(n int) {
	fAns = make([]int, n+1)
	nsqrt := int(math.Sqrt(float64(n)))
	for x := 1; x < nsqrt; x++ {
		for y := 1; y < nsqrt; y++ {
			for z := 1; z < nsqrt; z++ {
				ans := x*x + y*y + z*z + x*y + y*z + z*x
				if ans <= n {
					fAns[ans]++
				}
			}
		}
	}
}

func f(n int) int {
	return fAns[n]
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2308
#include<cstdio>
using namespace std;
#define N 300500
#define mod 1000000007
int n,p[N],su[N],v[N],su1[N],as,as1,tr[N],lb[N],tr2[N],rb[N],tr3[N];
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
void add(int x,int k){for(int i=x;i<=n;i+=i&-i)tr[i]=(tr[i]+k)%mod;}
int que(int x){int as=0;for(int i=x;i;i-=i&-i)as=(as+tr[i])%mod;return as;}
void add2(int x,int k){for(int i=x;i<=n;i+=i&-i)tr2[i]+=k;}
int que2(int x){int as=0;for(int i=x;i;i-=i&-i)as+=tr2[i];return as;}
void add3(int x,int k){for(int i=x;i<=n;i+=i&-i)tr3[i]=(tr3[i]+k)%mod;}
int que3(int x){int as=0;for(int i=x;i;i-=i&-i)as=(as+tr3[i])%mod;return as;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]),su[p[i]]++;
	for(int i=n-1;i>=1;i--)su[i]=su[i+1]+su[i]-1;
	as=1;
	for(int i=1;i<=n;i++)as=1ll*as*su[i]%mod;
	if(!as){printf("0\n");return 0;}
	lb[0]=1;
	for(int i=1;i<=n;i++)
	{
		v[i]=1ll*(su[i]-1)*pw(su[i],mod-2)%mod;
		su1[i]=v[i];if(su1[i-1])su1[i]=1ll*su1[i]*su1[i-1]%mod;
	}
	for(int i=n;i>=1;i--)if(v[i+1])rb[i]=rb[i+1];else rb[i]=i;
	for(int i=1;i<=n;i++)if(v[i-1])lb[i]=lb[i-1];else lb[i]=i;
	for(int i=1;i<=n;i++)
	{
		int su11=que(p[i])-que(lb[p[i]]-1),su2=que2(p[i])-que2(lb[p[i]]-1);
		as1=(as1+1ll*as*su11%mod*su1[p[i]]%mod*(mod+1)/2)%mod;
		su11=que3(rb[p[i]])-que3(p[i]),su2=que2(n)-que2(p[i]);
		as1=(as1+1ll*as*su2%mod-1ll*as*su11%mod*pw(su1[p[i]],mod-2)%mod*(mod+1)/2%mod)%mod;
		add(p[i],pw(su1[p[i]]?su1[p[i]]:1,mod-2)),add2(p[i],1);add3(p[i],su1[p[i]]);
	}
	printf("%d\n",(as1+mod)%mod);
}//

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e14
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void p(T x){cout << x << endl;}
template<class T>void pvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int v, e; cin >> v >> e;
    ll d[v][v];
    rep(i, v) rep(j, v) d[i][j] = INF;
    rep(i, v) d[i][i] = 0;

    ll from, to, cost;
    rep(i, e){
        cin >> from >> to >> cost;
        d[from][to] = cost;
    }

    rep(k, v){
        rep(i, v){
            rep(j, v){
                if(d[i][k]==INF || d[k][j]==INF) continue;
                chmin(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    
    rep(i, v){
        if(d[i][i] < 0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    rep(i, v){
        rep(j, v){
            if(d[i][j] != INF) cout << d[i][j];
            else cout << "INF";
            if(j!=v-1) cout << " ";
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
ll dp[1<<21][21];
bool mat[21][21];

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline ll solve(int n,int mask,int idx)
{
        //cerr<<idx<<" "<<mask<<endl;
    if(mask==(1<<n)-1) return 1;
    if(idx==-1) return 0;
    if(dp[mask][idx]!=-1) return dp[mask][idx];
    ll temp=0;
    rep(i,0,n){
        if(!mat[i][idx] || (mask&(1<<i))!=0) continue;
        else temp+=solve(n,mask|(1<<i),idx-1);
    }
    return dp[mask][idx]=temp%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    rep(i,0,n){
        rep(j,0,n) cin>>mat[i][j];
    }
    fill(dp,-1); cout<<solve(n,0,n-1)<<endl;
}

Measured memory_bytes: 344320
# 黒がある行と列を把握すればいい。
def ch(info,w): #もらったリストに黒が入ってるかを確認
    c=0
    for i in range(w):
        if info[i]=="#":
            c=1
            break
    return c

h,w=map(int,input().split())
info=[]
black=[]
hl=0
for i in range(h):
    s=list(input())
    if ch(s,w)==1:
        info.append(s)
        hl+=1
#print(info)
for i in range(hl):
    for j in range(w):
        if info[i][j]=="#":
            black.append(j)
for i in range(hl):
    for j in range(w):
        if j in black:
            print(info[i][j],end="")
    print("\n")

Measured memory_bytes: 4596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int


int solve( ){
 

 string s;
 cin>>s;
 int len=s.size();
 int z=0,o=0;
 rep(i,0,len)
 {
  if(s[i]=='1')o++;
  else z++;
 }
 cout<<min(2*z,2*o);



return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int *arr;
    int length;
    int capacity;
} Vector;

Vector *initVector() {
    Vector *v = (Vector*)malloc(sizeof(Vector));
    v->arr = (int*)malloc(sizeof(int)*10);  // initial capacity of vector is 10
    v->length = 0;                          // amount of elements
    v->capacity = 10;
    return v;
}

void disposeVector(Vector *v) {
    if (v != NULL) {
        if (v->arr != NULL) {
            free(v->arr);
        }
        free(v);
    }
}

void pushBack(Vector *v, int x) {
    if (v->length == v->capacity) {
        v->capacity += 10;
        v->arr = (int*)realloc(v->arr,sizeof(int)*(v->capacity));
    }
    v->arr[v->length++] = x;
}

void randomAccess(Vector *v, int p) {
    printf("%d\n",v->arr[p]);
}

void popBack(Vector *v) {
    --v->length;
}

int main() {
    int q;
    int op; // number of operation
    int input;
    Vector *v = initVector();
    scanf("%d",&q);
    while (q--) {
        scanf("%d",&op);
        switch (op) {
            case 0:     // pushBack(input)
                scanf("%d",&input);
                pushBack(v,input);
                break;
            case 1:     // randomAccess(input)
                scanf("%d",&input);
                randomAccess(v,input);
                break;
            default:    // op == 2, popBack()
                popBack(v);
        }
    }
    return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    int n,m;
    cin>>n>>m;
    cout<<(((n*(n-1))/2)+((m*(m-1))/2));
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    double n,d,ans=0,i,tmp;
    cin >> n >> d;
    vector<double> x(n);
    vector<double> y(n);
    
    for(i=0;i<n;i++){
        cin >> x.at(i) >> y.at(i);
        tmp=x.at(i)*x.at(i)+y.at(i)*y.at(i);
        if(tmp<0){
            tmp=(-tmp);
        }
        tmp = sqrt(tmp);
        if(tmp<=d){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 6484
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll i,j,k,n,m,p,ans=1;
ll Pow(ll n,ll m){
    ll ans=1;
    while(m>1){
        if(m%2==0){
            m/=2;
            n=n*n;
        }else{
            ans=ans*n;
            m/=2;
            n=n*n;
        }
    }
    return n*ans;
}
int main(){
    cin>>p>>n;
    if(p==1){
        cout<<n<<endl;
        return 0;
    }
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    ll ans=(ll)pow((double)n,(double)(1.0/p));
    for(i=ans+1;i>=2;i--){
        ll k=Pow(i,p);
        if(k>0 && n%k==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

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

int main()
{
    string t, h;
    int n, tp = 0, hp = 0;

    cin >> n;

    while (n-- && cin >> t >> h) {
        int i = 0;
        for (;t[i] && h[i] && t[i] == h[i]; i++)
            ;
        if (t[i] == h[i])
            tp++, hp++;
        else if (t[i] > h[i])
            tp += 3;
        else
            hp += 3;
    }

    cout << tp << " " << hp << endl;

    return 0;
}



Measured memory_bytes: 3164
a = [int(s) for s in input().split()]
if a[0] < 0:
  b = abs(a[0]) // a[2]
  c = a[0] + a[2] * int(b)
  d = int(c) + a[2]
  if a[1] <= int(b) or a[1] == int(b) + 1:
    print(abs(a[0] + a[1] * a[2]))
  else:
    if abs(int(c)) < abs(int(d)):
      if (a[1] - int(b)) % 2 == 0:
        print(abs(c))
      else:
        print(abs(d))
    else:
      if (a[1] - int(b) - 1) % 2 == 0:
        print(abs(d))
      else:
        print(abs(c))
else:
  b = a[0] // a[2]
  c = a[0] - a[2] * int(b)
  d = int(c) - a[2]
  if a[1] <= int(b) or a[1] == int(b) + 1:
    print(abs(a[0] - a[1] * a[2]))
  else:
    if abs(int(c)) < abs(int(d)):
      if (a[1] - int(b)) % 2 == 0:
        print(abs(c))
      else:
        print(abs(d))
    else:
      if (a[1] - int(b) - 1) % 2 == 0:
        print(abs(d))
      else:
        print(abs(c))

Measured memory_bytes: 9216
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;




int main(){
    ll x,y;cin>>x>>y;
    int ans=0;
    while(x<=y){
        ans++;
        x=x*2;
    }
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
using namespace std;
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int main(){
  int N; cin>>N;
  vector<double> x(N);
  vector<double> y(N);
  vector<int> tmp(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i);
    tmp.at(i)=i;
  }

  double ans=0.0;
  int i =0;
  do{
    double tans = 0.0;
    for(int i=0;i<N-1;i++){
      int z = tmp.at(i);
      int z2 = tmp.at(i+1);
      ans += pow(pow(x.at(z)-x.at(z2),2.0)+pow(y.at(z)-y.at(z2),2.0),0.5);
    }
  }while(next_permutation(tmp.begin(), tmp.end()));

  cout<< setprecision(11) <<ans/facctorialMethod(N)<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
int R,G,B,N;
  cin>>R>>G>>B>>N;
  
  int ans=0;
  for(int i=0;i<=N/R;i++){
    int a=N-i*R;
  for(int j=0;j<=a/G;j++){
  if((a-G*j)%B==0)
    ans++;
  
  }
 }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
from itertools import permutations
count = 0
dist = 0
for l in list(permutations(xy)):
    tmp = 0
    for i in range(len(l)-1):
        tmp += ((l[i+1][0]-l[i][0])**2+(l[i+1][1]-l[i][1])**2)**0.5
    dist += tmp
    count += 1

print(dist/count)



Measured memory_bytes: 13908
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

struct Node
{
  int value;
  Node *left, *right;
};

Node *root = NULL;

void insert(int key)
{
  Node *x = root;
  Node *y = NULL;
  Node *in = new Node;
  in->value = key;
  in->left = in->right = NULL;
  while (x != NULL)
  {
    y = x;
    if (x->value > key)
    {
      x = x->left;
    }
    else if (x->value < key)
    {
      x = x->right;
    }
  }

  if (y == NULL) root = in;
  else
  {
    if (y->value > key) y->left = in;
    else if (y->value < key) y->right = in;
  }
}

bool search(int key)
{
  Node *p = root;
  while (p != NULL)
  {
    if (p->value == key)
    {
      return true;
    }
    else if (p->value > key)
    {
      p = p->left;
    }
    else p = p->right;
  }
  return false;
}

void inorder(Node *t)
{
  if (t == NULL) return;
  inorder(t->left);
  printf(" %d", t->value);
  inorder(t->right);
}

void preorder(Node *t)
{
  if (t == NULL) return;
  printf(" %d", t->value);
  preorder(t->left);
  preorder(t->right);
}

int main()
{
  int n, x;
  string com;
  scanf("%d", &n);

  while (n--)
  {
    cin >> com;
    if (com == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if (com == "print")
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (com == "find")
    {
      scanf("%d", &x);
      if (search(x)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



Measured memory_bytes: 15712
N = int(input())
n = list(map(int, input().split()))

fourEven = 0
odd = 0
otherEven = 0
for num in n:
    if num % 4 == 0:
        fourEven += 1
    elif num % 2 == 1:
        odd += 1
    else:
        otherEven += 1

# print(len(n) == fourEven + otherEven + otherEven)

if len(n) // 2 <= fourEven:
    print('Yes')
elif odd <= fourEven:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
bingo = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

A = []
for _ in range(3):
	A.extend(list(map(int, input().split())))
N = int(input())
B = [int(input()) for i in range(N)]

C = [0 for _ in range(9)]
for bb in B:
	for i, aa in enumerate(A):
		if aa == bb:
			C[i] = 1

for bi in bingo:
	if C[bi[0]] == C[bi[1]] == C[bi[2]] == 1:
		print("Yes")
		exit(0)
print("No")


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

bool Prime_Number( int n )
{
    for( int i = 2; i <= sqrt(n); i++ )
    {
        if( n % i == 0 )
            return false;
    }
    return true;
}

void Prime_Factorize( int n )
{
    if( Prime_Number(n) == true )
    {
        cout << " " << n << endl;
        return;
    }
    else
    {
        for( int i = 2; i <= n; i++ )
        {
            if( n % i == 0 )
            {
                cout << " " << i;
                Prime_Factorize( n / i );
                return;
            }
        }
    }
}

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

    cout << n << ":";
    Prime_Factorize(n);

    return 0;
}


Measured memory_bytes: 3136