akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll cnt[66][2];

template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

signed main(){
	//cout << fixed << setprecision(10);
    int n; cin >> n;
    vl vec(n);
    rep(i,0,n){
        ll a; cin >> a;
        rep(j,0,61){
            if(a>>j & 1)cnt[j][1]++;
            else cnt[j][0]++;
        }
    }
    mint ans = 0;
    mint memo = 1;
    rep(i,0,61){
        mint add = cnt[i][0] * cnt[i][1];
        add *= memo;
        ans += add;
        memo *= 2;
    }
    cout << ans << endl;


	return 0;
}

Measured memory_bytes: 5628
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int v[N],c[N];
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    int tmp=0,ans=0;
    for(int i=0;i<N;i++){
        tmp=v[i]-c[i];
        if(tmp>=0){
            ans+=tmp;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_o
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int n;
int dp[21][1<<21];
vector<vector<int>> a;
int ways(int man,bitset<21> woman) {

  if (man >= n) return 1;
  int num = 0;
  // for(int i=0;i<n;i++) {
  //   if (woman[n-1-i]) {
  //     num += 1 << i;
  //   }
  // }
  auto &res = dp[man][woman.to_ulong()];
  if (res != -1) return res;
  res = 0;
  for(int i=0;i<n;i++) {
    if (a[man][i] and woman[i]) {
      woman[i] = false;
      res = (res + (long long) ways(man+1,woman)) % mod; 
      woman[i] = true;
    }
  }
  // cerr << "res for man: " << man << " " <<  res << '\n';
  return res;
}
int solve() {
  cin >> n;
  memset(dp,-1,sizeof dp[0][0] * 21 * (1<<21));
  a.resize(n,vector<int>(n));
  for(auto &e: a) for(auto &c: e) cin >> c;
  bitset<21> woman;
  woman.set();
  return ways(0,woman);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  cout << solve();
  return 0;
}

Measured memory_bytes: 172288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(ll i=0; i<a;i++)
#define rep1(i,a,b) for(ll i=(a);i<=(b);++i)
#define irep(i,b,a) for(ll i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const ll mod = 1000000007; // (ll)1e9+7
const ll maxn = 2000100;
ll ans[100][100];
ll FInd(ll x){
    while(x){
        if(x/10==0)return x;
        x/=10;
    }
}

int  main(){
        _ios;

        ll n;
        cin>>n;
        for(ll i = 1; i<=n;i++){
                ans[FInd(i)][i%10]++;
        }
        ll res = 0;
        for(ll i = 1; i<=9;i++){
            for(ll j = 1; j<=9;j++){
                res += ans[i][j] * ans[j][i];
            }
        }
        cout<<res<<endl;



return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1, mode = 0;
    for (int i = 1; i < n; i++) {
        if (mode == 0) {
            if (a[i] > a[i - 1]) mode = 1;
            else if (a[i] < a[i - 1]) mode = -1; 
        } else if (mode == 1) {
            if (a[i] < a[i - 1]) ans++, mode = 0;
        } else {
            if (a[i] > a[i - 1]) ans++, mode = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long n,l,a[N];
inline int read(){
    register int x=0,f=1;
    register char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
        x=x*10+(ch^48),ch=getchar();
    return x;
}
int main(){
    long long ans=0,res=1e9,k;
    scanf("%lld%lld",&n,&l);
    for(int i=1;i<=n;i++){
        a[i]=l+i-1;
        ans+=a[i];
        if(abs(a[i])<res){
            res=abs(a[i]);
            k=a[i];
        }
    }
    printf("%lld\n",ans-k);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,q,a[2005],ans=0x7fffffff,b[2005],c[2005],d[2005],t,l,r;
inline int min(int x,int y){
	return x<y?x:y;
}
int main(){
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++){
    	t=b[i],l=1,r=1;
	    c[0]=0;
	    while(l<=n){
	        while(a[l]<t&&l<=n) l++;
	        d[0]=0,r=l;
	        while(a[r]>=t&&r<=n) r++;
	        for(int i=l;i<r&&i<=n;i++) d[++d[0]]=a[i];
	        if(d[0]>=k){
	            sort(d+1,d+d[0]+1);
	            for(int i=1;i<=d[0]-k+1;i++) c[++c[0]]=d[i];
	        }
	        l=r;
	    }
	    sort(c+1,c+c[0]+1);
	    if(c[0]>=q) ans=min(ans,c[q]-c[1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = "".join(list(map(str, input().split())))
q = "".join(list(map(str, input().split())))

l = "".join([str(i+1) for i in range(n)])

cnt = 0
a,b = 0,0
for x in itertools.permutations(l):
	y = "".join(x)
	cnt += 1
	if y == p:
		a = cnt
	if y == q:
		b = cnt

	if a != 0 and b != 0:
		break

print(abs(a-b))

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

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

int main() {
    int a[3];
    rep(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
	return 0;
}


Measured memory_bytes: 3628
#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

typedef long long signed ll;

template<typename T>
class Vector2D {
public:
    T x;
    T y;

    Vector2D() {
        x = y = 0;
    }

    Vector2D(T x_, T y_) {
        x = x_;
        y = y_;
    }

    T operator*(const Vector2D<T> *e) {
        return this->x * e->x + this->y * e->y;
    }

    Vector2D<T> operator-(const Vector2D<T> *e) {
        return Vector2D<T>(this->x - e->x, this->y - e->y);
    }

    Vector2D<T> operator+(const Vector2D<T> *e) {
        return Vector2D<T>(this->x + e->x, this->y + e->y);
    }

    T operator*(const Vector2D<T> e) {
        return this->x * e.x + this->y * e.y;
    }

    Vector2D<T> operator-(const Vector2D<T> e) {
        return Vector2D<T>(this->x - e.x, this->y - e.y);
    }

    Vector2D<T> operator+(const Vector2D<T> e) {
        return Vector2D<T>(this->x + e.x, this->y + e.y);
    }

    Vector2D<T> operator*(const T r) {
        return Vector2D<T>(this->x * r, this->y * r);
    }

    Vector2D<T> operator/(const T r) {
        return Vector2D<T>(this->x / r, this->y / r);
    }

    double abs() {
        return sqrt(x * x + y * y);
    }

    T abs2() {
        return x * x + y * y;
    }

    T cross(Vector2D<T> e) {
        if(x * e.y >= y * e.x) return (x * e.y) - (y * e.x);
        else return (y * e.x) - (x * e.y);
    }

    double cos(Vector2D<T> e) {
        return (e * (*this)) / (e.abs() * abs());
    }

    double sin(Vector2D<T> e) {
//        if(e.abs() * this->abs() == 0.0) throw ;
        return ((x * e.y) - (y * e.x)) / (e.abs() * abs());
    }
};

typedef Vector2D<double> vdd;

double dist__(double x0, double y0, double x1, double y1, double xx, double yy) {
    int b = 0;
    vdd p[3] = {vdd(x0, y0), vdd(x1, y1), vdd(xx, yy)};
    if (((p[0] - p[1]) * (p[2] - p[1])) < 0) b = -1;
    if (((p[1] - p[0]) * (p[2] - p[0])) < 0) b = 1;
    if (b == 1) return (p[2] - p[0]).abs();
    if (b == -1) return (p[2] - p[1]).abs();
    return (p[1] - p[0]).cross(p[2] - p[0]) / (p[1] - p[0]).abs();
}

double dist(double x0, double y0, double x1, double y1, double xx, double yy){
    double res = dist__(x0,y0,x1,y1,xx,yy);
//    cout << res << endl;
    return res;
}
int main() {
    int q;
    cin >> q;
    loop(i, 0, q) {
        int x[4], y[4];
        vdd v[4];
        loop(j, 0, 4) {
            cin >> x[j] >> y[j];
            v[j] = vdd(x[j], y[j]);
        }
        if ((v[0] - v[1]).sin(v[2] - v[1]) * (v[0] - v[1]).sin(v[3] - v[1]) < 0 && (v[2] - v[3]).sin(v[0] - v[3]) * (v[2] - v[3]).sin(v[1] - v[3]) < 0) cout << 0 << endl;
        else
            cout << setprecision(16)
                 << min(min(dist(x[0], y[0], x[1], y[1], x[2], y[2]), dist(x[0], y[0], x[1], y[1], x[3], y[3])),
                        min(dist(x[2], y[2], x[3], y[3], x[0], y[0]), dist(x[2], y[2], x[3], y[3], x[1], y[1])))
                 << endl;
    }
}




Measured memory_bytes: 3280
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/

vi v[2*M];
int n,q,a,b,p,x,c[2*M]={};
void dfs(int now,int pre){
	c[now]+=c[pre];
	for(int next:v[now])if(next!=pre){
		dfs(next,now);
	}
}

int main() {
	cin>>n>>q;
	rep(i,0,n-1){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i,0,q)cin>>p>>x,c[p]+=x;
	dfs(1,0);
	rep(i,1,n+1){
		cout<<c[i];
		if(i!=n)cout<<" ";
	}
}

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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n >> k;
	ll arr[n+2];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}

	sort(arr,arr+n);
	m=0;
	for(i=0;i<k;i++)
	{
		m+=arr[i];
	}
	cout << m << "\n";
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <atcoder/dsu>


using namespace std;
using namespace atcoder;


int main(void){
    int n, q;
    int *t, *u, *v;

    scanf("%d", &n);
    scanf("%d", &q);

    dsu d(n);


    t = (int *)malloc(sizeof(int) * q);
    u = (int *)malloc(sizeof(int) * q);
    v = (int *)malloc(sizeof(int) * q);

    for(int i = 0; i < q; i++){
        scanf("%d", t + i);
        scanf("%d", u + i);
        scanf("%d", v + i);
    }

    for(int i = 0; i < q; i++){
        if(t[i] == 0)
            d.merge(u[i], v[i]);
        else{
            if(d.same(u[i], v[i]))
                printf("1\n");
            else
                printf("0\n");
        }
    }

    free(t);
    free(u);
    free(v);

    return 0;
}

Measured memory_bytes: 5328
using System;

class Program
{
    static void Main()
    {
        while (true)
        {

            string zeta = null;
            string[] alpha = Console.ReadLine().Split(' ');
            int a = int.Parse(alpha[1]);
            int b = int.Parse(alpha[0]);
            if (a == 0 && b == 0)
            {

                break;
            }

            for (int j = 0; a > j; j++) zeta = zeta + "#";
            for (int q = 0; b > q; q++)
            {
                Console.Write(zeta);
                Console.Write("\n");
            }
            Console.Write("\n");
           
        }

    }
}



Measured memory_bytes: 17992
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;

  ll ans = 0;

  ans += (n / (a + b)) * a;
  ans += min(n % (a + b), a);
  cout << ans << endl;
}


Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << a[k - 1] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  int minusCnt = 0;
  ll sum = 0;
  for (int i = 0; i < N; i++)
  {
    if (A[i] < 0)
      minusCnt++;
    sum += abs(A[i]);
  }
  bool minusEven;
  if (minusCnt % 2 == 0)
    minusEven = true;
  else
    minusEven = false;
  if (minusEven)
  {
    cout << sum << endl;
  }
  else
  {
    vector<ll> B;
    for (int i = 0; i < N; i++)
      B.push_back(abs(A[i]));
    sort(B.begin(), B.end());
    ll minValue = B[0];
    sum -= 2 * minValue;
    cout << sum << endl;
  }
  return 0;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int maxn = 1e5 + 5;
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

set<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	set<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.insert(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

int power(int x, unsigned int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;
	;
	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;

}


// Graph------------------------------------------------------------------------


int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
	// Never GIVE UP !!!!
	string s;
	string t;
	cin >> s >> t;
	int ans = 1e9;
	for (int i = 0; i <= s.size() - t.size(); i++)
	{
		int mn = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (s[i + j] != t[j])
			{
				mn++;
			}
		}
		ans = min(ans, mn);
	}
	cout << ans;

}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int k,n;
  cin >> n >> k;
  vector<int> a(n);
  int one;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==1){
      one=i;
    }
  }
  int ans=1000000;
  for(int i=0;i<k;i++){
    ans=min(ans,(one-i+k-2)/(k-1)+(n-1-(one-i+k-1)+k-2)/(k-1)+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         int N = sc.nextInt();
         int wnum = 0;
         int rnum = 0;
         int ans = 0;
         char[] C = new char[N];
         String text = sc.next();
         for(int i = 0 ; i < N ; i++){
                C[i] = text.charAt(i);
                if(C[i] == 'W'){
                    wnum++;
                }else{
                    rnum++;
                }
         }
         if(wnum == 0||rnum == 0){
         }else{ 
            for(int i = rnum ; i < N ; i++){
                if(C[i] == 'R'){
                    ans++;
                }
            }
         }
         System.out.println(ans);
    }
}


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

int main() {
	string w;
	cin >> w;
	int atoz[26]={};
	
	for(int i=0; i<w.length(); i++){
		atoz[w[i]-'a']++;
		
	}
	
	
	for(int i=0; i<26; i++){
		if(atoz[i]%2==1){
			cout <<"No"<<endl;return 0;
		}	
	}
	cout << "Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    Integer n = scan.nextInt();
    int[] a = new int[n];
    for(int i = 0 ; i < n ; i++){
      a[i] = scan.nextInt();
    }
    int sum = 0;
    for(int i = 0 ; i < n ; i++){
      sum += a[i];
    }
    Arrays.sort(a);
    if(sum % 10 == 0) {
      for(int i = 0 ; i < n ; i++) {
        if((sum - a[i]) % 10 == 0){
          continue;
        }
        System.out.println(sum - a[i]);
        return;
      }
    } else {
      System.out.println(sum);
      return;
    }
    System.out.println(0);
  }
}

Measured memory_bytes: 22740
from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:],i8[:])')
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(last[j]-i)
        score=score+s[i*26+v]-c
    return score

def main():
    start=time()
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=int64(([*range(26)]*15)[:d])
    M=func(s,x)
    while time()-start<1:
        y=x.copy()
        y[randint(0,d-1)]=randint(0,25)
        t=func(s,y)
        if t>M:
            M=t
            x=y
    print(*x+1,sep='\n')

main()

Measured memory_bytes: 112392
import sys
from bisect import bisect_left as bi_l
from collections import defaultdict

def main():
    s, t = sys.stdin.read().split()
    if set(t) - set(s):
        print(-1)
        sys.exit()

    n = len(s)
    s *= 2
    c = defaultdict(list)
    for i in range(n * 2):
        c[s[i]].append(i)

    i = 0
    l = 0 # left_most
    for ch in t:
        b = c[ch][bi_l(c[ch], l)]
        if b < n:
            l = b + 1
        else:
            l = b - n + 1
            i += n

    print(i+(l-1)+1) # 最初が0のため

if __name__ == '__main__':
    main()

Measured memory_bytes: 12396
#include <bits/stdc++.h>
#define F first
#define S second
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define p_b push_back
using namespace std;
typedef long long ll; //printf("%lld ", ll); to out put long
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;
const double eps = 1e-6;
const int MAXN = 1e6 + 5;
const ll MOD = 1e9 + 7;
bool ODD(ll O) {return (O % 2 != 0);}
ll gcd(ll a, ll b) {return __gcd(a , b);}
int dx[] = {1, 0, -1 ,0 , -1 , 0};
int dy[] = {0, 1, 0, -1 , -1 , 0};
ll power (ll x, ll y) {
    if(y == 0) return 1;
    if(ODD(y)) return x * power(x , y / 2) * power(x , y / 2);
    return power(x , y / 2) * power(x , y / 2);
}
/*------ never give up --------*/


int main () {
    int t = 1;
    //cin >> t;
    while(t--) {
        int n, k;
        cin >> n >> k;
        vector <int> vc(n);
        for(int &i : vc) cin >> i;
        sort(vc.begin() , vc.end());
        ll sum = 0;
        for(int i = 0; i < k; i++) sum += vc[i];
        cout << sum << "\n";

    }
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > a;
	for(int i = 1; i <= n; i++) {
		int x, l;
		scanf("%d%d", &x, &l);
		a.push_back({x - l, x + l});
	}
	sort(a.begin(), a.end());
	int cur = -2e9, ans = 0;
	for(auto tmp : a) {
		int le = tmp.first, ri = tmp.second;
		//cout << le << ' ' << cur << endl;
		if(le >= cur) {
			cur = ri;
			ans++;
		}else {
			cur = min(cur, ri);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int id[100002] = {};
  for(int i = 0 ; i < m ; i++){
    int l,r;
    cin >> l >> r;
    id[l]++;
    id[r+1]--;
  }
  for(int i = 0; i < n; i++){
    id[i+1] += id[i];
  }
  int cnt = 0;
  for(int i = 0; i <= n; i++){
    if(id[i] == m) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
n, a, b = map(int,input().split())
*p, = map(int,input().split())
l = []
#print(p)
for i in range(1,n):
  w = (p[i]-p[i-1])*a 
  if w >= b:
    l.append(b)
  else:
    l.append(w)
#print(l)
print(sum(l))

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vint a(n+1),b(n);
  vin(a);
  vint pos;
  rep(i,n){
    cin >> b[i];
    if(b[i]>=a[i]+a[i+1])pos.push_back(i);
  }
  int ans=0;
  if(!pos.empty()){
    rfor(pos,x){
      ans+=a[x]+a[x+1];
      a[x]=0;a[x+1]=0;b[x]=0;
    }
  }
  rep(i,n){
    if(b[i]>=a[i]+a[i+1]){
      ans+=a[i]+a[i+1];
      a[i+1]=0;
    }else{
      ans+=b[i];
      b[i]-=a[i];
      if(b[i]>0)a[i+1]-=b[i];
    }
  }

  cout << ans << endl;

}


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

int main(){
  int c;
	string S;
  cin >> S;
  
  rep(i,3){
    if(S.at(i)=='A')
      c++;
  }
  if(c==3 || c==0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
    
}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<vector<bool>> coG(N, vector<bool>(N, true));
    for (int i = 0; i < N; i++) coG[i][i] = false;
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      coG[a][b] = false;
      coG[b][a] = false;
    }
    vector<int> color(N, -1);
    bitset<1000> dp;
    dp.set(0);
    for (int v = 0; v < N; v++) {
      if (color[v] != -1) continue;
      vector<int> cnt(2, 0);
      queue<int> q;
      q.push(v);
      color[v] = 0;
      ++cnt[0];
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u = 0; u < N; u++) {
          if (!coG[v][u]) continue;
          if (color[u] == -1) {
            color[u] = 1 - color[v];
            ++cnt[1 - color[v]];
            q.push(u);
          } else {
            if (color[u] == color[v]) {
              cout << -1 << endl;
              return 0;
            }
          }
        }
      }
      dp = (dp << cnt[0]) | (dp << cnt[1]);
    }
    ll res = 1ll << 60;
    for (int x = 0; x <= N; x++) {
      if (dp[x]) {
        int y = N - x;
        res = min(res, 1ll * x * (x - 1) / 2 + 1ll * y * (y - 1) / 2);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int a,b;cin>>a>>b;
	int ans=0,flag=0,ans1=0,ans2=0;
	for(int i=1;i<=100000;i++){
		ans1=floor(i*1.0*8/100);
		ans2=floor(i*1.0*10/100);
		if(ans1==a and ans2==b){
			ans=i;
			flag=1;
			break;
		}
	}
	if(flag)
		cout<<ans;
	else{
		cout<<-1;
	}
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

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

#define sf scanf
#define pf printf
#define endl "\n"
#define off ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr freopen("in.txt", "r", stdin)
#define fw freopen("out.txt", "w", stdout)
#define pb push_back
#define eb emplace_back
#define PII pair<int, int>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define pass printf("Passed Here\n")

typedef long long ll;
typedef unsigned int ui;
int mod = 1000000007;

int main()
{
    ll d, n, ans;
    cin>>d>>n;
    if(d == 0) {
        cout<<n+(n/100)<<endl;
    }   
    else if(d == 1) {
        ans = 100*(n+(n/100));
        cout<<ans<<endl;
    }
    else {
        ans = 100*100*(n+(n/100));
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
    using System.Collections.Generic;
    using System.Linq;
 
    class Program
    {
        static void Main(string[] args)
        {
            var line = System.Console.ReadLine();
            long H = Convert.ToInt64(line);
            List<long> Hs = new List<long>();
            Hs.Add(H);
            long count = 0;
            count = function(H);
            Console.WriteLine(count.ToString());
        }
      	
      	static long function(long x)
        {
            if (x ==1)
            {
                return 1;
            }
            return 2 * function(x / 2) + 1;
        }
    }

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));


signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int h,w; cin >> h >> w;
    int c1,c2,d1,d2;
    cin >> c1 >> c2 >> d1 >> d2;
    c1--; c2--; d1--; d2--;
    char c[h][w];
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    int num[h][w];
    rep(i,h)rep(j,w)num[i][j]=-1;
    int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
    int res=0;
    rep(i,h){
        rep(j,w){
            if(num[i][j]!=-1||c[i][j]=='#')continue;
            queue<P> q;
            q.push({i,j});
            num[i][j]=res;
            while(!q.empty()){
                P v=q.front(); q.pop();
                rep(k,4){
                    int nx=v.fi+dx[k],ny=v.se+dy[k];
                    if(0<=nx&&nx<h&&0<=ny&&ny<w&&c[nx][ny]=='.'&&num[nx][ny]==-1){
                        num[nx][ny]=res;
                        q.push({nx,ny});
                    }
                }
            }
            res++;
        }
    }
    set<int> st[500100];
    rep(i,h){
        rep(j,w){
            if(num[i][j]==-1)continue;
            for(int a=-2;a<=2;a++){
                for(int b=-2;b<=2;b++){
                    int nx=i+a,ny=j+b;
                    if(0<=nx&&nx<h&&0<=ny&&ny<w&&c[nx][ny]=='.'&&num[nx][ny]!=num[i][j]){
                        st[num[i][j]].insert(num[nx][ny]);
                        st[num[nx][ny]].insert(num[i][j]);
                    }
                }
            }
        }
    }
    int stt=num[c1][c2];
    int ed=num[d1][d2];
    if(stt==ed){
        cout << 0 << endl;
        return 0;
    }
    vector<int> d(h*w,0);
    d[stt]=0;
    queue<int> q;
    q.push(stt);
    while(!q.empty()){
        int t=q.front(); q.pop();
        for(int u:st[t]){
            if(d[u]==0){
                d[u]=d[t]+1;
                if(u==ed){
                    cout <<d[t]+1<<endl;
                    return 0;
                }
                q.push(u);
            }
        }
    }
    cout << -1 << endl;
}



Measured memory_bytes: 53732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#if DEBUG
using Console = Atcoder.Helper.HelperConsole;
using AtcoderHelper = Atcoder.Helper.AtcoderHelper;
#endif

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
#if DEBUG
            var url = @"
https://atcoder.jp/contests/abc142/tasks/abc142_a
";
            AtcoderHelper.RunTestCases(url);
        }
        public static void Code()
        {
#endif
            var n = int.Parse(Console.ReadLine());
            var p = (double)((n + 1) / 2) / n;
            Console.WriteLine(p);
            // ここにソースコードを書く
        }
    }
}


Measured memory_bytes: 13140
s = input()
n = len(s)
if n == 1:
	print(s)
elif n == 2:
	print(9)
elif n == 3:
	print(9+(int(s)-99))
elif n == 4:
	print(9+900)
elif n == 5:
	print(9+900+(int(s)-9999))
else:
	print(90909)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll H, N;
	cin >> H >> N;

	vector<P> ab(N);
	//ll aMax = 0;

	for (ll i = 0; i < N; ++i)
	{
		cin >> ab[i].first >> ab[i].second;
		//aMax = max(ab[i].first, aMax);
	}

	/*
	vector<ll> min_mp(aMax+1, INF);

	for (ll i = 0; i < N; ++i)
	{
		min_mp[ab[i].first] = min(min_mp[ab[i].first], ab[i].second);
	}

	for (ll i = aMax-1; i >= 0; --i)
	{
		min_mp[i] = min(min_mp[i], min_mp[i+1]);
	}
	*/

	vector<ll> dp(H+1, INF);
	dp[0] = 0;
	for (ll h = 1; h <= H; ++h)
	{
		ll min_mp = 0;

		for (const auto e : ab)
		{
			ll x = h - e.first;
			x = max(x, 0LL);
			dp[h] = min(dp[h], dp[x] + e.second);
		}
	}



	/*
	sort(ab.begin(), ab.end(), [](const P& a, const P& b)
	{
		if (a.first > b.first) return true;
		if (a.first < b.first) return false;
		return (a.second < b.second);
	});

	for (auto e : min_mp)
	{
		cout << e << endl;
	}
	*/

	cout << dp[H] << endl;

	//system("pause");
}


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

