akhauriyash/Code-Regression huggingface dataset:
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,
        a:[Usize1;n-1],
    }
    let mut v = vec![0; n + 3];
    for &x in a.iter() {
        v[x] += 1;
    }
    for i in 0..n {
        println!("{}", v[i]);
    }
}


Measured memory_bytes: 5516
#include <stdio.h>
int main (void){
	int a,b,c,d=0,e=0;
	scanf("%d %d %d",&a,&b,&c);
	do{
		d++;
		e+=a;
		if(d%7==0)e+=b;
	}while(e<c);
	printf("%d\n",d);
	return 0;
}



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

int main() {
	int n, k; cin >> n >> k;
	vector<int>res(200005, 0);
	for (int i = 0, tmp; i < n; i++) {
		cin >> tmp; res[tmp]++;
	}
	sort(res.rbegin(), res.rend());

	int ans = 0;
	for (int i = k; i < 200005; i++)ans += res[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    vl A(N);
    in(N,A);
    ll a = 0;
    rep(i,N) a ^= A[i];
    rep(i,N) cout << (a^A[i]) << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 4784
#include<stdio.h>

static long long *a, count = 0;
void msort(int, int);
void merge(int, int, int);

int main()
{
	int n;
	scanf("%d", &n);
	a = new long long[n];

	for (int i = 0; i < n; i++)
		scanf("%d", a + i);

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

void msort(int left, int right)
{
	if (left + 1 < right)
	{
		int mid;
		mid = (left + right) / 2;
		msort(left, mid);
		msort(mid, right);
		merge(left, mid, right);
	}
	return;
}

void merge(int left, int mid, int right)
{
	int n1, n2, i, j;
	long long *l, *r;
	n1 = mid - left;
	n2 = right - mid;
	l = new long long[n1 + 1];
	r = new long long[n2 + 1];
	for (int i = 0; i < n1; i++)
		l[i] = a[left + i];
	for (int i = 0; i < n2; i++)
		r[i] = a[mid + i];
	r[n2] = l[n1] = 10000000000;
	i = j = 0;
	for (int k = left; k < right; k++)
		if (l[i] <= r[j])
		{
			a[k] = l[i];
			i++;
		}
		else
		{
			a[k] = r[j];
			j++;
			count += n1 - i;
		}
}


Measured memory_bytes: 40376
class Node():
    def __init__(self, id, num, child, nodetype=None, depth=-1, parent=-1):
        self.id = id
        self.num = num
        self.child = child
        self.nodetype = nodetype
        self.depth = depth
        self.parent = parent
    def showFinal(self):
        print 'node %d: parent = %d, depth = %d, %s,' % (self.id, self.parent, self.depth, self.nodetype), self.child
        
def calcDepth(node):
    if node.parent == -1:
        return 0
    return calcDepth(tree[node.parent]) + 1

n = int(raw_input())
dict = {}
tree = []

for i in range(n):
    a = map(int, raw_input().split())
    if len(a) > 2:
        dict[a[0]] = Node(a[0], a[1], a[2:])
    else:
        dict[a[0]] = Node(a[0], a[1], [], nodetype='leaf')

for i in range(n):
    tree.append(dict[i])

for i in range(n):
    children = tree[i].child
    for j in children:
        tree[j].parent = tree[i].id

for i in range(n):
    tree[i].depth = calcDepth(tree[i])
    if tree[i].parent != -1 and tree[i].child != []:
        tree[i].nodetype = 'internal node'
    elif tree[i].parent == -1:
        tree[i].nodetype = 'root'
        
for i in range(n):
    tree[i].showFinal() 

Measured memory_bytes: 137504
a=int(input())
b=[]
while a>26:
    c=a%26
    b.append(c)
    a=(a-1)//26

ans=""
b.append(a)
b=b[::-1]
for i in b:
    if i==0:
        ans+="z"
    else:
        ans+=chr(i+96)

print(ans)


Measured memory_bytes: 9180
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())
fs = factorization(N)

if N == 1:
  print(0)
  sys.exit()

ans = 0
for f in fs:
  for e in range(1, f[1] + 1):
    z = f[0] ** e
    if N % z == 0:
      N //= z
      ans += 1

print(ans)

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

class IntVector : public std::vector<int>
{
public:
	void Input(int Count);
	bool Search(int Target)const;
};

void IntVector::Input(int Count)
{
	for(int i=0;i<Count;i++)
	{
		int Input;
		std::cin >> Input;
		push_back(Input);
	}
}

bool IntVector::Search(int Target)const
{
	int left = 0;
	int right = size() - 1;
	int i = 0;
	while(left <= right)
	{
		i = left + (right - left)/2;
		if(at(i)==Target) return true;
		if(at(i)<Target){
			left = i+1;
		}else
		{
			right = i-1;
		}
	}
	return false;
}

int main()
{
	int n = 0;
	std::cin >> n;
	IntVector S;
	S.Input(n);
	int q = 0;
	std::cin >> q;
	int Count = 0;
	for(int i=0;i<q;i++)
	{
		int T;
		std::cin >> T;
		Count += S.Search(T);
	}
	
	std::cout << Count << std::endl;
	return 0;
}

Measured memory_bytes: 1672
#include <cstdio>//头文件不解释
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rr register
#define int long long
#define f_for(i,a,b) for(rr int i=a;i<=b;i++)
using namespace std;
const int maxx=1e4;
int n,m;
string a,b;
signed main(){
    cin>>a;
    b=a;
    bool t=true;
    int len=a.length()-1;
    for(rr int i=0; i<=len; i++)
        switch(a[i]){
            case 'q': a[i]='p';break;
            case 'p': a[i]='q';break;
            case 'b': a[i]='d';break;
            case 'd': a[i]='b';break;
        }
    for(rr int i=0;i<=len;i++)
        if(a[i]!=b[len-i])
            t=false;
    if(t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int h, a;
    cin >> h >> a;
    
    if(h % a == 0){
        cout << h / a << endl;
    }
    else{
        cout << (h / a) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    scc_graph g(n);
    rep(i,0,m){
        ll a,b; cin >> a >> b;
        g.add_edge(a, b);
    }
    auto v = g.scc();

    cout << v.size() << endl;
    for(auto &t : v){
        cout << t.size() << " ";
        print(t);
    }

}

Measured memory_bytes: 40092
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<queue>
#include<algorithm>
#include<vector>
#include<tuple>

using namespace std;

typedef long long LL;
const LL INF = 1e17;


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)



typedef vector<LL> V;
typedef vector<V> VV;
typedef tuple<LL, int, int> T;

typedef priority_queue<T> QUE;
int N, M, H, K,P,s,t;
int a[1123];
int b[1123];
LL c[1123];
int h[1123];
int r[1123];
LL dijkstra(VV &g, int p) {
	QUE que;
	VV d(N, V(H + 1,INF));
	d[s][0] = 0;
	que.push(T(0, s, 0));
	while (que.size()) {
		int v, tt; LL cost;
		tie(cost, v, tt) = que.top(); que.pop();
		cost = -cost;
		if (d[v][tt] < cost)continue;
		for (auto &e : g[v]) {
			int u = a[e] ^ b[e] ^ v;
			int nt = tt + h[e];
			if (nt > H)continue;
			LL nc = cost+c[e];
			if ((p >> r[e]) & 1)nc -= c[e];
			if (d[u][nt] <= nc)continue;
			d[u][nt] = nc;
			que.push(T(-nc, u, nt));
		}
	}
	LL res = INF;
	for (auto &it : d[t])res = min(res, it);
	return res;
}

int main() {
	while (cin >> N >> M >> H >> K, N + M + H + K) {
		VV g(N);
		REP(i, M) {
			cin >> a[i] >> b[i] >> c[i] >> h[i] >> r[i];
			a[i]--;
			b[i]--;
			r[i]--;
			g[a[i]].push_back(i);
			g[b[i]].push_back(i);

		}
		cin >> s >> t; s--; t--;
		cin >> P;
		vector<LL> p(1 << K, INF);
		p[0] = 0;
		REP(i, P) {
			LL val, num;
			int bit = 0;
			cin >> num >> val;
			REP(_, num) {
				int k;
				cin >> k; k--;
				bit |= (1 << k);
			}
			p[bit] = min(p[bit], val);
		}
		P = 1 << K;
		REP(i, P) {
			REP(j, P) {
				p[i | j] = min(p[i | j], p[i] + p[j]);
			}
		}
		LL res = INF;
		REP(i, P) {
			res = min(res, p[i]+dijkstra(g, i));
		}
		if (res == INF)cout << -1 << endl;
		else cout << res << endl;
	}
}

Measured memory_bytes: 3328
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int N, M;
int deg[MAXN][2], s[MAXN];
vi G[MAXN];
bool on[MAXN];


char S[MAXN];
int main(){
	scan(N, M, S);
	FOR(i,0,N) s[i] = S[i]-'A';
	FOR(i,0,M){
		int a,b; scan(a, b);
		a--; b--;
		deg[a][s[b]]++;
		G[a].pb(b);
		if(a!=b){
			deg[b][s[a]]++;
			G[b].pb(a);
		}
	}
	ms(on, true);
	queue<int> q;
	FOR(v,0,N){
		if(deg[v][0]==0 || deg[v][1]==0){
			on[v]=false;
			q.push(v);
		}
	}
	while(!q.empty()){
		int v=q.front(); q.pop();
		for(int u : G[v]){
			if(!on[u]) continue;
			if((--deg[u][s[v]]) == 0){
				on[u] = false;
				q.push(u);
			}
		}
	}
	bool ans = false;
	FOR(v,0,N) if(on[v]) ans |= deg[v][1-s[v]]>0;
	printf(ans ? "Yes\n" : "No\n");

}


Measured memory_bytes: 13312
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int M, T, P, R;
        cin >> M >> T >> P >> R;
 
        if(M==0 && T==0 && P==0 && R==0)
            break;
 
        int CP[50], TT[50], PT[50][10];
        for(int i=0; i<T; i++){
            CP[i] = TT[i] = 0;
            for(int j=0; j<P; j++)
                PT[i][j] = 0;
        }
 
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
 
            if(j==0){
                CP[t-1]++;
                TT[t-1] += (m+PT[t-1][p-1]);
            }
            else{
                PT[t-1][p-1] += 20;
            }
        }
 
        int tnow, tpre = -1;
        bool flg[50];
        for(int i=0; i<T; i++)
            flg[i] = false;
 
        for(int i=0; i<T; i++){
            tnow = -1;
            for(int j=0; j<T; j++){
                if(flg[j])
                    continue;
 
                if(tnow==-1){
                    tnow = j;
                }
                else{
                    if(CP[j]>CP[tnow] || (CP[j]==CP[tnow] && TT[j]<=TT[tnow])){
                        tnow = j;
                    }
                }
            }
 
            if(tpre!=-1){
                if(CP[tnow]==CP[tpre] && TT[tnow]==TT[tpre])
                    cout << '=';
                else
                    cout << ',';
            }
            cout << tnow+1;
 
            flg[tnow] = true;
            tpre = tnow;
        }
        cout << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3004
while True:
    try:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(c*d-a*f)/(b*d-a*e)
        if x==-0:
            x=0
        if y==-0:
            y=0
        print(f"{x:.3f} {y:.3f}")
    except:
        break


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();
		long tmp = 0;
		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (a % b != 0) {
			tmp = a;
			a = b;
			b = tmp % b;
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 26396
// AUTHOR:: MOHAMAMD FAISAL

"use strict";

const main = (input) =>{
  
  //const arr = input.trim().split("");
//  const firstplace = arr[arr.length -1];
  const firstplace = input%10;
  
  if(firstplace ==3)
    console.log("bon");
  else if(firstplace==0 || firstplace==1 || firstplace==6 || firstplace==8)
    console.log("pon");
  else
    console.log("hon");
};
  
main(require("fs").readFileSync("/dev/stdin","utf8"));


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

int main() {
  string s;
  int n;
  cin >> n >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]+n>'Z') {
      s[i]=s[i]+n-26;
    } else s[i]=s[i]+n;
  }
  cout << s << endl;
}


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


