akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n;
vi a, b, c;

int main(){
  scanf("%d", &n);
  a.resize(n);
  b.resize(n);
  c.resize(n);

  for(int& e : a) scanf("%d", &e);
  for(int& e : b) scanf("%d", &e);
  for(int& e : c) scanf("%d", &e);

  sort(all(a));
  sort(all(b));
  sort(all(c));

  vector<pair<int, ll>> bc;
  for(int i = n - 1;i >= 0;--i){
    while(!c.empty() && b[i] < c.back())
      c.pop_back();
    bc.pb(mp(b[i], n - sz(c)));
  }

  sort(all(bc));

  ll ans = 0, cur = 0;
  for(int i = n - 1;i >= 0;--i){
    while(!bc.empty() && a[i] < bc.back().fi)
      cur += bc.back().se,
      bc.pop_back();
    ans += cur;
  }

  cout << ans << '\n';

  return 0;
}


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

def resolve():
    s=input()
    x=len(s)//2
    l1='10'*x+'1'
    l2='01'*x+'0'
    cnt1=0
    cnt2=0
    for i in range(len(s)):
        if s[i]!=l1[i]:
            cnt1+=1
        if s[i]!=l2[i]:
            cnt2+=1
    print(min(cnt1,cnt2))
resolve()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;


