akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#define N 100000
#define xx fucker
#define yy lover
using namespace std;
int n,fa[N*2+5],xx[2*N+5],yy[2*N+5];
int find(int x){
	if(x==fa[x])return x;
	return fa[x]=find(fa[x]);
}
void work(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx==fy)return;
	fa[fy]=fx;
	xx[fx]+=xx[fy],yy[fx]+=yy[fy];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=N;i++)fa[i]=i,xx[i]=1;
	for(int i=N+1;i<=2*N;i++)fa[i]=i,yy[i]=1;
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		work(x,y+N);
	}
	long long ans=0;
	for(int i=0;i<=2*N;i++)if(fa[i]==i)
		ans+=1ll*xx[i]*yy[i];
	cout<<ans-n<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 998244353;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<u32 M = 1000000007>
struct modint{
    u32 val;
    modint(): val(0){}
    template<typename T>
    modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;}

    modint pow(ll k) const {
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;}
    modint inv() const {return pow(M-2);}
    modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;}
    modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;}
    modint& operator/=(modint a){return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){return modint(M-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};
using mint = modint<MOD>;

int main() {
    using B = bitset<4000>;
    auto f = [&](string &s) -> B {
        B res;
        for (int i = 0; i < s.size(); ++i) {
            if(s[i] == '1') res.set(4000+i-(int)s.size());
        }
        return res;
    };
    int n; B X;
    cin >> n;
    vector<B> v(n);
    {
        string x;
        cin >> x;
        X = f(x);
        for (int i = 0; i < n; ++i) cin >> x, v[i] = f(x);
    }
    for (int i = 1; i < n; ++i) {
        int a = v[0]._Find_first(), b = v[i]._Find_first();

        while(true){
            if(a == 4000 || b == 4000) {
                if(a == 4000) swap(v[0], v[i]);
                break;
            }
            if(a > b){
                v[i] ^= (v[0] >> (a-b));
                b = v[i]._Find_first();
            }else {
                v[0] ^= (v[i] >> (b-a));
                a = v[0]._Find_first();
            }
        }
    }

    int a = v[0]._Find_first(), b = X._Find_first();
    B Y;
    mint ans = 0;
    for (int i = b; i <= a; ++i) {
        if(X[i]) {
            ans += mint(2).pow(a-i);
        }
        if(X[i] != Y[i]){
            Y ^= (v[0] >> (a-i));
        }
    }
    int ok = 1;
    for (int i = 0; i < 4000; ++i) {
        if(!X[i] && Y[i]) {
            ok = 0;
            break;
        } else if(X[i] && !Y[i]) break;
    }
    if(ok) ans += mint(1);
    cout << ans.val << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N, K; cin >> N >> K;
    vector<int> x(N);
    int i = 0;
    int answer = pow(10, 9);
    int sum = 0;
    int sum2 = 0;
    while(i < N){
        cin >> x[i];
        i++;
    }
    K--;
    i = 0;
    while (i < N-K) {
        sum = 0;
        sum2 = 0;
        if (x[i] < 0 && x[i+K] >= 0) {
            sum = x[i + K] - x[i] * 2;
            sum2 = x[i + K] * 2 - x[i];
            sum = min(sum, sum2);
        } else if (x[i] < 0) {
            sum = abs(x[i]);
        } else {
            sum = x[i + K];
        }
        answer = min(answer, sum);
        i++;
    }
    
    cout << answer << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,warr=1;
  cin >>n;
  long long int k=1;
  string ans;
  if (n==0) cout << 0 <<endl;
  while (n!=0){
    warr*=-2;
    if (n%warr!=0){
      ans="1"+ans;
      n=n-warr/(-2);
    }
    else ans="0"+ans;
    k++;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func run() {
	s := next()
	t := next()
	count := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			count++
		}
	}
	Println(count)
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024

func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 2816
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;


struct node {
	node *r, *l, *p;
	int key;
};
node *root, *NIL;


void insert(int k) {
	node *y = NIL;
	node *x = root;
	node *z;

	z = (node *)malloc(sizeof(node));
	z->key = k;
	z->l = NIL;
	z->r = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->l;
		}
		else {
			x = x->r;
		}
	}
		z->p = y;
		if (y == NIL) {
			root = z;
		}
		else {
			if (z->key < y->key) {
				y->l = z;
			}
			else {
				y->r = z;
			}
		}
	
}