int main(){


int n,k,i;
cin>>n>>k;
int arr[n];
for(auto &x:arr)cin>>x;
sort(arr,arr+n);
int sum=0;
for(i=0;i<k;i++){
    sum+=arr[i];
}
cout<<sum;
}


Measured memory_bytes: 3568
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 30000

long t1, t2, a1, a2, b1, b2, a, b;

int input() {
        if (scanf("%ld %ld %ld %ld %ld %ld", &t1, &t2, &a1, &a2, &b1, &b2) < 0) return 0;
        return 1;
}

void init() {
}

long solve() {
        long a = a1*t1 - b1*t1;
        long b = a2*t2 - b2*t2;
        if (a<0) {
                a = -a;
                b = -b;
        }
        //a>=0
        if (a==0) return -1;
        //a>0
        //check a+b
        if (a+b==0) return -1;
        if (a+b>0) return 0;
        //a+b<0
        long d = -(a+b);
        //printf("a=%ld d=%ld\n", a, d);
        long r= (a/d+1)*2-1;
        if (a%d==0) r--;
        return r;
}

void output(long ans) {
        if (ans<0) printf("infinity\n");
        else printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
        //int ca; scanf("%d", &ca);
        while (input()) {
                init();
                output(solve());
                cleanup();
                //break;
        }
}


