akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
  for ( int v = nt[u]; v < n; v++ ) {
    nt[u] = v + 1;
    if ( M[u][v] ) return v;
  }
  return -1;
}

void dfs_visit(int r) {
  for ( int i = 0; i < n; i++ ) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while ( !S.empty() ) {
    int u = S.top();
    int v = next(u);
    if ( v != -1 ) {
      if ( color[v] == WHITE ) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for ( int u = 0; u < n; u++ )
    if ( color[u] == WHITE ) dfs_visit(u);
  for ( int i = 0; i < n; i++ )
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
}

int main() {
  int u,  k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;

  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  int k[n];
  rep(i,n){
    int u;
    cin >> u;
    k[u-1]=i;
  }
  int ma=1;
  int cnt=1;
  rep(i,n-1){
    if(k[i]<k[i+1]){
      cnt++;
    }
    else{
      cnt=1;
    }
    ma=max(ma,cnt);
  }
  cout << n-ma <<  endl;
}  


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;



int32_t main()
{


	string s;

	cin >> s;

	long long int sum = 0;




	for (int i = 0; i < s.size(); ++i)
		sum += s[i] - '0';


	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else cout << "No" << endl;




}

Measured memory_bytes: 3716
#include<iostream>
using namespace std;
int main(){
	int n,*a,d=0;
	cin>>n;
	a=new int[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		for(int j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
				int b=a[j];
				a[j]=a[j-1];
				a[j-1]=b;
				d++;
			}

		}
	}
	for(int i=0;i<n;i++)
		{cout<<a[i];
		if(i<n-1)
			cout<<" ";
	}
	cout << endl << d << endl;

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> A(N+1);
    vector<int> B(N+1);
    A[0] = 0;
    B[0] = 0;
    REP(i,N)A[i+1] = in() + A[i];
    REP(i,N)B[i+1] = in() + B[i];
    int maxa = 0;
    REP(i,N){
        maxa = max(A[i+1] - A[0] + B[N] - B[i],maxa);
    }
    cout << maxa << "\n";
}

Measured memory_bytes: 256
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    
}

signed main()
{
    fast;

    int x;cin>>x;

    // string y = "-kyu";

    if(x>=400 and x<=599) cout<<8;
    if(x>=600 and x<=799) cout<<7;
    if(x>=800 and x<=999) cout<<6;
    if(x>=1000 and x<=1199) cout<<5;
    if(x>=1200 and x<=1399) cout<<4;
    if(x>=1400 and x<=1599) cout<<3;
    if(x>=1600 and x<=1799) cout<<2;
    if(x>=1800 and x<=1999) cout<<1;
    // cout<<y;
    // if(x>=800 and x<=999) cout<<6;


    return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
	int N, M;
	Set<Integer>[] conns;
	boolean[] done;
	int result;

	Main(int N, int M, List<String> lines) {
		this.N = N;
		this.M = M;
		this.conns = new Set[N];
		this.done = new boolean[N];
		Arrays.fill(this.done, false);
		for (int i = 0; i < N; ++i) {
			this.conns[i] = new HashSet<>();
		}
		for (String line : lines) {
			String[] tokens = line.split(" ");
			int X = Integer.parseInt(tokens[0]);
			int Y = Integer.parseInt(tokens[1]);
			int Z = Integer.parseInt(tokens[2]);
			this.conns[X - 1].add(Y - 1);
			this.conns[Y - 1].add(X - 1);
		}
		result = calc2();
	}

	int calc2() {
		int result = 0;
		for (int i = 0; i < N; ++i) {
			if (!this.done[i]) {
				++result;
				this.calc(i);
			}
		}
		return result;
	}

	void calc(int nodeIndex) {
		this.done[nodeIndex] = true;
		for (Integer key : conns[nodeIndex]) {
			this.conns[key].remove(nodeIndex);
		}
		for(Integer key: conns[nodeIndex]) {
			calc(key);
		}
		this.conns[nodeIndex].clear();
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		List<String> lines = new ArrayList<>(M);
		for (int i = 0; i < M; ++i) {
			lines.add(in.readLine());
		}
		in.close();
		Main ins = new Main(N, M, lines);
		System.out.println(ins.result);
	}
}

