akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

//https://atcoder.jp/contests/abc123/tasks/abc123_d

ll x, y, z, K;
VE a, b, c, ans;

bool isOK(ll P) { //美味しさの合計がP以上のものはK個以上あるか判定
    ll cnt = 0;
    REP(i, x){
        REP(j, y){
            REP(k, z) {
                if(a[i] + b[j] + c[k] < P) break;
                cnt++;
                if (cnt >= K) {
                    return true;
                }
            }
        }
    }
    return false;
}

ll binary_search() {
    ll ng = 1e12 + 7; //always true
    ll ok = -1; //always true
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

void check(ll border) {
    REP(i, x){
        REP(j, y){
            REP(k, z) {
                if(a[i] + b[j] + c[k] < border)break;
                ans.push_back(a[i] + b[j] + c[k]);
            }
        }
    }
}

int main() {
    cin >> x >> y >> z >> K;
    ll A, B, C;
    REP(i, x) {cin >> A; a.push_back(A);}
    REP(i, y) {cin >> B; b.push_back(B);}
    REP(i, z) {cin >> C; c.push_back(C);}
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    ll bi = binary_search();
    check(bi + 1);
    sort(ans.rbegin(), ans.rend());
    REP(i, ans.size())print(ans[i]);
    rep(i, ans.size(), K) print(bi);
}

Measured memory_bytes: 384
n,k = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
ans = 10**19
it = x.bsearch_index{|i|i >= 0}
if it
  for i in it..[n-1,it+k-1].min
    if -k+i+1 >= 0
      temp = x[i]*2+(x[-k+i+1]).abs
      ans = temp if temp < ans
      temp = x[i]+(x[-k+i+1]).abs*2
      ans = temp if temp < ans
    end
  end
  if it+k-1 < n
    ans = x[it+k-1] if x[it+k-1] < ans
  end
  if it-k+1 >= 0
    if x[it] == 0
      ans = (x[it-k+1]).abs if (x[it-k+1]).abs < ans
    elsif it-k >= 0
      ans = (x[it-k]).abs if (x[it-k]).abs < ans
    end
  end
else
  ans = (x[n-k]).abs
end
puts ans

Measured memory_bytes: 9492
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  char S[4];cin>>S;
  sort(S,S+4);
  if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<int> d(N);
	for (i=0;i<N;i++){
		cin>>d[i];
	}
	sort(d.begin(),d.end());
	int l=d[N/2-1];
	int r=d[N/2];
	if (l==r){
		cout<<0<<endl;
		return 0;
	}
	int ans=r-l;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  for (auto& x : a) {
    cin >> x;
    sum += x;
  }
  ll ans = 1e18;
  for (int i = 0; i < n - 1; i++) {
    if (i) a[i] += a[i - 1];
    ans = min(ans, abs(2 * a[i] - sum));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
 
int main()
{
  int k;
  cin >> k;
 
  if (k % 2 == 0)
  {
    cout << -1 << "\n";
    return 0;
  }
  else
  {
    int count = 1;
    long long num = 7;
    while (count <= 1000000)
    {
      if (num % k == 0)
      {
        cout << count << "\n";
        // break;
        return 0;
      }
      count++;
      num = (num * 10 + 7) % k;
    }
  }
  cout << -1 << "\n";
 
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n; 
vll G[100100];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n;
  vpll ab(n-1);
  rep(i,n-1){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
    ab[i]={a,b};
  }
  
  queue<pll> q;
  q.emplace(0,0);
  vb visited(n);
  visited[0]=true;
  ll k=1;
  map<pll,ll> m;
  while(!q.empty()){
    auto p=q.front(); q.pop();
    ll v=p.first, color=p.second;
    ll ncolor=1;
    for(auto nv:G[v]){
      if(visited[nv]) continue;
      visited[nv]=true;
      if(color==ncolor) ncolor++;
      m[{v,nv}]=m[{nv,v}]=ncolor;
      chmax(k,ncolor);
      q.emplace(nv,ncolor);
      ncolor++;
    }
  }
  
  cout<<k<<endl;
  rep(i,n-1){
    cout<<m[ab[i]]<<endl;
  }
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int t;
    t = 1;
    bool ok = false;
    if(a == t || b == t || c == t || d == t){
        t = 9;
        if(a == t || b == t || c == t || d == t){
            t = 7;
            if(a == t || b == t || c == t || d == t){
                t = 4;
                if(a == t || b == t || c == t || d == t){
                    ok = true; 
                }
            }
        }
    }

    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a) = scan!(usize, usize);
    let vs = scan!(usize;;);
    let mut dp = vec![vec![vec![0; vs.iter().max().unwrap() * n + 1]; n + 1]; n + 1];

    dp[0][0][0] = 1;

    // card num
    for (i, &v) in vs.iter().enumerate() {
        // selected num
        for j in 0..dp[i + 1].len() {
            // sum
            for n in 0..dp[i + 1][j].len() {
                dp[i + 1][j][n] += if j > 0 && n >= v {
                    dp[i][j][n] + dp[i][j - 1][n - v]
                } else {
                    dp[i][j][n]
                }
            }
        }
    }

    let mut ans: i64 = 0;
    for (num, v) in dp[n].iter().enumerate().skip(1) {
        for (sum, &n) in v.iter().enumerate() {
            if sum % num == 0 && sum / num == a {
                ans += n;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 67836
#include<cstdio>

int selec_sort(int *a, int n){
    int count=0;
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i+1; j < n; j++){
            if(a[j] < a[minj]) minj = j;
        }
        int tmp = a[minj];
        a[minj] = a[i];
        a[i] = tmp;
        if(minj != i) count++;
    }
    return count;
}

int main(){
    int n; scanf("%d", &n);
    int a[100];
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int b = selec_sort(a, n);
    for(int i = 0; i < n-1; i++)
        printf("%d ", a[i]);
    printf("%d\n", a[n-1]);
    printf("%d\n", b);
}



Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define swap(a,b) ((a != b) && (a += b,b = a - b,a -= b))
using namespace std;


int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}

int main()
{
    int m,n,k;
    cin >> n >> m;

    vector<int> l(m+1,1);

    for(int i=0;i<n;i++){
        vector<int> ll(m+1,0);
        int a;
        cin >> k;
        for(int j=0;j<k;j++){
            cin>>a;
            ll[a]=1;
        }
        for(int j=0;j<m+1;j++){
            if(ll[j]==0)l[j]=0;
        }
    }

    cout<<accumulate(l.begin(), l.end(), 0)<<endl;
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#define ll long long
using namespace std;
int main()
{
    int t;
    int a[100005],b[2];
     b[0]=0;
     b[1]=0;
    scanf("%d",&t);
    for(int i=1; i<=t; i++)
    {
        scanf("%d",&a[i]);
    }
    sort (a+1,a+t+1);
    int f=0;
    for(int j=t; j>=1;)
    {
        if(f<2)
        {
            if(a[j]==a[j-1])
             {
                b[f]=a[j];
                f++;
                j=j-2;
                if(f==2)
                    break;
             }
            else
                j=j-1;
        }
    }
    ll s;
    s=(ll)b[0]*b[1];
    printf("%lld\n",s);
    return 0;

}


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


main(){
  int n;
  long long m[256],a[256],b[256];
  while(cin >> n,n){
    int temp;
    long long t=0;
    int cheak=0;
    for(int i=0;i<n;i++){
      cin >> m[i] >> a[i] >> a[i+n];
      b[i]=1;
      b[i+n]=2;
      m[i+n]=m[i];
    }

    for(int i=0;i<2*n-1;i++){
      for(int j=i+1;j<2*n;j++){
	if(a[i]>a[j]){
	  temp=a[i];
	  a[i]=a[j];
	  a[j]=temp;
	  temp=b[i];
	  b[i]=b[j];
	  b[j]=temp;
	  temp=m[i];
	  m[i]=m[j];
	  m[j]=temp;
	}
      }
    }

    
    for(int i=0;i<2*n;i++){
      if(b[i]==1) t+=m[i];
      else t-=m[i];
      if(t>150 && i!=2*n-1 && a[i]!=a[i+1]) cheak=1;
    }

    if(cheak==1) cout << "NG" << endl;
    else cout << "OK" << endl;
  }
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    string s[] = { "AC", "WA", "TLE", "RE" }, t;
    map<string, int> mp;
    int n;
    cin >> n;
    while (n--) {
        cin >> t;
        mp[t]++;
    }
    for (int i = 0; i < 4; ++i) {
        cout << s[i] << " x " << mp[s[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
def do(level,x):
    if x<=0: #1層も手を付けないとき
        return 0
    elif x>=whole[level]: #完食できるとき
        return patty[level]
    #それ以外、途中まで食べるときはlevel>=1の場合のみあり得る
    x-=1 #このとき1層目は必ずバンズ
    res=0 #食べたパティの総数を記録する
    if x>=whole[level-1]+1: #真ん中のパティまで到達できるとき
        x-=whole[level-1]+1
        res+=patty[level-1]+1
    return res+do(level-1,x)

n,x=map(int,input().split())
whole=[1]+[0]*50
patty=[1]+[0]*50
for i in range(1,n+1):
    whole[i]=whole[i-1]*2+3
    patty[i]=patty[i-1]*2+1
print(do(n,x))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
char ans[3] = {'A','B','C'};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  deque<int>dq[3];
  for(int i = 0; i < 3; ++i){
    string s;
    cin >> s;
    for(auto c : s){
      if(c == 'a')dq[i].push_back(0);
      else if(c == 'b')dq[i].push_back(1);
      else dq[i].push_back(2);
    }
  }
  int current = 0;
  while(true) {
    if(dq[current].empty()) {
      cout << ans[current] << endl;
      exit(0);
    }
    int c = dq[current].front();
    dq[current].pop_front();  
    current = c;
  }
  
  return 0;
}

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

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

    vector<bool> alphabet(26, false);
    for(auto c : s){
        int num = c - 'a';
        alphabet[num] = true;
    }

    string ans;
    bool flag = false;
    for(int i = 0; i < 26; i++){
        if(!alphabet[i]){
            ans += (i + 'a');
            flag = true;
        }
    }
    if(flag){
        ans = ans[0];
    }
    else{
        ans = "None";
    }

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

Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){
  ll A , B;

  cin >> A >> B;

  bool flag = true;
  ll i = 1;
  while(flag){
    if((A*2) <= B){
      i++;
      A = A*2;
    }else{
      flag = false;
    }

  }

  cout << i << endl;

  return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################
char arr[200];
char tmp[200];

void solve() {

    scanf("%s", arr);
    int k;
    SI(k);
    int n = strlen(arr);
    int ans = 0;
    
    if(k == 1) {
        ans += 9 * (n - 1);
        ans += arr[0] - '0';
    }
    tmp[n] = 0;
    REP(i, n) tmp[i] = '0';

    if(k == 2) {

        if(n - 1 >= 2) {
            ans += (n-1) * (n-2) / 2 * 9 * 9;
        }
        if(n >= 2) {
            for(int i = 1 ; i <= 9 ; i++) {
                tmp[0] = i + '0';
                for(int z = 1 ; z < n ; z++) {
                    for(int j = 1 ; j <= 9 ; j++) {
                        tmp[z] = j + '0';
                        if(strcmp(arr, tmp) >= 0) {
                            ans++;
                        }
                    }
                    tmp[z] = '0';
                }
                tmp[0] = '0';
            }
        }
    }

    if(k == 3) {
        
        if(n - 1 >= 3) {
            ans += (n-1) * (n-2) * (n-3) / 6 * 9 * 9 * 9;

        }
        if(n >= 3) {
            for(int i = 1 ; i <= 9 ; i++) {
                tmp[0] = i + '0';
                for(int z = 1 ; z < n ; z++) {
                    for(int y = z+1 ; y < n ; y++) {
                        for(int j = 1 ; j <= 9 ; j++) {
                            tmp[z] = j + '0';
                            for(int kk = 1 ; kk <= 9 ; kk++) {
                                tmp[y] = kk + '0';
                                if(strcmp(arr, tmp) >= 0) {
                                    ans++;
                                }
                                tmp[y] = '0';
                            }
                            tmp[z] = '0';
                        }
                    }
                }
                tmp[0] = '0';
            }
        }
    }

    printf("%d\n", ans);
}

void init() {
    


}

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




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

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    queue<pair<int, int>> que;
    rep(i, H) rep(j, W){
        char tmp; cin >> tmp;
        if(tmp == '.'){
            A[i][j] = -1;
        }
        else if(tmp == '#'){
            A[i][j] = 0;
            que.push(pair<int, int>(i, j));
        }
    }
    int ans = 0;
    int hd[] = {0,1,0,-1}, wd[] = {1,0,-1,0};
    while(!que.empty()){
        int hs = que.front().first;
        int ws = que.front().second;
        rep(i, 4){
            int ht = hs + hd[i];
            int wt = ws + wd[i];
            if(ht < 0 || ht >= H || wt < 0 || wt >= W){
                continue;
            }
            if(A[ht][wt] == -1){
                A[ht][wt] = A[hs][ws] + 1;
                que.push(pair<int, int>(ht, wt));
                ans = max(ans, A[ht][wt]);
            }
        }
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15292
n,m = map(int,input().split())
L = [list(map(int,input().split()))[1:] for _ in range(m)]
P = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
  on = bin(i)[2:].zfill(n)
  for s,p in zip(L,P):
    if sum(int(on[sij-1]) for sij in s) % 2 != p:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;

    cin >> s;
    string ans = "";
    ans += s[0];
    for (size_t i = 1; i < s.size(); ++i) {
        if (s[i - 1] != s[i])ans += s[i];
    }
    cout << ans.size() << endl;
    return 0;
}

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

int main(){
  string str;
  cin >> str;
  
  int posi_A, posi_Z;
  posi_A=str.find('A');
  posi_Z=str.rfind('Z');
  
  cout << posi_Z-posi_A+1 << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        long N = cin.Long();
        long P = cin.Long();

        if (N == 1) Console.WriteLine(P);
        else
        {
            long g = 1;
            long ans = 0;
            while (Math.Pow(g, N) <= P)
            {
                if (P % (long)Math.Pow(g, N) == 0) ans = g;
                g++;
            }
            Console.WriteLine(ans);

        }

        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
    #ifdef DGC
        //freopen("a.txt", "r", stdin);
        //freopen("b.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0);

    int n, l;
    cin >> n >> l;

    int s = 0;
    for (int i = 1; i <= n; ++i)
    	s += l+i-1;

    int ans = 1<<30, w;
    for (int k = 1; k <= n; ++k)
    {
    	int ss = 0;
    	for (int i = 1; i <= n; ++i)
    		if (i != k)
    			ss += l+i-1;
    	if (abs(s-ss) < ans)
    		ans = abs(s-ss), w = ss;
    }

    cout << w << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60
int main(){
    long long N;
    cin >> N;
    vector<long long>A(N+1);
    vector<long long>B(N);
    for(long long i=0;i<N+1;i++){
        cin >> A[i];
    }
    for(long long i=0;i<N;i++){
        cin >> B[i];
    }

    long long ans=0;
    for(long long i=0;i<N;i++){
        long long C=min(A[i],B[i]);
        ans+=C;
        A[i]-=C;
        B[i]-=C;
        long long D=min(A[i+1],B[i]);
        ans+=D;
        A[i+1]-=D;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    auto ans = (a * b % 2 == 0)
            ?"No"
            :"Yes";
    co(ans);
    return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    int a;
    int min_number = -1;
    int minus_count = 0;
    ll sum_number = 0;
    for(int i=0;i<N;i++){
        cin >> a;
        if (a<0){
            minus_count++;
        }
        if(min_number==-1){
            min_number = abs(a);
        }else{
            min_number = min(min_number, abs(a));
        }
        sum_number += abs(a);
    }
    if(minus_count%2 == 1){
        sum_number -= min_number * 2;
    }
    cout << sum_number;
    return 0;
}

Measured memory_bytes: 640
f = gets.split.map(&:to_i)
s = gets.split.map(&:to_i)
t = gets.split.map(&:to_i)
f.push(s)
f.push(t)
f.flatten!

if f.count(f.max_by {|x| f.count(x)}) > 2 
    puts "NO" 
else
    puts "YES"
end

Measured memory_bytes: 1788
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        int[] as = new int[n];
        int[] bs = new int[n];
        
        int k = 0;
        
        for(int i=0; i<n-1; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            as[i] = a;
            bs[i] = b;
            g[a].add(b);
            g[b].add(a);
            k = Math.max(k, g[a].size());
            k = Math.max(k, g[b].size());
        }
        
        HashMap<Long, Integer> ans = new HashMap<>();
        boolean[] used = new boolean[n];
        used[0] = true;
        int[] par = new int[n];
        ArrayDeque<Integer> q = new ArrayDeque<>();
        q.addFirst(0);
        while(q.size() != 0){
            int now = q.removeLast();
            int cnt = 0;
            for(int i=0; i<g[now].size(); i++){
                int next = g[now].get(i);
                if(!used[next]){
                    cnt++;
                    if(cnt == par[now]) cnt++;
                    par[next] = cnt;
                    ans.put(((long)now<<32) | next , cnt);
                    ans.put(((long)next<<32) | now , cnt);
                    used[next] = true;
                    q.addFirst(next);
                }
            }
        }
        
        System.out.println(k);
        for(int i=0; i<n-1; i++){
            long key = ((long)as[i]<<32) | bs[i];
            System.out.println(ans.get(key));
        }
    }
}


Measured memory_bytes: 85344
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef long long ll;


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  ll ans = 0;
  REP(i, N) {
    ans += min(B[i], A[i] + A[i + 1]);
    ll rest = max(0LL, B[i] - A[i]);
    A[i + 1] = max(0LL, A[i + 1] - rest);
  }

  printf("%lld\n", ans);
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N+1);
  for(int i = 0 ; i < N+1 ; i++){
    scanf("%lld",&A[i]);
  }
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
   int n,m,k; cin >> n >> m >> k;
   rep(j,0,n+1) {
     rep(i,0,m+1) {
       int res=i*(n-j)+j*(m-i);
       if(res==k){
          cout << "Yes" << endl;
          return 0;
       }
     }
   } 
   cout << "No" << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    int l, r, d, x = 0;
    cin >> l >> r >> d;
    FOR(i, l, r) {
        if (i % d == 0) x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
vector<int> G[MAXN];

int dfs(int node, int par){
	int cnt=0;
	for (int v:G[node]) if (v!=par) cnt+=dfs(v, node);
	if (!cnt) return 1;
	if (cnt==1) return 0;
	cout<<"First\n";
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	if (n&1) kill("First")
	for (int i=1; i<n; i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1, 1);
	cout<<"Second\n";
	
	return 0;
}


Measured memory_bytes: 9168
#!/usr/bin/env python3
import sys

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b),b) + str(n%b)
    return str(n%b)

def solve(N: int, K: int):
    return len(base10to(N, K))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(N, K))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int count, max;
	max = 50;
	int m[max], f[max], r[max], s;
	for (count = 0; count < max; count++) {
		scanf("%d %d %d", &m[count], &f[count], &r[count]);
		if (m[count] == -1 && f[count] == -1 && r[count] == -1) {
			break;
		}
	}
	for (int i = 0; i < count; i++) {
		s = m[i] + f[i];
		if (m[i] == -1 || f[i] == -1) {
			printf("F\n");
		} else if (s >= 80) {
			printf("A\n");
		} else if (s >= 65) {
			printf("B\n");
		} else if (s >= 50) {
			printf("C\n");
		} else if (s >= 30) {
			if (r[i] >= 50) {
				printf("C\n");
			} else {
				printf("D\n");
			}
		} else {
			printf("F\n");
		}
	}
}



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

using namespace std;

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

struct point {
	int x;
	int y;
	point(int a, int b) : x(a), y(b) {}
	point() : x(0), y(0) {}
	int operator-(const point& a) {
		return abs(x - a.x) + abs(y - a.y);
	}
};

vector<point> p, c;
int n, m;

int culcpos(int a)
{
	int k = 1e9;
	int res = -1;
	rep(i, m) {
		int t = p[a] - c[i];
		if (t < k) {
			k = t;
			res = i;
		}
	}
	return res + 1;
}


int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		p.emplace_back(x, y);
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		c.emplace_back(x, y);
	}
	rep(i, n) {
		cout << culcpos(i) << endl;
	}
}



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