Measured memory_bytes: 128
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


struct edge{
	int from,to,cost;
	edge(){
		
	}
	edge(int x,int y,int cs){
		from = x;
		to = y;
		cost = cs;
	}
	
};

struct vertex{
	int idx,x,y;
}a[MAX],b[MAX];


vector<edge> g;
int parent[MAX];

bool cmpfunc(edge pertama,edge kedua){
	return pertama.cost < kedua.cost;
}

int findParent(int child){
	if (child==parent[child]) return child;
	return parent[child] = findParent(parent[child]);
}

bool cmpfunc2(vertex pertama,vertex kedua){
	return pertama.x < kedua.x;
}

int main(){
	base();
	int n;
	cin>>n;
	FOR(i,0,n){
		cin>>a[i].x;
		cin>>b[i].x;
		a[i].idx = i;
		b[i].idx = i;
		parent[i] =i;
	}
	sort(a,a+n,cmpfunc2);
	sort(b,b+n,cmpfunc2);
	int k=0,cc=0;
	ll ans=0;
	FOR(i,0,n-1){
		g.pb(edge(a[i].idx,a[i+1].idx,a[i+1].x - a[i].x));
		g.pb(edge(b[i].idx,b[i+1].idx,b[i+1].x - b[i].x));
		k+=2;
	}
	sort(g.begin(),g.end(),cmpfunc);
	for(int i=0;i<k && cc<n-1;i++){
		int p = findParent(g[i].from);
		int q = findParent(g[i].to);
		
		if (p!=q){
			parent[p] = q;
			ans+=g[i].cost;
			cc++;
		}
		
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 7668
#include<iostream>
using namespace std;
typedef long long int int64;
int main(){
  int64 n;
  cin>>n;
  int64 a[n],b[n];
  for(int i=0;i<=n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  int64 sum=0;
  for(int i=0;i<n;i++){
    int64 rem=min(a[i],b[i]);a[i]-=rem;b[i]-=rem;sum+=rem;
    rem=min(a[i+1],b[i]);a[i+1]-=rem;b[i]-=rem;sum+=rem;
  }
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 1792
N, K = map(int, input().split())
cnt = 0

candidates = [i for i in range(K, N + 1, K)]
size = len(candidates)
cnt += size ** 3

if K % 2 == 0:
    for_even_k = [i for i in range(K // 2, N + 1, K)]
    size_for_even = len(for_even_k)
    cnt += size_for_even ** 3

print(cnt)


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

using namespace std;
#define int long long
#define N 666666
int a[N];
signed main(){
	int n;cin>>n;
	int sum=1;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int> v;
	for(int i=1;i<=n+1;i++){
		if(a[i]==a[i+1]) sum++;else v.push_back(sum),sum=1;
	}
	int ans=0;
	for(int i=0;i<v.size();i++){
		//cout<<v[i]<<" ";
		ans+=v[i]/2;
	} 
//	cout<<'\n';
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO
  int N, K, del = 0; cin >> N >> K;
  unordered_map<int, int> freq;
  vector<int> ins;
  for(int rep = 0; rep < N; ++rep){
    int x; cin >> x;
    freq[x]++;
  }

  for(auto ele : freq){
    ins.PB(ele.S);
  }

  sort(ALLR(ins));

  for(int rep = K; rep < SZ(ins); ++rep){
    del += ins[rep];
  }

  cout << del << "\n";

  return 0;
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int H, W, i, j, k, l;
  cin >> H >> W;
  
  vector<string> vec(H);
    for(i=0;i<H;i++){
      cin >> vec.at(i);}
  
  for(j=0;j<W+2;j++){
    cout << "#";}
  cout << endl;
  
  for(k=0;k<H;k++){
    cout << "#" << vec.at(k) << "#" << endl;}
  
  for(l=0;l<W+2;l++){
    cout << "#";}
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int main()
{
    FIO;
    int n;
    cin >> n;
    map<long long, long long> m;
    long long sum = 0;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        m[x]++;
        sum+=x;
    }

    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        sum = sum + (m[b] * (c-b));
        m[c] += m[b];
        m[b] = 0;
        cout << sum << "\n";
    }
}



Measured memory_bytes: 9484
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	
	char Russia[50][50];

	for (int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			char color;
			cin >> color;

			Russia[i][j] = color;
		}
	}

	int answer = 999999;

	for(int WB=0;WB<N-2;WB++){
		for(int BR=WB+1;BR<N-1;BR++){

			int karian = 0;

			for(int shiro=0;shiro<WB+1;shiro++){
				for(int retsu=0;retsu<M;retsu++){

					if(Russia[shiro][retsu] != 'W'){
						karian++;
					}
				}
			}


			for(int ao=WB+1;ao<BR+1;ao++){
				for(int retsu=0;retsu<M;retsu++){

					if(Russia[ao][retsu] != 'B'){
						karian++;
					}
				}
			}



			for(int aka=BR+1;aka<N;aka++){
				for(int retsu=0;retsu<M;retsu++){

					if(Russia[aka][retsu] != 'R'){
						karian++;
					}
				}
			}

			if(karian < answer){
				answer = karian;
			}
		}
	}
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3092
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long X, Y;
    cin >> X >> Y;

    long long ans = 0;
    while (X <= Y) ans++, X *= 2;

    cout << ans << endl;

}















































Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[10000];
int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  int c = 0;
  rep(i, s.size()){
    c += s[i] - '0';
  }
  if(n%c)cout << "No";
  else cout << "Yes";
  cout << endl;
}



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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    int W,H,N,l=0,r,d=0,u;
    cin >> W >> H >> N;
    r=W;
    u=H;
    for(int i=0;i<N;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            l=max(l,x);
        }
        if(a==2){
            r=min(r,x);
        }
        if(a==3){
            d=max(d,y);
        }
        if(a==4){
            u=min(u,y);
        }
    }
    if(r<=l||u<=d)
    cout << 0 << endl;
    else
    cout << (r-l)*(u-d) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int d1[n],d2[n];
    for (int i = 0; i < n;i++) {
        cin >> d1[i] >> d2[i];
    }
    bool ok = false;
    for (int i = 0; i < n;i++) {
        for (int j = i + 1; j < n;j++) {
            for (int k = j + 1; k < n;k++) {
              if (d1[i] == d2[i] && d1[j] == d2[j] && d1[k] == d2[k] ) {
                  ok = true;
                  break;
              }  
              break;
            }
            break;
        }
    }
    if (ok) cout << "Yes\n";
    else cout <<"No\n";
}


