akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        long ans = 0;
        for(int i = 0; i < n-1; i++){
            ans += a[i];
        }
        pw.println(ans + a[n-1]/2);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25344
"""
python3 main.py < input.txt
"""
import math
import itertools as it
import heapq
"""
A,B,T=map(int, input().split())
print(int(math.floor((T+0.5)/(A))*B))
"""
"""
N=int(input())
V=list(map(int, input().split()))
C=list(map(int, input().split()))
print(sum([V[i] - C[i] for i in range(N) if V[i] - C[i] > 0]))
"""
"""
N=int(input())
A=list(enumerate(map(int, input().split())))
l=list(A)
l.sort()

x=(-1, -1)
y=(-1, -1)

while l[0][1] != 0:
        l=list(map(lambda it: (it[0], it[1]%l[0][1]), l[1:]))
        (i, xi) = x
"""
N=int(input())
A=list(map(int, input().split()))
nNeg = len([1 for a in A if a < 0])
minAbs = min(A, key=lambda ai: abs(ai))
if nNeg%2 == 0:
        print(sum([abs(ai) for ai in A]))
else:
        print(-2*abs(minAbs) + sum([abs(ai) for ai in A]))

Measured memory_bytes: 14460
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        boolean[][] cards = new boolean[4][13];
        for(int i = 0; i < x; i++){
            String s = input.next();
            int num = input.nextInt();
            switch(s){
                case "S":
                    cards[0][num-1] = true;
                    break;
                case "H":
                    cards[1][num-1] = true;
                    break;
                case "C":
                    cards[2][num-1] = true;
                    break;
                case "D":
                    cards[3][num-1] = true;
                    break;
            }
        }
        for(int i = 0; i < cards.length; i++){
            for(int n = 0; n < cards[i].length; n++){
                if(!cards[i][n]){
                    switch(i){
                        case 0:
                            System.out.println("S "+(n+1));
                            break;
                        case 1:
                            System.out.println("H "+(n+1));
                            break;
                        case 2:
                            System.out.println("C "+(n+1));
                            break;
                        case 3:
                            System.out.println("D "+(n+1));
                            break;
                    }
                }
            }
        }
    }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	
	ll sum = 0;
	rep(i, n) sum += a[i];
	ll m = n * (n + 1) / 2;
	if (sum % m != 0) {
		cout << "NO" << endl;
		return 0;
	}
	ll time = sum / m;
	
	rep(i, n) {
		ll dif = a[(i + 1) % n] - a[i];
		dif -= time;
		if (dif > 0) {
			cout << "NO" << endl;
			return 0;
		}
		if (dif % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int x,y;
while(cin >> x >> y) cout << x+y/2 << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {
    
    int n;
    cin>>n;
    vector<int> a(n);
    vector<vector<int>> x(n,vector<int>(n));
    vector<vector<int>> y(n,vector<int>(n));
    rep(i,n) {
        cin>>a[i];
        rep(j,a[i]) {
            cin>>x[i][j]>>y[i][j];
        }
    }

    //n個についてbit全探索
    //t[i]をtrue,falseで判断
    int ans=0;
    vector<int> t(n);
    for(int bit=0; bit <(1<<n); ++bit) {
        for(int i=0;i<n;i++) {
            if(bit & (1<<i))    t[i]=1;
            else    t[i]=0;
        }
        //ここから処理を書く
        rep(i,n) {
            if(t[i]==1) {
                rep(j,a[i]) {
                    if(t[x[i][j]-1]!=y[i][j])   i=j=n;
                }
            }
            if(i==n-1)  {
                int sum=0;
                rep(i,n) {
                    sum+=t[i];
                }
                ans=max(ans,sum);
            }
        }
    }

    cout<<ans<<endl;
    

 return 0;
}

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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << '\n';
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("lineup.in","r",stdin );
#define outF freopen("lineup.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define ll long long
#define int ll
const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const ll N = 200 , oo = 1e7 , M = 6, mod = 1e9 + 7 , K = 12;

int32_t main(){
    // inF;outF;

    fastio;
    // Dont Forget memset

    //calculate constraints please!!!
int n , k ;
cin >> n >> k ;
vector<int>v(n);
for(auto &it : v)cin >> it ;
sort(v.begin() , v.end());
int sum = 0 ;
for(int i = 0 ; i < k ; i ++)sum += v[i];
cout << sum ;

}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define rep(i,N) for(int (i) = 0;(i) < (N); (i)++)
int main(){
    std::cin.tie(nullptr);std::ios::sync_with_stdio(false);

    std::string s;std::cin>>s;
    std::map<char,int> m;
    bool flag = true;
    rep(i,s.size()){
        m[s[i]]++;
    }
    if(m.size()==2){
        for(const auto&a:m){
            if(a.second!=2)flag = false;
        }
    }else flag = false;

    if(flag == true)std::cout<<"Yes";
    else std::cout<<"No";

    return 0;
}


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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<string> a(n); for (auto&& e : a) cin >> e;
  V<string> b(m); for (auto&& e : b) cin >> e;
  REP(x, n - m + 1) REP(y, n - m + 1) {
    bool ok = true;
    REP(i, m) if (a[x + i].substr(y, m) != b[i]) {
      ok = false;
      break;
    }
    if (ok) return cout << "Yes\n", 0;
  }
  cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int W = 0;
  int H = 0;
  int x = 0;
  int y = 0;
  int r = 0;
  
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(H >= y + r && y - r >= 0 && W >= x + r && x - r >= 0)
    printf("Yes\n");
  else
    printf("No\n");
	
  return 0;
}

Measured memory_bytes: 584
// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	return 0;
}