Measured memory_bytes: 116980
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		//zyunbi
		int temp=0;
		int now=1;
		List<Integer> list = new ArrayList<Integer>();
		for (int i=0;i<N;i++) {
			if (S.charAt(i)-48==0+now) {
				temp++;
			} else {
				list.add(temp);
				now=1-now;
				temp=1;
			}
		}
		if (temp!=0) {
			list.add(temp);
		}
		if (list.size()%2==0) {
			list.add(0);
		}

		//ruiseki
		/*
		List<Integer> R = new ArrayList<Integer>();
		int X=0;
		R.add(0);
		for (int i=0;i<list.size();i++) {
			X=list.get(i)+R.get(i);
			R.add(X);
		}

		int add=2*K+1;
		int left;
		int right;
		int temp_A;
		int max=0;
		for (int i=0;i<R.size();i+=2) {
			left=i;
			right=Math.min(left+add,R.size()-1);
			temp_A=R.get(right)-R.get(left);
			max=Math.max(max,temp_A);
		}
		*/

		//syakutori
		int add=2*K+1;
		int left=0;
		int right=0;
		int tmp=0;
		int max=0;
		for (int i=0;i<list.size();i+=2) {
			int Nextleft=i;
			int Nextright=Math.min(i+add,list.size());
			while (Nextleft>left) {
				tmp-=list.get(left);
				left++;
			}

			while (Nextright>right) {
				tmp+=list.get(right);
				right++;
			}
			max=Math.max(max,tmp);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 26412
// 1ずつ増えていくLISを求めればよい
#include<iostream>
#include<algorithm>
using namespace std;

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

    int A[n+1] = {};     
    int B[n+1] = {}; //逆引き

    for(int i = 1; i <= n; i++){
        cin >> A[i];
        B[A[i]] = i;
    }

    // for(int i = 1; i <= n; i++){
    //     cout << B[i] << endl;
    // }

    int forward[n+1] = {};
    for(int i = 1; i <= n; i++){
        if(A[i] == 1)   forward[i] = 1;
        else{
            if(B[A[i]-1] < i)   forward[i] = forward[B[A[i]-1]]+1;
            else                forward[i] = 1;
        }
    }

    int backward[n+1] = {};
    for(int i = n; i >= 1; i--){
        if(A[i] == n)   backward[i] = 1;
        else{
            if(B[A[i]+1] > i)   backward[i] = backward[B[A[i]+1]]+1;
            else                backward[i] = 1;
        }
    }

    sort(forward, forward+n+1);
    sort(backward, backward+n+1);

    // for(int i : forward)   cout << i << " ";
    // cout << endl;
    
    // for(int i : backward)   cout << i << " ";
    // cout << endl;

    int inc = forward[n];
    int dec = backward[n];

    if(inc > dec)   cout << (n-inc) << endl;
    else            cout << (n-dec) << endl;

    return 0;
    
}

Measured memory_bytes: 3328
n = int(input())
x = list(map(int,input().split()))

s = sum(x)//n
s1 = s+1
tairyoku1=0
tairyoku2=0

for i in range(n):
  tairyoku1 += (x[i]-s)**2
  tairyoku2 += (x[i]-s1)**2
  
print(min(tairyoku1,tairyoku2))

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

int main(){
    string s;
    cin >> s;
    bool ans = true;
    for (int i = 0;i < 3;i++){
        if (s[i] == s[i+1]){
            ans = false;
            break;
        }
    }

    if(ans){
        cout << "Good" << endl;
    }
    else {
        cout << "Bad" << endl;
    }
}

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


int A[300];
int main(){

  cin >> A[0]>>A[1]>>A[2];

  
  sort(A, A + 3); 
 
  

  cout << std::abs(A[2]-A[1])+std::abs(A[1]-A[0])<<endl;


}

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

const int MAXN = 2010, MODX = 1000000007;

