akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;

int main(){
	cin >> n;
	vector<pll> line(n);
	vector<ll> ans(n,0);
	rep(i,n){
		cin >> line[i].first;
		line[i].second = i;
	}

	sort(all(line),greater<pll>());
	int minp = line[0].second;
	repa(i,n){
		if(line[0].first == line[i].first){
			chmin(minp,line[i].second);
			continue;
		}
		ans[minp] += i * (line[0].first - line[i].first);
		line[0].first = line[i].first;
		chmin(minp,line[i].second);
	}
	ans[minp] += n * (line[0].first);
	foreach(i,ans){
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
 
  if ((s.at(0)==s.at(1)&&s.at(1)==s.at(2))||(s.at(1)==s.at(2)&&s.at(2)==s.at(3))) {
    cout <<"Yes"<< endl;
  }
  else{
    cout <<"No"<< endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	if(K == 1)
		cout << 0;
	else
		cout << N - K;

	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ct[200005];
int a[200005];
ll ans = 0;
ll f(int x){
    return (ll)x*(x-1)/2;
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        ct[a[i]]++;
    }
    for (int i = 0; i <= n; i++){
        ans += f(ct[i]);
    }
    for (int i = 0; i < n; i++){
        printf("%lld\n",ans-f(ct[a[i]])+f(ct[a[i]]-1));
    }
}


Measured memory_bytes: 3712
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 520
#define mid ((l+r)>>1)
using namespace std;
int read(){
    int nm=0,fh=1; char cw=getchar();
    for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
    for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
    return nm*fh;
}
int p[M*M*4],od[M],pos[M],n,m,ans[M*M];
bool cmp(int x,int y){return pos[x]<pos[y];}
void fad(){puts("No");exit(0);}
void ins(int x,int l,int r,int pos,int num){
    if(p[x]==r-l+1) return fad();
    p[x]++; if(l==r){ans[l]=num;return;}
    if(pos<=mid) ins(x<<1,l,mid,pos,num);
    else ins(x<<1|1,mid+1,r,pos,num);
}
void add_pre(int x,int l,int r,int rs,int num){
    if(l>rs||p[x]==r-l+1) return fad();
    p[x]++; if(l==r){ans[l]=num;return;}
    if(p[x<<1]<mid-l+1) add_pre(x<<1,l,mid,rs,num);
    else add_pre(x<<1|1,mid+1,r,rs,num);
}
void add_suf(int x,int l,int r,int ls,int num){
    if(r<ls||p[x]==r-l+1) return fad();
    p[x]++; if(l==r){ans[l]=num;return;}
    if(p[x<<1|1]<r-mid) add_suf(x<<1|1,mid+1,r,ls,num);
    else add_suf(x<<1,l,mid,ls,num);
}
int main(){
    n=read(),m=n*n;
    for(int i=1;i<=n;i++) pos[i]=read(),od[i]=i,ins(1,1,m,pos[i],i);
    sort(od+1,od+n+1,cmp);
    for(int i=1;i<=n;i++){
        for(int j=1;j<od[i];j++) add_pre(1,1,m,pos[od[i]],od[i]);
    }
    for(int i=n;i>0;i--){
        for(int j=od[i]+1;j<=n;j++) add_suf(1,1,m,pos[od[i]],od[i]);
    }
    puts("Yes");
    for(int i=1;i<=m;i++) printf("%d%c",ans[i],i<m?' ':'\n');
    return 0;
}


Measured memory_bytes: 5120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.readIntArray(3);
            Arrays.sort(a);
            int ans = 0;
            for (int i = 1; i < 3; i++) ans += a[i] - a[i - 1];
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] ans = new int[size];
            for (int i = 0; i < size; i++) ans[i] = readInt();
            return ans;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N, M;
  cin >> N >> M;

  const ll INF = 100110011001;

  vector<vector<P> > toLst(N + 1);
  vector<vector<P> > frLst(N + 1);
  vector<ll> visited(N + 1, INF);

  for (int i = 0; i < M; i++) {
    ll fr, to, wt;
    cin >> fr >> to >> wt;
    toLst[fr].push_back(P(to, wt));
    toLst[to].push_back(P(fr, -wt));
  }

  queue<ll> sque;
  for (int i = 1; i <= N; i++) {
    if (visited[i] != INF) continue;
    sque.push(i);
    visited[i] = 0;
    while (!sque.empty()) {
      ll tmp = sque.front();
      sque.pop();
      for (auto& nxt : toLst[tmp]) {
        if (visited[nxt.first] != INF) {
          if(visited[nxt.first] != nxt.second + visited[tmp]){
            puts("No");
            return 0;
          }
        } else {
          visited[nxt.first] = nxt.second + visited[tmp];
          sque.push(nxt.first);
        }
      }  // nxt
    }    // !sque
  }      // !que

  puts("Yes");

  return 0;
}


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