Measured memory_bytes: 3592
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	//n頂点m枝に対して隣接リストをつくる。
	int n;
	cin >> n;
	int u, v;
	//vector< vector <int> > ls(n); //0-origin
	vector< vector <int> > ls(n+1); //1-origin
	REP(i, n-1){ 
		cin >> u >> v; 
		ls[u].push_back(v); 
		ls[v].push_back(u); //有向グラフならコメントアウトせよ
	}
	//
	priority_queue<ll> c;
	REP(i, n) {
		cin >> tmp;
		c.push(tmp);
	}
	ll num[n+1];
	queue<int> q;
	q.push(1);
	bool ch[n+1] ={};
	ch[1]= true;
	while(!q.empty()){
		tmp = q.front();
		q.pop();
		num[tmp] = c.top();
		if(tmp != 1) ans += c.top();
		c.pop();
		REP(i, ls[tmp].size()) {
			if(!ch[ls[tmp][i]]){
				ch[ls[tmp][i]]= true;
				q.push(ls[tmp][i]);
			}
		}
	}
	cout << ans << endl;
	REP1(i,n) cout << num[i] << " ";
	cout << endl;
}

Measured memory_bytes: 4160
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 2e5 + 7;

int n, dp[maxn][4];
pair < pair < int, int >, int > a[maxn];

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i].f.f >> a[i].f.s >> a[i].s;
	dp[1][1] = a[1].f.f;
	dp[1][2] = a[1].f.s;
	dp[1][3] = a[1].s;
	for (int i = 2; i <= n; i++){
		dp[i][1] = max(dp[i - 1][3], dp[i - 1][2]) + a[i].f.f;
		dp[i][2] = max(dp[i - 1][3], dp[i - 1][1]) + a[i].f.s;
		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + a[i].s;
	}
	cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
	return 0;
} 

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
	int a[3], k;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	cin >> k;
	sort(a, a + 3, greater<int>());
	for (int i = 0; i < k; i++) {
		a[0] *= 2;
	}
	cout << accumulate(a, a + 3, 0) << endl;
}