string map[MAXN];
int dp_lr[MAXN][MAXN], dp_ud[MAXN][MAXN];
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(dp_lr, 0, sizeof(dp_lr));
	memset(dp_ud, 0, sizeof(dp_ud));
	int h, w;
	cin>>h>>w;
	for (int i=0; i<h; i++)
		cin>>map[i];
	for (int i=0; i<h; i++) {
		for (int c=0, tail=0; c<w; tail=++c) {
			while(tail<w && map[i][tail]=='.')
				tail++;
			int len = tail-c;
			while(c<tail)
				dp_lr[i][c++] = len;
		}
	}
	for (int j=0; j<w; j++)
		for (int r=0, tail=0; r<h; tail=++r) {
			while(tail<h && map[tail][j]=='.')
				tail++;
			int len = tail-r;
			while(r<tail)
				dp_ud[r++][j] = len;
		}
	int ans = 0;
	for (int i=0; i<h; i++)
		for (int j=0; j<w; j++)
			ans = max(ans, dp_lr[i][j]+dp_ud[i][j]);
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 36096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		//Scanner sc = new Scanner(System.in);
		//int n= Integer.parseInt(sc.next());
		//System.out.println(n);


		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


			String line = br.readLine();
			String[] strs = line.split(" ");//区切りで変える

			int N = Integer.parseInt(strs[0]);
			int A = Integer.parseInt(strs[1]);
			int B = Integer.parseInt(strs[2]);

			int max = Math.min(A, B);
			int sum = A+B;
			int min = Math.max(0, sum-N);

			System.out.println(max+" "+min);


		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}


	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>

#define INF 0x3f3f3f3f

typedef std::pair<int, int> EDGE;

const int N = 1e5 + 1;

std::vector<EDGE> G[N];
int dis[N];

void dij(int st) {
  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
  bool vis[N] = {false};
  dis[st] = 0;
  q.push({dis[st], st});
  while (!q.empty()) {
    auto nv = q.top();
    q.pop();
    int x = nv.second;
    if (vis[x]) continue;
    vis[x] = 1;
    for (auto &d : G[x]) {
      int v = d.first;
      int c = d.second;
      if (dis[v] > dis[x] + c) {
        dis[v] = dis[x] + c;
        q.push({dis[v], v});
      }
    }
  }
}

