akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<bool> ac(n,false);
    vint cnt(n,0);
    int ansac = 0;
    int ansp = 0;
    REP(i,m){
        int p;
        cin >> p;
        p--;
        string s;
        cin >> s;
        if(s=="AC"){
            if(ac[p]==false){
                ansac++;
                ansp += cnt[p];
                ac[p]=true;
            }
        }else{
            if(ac[p]==false){
                cnt[p]++;
            }
        }
    }
    cout << ansac << " " << ansp << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=2e5+10;
long long sum[maxn];
int n;

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            long long a;
            scanf("%lld",&a);
            if(i==1)
            {
                sum[1]=a;
                continue;
            }
            sum[i]=sum[i-1]+a;
        }

        long long minmum=abs(sum[n]-sum[1]-sum[1]);
        for(int i=1;i<n;i++)
        {
            minmum=min(minmum,abs(sum[n]-sum[i]-sum[i]));
        }
        printf("%lld",minmum);
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define fore(i,a) for(auto &i:a)
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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


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

int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   int n,ans = 1000000;
   cin >> n;
   int a[n];
   rep(i,0,n) cin >> a[i];

   rep(i,-100,101){
      int sum = 0;
      rep(j,0,n){
         sum += (a[j] - i) * (a[j] - i);
      }
      ans = min(ans, sum);
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
def palindrome_philia(S: str)->int:
    ans = 0
    for i in range(len(S)//2):
        if S[i] != S[-(i+1)]:
            ans += 1
    return ans


if __name__ == "__main__":
    S = input()
    ans = palindrome_philia(S)
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)

int main() {
    string a, str, c;
    cin >> a >> str >> c;
    cout << "A" << str.at(0) << "C" << endl;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())

h = (30 * H) + (M / 2)
m = 6 * M

if m == 0:
    kaku = h
    
elif h <= m:
    kaku = m - h
else:
    kaku = h - m

if kaku >= 180:
    360 - kaku
    
p = math.cos(math.radians(kaku))
c = A ** 2 + B ** 2 - (2 * A * B * p)
print(math.sqrt(c))

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0, cnt = 1;
    rep(i, N-1) {
      if (a[i] == a[i+1]) {
        cnt++;
        if (cnt % 2 == 0) ans++;
      } else {
        cnt = 1;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  declare(strict_types=1);

  $toBinary = function ($xs, $length)
  {
      $x = (int)0;
      for ($i = 0; $i < $length; $i++)
      {
          $x |= (int)(array_pop($xs) === '#') << $i;
      }
      return $x;
  };

  fscanf(STDIN, "%i %i", $n, $m);
  for ($i = 0; $i < $n; $i++)
  {
      $row = str_split(trim(fgets(STDIN)), 1);
      $a[$i] = $toBinary($row, $n);
      $sum_a[$i] = array_count_values($row)["#"];

  }
  for ($i = 0; $i < $m; $i++)
  {
      $row = str_split(trim(fgets(STDIN)), 1);
      $b[$i] = $toBinary($row, $m);
      $sum_b[$i] = array_count_values($row)["#"];
  }

  $solve = function () use ($n, $m, $a, $b, $sum_a, $sum_b)
  {
      for ($i = $n - ($n - $m) - 1; $i >= 0; $i--)
      {
          for ($j = 0; $j < $m && $sum_a[$i + $j] >= $sum_b[$j]; $j++)
              ;
          if ($j !== $m)
          {
              continue;
          }

          $k = $n - $m;
          while (TRUE)
          {
              while ($k >= 0 && (($a[$i] >> $k) & $b[0]) !== $b[0])
              {
                  $k--;
              }
              if ($k < 0)
              {
                  break;
              }

              for ($j = 1; $j < $m && (($a[$i + $j] >> $k) & $b[$j]) === $b[$j]; $j++)
                  ;
              if ($j === $m)
              {
                  return "Yes";
              }

              $k--;
          }
      }

      return "No";
  };
  
  echo $solve().PHP_EOL;


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    int out = ceil((float)(n - 1) / (k - 1));
    cout << out << endl;
    return 0;    
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, x;
	cin >> N >> x;
	int a[N];
	REP(i, 0, N) cin >> a[i];
	sort(a, a+N);
	int c = 0;
	bool out = false;
	REP(i, 0, N){
		if( x >= a[i]){ 
			x-= a[i];
			++c;
		}
		else{
			out = true;
			break;
		}
	}
	if(x == 0)	cout << c;
	else cout << c-(c>0 && !out?1:0);
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  cout << (n+999)/1000*1000-n << endl;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  REP(i,3){
      cin >> S;
      cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
#define ll long long int
#define ull unsigned long long int
#define inf LONG_MAX;
using namespace std;
ll n,w,weight[100005],price[100005];
ll dp[101][100001];
int main()
{
    fast_io
    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>weight[i]>>price[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(weight[i]<=j)
                dp[i][j]=max(price[i]+dp[i-1][j-weight[i]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 81672
import java.util.*;

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

        String[] str_list = new String[n];

        String temp = sc.nextLine();

        for (int i = 0; i < n; i++) {
            str_list[i] = sc.nextLine();
            if (i != 0) {
                for (int j = 0; j < i - 1; j++) {

                    if (str_list[i].equals(str_list[j])) {
                        System.out.println("No");
                        return;
                    }

                }

                if(str_list[i].charAt(0) != str_list[i-1].charAt(str_list[i-1].length()-1)){
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");

    }
}

Measured memory_bytes: 21332
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:07:49 2020

@author: NEC-PCuser
"""

A, B = map(str, input().split())
A = int(A)
B = float(B) * 1000 // 1

C = A * int(B) // 1000
print(C)

Measured memory_bytes: 9236
#include <stdio.h>
#include <math.h>

int main(void)
{
	for(; ; ) {
		int x, h;
		double S, c;
		
		scanf("%d\n%d", &x, &h);
		if(x==0 && h==0) break;
		
		c=pow((double)1/4*x*x+h*h, 1.0/2);
		S=x*x+2*c*x;
		
		printf("%f\n", S);
	}
	
	return 0;
}


Measured memory_bytes: 684
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int L = s.size();

    stack<char> st;

    int S = 0, ans = 0;
    for(int i = 0; i < L; i++){
        if(S == 0){
            st.push(s[i]);
            S++;
            continue;
        }

        char c = st.top();
        if((c == '0' && s[i] == '1') || (c == '1' && s[i] == '0'))
            st.pop(), ans += 2, S--;
        else
            st.push(s[i]), S++;
    }

    cout << ans << '\n';
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int k,n;
    cin >> k >> n;

    vector<int> a(n);
    vector<int> d(n,0);

    cin >> a[0];
    REAP(i,1,n){
        cin >> a[i];
        d[i-1] = a[i] - a[i-1];
        if(i==n-1){
            d[i]=k-a[n-1]+a[0];
        }
    }

    sort(All(d));
    cout << k - d[n-1] << endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

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

    int cnt = 0;
    for (int i = 1; i < n; i++){
        if (s[i] == 'E')
            cnt++;
    }
    int ans = cnt;
    for (int i = 1; i < n; i++){
        if (s[i-1] == 'W') cnt++;
        if (s[i] == 'E') cnt--;
        if (ans > cnt) ans = cnt;
    }

    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;

vector< vector<int> > g;

void dfs(int cur, int par, vector<int>& d) {
    for (int nex : g[cur]) {
        if (nex == par) continue;
        d[nex] = d[cur] + 1;
        dfs(nex, cur, d);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    g.resize(n);

    //vector<int> cnt(n, 0);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        //cnt[a]++;
        //cnt[b]++;
    }

    vector<ll> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    vector<int> d1(n, 0);
    dfs(0, -1, d1);

    int node = 0;
    for (int i = 0; i < n; i++) {
        if (d1[node] < d1[i]) node = i;
    }

    vector<int> d2(n, 0);
    dfs(node, -1, d2);

    int node2 = 0;
    for (int i = 0; i < n; i++) {
        if (d2[node2] < d2[i]) node2 = i;
    }
    int max_val = d2[node2];
    
    vector<int> d3(n, 0);
    dfs(node2, -1, d3);

    vector<int> d(n);
    vector<int> ord(n);
    for (int i = 0; i < n; i++) {
        d[i] = min({d2[i], d3[i], max_val - d2[i], max_val - d3[i]});
        ord[i] = i;
    }
    sort(ord.begin(), ord.end(), [&](const int i1, const int i2){return d[i1] < d[i2];});

    vector<int> used(n, false);
    ll ans = 0;
    vector<int> memo(n, 0);
    for (int ii = 0; ii < n; ii++) {
        int i = ord[ii];
        memo[i] = c[ii];
        for (int j : g[i]) {
            if (used[j]) continue;
            ans += c[ii];
        }
        used[i] = true;
    }

    cout << ans << endl;
    for (int i = 0; i < n; i++) {
        cout << memo[i] << " \n"[i + 1 == n];
    }
    return 0;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    A = [int(i) for i in input().split()]

    up = False
    money = 1000
    has = 0  # 株数
    if A[0] < A[1]:
        v = money//A[0]
        has += v
        money -= v*A[0]
        up = True
    pre = A[0]
    for a in A[1:]:
        if not up:
            if pre >= a:
                pass
            else:
                # 局所最安値
                v = money//pre
                has += v
                money -= v*pre
                up = True
        else:
            if pre <= a:
                pass
            else:
                # 局所最高値
                money += has*pre
                has = 0
                up = False
        pre = a
    money += has*A[-1]
    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61968
H, W = map(int, input().split())
N = int(input())
alist = [[a, i+1] for i, a in enumerate(map(int, input().split()))]
alist.sort()
drow_Order = []
for x in alist:
  for a in range(x[0]):
    drow_Order += [x[1]]
ans = ''
aaa = 0
for row in range(H):
  if row%2==0:
    ans = map(str, drow_Order[row*W:(row+1)*W])
  else:
    ans = map(str, reversed(drow_Order[row*W:(row+1)*W]))
  ans = ','.join(ans)
  print(ans.replace(',', ' '))

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

int main() {
	int n;
	long long p;
	long long a;
	long long m;

	p=0;
	m=0;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (m<a) m=a;
		p+=m-a;
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
using namespace std;

typedef long long ll;
unsigned GetDigit(ll num){
  return log10(num)+1;
}

int main(){
  ll n;
  ll dig[16];
  cin>>n;
  
  ll digit=GetDigit(n);
  
  ll nn=n;
  
  bool all=true;
  for(int i=1; i<=digit; i++){
    dig[i]=nn/pow(10, digit-i);
    nn=nn%(ll)pow(10,digit-i);
    if(i!=1){
      if(dig[i]!=9) all=false;
    }
  }
  
  if(!all)cout<<dig[1]-1+9*(digit-1)<<endl;
  else cout<<dig[1]+9*(digit-1)<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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



int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(a * n, b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	map<string, int> m;
	rep(i,n){
		string s;
		cin >> s;
		m[s] = 1;
	}
	cout << m.size() << endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const int mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int n,k;

int main(){
    scanf("%d%d",&n,&k);
    vi a(n);
    rep(i,n) scanf("%d",&a[i]);
    vvi ldp(n,vi(k,0));
    vvi rdp(n,vi(k,0));
    rep(i,n){
        ldp[i][0]=1;rdp[i][0]=1;
        if (a[i]<k) ldp[i][a[i]]=1;
        if (a[n-1-i]<k) rdp[i][a[n-1-i]]=1;
    }
    rep2(i,1,n)rep(j,k){
            if (j-a[i]>=0) ldp[i][j]=ldp[i-1][j-a[i]]||ldp[i-1][j];
            else ldp[i][j]=ldp[i-1][j];
            if (j-a[n-1-i]>=0) rdp[i][j]=rdp[i-1][j-a[n-1-i]]||rdp[i-1][j];
            else rdp[i][j]=rdp[i-1][j];
    }
    rep(i,n)rep2(j,1,k){
        rdp[i][j]+=rdp[i][j-1];
    }
    int cnt=0;
    int lnum=0;
    rep(i,n){
        if (k-a[i]<=0){
            cnt+=1;
            continue;
        }
        rep(j,k){
            if (i==0) lnum=0;
            else if (i==n-1){
                if (ldp[i-1][j] && a[i]+j>=k){
                    cnt+=1;
                    break;
                }
                continue;
            }
            else{
                if (ldp[i-1][j]) lnum=j;
                else continue;
            }
            if (k-a[i]-lnum<=0){
                cnt+=1;
                break;
            }
            if (rdp[n-2-i][k-1-lnum]-rdp[n-2-i][k-a[i]-lnum-1]){
                cnt+=1;
                break;
            }
        }
    }
    cout << n-cnt << endl;
    return 0;
}


Measured memory_bytes: 195968
n, c = map(int, input().split())
x1 = [0]
x2 = []
v1 = [0]
v2 = [0]
for _ in range(n):
    x, v = map(int, input().split())
    x1.append(x)
    x2.append(c-x)
    v1.append(v)
    v2.append(v)
x2.append(0)
x2.reverse()
v2.append(0)
v2.reverse()
v2 = v2[:-1]
for i in range(n):
    v1[i+1] += v1[i] 
    v2[i+1] += v2[i] 

max11, max12 = [0], [0]
for i in range(1, n+1):
    max11.append(max(max11[-1], v1[i]-x1[i]))
    max12.append(max(max12[-1], v1[i]-2*x1[i]))
max21, max22 = [0], [0]
for i in range(1, n+1):
    max21.append(max(max21[-1], v2[i]-x2[i]))
    max22.append(max(max22[-1], v2[i]-2*x2[i]))

ans = max(max(max11), max(max21))
for i in range(n+1):
    ans = max(ans, max11[i]+max22[n-i], max21[i]+max12[n-i])

print(ans)


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

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

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    CIN(n);
    vi A(n);VCIN(A);
    for(int i=n-1;i>=0;i-=2)printf("%d ",A[i]);
    for(int i=n%2;i<n;i+=2)printf("%d ",A[i]);
    END;

    return 0;
}

Measured memory_bytes: 2944
fun main(args: Array<String>) {
    fun sequence(n: Long): Sequence<Pair<Long, Long>> {
        var i = 1L
        fun f() = generateSequence {
            while (i * i <= n) {
                if (n % i == 0L) {
                    return@generateSequence i to n / i++
                }
                i++
            }
            null
        }
        return f()
    }

    val n = readLine()!!.toLong()
    println(sequence(n).map { it.first + it.second - 2 }.min())
}


Measured memory_bytes: 33816
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[] = new int [M];
		for(int i=0;i<M;i++) {
			A[i] = sc.nextInt();
		}
		int finish = 0;
		for(int j=0;j<M;j++) {
			finish = finish+A[j];
		}
		if(finish>N) {
			System.out.println(-1);
		}else {
			System.out.println(N-finish);
		}
		
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    vector<int> ans;
    bool rev = false;
    rep(i, n){
        rep(j, a[i]){
            ans.emplace_back(i+1);
            if(ans.size() == w){
                if(rev){
                    for(int k = w-1; k >= 0; k--){
                        cout << ans[k] << " ";
                    }
                    rev = false;
                }else{
                    rep(k, w){
                        cout << ans[k] << " ";
                    }
                    rev = true;
                }
                cout << el;
                ans = {};
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            long count = 0;
            string ans = Console.ReadLine();
            string[] str = Console.ReadLine().Split(' ');
            while (str[0] != "END_OF_TEXT")
            {
                for (int n = 0; n < str.Length; n++)
                {
                    if (string.Compare(ans, str[n], true) == 0)
                    {
                        count++;
                    }
                }
                str = Console.ReadLine().Split(' ');
            }
            Console.WriteLine(count);
        }
    }
}

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

int main()
{
   int a , b;
   cin >> a >> b;
   int ans = a+ b;
   if(ans >= 10){
       cout << "error" <<endl;
   }else{
       cout << ans << endl;
   }
}


Measured memory_bytes: 256
tdlist = lambda i, j, value=0: [[value] * j for _ in range(i)]

h, w = map(int, input().split())
D = 160*80
D2 = D*2+1

diff = [list(map(int, input().split())) for _ in range(h)]
for i in range(h):
    for j, b in enumerate(list(map(int, input().split()))):
        diff[i][j] = abs(diff[i][j] - b)

dp = tdlist(h, w)
dp[0][0] |= 1 << D+diff[0][0]
dp[0][0] |= 1 << D-diff[0][0]

for i in range(h):
    for j in range(w):
        if j:
            dp[i][j] |= dp[i][j-1] << diff[i][j]
            dp[i][j] |= dp[i][j-1] >> diff[i][j]
        if i:
            dp[i][j] |= dp[i-1][j] << diff[i][j]
            dp[i][j] |= dp[i-1][j] >> diff[i][j]

ans = float("inf")
for i in range(D2):
    if dp[h-1][w-1] >> i & 1:
        ans = min(ans, abs(i-D))
print(ans)


Measured memory_bytes: 20212
#include <iostream>
#include <stdlib.h>

using namespace std;

int search(int **a, int s, int t, int c, int n)
{
	if((s+c) >= n || (t+c) >= n){
		return 1;
	}
	
	for(int i = 0; i <= c; i++){
		if(a[s+c][t+i] == 1 || a[s+i][t+c] == 1){
			return 1;
		}
	}
	
	return (1 + search(a, s, t, (c+1), n));
}

int main(int argc, char **argv)
{
	int n, tmp, c, **array;
	char w;
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		
		array = (int **)calloc(n, sizeof(int));
		for(int i = 0; i < n; i++){
			array[i] = (int *)calloc(n, sizeof(int));
		}
	
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> w;
				array[i][j] = (w == '.')? 0 : 1;
			}
		}
	
		c = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(array[i][j] == 0){
					tmp = search(array, i, j, 1, n);
					
					if(tmp > c){
						c = tmp;
					}
				}
			}
		}
		cout << c << endl;
		
		for(int i = 0; i < n; i++){
			free(array[i]);
		}
		free(array);
	}
	
	return 0;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 1e4+5 ; 
const ll mod = 1e9+7 ; 
ll dp[N][105][2]; 
int n , D; 
string s; 
ll solve(int i, int rem , int b){
	if(i==n){
		if( !rem )
		return 1;
		return 0 ; 
	} 
	ll& r = dp[i][rem][b] ;
	if( r != - 1 )return r ;
	r = 0 ; 
	int digit = s[i]-'0' ; 
	if( b == 1 ){
		r += solve(i+1,(rem+digit)%D,1) ; 
		r%=mod ; 
		for(int x = 0 ; x < digit ; x++ ){
			r += solve(i+1,(rem+x)%D,0) ;
			r%=mod ;  
		}
	}else {
		for(int x = 0 ; x <= 9 ; x++ ){
			r += solve(i+1,(rem+x)%D,0) ; 
			r %= mod ; 
		}
	}
	return r ; 
}
int main(){ 
	cin >> s >> D ; 
	n = s.length() ; 
	dp[0][0][1]=1; 
	for(int i = 0 ; i < n ; i++ ){
			for(int r = 0 ; r < D ; r++ ){
				int digit = s[i]-'0' ; 
				dp[i+1][(r+digit)%D][1] += dp[i][r][1] ; 
				dp[i+1][(r+digit)%D][1] %= mod ; 
				for(int x =0 ; x < digit ; x++ )dp[i+1][(x+r)%D][0] += dp[i][r][1] , dp[i+1][(x+r)%D][0]%=mod; 
				for(int x = 0 ; x <= 9 ; x++ )dp[i+1][(x+r)%D][0]  += dp[i][r][0],dp[i+1][(x+r)%D][0]%=mod; 
		}
	}cout << (dp[n][0][0]-1+dp[n][0][1]+mod)%mod << endl; 
}

Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>
#include <cfloat>
#include <numeric>
 
//#include <bits/stdc++.h>

using namespace std;

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


int main(int argc, const char * argv[]) {

    
    long long int n;
    cin >> n;

    long long int money = 100;
    int cnt =0;
    

    
    while(money < n){
        
        money = money*1.01;
        cnt++;
    }

    
    cout << cnt << endl;
    
    return 0;
}


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


int main(){
    long long K,A,B;
    cin>>K>>A>>B;
    
    if(A>=B-1){
        cout<<K+1<<endl;
    }else{
        long long ans=0;
        long long k=0;
        k=A-1;
        k=K-k;
        
        long long d=B-A;
        
        if(k%2==0){
            
        }
        else ans++;
        ans+=d*(k/2);
        ans+=A;
        
        cout<<ans<<endl;
    }
    
    return 0;
    
    


}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
const int N = 2e5+10;
int a, b, c, n, cz[N]; char inp[N][5];
int main() {
	scanf("%d%d%d%d", &n, &a, &b, &c);
	for (int i=1; i<=n; i++) scanf("%s", inp[i]);
	for (int i=1; i<=n; i++) {
		if (inp[i][0] == 'A' && inp[i][1] == 'B') {
			if (!a && !b) {printf("No\n"); return 0;}
			if (a == 1 && b == 1 && i < n) {
				if (inp[i+1][0] == 'A') ++a, --b, cz[i] = 0;
					else --a, ++b, cz[i] = 1;
				continue;
			}
			if (a < b) ++a, --b, cz[i] = 0; else --a, ++b, cz[i] = 1;
		}
		if (inp[i][0] == 'A' && inp[i][1] == 'C') {
			if (!a && !c) {printf("No\n"); return 0;}
			if (a == 1 && c == 1 && i < n) {
				if (inp[i+1][0] == 'A') ++a, --c, cz[i] = 0;
					else --a, ++c, cz[i] = 2;
				continue;
			}
			if (a < c) ++a, --c, cz[i] = 0; else --a, ++c, cz[i] = 2;
		}
		if (inp[i][0] == 'B' && inp[i][1] == 'C') {
			if (!b && !c) {printf("No\n"); return 0;}
			if (b == 1 && c == 1 && i < n) {
				if (inp[i+1][1] == 'B') ++b, --c, cz[i] = 1;
					else --b, ++c, cz[i] = 2;
				continue;
			}
			if (b < c) ++b, --c, cz[i] = 1; else --b, ++c, cz[i] = 2;
		}
	}
	printf("Yes\n");
	for (int i=1; i<=n; i++) {
		if (!cz[i]) printf("A\n");
		if (cz[i] == 1) printf("B\n");
		if (cz[i] == 2) printf("C\n");
	}
	return 0;
}

Measured memory_bytes: 2548
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);

    int a[N];
    int b[100005] = {0};
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a[i]);

        if (a[i] != 0) b[a[i] - 1] += 1;
        b[a[i]] += 1;
        b[a[i] + 1] += 1;
    }

    int ans = *max_element(b, b + 100001);

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

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(void){
int i1,i2,i3;
int flag=0;
  scanf("%d",&i1);
  scanf("%d",&i2);
  scanf("%d",&i3);
  if(i1==i2) flag+=1;
  if(i1==i3) flag+=1;
  if(i2==i3) flag+=1;
  if(flag==1) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Mod = 1e9+7;
LL f[20][1<<16], g[1<<16];
LL n, m, N;
LL a[20];
LL jc[(1<<16)+1], inv[(1<<16)+1];
LL C(LL x, LL y) { return jc[x]*inv[y]%Mod*inv[x-y]%Mod; }
void up(LL &x, LL y) { x = (x + y) % Mod; }
int main() {
	LL i, j, k;
	scanf("%lld%lld", &n, &m);
	N = 1<<n;
	for(i = 1; i <= m; i++) scanf("%d", &a[i]);
	sort(a+1, a+m+1);
	jc[0] = 1;
	for(i = 1; i <= N; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] = 1;
	for(i = 2; i <= N; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(i = 2; i <= N; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	f[m+1][0] = 1;
	for(i = m; i >= 1; i--){
		for(j = 0; j < N; j++) f[i][j] = f[i+1][j];
		for(j = 0; j < N; j++){
			for(k = 0; k < n; k++){
				if(!(j&(1<<k)) && (j|(1<<k)) <= N-a[i]+1) up(f[i][j|(1<<k)], f[i+1][j]*C(N-a[i]-j, (1<<k)-1)%Mod*jc[1<<k]);
			}
		}
	}
	LL ans = 0;
	for(i = 0; i < N; i++){
		g[i] = g[i>>1]+(i&1);
		if(g[i]&1) up(ans, (Mod-1)*f[1][i]%Mod*jc[N-i-1]);
		else up(ans, f[1][i]*jc[N-i-1]);
	}
	printf("%lld\n", ans*N%Mod);
	return 0;	
}

Measured memory_bytes: 9856
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= 1000; ++i) {
        if ((a * i - c) % b == 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int n;
		cin >> n;
		int A[n+5];
		int B[n+5];
		rep(i,1,n)
		{
			cin >> A[i];
			cin >> B[i];
		}
		sort(A+1,A+n+1);
		sort(B+1,B+n+1);
		int x,y;
		if(n%2==1)
		{
			x = A[n/2+1];
			y = B[n/2+1];
		}
		else
		{
			x = A[n/2] + A[n/2+1];
			y = B[n/2] + B[n/2+1];
		}
		cout << y-x + 1;
		
	}
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		String input = br.readLine();
		String segment = br.readLine();
		
		StringBuffer[] sbArray = new StringBuffer[input.length()];
		
		for(int i = 0; i < input.length() ; i++){
			sbArray[i] = new StringBuffer();
			for(int j = 0 ; j < segment.length() ; j++){
				sbArray[i].append(input.charAt((i+j)%input.length()));
			}
			
			//System.out.println(sbArray[i].toString());
			if(sbArray[i].toString().equals(segment)){
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24472
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,count=0;
	long long h,w,a,b;
	cin>>n>>h>>w;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(h<=a && w<=b) count++;
	}
	cout<<count<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
const int maxn=100000+10; 
map<int,int>m;
int main()
{
	int n,a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		m[a]++;
	}
	int ans=0;
	for(map<int,int>::iterator it = m.begin();it!=m.end();it++)
	{
		int temp=(*it).second;
		if(temp%2==1)
			ans++;
	}
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 4864
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
vi a(n,10);
int m;
cin>>m;
while(m--)
{
	int pos,dig;
	cin>>pos>>dig;
	if(a[pos-1]!=10)
	{
		if(dig!=a[pos-1])
		{
			cout<<-1;
			return ;
		}
	}
	else
	{
a[pos-1]=dig;
	}
}
if(a[0]==0)
{
	if(n>=2){
	cout<<-1;
	return ;}
	else
		{
			cout<<0;
			return;
		}
}
if(a[0]==10)
{
	if(n==1)
	{
		cout<<0;
		return ;
	}
	else
		a[0]=1;
}
for(int i=1;i<n;i++)
{
	if(a[i]==10)
		a[i]=0;
}
for(auto &x:a)
cout<<x;
}
int main()
{
//code

fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

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

    std::vector<int> p;
    p.reserve(n);
    int x;
    for (int i = 0; i < n; ++i) {
        std::cin >> x;
        p.push_back(x);
    }

    int ret = 0;
    for (int i = 1; i < n - 1; ++i) {
        const auto a = p[i - 1];
        const auto b = p[i];
        const auto c = p[i + 1];

        if ((a < b && b < c) || (c < b && b < a)) {
            ++ret;
        }
    }

    std::cout << ret << std::endl;
}


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

int main(void) {

    long long N,A,B;
    int i;
    long long sum = 0;

    scanf("%lld %lld %lld", &N, &A, &B);
    long long X[N];
    for(i=0;i<N;i++){
        scanf("%lld",&X[i]);
    }

    for(i=1;i<N;i++){
        long long dis = X[i] - X[i-1];
        if(B > dis * A){
            sum += dis * A;
        }
        else{
            sum += B;
        }
    }

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


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

#define rep2(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) rep2(i,0,n)
#define all(a) a.begin(),a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << n * 2 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <map>
#include <string>

using namespace std;

int main() {
    int a[] = {111,222,333,444,555,666,777,888,999};
    int n;cin>>n;
    int i = 0;
    while(n >a[i])i++;
    cout<<a[i];
}


Measured memory_bytes: 256