Measured memory_bytes: 256
count=0
N=int(input())
for i in range(N):
	if (i+1)%3==0 and (i+1)%5==0:
		continue
	elif (i+1)%3==0:
		continue
	elif (i+1)%5==0:
		continue
	else:
		count+=(i+1)
print(count)

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

int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string w;
    cin>>w;
    for(int i=0;i<3;i++)
    {
        if(w==s[i] && i!=2){
            cout<<s[i+1];break;}
        else if(i==2){
            cout<<s[0];break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod=1e9+7;
inline int ksm(int a,int b){
	int res=1;
	while (b){
		if (b&1) res=1ll*res*a%mod;
		a=1ll*a*a%mod;b>>=1;
	}
	return res;
}
int main(){
	int n;cin>>n;
	cout<<(ksm(10,n)-2ll*ksm(9,n)%mod+ksm(8,n)%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 3220
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;


typedef pair<int, int> Location;
typedef queue<Location> LocationQueue;

#define N 1000
char field[N][N];
int levels[N][N] = {0};
bool visited[N][N] = {false};

inline int solve(int h, int w, LocationQueue &que) {
  /*
  cout << h << " " <<  w << " " << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
  */
  Location loc;
  int i0, j0, i, j, level;
  int max_level = 0;
  const int dx[4] = {-1, 1, 0, 0};
  const int dy[4] = { 0, 0, 1,-1};

  while(que.size()){
    loc = que.front(); que.pop();
    i0 = loc.first; j0 = loc.second;
    level = levels[i0][j0];

    for(int n = 0; n < 4; n++){
        i = i0 + dx[n];
        j = j0 + dy[n];

        if (i >= 0 && i <= h - 1 && j >= 0 && j <= w -1 &&
            !visited[i][j]
            && (field[i][j] == '.'))
        {
          field[i][j] = '#';
          visited[i][j] = true;
          que.push(make_pair(i,j));
          levels[i][j] = level + 1;
          max_level = max(max_level, level+1);
        }
    }
  }

  return max_level;
}

int main(int argc, char const *argv[]) {
  int h, w;
  char c;
  LocationQueue que;

  cin >> h;
  cin >> w;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c;
      field[i][j] = c;
      if (c == '#') {
        que.push(make_pair(i, j));
        visited[i][j] = true;
      }
    }
  }

  cout << solve(h, w, que);

  return 0;
}


Measured memory_bytes: 11008
#include<stdio.h>
int main(){
  int N,i,T=100,m,count=0,flag=1;
  scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
}
  while(flag){
    flag=0;
  for(i=0;i<N-1;i++){
    if(a[i]>a[i+1]){
      m=a[i];
      a[i]=a[i+1];
      a[i+1]=m;
      count++;
      flag=1;
    }
  }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",a[i]);
    
}
  printf("%d",a[N-1]);
   printf("\n");
    printf("%d\n",count);
    return 0;
}
    
    



Measured memory_bytes: 2144
'''A - B +/- A
https://atcoder.jp/contests/abc118/tasks/abc118_a

>>> main(4, 12)
16
>>> main(8, 20)
12
>>> main(1, 1)
2
'''


def main(a: int, b: int):
    if (b % a) == 0:
        print(a+b)
    else:
        print(b-a)


if __name__ == "__main__":
    a, b = map(int, input().split(' '))
    main(a, b)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch[100000];
    scanf("%s",ch);
    int l=strlen(ch);
    if(ch[l-1]=='s')
    {
        printf("%ses",ch);
    }
    else
    
    {
        printf("%ss",ch);
    }
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    string s; cin >> s;
    int ans = 0;
    REP(i,1,s.size()){
        if(s[i]!=s[i-1]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,m,i,j;
  scanf("%d%d", &n, &m);
  int A[n][m],B[m];
  int C[n];
  int sum,sum1=0;
  for( i = 0; i < n; i++){
    for( j = 0; j < m; j++){
      scanf("%d", &A[i][j]);
    }
  }

  for( i = 0; i < m; i++){
    scanf("%d", &B[i]);
  }

  for( i = 0; i< n; i++){
    for( j = 0; j < m; j++){
      sum = A[i][j] * B[j];
      sum1 += sum;
      sum = 0;
    }
    C[i] = sum1;
    printf("%d\n", C[i]);
    sum1 = 0;
  }

  return 0;
}
 



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
deque<char>que;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int q,t,f;
    string st,c;
    bool state=true;//1为正，0为反
    cin>>st;
    for(int i=0;i<st.size();i++){
        que.push_back(st[i]);
    }
    cin>>q;
    while(q--){
        cin>>t;
        if(t==1){
            state=(!state);
        }else{
            cin>>f>>c;
            if(state){
                if(f==1) que.push_front(c[0]);
                else que.push_back(c[0]);
            }else{
                if(f==1) que.push_back(c[0]);
                else que.push_front(c[0]);
            }
        }
    }
    if(state){
        while(!que.empty()){
            cout<<que.front();
            que.pop_front();
        }
    }else{
        while(!que.empty()){
            cout<<que.back();
            que.pop_back();
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 976
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);
llong ans=0;
void merge(llong left, llong right, llong *A, llong n){
    llong mid = (left+right)/2;

    //要素数が一個
    if(right==left){
        return;
    }
    merge(left, mid, A, n);
    merge(mid+1, right, A, n);
    llong LeftArrayIndex=left;
    llong RightArrayIndex=mid+1;
    llong CopyArray[n];
    for(int i=left; i<=right; i++){
        CopyArray[i] = A[i];
    }
    for(llong i=left; i<=right; i++){
        if(RightArrayIndex>right){
            A[i] = CopyArray[LeftArrayIndex];
            LeftArrayIndex++;
            ans++;
        }else if(LeftArrayIndex>mid){
            A[i] = CopyArray[RightArrayIndex];
            RightArrayIndex++;
            ans++;
        }
        else if(CopyArray[LeftArrayIndex] >= CopyArray[RightArrayIndex]){
            A[i] = CopyArray[RightArrayIndex];
            RightArrayIndex++;
            ans++;
        }else{
            A[i] = CopyArray[LeftArrayIndex];
            LeftArrayIndex++;
            ans++;
        }
    }
    return;
}

int main(){
    llong n;
    cin >> n;
    llong A[n];
    for(int i=0; i<n; i++){
        cin >> A[i];
    }
    merge(0, n-1, A, n);
    for(int i=0; i<(n-1); i++){
        cout << A[i] << " ";
    }
    cout << A[n-1] << endl;
    cout << ans << endl;
}


Measured memory_bytes: 10872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,deduct,ans=0;
    cin>>n>>deduct;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    if(n<=deduct)
    {
        return cout<<"0"<<endl,0;
    }
    sort(arr,arr+n);
    for(int k=0; k<n-deduct; k++)
    {
        ans+=arr[k];
    }
    cout<<ans<<endl;

    return  0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int count1=0;
		int count0=0;
		for(int i = 0; i<s.length(); i++){
			if(s.charAt(i)=='0'){
				count0++;
			}else{
				count1++;
			}
		}
		System.out.println(Math.min(count0,count1)*2);
	}
}

Measured memory_bytes: 24276
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	for(int i = 100; i >= 1; --i){
		if(a % i == 0 && b % i == 0) cnt++;
		if(cnt == k){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int M)
        {
            var D = new List<int>();
            for (int i = 1; i * i <= M; ++i)
            {
                if (M % i == 0)
                {
                    D.Add(i);
                    D.Add(M / i);
                }
            }
            return D.Where(d => d <= M / N).Max();
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1]));
        }
    }
}


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

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
  int R, C, n;
  cin >> R >> C >> n;

  rep(i,n){
    int r,c,v;
    cin >> r>>c>>v;
    a[r-1][c-1]=v;
  }
  rep(i,R)rep(j,C){
    for(int k=2;k>=0;k--){
      chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
    }
    rep(k,4){
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }
  ll ans=0;
  rep(k,4){
    chmax(ans, dp[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int stone[n];
    for(int i=0;i<n;i++){
        cin>>stone[i];
    }
    //DP[i] is true if first player wins if i stones are remaning;
    vector<bool> dp(m+1,false);
    for(int i=0;i<=m;i++){
        for(int j=0;j<n;j++){
            if(i>=stone[j]&&!dp[i-stone[j]]){
                dp[i] = true;
            } 
        }
    }
    string ans="";
    ans = (dp[m]==true?"First":"Second");
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int i=1;
        int x;
        while (i != 0) {
            x = sc.nextInt();
            if(x == 0) break;
            System.out.println("Case " + i + ": " + x);
            i++;
        }
        sc.close();
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

ll I,O,T,J,L,S,Z,K;

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

	cin>>I>>O>>T>>J>>L>>S>>Z;
	if(I&&J&&L) K=(I-1)/2*2+O+(J-1)/2*2+(L-1)/2*2+3;
	cout<<max(I/2*2+O+J/2*2+L/2*2,K)<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = input()
r_count = c.count('R')
ans = 0

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

for ci in c:
    if ci == 'W':
        ans += 1
    r_count -= 1
    if r_count == 0:
        print(ans)
        exit()
print(ans)        

Measured memory_bytes: 9380
A, B, C, X, Y = map(int, input().split())
ans = X * A + Y * B
for nab in range(2, max(X, Y) * 2 + 2, 2):
    price = nab * C
    price += max(X - (nab // 2), 0) * A
    price += max(Y - (nab // 2), 0) * B
    ans = min(ans, price)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    ll cnt = 0;
    Fori(i, 1, n+1) {
        int a;
        cin >> a;
        if(i % 2 && a % 2) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    ll N, M; cin >> N >> M;
    ll ans = 0;
    ll sum = 0;
    vector<ll> v(N); for (int i = 0; i < N; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    for (int i = 0; i < N; ++i) {
        if (v[i] * 4 * M >= sum) ans++;
    }
    string mes = "Yes";
    if (ans < M) { mes = "No"; }
    cout << mes << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	char s[4];
	scanf("%s", &s);
	int i;
	if ((s[0] == '7') || (s[1] == '7') || (s[2] == '7')) {
		printf("Yes");

	}
	else {
		printf("No");
	}

	return 0;

}


Measured memory_bytes: 1736