Measured memory_bytes: 3612
N, K = map(int, input().split())
if 2 * K > (N - 1) * (N - 2):
  print(-1)
else:
  M = N - 1
  D = {1: [_ for _ in range(2, N+1)]}
  cnt = ((N - 1) * (N - 2)) // 2
  pnt = 2
  qnt = 3
  while cnt != K:
    cnt -= 1
    if pnt in D:
      D[pnt].append(qnt)
    else:
      D[pnt] = [qnt]
    qnt += 1
    if qnt == N + 1:
      pnt += 1
      qnt = pnt + 1
    M += 1
  print(M)
  for i in D:
    for j in D[i]:
      print(i, j)

Measured memory_bytes: 3608
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val c1 = sc.next()
    val c2 = sc.next()
    println(problem077a(c1, c2))
}

fun problem077a(c1: String, c2: String): String {
    return if (c1 == c2.reversed() && c1.reversed() == c2) "YES" else "NO"
}

Measured memory_bytes: 31396
import java.util.*;
        public class Main {
        	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long x=n/k;
		if(Math.abs(n-x*k)<Math.abs(n-(x+1)*k)){

			System.out.print(Math.abs(n-x*k));
		}else{
			System.out.print(Math.abs(n-(x+1)*k));
		}
	}
        }

Measured memory_bytes: 21588
#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()
using ll = long long;
using P = pair<int, int>;

int main(){
    int x;
    cin >> x;
    int sum = 0;
    rep(i, x+1) {
        sum += i;
        if(sum >= x) {
            cout << i << endl;
            return 0;
        } 
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);
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;}