const int MOD=1e9+7;

vector<ll> fac(300001);
vector<ll> ifac(300001);

ll modpow(ll x,ll n){
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1; 
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a==0&&b==0) return 1;
    if(a<b||a<0) return 0;
    ll tmp = ifac[a-b]*ifac[b] % MOD;
    return tmp*fac[a]%MOD;
}

void prepare(){
    fac[0]=1;ifac[0]=1;
    for(ll i=0;i<300000;i++){
        fac[i+1]=fac[i]*(i+1)%MOD;
        ifac[i+1]=ifac[i]*modpow(i+1,MOD-2)%MOD;
    }
}

int main(){
    int n,k;
    cin>>n>>k;
    prepare();
    REP(i,k){
        cout<<comb(n-k+1,i)*comb(k-1,i-1)%MOD<<endl;
    }

    return 0;
}

Measured memory_bytes: 4992
process.stdin.on('data', function(chunk) {
   
    var data = chunk.split(' ').map(Number);
    var a = data[0];
    var b = data[1];
    var c = data[2];
    var count = 0;
    for (var i = a; i < b + 1; i++){
        if (c % i === 0){
            count ++;
        }
}
    console.log(count);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans(n);
    int a = (s == (int)1e9? 1 : (int)1e9);
    for(int i = 0; i < n; i++){
        if(i < k){
            ans[i] = s; 
        }else{
            ans[i] = a;
        }
    }
    cout << ans[0];
    for(int i =1; i < n; i++){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


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

int main (){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);
    
    sort(p.begin(), p.end());
    ll ans = 0;
    rep(i, K){
        ans += p.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    int cnt=0;
    n--;
    deque<char> q;
    while(n>=0){
        q.push_front((char)'a'+(n%26));
        n/=26;
        n--;
    }
    while(!q.empty()){
        cout<<q.front();
        q.pop_front();
    }
    cout<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
int n, a[9][9], r[9][9];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		if (i) printf("\n");
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) scanf("%d", &a[j][k]), r[j][k] = 0;
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				for (int l = 0; l < 9; l++) {
					if (k != l && a[j][k] == a[j][l]) r[j][k] = 1;
					if (j != l && a[j][k] == a[l][k]) r[j][k] = 1;
				}
				for (int l = j / 3 * 3; l < j / 3 * 3 + 3; l++) {
					for (int m = k / 3 * 3; m < k / 3 * 3 + 3; m++) {
						if (j != l && k != m && a[j][k] == a[l][m]) r[j][k] = 1;
					}
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) printf("%c%d", r[j][k] ? '*' : ' ', a[j][k]);
			printf("\n");
		}
	}
}

Measured memory_bytes: 2644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    ll n, d;
    cin >> n >> d;
    vector<pair<int, int>> p;
    for(int i = 0; i<n; i++){
        int x, y;
        cin >> x >> y;
        p.push_back(make_pair(x, y));
    }

    int count = 0;

    for(auto point: p){
        if((pow(point.first, 2) + pow(point.second, 2)) <= d*d){
            count++;
        }
    }

    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN * 3];
