akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n;
	cin>>n;
	map<string,int> m;
	for(int i = 0;i<n;i++){
		string str;
		cin>>str;
		m[str]++;
	}

	map<string,int>::iterator itr;
	vector<pair<int,string> > v;
	tr(itr,m){
		v.pb(mp(itr->se,itr->fi));
	}

	sort(all(v));

	vector<string> arr;
	arr.pb(v[v.size()-1].se);
	for(int i = v.size()-2;i>=0;i--){
		if(v[i].fi==v[v.size()-1].fi)
			arr.pb(v[i].se);
	}
	sort(all(arr));
	for(int i = 0;i<arr.size();i++)
		cout<<arr[i]<<'\n';
	return 0;
}


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

int main(){
   long n,ans=0;
   cin >> n;
   long a[n];
   map<long,long> mp;
   for(long i=0;i<n;i++){
       cin >> a[i];
       mp[a[i]]++;
   } 
   for(auto i:mp) ans += (i.second*(i.second-1))/2;
   long a1 = ans;
   for(long i=0;i<n;i++){
       long b = mp[a[i]];
       a1 -= b-1;
       cout << a1 << endl;
       a1 = ans;
   }
}

Measured memory_bytes: 12160
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define sz(x) (int)x.size()

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e9+7;
const ll N = 1e5+1;
const ll mod = 1e9+7;
const ll P = 31;

int main() {
    IOS
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = 1;
    while(a > 0 && c > 0) {
        if(x % 2 != 0) {
            c -= b;
        }
        else {
            a -= d;
        }
        x++;
    }
    if(a <= 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  int ret = 0;
  cin >> N;
  for (int i=0; i<N; i++) {
    ll a;
    cin >> a;
    while (a % 2 == 0) {
      ret++;
      a /= 2;
    }
  }
  cout << ret << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var A = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var BC = new (int B, int C)[M];

        for (int i = 0; i < M; i++)
        {
            var _BC = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            BC[i] = (_BC[0], _BC[1]);
        }

        var sortedA = A.OrderByDescending(x => x).ToArray();
        var sortedBC = BC.OrderByDescending(x => x.C).ToArray();

        var ACursor = 0;
        var BCCursor = 0;

        void PopA() { ACursor++; }
        void PopC()
        {
            if (sortedBC[BCCursor].B > 0)
                sortedBC[BCCursor].B--;
            if (sortedBC[BCCursor].B == 0)
                BCCursor++;
        }

        long PeekA() => ACursor < N ? sortedA[ACursor] : -1;
        long PeekC() => BCCursor < M ? sortedBC[BCCursor].C : -1;

        var ans = 0L;

        for (int i = 0; i < N; i++)
        {
            var a = PeekA();
            var c = PeekC();
            if(a > c)
            {
                ans += a;
                PopA();
            }
            else
            {
                ans += c;
                PopC();
            }
        }

        WriteLine(ans);
    }
}


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

dp=[[0 for i in range(0,K+1)] for i in range(0,N)]
for i in range(0,K+1):
    if A[0]>=i:
        dp[0][i]=1

for i in range(1,N):
    for j in range(0,K+1):
        if j==0:
            dp[i][j]=dp[i-1][j]
        elif A[i]>=j:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod
        else:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1-A[i]])%mod

print(dp[N-1][K])

Measured memory_bytes: 173192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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;}

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

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    if(B<N*A){
        cout<<B<<endl;
    }else{
        cout<<N*A<<endl;
    }
    return 0;
}

//a=97,z=122

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

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

int main() {
  int N;
  cin >> N;
  int M = 100000;
  for (int a = 1; a < N; a++) {
    int b = N - a;
    int sum = findSumOfDigits(a) + findSumOfDigits(b);
    if (sum < M) M = sum;
  }
  cout << M << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

// ll gcd(ll a,ll b){
//     if(a==0)    return b;
//     gcd(b%a,a);
// }

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};