int main() {
  int n, e, st;
  while (std::cin >> n >> e >> st) {
    for (int i = 0; i < N; ++i) G[i].clear();
    memset(dis, INF, sizeof(dis));
    for (int i = 0; i < e; ++i) {
      int u, v, c;
      std::cin >> u >> v >> c;
      G[u].push_back({v, c});
    }
    dij(st);
    for (int i = 0; i < n; ++i) {
      if (dis[i] == INF) {
        std::cout << "INF" << std::endl;
      } else {
        std::cout << dis[i] << std::endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

int main(){
    ll N, M; cin >> N >> M;
    vector<vector<ll>> g(N, vector<ll>());
    vector<ll> visited(N, 0);
    vector<ll> ans(N, -1);
    rep(i, M){
        ll a, b; cin >> a >> b;
        g[--a].push_back(--b);
        g[b].push_back(a);
    }
    queue<ll> que;
    que.push(0);
    while(!que.empty()){
        ll node = que.front(); que.pop();
        if (visited[node]) continue;
        visited[node] = 1;
        eachdo(g[node], e){
            if (visited[e]) continue;
            que.push(e);
            if (ans[e] == -1) ans[e] = node;
        }
    }
    pt("Yes");
    rep(i, N){
        if(!i) continue;
        pt(ans[i] + 1);
    }

}

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

int main(){
  int N;
  cin >> N;
  map<int, int> A;
  for(int ii=0; ii<N; ii++){
    int a;
    cin >> a;
    A[a]=ii+1;
  }
  for(auto& a : A){
    cout << a.second << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>

//最大公約数を求めるプログラム(m >= n)
int calcGcd(int m, int n);
//最小公倍数を求めるプログラム
inline int calcLcm(int m, int n, int gcd);

int main(){
	int gcd, lcm, x, y;
	
	while(std::cin >> x >> y){
		if(x > y) gcd = calcGcd(x, y);
		else gcd = calcGcd(y, x);
		lcm = calcLcm(x, y, gcd);
		
		std::cout << gcd << " " << lcm << std::endl;
	}
}

int calcGcd(int m, int n){
	if(n == 0) return m;
	else return calcGcd(n, m%n);
}

inline int calcLcm(int m, int n, int gcd){
	return m / gcd * n;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <math.h>
using namespace std;

int main() {
	int a, b, A, B;
	cin >> a >> b;
	A = 0;
	B = 0;
	for (int i = 0; i < b; i++) A = A + a * pow(10, i);
	for (int i = 0; i < a; i++) B = B + b * pow(10, i);

	if (a < b) cout << A << endl;
	else cout << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	std::string a, b;

	std::cin >> a >> b;

	for (size_t i = 0; i < std::max(b.length(), a.length()); i++) {
		std::cout << a[i];
		if (i == b.length()) break;
		std::cout << b[i];
		if (i + 1 == a.length()) break;
	}
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	x,y = map(int,input().split())
	
	flg = False

	for i in range(0,x+1):
		for j in range(0,y+1):
			if i + j == x and 2*i + 4*j == y:
				flg = True
				break

	if flg:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 9176
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)
    {
        int b;
        cin>>b;
        if(b%2==0)
        {
            if(b%3!=0&&b%5!=0)
            {
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, x, y;
	cin >> n >> x >> y;
	
	vector< vector<int> > G(n);
	for(int i = 0; i < n - 1; ++i) {
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	
	x--;
	y--;
	G[x].push_back(y);
	G[y].push_back(x);
	vector<int> ans(n - 1, 0);
	
	for(int i = 0; i < n; ++i) {
		
		vector<int> dist(n, MOD);
		queue<int> q;
	
		dist[i] = 0;
		q.push(i);
	
		while( !q.empty() ) {
			int v = q.front();
			q.pop();
		
			for(int xv : G[v]) {
				if( dist[xv] > dist[v] + 1) {
					dist[xv] = dist[v] + 1;
					q.push(xv);
				}
			}
		}
		
		for(int j = i + 1; j < n; ++j) {
			ans[dist[j] - 1]++;
		}
		
	}
	
	for(auto i : ans) {
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        x: usize,
    };

    let c = (x - 400) / 200;
    let res = 8 - c;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2252
#include<stdio.h>
#define SIZE 200000
long det(long);
int main()
{
  int n;
  long a[SIZE];
  int i;
  long sum=0,dist,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%ld",&a[i]);
      sum+=a[i];
    }
  dist=ans=sum-2*a[0];
  ans=det(ans);
  for(i=1;i<n-1;i++)
    {
      dist-=2*a[i];
      if(det(dist)<ans) ans=det(dist);
    }
  printf("%ld\n",ans);
  return 0;
}
long det(long x)
{
  if(x<0) return x*(-1);
  else return x;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int t,x,n,m,sum=0,count=0;
    cin>>n>>m;
    vector<int>a;
        for(x=0;x<n;x++){
        cin>>t;
        a.push_back(t);

    }
    for(vector<int>::iterator i=a.begin();i!=a.end();i++){
        sum=sum+*i;
    }
    float prob=(float)sum/(4*m);
    for(vector<int>::iterator i=a.begin();i!=a.end();i++){
float l=float(*i);
        if(*i>=prob) count++;
    }
    if(count>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
map<ll,ll> ma;
ll pcnt[55];
ll solve(ll n)
{
	if(n == 1)
	{
		string tmp = "BPPPB";
		ma[1] = 3;
		pcnt[1] = 3;
		return tmp.size();
	}
	ma[n] = 2ll*solve(n-1)+3;
	pcnt[n] = 2ll*pcnt[n-1]+1;
	// if(ma[n]!="")
	// 	return ma[n];
	// ma[n] = "B"+solve(n-1)+"P"+ma[n-1]+"B";
	// cout<<ma[n]<<endl;
	return ma[n];
}
ll ans(ll n,ll x)
{
	if(n==0 && x>0)
		return 1;
	if(n==0 && x<=0)
		return 0;
	if(x-1<=ma[n-1])
		return ans(n-1,x-1);
	return pcnt[n-1]+1+ans(n-1,x-2-ma[n-1]);
}
int main()
{
	ll n,i,j,x;
	string s;
	cin>>n>>x;
	pcnt[0] = 1;
	ma[0] = 1;
	for(i=1;i<=n;i++)
	{
		ma[i] = 2ll*ma[i-1]+3;
		pcnt[i] = 2ll*pcnt[i-1]+1;
	}
	// ll l = solve(n);
	// cout<<l<<endl;
	// ll cnt = pcnt[n];
	// ll k = 0;
	// for(i=1;i<=n;i++)
	// 	cout<<ma[i]<<" "<<pcnt[i]<<endl;
	// for(i=n;i>0;i--)
	// {
	// 	if(ma[i]>=x && x>=ma[i-1])
	// 	{
	// 		cout<<(x-pcnt[i-1])<<endl;
	// 		return 0;
	// 	}
	// }
	cout<<ans(n,x)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;

int n;
int P[100005];
pair<int, int> X[100005];
pair<int, int> Y[100005];

int find(int x){
	if (P[x] == x) return x;
	return P[x] = find(P[x]);
}

bool join(int x, int y){
	int a = find(x), b = find(y);
	if (a == b) return 0;
	P[a] = P[b];
	return 1;
}

int main(){
	cin>>n;
	f(i, n) P[i] = i;
	f(i, n) {	
		cin>>X[i].first>>Y[i].first;
		X[i].second = Y[i].second = i;
	}
	sort(X, X+n);
	sort(Y, Y+n);
	vector<pair<int, pair<int, int>>> V;
	f(i, n-1){
		V.push_back({X[i+1].first - X[i].first, {X[i+1].second, X[i].second}});
		V.push_back({Y[i+1].first - Y[i].first, {Y[i+1].second, Y[i].second}});
	}
	long long ans = 0;
	sort(V.begin(), V.end());
	for (auto x: V){
		int c = x.first, y = x.second.first, z = x.second.second;
		if (join(y, z)) ans += c;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6900
import java.util.Scanner;

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


Measured memory_bytes: 40288
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
N,M = (int(i) for i in input().split())
A = sorted([int(i) for i in input().split()])
e,p = [(0,0)],0
for k, v in sorted([[int(i) for i in input().split()] for i in range(M)], key=lambda x: -x[1]):
    e.append((e[p][0]+k,v))
    p+=1

p = 1
for i in range(min(e[-1][0],len(A))):
    B,C = e[p]
    if A[i]<C:
        A[i]=C
    else:
        break
    if i == B-1:
        p+=1
print(sum(A))


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

int main()
{
    int N;
    int A, dp[20005];
    cin >> N;
    fill_n(dp, 20005, (1 << 30) - 1);
    dp[0] = 0;
    for(int p = 1; p < N; p++) {
        cin >> A;
        for(int i = N / 2; i >= 0; i--) {
            dp[p] = min(dp[p], dp[i] + A);
            dp[p - i] = min(dp[p - i], dp[i] + A);
        }
    }
    cout << dp[N / 2] << endl;
    return (0);
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
class rectangle{
	private:
		int name,x,y;
	public:rectangle(int name,int x,int y):name(name),x(x),y(y){}
	       int getX(){
		       return x;
	       }
	       int getY(){
		       return y;
	       }
};
int main(){
	int N;
	int n,d;
	int x,y;
	int maxX=0,minX=0,maxY=0,minY=0;
	int width=1,height=1;
	vector<rectangle> recs;
	while((cin>>N)&&(N!=0)){
		recs.push_back(rectangle(0,0,0)); // 0 into recs at (0,0)
		if(N!=1){
			for(int i=1;i<N;i++){
				cin>>n>>d;
				x = recs[n].getX();
				y = recs[n].getY();
				if(d==0) {
					recs.push_back(rectangle(i,x-1,y));
					minX = min(minX,x-1);
				}
				else if(d==1){
					recs.push_back(rectangle(i,x,y-1));
					minY = min(minY,y-1);
				}
				else if(d==2){ 
					recs.push_back(rectangle(i,x+1,y));
					maxX = max(maxX,x+1);
				}
				else if(d==3){
					recs.push_back(rectangle(i,x,y+1));
					maxY = max(maxY,y+1);
				}
			}
			width = maxX + abs(minX) + width;
			height = maxY + abs(minY) + height;
		}
		cout << width << " " << height << endl;
		recs.clear();
		maxX=0;
		minX=0;
		maxY=0;
		minY=0;
		width = 1;
		height = 1;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	string s;
	cin >> s;

	rep(i, s.length()) {
		cout << "x";
	}

	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    words = list()
    rule = True
    for _ in range(N):
        word = input()
        if len(words) > 0:
            if words[-1][-1] != word[0]:
                rule = False
        if word not in words:
            words.append(word)
        else:
            rule = False
    if rule == True:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 3060
k, n = map(int, input().split())
List = list(map(int, input().split()))

dis_list = [0 for i in range(n)]
for i in range(1, n):
    dis_list[i] = List[i] - List[i - 1]

dis_list[0] = k - List[-1] + List[0]

print(int(k -max(dis_list)))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

void solve(){
    string s,t;
    cin >>  s>> t;
    ll ans=0;
    loop(i,0,s.size()){
        if(s[i]!=t[i]) ans++;
    }

    cout << ans << endl;
    

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	char ch=getchar();
	
	while(!isdigit(ch)){
	   if(ch=='-')
	      f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);/*syn加速*/
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;   //c(n,2)
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>

int main(){
    int n, a, b;
    char s[100001];

    scanf("%d %d %d %s", &n, &a, &b, s);

    int cnt = 0;
    int cnt_foreign = 0;
    char ans[100001] = {0};
    for(int i = 0; i < n; ++i){
        if((s[i] == 'a') && (cnt < (a + b))){
            cnt++;
            ans[i] = 1;
        }else if((s[i] == 'b') && (cnt < (a + b)) && ((cnt_foreign + 1) <= b)){
            cnt++;
            cnt_foreign++;
            ans[i] = 1;
        }else{
            ;
        }
    }

    for(int i = 0; i < n; ++i){
        if(ans[i] == 1) puts("Yes");
        else puts("No");
    }

    return 0;
}


Measured memory_bytes: 1816
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b;
    cin >> a >> b;
    //処理
    //出力
    if(a%500 <= b) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
N, L = map(int, input().split())
f = 0
for i in range(N):
    f += L + i

memo = 10**9
for i in range(N):
    s = 0
    for j in range(N):
        if j != i:
            s += L + j
    if abs(f - s) < memo:
        memo = abs(f - s)
        res = s
    

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int temp;
	if(b==100){
		temp=1000;
	}
	if((b>9)&&(b<100)){
		temp=100;
	}
	if((b>=1)&&(b<10)){
		temp=10;
	}
	int c=a*temp+b;
	if(sqrt(c)==(int)sqrt(c)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	} 
	return 0;
} 

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  ll rep = n / (a+b);
  ll amari = n % (a+b);
  ll add = amari;
  if (amari >= a) add = a;
  ll ans  = rep * a + add;
  cout << ans << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;

  int64_t sum = 0;
  
  for (int i = 0; i < 1 << (s.size() - 1); i++) {
    bitset<10> b(i);
    string tmp = "";
    
    for (int j = 0; j < s.size(); j++) {
      tmp += s.at(j);
      
      if (b.test(j)) {
        sum += stoll(tmp);
        tmp = "";
      }
    }
    
    sum += stoll(tmp);
  }
  
  cout << sum << endl;
}


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

using namespace std;

int n, m;
vector<vector<bool>> graph;
vector<bool> visit;

bool dfs(int next)
{
    visit[next] = true;

    bool a = true;
    for (int i = 0; i < n; i++) {
        if (!visit[i]) {
            a = false;
            break;
        }
    }
    if (a) {
        return true;
    }

    for (int i = 0; i < n; i++) {
        if (!visit[i] && graph[i][next]) {
            bool res = dfs(i);
            if (res) {
                return true;
            }
        }
    }

    return false;
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        visit.push_back(false);
    }
    for (int i = 0; i < n; i++) {
        vector<bool> temp;
        for (int j = 0; j < n; j++) {
            temp.push_back(false);
        }
        graph.push_back(temp);
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (!graph[i][j]) continue;
            for (int i = 0; i < n; i++) {
                visit[i] = false;
            }
            graph[i][j] = false;
            graph[j][i] = false;
            bool res = dfs(0);
            graph[j][i] = true;
            graph[i][j] = true;
            if (!res) {
                count++;
            }
        }
    }
    cout << count << endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll L, R;
    cin >> L >> R;
    ll new_r = min(R, L + 4038);
    int ans = 2018;
    for(ll i = L; i <= new_r; i++){
        for(ll j = i + 1; j <= new_r; j++){
            int mod = (i * j) % 2019;
            ans = min(ans, mod);
        }
    }
    cout << ans << endl;  
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int Ni = N;
  while (N) {
    sum += N % 10;
    N /= 10;
  }

  if (Ni % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
	int N, K;
	int min=1;

	cin >> N >> K;
	
	for (int i = 0;i<N; ++i) {
		if (min <= K) {
			min *= 2;
		}
		else {
			min += K;
		}
	}
	
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
let input_price() = Scanf.scanf "%s %s\n" @@ fun xs u ->
  let x = 
    if String.contains xs '.' then xs |> float_of_string 
    else xs |> int_of_string |> float_of_int in 
      if u = "JPY" then x 
      else x *. 380000.
;;

let () = Scanf.scanf "%d\n" @@ fun n ->
  let price = Array.init n @@ fun _ -> input_price() in
  Printf.printf "%f\n" @@ Array.fold_right (+.) price 0.
;;

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<long long int> H(N, 0);
    for (int i = 0; i < N; i++) cin >> H[i];
    bool T = true;
    for (int i = 0; i < N - 1; ++i) {
        if (H[i] <= H[i + 1]) {
            if (H[i] < H[i + 1]) {
                H[i + 1]--;
            }
            else {
                continue;
            }
        }
        else {
            T = false; break;
        }
    }
    if (T) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


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

int main() {
	int n;
	int r,rr,i,ii,j,jj,k,kk;
	int rout,iout,jout,kout;
	
	while ( cin >> n, n ){
		for ( int num = 0; num < n; num++ ) {
			cin >> r >> i >> j >> k >> rr >> ii >> jj >> kk;
			
			rout = r * rr - i * ii - j * jj - k * kk;
			iout = r * ii + i * rr + j * kk - k * jj;
			jout = r * jj - i * kk + j * rr + k * ii;
			kout = r * kk + i * jj - j * ii + k * rr;
			
			cout << rout << " " << iout << " " << jout << " " << kout << endl;
			
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define ll long long
#define MAX 1000000000

ll n,k;
ll a[212345];

int main(){
  scanf("%lld%lld",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);}

  ll l=0,r=MAX+1;
  while(l<r){
    if(l+1==r) break;
    ll mid=(l+r)/2;
    ll count=0;
    for(int i=0;i<n;i++){
      count+=(a[i]-1)/mid;}
    if(count<=k) r=mid;
    else l=mid;}

  printf("%lld\n",r);
  return 0;
}


Measured memory_bytes: 3284
import java.util.*


fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextLong()
    val a = cin.nextLong()
    val b = cin.nextLong()

    val c: Long = b - a

    if (0 > c) {
        println(0)
    } else if (n == 1.toLong()) {
        if (c > 0) {
            println(0)
        } else {
            println(1)
        }
    } else {
        val max: Long = b*(n-1) + a
        val min: Long = a*(n-1) + b
        println(max - min + 1)
    }
}

Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
	string S;
	cin >> S;

	int zero = 0;
	int one = 0;
	rep(i, (int)(S.size())){
		if (S.at(i) == '0') zero++;
		else one++;
	}
	cout << 2 * min(one, zero) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;(a)<=i;--i)
template<class T> class segtree{
	int n = 1;
	vector<T> dat;
	T def;
public:
	segtree(const vector<T>& _dat, const T _def = 0) : def(_def) {
		int _n = _dat.size();
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
		FOR(i, 0, _n)dat[i + n] = _dat[i];
		rFOR(i, 1, n)dat[i] = dat[i << 1] | dat[i << 1 | 1];
	}
	void update(int i, T a) {
		i += n;
		dat[i] = a;
		while (1 < i) {
			i >>= 1;
			dat[i] = dat[i << 1] | dat[i << 1 | 1];
		}
	}
	T value(int l, int r) {
		T ret = def;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1)ret |= dat[l++];
			if (r & 1)ret |= dat[--r];
		}
		return ret;
	}
};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;

	vector<int> a(n);
	FOR(i, 0, n)a[i] = 1 << (s[i] - 'a');
	segtree<int> seg(a);

	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			seg.update(i - 1, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			int b = seg.value(l - 1, r);
			int ans = 0;
			FOR(i, 0, 26)if (b & (1 << i))++ans;
			cout << ans << "\n";
		}
	}
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

#define INF 2e9

char S[1024],T[1024];

int main(){

    scanf("%s",S);
    scanf("%s",T);

    int ans = 0;
    int i;

    REP(i,3){
        if (S[i] == T[i]){
            ans++;
        }
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;
	int res = 1;
	for (int i = 0; i < N; ++i) {
		if (res*2 < res+K) {
			res *= 2;
		}
		else {
			res += K;
		}
	}
	cout << res << endl;

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3056
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int t = sc.nextInt();

        int takoyaki = 0;
        int time = 0;

        while (n > takoyaki) {
            time += t;
            takoyaki += m;
        }
        System.out.println(time);

        sc.close();

        }

    }



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main(){
    int n,ans;
    cin>>n;
    for(int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(int i=0;i<v.size();++i)
    {
        if(m[v[i]]>=v[i]) 
             ans+=m[v[i]]-v[i];
        else ans+=m[v[i]];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
template <class T>
inline void cmin(T &a, T b) { ((a > b) && (a = b)); }
template <class T>
inline void cmax(T &a, T b) { ((a < b) && (a = b)); }

int main()
{
  int k,a,b;
  siii(k,a,b);
  re(i,a,b)
  {
    if(i%k==0){puts("OK");return 0;}
  }
  puts("NG");
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define sz(a) ((int)(a.size()))
#define OTIMIZA 2
#define INSERE 1
#define REMOVE 0
#define move aslzxc
bool ok(ll x , ll y)
{
	if(y != 1)
	while(x % y == 0)
		x /= y;
	return x % y == 1;
}
int main()
{
	ll n;
	cin >> n;
	ll m = n - 1;
	set<ll> divs;
	for(ll i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			divs.insert(i);
			divs.insert(n / i);
		}
		if(m % i == 0)
		{
			divs.insert(i);
			divs.insert(m / i);
		}
	}
	int ans = 0;
	for(auto x : divs)
		ans += ok(n , x);
	cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define rrep(i,a) for(int i=a; i>=0; --i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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(){
    int N;
    cin>>N;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    int m1=0,m2=0;
    rep(i,N){
        if(m1<=a[i]){
            m2=m1;
            m1=a[i];
        }else if(m2<a[i]){
            m2=a[i];
        }
    }
    rep(i,N){
        if(m1==a[i]) cout<<m2<<endl;
        else cout<<m1<<endl;
    }
}

Measured memory_bytes: 2432
n = int(input())

if n <= 111:
    print(111)
elif n <= 222:
    print(222)
elif n <= 333:
    print(333)
elif n <= 444:
    print(444)
elif n <= 555:
    print(555)
elif n <= 666:
    print(666)
elif n <= 777:
    print(777)
elif n <= 888:
    print(888)
elif n <= 999:
    print(999)
else:
    print(1111)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	int64_t n, m;
	n = A * B;
	m = C * D;

	if (n > m) {
		cout << n << endl;
	}
	else {
		cout << m << endl;
	}
}

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

long long n,k;

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

    cin>>n>>k;
    if(k%2==1)
    {
        long long d=n/k;
        if(d*d*d>0)
            cout<<d*d*d<<endl;
        else
            cout<<0<<endl;
        return 0;
    }
    else
    {
        long long r=0;
        long long d=n/k;
        r+=d*d*d;
        for(int i=1;i<k;i++)
        {
            long long q=2*i;
            if(q%k==0)
            {
                long long n1=d*k;
                if(n-n1>=i)
                    r+=(d+1)*(d+1)*(d+1);
                else
                    r+=d*d*d;
            }
        }
        if(r>0)
            cout<<r<<endl;
        else
            cout<<0<<endl;
        return 0;
    }
}


Measured memory_bytes: 3648