akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  b = B[i]
  if A[i] >= b:
    ans += b
  else:
    br = b - A[i]
    ans += A[i]
    if A[i + 1] >= br:
      ans += br
      A[i + 1] -= br
    else:
      ans += A[i + 1]
      A[i + 1] = 0
      
print(ans)

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int A[3][3];
    REP(i, 3) {
        REP(j, 3) {
            cin >> A[i][j];
        }
    }
    int N; cin >> N;
    bool bingo[3][3];
    fill(bingo[0], bingo[3], 0);
    REP(n, N) {
        int b; cin >> b;
        REP(i, 3) {
            REP(j, 3) {
                if(A[i][j] == b) {
                    bingo[i][j] = true;
                }
            }
        }
    }
    bool is_bingo = false;
    REP(i, 3) {
        if ((bingo[i][0] && bingo[i][1] && bingo[i][2]) ||
            (bingo[0][i] && bingo[1][i] && bingo[2][i])) {
            is_bingo = true;
        }
    }
    if ((bingo[0][0] && bingo[1][1] && bingo[2][2]) ||
        (bingo[0][2] && bingo[1][1] && bingo[2][0])) {
        is_bingo = true;
    }
    cout << ((is_bingo) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3540
/* ***********************************************
Author        :axp
Created Time  :2016/9/11 20:08:36
TASK		  :B.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
int n[3];
string s[3];
int T;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    for(int i=0;i<3;i++)cin>>s[i];
	int now=0;
	for(;;)
	{
		if(n[now]==s[now].size())
		{
			putchar('A'+now);
			putchar(10);
			return 0;
		}
		now=s[now][n[now]++]-'a';
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std; 
int main(){
	int N; 
	cin >> N; 
	int A[110][110] = {}; 
	for(int i = 1; i <= N; i++){
		int H; 
		cin >> H; 
		for(int j = 1; j <= H; j++){
			A[i][j] = 1; 
		}
	}
	int count = 0; 
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= 100; j++){
			if(A[i-1][j] == 0 && A[i][j] == 1){
				count ++; 
			}
		}
	}
	cout << count << endl; 
}

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

int main() {
	int N;
	cin >> N;
	double bumbo = 0;
	for (int i = 0; i < N; i++) {
		double A;
		cin >> A;
		bumbo += 1.0 / A;
	}
	printf("%f\n",1.0 / bumbo);

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int h, n;
    cin >> h >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i] ;
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += A[i];
    }

    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val k = readInt()
    val s = read()

    if (s.length <= k) {
        println(s)
        return
    }

    println(s.substring(0, k) + "...")

}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 34472
n=int(input())
f=lambda x:sorted([list(map(int,input().split())) for _ in range(n)],key=lambda k:k[x])
r,b=f(1)[::-1],f(0)
a=0
for c,d in b:
  for l in r:
    if c>l[0] and d>l[1]: r.remove(l); a+=1; break
print(a)

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

#define N 36

typedef struct {
    char mark;
    int number;
} Card;

void print(Card *, int);

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

    int n;
    cin>>n;  //データの数の入力
    Card list1[N], list2[N];
    for(int i = 0; i < n; i++) {
        cin>>list1[i].mark>>list1[i].number; //データの入力
        list2[i] = list1[i];
    }
    
    Card temp;
    
    //バブルソート
    for(int i = 0; i < n; i++) {
        for(int j = n-1; j > i; j--) {
            if(list1[j].number < list1[j-1].number) {
                temp = list1[j-1]; //入れ替えのための値保持
                list1[j-1] = list1[j];
                list1[j] = temp;
            }
        }
    }
    
    print(list1, n);
    cout<<"Stable"<<endl;
    
    //選択ソート
    for(int i = 0; i < n-1; i++) {
        int min = i;
            for(int j = i+1; j < n; j++) {
            if(list2[min].number > list2[j].number) min = j;
        }
        if(min != i) {
            temp = list2[min]; //入れ替えのための値保持
            list2[min] = list2[i];
            list2[i] = temp;
        }
    }
    
    print(list2, n);
    
    for (int i = 0; i < n; i++) {
        if(list1[i].mark != list2[i].mark) {
            cout<<"Not stable"<<endl;
            return 0;
        }
    }
    cout<<"Stable"<<endl;
    return 0;
}

void print(Card *list, int n) {
    //出力
    for(int i = 0; i < n-1; i++) cout<< list[i].mark << list[i].number <<' ';
    cout<< list[n-1].mark << list[n-1].number <<endl;
}



Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<utility>
using namespace std;

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

    vector<int> ans;
    for(int i = 0 ; i <= w ; ++i){
        ans.emplace_back(i);
    }

    for(int i = 0 ; i < n ; ++i){
        int a, b;
        char c;
        cin >> a >> c >> b;
        swap(ans[a], ans[b]);
    }

    for(int i = 1 ; i <= w ; ++i){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>

void MaxH(int *,int);

void BMax(int *);

int n;

int main()
{
  int i;

  scanf("%d",&n);

  int A[n+1];

  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
    }

  BMax(A);

  for(i=1;i<=n;i++)printf(" %d",A[i]);


  printf("\n");
  
  return 0;
}

void MaxH(int *A,int i)
{
  int L,R,lg,koukan;

  L=2*i;
  R=2*i+1;

  if(L<=n&&A[L]>A[i])lg=L;
  else lg=i;

  if(R<=n&&A[R]>A[lg])lg=R;

  if(lg!=i)
    {
      koukan=A[i];
      A[i]=A[lg];
      A[lg]=koukan;

      MaxH(A,lg);
    }
}

void BMax(int *A)
{
  int i;
  for(i=n/2;i>=1;i--)
    {
      MaxH(A,i);
    }
}



Measured memory_bytes: 3756
#include <stdio.h>
#include <string.h>
void init(char W[][11],int N);
int judge(char W[][11],int N);
int main(){
  int N;
  char W[100][11];
  int i;

  scanf("%d",&N);
  init(W,N);

  if(judge(W,N))printf("No\n");
  else printf("Yes\n");

  return 0;
}

void init(char W[][11],int N){
  for(int i=0;i<N;i++){
    scanf("%s",W[i]);
  }
}

int judge(char W[][11],int N){
  int i,j;
  printf("\n");
  for(i=1;i<N;i++){
    if(W[i-1][strlen(W[i-1])-1]!=W[i][0])
      return 1;
    else for(j=0;j<i;j++)if(strcmp(W[i],W[j])==0)return 1;
  }
  return 0;
}

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

int main(){    
    vector<int> front(21, 0);
    vector<int> side(21, 0);
    while(1){
        int w, d, tmp, ans = 0;
        cin >> w >> d;
        if(w == 0){
            break;
        }
        front.assign(21, 0);
        side.assign(21, 0);
        for(int i = 0; i < w; ++i){
            cin >> tmp;
            ++front[tmp];
        }
        for(int i = 0; i < d; ++i){
            cin >> tmp;
            ++side[tmp];
        }
        for(int i = 20; i > 0; --i){
            ans += max(front[i], side[i]) * i;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3044
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
  
using namespace std;

int solve(vector<int>& v, int k, int start, int last) {
	int n = v.size();
	if (n == 0) return last;
	int next = (start+k+n-1)%n;
	last = v[next];
	v.erase(v.begin()+next);
    return solve(v, k, next, last);
}
int main()
{
    int n, k, m;
    int numarray[10001];
    while(1){
        cin >> n >> k >> m;
        if(n == 0 && k == 0 && m == 0) break;
        vector<int> v;
        for(int i = 0; i < n; i++){
            if (i != m-1) v.push_back(i+1);
        }
        // numarray = {0, 1, 2, 3, 4, 5, ...}
        int ans;
        ans = solve(v, k, m-1, m);
        cout << ans << endl;
    }
}
 

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A + B > C + D) {
        cout << "Left" << endl;
    } else if(A + B < C + D) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}


Measured memory_bytes: 3580
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll INF = 1e18 + 10 ; 
int main(){
    fastio
    string s ; 
    cin >> s ; 
    int n = (int) s.size() ;
    for(int i = 0; i < n; i++){
        if ( i + 1 < n && s[i] == s[i + 1] ){
            return cout << i + 1 << ' ' << i + 2 << endl , 0 ;
        }
        if ( i + 2 < n && s[i] == s[i + 2] ){
            return cout << i + 1 << ' ' << i + 3 << endl , 0 ;
        }
    }
    cout << -1 << ' ' << -1 << endl;
    return 0 ;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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 (a>b) { a=b; return 1; } return 0; }
const ll LINF = 1e18;

int main()
{
  int H, W; cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  REP(h, H) REP(w, W) cin >> A[h][w];

  vector<vector<bool>> visit(H, vector<bool>(W, false));
  visit[0][0] = visit[H-1][W-1] = true;

  int h = 0, w = 0;
  while (!(h == H-1 && w == W-1)) {
    if (h+1 < H && A[h+1][w] == '#') {
      h++;
      visit[h][w] = true;
    } else if (w+1 < W && A[h][w+1] == '#') {
      w++;
      visit[h][w] = true;
    } else {
      cout << "Impossible" << endl;
      return 0;
    }
  }

  REP(h, H) REP(w, W) {
    if (A[h][w] == '#' && !visit[h][w]) {
      cout << "Impossible" << endl;
      return 0;
    }
  }

  cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x >= 400 && x <=599){
    cout << "8\n";
  }else if(x >= 600 && x <= 799){
    cout << "7\n";
  }else if(x >= 800 && x <= 999){
    cout << "6\n";
  }else if(x >= 1000 && x <= 1199){
    cout << "5\n";
  }else if(x >= 1200 && x <= 1399){
    cout << "4\n";
  }else if(x >= 1400 && x <= 1599){
    cout << "3\n";
  }else if(x >= 1600 && x <= 1799){
    cout << "2\n";
  }else if(x >= 1800 && x <= 1999){
    cout << "1\n";
  }
}

Measured memory_bytes: 3632
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef long double ld;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define ui(n) ((unsigned int)(n))
#define LL(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((long double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const LL LINF=4557430888798830399;
const ld eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

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

const int maxn=1000010;

int n,m,K,sx,sy,tx,ty;

int main()
{
	cin>>n>>m>>K>>sx>>sy>>tx>>ty;
	
	vector<string> str(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>str[i];
		str[i]=" "+str[i];
	}

	vector<vector<int> > dist(n+1,vector<int>(m+1,INF));

	queue<pair<int,int> > q;
	q.push({sx,sy});
	dist[sx][sy]=0;

	while(!q.empty())
	{
		int x=q.front().fs,y=q.front().sc;q.pop();

		for(int k=0;k<4;k++) for(int l=1;l<=K;l++)
		{
			int cx=x+dx[k]*l,cy=y+dy[k]*l;
			if(cx<1||cx>n||cy<1||cy>m||str[cx][cy]=='@'||dist[x][y]+1>dist[cx][cy]) break;
			
			if(dist[x][y]+1<dist[cx][cy])
			{
				dist[cx][cy]=dist[x][y]+1;
				q.push({cx,cy});
			}
		}
	}

	cout<<(dist[tx][ty]==INF?-1:dist[tx][ty]);

	return 0;
}

Measured memory_bytes: 16044
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8;
 
ll a[5];
int main(){
	ll n;
	cin>>n;
	for(ll i=0; i<n; i++){
		string s;
		cin>>s;
		if(s[0]=='M') a[0]++;
		else if(s[0]=='A') a[1]++;
		else if(s[0]=='R') a[2]++;
		else if(s[0]=='C') a[3]++;
		else if(s[0]=='H') a[4]++;
	}
	
	for(ll i=0; i<5; i++){
		for(ll j=i+1; j<5; j++){
			for(ll k=j+1; k<5; k++){
				ans += a[i]*a[j]*a[k];
			}
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
import sys
from itertools import accumulate
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
SA = sum(A)
CA = list(accumulate(A))
ans = float('inf')
for ca in CA:
    b = SA - ca
    ans = min(ans, abs(b - ca))
print(ans)

Measured memory_bytes: 92368
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <queue>
#include <cassert>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::swap;
using std::sort;
using std::vector;
using std::string;
using std::min;
using std::max;
using std::pair;
using std::set;
using std::map;


typedef long long ll;
const int MAXN = 100005;
const int INF = 1000000009;

vector<vector<int>> g;

int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v; --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }


    vector<int> q;
    for (int i = 0; i < g[0].size(); ++i) {
        q.push_back(g[0][i]);
    }

    for (auto v: q) {
        for (int u: g[v]) {
            if (u == n - 1) {
                cout << "POSSIBLE";
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 12784
S=input()
N=len(S)
c=[1]*N
for i in range(N-1):
  if S[i]=='R' and S[i+1]=='R':
    c[i+2]+=c[i]
    c[i]=0
    
for i in range(N-1, 1, -1):
  if S[i]=='L' and S[i-1]=='L':
    c[i-2]+=c[i]
    c[i]=0
    
print(' '.join(map(str, c)))

Measured memory_bytes: 10484
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u32 = itr.next().unwrap().parse().unwrap();
    let m: u32 = itr.next().unwrap().parse().unwrap();

    //
    // (1 / 2) ^ mで終了
    println!("{}", (1900 * m + (n - m) * 100) * (1 << m));
}


Measured memory_bytes: 2048
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    forn (i, 1, sz(s)) {
        if (s[i] == s[i - 1]){
            return cout << i << " " << i + 1, 0;
        }
    }
    forn (i, 2, sz(s)) {
        if (s[i - 2] == s[i]) {
            return cout << i - 1 << " " << i + 1, 0;
        }
    }
    cout << "-1 -1";
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    string s;
    cin >> s;
    int l = s.size();
    string d = "";
    rep(i,l-1){
        if(s.substr(i,2)=="BC"){
            s[i+1]='D';
            continue;
        }
        d += s[i];
    }
    d += s[l-1];
    ll ans = 0;
    int d_l = d.size();
    int cnt = 0;
    rep(i,d_l){
        if(d[i]=='A'){
            cnt++;
        }
        else if(d[i]=='D'){
            ans += cnt;
        }
        else{
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

typedef pair<int,int> P;

int main(){
	int N;
	while(cin >> N, N){
		vector<P> v;
		int ans=0, sum=0, mx=0;
		bool dp[1005][1005] = {0};
		dp[0][0] = true;
		rep(i,N){
			int r, w;
			cin >> r >> w;
			v.emplace_back(r, w);
			sum += r;
			mx = max(mx, r);
			ans += r + w;
		}
		sort( v.begin(), v.end() );
		v.pop_back();
		if( 2*mx > sum ){
			rep(t, v.size()) rep(k,2){
				int w = v[t].first + ( k ? 0 : v[t].second );
				for(int j=1000; j>=0; j--){
					if( j+w <= 1000 ){
						dp[t+1][j+w] |= dp[t][j];
					}
					dp[t+1][j] |= dp[t][j];
				}
			}
			rep(i, mx+1){
				if( dp[ v.size() ][ mx-i ] ){
					ans += i;
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e2+10;
int a[maxn],b[maxn];
int n,k,ans=0;
void update(int x){
    int sum=0;
    for(int i=1;i<=n;i++){
        b[i]=a[i]%x;
        sum+=b[i];
    }
    sort(b+1,b+n+1,greater<int>());
    int sum1=sum;
    for(int i=1;i<=sum1/x;i++){
        sum-=b[i];
    }
    if(sum<=k)
        ans=max(ans,x);
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    ll sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    for(int i=2;i*i<=sum;i++){
        if(sum%i==0){
            update(i);
            update(sum/i);
        }
    }
    update(sum);
    update(1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int h,w;
    int i,j;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i%2==0 && j%2==0)||(i%2==1 && j%2==1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,m=0,ans=0; cin>>n;
  vector<int> a(n+1);
  rep(i,0,n){
    cin>>a[i];
    m=max(m,a[i]);
  }
  a[n]=-1;
  rep(i,1,m+1){
    int c=0;
    bool f=false;
    rep(j,0,n+1){
      if(a[j]>=i) f=true;
      else if(f){
        ans++;
        f=false;
      }
    }
    ans+=c;
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{	
	char A,B,C,D;
	while(cin>>A>>B>>C>>D)
	{	
		int a=A-'0',b=B-'0', c=C-'0', d=D-'0';
		if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
		else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
		else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
		else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
		else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
		else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
		else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
		else if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

         ll a,b,c,d,e;
        cin>>a>>b>>c;

        d= c-a-b;
        e= 4*a*b;


        
        

        if(d>0 && d*d >e )
        	cout<<"Yes";
        else
        	cout<<"No";
        return 0;
    }


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
S = input()
C = collections.Counter(S)
R = [0] * (n+1)
G = [0] * (n+1)
B = [0] * (n+1)
for i,si in enumerate(S):
  R[i+1] += R[i]
  G[i+1] += G[i]
  B[i+1] += B[i]
  if si == "R":R[i+1] += 1
  elif si == "G":G[i+1] += 1
  else:B[i+1] += 1
for i in range(1,n-1):
  si = S[i]
  if si == "R":
    ans += G[i] * (B[n]-B[i+1]) + B[i] * (G[n]-G[i+1])
  elif si == "G":
    ans += R[i] * (B[n]-B[i+1]) + B[i] * (R[n]-R[i+1])
  else:
    ans += G[i] * (R[n]-R[i+1]) + R[i] * (G[n]-G[i+1])
#   print(ans,i,si)
# print(R,G,B,sep = "\n")
# print(ans,"debug")
# print(R[2] * (B[n]-B[2+1]))
    
for span in range(1,n):
  for i in range(n-2*span):
    if S[i] != S[i+span] and S[i+span] != S[i+span+span] and S[i+span+span] != S[i]:
      ans-=1
print(ans)

  
  

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

typedef long long ll;
const ll N = 10005;
ll n, a[N], b[N], s;

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		s -= a[i];
	}
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&b[i]);
		s += b[i];
	}
	if(s < 0) {
		puts("No");
		return 0;
	}
	ll A = 0, B = 0;
	for(ll i=1;i<=n;i++) {
		if(a[i] < b[i]) {
			A += (b[i]-a[i]+1)/2;
			a[i] += (b[i]-a[i]+1)/2*2;
		}
	}
	for(ll i=1;i<=n;i++) {
		if(a[i] > b[i]) {
			B += (a[i] - b[i]);
			b[i] += (a[i] - b[i]);
		}
	}
	puts(A <= s && B <= s ? "Yes" : "No");
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, c; cin >> a >> b >> c;
	set<int> x;
	x.insert(a); x.insert(b); x.insert(c);
	cout << x.size() << endl;
}

Measured memory_bytes: 256
S = input()
S = list(S)
b_num =0
w_num = 0
for i in range(0,len(S),2):
    if S[i] == '0':
        b_num +=1
    else:
        w_num += 1
for i in range(1,len(S),2):
    if S[i] == '0':
        w_num +=1
    else:
        b_num += 1

ans = min([b_num , w_num])
print(ans)

Measured memory_bytes: 3956
/*
AOJ - ITP1_9_d
Date: 20181009
Author: Mikoron * ♡mikoiwate_351♡
*/

#define STRMAX 1001
#define COMMAX 11

#include<stdio.h>
#include<string.h>

int main(void) {
        char words[STRMAX], com[COMMAX], replace[STRMAX];
        short i, j, com_num, a, b;

        scanf("%s", words);
        scanf("%hd", &com_num);

        for(i = 0; i < com_num; i++) {
                scanf("%s", com);
                if(!(strcmp(com,"print"))) {
                        scanf("%hd %hd", &a, &b);
                        for(j = a; j <= b; j++) printf("%c", words[j]);
                        printf("\n");
                }
                else if(!(strcmp(com,"reverse"))) {
                        scanf("%hd %hd", &a, &b);
                        strcpy(replace,words);
                        for(j = a; j <= b; j++) words[j] = replace[b+a-j];
                }
                else if(!(strcmp(com,"replace"))) {
                        scanf("%hd %hd %s", &a, &b, replace);
                        for(j = a; j <= b; j++) words[j] = replace[j-a];
                }
        }
        return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  vector<string> v;
  loop(H) {
    string s;
    cin >> s;
    if (s != string(W, '.'))
      v.eb(s);
  }
  vector<string> w;
  rep(i, 0, W) {
    string s;
    rep(j, 0, v.size()) { s.pb(v[j][i]); }
    if (s != string(v.size(), '.')) {
      w.eb(s);
    }
  }

  rep(i,0,w[0].size()){
    rep(j,0,w.size()){
      cout<<w[j][i];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,A;
long long dp[55][2555]={{1}};
long long ans;
int main(){
    cin>>N>>A;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        for(int j=N;j>0;j--)
            for(int k=0;k<2500;k++)
                dp[j][k+x]+=dp[j-1][k];
    }
    for(int i=1;i<=N;i++){
        ans+=dp[i][A*i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        long ans = 0;
        if (inpt.Count(a => a % 2 == 0) > 0)
        {
            ans = 0;
        }
        else
        {
            ans = Math.Min(inpt[0] * inpt[1], Math.Min(inpt[1] * inpt[2], inpt[0] * inpt[2]));
        }
        Console.WriteLine(ans.ToString("##############################################0"));


    
    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"





3 3 3





";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main() {
    int n, m = INF, sum = 0, s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        sum += s;
        if (s % 10) m = min(m, s);
    }
    cout << max(0, sum - (sum % 10 ? 0 : m)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> h(n);
  for(int i = 0;i < n;i++)cin >> h[i];
  vector<ll> res(n);
  for(int i = 0;i < n;i++)res[i] = 100000000000;
  res[0] = 0;
  res[1] = abs(h[0] - h[1]);
  for(int i = 2;i < n;i++){
    res[i] = min(res[i - 2] + abs(h[i - 2] - h[i]),res[i - 1] + abs(h[i - 1] - h[i]));
  }
  cout << res[n - 1] << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  7 18:47:41 2020

@author: naoki
"""
import sys
import copy
def func():
    N, M = map(int, input().split())
    uvs = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
    S, T = map(lambda x:int(x)-1, input().split())
    
    roots = [[] for _ in range(N)]
    
    for uv in uvs:
        roots[uv[0]].append(uv[1])
    
    costs = [-10000]*(N)
    
    from collections import deque
    
    todo = deque([S])
    costs[S] = 0
    todo_set = set([S])
    
    layers = [set() for _ in range(3)]
    
    while len(todo)>0:
        checking = todo.popleft()
        next_targets = deque([checking])
        for i in range(3):
            purposes = set()
            while len(next_targets) > 0:
                now = next_targets.pop()
                for root in roots[now]:
                    if root not in layers[i]:
                        layers[i].add(root)
                        purposes.add(root)
            next_targets = purposes.copy()
        for next_target in next_targets:
            if costs[next_target] < 0 and next_target not in todo_set:
                costs[next_target] = costs[checking]+1
                todo.append(next_target)
                todo_set.add(next_target)
                if next_target == T:
                    print(costs[next_target])
                    sys.exit()
    print(-1)
if __name__ == "__main__":
    func()

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

const static int MAX = 100010;
const static int DIV = 1000000007;

int main()
{
  int N, M;
  int A[MAX];

  cin >> N >> M;
  if (M > 0) {
    cin >> A[0];
    ++A[0];
  }

  for (int i = 1; i < M; ++i)
  {
    cin >> A[i];
    ++A[i];
    if (A[i] - A[i-1] == 1)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  int ai = 0;
  int DP[MAX] = {0};
  DP[0] = 1;
  for (int i = 1; i <= N; ++i)
  {
    if (i == A[ai])
    {
      ++ai;
      continue;
    }

    DP[i] = (DP[i] + DP[i-1]) % DIV;
    DP[i+1] = DP[i-1] % DIV;
  }

  cout << DP[N] << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
   
int main(){
    int a,b;
    cin >> a >> b;

    if ((a == 1 && b == 2) || (a == 2 && b == 1)) cout << 3 << endl;
    else if ((a == 1 && b == 3) || (a == 3 && b == 1))cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
X = [int(x) for x in input().split()]
list.sort(X,reverse=True)
A,B,C = X[0],X[1],X[2]
count = 0

while A!=B or B!=C or C!=A:
    if (B-C)%2 == 1 and A==B:
        A=A+1
        B=B+1
        count = count + 1
    elif B!=C and (B-C)%2 == 0:
        while B!=C:
            C = C + 2
            count = count + 1
    else:
        B = B + 1
        C = C + 1
        count = count + 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define N 2005
#define Mod 1000000007
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
int n,k,f[N];
int Pow(int a,int b) {
	int res=1;
	while(b) {
		if(b&1)res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
}
int calc(int n,int m) {
	if(n<m)return 0;
	return f[n]*Pow(f[m],Mod-2)%Mod*Pow(f[n-m],Mod-2)%Mod;
}
signed main() {
	scanf("%lld%lld",&n,&k),f[0]=1;
	for(int i=1; i<=n; i++)f[i]=f[i-1]*i%Mod;
	for(int i=1; i<=k; i++)printf("%lld\n",calc(k-1,i-1)*calc(n-k+1,i)%Mod);
	return 0;
}


Measured memory_bytes: 256
program ABC052C
    implicit none
    integer(8)::N,sn,i,j,k
    integer(8)::result=1
    integer(8),dimension(1000)::L
    read(5,*)N
    L=0
    do i=1,N
        k=i
        do j=2,i
            do
                if(mod(k,j)==0)then
                    L(j)=L(j)+1
                    k=k/j
                else
                    exit
                end if
            end do
        end do
    end do

    do i=1,1000
        !print'(i0,1x,i0)',i,L(i)
        result=result*(L(i)+1)
        result=mod(result,10**9+7)
    end do

    print'(i0)',result
end program ABC052C

Measured memory_bytes: 256
import java.util.Scanner;

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

		String _0 = s.replaceAll("1", "");
		String _1 = s.replaceAll("0", "");
		
		int ans = Math.min(_0.length(), _1.length()) * 2;
		System.out.println(ans);
		
	}
}


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 100010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn];
string s, ss;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n=0;
    cin >> s;
    for(auto u : s) n+=u-'0';
    if(n%3)cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 3680
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int N = s.length();
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (s[i] == 'p')
      ans--;
    if (i % 2 == 1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<ll>());

	if (s < t)
		std::cout << "Yes"<< std::endl;
	else
		std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) 
	int k; cin>>k;
	string s; cin>>s;
	if(len(s)>k) {
		f(i,0,k) cout<<s[i];
		cout<<"...";
	}
	else cout<<s;

	
    return 0 ;  
}

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

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

for i in range(N):

    if (i == 0) and H[i] > 0:
        H[i] = H[i] - 1

    else:
        if H[i] < H[i-1]:

            print('No')
            exit(0)

        elif H[i] - H[i-1] >= 1:
            H[i] = H[i] - 1

print('Yes')

Measured memory_bytes: 14396
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int [][] a = new int[n][m];
        int [] b = new int[m];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for(int j = 0; j < m; j++) {
            b[j] = sc.nextInt();
        }
        int [] x = new int[n];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                x[i] += a[i][j]*b[j];
            }
        }
        for(int i = 0; i < n; i++) {
            System.out.println(x[i]);
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 105;
int n;
int a[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int *p = unique(a, a + n);
    cout << (p - a) << endl;
    return 0;
}


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

int main() {
  int x, y, n, cnt = 1000, ans;
  cin >> x >> n;

  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  vector<int> p(103);
  for (int i = 0; i < n; i++) {
    cin >> y;
    p[y] = 100000;
  }

  for (int i = 0; i <= 101; i++) {
    if (p[i] < 100000) p[i] = abs(x - i);
  }

  for (int i = 0; i <= 101; i++) {
    if (p[i] < cnt) {
      cnt = p[i];
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

struct Food{
	string f;
	int w,s;
	bool operator <(const Food &a)const{
		if(w==a.w) return s>a.s;
		return w>a.w;
	}
};

int main(){
	int N;
	while(cin>>N,N){
		int sumW = 0;
		Food food[10];
		for(int i=0;i<N;i++){
			cin>>food[i].f>>food[i].w>>food[i].s;
			sumW += food[i].w;
		}
		sort(food,food+N);
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(food[j].w == -1) continue;
				if(food[j].s >= sumW-food[j].w){
					cout<<food[j].f<<endl;
					sumW -= food[j].w; food[j].w = -1; break;
				}
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    sc.close();

    int a = A - B;

    int ans = 0;

    if (0 < C-a){
      ans = C - a;
    }

    System.out.println(ans);
    
  }

}

Measured memory_bytes: 21844
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    vi cnt(26,0);
    string  s; cin >> s;
    int ans=100;
    for (int i=0;i<sz(s);i++) cnt[s[i]-'a']++; 
    for (int i=25;i>=0;i--){
        int cur=0;
        char ch=i+'a';
        for (int j=0,t=0;j<sz(s);j++){
            if (s[j] == ch) t=0;
            else t++;
            cur = max(cur,t);
        }
        ans = min(ans,cur);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/*
    serval -> srraa -> rrra -> rrr;
*/


Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

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

  int n,m,cnt = 0;
  cin >> n >>m;
  dsu ft(n);
  vector<int> a(m),b(m);
  for (int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    ft.merge(a[i]-1,b[i]-1);
  }
  
  for (int i = 1; i < n; i++){
    if (ft.same(0,i)){
      
    }else{
      ft.merge(0,i);
      cnt++;
    }  
  }
  
  cout << cnt << '\n';

  return 0;
}

Measured memory_bytes: 4536