void Solve() {
    read(N);
    for(int i = 1 ; i <= 3 * N ; ++i) read(a[i]);
    sort(a + 1,a + 3 * N + 1);
    int64 ans = 0;
    for(int i = 3 * N - 1 ; i >= N + 1 ; i -= 2) {
	ans += a[i];
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

int main() {
  int n;
  cin >> n;
  while(n--) {
    int a[5][5];
    for(int i=0; i<5; i++) {
      for(int j=0; j<5; j++) cin >> a[i][j];
    }
    int max=0;
    for(int i=0; i<5; i++) {
      for(int j=0; j<5; j++) {
	if(a[i][j]) {
	  for(int k=0; k+j<5; k++) {
	    if(a[i][j+k]==0) break;
	    for(int l=0; l+i<5; l++) {
	      if(a[i+l][j]==0) break;
	      bool ck=true;
	      for(int x=0; x<=l; x++) {
		for(int y=0; y<=k; y++) {
		  if(a[i+x][j+y]==0) {
		    ck=false;
		    break;
		  }
		}
	      }
	      if(ck && max<(l+1)*(k+1)) max=(l+1)*(k+1);
	    }
	  }
	}
      }
    }
    cout << max << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.TreeSet;
public class Main{
    public static void main(String[] args) {
        TreeSet <Integer> numerosUtiles = new TreeSet<>();
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] numbers = new int [n];
        for (int i = 0; i < n; i++) {
            numbers[i] = in.nextInt();
            
        }
        for (int i = 1; i < (n-1); i++) {
            int a = numbers[i-1];
            int b = numbers[i];
            int c = numbers[i+1];
            if ((b>a && b<c) || (b<a && b>c)){
                numerosUtiles.add(b);
            }
        }
        System.out.println(numerosUtiles.size());
    }
      
}

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

void Swap(int& a, int& b)
{
	int temp = a;
	a = b;
	b = temp;
}

int main()
{
	int N, num = 0;
	int a[100];
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = N - 1; j >= i + 1; j--)
		{
			if (a[j] < a[j - 1])
			{
				Swap(a[j], a[j - 1]);
				num++;
			}

		}
	}

	for (int i = 0; i < N; i++)
	{
		if (i != N - 1) cout << a[i] << " ";
		else if (i == N -1)cout << a[i] << endl;
	}
	cout << num << endl;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

char s[5];

int main(void)
{
  scanf("%s", s);
  bool f = true;
  char prev = 'X';
  for (int i = 0; i < 5; i++) {
    if (prev == s[i]) {
      f = false;
    }
    prev = s[i];
  }
  printf("%s\n", (f ? "Good" : "Bad"));
  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

long long int pow2(int num){
	long long int ret = 1;
	for(int i = 0; i < num; i++){
		ret *= 2;
		ret %= 1000000007;
	}
	return ret;
}

int sum[200000];

int main(){
	
	long long int N;
	
	cin >> N;
	
	for(int i = 0; i < N; i++){
		sum[i] = 0;
	}
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		sum[num]++;
	}
	
	bool flag = true;
	
	if(N % 2 == 0){
		for(int i = 1; i < N; i += 2){
			if(sum[i] != 2){
				flag = false;
			}
		}
	}else{
		if(sum[0] != 1){
			flag = false;
		}
		for(int i = 2; i < N; i += 2){
			if(sum[i] != 2){
				flag = false;
			}
		}
	}
	
	if(flag){
		cout << pow2(N / 2) << endl;
	}else{
		cout << "0" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 768
// author: erray
#include<bits/stdc++.h>
 
using namespace std;
 
int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = LLONG_MAX;
  long long suf = accumulate(a.begin(), a.end(), 0LL);
  long long pref = 0;
  for (auto el : a) {
    suf -= el;
    pref += el;
    ans = min(ans, abs(pref - suf));
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3672
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

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

    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int last = -1;
    bool ok = true;
    REP(i, n) {
        if (last < a[i]) {
            last = a[i] - 1;
        } else if (last == a[i]) {
            last = a[i];
        } else {
            ok = false;
        }
    }
    cout << ( ok ? "Yes" : "No" ) << endl;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin>>N;

  LL cnt = 0;

  LL start_b = 0;
  LL end_a = 0;
  LL both = 0;

  REP(i,N){
    string s;
    cin >> s;
    REP(j,s.size()-1){
      if(s[j]=='A'&&s[j+1]=='B'){
        cnt++;
      }
    }
    if(s[0]=='B'&&s[s.size()-1]=='A'){
      both++;
    }else
    if(s[0]=='B'){
      start_b++;
    }else
    if(s[s.size()-1]=='A'){
      end_a++;
    }
  }

  if(start_b>=1&&end_a>=1){
    start_b--;
    end_a--;
    cnt += both+1;
    both = 0;
  }else
  if(start_b>=1){
    cnt += both;
    start_b--;
  }
  else if (end_a >= 1)
  {
    cnt += both;
    end_a--;
  }
  else
  {
    if(both>=1){
    cnt += both - 1;
    }
  }
  cnt += min(end_a, start_b);

  cout << cnt << endl;
}


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

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

    int ans = 999999999;
    for (int i = 0; i < s.size()-3+1; i++) {
        int num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
        ans = min(ans, abs(num - 753));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
//using fs = unordered_set;
//#define fs set//unordered_set
vector<ll> S(0);

ll FFi(ll i){
    if(S[i]==i)return i;
    return S[i]=FFi(S[i]);
    
}

void marge(ll a,ll b){
    ll aa=FFi(a),bb=FFi(b);
    if(aa==bb)return;
    ll mms = (aa<bb)?aa:bb;
    S[aa]=mms;
    S[bb]=mms;
}


int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> A(N);
    for(ll i=0;i<N;i++)S.push_back(i);
    for(ll i=0;i<M;i++){
        ll sub1,sub2;
        cin >> sub1 >> sub2;
        marge(sub1-1, sub2-1);
     
        
    }
   
    vector<ll> CO(N,0);
    for(ll i:S){
        CO[FFi(i)]++;
    }
    sort(CO.begin(), CO.end(), [](ll a,ll b){return a>b;});
    
    cout << CO[0] << endl;
    
    
}



Measured memory_bytes: 11064
#include <bits/stdc++.h>
using namespace std;
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;
}
 
 
int main() { 
    int h, w, start_y, start_x, goal_y, goal_x;
    cin >> h >> w >> start_y >> start_x >> goal_y >> goal_x;
    start_y--;
    start_x--;
    goal_y--;
    goal_x--;
    vector<vector<char>> s(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s.at(i).at(j);
        }
    }

    deque<vector<int64_t>> que;
    que.emplace_back(vector<int64_t>{start_y, start_x, 0});
    vector<vector<int64_t>> x(h, vector<int64_t>(w, INT64_MAX));
    while (!que.empty()) { 
        vector<int64_t> cur = que.front();
        que.pop_front(); 
        int64_t cur_y = cur.at(0);
        int64_t cur_x = cur.at(1);
        int64_t cnt = cur.at(2);
        chmin(x.at(cur_y).at(cur_x), cnt);
        for (int i = -2; i < 3; i++) {
            for (int j = -2; j < 3; j++) {
                int64_t next_y = cur_y + i;
                int64_t next_x = cur_x + j;
                if (next_y < 0 || h <= next_y || next_x < 0 || w <= next_x) {
                    continue;
                }
                if (s.at(next_y).at(next_x) == '#') {
                    continue;
                }
                int64_t next_cnt = cnt;
                bool magic = false;
                // if (cur_y == 0 && cur_x == 0 && i == 0 && j == 1) {
                //     cout << "!!!" << abs(i) + abs(j) << endl;
                // }
                if (abs(i) + abs(j) >= 2) {
                    magic = true;
                }
                if (magic) {
                    next_cnt++;
                }
                if (x.at(next_y).at(next_x) <= next_cnt) {
                    continue;
                }
                vector<int64_t> next = {next_y, next_x, next_cnt};
                // if (cur_y == 0 && cur_x == 0) {
                //     cout << next_y << " " << next_x << " " << next_cnt << endl;
                // }
                if (magic) {
                    que.emplace_back(next);
                }
                else {
                    que.emplace_front(next);
                }
            }
        }
    }
    int64_t ans = x.at(goal_y).at(goal_x);
    if (ans == INT64_MAX) {
        ans = -1;
    }
    cout << ans << endl;

    // for (int i = 0; i < h; i++) {
    //     for (int j = 0; j < w; j++) {
    //         cout << x.at(i).at(j) << " ";
    //     }
    //     cout << endl;
    // }
    // return 0;
}

Measured memory_bytes: 33980
/*
    Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth;

Then took the other, as just as fair,
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that the passing there
Had worn them really about the same,

And both that morning equally lay
In leaves no step had trodden black.
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.

I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I—
I took the one less traveled by,
And that has made all the difference.
*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld long double
map<ll , ll>M;

int main()
{
    int n;
    cin >> n;
    string x , y;
    cin >> x >> y;
    ll i = 0;

    while(i < x.size())
    {
        cout << x[i] << y[i];
        i++;
    }
}


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

int main() {

  int N,K;
  cin >> N >> K;

  vector<int> A(N+1);
  for(int i = 0;i < N;i++) cin >> A[i];

  int limit = min(K,100);
  

  for(int i = 0;i < limit;i++) {

    vector<int> B(N+1);
    
    for(int j = 0;j < N;j++) {
      int l = max(0,j-A[j]);
      int r = min(N,j+A[j]+1);
      B[l]++; B[r]--;
    }

    for(int j = 0;j < N;j++) {
      B[j+1] += B[j];
      A[j] = B[j];
    }

  }

  for(int i = 0;i < N;i++) cout << A[i] << " ";
  cout << endl;

  

}


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

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

typedef long long ll;

using namespace std;

const int INF = 1 << 30;

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  vector<int> b(n);
  int aMax = 0;
  rep(i, n) {
    int aa, bb;
    cin >> aa >> bb;
    aMax = max(aMax, aa);
    a.at(i) = aa;
    b.at(i) = bb;
  }

  // dp[i] 体力を i 削るときの最小の消費魔力
  int hh = h + aMax;
  vector<int> dp(hh, INF);
  dp.at(0) = 0;

  for (int i = 0; i < hh; i++) {
    for (int j = 0; j < n; j++) {
      int aa = a.at(j);
      int bb = b.at(j);
//      // 貰うDP
//      if (i - aa >= 0) {
//        chmin(dp.at(i), dp.at(i - aa) + bb);
//      }
      // 配るDP
      if (i + aa < hh) {
        chmin(dp.at(i + aa), dp.at(i) + bb);
      }
    }
  }
  int res = INF;
  for (int i = h; i < hh; i++) {
    chmin(res, dp.at(i));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  string ans;
  cin >> a >> b >> c >> d;
  if(a+b>c+d)ans="Left";
  else if(a+b<c+d)ans="Right";
  else ans="Balanced";
  cout << ans << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 505;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int n, p[N * N], a[N][N], dist[N][N], ans;

void dfs(int x, int y) {
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx >= 1 && nx <= n && ny >= 1 && ny <= n && dist[nx][ny] > dist[x][y] + a[nx][ny]) {
			dist[nx][ny] = dist[x][y] + a[nx][ny];
			dfs(nx, ny);
		}
	}
}

int main() {
	read(n);
	for (int i = 1; i <= n * n; ++i) {
		read(p[i]);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			a[i][j] = 1;
			dist[i][j] = std::min({i, j, n - i + 1, n - j + 1});
		}
	}
	int ans = 0;
	for (int i = 1; i <= n * n; ++i) {
		int x = (p[i] - 1) / n + 1, y = (p[i] - 1) % n + 1;
		--dist[x][y], a[x][y] = 0;
		ans += dist[x][y];
		dfs(x, y);
	}
	print(ans);
}


Measured memory_bytes: 27040
S = str(input())
atcg = "ATCG"
count = 0
count_max = 0
for x in S:
    if x in atcg:
        count += 1
    else:
        if count_max <= count:
            count_max = count
        count = 0

if count_max <= count:
    count_max = count

print(count_max)

Measured memory_bytes: 3060
#include <stdio.h>

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

    int count = 0;
    for (int n = a; n <= b; n++) {
        if (c % n == 0) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


const int lim = 1e18;

void solve()
{
    int n;
    cin >> n;
    
    int r1 = 1,r2 = 1;
    int x;
    
    while(n--)
    {
        cin >> x;
        
        r1 = (r1*x)%MOD;
        r2*=x;
    }
    
    int r3 = (r2%MOD);
    
    if(r3 != r1) r2 = -1;
    
    if(r2 > lim) r2 = -1;
    
    cout << r2;
}

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

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

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

	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}

	if(a > c){
		tmp = a;
		a = c;
		c = tmp;
	}

	if(b > c){
		tmp = b;
		b = c;
		c = tmp;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 3072
n,k = map(int, input().split())
a = []
for i in range(1,n+1):
    a.append(i)
b = [0] * n
for i in range(k):
    d = int(input())
    c  = list(input().split())
    for j in range(d):
        b[int(c[j])-1] +=1

ans = b.count(0)
print(ans)

Measured memory_bytes: 9148
#include <cstdio>
#include <cstring>
#include <algorithm>
const int maxn = 1e5+7;
char s[maxn], t[maxn];
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n%m); }
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s%s", s, t);
    int d = gcd(n, m);
    bool flag = true;
    for (int i = 0; i < d; i++) {
        if (s[i *(n/d)] != t[i * (m/d)])
            flag = false;
    }
    if (flag) printf("%lld\n", 1ll*n*m/d);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 384
tab = ('a'..'z').to_a
while sen = gets do
  26.times do
    if sen.include?('the') or sen.include?('this') or sen.include?('that')
      puts sen
      break
    end

    sen.length.times do |i|
      next if sen[i] !~ /[a-z]/
      index = (tab.index(sen[i]) + 1)%26
      sen[i] = tab[index]
    end
  end
end

Measured memory_bytes: 6104
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b)
{
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll b, c, n;
    string ans;
    cin >> n;
    ll a[n];
    c = 0;
    for(ll i = 0; i < n; i++){
         cin >> a[i];
         c += a[i];
    }
    b = 0;
    ll x = n / 3;
    sort(a,a+n);
    if(c == 0);
    else if(n%3 != 0)b++;
    else for(ll i = 0; i < x; i++){
        
        if(((a[i]^a[i+x])^a[i + 2*x]) == 0 && a[0] == a[i] && a[x] == a[i+x] && a[2*x] == a[i + 2*x]);else b++;
    }
    if(b==0)ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, p;
  cin >> n >> p;

  string s;
  cin >> s;

  if (p == 2 || p == 5) {
    ll ans = 0;
    for (ll i = n-1; i >= 0; --i) {
      if ((s[i]-'0') % p == 0) {
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<ll> sum(n+1);
  ll ten = 1;
  for (ll i = n-1; i >= 0; --i) {
    ll a = ((s[i]-'0') * ten) % p;
    sum[i] = (sum[i+1] + a) % p;
    ten = (ten * 10) % p;
  }

  vector<ll> cnt(p);
  ll ans = 0;
  for (ll i = n; i >= 0; --i) {
    ans += cnt[sum[i]];
    cnt[sum[i]]++;
  }

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

Measured memory_bytes: 2180
#include<stdio.h>
int main(){
	long long sum=0,min,max;
    long  long n,i;
    scanf("%lld",&n);
	long long a[n];
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
    max=a[0];
    min=a[0];
	for(i=0;i<n;i++){
		sum+=a[i];
		if(max<=a[i])max=a[i];
		if(min>=a[i])min=a[i];
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int X;
  cin >> X;

  int ans = 1;
  FORS(i, 2, X) {
    int p = 2;
    while (1) {
      int val = (int)pow(i, p);
      if (val > X)
        break;
      else {
        chmax(ans, val);
        p++;
      }
    }
  }
  print(ans);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define D 365
typedef long long ll;
ll calcSat(int *tmpt, int s[][26], int *c) {
	int last[26] = {0};
	ll tmpSat = 0;
	for (int i = 0; i < D; i++) {
		tmpSat += s[i][tmpt[i] - 1];
		last[tmpt[i] - 1] = i + 1;
		for (int j = 0; j < 26; j++) {
			tmpSat -= (c[j] * (i + 1 - last[j]));
		}
		/**
		printf("%lld\n", tmpSat);
		/**/
	}
	return tmpSat;
}
int main() {
	srand(314159);
	scanf("%*d");
	int c[26], s[D][26];
	int t[D] = {0};
	ll bestSat = 0;
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	/**/
	for (int i = 0; i < D; i++) {
		t[i] = rand() % 26 + 1;
		bestSat = calcSat(t, s, c);
	}
	/**/

	for (int cnt = 0; cnt < 200000; cnt++) {
		int tmpt[D];
		int pos = rand() % D;
		for (int i = 0; i < D; i++) {
			tmpt[i] = t[i];
		}
		tmpt[pos] = rand() % 26 + 1;
		ll tmpSat = calcSat(tmpt, s, c);
		if (tmpSat > bestSat) {
			bestSat = tmpSat;
			t[pos] = tmpt[pos];
		}
	}
	// printf("%lld\n", bestSat);

	for (int i = 0; i < D; i++) {
		printf("%d\n", t[i]);
	}
	return 0;
}