ll dp[700][2005];

ll dynamic(ll i,ll sum){
    if(sum==0) return dp[i][sum]=1;
    if(sum<3)    return dp[i][sum]=0;
    if(dp[i][sum]!=-1)  return dp[i][sum];
    ll ways=0;
    for(int j=3;j<=sum;j++){
        ways+=dynamic(i+1,sum-j);
        ways%=MOD;
    }
    return dp[i][sum]=ways;
}


int main() {
    fastio
    // int t=1;
    // cin>>t;
    ll n,m,i,l,d,bank,s,k,j,x,y,ans,q;
    f(i,700){
        f(j,2005){
            dp[i][j]=-1;
        }
    }
    cin>>n;
    ans=dynamic(0,n);
    // cout<<dp[i][n]<<endl;
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 14620
#include<iostream>
#include<vector>
#include<tuple>
#include<utility>
using namespace std;

int H,W;
int a[503][503];

int main(){
  cin>>H>>W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>a[i][j];
    }
  }
  int cnt=0;
  vector<tuple<int,int,int,int> > v;
  for(int i=1;i<=H;i++){
    for(int j=1;j<W;j++){
      if(a[i][j]&1){
        a[i][j+1]++;
        a[i][j]--;
        v.push_back(make_tuple(i,j,i,j+1));
        cnt++;
      }
    }
  }
  for(int i=1;i<H;i++){
    if(a[i][W]&1){
      a[i+1][W]++;
      a[i][W]--;
      v.push_back(make_tuple(i,W,i+1,W));
      cnt++;
    }
  }
  cout<<cnt<<endl;
  int n=v.size();
  int a,b,c,d;
  for(int i=0;i<n;i++){
    tie(a,b,c,d)=v[i];
    cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
  }
  return 0;
}