int main(){
    int n; cin >> n;
    bool isOk = false;
    for(int i=1; i<=9;i++){
        int x;
        if(n % i == 0){
            x = n/i;
            if(1 <= x && x<=9){
                isOk = true;
                break;
            }
        }
    }
    if(isOk){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


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

r = x % d
m = x // d
if m > k:
    print(x - k * d)
elif (-m) > k:
    print(abs(x + k * d))
elif (k - m) % 2 == 0:
    print(r)
else:
    print(d - r)

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
ll const mod = 1e9+7;

const int MAX_N = 2000010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void init(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    init(2000005);
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    ll ans = 0;
    for (int i = 0;i < k+1;++i) {
        (ans += combi(n+k-i-1,k-i)*pow_mod(25,k-i)%mod*pow_mod(26,i)%mod) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 52132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, k; cin >> n >> k;
  outl(n - k + 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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(void) {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> bs(M, 0);
    for (int i = 0; i < M; i++) {
        cin >> bs[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int acc = 0;
        for (int j = 0; j < M; j++) {
            int x;
            cin >> x;
            acc += bs[j] * x;
        }

        if (acc + C > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
c1 = [int(v) for v in input().split()]
c2 = [int(v) for v in input().split()]
c3 = [int(v) for v in input().split()]

ans = 'No'
if (c1[0] - c1[1] == c2[0] - c2[1] == c3[0] - c3[1] and
    c1[1] - c1[2] == c2[1] - c2[2] == c3[1] - c3[2]):
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,x;
    cin >> n >> x;
    vi a(n);
    rep(i,n)cin >> a[i];
    int d = 0;
    int ans = 1;
    rep(i,n){
        d += a[i];
        if(d <= x)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,x,y,i;
	x=0;
	y=0;
	for(i=0;i<3;i++){
		scanf("%d",&n);
		if(n==5) x=x+1;
		else y=y+1;
	}
	if(x==2 && y==1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
x = int(input())

if x < 600:
	ans = 8
elif x < 800:
	ans = 7
elif x < 1000:
	ans = 6
elif x < 1200:
	ans = 5
elif x < 1400:
	ans = 4
elif x < 1600:
	ans = 3
elif x < 1800:
	ans = 2
elif x < 2000:
	ans = 1

print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*p[i] = iとなっている所をswap p[i] = iとなっている所が
K個隣合っている時、K%2 == 0ならK/2回 swap K%2 == 1ならK/2 +1回swap
*/
/*p[i] = iとなっている区間の長さをメモしていき、各々の区間に
おけるswap回数を足していく
*/
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N){
      cin >> p[i];
  }
  p.push_back(-1);
  vector<int> d;//連続区間の長さの列
  int c = 0;//連続区間の長さ
  for(int i = 0;i<p.size();i++){
      if(p[i] == i+1){
          c++;
      }
      else if(p[i] != i){
        d.push_back(c);
        c = 0;
      }
  }
  int ans = 0;
  for(int i = 0;i<d.size();i++){
      if(d[i]%2 == 0) ans += d[i]/2;
      else ans += d[i]/2 +1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1528
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N];
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int flag = 0, ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] == a[i-1])
			continue;
		if(n-i+1 == i-1){
			ans = a[i] - a[i-1];
			flag = 1;
		}
		if(flag == 1){
			if(a[i] == a[i-1])
				ans++;
			else
				flag = 0;
		}
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define m 1000000007
using namespace std;
int main()
{
    char a[1002][1002];
   int h,w;
    cin>>h>>w;
    for( int i=1;i<=h;i++)
    {
        for( int j=1;j<=w;j++)
        {
            cin>>a[i][j];
        }
    }
  
    ll int dp[h+1][w+1];
  
    for( int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
        dp[i][j]=1;
        }
        
    }


   
    for(int i=1;i<=h;i++)
    {
        for( int j=1;j<=w;j++)
        {
            if(a[i][j]=='#')
            {
                dp[i][j]=0;
            }
        }
    }
    for( int i=1;i<=w;i++){
        if(dp[1][i]==0)
    {
        for(int j=i;j<=w;j++)
        {
            dp[1][j]=0;
        }
        break;
    }
}

for( int i=1;i<=h;i++){
        if(dp[i][1]==0)
    {
        for( int j=i;j<=h;j++)
        {
            dp[j][1]=0;
        }
        break;
    }
}



 for(int i=2;i<=h;i++)
    {
        for(int j=2;j<=w;j++)
        {
            if(dp[i][j]!=0)
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%m;
        }
    }
    cout<<dp[h][w]<<endl;
}


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

void swap(int& a, int& b)
{
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
}

int gcd(int a, int b) // a>b
{
        int rem;
        rem = a%b;
        if(rem == 0){ return b; }
        else{ gcd(b, rem); }
}

int main()
{
        int a, b;
        int g, l;

        while(scanf("%d %d", &a, &b) != EOF){
                if(a<b){ swap(a, b); }
                g = gcd(a, b);
                l = a/g*b;
                cout << g << " " << l << endl;
        }
        return 0;
}

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

int main(int argc, char *argv[]) {
  int n;
  std::string s;
  std::cin >> n >> s;
  int x = 0, max = 0;
  for (auto &c : s) {
    if (c == 'I')
      ++x;
    else
      --x;
    max = std::max(max, x);
  }
  std::cout << max << std::endl;
}


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

int main() {
  int N;
  cin >> N;
  char S;
  string flag = "Three";
  for (int i=0; i<N; i++) {
    cin >> S;
    if (S == 'Y') {
    	flag = "Four";
    }
  }
  cout << flag << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;

priority_queue <int> q1,q2;
int sign[N],L[N],R[N],n,Ans,sum;
signed main()
{
	q1.push(0); q2.push(0);
	cin >> n; for(int i=1;i<=n;i++)
		cin >> L[i] >> R[i];
	for(int i=1;i<=n;i++) q1.push(-R[i]);
	for(int i=1;i<=n;i++) q2.push(L[i]);
	for(int i=0;i<=n/2;i++)
		sum+=2*(q2.top()+q1.top()),
		q1.pop(), q2.pop(),
		Ans=max(Ans,sum);
	cout << Ans << endl;
}

Measured memory_bytes: 4084
def getN():
    return int(input())

def getMN():
    return list(map(int, input().split()))

def getlist():
    return list(map(int, input().split()))

def valid(steps):
    for i , x in enumerate(sorted(steps)):
        if i != x:
            return i - 1

    return len(steps) - 1
#
n = getN()
za = []
for i in range(n):
    za.append(getlist())
ans = 0
from collections import defaultdict
kumi = defaultdict(int)

for i, pa in enumerate(za):
    for j, pb in enumerate(za):
        xa, ya = pa
        xb, yb = pb
        dfx = xa - xb
        dfy = ya - yb

        diff = str(dfx) + str(dfy)
        kumi[diff] += 1

if n == 1:
    print(1)
    import sys;sys.exit()
del kumi["00"]
print(n - max(list(kumi.values())))

# for p1 in za:
#     for p2 in za:
#         steps = []
#         if p1 == p2:
#             continue
#         xa, ya = p1
#         xb, yb = p2
#         dfx = xb - xa
#         dfy = yb - ya
#         if not (dfx or dfy):
#             continue
#         for p3 in za:
#             xc, yc = p3
#             if dfx:
#                 if (xc - xa) % dfx == 0:
#                     step = (xc - xa) // dfx
#                     if yc - ya == dfy * step:
#                         steps.append(step)
#
#             else:
#                 if xc == xa:
#                     if (yc - ya) % dfy == 0:
#                         steps.append((yc - ya) // dfy)
#         tmp = valid(steps)
#         print(p1, p2, tmp, steps)
#         if tmp > ans:
#             ans = tmp
#             if tmp == 3:
#                 print(p1, p2)
#
# print(n-ans)


Measured memory_bytes: 41584
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<pii> A(N);
    REP(i, N){
        cin >> A[i].fi;
        A[i].se = i+1;
    }
    SORT(A);

    REP(i, N){
        pr(A[i].se);
    }
}

Measured memory_bytes: 1664
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int n,a,x[200010],i;
    scanf("%d\n",&n);
    for(i=0;i<=n;i++){
        x[i]=0;
    }
    for(i=0;i<n-1;i++){
        scanf("%d ",&a);
        x[a]++;
    }
    for(i=1;i<=n;i++){
        printf("%d\n",x[i]);
    }
    return 0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <iomanip>
 
using namespace std;
 
int main(){
  int n;
  while(cin>>n&&n){
    vector<int> data((n+1)*(n+1));
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        cin>>data[i*(n+1)+j];
        data[i*(n+1)+n]+=data[i*(n+1)+j];
        data[n*(n+1)+j]+=data[i*(n+1)+j];
        data[(n+1)*(n+1)-1]+=data[i*(n+1)+j];
      }
    }
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++){
        cout<<setw(5)<<data[i*(n+1)+j];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<int> v(n);
    for (size_t i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    double value = static_cast<double>(v[0]);
    for (size_t i = 1; i < n; ++i) {
        value += static_cast<double>(v[i]);
        value /= 2.;
    }
    cout << fixed << setprecision(5) << value << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
using namespace std;
bool mapp[105][105];
int main () {
	int a, b;
	scanf("%d %d", &a, &b);
	SET(mapp, 0);
	a--; b--;
	bool flag = false;
	int st;
	FOR(i, 1, 100, 2) {
		FOR(j, 2, 100, 2) {
			if (!b) {
				flag = true; break;
			}
			mapp[i][j] = 1; b--;
		}
		if (flag) {
			st = i + 2; break;
		}
	}
	FOR(i, st, 100, 1) FOR(j, 1, 100, 1) mapp[i][j] = 1;
	flag = false;
	FOR(i, st + 1, 100, 2) {
		FOR(j, 1, 100, 2) {
			if (!a) {
				flag = true; break;
			}
			mapp[i][j] = 0; a--;
		}
		if (flag) break;
	}
	printf("100 100\n");
	FOR(i, 1, 100, 1) {
		FOR(j, 1, 100, 1) {
			printf("%c", mapp[i][j] ? '#' : '.');
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	if ( n%500 <= a ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      char[] sArr = s.toCharArray();
      Arrays.sort(sArr);

      String t = sc.next();
      char[] tArr = t.toCharArray();
      Arrays.sort(tArr);
      int i = 0, j = tArr.length - 1;
      while(i < sArr.length && j >= 0) {
        if(sArr[i] > tArr[j]) {
          System.out.println("No");
          return;
        } else if(sArr[i] < tArr[j]) {
          System.out.println("Yes");
          return;
        } else {
            i++; j--;
        }
      }
      if(i == sArr.length && j >= 0)
        System.out.println("Yes");
      else
        System.out.println("No");
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_K = 100, MAX_SQRTN = 100000;
ll N, K;
ll dp[MAX_K][MAX_SQRTN];

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

  cin >> N >> K;

  set<int> st;
  vector<ll> v;
  for (ll i = 1; i*i <= N; ++i) {
    st.insert(i);
    st.insert(N/i);
  }
  for (int a : st) {
    v.push_back(a);
  }
  sort(all(v));

  for (int i = 0; i < len(v); ++i) dp[0][i] = 1;
  for (int i = 1; i < K; ++i) {
    vector<ll> sum(len(v));
    sum[0] = dp[i-1][0];
    for (int j = 1; j < len(v); ++j) sum[j] = mod(sum[j-1] + dp[i-1][j]*(v[j]-v[j-1])%MOD, MOD);
    for (int j = 0; j < len(v); ++j) {
      ll a = N/v[j];
      int idx = lower_bound(all(v), a) - v.begin();
      dp[i][j] = mod(sum[idx], MOD);
    }
  }

  ll ans = dp[K-1][0];
  for (int i = 1; i < len(v); ++i) {
    ans = mod(ans + dp[K-1][i]*(v[i]-v[i-1])%MOD, MOD);
  }

  cout << ans << endl;

  return 0;
}


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


using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

typedef long long ll;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


// * Dinic法による最大流
template<typename T> struct MaxFlow {
	const T INF =  1LL<<59; //1 <<29;
	const int V;
	struct Edge { int to, rev; T cap; };
	vector<vector<Edge>> g;
	vector<int>  iter, level;
	
	void init() { for(int i = 0; i < V; i++) g[i].clear(); }
	MaxFlow(int su) : V(su), g(V) { };
	void add(int from, int to, T cap) {
		g[from].push_back(Edge{to, (int)g[to].size(), cap});
		g[to].push_back(Edge{from, (int)g[from].size()-1, 0});
	}

	void bfs(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		for(;!que.empty();) {
			int v = que.front(); que.pop();
			for(const Edge& e: g[v]) if(e.cap > 0){
				if (level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	T dfs(int v, int t, T f) {
		if (v == t) return f;
		for(int &i = iter[v]; i < (int)g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap <= 0) continue;
			if (level[v] < level[e.to]) {
				T d = dfs(e.to, t, min(f, e.cap));
				if (d <= 0) continue;
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}

	T exec(int s, int t) {
		level.assign(V, -1);
		iter.assign(V, 0);
		T flow = 0;
		for(;;) {
			bfs(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			T f;
			for(;(f = dfs(s, t, INF)) > 0;) flow += f;
		}
	}
};



int main() {

	int n; cin >>n;
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	
	MaxFlow<ll> mf(n+5);
	int S=n, T=n+1;
	ll psm=0;
	
	rep(i,n){
		if(a[i]>0){
			mf.add(i, T, a[i]);
			mf.add(S, i, 0);
			psm += a[i];
		}else{
			mf.add(S, i, -a[i]);
			mf.add(i, T, 0);
		
		}
	}
	rep(i,n) rep2(j, i+1,n){
		if((j+1)%(i+1)==0) mf.add(i, j, mf.INF);
	}
	ll res = mf.exec(S, T);
	cout << psm - res <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <math.h>
#include <iterator>
#include <iomanip>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <cctype>
#include <ctime>
#include <climits>
#include <limits>
#define fore(i,a,b) for(ll i = (a),_b = (b); i < (_b); i++)
#define fort(i,a,b) for(ll i = (a),_b = (b); i <= (_b); i++)
#define ford(i,a,b) for(ll i = (a),_b = (b); i >= (_b); i--)
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define pb push_back
#define pf push_front
//#define LOCAL
using namespace std;

typedef long long ll;

const ll maxD = 1e2 + 5;
const ll maxN = 1e4 + 5;
const ll MOD = 1e9 + 7;

ll d,n;
ll dp[maxN][maxD][2];
bool vis[maxN][maxD][2];
string k;

void input(){
    cin >> k >> d;
    n = sz(k);
}

ll DP(const ll idx,
      const ll tot,
      const bool all){
    if(idx >= n)
        return !tot;
    if(!vis[idx][tot][all]){
        vis[idx][tot][all] = true;
        const int x = all ? 9 : (k[idx] - '0');
        fort(i,0,x)
            dp[idx][tot][all] = (dp[idx][tot][all] + DP(idx + 1,(tot + i) % d,(i < x) || all)) % MOD;
    }
    return dp[idx][tot][all];
}

int main(){
    #ifdef LOCAL
        freopen("s.INP","r",stdin);
    #endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    cout << (DP(0,0,false) - 1 + MOD) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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(void){
    int N, M; cin >> N >> M;
    string A[N], B[N];

    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];

    for(int i=0; i<N-M+1; i++){
        for(int j=0; j<N-M+1; j++){
            bool flg = true;

            for(int s=0; s<M; s++){
                for(int t=0; t<M; t++){
                    if(B[s][t] != A[i+s][j+t]) flg = false;
                }
            }

            if(flg){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC121().SolveD(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

    class ABC121
    {
        public void SolveD(ConsoleInput cin)
        {
            var a = cin.ReadLong;
            var b = cin.ReadLong;
            WriteLine(xor(a - 1) ^ xor(b));
            ReadLine();
        }

        public long xor(long n)
        {
            switch ((n + 1) % 4)
            {
                case 0: return 0;
                case 1: return 0 ^ n;
                case 2: return 1;
                case 3: return 1 ^ n;
                default: return 0;
            }
        }
    }
}

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  string s; cin>>s;
  int n = SZ(s);
  int z=0,o=0;
  for (int i=0; i<n; i++) {
    if (s[i]=='0') z++;
    else o++;
  }
  cout << min(z,o)*2 << endl;
}

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


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> pv(n);
	for (int i = 0; i < n; ++i) {
		cin >> pv[i].second;
		pv[i].first = i;
	}

	sort(pv.begin(), pv.end(), [](const pair<int, int>& a, const pair<int, int>& b) {
		return a.second < b.second;
	});

	int ret = 1;
	int pos = pv[0].first;
	for (int i = 1; i < n; ++i) {
		if (pv[i].first < pos) {
			pos = pv[i].first;
			++ret;
			if (pos == 0) {
				break;
			}
		}
	}

	cout << ret << endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    deque<int> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    
    sort(h.begin(), h.end());

    k = min(n,k);
    
    rep(i,k) {
        h.pop_back();
    }

    ll ans = 0;
    rep(i,h.size()) {
        ans += h[i];
    }

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


Measured memory_bytes: 1024
// https://github.com/PabloMessina/Competitive-Programming-Material/blob/master/Codejam_template.cpp
#pragma GCC optimize("Ofast") // OPTIONAL: for faster execution
#include <bits/stdc++.h>      // import everything in one shot
using namespace std;
// defines
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define invrep(i, a, b) for (int i = b - 1; i >= a; --i)
#define umap unordered_map
#define uset unordered_set
// typedefs
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
// -------------------------------

int main()
{
    // OPTIONAL: for faster input/output (only if using cin/cout)
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, M, u, v, S, T;
    cin >> N >> M;

    vector<int> g[3 * N];
    rep(i, 0, M)
    {
        cin >> u >> v;
        g[u - 1].push_back(N + v - 1);
        g[N + (u - 1)].push_back(2 * N + v - 1);
        g[2 * N + (u - 1)].emplace_back(v - 1);
    }
    // rep(b, 0, 3 * N)
    // {
    //     cout << b << " -> ";
    //     rep(k, 0, g[b].size())
    //     {
    //         cout << g[b][k] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    cin >> S >> T;
    S--;
    T--;

    int bfs[3 * N];
    memset(bfs, -1, sizeof(bfs));
    queue<int> q;
    q.push(S);
    bfs[S] = 0;
    while (!q.empty())
    {
        int current = q.front();
        q.pop();

        for (int neig : g[current])
        {
            if (bfs[neig] == -1)
            {
                bfs[neig] = bfs[current] + 1;
                if (neig == T)
                {
                    cout << bfs[neig] / 3 << endl;
                    // rep(i, 0, 3 * N)
                    // {
                    //     cout << bfs[i] << " ";
                    // }
                    // cout << endl;
                    return 0;
                }
                q.push(neig);
            }
        }
    }

    cout << -1 << endl;
    return 0;
}

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

ll knapsack(ll W, ll val[], ll wt[], ll n){
    ll K[n+1][W+1];
    for (ll  i = 0; i <= n; i++)
   {
       for (ll  w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(K[i-1][w], val[i-1] + K[i-1][w-wt[i-1]]);
           else
                 K[i][w] = K[i-1][w];
       }
   }
   return K[n][W];
}

int main(){
    ll n,W;
    cin>>n>>W;
    ll w[n],val[n];
    for(ll i=0; i<n; i++){
        cin>>w[i]>>val[i];
    }
    cout<<knapsack(W, val, w, n)<<endl;



return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a; cin >> a;
    int ans = a + a * a + a* a* a;
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
const long long int INF = 1LL << 60;

struct Sweet {
    long long int x, y, z;
};

int N, M;
int main() {
    scanf("%d%d", &N, &M);
    vector<Sweet> sweets;
    for(int i=0; i<N; i++) {
        long long int x, y, z; scanf("%lld%lld%lld", &x, &y, &z);
        sweets.push_back(Sweet{x, y, z});
    }

    long long int ans = 0;
    for(int x=0; x<2; x++) {
        for(int y=0; y<2; y++) {
            for(int z=0; z<2; z++) {
                sort(sweets.begin(), sweets.end(), [&](Sweet P, Sweet Q) {
                    long long int vl = (2*x-1) * P.x + (2*y-1) * P.y + (2*z-1) * P.z;
                    long long int vr = (2*x-1) * Q.x + (2*y-1) * Q.y + (2*z-1) * Q.z;
                    return vl > vr;
                });

                long long int A = 0, B = 0, C = 0;
                for(int i=0; i<M; i++) {
                    A += sweets[i].x;
                    B += sweets[i].y;
                    C += sweets[i].z;
                }
                ans = max(ans, llabs(A) + llabs(B) + llabs(C));
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 110
char a[N*2],b[N];
int main()
{
    int i,j,k;
    scanf("%s%s",a,b);
    k=strlen(a);
    for(i=0;i<k;i++)
        a[i+k]=a[i];
    for(i=0;i<k;i++)
    {
        for(j=0;j<k;j++)
        if(a[i+j]!=b[j])
            break;
        if(j==k)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
MOD = 10**9 + 7
N, K = list(map(int, input().split()))

ans = 0

n = [i for i in range(N+1)]

l_sum = sum(n[:K])
r_sum = sum(n[-K:])

l = K
r = N-K

for i in range(K, N+1):
    ans = (ans + r_sum - l_sum + 1) % MOD
    
    l_sum += n[l]
    r_sum += n[r]
    
    l += 1
    r -= 1
    
print((ans+1)%MOD)


Measured memory_bytes: 18304