Measured memory_bytes: 1760
#include<cstdio>
int main()
{
	long long d,n;
	scanf("%lld%lld",&d,&n);
	if  (n==100)    ++n;
	for (long long i=1;i<=d;++i)
		n*=100;
	printf("%lld\n",n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int MAX_N = 1e5 + 5; 
int N, C, K, a[MAX_N]; 
int ans = 1; 

int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	N = gi(), C = gi(), K = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi(); 
	sort(&a[1], &a[N + 1]); 
	for (int i = 1, lst = 1; i <= N; i++) 
		if (i - lst + 1 > C || a[lst] + K < a[i])
			lst = i, ans++;
	printf("%d\n", ans); 
    return 0; 
} 

Measured memory_bytes: 4140
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    if(a[i]==i+1) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string a, b; cin >> a >> b;
  int num = stoi(a+b);
  if(sqrt(num) == (int)sqrt(num)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
	int N,K;
	cin >> N >> K;
	for(int i = 0; i < K; i++){
		int t1,t2,t3,t4,ans;
		cin >> t4 >> t3;
		if(t4> N/2) t4 = N+1-t4;
		if(t3 > N/2) t3 =N+1-t3;
		t1 = max(t4, t3);
		t2 = min(t4, t3);
		ans = t2%3;
		if(ans == 0)ans = 3;
		cout << ans<< endl;
	}
	return 0;
}


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

int main()
{
  char a[11],b[11],c[11];
  int res=0;
  cin >> a>>b>>c;

  if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0]) cout << "YES" << endl;
  else cout << "NO"<<endl;
}


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