using namespace std;

int main()
{
	for(int n;cin>>n;){
		int bp,tp; cin>>bp>>tp;
		int bc; cin>>bc;
		vector<int> tcs(n);
		for(int i=0;i<n;i++)
			cin>>tcs[i];
		sort(tcs.begin(),tcs.end(),greater<int>());
		
		int res=bc/bp;
		for(int i=0,j=0;i<n;i++){
			j+=tcs[i];
			res=max(res,(bc+j)/(bp+tp*(i+1)));
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
vector<int> g[100000];
int dmx[100000];
bool used[100000];
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(used[y]) continue;
		dfs(y);
		dmx[x]=max(dmx[y]+1, dmx[x]);
	}
}
int dmx1[100000], ans[100000];
void dfs2(int x){
	used[x]=1;
	int mx=0, mx2=0;
	for(auto y:g[x]){
		if(used[y]){
			if(mx<dmx1[x]){
				mx2=mx;
				mx=dmx1[x];
			}else if(mx2<dmx1[x]){
				mx2=dmx1[x];
			}
		}else{
			if(mx<dmx[y]+1){
				mx2=mx;
				mx=dmx[y]+1;
			}else if(mx2<dmx[y]+1){
				mx2=dmx[y]+1;
			}
		}
	}
	for(auto y:g[x]){
		if(used[y]) continue;
		if(mx==dmx[y]+1){
			dmx1[y]=mx2+1;
		}else{
			dmx1[y]=mx+1;
		}
	}
	ans[x]=2*(n-1)-max(dmx[x], dmx1[x]);
	for(auto y:g[x]){
		if(!used[y]) dfs2(y);
	}
}

int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int u, v;
		cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0);
	fill(used, used+n, 0);
	dfs2(0);
	for(int i=0; i<n; i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 14556
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int n;
string s,t;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	cin>>s>>t;
	for(ri i=0;i<n;++i)
		cout<<s[i]<<t[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define fi first
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, ii>  iii;
typedef pair<double, double>  iidb;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3600000
#define offset 3000
#define ptr nodo*
const ll MOD=1e9+7;

using namespace std;
const ll inf=1e15;
bool vis[tam][100];
void MODUL(int &num,int &mod){
	while(num>=mod)num-=mod;
}
int main()
{	
	
	int n;
	cin>>n;
	queue<ii> cola;
	forr(i,1,10)
	cola.push({i,i});
	while(!cola.empty())
	{
		auto par=cola.front();
		cola.pop();
		vis[par.fi][par.se]=1;
		if (par.se>90)continue;
		forr(j,0,10){
			int nxt=par.fi*10+j;MODUL(nxt,n);
			int nxt2=par.se+j;
			if (!vis[nxt][nxt2]){
				vis[nxt][nxt2]=1;
				cola.push({nxt,nxt2});
			}
		}	
	}
	forr(i,1,100)
	{
		if (vis[0][i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	assert(false);
}			

Measured memory_bytes: 46244
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n,mx=0;
    cin>>n;
    string s;
    map<string,int>m;
    for (int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
        mx=max(mx,m[s]);
    }
    for (map<string,int>::iterator it=m.begin();it!=m.end();it++)
        if (it->second==mx)
        cout<<it->first<<'\n';
    return 0;
}

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

class Bipartite {
public:
  Bipartite(int n)
    : graph(n), pairs(n, -1), used(n, false) {}

  void addEdge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  int run() {
    int res = 0;
    for (int v = 0; v < pairs.size(); ++v) {
      if (pairs[v] < 0) {
        fill(used.begin(), used.end(), false);
        if (dfs(v))
          ++res;
      }
    }
    return res;
  }

private:
  bool dfs(int v) {
    used[v] = true;
    for (int u : graph[v]) {
      int w = pairs[u];
      if (w < 0 || (!used[w] && dfs(w))) {
        pairs[v] = u;
        pairs[u] = v;
        return true;
      }
    }
    return false;
  }

  int v;
  vector<vector<int>> graph;
  vector<int> pairs;
  vector<bool> used;
};

using Point = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<Point> reds, blues;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    reds.emplace_back(a, b);
  }
  for (int i = 0; i < n; ++i) {
    int c, d;
    cin >> c >> d;
    blues.emplace_back(c, d);
  }

  Bipartite bib(2*n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (reds[i].first < blues[j].first && reds[i].second < blues[j].second)
        bib.addEdge(i, n + j);
    }
  }
  cout << bib.run() << "\n";

  return 0;
}


Measured memory_bytes: 256
x=gets.to_i
if x >= 400 && x <= 599
  puts 8
elsif x >= 600  && x <= 799
  puts 7
elsif x >= 800  && x <= 999
  puts 6
elsif x >= 1000  && x <= 1199
  puts 5
elsif x >= 1200  && x <= 1399
  puts 4
elsif x >= 1400  && x <= 1599
  puts 3
elsif x >= 1600  && x <= 1799
  puts 2
elsif x >= 1800  && x <= 1999
  puts 1
end

Measured memory_bytes: 14356
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vu64 l;
vu64 p;

u64 solve(u64 n, u64 x)
{
    u64 ret = 0;
    if (n == 0)
    {
        ret = p[0];
    }
    else if (x <= 1)
    {
        ret = 0;
    }
    else if (2 <= x && x <= l[n - 1] + 1)
    {
        ret = solve(n - 1, x - 1);
    }
    else if (l[n - 1] + 2 == x)
    {
        ret = p[n - 1] + 1;
    }
    else if (l[n - 1] + 3 <= x && x <= 2 * l[n - 1] + 2)
    {
        ret = solve(n - 1, x - l[n - 1] - 2) + p[n - 1] + 1;
    }
    else if (x == l[n])
    {
        ret = p[n];
    }
    return ret;
}

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

    u64 N, X;
    cin >> N >> X;

    l.resize(N + 1);
    p.resize(N + 1);

    l[0] = p[0] = 1;
    rep (i, N)
    {
        l[i + 1] = 2 * l[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }

    cout << solve(N, X) << "\n";
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(n),i++)

using namespace std;
int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    if (s == "ARC") cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

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

using namespace std;
using ll = long long;

int main() {
	int N, C;
	cin >> N >> C;
	vector<int> s(N), t(N), c(N);
	REP(i, N) cin >> s[i] >> t[i] >> c[i];
	vector<vector<int>> time(C,vector<int>(100000 + 1,0));
	int ch,chmax = 0;
	REP(i, N) FOR(j, s[i], t[i] + 1) {
		time[c[i] - 1][j] = 1;
	}
	REP(i, 100000 + 1) {
		ch = 0;
		REP(j, C) ch += time[j][i];
		chmax = max(chmax, ch);
	}
	cout << chmax << endl;

	return 0;
}

Measured memory_bytes: 13568
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#include<sstream>
#include<time.h>

#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define MEM(a) memset(a, 0, sizeof(a))
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
#define endl "\n"
#define eps 1e-8
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  998244353;

int n, m, k;

ll work(ll x)
{
    ll c = 0, sum = 0;
    for(ll i = 1;i <= N; ++i) {
        if(sum+i > x)  break;
        sum += i;
        c++;
    }
    return c;
}
void solve()
{
   ll a;
   scanf("%lld", &a);
   ll t = a;
   ll ans = 0;
   for(ll i = 2; i*i <= t; ++i) {
        if(t%i == 0) {
            ll c = 0;
            while(t%i == 0) {
                t/=i;
                c++;
            }
            ans += work(c);
        }
   }
   if(t > 1) ans++;
   printf("%lld\n", ans);

}

int main()
{
//    FAST();
//    init();
//    int _;scanf("%d", &_); while(_--)
//    while(scanf("%d", &n)&&n)
//    while(scanf("%d%d%d", &n, &m, &k)&&(n+m+k))
    solve();
    return 0;
}


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

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

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

	string s; cin >> s;

	int cnt = 0;

	for (int i = 0;i < s.size();i++){
		if(s[i] == '0') cnt--;
		else cnt++;
	}

	cout << s.size()-abs(cnt) << endl;
	return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;

char maze[1001][1001];
int dis[1001][1001];

int main(void){
    int H, W, N;
    int sx, sy;
    cin >> H >> W >> N;
    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
            if(maze[i][j]=='S') sy = i, sx = j;
        }
    }
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};

    int ans = 0;

    const int INF = 99999999;

    rep(HP, N+1) {
        queue<P> que;
        rep(i, H) rep(j, W) dis[i][j] = INF;
        que.push(P(sx, sy));
        dis[sy][sx] = 0;

        while(que.size()) {
            P p = que.front(); que.pop();
            if(maze[p.second][p.first] == HP+'0') {
                sx = p.first;
                sy = p.second;
                ans += dis[sy][sx];
                break;
            }
            rep(i, 4) {
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];
                if(nx >= 0 && nx < W && ny >= 0 && ny < H 
                   && maze[ny][nx] != 'X' && dis[ny][nx]==INF) {
                    que.push(P(nx, ny));
                    dis[ny][nx] = dis[p.second][p.first] + 1;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6112