int main () {
  int x, a, b;
  cin >> x >> a >> b;
  
  int A, B;
  if (x - a >= 0) A = (x - a);
  else A = (a - x);
  
  if (x - b >= 0) B = (x - b);
  else B = (b - x);
  
  if (A > B) cout << 'B' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W,i,x,t;
    i=0;
    x=0;
    t=0;
    string a="";
    string b="";
    while(1){
        cin>>H>>W;
        if(H==0&&W==0) break;
        while(x<W){
           if(x%2==0) a+="#";
           else a+=".";
           x+=1;
        }
        while(t<W){
           if(t%2==0) b+=".";
           else b+="#";
           t+=1;
        }
        while(i<H){
            if(i%2==0) cout<<a<<endl;
            else cout<<b<<endl;
            i+=1;
        }
        cout<<endl;
        t=0;
        x=0;
        i=0;
        a="";
        b="";
    }
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll 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);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;

  vll P(N);
  ll ans = 0;
  rep(i, N) {
    cin >> P[i];
    P[i]--;
    if (i == 0) continue;
    // debug(i);

    // debug(P[i]);
    // debug(P[i - 1]);

    if (P[i] == i && P[i - 1] == i - 1) {
      ans++;
      P[i - 1] = INF;
      P[i] = INF;
    }
  }

  rep(i, N) {
    if (P[i] == i) {
      ans++;
    }
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3952
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

	public static class Program
	{
		public static void Main()
		{
			string s = Console.ReadLine();
			string o;
			int a = s.Length;

			if (s.Substring(a-1, 1).Equals("s"))
			{
				o = "es";
			}
			else { o = "s"; }
			Console.WriteLine(s+o);
		}
	}
}