int main(){
    string S, T;
    cin >> S >> T;
    vector<set<int>> sto(26), tto(26);

    int n = S.size();

    rep(i,n){
        sto[S[i]-'a'].insert(T[i]-'a');
        tto[T[i]-'a'].insert(S[i]-'a');
    }

    bool isOK = true;
    rep(i,26){
        if (sto[i].size() > 1) isOK = false;
        if (tto[i].size() > 1) isOK = false;
    }

    if(isOK) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

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

using namespace std;

long long cnts[5];

int main() {
    int N;
    cin >> N;
    string s;
    for (int i = 0; i < N; ++i) {
        cin >> s;
        if (s[0] == 'M') cnts[0]++;
        else if (s[0] == 'A') cnts[1]++;
        else if (s[0] == 'R') cnts[2]++;
        else if (s[0] == 'C') cnts[3]++;
        else if (s[0] == 'H') cnts[4]++;
    }

    long long ans = 0;
    ans += cnts[0] * cnts[1] * cnts[2];
    ans += cnts[0] * cnts[1] * cnts[3];
    ans += cnts[0] * cnts[1] * cnts[4];
    ans += cnts[0] * cnts[2] * cnts[3];
    ans += cnts[0] * cnts[2] * cnts[4];
    ans += cnts[0] * cnts[3] * cnts[4];
    ans += cnts[1] * cnts[2] * cnts[3];
    ans += cnts[1] * cnts[2] * cnts[4];
    ans += cnts[1] * cnts[3] * cnts[4];
    ans += cnts[2] * cnts[3] * cnts[4];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
class Dice:
    def __init__(self, labels):
        self.labels = labels
        
    def __str__(self):
        return str(self.labels[0])
    
    def roll_south(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[4], self.labels[0], self.labels[1], self.labels[5]
            
    def roll_east(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[3], self.labels[0], self.labels[2], self.labels[5]
    
    def roll_west(self):
        self.labels[0], self.labels[3], self.labels[5], self.labels[2] = self.labels[2], self.labels[0], self.labels[3], self.labels[5]
    
    def roll_north(self):
        self.labels[0], self.labels[4], self.labels[5], self.labels[1] = self.labels[1], self.labels[0], self.labels[4], self.labels[5]
        
def main():
    labels = list(map(int, input().split()))
    orders = input()
    d = Dice(labels)
    for o in orders:
        if o == 'S':
            d.roll_south()
        elif o == 'E':
            d.roll_east()
        elif o == 'W':
            d.roll_west()
        elif o == 'N':
            d.roll_north()
    print(d)
    
main()


Measured memory_bytes: 5608
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  vvll dp(n + 1, vll(2, INF));
  dp[0][0] = 0;
  rep(i, n) {
    ll di = s[n - 1 - i] - '0';
    dp[i + 1][0] = dp[i][0] + di;
    if(di != 0) dp[i + 1][1] = dp[i][0] + 10 - di;
    if (dp[i][1] != INF) {
      if(di != 9) chmin(dp[i + 1][0], dp[i][1] + di + 1);
      chmin(dp[i + 1][1], dp[i][1] + 9 - di);
    }
  }

  ll ans = min(dp[n][0], dp[n][1] + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 58012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0;(i) < (n); (i)++)
int main(){
 int n,m,l,j;
 cin >> n;
 m = n/500;
 l = n%500;

 j = l/5;

 cout << m*1000 + j*5 << endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli a[2][110];
lli sum[2][110];

signed main(){

	lli n;
	cin>>n;

	REP(i,0,2)REP(j,0,n)cin>>a[i][j];

	REP(i,0,2)REP(j,0,n)sum[i][j+1] = sum[i][j]+a[i][j];

	lli ans = 0;
	REP(i,0,n){
		ans = max(ans,sum[0][i+1]+sum[1][n]-sum[1][i]);
	}
	cout<<ans<<endl;


	return 0;
}

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

void fnInput(vector<int>& rvnHeight)
{
  int nHeightSiz;
  cin >> nHeightSiz;
  rvnHeight.resize(nHeightSiz);

  for (int& rnHeight : rvnHeight)
    cin >> rnHeight;
}

int fnMinExecCnt(vector<int>& rvnHeight)
{
  int nExecCnt = 0;
  int nPrevExecCnt = -1;

  while (nPrevExecCnt != nExecCnt)
  {
    nPrevExecCnt = nExecCnt;
    int nBgn = 0;
  
    while (nBgn < rvnHeight.size() )
    {
      int nFoward = nBgn;

      while (nFoward < rvnHeight.size() &&
             rvnHeight[nFoward]            )
      {
        rvnHeight[nFoward]--;
        nFoward++;
      }

      if (nBgn != nFoward) nExecCnt++;
      nBgn = nFoward + 1;
    }
  }
  return nExecCnt;
}
 
int main()
{
  vector<int> vnHeight;

  fnInput(vnHeight);
  cout << fnMinExecCnt(vnHeight) << endl;

  return 0;
}

Measured memory_bytes: 3600
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
if T[-1] != A[0] or T.index(T[-1]) > N - 1 - A[::-1].index(A[0]):
    print(0)
    exit()
ans = 1
MOD = 10 ** 9 + 7
for i in range(1, N - 1):
    t_comb = 1
    if T[i - 1] == T[i]:
        t_comb *= T[i]

    a_comb = 1
    if A[i] == A[i + 1]:
        a_comb *= A[i]
    ans = (ans * min(t_comb, a_comb)) % MOD
print(ans)

Measured memory_bytes: 18752
n,k = gets.split.map(&:to_i)
s = gets.chomp
ans = 0
cnt = 0
cnt += 1 if s[0] == "L"
cnt += 1 if s[n-1] == "R"
cnt -= 1 if s[0] == "L" || s[n-1] == "R"
1.upto(n-1) do |i|
  if s[i-1] == s[i]
    ans += 1
  elsif s[i-1] == "R" && s[i] == "L"
    cnt += 1
  else
    cnt
  end
end

if cnt <= k
  p n-1
else
  p ans + k * 2
end

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
#define endll ("\n")
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b <= a + c && a + b <= b + c) {
        cout << a + b << endll;
    } else if (a + b >= a + c && c + b >= a + c) {
        cout << a + c << endll;
    } else {
        cout << b + c << endll;
    }
}









Measured memory_bytes: 3608
#include<stdio.h>
#define ROOT -1
#define N 100000

typedef struct node{
  int pa;
  int left; 
  int right;
}NODE;

 NODE T[N];


int num, h=0;
int  De[N];

int depth(int);
void print(int);


/*main 関数*/
main(){

  int  i,j,t;
  int  degree, num2, elem;


  scanf("%d", &num);
  /*初期化*/
  for ( i = 0; i < num; i++ ){
    T[i].pa = ROOT;
    T[i].left = ROOT;
    T[i].right = ROOT;
  }


  for ( i = 0; i < num; i++ ){
    scanf("%d %d", &num2, &degree);

    for ( j = 0; j < degree; j++ ){
      scanf("%d", &elem);


      if ( j == 0 ){
	T[num2].left = elem;
      }
      else {
	
	T[t].right = elem;
      }
      
      t = elem;
      /*親指定*/
      T[t].pa = num2;
    }
  }
  
  for ( i = 0; i < num; i++ ){ De[i] = depth(i); }

  /*表示*/
  for ( i = 0; i < num; i++ ){

    /*関数の呼出*/
    print(i);
  }
  return 0;
}

void print(int a){
  int i;
  int c;


  printf("node %d: ", a);
  printf("parent = %d, ", T[a].pa);
  printf("depth = %d, ", De[a]);

  if ( T[a].pa == ROOT ) printf("root, ");

  else if ( T[a].left == ROOT ) printf("leaf, ");

  else printf("internal node, ");

  printf("[");


  for(i = 0, c = T[a].left; c != ROOT; i++, c = T[c].right){
    if (i!=0){
 printf(", ");
    }

    printf("%d", c);
  }
  printf("]\n");
}

/*深さの計算*/
int depth(int a){
  int cnt=0;

  while(T[a].pa != ROOT){
    cnt++;
    a = T[a].pa;
   
  }
  return cnt;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,y,k;
	scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
	if((2*c)<(a+b))
	{
		if(x>y)
		{
			k=x*c*2;
			if((y*2*c+(x-y)*a)<k)
				printf("%d",y*2*c+(x-y)*a);
			else
				printf("%d",k);
		}
		else
		{
			k=y*c*2;
			if((x*2*c+(y-x)*b)<k)
				printf("%d",x*2*c+(y-x)*b);
			else
				printf("%d",k);
		}
	}
	else
		printf("%d",x*a+y*b);
	return 0;
}


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

int get5(int n) {
    int ans = 0;
    int now = 5;
    while (now <= n) {
        ans += n / now;
        now *= 5;
    }
    return ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if (n % 2 == 0) {
        n /= 2;
        cout << get5(n) << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, M;
vi a, b;

int f(int x) {
    rep(i, M)b[i] = a[i] >= x;
    b[M] = 1 - b[M - 1];

    int dis = INT_MAX, val=-1, l = 0, cur = b[0];
    rep(r, M + 1) {
        if(b[r] != cur) {
            int len = r - l;
            if(len >= 2) {
                if(l <= N - 1 && N - 1 < r) {
                    val = cur;
                    break;
                }
                if(N - 1 < l && l <= 2 * (N - 1) && l - (N - 1) < dis) {
                    dis = l - (N - 1);
                    val = cur;
                }
                if(r <= N - 1 && r >= 1 && N - 1 - (r - 1) < dis) {
                    dis = N - 1 - (r - 1);
                    val = cur;
                }
            }
            l = r;
            cur = b[r];
        }
    }
    if(val != -1)return val;
    else return (b[N - 1] + N - 1) & 1;
}

int main(){
    cin >> N;
    M = 2 * N - 1;
    a = vi(M);
    rep(i, M)scanf("%d", &a[i]);
    b = vi(M+1);
    int l = 1, r = M + 1, m;
    while(r - l > 1) {
        m = (l + r) / 2;
        (f(m) ? l : r) = m;
    }
    cout << l << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1), a(n);
  rep(i, 0, n-1) cin >> b[i];
  a[0] = b[0];
  rep(i, 0, n-1) {
    if(b[i] < a[i]) a[i] = b[i];
    a[i+1] = b[i];
  }
  int sum = 0;
  rep(i, 0, n) sum += a[i];
  cout << sum << "\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0),cin.tie(0)

int median(vector<int> A) {
	int N = A.size();
	if (N&1) return A[N/2];
	else return A[N/2-1] + A[N/2];
}

int main () {
	inputSpeed();

	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	sort(all(A));
	sort(all(B));
	printf("%d\n", (median(B)-median(A))+1);
}


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

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

int main() {
  long long N;
  cin >> N;
  vector<long long> vec(N);
  long long ans=0,cnt=1,tmp;
  for(long long i = 0; i < N; i++){
    cin >> tmp;
    if(tmp==cnt) cnt++;
    else ans++;
  }
  if(ans==N) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 1792
N,M=map(int,input().split())
S,r,s=input(),[],N
for _ in range(2*N):
    if S[s]=='1':
        s += 1
    else:
        r.append(str(N-s))
        N,s=s,max(0,s-M)
    if N == 0:
        break
print(*[-1] if s else r[1:][::-1])

Measured memory_bytes: 52896
//☭
#include<cstdio>
#include<queue>
#include<map>
#include<set>
 
using namespace std;
 
const int N=1e5+10;
 
struct pai{
    int f, s;
};
 
bool operator <(pai a, pai b) {
    return (a.f==b.f)?(a.s<b.s):(a.f<b.f);
}
 
map< pai, int>m;
set<int> mu[N];
queue< pai >q;
 
int f[N], n;
 
inline void add(int x, int y) {mu[x].insert(y), mu[y].insert(x);}
 
pai marry(int x, int y) {
    if(x>y) {int t=y; y=x, x=t;}
    return (pai){x, y};
}
 
int f_f(int x){
    return f[x]?f[x]=f_f(f[x]):x;
}
 
int main(){
    scanf("%d", &n);
    for(int i=1; i<=(n<<1)-2; i++) {
        int x, y; scanf("%d%d", &x, &y), add(x, y);
        pai edg=marry(x, y); ++m[edg];
        if(m[edg]==2) q.push(edg);
        if(m[edg]>2) {puts("NO"); return 0;}
    }
    for(int w=1; w<n; w++) {
        if(q.empty()) {puts("NO"); return 0;}
        int x=0, y=0;
        while(x==y) x=f_f(q.front().f), y=f_f(q.front().s), q.pop();
        if(mu[x].size()>mu[y].size()) swap(x, y); f[x]=y;
        for(set<int>::iterator i=mu[x].begin(); i!=mu[x].end(); i++){
            int from=f_f(*i); mu[from].erase(mu[from].find(x)); if(from==y) continue;
            add(from,y); pai t=marry(from,y); m[t]++; if(m[t]==2) q.push(t);
        }
        mu[x].clear();
    }
    puts("YES");
}


Measured memory_bytes: 39168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

bool isPalind(const string& s) {
    string rev = s;
    reverse(rev.begin(), rev.end());

    if(rev == s) {
        return true;
    }

    return false;
}

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

    int len = s.length();

    if(!isPalind(s)) {
        cout << "No";
        return 0;
    }

    int n = (len - 1) / 2.0;

    string a;
    rep(i, n) {
        a += s[i];
    }

    if(!isPalind(a)) {
        cout << "No";
        return 0;
    }

    n = (len + 3) / 2.0;

    string b;
    for(int i = n - 1; i < len; i++) {
        b += s[i];
    }

    if(!isPalind(b)) {
        cout << "No";
        return 0;
    }

    cout << "Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<pair<pii, pii>> res;
    rep(i, H) rep(j, W) cin >> A[i][j];
    for(int i = 0; i < H; i++) {
        if(i % 2 == 0) {
            for(int j = 0; j < W; j++) {
                if(j == W - 1) {
                    if(i + 1 == H)
                        continue;
                    if(A[i][j] % 2) {
                        res.pb(MP(MP(i + 1, j + 1), MP(i + 2, j + 1)));
                        A[i][j]--;
                        A[i + 1][j]++;
                    }
                } else {
                    if(A[i][j] % 2) {
                        res.pb(MP(MP(i + 1, j + 1), MP(i + 1, j + 2)));

                        A[i][j]--;
                        A[i][j + 1]++;
                    }
                }
            }
        } else {
            for(int j = W - 1; j >= 0; j--) {
                if(j == 0) {
                    if(i + 1 == H)
                        continue;
                    if(A[i][j] % 2) {
                        res.pb(MP(MP(i + 1, j + 1), MP(i + 2, j + 1)));

                        A[i][j]--;
                        A[i + 1][j]++;
                    }
                } else {

                    if(A[i][j] % 2) {
                        res.pb(MP(MP(i + 1, j + 1), MP(i + 1, j)));
                        A[i][j]--;
                        A[i][j - 1]++;
                    }
                }
            }
        }
    }
    cout << res.size() << endl;
    rep(i, res.size()) {
        cout << res[i].first.first << ' ' << res[i].first.second << ' '
             << res[i].second.first << ' ' << res[i].second.second << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const ll mod = 1e9 + 7;
int main()
{
	SPEED
	int n, k, d;
	cin >> n >> k;

	int mark[n] = {0};
	
	while(k--)
	{
		cin >> d;
		for (int i = 0; i < d; ++i)
		{
			int temp;
			cin >> temp;
			mark[temp-1] = 1;
		}
	}

	int cunt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (mark[i]==0)
		{
			cunt++;
		}
	}
	cout << cunt;

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e16;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

/*
void dijkstra(){
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;pq.push(make_pair(0,0));
  rep(i,110000)d[i] = INF;d[0] = 0;
  while(!pq.empty()){
    pair<int,int> from = pq.top();pq.pop();
    int fromV = from.second, fromC = from.first;
    if(d[fromV] < fromC)continue;
    rep(i,g[fromV].size()){
      int to = g[fromV][i];
      if(d[to] <= fromC+costs[to])continue;
      d[to] = fromC+costs[to];
      pq.push(make_pair(d[to], to));
    }
    //cout << fromV << " " << fromC << endl;
  }
}*/

int n;pair<int,int> a[110], b[110];
signed main(){
  cin>>n;rep(i,n)cin>>a[i].second>>a[i].first;rep(i,n)cin>>b[i].first>>b[i].second;
  sort(a,a+n, greater<pair<int,int>>());sort(b,b+n);
  int ans = 0;
  rep(i,n){
    rep(j,n){
      if(a[j].first < b[i].second && a[j].second < b[i].first){
        ans++;a[j].first = a[j].second = INF;
        break;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=0
temp=999999999
for i in range(0,n):
  temph=abs(t-int(h[i])*0.006-a)
  temp=min(temph,temp)
  if temp==temph:
    ans=i
print(ans+1)

Measured memory_bytes: 3064
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)
#define MOD (ll)(1e9+7)
 
#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)
 
//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

ll n;
vector<ll> g[N];


vector<ll> path;
bool found;
void dfs(ll u, ll par) {
    if (u == n-1) found = true;

    rep(i,0,g[u].size()) {
        if (found) break;
        ll ch = g[u][i];
        if (ch == par) continue;
        dfs(ch,u);
    }

    if (found)
        path.push_back(u);
}


ll sz;
void dfs2(ll u, ll par) {
    sz++;
    rep(i,0,g[u].size()) {
        ll ch = g[u][i];
        if (ch == par) continue;
        dfs2(ch,u);
    }
}

void solve() {
    cin >> n;
    rep(i,0,n-1) {
        ll a, b; cin >> a >> b; a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0,0);

    ll ps = path.size();
    reverse(path.begin(),path.end());
    ll f = path[(ps-1)/2];
    ll s = path[1+(ps-1)/2];

    sz = 0;
    dfs2(f,s);
    ll fs = sz;
    sz = 0;
    dfs2(s,f);
    ll ss = sz;

    if (fs > ss) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 32632
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()] 

su = [0 for _ in range(n)] #鉄の棒の切れ目の座標
for i in range(n):
    su[i] = su[i-1] + a[i]
#print(su)

tmp = 2 * pow(10, 10) + 1
for i in su:
    #if abs(i - su[-1]/2) < tmp:
    #    tmp = abs(i - su[-1]/2)
    tmp = min(tmp, abs(i - su[-1]/2))
#print(su[-1]/2, tmp)

"""
#中心に一番近い鉄の棒の切れ目と中心との距離の差
l = 0
r = n-1
while (l - r) >= 1:
    c = (l + r) // 2
    #print(l, r, c)
    if su[c] < su[-1] / 2:
        l = c
    elif su[c] > su[-1] / 2:
        r = c
#print(su[l], su[r])
tmp = min(abs(su[l] - su[-1]/2), abs(su[r] - su[-1]/2))
print(tmp)
"""

ans = 2 * tmp
print(int(ans))


Measured memory_bytes: 25740
// AtCoder Beginner Contest 088 - Problem C: Takahashi's Information (https://abc088.contest.atcoder.jp/tasks/abc088_d)
#include <bits/stdc++.h>

using namespace std;
using ii = pair<int, int>;
using iii = pair<ii, int>;

const int MAX { 60 };
const vector<ii> dirs { ii(1, 0), ii(0, 1), ii(-1, 0), ii(0, -1) };

int dist[MAX][MAX];

int solve(const vector<string>& S, int H, int W)
{
    if (S[0][0] == '#' or S[H - 1][W - 1] == '#')
        return -1;

    memset(dist, -1, sizeof dist);
    int whites = 0;

    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            whites += (S[i][j] == '.' ? 1 : 0);

    queue<iii> q;
    q.push(iii(ii(0, 0), 1));
    dist[0][0] = 1;

    while (not q.empty())
    {
        auto p = q.front();
        q.pop();

        auto x = p.first.first, y = p.first.second;
        auto d = p.second;

        if (x == H - 1 and y == W - 1)
            break;

        for (auto dir : dirs)
        {
            int u = dir.first + x, v = dir.second + y;

            if (u < 0 or u >= H or v < 0 or v >= W or dist[u][v] > -1 or S[u][v] == '#')
                continue;

            dist[u][v] = d + 1;
            q.push(iii(ii(u, v), d + 1));
        }
    }

    return dist[H - 1][W - 1] == -1 ? -1 : whites - dist[H - 1][W - 1];
}

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> S(H);

    for (int i = 0; i < H; ++i)
        cin >> S[i];

    cout << solve(S, H, W) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int H,W;cin>>H>>W;
	vector<vector<char>> VVI;
	VVI = vector<vector<char>>(H,vector<char>(W,0));
	rep(aa,H){
		rep(bb,W)cin>>VVI[aa][bb];
	}
	int cnt = 0;
	for(int i = 0; i < H; i++){
		for(int t = 0; t < W; t++){
			cnt = 0;
			if(VVI[i][t] == '.'){
				cnt = 0;
				for(int x = -1; x <= 1; x++){
					for(int y = -1; y <= 1; y++){
						if(i + y >= 0 && t + x >= 0 && i + y < H && t + x < W){
							if(VVI[i + y][t + x] == '#'){
								cnt++;
							}
						}
					}
				}
				VVI[i][t] = to_string(cnt)[0];
			}
		}
	}
	//出力
	rep(j , H){
		rep(q , W){
			cout<<VVI[j][q];
		}
		cout<<endl;
	}

}


Measured memory_bytes: 764
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll a,h;
	double x;
	double ans;
	cin>>a>>h>>x;
	x/=a;
	if(x>a*h/2){
		x=a*h-x;
		ans=atan((double)a*a/2/x);
		ans=ans/M_PI*180;
		ans=90-ans;
	}else{
		ans=atan((double)2*x/h/h);
		//cout<<ans;
		ans=ans/M_PI*180;
		ans=90-ans;
	}
	printf("%.10lf",ans);
	return 0;
}


Measured memory_bytes: 512
from functools import reduce
import math

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    S = []
    S.append(int(input().rstrip()))
    S.append(int(input().rstrip()))
    S.append(int(input().rstrip()))
    S.append(int(input().rstrip()))
    S.append(int(input().rstrip()))
    min_s = min(S)
    if(N % min_s == 0):
        print(N//min_s -1 + 5)
    else:
        print(N//min_s + 5)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    counter = Counter(read_ints())
    T = sum(k*v for (k, v) in counter.items())
    Q = read_int()
    for _ in range(Q):
        b, c = read_ints()
        b_count = counter[b]
        counter[b] = 0
        counter[c] += b_count
        T = T-b*b_count+c*b_count
        print(T)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 90616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    ll x;
    scanf("%lld", &x);
    ll ans = 2*(x/11);
    if(x%11) {
        if(x%11 > 6) ans += 2;
        else ans++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
object Main extends App {
    val stdin = new java.util.Scanner(new java.io.BufferedInputStream(System.in))
    val stdout = new java.io.PrintWriter(new java.io.BufferedOutputStream(System.out))

    while (stdin.hasNext()) {
        val foo = stdin.nextInt()
        var bar : scala.math.BigInt = 0
        for (i <- 1 to foo) {
            val x : scala.math.BigInt = i
            val k : scala.math.BigInt = foo / x
            bar += (x + x * k) * k / 2
        }
        stdout.printf("%s\n", bar.toString)
    }

    stdin.close()
    stdout.close()
}

Measured memory_bytes: 62704
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll r, g, b, n;

int main(){
	cin >> r >> g >> b >> n;
    ll ans = 0;
    
    for(ll i = 0; i <= n/r; i++){
    	ll buf = n-r*i;
    	if(buf == 0){ans++;}
    	else{
			for(ll j = 0; j <= buf/g; j++){
				    ll bufbuf = buf-g*j;
					if(bufbuf%b == 0){ans++;}
			}
    	}
    }
    
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
  double n, x[110], y[110], absmax;
  cin>>n;
  absmax = 0;
  for(int i=0; i<n; i++){
    cin>>x[i];
  }
  for(int i=0; i<n; i++){
    cin>>y[i];
  }
  for(int i=1; i<=3; i++){
    double sum = 0, d;
    for(int j=0; j<n; j++){
      sum += pow(abs(x[j]-y[j]), i);
      if (absmax<=abs(x[j]-y[j]) && i==1) absmax = abs(x[j]-y[j]);
    }
    d = pow(sum, 1.0/i);
    printf("%.5f\n", d);
  }
  printf("%5f\n", absmax);
  return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll w, h, n;
  cin >> w >> h >> n;
  vector<vll> coo(h, vll(w, 0));
  rep(i, 0, n){
    ll x, y, a;
    cin >> x >> y >> a;
    if(a == 1)rep(i, 0, x)rep(j, 0, h) coo.at(j).at(i) = 1;
    if(a == 2)rep(i, x, w)rep(j, 0, h) coo.at(j).at(i) = 1;
    if(a == 3)rep(i, 0, y)rep(j, 0, w) coo.at(i).at(j) = 1;
    if(a == 4)rep(i, y, h)rep(j, 0, w) coo.at(i).at(j) = 1;
  }
  ll ans = 0;
  rep(i, 0, w)rep(j, 0, h) if(coo.at(j).at(i) == 0) ans++;
  cout << ans << endl;
}



Measured memory_bytes: 384
from sys import stdin


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def main():
    X, Y = [int(x) for x in stdin.readline().rstrip().split()]
    if (X + Y) % 3:
        print(0)
    else:
        m = (2 * X - Y) // 3
        n = X - 2 * m
        if n < 0 or m < 0:
            print(0)
        else:
            ans = cmb(n + m, min(n, m))
            print(ans % (10 ** 9 + 7))


if __name__ == "__main__":
    main()


Measured memory_bytes: 45812
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		
		for(int i = a; i <= b; i++){
			int x = i % 10;
			int y = i / 10000 % 10;
			int p = i / 10 % 10;
			int q = i / 1000 % 10;
			if (x == y && p == q){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <ostream>
#include <istream>
#include <cmath>
#include <string>
#include <vector>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <vector>
#include <set>
#define pb push_back
#define ppb pop_back
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i <= int(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"
#define pi 3.1415926535897932
#define NMAX 100005
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod=1e9+7;
const int INF=INT_MAX/2;
vector<int> bfs(int N,vector<vector<int>>& G,int s) {
	vector<int> d(N,INF);
	d[s]=0;
	queue<int> q;
	q.push(s);
	while(q.size()) {
		int u=q.front();
		q.pop();
		for(int v:G[u]) {
			if(d[v]>d[u]+1) {
				d[v]=d[u]+1;
				q.push(v);
			}
		}
	}
	return d;
}
int main() {
	int n;
	cin>>n;
	vector<vector<int>>G(n);
	forn(i,n-1) {
		int u,v;
		cin>>u>>v;
		u--;
		v--;
		G[u].push_back(v),G[v].push_back(u);
	}
	vector<int>d1=bfs(n,G,0);
	vector<int>d2=bfs(n,G,n-1);
	int n1=0,n2=0;
	forn(u,n)if(d1[u]<=d2[u])n1++;
	else n2++;
	cout<<(n1>n2?"Fennec":"Snuke")<<endl;
	return 0;
}



Measured memory_bytes: 6528
import java.util.*;

public class Main {
    static final TreeMap<Long, Integer> factorization = new TreeMap<>();
    static final List<Long> factors = new ArrayList<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long ln = n;
        long k = in.nextInt();
        long[] array = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            array[i] = in.nextLong();
            sum += array[i];
        }
        long sumTemp = sum;
        for (long p = 2; p < 22361; p++) {
            int power;
            for (power = 0; sumTemp % p == 0; sumTemp /= p, power++);
            if (power > 0) {
                factorization.put(p, power);
            }
        }
        if (sumTemp != 1L) {
            factorization.put(sumTemp, 1);
        }
        generateFactors(1);
        factors.sort(Comparator.reverseOrder());
        for (long f : factors) {
            Long[] residues = new Long[n];
            long residueSum = 0;
            for (int i = 0; i < n; i++) {
                residues[i] = array[i] % f;
                residueSum += residues[i];
            }
            Arrays.sort(residues);
            long req = 0;
            long li = 0;
            for (int i = 0; li < ln - (residueSum / f); i++, li++) {
                req += residues[i];
            }
            if (k >= req) {
                System.out.println(f);
                return;
            }
        }
    }

    static void generateFactors(long curr) {
        if (factorization.isEmpty()) {
            factors.add(curr);
        } else {
            long p = factorization.firstKey();
            int power = factorization.remove(p);
            for (int e = 0; e <= power; e++, curr *= p) {
                generateFactors(curr);
            }
            factorization.put(p, power);
        }
    }
}


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

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;

    std::vector<int> vec(3);
    vec.at(0) = a + b;
    vec.at(1) = b + c;
    vec.at(2) = c + a;

    std::cout << *std::min_element(vec.begin(), vec.end()) << std::endl;

    return 0;

}

Measured memory_bytes: 888
//Keep working hard :)
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e5+5;
int w[N];
vector<int> v[N];
map<pair<int,int>,int> mp;
bool vis[N],col[N];
int n;

void dfs(int node, int weight,int parent)
{
        vis[node] = true;
        if(parent == -1)col[node] = 1;
        else col[node] = (weight&1) ? col[parent]^1 : col[parent];
        for(auto i : v[node])
        {
                if(!vis[i])
                dfs(i,mp[{i,node}],node);
        }
}
void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
      //  fileIO();
        cin >> n;
        int x = n-1;
        for(int i = 1; i <= x;i++)
        {
                int a,b,c;
                cin >> a >> b >> c;
                pair<int,int> temp1 = {a,b},temp2 = {b,a};
                mp[temp1] = c;
                mp[temp2] = c;
                v[b].push_back(a);
                v[a].push_back(b);
        }
        dfs(1,0,-1);
        for(int i = 1; i <= n; i++)cout << col[i]<<'\n';
	return 0;
}


Measured memory_bytes: 21376
n, T = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
dt = [t[i+1] - t[i] for i in range(n-1)]
ans = 0
for i in dt:
    if i <= T:
        ans += i
    else:
        ans += T

print(ans + T)


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

int main() {
	int k, n;
	cin>>k>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	vector<int> diff;
    for(int i=1;i<n;i++)
        diff.push_back(arr[i]-arr[i-1]);
    diff.push_back(arr[0]+k-arr[n-1]);
    sort(diff.begin(),diff.end());
    long long sum=0;
    for(int i=0;i<n-1;i++)
        sum+=diff[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Hello
{
    static void Main()
    {
        var n = Console.ReadLine().Split();
        
        int a = int.Parse(string.Join("",n));
        string str = "";
        if (a % 4 == 0)
        {
            str = "YES";
        }
        else
        {
            str = "NO";
        }

        Console.WriteLine(str);
    }
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  string abc = "ABC";
  int abc_i = 0;
  string s;
  cin >> n;
  cin >> s;
  int ans = 0;
  REP(i,n) {
    if(s[i] == abc[abc_i]) {
      if(abc_i == 2) {
        ++ans;
        abc_i = 0;
      } else {
        ++abc_i;
      }
    } else {
      if(s[i] == 'A') {
        abc_i = 1;
      } else {
        abc_i = 0;
      }
    }
  }
  cout << ans;

  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 15 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    ivv(n);

    vi v(n);

    iv(v);

    bint ans = v[0];

    for(int i=1; i<n; ++i){
        ans+=max(v[i]-v[i-1] , 0);
    }
    cout<<ans<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	//int l=strlen(s);
	//int l=strlen(s);
	if(s[s.length()-1]=='s'){
		cout<<s+"es"<<endl;
	}
	else{
		cout<<s+"s"<<endl;
	}
}

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

int main(){
  int ans = 0;
  int a;
  cin >> a;
  vector<int> gp(a);
  rep(i, a){
    cin >> gp.at(i);
    ans += gp.at(i);
  }
  sort(all(gp));
  ans -= gp.at(a - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int h[n][n],f[n][n],mx[n],mn[n],amx;
		rep(i,n)rep(j,n)cin>>h[i][j];
		amx=0;
		rep(i,n){
			mn[i]=11111;
			rep(j,n)if(mn[i]>h[i][j])mn[i]=h[i][j];
		}
		rep(j,n){
			mx[j]=0;
			rep(i,n)if(mx[j]<h[i][j])mx[j]=h[i][j];
		}
		rep(i,n)rep(j,n)if(mx[j]==h[i][j]&&h[i][j]==mn[i] && amx<h[i][j])amx=h[i][j];
		cout<<amx<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    if(a[i]>=k) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		long n = Long.parseLong(reader.readLine());
		StringBuffer strbf = new StringBuffer();
		while(n > 0) {
			n--;
			strbf.append((char)('a' + n % 26));
			n /= 26;
		}
		out.print(strbf.reverse().toString());
		out.flush();
		out.close();
    }
}


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

S = input()
count = 0
c_for = 0
for i in range(N):
    if count < A+B:
        if S[i] == 'a':
            print('Yes')
            count += 1
        elif S[i] == 'b':
            if c_for < B:
                print('Yes')
                count += 1
                c_for += 1
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')



Measured memory_bytes: 4016