Measured memory_bytes: 5232
#include <iostream>
using namespace std;
// Recursive function to return gcd of a and b
class gfg
{
 public : long long int gcd(long long int a, long long int b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }


// Function to return LCM of two numbers
  long long int lcm(long long int a, long long int b)
 {
    return (a*b)/gcd(a, b);
 }
} ;
// Driver program to test above function
int main()
{
    gfg g;
   long long int a,b;
   cin >> a >> b;
    cout<<g.lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * DA-IICT
 * Author : PARTH PATEL
 */
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;


 class Main {

	public static int mod = 1000000007;
	static FasterScanner in = new FasterScanner();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {

		int n=in.nextInt();
		boolean bool=false;
		if(n%10==9)
			bool=true;
		n/=10;
		if(n==9)
			bool=true;
		if(bool)
			out.println("Yes");
		else
			out.println("No");
		out.close();

	}

	public static long pow(long x, long n, long mod) {
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod) {
			if ((n & 1) != 0) {
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2) {
		long r;
		while (n2 != 0) {
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

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

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

}


Measured memory_bytes: 21332
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
Cont=Counter(A)
Cont1=Counter(A)
for k,v in Cont.items():
  Cont1[k-1]+=v
  Cont1[k+1]+=v
print(Cont1.most_common()[0][1])



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  if(a + b == 15) fin('+')
  else if(a * b == 15) fin('*')
  else fin('x')
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    string s;
    int a;
	vector<pair<string , int>> Restaurant;
    for(int i = 0; i < N; i++){
        cin >> s >> a;
    	Restaurant.push_back(make_pair(s, a));
    }
    pair<string , int> temp;
    int count;
    vector<int> Result(N);
    for(int i = 0; i < N; i++){
        count = 1;
    	temp = Restaurant.at(i);
        for(int j = 0; j < N; j++){
        	if(temp.first > Restaurant.at(j).first ){
            	count++;
            }else if(temp.first == Restaurant.at(j).first){
            	if(temp.second < Restaurant.at(j).second){
                	count++;
                }
            }
        }
        Result.at(i) = count;
    }
    for(int i = 0; i < N ; i++){
    	for(int j = 0; j < N; j++){
        	if(Result.at(j) == i + 1){
            	cout << j + 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;
#define MAX (int)2e5

int box[MAX+1];
int cond[MAX+1];
int main(void){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++){
    int ai;
    cin >> ai;
    cond[i] = ai;
  }

  for(int n=N;0<n;n--){
    int num = 2;
    int sum = 0;
    // 2以上の倍数の玉の数をたす
    while(num*n <= N){
      sum = (sum + box[num*n])%2;
      num++;
    }
    if(cond[n] == 1){
      if(sum == 1){
	box[n] = 0;
      }else{
	box[n] = 1;
      }
    }else{
      if(sum == 1){
	box[n] = 1;
      }else{
	box[n] = 0;
      }
    }
  }
  int ball = 0;
  for(int i=1;i<=N;i++){
    ball = ball + box[i];
  }
  cout << ball << endl;
  bool flag = false;
  for(int i=0;i<=N;i++){
    if(box[i] == 1){
      flag = true;
      cout << i << " ";
    }
  }
  if(flag)
    cout << endl;
  return 0;
} 


Measured memory_bytes: 2432
N, A, B = map(int,input().split())

sho = N // (A + B)
amari = N % (A + B)

#print(sho,amari)

if A == 0:
    print(0)
    exit(0)

if amari < A:
    print(sho * A + amari)
else:
    print(sho * A + A)

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		String str=scan.next();
		String str2=scan.next();
		int cnt=0;
		for(int i=0;i<3;i++)
		{
			char ch=str.charAt(i);
			char ch2=str2.charAt(i);
			if(ch==ch2)cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int N = 1299710;
  vector<int> prime(N);
  REP(i,N) prime[i] = i;
  prime[1] = 0;
  for (int i=2;i<N;++i)
    if (prime[i])
      for (int j=i*2; j<N; j+=i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime), 0), prime.end());
  int n;
  while(cin>>n,n) {
    if (binary_search(ALL(prime), n))
      cout << 0 << endl;
    else
      cout << *upper_bound(ALL(prime), n) - *(upper_bound(ALL(prime), n)-1) << endl;
  }
}

Measured memory_bytes: 0
from collections import deque


def solve():
    n = int(input())
    a = list(map(str, input().split(" ")))
    ans = deque()

    i = 0
    if n % 2:
        while i != n:
            if i % 2:
                ans.append(a[i])
            else:
                ans.appendleft(a[i])
            i += 1
    else:
        while i != n:
            if i % 2:
                ans.appendleft(a[i])
            else:
                ans.append(a[i])
            i += 1

    print(" ".join(ans))


solve()

Measured memory_bytes: 26564
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 10:36:48 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	ll	n, k;
	cin >> n >> k;
	map<ll, ll>	M;
	rep(i, n)
	{
		ll	a, b;
		cin >> a >> b;
		M[a] += b;
	}
	ll	sum;
	sum = 0;
	ll	ans;
	ans = 0;
	for (auto p : M)
	{
		ans = p.first;
		sum += p.second;
		if (sum > k - 1)
			break ;
	}
	cout << ans << endl;
}
// END

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


Measured memory_bytes: 4224
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int M,K;
  cin >> M >> K;
  int array=pow(2,M);
  if(K==0) rep(i,array) cout << i << " " << i << " ";
  else if(M==1 && K==1) cout << "-1" << endl;
  else if(pow(2,M)<=K) cout << "-1" << endl;
  else{
    rep(i,array) if(i!=K) cout << i << " ";
    cout << K << " ";
    reprev(i,array) if(i!=K) cout << i << " ";
    cout << K << endl;
  }
}

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld n,d;
  cin>>n>>d;
  lld x,y;
  lld cnt = 0;
  while(n--)
  {
    cin>>x>>y;
    lld dist = x*x + y*y;
    if(dist<=d*d)
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int ans = 1;

	for (int i = 1; i < n; i++) {
		bool tmp = true;
		for (int j = 0; j < i; j++) {
			if (h[j] > h[i]) {
				tmp = false;
				break;
			}
		}
		if (tmp)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  int n;
  int i;
  int count=0;
  char *s;
  
  scanf("%d",&n);
  s=(char*)malloc(sizeof(char)*(n+1));
  scanf("%s",s);
  
  for(i=0;i<n-2;i++){
    if(s[i]=='A'){
      if(s[i+1]=='B'){
        if(s[i+2]=='C'){
          count++;
        }
      }
    }
  }
  
  printf("%d",count);
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        try {
            String line = br.readLine();
            st = new StringTokenizer(line);
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            int l = Integer.parseInt(st.nextToken());
            long[][] matrixA = new long[n][m];
            long[][] matrixB = new long[m][l];
            long[][] matrixC = new long[n][l];
            for (int i = 0; i < n; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < m; j++) {
                    matrixA[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < m; i++) {
                line = br.readLine();
                st = new StringTokenizer(line);
                for (int j = 0; j < l; j++) {
                    matrixB[i][j] = Integer.parseInt(st.nextToken());
                }
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < l; j++) {
                    for (int k = 0; k < m; k++) {
                        matrixC[i][j] += matrixA[i][k]*matrixB[k][j];
                    }
                }
            }
            printMatrix(matrixC);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
     
    private static void printMatrix(long[][] matrix){
        for (long[] longs : matrix) {
            StringBuilder sb = new StringBuilder();
            for (long anLong : longs) {
                sb.append(anLong).append(" ");
            }
            System.out.println(sb.toString().trim());
        }
    }
}

Measured memory_bytes: 32976
#include<iostream>
using namespace std;
string s[8];
main()
{
    for(int i=0;i<8;i++)cin>>s[i];
    cout<<90<<endl;
    for(int j=0;j<8;j++)
    {
        for(int i=8;i--;)cout<<s[i][j];
        cout<<endl;
    }
    cout<<180<<endl;
    for(int i=8;i--;)
    {
        for(int j=8;j--;)cout<<s[i][j];
        cout<<endl;
    }
    cout<<270<<endl;
    for(int j=8;j--;)
    {
        for(int i=0;i<8;i++)cout<<s[i][j];
        cout<<endl;
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string str;
	//cin >> str; ?????????????????????????????§???????????????
	getline(cin,str);
	REP(i,str.size()){
		/*
		??¢???????????????'A'-'Z' < 'a' -'z'??¨????????? 'Z'??¨'a'?????????????¨?????????????
		http://www.asciitable.com/
		*/
		if('A'<=str[i]&&str[i]<='Z') cout << (char)(str[i]+'a'-'A');
		else if('a'<=str[i]&&str[i]<='z') cout << (char)(str[i]-('a'-'A'));
		else cout << str[i];
	}
	cout << endl;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,a) FOR(i,0,a)
#define real() X
#define imag() Y
#include <iostream>
using namespace std;
typedef long long ll;
ll sumsum[2000010];
ll sums(int s,int e){
	if(s>e)
		return 0;
	return sumsum[e+1]-sumsum[s];
}
ll divide(int ss,int ee){
	int s=ss;
	int e=ee;
	ll maxim=0;
	while(s<=e){
		int f=(s+e)/2;
		maxim=max(maxim,min(sums(ss,f),sums(f+1,ee)));
		if(sums(ss,f)<=sums(f+1,ee))
			s=f+1;
		else
			e=f-1;
	}
	return maxim;
}
int main() {
	ll N,p,s,sum=0;
	vector<ll> baum;
	cin >> N;
	REP(i,N){
		cin >> p;
		baum.push_back(p);
		sum+=p;
		sumsum[i+1]=sumsum[i]+p;
	}
	REP(i,N){
		baum.push_back(baum[i]);
		sumsum[N+i+1]=sumsum[N+i]+baum[i];
	}
	int head=0;
	ll maxim=0;
	REP(snake,N){
		while(sums(snake,head)*3<sum) head++;
		if(sums(snake+1,head)*3<sum){
			maxim=max(maxim,divide((head+1)%N,(snake+N-1)%N+N*((head+1)%N>(snake+N-1)%N)));
		}
	}
	cout << maxim << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5144
#include <stdio.h>
#include <math.h>
#define N 500001

void buildMaxHeap(int* a_p, int h);
void maxh(int* a_p, int ix, int h);
int parent(int i);
int left(int i);
int right(int i);
void swap(int *a_p, int *b_p);

int main(){
  int n, i, j;
  int ix;
  int a[N];

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

  buildMaxHeap( a ,n );

  for( i = 1 ; i <= n; i++){
    printf(" %d" ,a[i]);
  }
  printf("\n");
    
  return 0; // Don't forget return 0
}

void buildMaxHeap(int* a_p, int h){
  int i;
  for( i=h/2 ; i>=1 ; i--){
    maxh( a_p ,i ,h );
  }
}

void maxh(int* a_p, int ix, int h){
  int largest;
  int l = left(ix);
  int r = right(ix);

  if( l<=h && a_p[l]>a_p[ix] ){
    largest = l;
  }else {
    largest = ix;
  }
  if( r <= h && a_p[r]>a_p[largest] ){
    largest = r;
  }

  if(largest!=ix){
    swap( &(a_p[ix]) ,&(a_p[largest]) );
    maxh( a_p ,largest ,h);
  }

}

int parent(int i){
  return floor(i/2);
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void swap(int *a_p, int *b_p){
  int k;
  k    = *a_p;
  *a_p = *b_p;
  *b_p = k;
}

Measured memory_bytes: 2552
# coding: utf-8
# Your code here!

N, A, B = map(int, input().split())

# print(N)
# print(A)
# print(B)

if A < B:
    print(A)
else:
    print(B)
    
# print((A + B) - N)

if ((A + B) - N) >= 0:
    print((A + B) - N)
else:
    print(0)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
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;
}
const long long INF = 1LL<<60;

int main(){
    int N;
    long long W;
    
    cin >> N >> W;
    long long dp[N+1][W+1];
    for(int i=0;i<N+1;i++){
        for(int j=0;j<W+1;j++)dp[i][j]=0;
    }
    long long weight[N], value[N];
    for(int i=0;i<N;i++){cin >> weight[i] >> value[i];}

    // dp
    for(int i=0;i<N;i++){
        for(int sum_w=0;sum_w<W+1;sum_w++){
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
            if(sum_w - weight[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w-weight[i]]+value[i]);
            }
            // cout << dp[i+1][sum_w] << " " << sum_w << endl;
            
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79104
n,m = [int(x) for x in input().split()]
x = []
for i in range(m):
  x.append([int(x) for x in input().split()])
count = [1] * (n+1)
flag = [0] * (n+1)
flag[1] = 1
for i in range(m):
  if flag[x[i][0]] == 1:
    flag[x[i][1]] = 1
  if count[x[i][0]] == 1:
    flag[x[i][0]] = 0
  count[x[i][0]] -= 1
  count[x[i][1]] += 1

res = 0
for i in range(n+1):
  if flag[i] == 1:
    res += 1
    
print(res)

Measured memory_bytes: 26980
/*
	@author: cheerioskun
*/
#pragma GCC target("popcnt")
#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;

int ways[1003][1003];
char grid[1003][1003];

int main(){
	fast_io
	int H, W;
	cin>>H>>W;
	for(int i = 0;i < H; ++i){
		for(int j = 0;j < W; ++j){
			cin>>grid[i][j];
		}
	}
	for(int i = 0;i < H; ++i){
		for(int j = 0;j < W; ++j){
			ways[i][j] = 0;
		}
	}
	// PUSH DP
	ways[0][0] = 1;
	for(int i = 0;i < H; ++i){
		for(int j = 0;j < W; ++j){
			if(grid[i][j] == '.'){
				ways[i + 1][j] += ways[i][j];
				ways[i][j + 1] += ways[i][j];
				ways[i + 1][j] %= MOD;
				ways[i][j + 1] %= MOD;
			}
		}
	}
	cout<<ways[H - 1][W - 1]<<endl;
	
	#ifndef ONLINE_JUDGE
    	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}



Measured memory_bytes: 8516
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double d = sc.nextDouble();

        int count = 0;
        double x;
        double y;
        for(int i = 0; i < n; i++) {
            x = sc.nextDouble();
            y = sc.nextDouble();
            if(distance(x, y) <= d) count++;
        }

        System.out.println(count);
    }

    private static double distance(double x, double y) {
        return (Math.sqrt(x * x + y * y));
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += p[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,m;
  cin>>n>>m;
  map<int,int> mp;
  REP(i,m){
    int temp_a,temp_b;
    cin>>temp_a>>temp_b;
    if(temp_a==1) mp[temp_b]++;
    if(temp_b==n) mp[temp_a]++;
  }

  REP(i,n){
    if(mp[i]==2){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 9600
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let arrP = scanner.ArrayI32(n)
    let (ans, _) = Array.fold (fun (cont, min) x -> if x <= min then cont, x else cont + 1, min) (0, arrP.[0]) arrP

    n - ans
    |> printfn "%i"

    0


Measured memory_bytes: 33628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10
const int MAX_N =10000000;


bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll par[MAX_N],ranking[MAX_N];

void init(ll n){
    rep(i,n){
        par[i]=i;
        ranking[i]=0;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranking[x]<ranking[y]) par[x]=y;
    else{
        par[y]=x;
        if(ranking[x]==ranking[y]) ranking[x]++;
    }
}

bool same(ll x,ll y){
    return find(x)==find(y);
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0,d;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    
    sort(ALL(a),greater<>());
    if(n%2==0){
        d=n/2;
        rep(i,d){
            if(i==0) sum+=a[i];
            else sum+=a[i]*2;
        }
    }
    else{
        d=n/2 + 1;
        rep(i,d){
            if(i==0 || i==d-1) sum+=a[i];
            else sum+=a[i]*2;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n; 
long long int m = 1234567;
long long int M = -1234567; 
long long int S = 0; 
cin >> n;  
for (int i = 0; i < n; i++){
long long int a; 
cin >> a; 
m = min(m, a); 
M = max(M, a); 
S += a; 
}
cout << m << " " << M << " " << S << endl; 
}


Measured memory_bytes: 3128
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    la=list(map(int,input().split()))
    lb=list(map(int,input().split()))
    cnt=0
    for i in range(n):
        x=min(la[i],lb[i])
        cnt+=x
        lb[i]-=x
        la[i]-=x
        y=min(lb[i],la[i+1])
        cnt+=y
        la[i+1]-=y
    print(cnt)
resolve()


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

int main() {
    int n;
    cin >> n;
    
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    int ans = 1;
    int tmp = p[0];
    for(int i = 1; i < n; i++) {
        if(tmp >= p[i]) {
            ans++;
            tmp = p[i];
        }
    }

    cout << ans << endl;

    return 0;
}

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

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


Measured memory_bytes: 512
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine().toCharArray

    class UnionFind {
      val parents: Array[Int] = Array.ofDim[Int](s.length)

      for (i <- parents.indices) {
        parents(i) = i
      }

      def unite(parent: Int, child: Int): Unit = {
        val rootOfParent = getRoot(parent)
        val rootOfChild = getRoot(child)
        if (rootOfParent != rootOfChild) {
          parents(rootOfChild) = rootOfParent
        }
      }

      def getRoot(person: Int): Int = {
        @tailrec
        def getAncestors(as: List[Int], me: Int): List[Int] = {
          val parent = parents(me)
          if (parent == me) {
            me :: as
          } else {
            getAncestors(me :: as, parent)
          }
        }

        val ancestors = getAncestors(Nil, person)
        val root = ancestors.head
        ancestors.tail.foreach { ancestor =>
          parents(ancestor) = root
        }

        root
      }
    }

    val unionFind = new UnionFind

    for (i <- s.indices) {
      if (s(i) == 'R') {
        if (s(i + 1) == 'R') {
          unionFind.unite(i + 1, i)
        } else {
          // do nothing. I'm root!
        }
      } else {
        unionFind.unite(i - 1, i)
      }
    }

    val lastPosition = Array.ofDim[Int](s.length)
    for (i <- s.indices) {
      val root = unionFind.getRoot(i)
      val diff = Math.abs(root - i)
      lastPosition(root + diff % 2) += 1
    }

    out.println(lastPosition.mkString(" "))
    out.flush()
  }
}


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

int main(void){
    int n = 0;
    int n2 = 0;
    int sum = 0;
    int x = 0;
    int waru = 1;

    scanf("%d", &n);

    // 1桁の時
    if(n < 10){
        printf("%d\n", n);
        return 0;
    }

    // 2桁以上の時
    n2 = n;
    while(n2 / waru > 10){
        waru *= 10;
        x++;
    }
//    fprintf(stderr, "x = %d\n", x);

    sum = n % 10;
//    fprintf(stderr, "sum = %d\n", sum);
    n2 = n - (n % 10);
    while(x > 0){
//        printf("waru = %d\n", waru);
        int shou = 0;
        shou = n2 / waru;
        sum += shou;
        n2 -= shou * waru;
        waru /= 10;
        x--;
//        fprintf(stderr, "sum = %d x = %d n2 = %d\n", sum, x, n2);        
    }


    if(n % sum == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long int
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
	cerr << '{';
	__print(x.first);
	cerr << ',';
	__print(x.second);
	cerr << '}';
}
template <typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", ";
	_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
	cerr << "[" << #x << "] = ["; \
	_print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------
#define N 21
int n;
int mat[N][N];
ll dp[N][1<<N];

ll solve(int man ,int mask){

	if(man==n && !mask){
		return 1;
	}
	if(dp[man][mask]>-1){
		return dp[man][mask];
	}
	int ans=0;
	for(int i =0;i < n;i++){

		if(mat[man][i] && (mask & (1ll<<i))){
			ans = (ans%mod +  solve(man+1,mask^(1ll<<i))%mod)%mod;
		}
	}
	return dp[man][mask]=ans;
}

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

}

Measured memory_bytes: 347696
#include <bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }else if(b=='T'){
    cout<<'A'<<endl;
  }else if(b=='G'){
    cout<<'C'<<endl;
  }else{
    cout<<'G'<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+10;
map<int,int>mp;
int main(){
    int n;
    cin>>n;
    bool ok=true;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        mp[x]++;
        if(mp[x]>1){
            ok=false;
        }
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    

    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	char dt;
	int cnt[h][w];
	rep(i,h)rep(j,w){cin>>dt;cnt[i][j]=(dt=='c')?0:-1*INF;}
	rep(i,h){
		rep(j,w){
			if(j==0)continue;
			if(cnt[i][j]==0)cnt[i][j]=0;
			else if(cnt[i][j-1]>=0)cnt[i][j]=cnt[i][j-1]+1;
		}
	}
	rep(i,h){
		rep(j,w){
			if(cnt[i][j]>=0)cout<<cnt[i][j];
			else cout<<-1;
			if(j!=w-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;

    int num0 = 0, num1 = 0;

    rep(i, 0, S.size()) {
        if (S[i] == '0') ++num0;
        else ++num1;
    }

    cout << min(num0, num1)*2 << "\n";
}

Measured memory_bytes: 512