Measured memory_bytes: 25896
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    vector<pll> xy(N);
    for (int i = 0; i < N; i++) {
        cin >> xy[i].fi >> xy[i].se;
    }
    if (N == 1){
        pr(1);
        return 0;
    }

    ll ans = INF;
    REP(i, N){
        REP(j, N){
            if(i == j) continue;
            ll p = xy[j].fi - xy[i].fi;
            ll q = xy[j].se - xy[i].se;

            ll tmp = 0;
            REP(i2, N){
                REP(j2, N){
                    if(i2 == j2) continue;
                    
                    ll tp = xy[j2].fi - xy[i2].fi;
                    ll tq = xy[j2].se - xy[i2].se;

                    if(tp == p && tq == q) tmp++;
                }
            }
            ans = min(ans, N - tmp);
        }
    }

    pr(ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = scan.nextInt();
        Integer m = scan.nextInt();
        Integer x = scan.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();

        for(int i=0;i<m;i++) a.add(scan.nextInt());

        Collections.sort(a);

        int cost1 = 0;
        int cost2 = 0;
        int p = 0;
        while(true){
            if(a.get(p) >= x) break;
            p++;
        }
        cost1 = p;
        cost2 = a.size()-p;
        if(cost1 < cost2)
            System.out.println(cost1);
        else
            System.out.println(cost2);
    }

    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
    }


}

Measured memory_bytes: 21844
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll n,x,t;
	cin>>n>>x>>t;
	ll zz=n/x;
	if(n%x)
	zz++;
	cout<<zz*t;	
}

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

using namespace std;

#define li long long int
#define ld double_t
#define mod (li)(1e9+9)
const int MX1=3e5+5;
const int MX2=1e6+5;
const li inf=1e18;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n;
unordered_map<int,int> mpp;

void solve(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		mpp[x]++;
	}
	int ans=0;
	for(auto it:mpp){
		int x,y;
		x=y=mod;
		if(it.second>=it.first) x=it.second-it.first;
		y=it.second;
		ans+=min(x,y);
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main()
{
	int N, W;
	cin >> N >> W;
	vector<int> dp(W + 1, 0);
	for (int i = 0, v, w; i < N; i++) {
		cin >> v >> w;
		for (int j = w; j <= W; j++) {
			if (dp[j] < dp[j - w] + v) {
				dp[j] = dp[j - w] + v;
			}
		}
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3164