using namespace std;

int N;
string S;
int K;

int main()
{
	cin >> N >> S >> K;
	for (int i=0; i<S.length(); i++) if (S[i]!=S[K-1]) S[i]='*';
	cout << S;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int f[M];

int binpow(int a, int b){
    int res = 1;
    while (b){
        if (b&1){
            res = 1ll * res * a % MOD;
        }
        a = 1ll * a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main(){
    f[0] = 1;
    for (int i = 1; i < M; i++){
        f[i] = 1ll * f[i-1] * i % MOD;
    }
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if ((x+y)%3){
        cout << 0;
        return 0;
    }
    int n = (x + y) / 3;
    if (min(x, y) < n){
        cout << 0;
        return 0;
    }
    int k = min(x, y) - n;
    int ans = 1ll * f[n] * binpow(f[k], MOD-2) % MOD;
    ans = 1ll * ans * binpow(f[n-k], MOD-2) % MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 4224
r,c = map(int, input().split())
matrix = []
for i in range(r):
    a = list(map(int, input().split()))
    sum = 0
    for j in range(c):
        sum += a[j]
    a.append(sum)
    matrix.append(a)
    for k in range(c+1):
        print(a[k], end = "")
        if k != c:
            print(" ", end = "")
    print()
for l in range(c+1):
    sum2 = 0
    for m in range(r):
        sum2 += matrix[m][l]
    print(sum2, end = "")
    if l != c:
        print(" ", end = "")
print()



Measured memory_bytes: 5740
def floor_pow2(n):
    res = 0
    while 2**res <= n:
        res += 1
    return res-1

n = int(input())
n -= 1

if n <= 3:
    N = 2
    M = n+1
    print(N, M)
    for i in range(M):
        print(1, 2, i)
    exit(0)

# output
N = floor_pow2(n) + 1
M = 0

# G[i] = [to, len]
G = [[] for i in range(N)]

for i in range(1,N,1):
    G[i].append([i-1, 2**(i-1)])
    G[i].append([i-1, 0])
    M += 2

bias = 2 ** (N - 1)
u = n - bias

while True:
    if u <= 1:
        G[-1].append([u, bias])
        M += 1
        break

    tu = floor_pow2(u)
    G[-1].append([tu, bias])
    bias += 2 ** tu
    u -= 2 ** tu
    M += 1

print(N, M)
for ix, es in enumerate(G):
    for e in es:
        print(N-ix, N-e[0], e[1])


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,m,x;cin >>n>>m>>x;
    vector<ll>a(m);ll cnt=0;
    ll ans=0;
    for (int i = 0; i < m; ++i) {
        cin >>a[i];
        if(a[i]>x)cnt++;
        else ans++;
    }
    cnt=min(ans,cnt);
    cout <<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256