void preorder(node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->l);
	preorder(u->r);
}


void inorder(node *u) {
   if (u == NIL)return;
   inorder(u->l);
   printf(" %d", u->key);
   inorder(u->r);
}


int main() {
	int n, i, y;
	string ord;

	scanf("%d", &n);
	//scanf_s("%d", &n);

	for (i = 0;i < n;i++) {
		cin >> ord;
		if (ord == "insert") {
			scanf("%d", &y);
			//scanf_s("%d", &y);
			insert(y);
		}
		if (ord == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long B, long long C){
	ll res = min(B/A, C);
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vi w(n);
  rep(i,n) cin>>w.at(i);
  int sum=0;
  rep(i,n) sum+=w.at(i);
  int left=0;
  int right=sum;
  int min=1000000;
  rep(i,n){
    left+=w.at(i);
    right-=w.at(i);
    chmin(min,abs(right-left));
  }
  cout<<min<<endl;
}

Measured memory_bytes: 256
from fractions import gcd
import sys
n, m = map(int, input().split())
s = input()
t = input()
if s[0]==t[0]:
    g = gcd(n, m)
    x = g*(n//g)*(m//g)
    num_s, num_t = x//n, x//m
    for i in range(0, x, num_s):
        if i%num_t==0 and s[i//num_s]!=t[i//num_t]:
            print(-1)
            sys.exit()
    print(x)
else:
    print(-1)

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

unsigned ggcd(unsigned a, unsigned b) {
  if(a < b) ggcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    long long n,m,ans;
    cin >> n >> m;
    ans = -1;
    string s,t;
    cin >> s >> t;
    if(m>n){
        swap(n,m);
        swap(s,t);
    }

    if(s[0] != t[0]){
        ans = -1;
    }
    else if(ggcd(n,m) == 1){
        ans = n*m;
    }else{
        bool flag = false;
        long long L;
        if(ggcd(n,m)<=0){
            flag = true;
            L =100;
        }else{
            L = abs(n*m)/ggcd(abs(n),abs(m));
        }
        ans = L;
        vector<string> sc(L),tc(L);
        //string sc[L]={},tc[L]={};
        
        for(long long i=0;i<m;i++){
            long long ind = (L/m)*i+1;
            tc[ind] = t[i];
        }
        for(long long i=0;i<n;i++){
            long long ind = (L/n)*i+1; 
            sc[ind] = s[i];
            if(tc[ind] != ""){
                if(sc[ind] == tc[ind]){
                    continue;
                }
                else{
                    ans = -1;
                    break;
                }
            }
        }
        if(flag) ans = -1;
    }

    cout << ans<<endl;
}

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

int ctoi(char c){
    if(c=='1') return 1;
    if(c=='2') return 2;
    if(c=='3') return 3;
    if(c=='4') return 4;
    if(c=='5') return 5;
    if(c=='6') return 6;
    if(c=='7') return 7;
    if(c=='8') return 8;
    if(c=='9') return 9;
}

int main(){
    string s;
    cin >> s;
    ll sum=0;
    rep(i,s.size()) sum+=ctoi(s.at(i));
    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int N = 111;
int b[N];
int a[N];

int main( )
{
    int n, i, j, k;
    long long int s = 0;
    cin >> n;
    for (i = 2; i <= n; i++) {
        cin >> b[i];
    }
    a[1] = b[2];
    s += a[1];
    for (i = 2; i <= n; i++) {
        a[i] = b[i];
        s += a[i];
        j = max(a[i], a[i - 1]);
        if (j > b[i]) {
            s -= a[i - 1];
            a[i - 1] = b[i];
            s += b[i];
        }
    }
//    for (i = 1; i <= n; i++) {
//        cout << a[i] << ' ';
//    }
//    cout << '\n';
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	vector<long long int> aa;

	aa.push_back(3);
	aa.push_back(5);
	aa.push_back(7);

	vector<long long int> cc;
	string s;
	stringstream ss;

	for (int i = 0; i < 10; i++) {
		vector<long long int> bb;
		for (long long int j = 0; j < aa.size(); j++) {
			bb.push_back(aa[j] * 10 + 3);
			bb.push_back(aa[j] * 10 + 5);
			bb.push_back(aa[j] * 10 + 7);
		}

		for (long long int j = 0; j < bb.size(); j++) {
			ss.clear();
			ss << bb[j];
			ss >> s;
			if (s.find('7') != string::npos && s.find('5') != string::npos && s.find('3') != string::npos) {
				cc.push_back(bb[j]);
			}
		}
		aa = bb;
	}

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

	int ans = 0;

	for (int i = 0; i < cc.size(); i++) {
		if (cc[i] <= n) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10676
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        char[][] fields = new char[H][W];
        
        sc.nextLine();
        for(int i = 0; i < H; i++){
            fields[i] = sc.nextLine().toCharArray();
        }
        sc.close();

        Set<Integer> ignoreH = new HashSet<>();
        Set<Integer> ignoreW = new HashSet<>();        
        
        for(int i = 0; i < H; i++){
            boolean delH = true;
            for(int j = 0; j < W; j++){
                if (fields[i][j] != '.'){
                    delH = false;
                    break;
                }
            }
            
            if(delH) ignoreH.add(i);
        }
        
        for(int j = 0; j < W; j++){
            boolean delW = true;            
            for(int i = 0; i < H; i++){
                if(fields[i][j] != '.'){
                    delW = false;
                    break;
                }
            }
            if(delW) ignoreW.add(j);
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < H; i++){
            if( ignoreH.contains(i) ) continue;
            for(int j = 0; j < W; j++){
                if( ignoreW.contains(j) ) continue;
                sb.append(fields[i][j]);
            }
            sb.append("\r\n");
        }
        
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 22228
T = ['L', 'R']
s = str(input())
S = [s[i:i+1] for i in range(0, len(s), 1)]

j = 0
for j in range(0, len(S)-1, 2):
    if (S[j] == T[0]) or (S[j+1] == T[1]):
        print('No')
        exit()
if (len(S) % 2 != 0) and (S[-1] == T[0]):
    print('No')
    exit()
print('Yes')


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

using namespace std;

int n, m;
char grid[51][51];
int b[51][51];

        void check(int i, int j){

                if(i > 1){
                    if(grid[i-1][j] == '#'){
                         b[i][j] = 1;
                         b[i-1][j] = 1;
                     }
                  }
                
                if(i < n){
                    if(grid[i+1][j] == '#'){
                         b[i+1][j] = 1;
                         b[i][j] = 1;
                     }  
                 }
                
                 if(j < m){
                    if(grid[i][j+1] == '#'){
                         b[i][j+1] = 1;
                         b[i][j] = 1;
                     }  
                 }
                 
                  if(j > 1){
                    if(grid[i][j-1] == '#'){
                         b[i][j-1] = 1;
                         b[i][j] = 1;
                     } 
                   }
           
             }


int main(){                               


    cin >> n >> m;

    for(int i = 1; i <=n ; i++){
        for(int j = 1; j <= m; j++){
            cin >> grid[i][j];
         }
     }

    
    for(int i = 1; i <=n ; i++){
        for(int j = 1; j <= m; j++){
             if(grid[i][j] == '#'){
                  check(i,j);
              }
         }
     }
    
    string ans = "Yes";
    bool t = true;

    for(int i = 1; i <=n ; i++){
        for(int j = 1; j <= m; j++){
              if((grid[i][j] == '#') && (b[i][j] == 0)){
                  ans = "No"; t = false; break;
               }
           }
        if(!t)
           break;
       }

    
    cout << ans;
    

                                                                                                                                                                                                      
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
dp = np.zeros(N, dtype=int)
ans = 0
if N == 1:
	print(A1[0] + A2[0])
else:
	for i in range(N):
		if np.sum(A1[:i]) + np.sum(A2[i-1:]) > ans:
			ans = np.sum(A1[:i]) + np.sum(A2[i-1:])
	print(int(ans))

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<P> items(N);
    vector<ll> mi, ma;
    if (N % 2) {
        rep(i, N) {
            ll a, b;
            cin >> a >> b;
            items[i] = {a, b};
            mi.push_back(a);
            ma.push_back(b);
        }
        sort(mi.begin(), mi.end());
        sort(ma.begin(), ma.end());
        ll ans = ma[N / 2] - mi[N / 2] + 1;
        cout << ans << '\n';
    } else {
        rep(i, N) {
            ll a, b;
            cin >> a >> b;
            items[i] = {a * 2, b * 2};
            mi.push_back(2 * a);
            ma.push_back(2 * b);
        }
        sort(mi.begin(), mi.end());
        sort(ma.begin(), ma.end());
        ll ans = (ma[N / 2] + ma[N / 2 - 1]) / 2 - (mi[N / 2] + mi[N / 2 - 1]) / 2 + 1;
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 9776
A,B = list(map(int,input().split()))
C = []
for i in range(A*14):
  if A * 12.5 <= i < (A+1) * 12.5 and B * 10 <= i < (B+1) * 10:
    C.append(i)
if len(C) == 0:
  print('-1')
else:
  print(min(C))

Measured memory_bytes: 3060
from itertools import accumulate, product
def solve():
    N,W = map(int,input().split())
    value = [list() for _ in range(4)]
    w1 = None
    for i in range(N):
        w,v = map(int,input().split())
        if i == 0:
            w1 = w
        value[w-w1].append(v)
    
    acc = []
    for i in range(4):
        value[i].sort(reverse=True)
        acc.append(list(accumulate(value[i])))
    
    comb = []
    for i_0 in range(len(acc[0]) + 1):
        for i_1 in range(len(acc[1]) + 1):
            for i_2 in range(len(acc[2]) + 1):
                for i_3 in range(len(acc[3]) + 1):
                    comb.append((i_0,i_1,i_2,i_3))
    ans = 0
    for c in comb:
        if isOver(c, acc):
            continue
        sum_w = c[0] * w1 + c[1] * (w1+1) + c[2] * (w1+2) + c[3] * (w1+3)
        if sum_w > W:
            continue
        res = 0
        for i in range(4):
            if c[i] == 0:
                continue
            res += acc[i][c[i]-1]
        
        ans = max(ans,res)
    
    print(ans)

def isOver(c, acc):
    res = False
    for i in range(4):
        if len(acc[i]) < c[i]:
            res = True
    
    return res
if __name__ == '__main__':
    solve()

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

int GetBombNumber(int x, int y, const vector<string> field) {
  int count = 0;
  for (int i = y - 1; i <= y + 1; ++i) {
    if (i < 0 || i >= field.size()) continue;
    for (int j = x - 1; j <= x + 1; ++j) {
      if (j < 0 || j >= field[i].size()) continue;
      if (field[i][j] == '#') count++;
    }
  }
  return count;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  for (int i = 0; i < h; ++i) {
    cin >> field[i];
  }
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      if (field[y][x] == '#') {
        cout << "#";
      } else {
        cout << GetBombNumber(x, y, field);
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int x=0;
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		String S=s.next();
		int i=0;
		int y[]=new int[S.length()];
		int max=0;
		
		for(i=0;i<S.length();i++){
			if(S.charAt(i)=='I'){
				x++;
				y[i]=x;
			}else{
				x--;
				y[i]=x;
			}
		}
		
		max=y[0];
		
		for(i=0;i<S.length();i++){
			if(max<y[i]){
				max=y[i];
			}
		}
		if(max<0){
			max=0;
		}
		System.out.println(max);

	}

}

Measured memory_bytes: 21844
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define MSI map<string,int>
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int x;
	cin >> x;
	x <1200 ? cout << "ABC" << endl : cout << "ARC" << endl;
	return 0;
}

Measured memory_bytes: 256
//no print start
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <complex>
#include <bitset>
#include <random>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

typedef long long ll, lint;
typedef long double ldouble;

#define sz(v) ((int) (v).size())
#define FOR(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define For(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()

#ifdef ALEX
#define eprintf(...) fprintf(stdout, __VA_ARGS__)
#define print_var(x) cout << #x << " = " << x << endl
#define print_array(arr, len) {cout << #arr << " = "; for(int i = 0; i < len; ++i) cout << arr[i] << ' '; cout << endl;}
#define print_iterable(it) {cout << #it << " = "; for(const auto& e : it) cout << e << ' '; cout << endl << endl;}
#define print_2d_array(arr, len1, len2) {\
		cout << #arr << ':' << endl;\
		for(int i = 0; i < len1; ++i, cout << endl) \
			for(int j = 0; j < len2; ++j)\
				cout << arr[i][j] << ' '; \
		cout << endl;\
	}
#define print_endl() cout << endl
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0;
#define print_iterable(it) (void)0;
#define print_2d_array(arr, len1, len2) (void)0;
#define print_endl() (void)0
#endif

#define forn(var, count) for (int var = 0; var < count; var++)

template<class T>
string to_string(T arr, int len = 1e9) {
	stringstream ss;
	int i = 0;
	for (auto item : arr) {
		ss << item << ' ';
		if (++i == len)
			break;
	}
	return ss.str();
}

#ifdef ALEX
#define dbg(expr) cout << "[line " << __LINE__ << "] " << (#expr) << ": " << (expr) << endl;
#else
#define dbg(expr) (void) 0;
#endif

#pragma endregion
//no print end

void solve() {
	string s;
	cin >> s;
	int n = s.length();
	if (s.back() == '1' || s.front() == '0') {
		cout << -1;
		return;
	}
	bool is_pal = true;
	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[n - i - 2]) {
			is_pal = false;
			break;
		}
	}
	if (!is_pal) {
		cout << -1;
		return;
	}
	vector<pair<int, int> > g;
	int cur_root = n / 2;
	for (int v = cur_root + 1; v < n; v++)
		g.emplace_back(cur_root, v);
	for (int v = cur_root - 1; v >= 0; v--) {
		g.emplace_back(cur_root, v);
		if (s[v] == '1')
			cur_root = v;
	}
	for (auto e : g) {
		cout << e.first + 1 << ' ' << e.second + 1 << '\n';
	}
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
#ifdef ALEX
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	solve();
	eprintf("\n\ntime: %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}

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

int main() {
  int N, K, d;
  cin >> N >> K;
  bool D[10];
  fill(D, D+10, true);
  for (int i=0; i<K; i++) {
    cin >> d;
    D[d] = false;
  }
  int i;
  for (i=N; ;i++) {
    int m = i;
    while (m != 0) {
      if (!D[m%10])
        break;
      m /= 10;
    }
    if (m == 0)
      break;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 3552
import math

a, b, H, M = map(int, input().rstrip().split())
if H == 0 and M == 0:
    print(abs(a-b))
else:
    H = H * 5 + (float(M) / 12)
    kakudo = abs(H - M)
    kakudo *= 6
    print(math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo))))


Measured memory_bytes: 9512
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

struct Node { 
    int k;
    Node *p, *l, *r; 
};
Node *N, *R;

void insert(int u) {
    Node *a = R, *b = N, *c;
    c = (Node *)malloc(sizeof(Node));
    c->k = u, c->l = N, c->r = N;

    while(a != N) {
        b = a;
        if(c->k < a->k) a = a->l;
        else a = a->r;
    }
    c->p = b;
    if(b == N) {
        R = c;
    } else {
        if(c->k < b->k) b->l = c;
        else b->r = c;
    }
}

void inOrder(Node *u) {
    if(u == N) return;
    inOrder(u->l);
    printf(" %d", u->k);
    inOrder(u->r);
}

void preOrder(Node *u) {
    if(u == N) return;
    printf(" %d", u->k);
    preOrder(u->l);
    preOrder(u->r);
}

int main()
{
    #ifdef LOCAL
        freopen("E:\\Temp\\input.txt", "r", stdin);
        freopen("E:\\Temp\\output.txt", "w", stdout);
    #endif

    int a, i, n;
    char c[10];
    scanf("%d", &n);
    for(i=0; i<n; ++i) {
        scanf("%s", c);
        if(c[0] == 'i') {
            scanf("%d", &a);
            insert(a);
        } else {
            inOrder(R); printf("\n");
            preOrder(R); printf("\n");
        }
    }

    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> W(N);
	int sumL = 0;
	int sumR = 0;
	for(int i = 0; i < N; i++){
		cin >> W.at(i);
		sumR += W.at(i);
	}
	int dis = abs(sumL - sumR);
	
	for(int i = 0; i < N; i++){
		sumL += W.at(i);
		sumR -= W.at(i);
		dis = min(dis, abs(sumL - sumR));
	}
	
	cout << dis << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    int a, b, m;
    cin >> a >> b >> m;
    int ans = 0;
    int cost = 1e9;
    vector<int> A, B;
    REP(i, a) {
        int c;
        cin >> c;
        cost = min(cost, c);
        A.push_back(c);
    }
    ans += cost;
    cost = 1e9;
    REP(i, b) {
        int c;
        cin >> c;
        cost = min(cost, c);
        B.push_back(c);
    }
    ans += cost;
    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        ans = min(ans, A[a] + B[b] - c);
    }
    cout << ans << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 2548
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String[] s = new String[n];
		for (int i = 0; i < n; i++)
			s[i] = sc.next();
		Arrays.sort(s);
		int m = Integer.parseInt(sc.next());
		String[] t = new String[m];
		for (int i = 0; i < m; i++)
			t[i] = sc.next();
		Arrays.sort(t);
		int max = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			while (count + i < n && s[i].equals(s[count + i]))
				count++;
			int index = -1;
			for (int j = 0; j < m; j++) {
				if (s[i].equals(t[j])) {
					index = j;
					break;
				}
			}
			int countj = 0;
			if (index != -1) {
				while (countj + index < m && s[i].equals(t[countj + index]))
					countj++;
			}
			if (count - countj > max)
				max = count - countj;
		}
		System.out.println(max);
	}
}

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

const int INF = 1e9+5;

int main () {
    int n,k;
    cin >> n >> k;
    int arr[n];
    vector<int> dp(n,INF);
    for(int i = 0;i < n;i++) cin >> arr[i];
    dp[0] = 0;
    for(int i = 0;i < n;i++) {
        for(int j = i + 1;j <= i + k;j++) {
            if(j < n) dp[j] = min(dp[j],dp[i] + (abs(arr[i] - arr[j])));
        }
    }
    //for(int i = 0;i < n;i++) cout << dp[i] << " ";
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;


int main(){
    string s;
    cin>>s;
    ll n=s.length();
    vector<ll> ans(n,0);
    ll num[2]={0,0};
    ll count=0;
    ll place,place_=0;
    bool flag=1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1] && i!=n-1){
            num[count%2]++;
            if(flag){
                place=i;
                place_=count;
                count++;
                flag=0;
            }else{
                if(place_%2){
                    ans[place-1]=num[1];
                    ans[place]=num[0];
                }else{
                    ans[place-1]=num[0];
                    ans[place]=num[1];
                }
                num[0]=num[1]=0;
                count=0;
                place_=0;
                flag=1;
            }
        }else if(i==n-1 && s[i]==s[i-1]){
            num[count%2]++;
            num[(count+1)%2]++;
            if(place_%2){
                ans[place-1]=num[1];
                ans[place]=num[0];
            }else{
                ans[place-1]=num[0];
                ans[place]=num[1];
            }
        }else if(i==n-1){
            num[count%2]++;
            num[(count+1)%2]++;
            if(place_%2){
                ans[i-1]=num[1];
                ans[i]=num[0];
            }else{
                ans[i-1]=num[0];
                ans[i]=num[1];
            }
        }else{
            num[count%2]++;
            count++;
            if(flag) place_++;
        }
    }
    for(int i=0;i<n;i++) cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;


int main() {
    int a,b,c ;
    cin >> a >> b >> c  ;
  
    if(a+b >= c)
      cout << "Yes" ;
    else
      cout << "No" ;
      
    cout << endl ;
    

	return 0;
}



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

int main()
{
	int A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	cout << max(C-(A - B),0) << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"


func main() {
	var n int

	fmt.Scan(&n)

	var A[2000] int

	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}

	flag := false
	res := 0
	for i := 0; true; i++ {
		for i := 0; i < n; i++ {
			if A[i]%2 == 0 {
				A[i] /= 2
			} else {
				flag = true
			}
		}

		if flag {
			break
		}
		res += 1

	}

	fmt.Println(res)
}

Measured memory_bytes: 512
x = input()
ans = "No"
a = x[0]

for i in range(1, 4):
    if a != x[i]:
        b = x[i]
        ans = "Yes"
        break

for i in range(4):
    if (x[i] != a) and (x[i] != b):
        ans = "No"

print(ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




int N;
ll C, K;
vector<ll> v;

int main () {
  cin >> N >> C >> K;

  Rep(i, N) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  sort(All(v));

  int ans = 0;
  int c = 0;
  int tmp = v[0];

  Rep(i, v.size()) {
    if (c == C || v[i] > (tmp + K)) {
      ans++;
      c = 1;
      tmp = v[i];
    } else {
      c++;
    }
  }

  ans++;

  cout << ans << "\n";
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

bool isEvenString(string s) {
    if (s.size() % 2 == 1) return false;
    int split = s.size() / 2;
    string left = s.substr(0, split);
    string right = s.substr(split);
    return left == right;
}

int main() {

    string s;
    cin >> s;

    for (int i = s.size() - 1; i >= 0; i--) {
        string sub = s.substr(0, i);
        if (isEvenString(sub)) {
            cout << sub.size()  << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int R, C, g[2200][2200], v[2200][2200], h[2200][2200], dot[2200][2200], Q;

int q (int k[2200][2200], int a, int b, int i, int j) {
        return k[i][j] - (a?k[a-1][j]:0) - (b?k[i][b-1]:0) + (a&&b?k[a-1][b-1]:0);
}

int main () {
        scanf("%d %d %d", &R, &C, &Q);
        fo(i, 0, R) fo(j, 0, C) {
                char c; scanf(" %c", &c);
                g[i][j] = (c == '1');
        }
        fo(i, 0, R) fo(j, 0, C) {
                if (i+1<R) v[i][j] = (g[i][j] && g[i+1][j]);
                if (j+1<C) h[i][j] = (g[i][j] && g[i][j+1]);
                dot[i][j] = g[i][j];

                if (i) v[i][j] += v[i-1][j], h[i][j] += h[i-1][j], dot[i][j] += dot[i-1][j];
                if (j) v[i][j] += v[i][j-1], h[i][j] += h[i][j-1], dot[i][j] += dot[i][j-1];
                if (i&&j) v[i][j] -= v[i-1][j-1], h[i][j] -= h[i-1][j-1], dot[i][j] -= dot[i-1][j-1];
        }
        fo(i, 0, Q) {
                int x1, y1, x2, y2; scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
                x1--,y1--,x2--,y2--;
                if (x1>x2) swap(x1, x2);
                if (y1>y2) swap(y1, y2);

                int V = q(dot, x1, y1, x2, y2);
                int E = q(v, x1, y1, x2-1, y2) + q(h, x1, y1, x2, y2-1);
                printf("%d\n", V-E);
        }
        return 0;
}


Measured memory_bytes: 75648
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    int c=0;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='o')
        {
            c++;
        }
    }
    
    c+=(15-s.size());
    
    if(c>=8)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    cout<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A;string S;cin>>N>>S;
  for(char x='0';x<='9';x++){
    int i,j,k;
    for(i=0;i<N-2;i++)if(S.at(i)==x)break;    
    if(i!=N-2){
      for(char y='0';y<='9';y++){
        for(j=i+1;j<N-1;j++)if(S.at(j)==y)break;
        if(j!=N-1){
          for(char z='0';z<='9';z++){
            for(k=j+1;k<N;k++)if(S.at(k)==z)break;
            if(k!=N)A++;
          }
        }
      }
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

string s;
ll cnt[3], minn;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		cnt[s[i]-'a']++;
	}
	minn=INF;
	minn=min(cnt[0],minn);
	minn=min(cnt[1],minn);
	minn=min(cnt[2],minn);
	cnt[0]-=minn;
	cnt[1]-=minn;
	cnt[2]-=minn;
	for(int i = 0; i < 3; i++){
		if(cnt[i]==0){
			if(cnt[(i+1)%3]+cnt[(i+2)%3]<=1 || (cnt[(i+1)%3]+cnt[(i+2)%3]==2 && cnt[(i+1)%3]==cnt[(i+2)%3])){
				cout<<"YES\n";
				return 0;
			}
			else{
				cout<<"NO\n";
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt(), W = in.nextInt();
            int[] weight = new int[N + 1], values = new int[N + 1];
            for(int i = 1; i <= N; i++) {
                weight[i] = in.nextInt();
                values[i] = in.nextInt();
            }

            long[][] dp = new long[N + 1][W + 1];
            long res = maxValue(weight, values, W, N, dp);
            out.println(res);
        }

        public long maxValue(int[] weight, int[] values, int W, int N, long[][] dp) {
            if(W == 0 || N == 0)
                return 0;

            if(dp[N][W] != 0)
                return dp[N][W];

            long max = 0;
            if(W - weight[N] >= 0)
                max = Math.max(max, values[N] + maxValue(weight, values, W - weight[N], N - 1, dp));
            max = Math.max(max, maxValue(weight, values, W, N - 1, dp));

            dp[N][W] = max;
            return max;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 131040
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
   
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;

int main(){
    ll b,d,x,y,z,n,m,k,l,w,sum=100000,sum2=0,ans=0;
    string s,t;
    bool ok=true;
    cin >> s;   
    rep(i,s.size()){
        if(s[i]=='1'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, comp[21][21];
ll dp[21][(1 << 21)];
ll solve(int i, int msk)
{
    if(i == n) return 1;
    if(dp[i][msk] != -1) return dp[i][msk];
    ll tot = 0;
    for(int j = 0; j < n; j++)
        if(!(msk >> j & 1) && comp[i][j])
            tot = (tot + solve(i + 1, msk ^ (1 << j))) % mod;
    return dp[i][msk] = tot;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> comp[i][j];
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 344320
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A*B==C*D) cout<<A*B<<endl;
    else if(A*B<C*D) cout<<C*D<<endl;
    else if(A*B>C*D) cout<<A*B<<endl;
    return 0;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
a = list(map(lambda x: int(x), input().split()))
#a = list(map(lambda x: int(x), in1.split()))
b = []
strlow = a[0]

for idx1 in range(1, len(a)):
    b.append(a[idx1] - strlow)
    if a[idx1] < strlow:
        strlow = a[idx1]

print(b.count(max(b)))


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

using namespace std;


int main() {
	int m,k;
	cin>>m>>k;
	if(k>(1<<m)-1){
		cout<<-1;
		return 0;
	}
	if(m==0){
		cout<<"0 0";
		return 0;
	}
	if(m==1) {
		if(k==1) cout<<-1;
		else cout<<"0 0 1 1";
		return 0;
	}
	if(k==0){
		for(int i=0;i<=(1<<m)-1;i++){
			cout<<i<<" ";
		}	
		for(int i=(1<<m)-1;i>=0;i--){
			cout<<i<<" ";
		}	
		return 0;
	}
	vector<int>p;
	p.push_back(0);
	p.push_back(k);
	p.push_back(0);
	for(int i=1;i<=(1<<m)-1;i++){
		if(i==k)continue;
		p.push_back(i);
	}
	p.push_back(k);
	for(int i=(1<<m)-1;i>=1;i--){
		if(i==k)continue;
		p.push_back(i);
	}
	for(int i=0;i<(int)p.size();i++){
		cout<<p[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 2932