akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main() {
  int n,k;
  cin >> n >> k;
  int R,S,P;
  cin >> R >> S >> P;
  string t;
  cin >> t;
  int ans = 0;
  vbool judge(t.size());
  rep(i,t.size()){
    if(t[i] == 'r'){
      if(i - k >= 0){
        if(judge[i-k] != true){
          judge[i] = true;
          ans += P;
        }
        else if(t[i-k] != 'r'){
          judge[i] = true;
          ans += P;
        }
      }
      else{
        judge[i] = true;
        ans += P;
      }
    }
    if(t[i] == 's'){
      if(i - k >= 0){
        if(judge[i-k] != true){
          judge[i] = true;
          ans += R;
        }
        else if(t[i-k] != 's'){
          judge[i] = true;
          ans += R;
        }
      }
      else{
        judge[i] = true;
        ans += R;
      }
    }
    if(t[i] == 'p'){
      if(i - k >= 0){
        if(judge[i-k] != true){
          judge[i] = true;
          ans += S;
        }
        else if(t[i-k] != 'p'){
          judge[i] = true;
          ans += S;
        }
      }
      else{
        judge[i] = true;
        ans += S;
      }
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

ll mod=1e9+7;

long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}


int main(){
    ll k,l;
    string s;
    cin>>k>>s;
    l=s.size();
    vector<ll> x25(l+k+1,1),x26(l+k+1,1),con(l+k+2,1);
    rept(i,1,l+k+1){
        x25[i]=x25[i-1]*25%mod;
        x26[i]=x26[i-1]*26%mod;
    }
    rept(i,l-1,l+k+2){
        con[i+1]=((con[i]*(i+1))%mod)*modinv(i+2-l,mod)%mod;
    }
    ll sum=0;
    rept(i,l,l+k+1){
        sum+=con[i-1]*x25[i-l]%mod*x26[l+k-i]%mod;
        sum%=mod;
    }
    cout<<sum<<endl;
   // cout<<x25<<x26<<con<<endl;
    return 0;
}


Measured memory_bytes: 51208
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>n;
    rep(i,1,n+1)
    {
        if((i%5!=0)&&(i%3!=0)) sum+=i;
    }
    cout<<sum;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N ;
  string S ;
  cin >> N >> S ;
  int count = 0;
  
  for(int i = 0; i <= N - 3 ; i++){
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') count++;
    
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
b1, b2, b3 = map(int,input().split())
if b1 == 1:
    if b2 == 1:
        print('Open')
    else:
        print('Close')
else:
    if b2 == 0:
        if b3 == 1:
            print('Open')
        else:
            print('Close')
    else:
        print('Close')


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <iomanip>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int L;
  std::cin >> L;
  double len = L / 3.0;
  std::cout << std::fixed << std::setprecision(20) << len * len * len << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

bool deliver(int n, int k, long long W[], long long P) {
    int garbage = 0;
    for (int j = 0; j < k; j++ ) {
        long long s = 0;
        while (s + W[garbage] <= P) {
            s += W[garbage];
            garbage++;
            if (garbage == n) return true;
        }
    }
    return false;
}

int binary_search(int n, int k, long long W[]) {
    int end = n * 10000;
    int begin = 0;

    while(end - begin > 0) {
        int mid = (begin + end) / 2;
        if (deliver(n, k, W, mid)) {
            end = mid;
        } else {
            begin = mid + 1;
        }
    }
    return begin;
}

int main(void) {
    int n, k;
    long long W[100000];

    cin >> n >> k;
    for (int i = 0; i < n; i++ ) cin >> W[i];
    int ans = binary_search(n, k, W);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3864
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String n = scan.nextLine();
    String p = scan.nextLine();
    String q = scan.nextLine();

    List<Integer> pArray = Arrays.stream(p.split(" ")).map(Integer::valueOf)
        .collect(Collectors.toList());
    List<Integer> qArray = Arrays.stream(q.split(" ")).map(Integer::valueOf)
        .collect(Collectors.toList());

    int pans = 0;
    List<Integer> tmpLIst = new ArrayList<>();
    while (!pArray.isEmpty()) {
      tmpLIst.clear();
      tmpLIst.addAll(pArray);
      pans = pans + calc(tmpLIst);
      pArray.remove(0);
    }

    int qans = 0;
    while (!qArray.isEmpty()) {
      tmpLIst.clear();
      tmpLIst.addAll(qArray);
      qans = qans + calc(tmpLIst);
      qArray.remove(0);
    }
    System.out.println(pans >= qans ? pans - qans : qans - pans);
    scan.close();
  }

  static int calc(List<Integer> list) {

    if (list.size() == 1) {
      return 1;
    }

    int base = list.get(0);
    Collections.sort(list);
    int index = list.indexOf(base);

    int f = 1;
    for (int i = 1; i < list.size(); i++) {
      f = f * i;
    }
    return index * f;
  }
}

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

int main() {
  int a, b, a1, a2, b1, b2, c;
  cin >> a >> b;
  a1 = a/10000;
  a2 = a/1000-10*a1;
  b1 = b/10000;
  b2 = b/1000-10*b1;
  if (a%1000 > a%1000-a%100+a1+10*a2) c+=1;
  if (b%1000 < b%1000-b%100+b1+10*b2) c+=1;
  cout << b/100-a/100-c+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n, h;
vector<string> hint;
vector<bitset<10> > digit;
bitset<10> used;
string ret;

void solve(string& s, int i, int& num, vector<int>& hit0, vector<int>& blow0)
{
    if(i == n){
        ret = s;
        ++ num;
        return;
    }

    for(int j=0; j<10; ++j){
        if(used[j])
            continue;
        used[j] = true;
        s[i] = j + '0';

        vector<int> hit = hit0;
        vector<int> blow = blow0;
        bool ng = false;
        for(int k=0; k<h; ++k){
            if(s[i] == hint[k][i])
                -- hit[k];
            else if(digit[k][s[i]-'0'])
                -- blow[k];
            if(hit[k] < 0 || blow[k] < 0 || hit[k]+blow[k] >= n-i){
                ng = true;
                break;
            }
        }

        if(!ng)
            solve(s, i+1, num, hit, blow);

        used[j] = false;
        if(num == 2)
            break;
    }
}

int main()
{
    for(;;){
        cin >> n >> h;
        if(n == 0)
            return 0;

        hint.resize(h);
        digit.assign(h, 0);
        vector<int> hit(h), blow(h);
        for(int i=0; i<h; ++i){
            cin >> hint[i] >> hit[i] >> blow[i];
            for(int j=0; j<n; ++j)
                digit[i][hint[i][j] - '0'] = true;
        }

        string s(n, ' ');
        int num = 0;
        solve(s, 0, num, hit, blow);
        if(num == 1)
            cout << ret << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 920
#include<iostream>
#include<cstring>

using namespace std;

int main(){
    string S, T; cin >> S >> T;
    int n = S.size();
    int c = 0;
    
    for(int i = 0; i < n;i++) 
        if(S[i] != T[i]) c++;
      	  
    cout << c << endl;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define sz 200005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

int main()
{
    faster_io;
    int n,m,mx,mn,x=1,y,j;
    cin>>n>>m;

    y = ceil(log(m)/log(2));
    y = pow(2.0,y);
//    cout<<y<<endl;
    for(int i=2;i<=n;i++){
        int cnt=0;
        j = i;
        while(j<m){
            j = j<<1;
            cnt++;
        }
//        cout<<cnt<<endl;
        x+=(y/pow(2.0,cnt));
    }

    y*=n;
//
//    cout<<x<<" "<<y<<endl;
////    x = 49995;
    double ans = double(x)/y;
//    cout<<fixed<<setprecision(12)<<ans<<endl;
    printf("%.10lf\n",ans);

    return 0;
}






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

int main(){
    string s;
    cin >> s;
    bool ans=true;
    if(s.at(0)==s.at(1) && s.at(1)==s.at(2))ans=false;
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
main = do
  s <- getLine

  let shrink [] _ _ = 10^9
      shrink s c res | s == replicate (length s) c = res
                     | otherwise = shrink s' c (res+1)
        where
          s' = map (\i -> if s !! i == c || s !! (i+1) == c then c else 'X') [0..(length s - 2)]

      solve [] ans     = ans
      solve (c:cs) ans = solve cs (min ans (shrink s c 0))

  print $ solve ['a'..'z'] (10^9)

Measured memory_bytes: 1404
#include <stdio.h>

	int main(void){
		int n,k;
		scanf("%d %d",&n,&k);
		long x[100000]={};
		long m[100001]={};
		long p[100001]={};
		m[0]=0;
		p[0]=0;
		int a=1,b=1;
		int i;
		int minus = 0;//マイナス側に置かれているろうそくの数
		int plus = 0; //プラス側に置かれているろうそくの数
		for(i=0;i<n;i++){
			scanf("%ld",&x[i]);
				if(x[i]==0){		//もしも座標0にろうそくがあったならば
					k--;
				}
			if(x[i]<0){ //minusの座標に置かれているろうそくの数をカウントする
				minus++;
			}
			if(x[i]>0){
				p[b] = x[i];//0からb本のろうそくをプラス側に火をつけるのにかかる時間はp[b]
				b++;
				plus++;
			}
		}
		//printf("plusの本数は%d\n",plus);
		//printf("minusの本数は%d\n",minus);
		//原点からプラス座標にn本火をつけるのにかかる時間をp[n]とする。
		//原点からマイナス座標にn本火をつけるのにかかる時間をm[n]とする。
		for(i=minus;i>0;i--){
			m[a]=-(x[i-1]);
			a++;
		}
		//printf("0からプラス座標に2本火をつけるのにかかる時間は%d\n",p[2]);
		//printf("0からマイナス座標に1本火をつけるのにかかる時間は%d\n",m[1]);
		//あとは原点から左にi本右からk-i本火をつけると考える
		long ans = 2*1000000000;
		long temp;
		long temp2;
		if(k==0){
			ans=0;
			printf("%ld",ans);
			return 0;
		}
		for(i=0;i<=k;i++){
			if( (k-i)>plus){
				continue;
			}
			if( i>minus){
				continue;
			}
			temp = 2*m[i]+p[k-i];
			temp2= m[i]+2*p[k-i];
			if( ans > temp){
				ans = temp;
			}
			if(ans > temp2){
				ans =temp2;
			}
		}
		printf("%ld",ans);
		return 0;
	}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける



int main() {
	ll h;
	cin >> h;
	ll target = h;
	ll monster = 1;
	ll div = 0;
	while (target > 1) {
		target /= 2;
		div+=monster;
		monster *= 2;
	}
	ll ans = div + monster;
	cout << ans << endl;
}


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

using namespace std;
set<long long> s1;
const long long MAXN = 3e5+5;
long long obs[MAXN];
long long h[MAXN];vector<long long> v1;
long long ans;
int main(){
    long long x;
    cin>>x;
    long long curr =1;
    v1.push_back(0);
    while(true){
        long long hold = curr*curr*curr*curr*curr;
       
        if(hold>1e18){
            break;
        }
        v1.push_back(hold);
        curr++;
    }
    for(long long i=0;i<v1.size();i++){
        for(long long j=0;j<v1.size();j++){
            if(v1[i]+v1[j] == x){
                cout<<(i)<<" "<<-j<<endl;
                return 0;
            }
            if(v1[i]-v1[j] == x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll K; cin >> K;

  //main
  deque<ll> dq;
  for(int i=1; i<=9; i++){
    dq.push_back(i);
  }
  
  ll c = 0;
  ll ans = 0;
  while(c < K){
    ll now = dq.front(); dq.pop_front();
    ans = now;
    if(now%10 == 0){
      dq.push_back(now*10+0);
      dq.push_back(now*10+1);
    }else if(now%10 == 9){
      dq.push_back(now*10+8);
      dq.push_back(now*10+9);
    }else{
      dq.push_back(now*10+now%10-1);
      dq.push_back(now*10+now%10);
      dq.push_back(now*10+now%10+1);
    }
    c ++;
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
 
int main() {
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 1, type = 0;
	for (int i = 1; i < n; i++) {
		if (type == 1 && a[i] < a[i - 1]) {
			type = 0; ans++;
		}
		else if (type == 2 && a[i] > a[i - 1]) {
			type = 0; ans++;
		}
		else if (type == 0 && a[i] < a[i - 1]) {
			type = 2;
		}
		else if (type == 0 && a[i] > a[i - 1]) {
			type = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
ll fact_mod(ll n, ll mod) {
    ll f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}
// 繰り返し二乗法 (再帰バージョン)
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    ll b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}
int N,A,B,C,D;
int main(){
	cin>>N>>A>>B>>C>>D;
	//%MOD下での階乗
	ll ex[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		ex[i]=ex[i-1]*i%MOD;
	}
	//%MOD下での階乗の逆数
	ll inv[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		inv[i]=mod_pow(i,MOD-2,MOD);
	}
	for(int i=1;i<SIZE;i++){
		inv[i]=inv[i-1]*inv[i]%MOD;
	}
	//モジュラ逆元
	ll gyaku[SIZE]={1,0};
	//コンビネーション
	ll comb[SIZE][SIZE]={};
	for(int i=0;i<SIZE;i++)
		for(int j=0;j<=i;j++)
			comb[i][j]=ex[i]*inv[i-j]%MOD*inv[j]%MOD;
	for(int i=1;i<SIZE;i++)
		gyaku[i]=mod_pow(i,MOD-2,MOD);
	//DP[j][i]=j人をi人以下のグループに分けるときの分け方
	ll DP[SIZE][SIZE]={};
	for(int i=0;i<=N;i++)
		DP[i][0]=1;
	for(int i=A;i<=B;i++){
		for(int j=0;j<=N;j++){
			//DP[i][j]が0のときは、無意味なので飛ばす
			if(DP[i][j]==0)
				continue;
			//k==0のとき、func()==1;
			//j==0のときは足さない（1なので）
			if(j!=0){
				DP[i+1][j]+=DP[i][j];
				DP[i+1][j]%=MOD;
			}
			//Fをつくる
			ll F=1;
			//(N-j)Ci*(N-j-i)Ci*...*(N-j-(C-1)i)Ci
			for(int k=0;k<C;k++){
				if(N-j-k*i>=0)
					F*=comb[N-j-k*i][i];
				F%=MOD;
				F*=gyaku[k+1];
				F%=MOD;
			}
			for(int k=1;k<=D;k++){
				//N以上に遷移する必要はない
				if(j+i*k>N)
					break;
				if(C<=k){
					DP[i+1][j+i*k]+=DP[i][j]*F%MOD;
					DP[i+1][j+i*k]%=MOD;
					F*=comb[N-j-k*i][i];
					F%=MOD;
					F*=gyaku[k+1];
					F%=MOD;
				}
			}
		}
	}
	cout<<DP[B+1][N]<<endl;
	return 0;
}

Measured memory_bytes: 17536
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n; cin >> n;
	ll cnt = 0;
	cnt += n / 100000000;
	cnt += n % 100000000 / 10000000;
	cnt += n % 10000000 / 1000000;
	cnt += n % 1000000 / 100000;
	cnt += n % 100000 / 10000;
	cnt += n % 10000 / 1000;
	cnt += n % 1000 / 100;
	cnt += n % 100 / 10;
	cnt += n % 10;
	if (n % cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
  char s[101];
  int i=0;
  for(i=0;i<101;i++){
    s[i]=0;
  }
  scanf("%s",s);
  i=0;
  while(s[i]!=0){
    printf("x");
    i++;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 1050
using namespace std;
int a[N],n,ans;
inline int rd() {
    int x=0,f=1;char ch=getchar();
    while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return x*f;
}
int main() {
    n = rd() * 2;
    for (int i=1;i<=n;i++) a[i] = rd();
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i+=2) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
#include <cassert>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ld = long double;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES(x, y) ifstream fin(x); ofstream fout(y);
#define PI_NUM acos(-1.0)

void solve() {
    ll n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << 0;
        return;
    }

    vll a(n);
    for (auto &i : a) {
        cin >> i;
    }

    vll prefixSums(n, a[0]);
    for (int i = 1; i < n; i++) {
        prefixSums[i] = prefixSums[i - 1] + a[i];
    }

    for (int i = 0; i < n; i++) {
        prefixSums[i] -= i;
    }

    for (int i = 0; i < n; i++) {
        prefixSums[i] %= k;
    }

    vll ps;
    ps.push_back(1);
    for (int i = 0; i < n; i++) {
        ps.push_back(prefixSums[i]);
    }

    ll ans = 0;
    int lastToDelete = 0;
    unordered_map<ll, ll> mp;

    for (int r = 0; r < len(ps); r++) {
        int l = max(0, r + 1 - (int) k);
        if (l > lastToDelete) {
            mp[ps[lastToDelete]]--;
            lastToDelete = l;
        }
        ans += mp[ps[r]];
        mp[ps[r]]++;
    }

    cout << ans;
}

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


Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

/*ll dp[100001],path[100001];

void init(){
	f(i,0,100001){
		dp[i]=-1;
	}
}

void solve(ll n){
	if(i==1){
		return dp[n]=1;
	}

	if(dp[n]!=-1){
		return dp[n];
	}else{
		if()
	}
}
*/
int main(){
	ini();

	string s;
	cin >> s;
	if(s=="ABC"){
		cout << "ARC";
	}else{
		cout << "ABC";
	}

}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

#define inf 1e9;

int main() {
  int N;
  cin >> N;
  vector<int> cost(N+1, 0);
  vector<int> heights(N+1, 0);
  cost[0] = inf;
  rep(i, 0, N) {
    cin >> heights[i+1];
  }

  rep(i, 2, N+1) {
    cost[i] = min(abs(heights[i] - heights[i - 2]) + cost[i - 2], abs(heights[i] - heights[i - 1]) + cost[i - 1]);
  }

  cout << cost[N] << endl;

  return 0;
};


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

namespace YAKINIKU
{
    class YAKINIKU
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();

            if (inp.Length < 4)
            {
                Console.WriteLine("No");
                return;
            }

            if (inp.Substring(0, 4)=="YAKI")
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            return;
        }
    }
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

string trans (string S, string f, string t) {
    string ret;
    REP (i, S.length()) {
        int idx = ALL (find, f, S[i]) - f.begin();
        ret += t[idx];
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cout << trans (S, alp, alp.substr (N) + alp.substr (0, N)) << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    //if it have spaces we use getline
    //string bt3aml m3ah 3ala eno ""
    //bs el char ''
    //hena et3mlt m3ah 3ala asas eno array of char



    for(int i=0;i<19;i++){

        if(s[i]== ','){
            s[i]=' ' ;
            //konna lazm n3ml cout 3shan y3'yr w ntb3
            cout<<s[i];

        }
        else
            cout<<s[i];
        }



              //  cout<<s;






    return 0;
}

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

#define print(n) cout  << n << "\n"

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) {
		print("delicious");
	}else if (a+x- b>=0) {
		print("safe");
	}
	else {
		print("dangerous");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[12];
  int i,j,n[10];;
  while(fgets(s,12,stdin)!=NULL){
    for(i=0;i<10;i++){
      n[i]=s[i]-'0';
    }
    for(i=0;i<10;i++){
      for(j=0;i+j<9;j++){
	n[j]+=n[j+1];
	n[j]%=10;
      }
    }
    printf("%d\n",n[0]);
  }
  return 0;
}

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

int main()
{
    int n,ans;

    cin >> n;

    if (n % 1000 == 0)
        ans = 0;
    else
        ans = 1000 - (n % 1000);

    cout << ans << endl;

    return 0;
}


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

int main(){
	string s,t; cin >> s >> t;
	map<char,char> mp;
	bool r = true;
	rep(i,s.size()){
		if (!(mp.count(s.at(i)))) {
			mp[s.at(i)] = t.at(i);
		}
		else {
			if(mp.at(s.at(i)) != t.at(i)){
				r = false;
				break;
			}	
		}
	}
	map<char,char> lp;
	rep(i,s.size()){
		if (!(lp.count(t.at(i)))) {
			lp[t.at(i)] = s.at(i);
		}
		else {
			if(lp.at(t.at(i)) != s.at(i)){
				r = false;
				break;
			}	
		}
	}
	if(r)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 776
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            string[] num = Console.ReadLine().Split();

            for (int i = count - 1; i >= 0; i--)
            {
                Console.Write(num[i]);
                if (i != 0) Console.Write(" ");
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15924
#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <algorithm>
using ui32 = std::uint_fast32_t;
using std::scanf;
using std::printf;
ui32 F[2][3];
int main()
{
	ui32 N, a, b, c, tmp[2];
	scanf("%" SCNuFAST32, &N);
	while (N--)
	{
		tmp[0] = N & static_cast<ui32>(1);
		tmp[1] = tmp[0] ^ static_cast<ui32>(1);
		scanf("%" SCNuFAST32 "%" SCNuFAST32 "%" SCNuFAST32, &a, &b, &c);
		F[tmp[1]][0] = std::max(F[tmp[0]][1], F[tmp[0]][2]) + a;
		F[tmp[1]][1] = std::max(F[tmp[0]][0], F[tmp[0]][2]) + b;
		F[tmp[1]][2] = std::max(F[tmp[0]][0], F[tmp[0]][1]) + c;
	}
	printf("%" PRIuFAST32 "\n", *std::max_element(F[1], F[1] + 3));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

bool ck(string s) {
  rep(i,s.size()) {
    if(s[i]!=s[s.size()-1-i]) return 0;
  }
  return 1;
}

void Main() {
  string s;
  cin >> s;
  if(ck(s)&&ck(s.substr(0,s.size()/2))&&ck(s.substr(s.size()/2+1,s.size()/2))) pr("Yes");
 else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int n, m;
    cin >> n >> m;
    VI a(m);
    int sum = 0;
    REP(i,m){
        cin >> a[i];
        sum += a[i];
    }
    if(n >= sum){
        cout << n - sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    rep(i, N) cin >> P[i], P[i]--;
    rep(i, N) cin >> C[i];

    ll ans = -INF;

    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;

        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }

        ll path = 0;
        int cnt = 0;

        while (true) {
            cnt++;
            path += C[v];

            if (cnt > K) break;

            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0LL, cycle_sum) * num;
            ans = max(ans, score);

            v = P[v];
            if (v == i) break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3676
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define inf 1000000000000000001
#define pii pair<int, int>
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

const int N = 4e5;
const int MOD = 1e9 + 7;

int fac[N + 10], ifac[N + 10];

int power(int x, int t){
    int ans = 1;
    while(t > 0) {
        if(t & 1) ans = 1LL * ans * x % MOD;
        x = 1LL * x * x % MOD;
        t >>= 1;
    }
    return ans;
}

void init_fac(){
    fac[0] = 1;
    for(int i = 1; i < N; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
    }
    ifac[N - 1] = power(fac[N - 1], MOD - 2);
    for(int i = N - 1; i >= 1; i--){
        ifac[i - 1] = (ifac[i] * i) % MOD;
    }
}

int C(int n, int m)
{
	if(n < m) return 0;
	return fac[n] * (1LL * ifac[m] * ifac[n - m] % MOD) % MOD;
}

int n, k;
int arr[N];


int32_t main(){ _
    init_fac();
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    sort(arr + 1, arr + 1 + n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i <= n - k + 1) {
            int min_way = C(n - i, k - 1);
            ans = (ans - (min_way * arr[i]) % MOD + MOD) % MOD; 
        }
        if (i >= k) {
            int mx_wau = C(i - 1, k - 1);
            ans = (ans + (mx_wau * arr[i]) % MOD) % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s;
  cin>>s;
  int n=s.size();
  int zc=0;
  int oc=0;
  rep(i,n) {
    if(s[i]=='1') {
      zc++;
    } else {
      oc++;
    }
  }
  cout << 2*min(zc,oc)<<endl;
  return 0;
}


Measured memory_bytes: 512
object Main {
  def main(args: Array[String]) = {

    val pw = new java.io.PrintWriter(System.out)
    val sc = new java.util.Scanner(System.in)
    val S = sc.nextLong
    sc.close()

    val num = 1000000000L
//    val s1 = S / num
//    val s2 = S % num
    //  pw.println(s"${s1 + s2} ${s2} ${num - 1} ${num} 0 0")
    val x = (num - S % num) % num
    val y = (S + x) / num
    pw.println(s"0 0 ${num} 1 ${x} ${y} ")

    pw.flush()
  }
}

Measured memory_bytes: 27312
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    A, B = map(int, input().split())

    ans = 0

    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

class Node {
	Node[] to;
	Node[] from;
	int n;
}

void main() {
	int m = to!int(readln().strip());
	int n = to!int(readln().strip());

	auto nodes = new Node[m];
	foreach(i; 0..m) {
		nodes[i] = new Node;
		nodes[i].n = i+1;
	}
	foreach(i; 0..n) {
		auto s = map!(a => to!int(a)-1)(readln().strip().split());
		nodes[s[0]].to ~= nodes[s[1]];
		nodes[s[1]].from ~= nodes[s[0]];
	}
	Node[] S;
	foreach(node; nodes) {
		if(node.from.empty())
			S ~= node;
	}
	Node[] L;
	while(!S.empty()) {
		L ~= S.front;
		S.popFrontN(1);
		foreach(node; L.back.to) {
			node.from = remove!(a => a == L.back)(node.from);
			if(node.from.empty())
				S ~= node;
		}
	}
	foreach(node; L) {
		writeln(node.n);
	}
}

Measured memory_bytes: 1108
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if(a*b % 2 == 0){
			System.out.println("Even");

		}else{
			System.out.println("Odd");

		}
	}
}




class Graph{
	int from;
	int to;
	int cost;

	public Graph() {
	}

	public Graph(int f,int t,int c) {
		from = f;
		to= t;
		cost = c;
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
  	ll B=0;
    ll Ans=1;
    bool OK=true;
    rep(i, N){
        cin>>A[i];
        Ans*=A[i];
        if(Ans>1000000000000000000)OK=false;
        if(A[i]==0){
          cout<<0<<endl;
          return 0;
        }
      	while(A[i]>9){
          	A[i]/=10;
          	B++;
        }
    }
  	if(B>18)OK=false;
  	if(B==18){
      	if(Ans!=1000000000000000000)OK=false;
    }
    if(!OK){
        cout<<-1<<endl;
    }else{
        cout<<Ans<<endl;
    }

}

Measured memory_bytes: 3920
class Unionfind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n)
        
    def find(self, x):
        if(self.parents[x] < 0):
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if(x == y):
            return
        
        if(self.parents[x] > self.parents[y]):
            x, y = y, x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())

n, m = map(int,input().split())
uf = Unionfind(n)


for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

print(uf.group_count()-1)


Measured memory_bytes: 13020
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<long long, long long>


using namespace std;
const long long int MOD=1e9+7;

int main(){
   long long h, n, a[100009];
   cin >>h>>n;
   for(long long i=0;i<n;i++)cin >> a[i];
   long long sm=0;
   for(int i=0;i<n;i++)sm+=a[i];
   cout << (sm>=h?"Yes": "No") << endl;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// スペース区切りの文字列から int のスライスを得る
func intSlice(s string) []int {
	ss := strings.Split(s, " ")
	res := make([]int, len(ss))
	for i, v := range ss {
		iv, _ := strconv.Atoi(v)
		res[i] = iv
	}

	return res
}

var limit int = 1000000007

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	broken := make([]bool, n+1)
	for i := 0; i < m; i++ {
		var a int
		fmt.Scan(&a)
		broken[a] = true
	}

	dp := make([]int, n+2)
	dp[n+1] = 0
	dp[n] = 1
	for i := n - 1; i >= 0; i-- {
		if broken[i] {
			dp[i] = 0
		} else {
			dp[i] = (dp[i+1] + dp[i+2]) % limit
		}
	}

	fmt.Println(dp[0] % limit)
}


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

int main(void)
{
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i < N; i++){
        cin >> A[i];
    }
    
    map<int, int> cnt;
    long long ans=0;

    for(int i=0; i<N; i++){
        int sa = i - A[i];
        ans += cnt[sa];
        int wa = i + A[i];
        cnt[wa]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 21124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int sum (int n)
{
   int re=0;
   while(n)
   {
      re+=n%10;
      n/=10;
   }
   return re; 
}

int main()
{
   int n;
   cin >> n;
   int ans = 111111111;
   for(int i=1;i<n;i++)
   {
      int now=0;
      now+=sum(n-i);
      now+=sum(i);
      ans = min(ans,now);
   }
   cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 256
a = {}
while True:
    try:
        a_i = int(input())
        if a_i in a:
            a[a_i] += 1
        else:
            a[a_i] = 1
    except:
        break
mode_count = max(a.values())
b = []
for key, value in a.items():
    if value == mode_count:
        b.append(key)
print(*sorted(b),sep="\n")




Measured memory_bytes: 5600