akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int N = sc.nextInt();

        if (N == 1) {
            System.out.println("1");
            sc.close();
            return;
        }

        int max2 = 1;

        while (max2 < N) {
            max2 *= 2;
        }
        max2 /= 2;

        int count = 1;
        while (max2 <= N) {
            max2 *= count;
            count++;
        }
        max2 /= --count;

        System.out.println(max2);
        sc.close();
    }
}

Measured memory_bytes: 35752
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================
//using系

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using Graph = vvi;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
using kaage = priority_queue<int, vector<int>, greater<int>>;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;

// ========================================================================
//define系

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

// ========================================================================


ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 


// ========================================================================


//ある程度のテンプレ
//これとBFS、あとその時その時で使うものはここに書く


// ========================================================================


/*signed*/int main() {
	ll n, a, b; cin >> n >> a >> b;
	if (a % 2 == b % 2) cout << abs(a - b) / 2 << endl;
	else {
		cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
	}

	return 0;
}

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

int main(){
  int n, u, k, v;
  cin >> n;
  int A[n * n];

  for(int i = 0; i < n * n; i++)
    A[i] = 0;

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    while(k--){
      cin >> v;
      A[(u - 1) * n + (v - 1)] = true;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j) cout << " ";
      cout << A[i * n + j];
    }
    cout << endl;
  }
}

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

int main() {
  int x1, x2, y1, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  const auto x3 = x2 + y1 - y2;
  const auto y3 = y2 + x2 - x1;
  std::cout << x3 << " " << y3 << " "
    << x3 + y2 - y3 << " " << y3 + x3 - x2 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.14159265358979
#define coutdb cout<<fixed<<setprecision(30)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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 pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, M, A[100000]; cin >> N >> M;
  REP(i, N) cin >> A[i];
  int imos[200010] = {};
  REP(i, N-1){
    if(A[i] < A[i+1]){
      imos[A[i]+1]++; imos[A[i+1]]--;
    } else {
      imos[A[i]+1]++; imos[A[i+1]+M]--;
    }
  }
  REP(i, 2*M+1) imos[i+1] += imos[i];
  umap<int, int> mp;
  int cnt = 0;
  REP(i, N-1){
    mp[A[i+1]] += (A[i+1]+M-A[i]) % M - 1;
    if(A[i] < A[i+1]) cnt += A[i+1]-A[i];
    else cnt += 1 + A[i+1]-1;
  }
  // cerr << cnt << endl;
  int ans = cnt;
  for(int x = 1; x < M; x++){
    cnt -= imos[x]+imos[x+M];
    cnt += mp[x];
    // cerr << cnt << endl;
    chmin(ans, cnt);
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

int N, M, L;
int G[101][101];

struct BM
{
  vector< vector<int> > graph;
  vector<int> matched;
  vector<bool> used;
  BM(int V):graph(V), matched(V, -1), used(V, false){}
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  bool dfs(int u)
  {
    used[u] = true;
    for(auto& v : graph[u]) {
      int w = matched[v];
      if(w < 0 || !used[w] && dfs(w)) {
	matched[u] = v;
	matched[v] = u;
	return true;
      }
    }
    return false;
  }
  int match()
  {
    int res = 0;
    for(int u = 0; u < graph.size(); u++) {
      if(matched[u] < 0) {
	used.clear(); used.resize(graph.size(), false);
	if(dfs(u)) res++;
      }
    }
    return res;
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N >> M >> L, N) {
    rep(i, 101) rep(j, 101) G[i][j] = (i == j ? 0 : inf);
    rep(i, M) {
      int u, v, d;
      cin >> u >> v >> d;
      G[u][v] = G[v][u] = d;
    }
    rep(i, N) rep(j, N) rep(k, N) {
      G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
    }
    vector<int> p(L), t(L);
    rep(i, L) cin >> p[i] >> t[i];
    BM bm(2*L);
    rep(i, L) rep(j, L) if(i != j) {
      if(t[i] + G[p[i]][p[j]] <= t[j]) bm.add_edge(i, j + L);
    }
    cout << L - bm.match() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 13820
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
int main(){
	int a; cin>>a;
	int sayi2;
	int count = 0, maxx = 0;
	forloop(a){
		int sayi; cin>>sayi;
		if(i > 0 && sayi <= sayi2){
			count++;
          if(i == a-1){
            maxx = max(count, maxx);
          }
		}else{
			maxx = max(count, maxx);
			count = 0;
		}
		sayi2 = sayi;
	}
	cout<<maxx;
	return 0;
}


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

using namespace std;

//#define FILE_IO

int N, M, Q;
char a[2005][2005];

class MatrixSum
{
public:
    int a[2005][2005];

    void initSum()
    {
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++)
                a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
    }

    int get(int xa, int ya, int xb, int yb)
    {
        if(xa > xb || ya > yb)  return 0;
        return a[xb][yb] - a[xa - 1][yb] - a[xb][ya - 1] + a[xa - 1][ya - 1];
    }
};
MatrixSum sum, lin, col;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d%d\n", &N, &M, &Q);
    for(int i = 1; i <= N; i++)
        scanf("%s", a[i] + 1);

    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= M; j++)
        {
            sum.a[i][j] = a[i][j] == '1';
            lin.a[i][j] = (a[i][j] == '1' && a[i][j - 1] == '1');
            col.a[i][j] = (a[i][j] == '1' && a[i - 1][j] == '1');
        }

    sum.initSum(); lin.initSum(); col.initSum();

    for(int i = 1; i <= Q; i++)
    {
        int xa, ya, xb, yb;
        scanf("%d%d%d%d", &xa, &ya, &xb, &yb);

        //cerr << sum.get(xa, ya, xb, yb) << " ";
        //cerr << lin.get(xa, ya + 1, xb, yb) << " ";
        //cerr << col.get(xa + 1, ya, xb, yb) << "\n";

        int ans = sum.get(xa, ya, xb, yb) - lin.get(xa, ya + 1, xb, yb) - col.get(xa + 1, ya, xb, yb);
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 52864
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){
    long long int in = 0;
    vector<long long int> inList;
    long long int b;

    while(cin >>b && b){
      ll t = 1,s=1;
      long long int sum = 0;
      while(1){
      if(sum < b){
        sum += t;
        t++;
      }else if(sum > b){
        sum -= s;
        s++;
      }else{
        cout <<s<<" "<<t-s<<endl;
        break;
      }
      }

    }

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/


Measured memory_bytes: 3036
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 1e9 + 7;
ll dp[2005]; 
vll divs;
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
int main(){
	ll n, k; cin >> n >> k;
	for (ll i = 1; i <= sqrt(n); i++){
		if (i == sqrt(n)){
			if (i * i == n) divs.pb(i);
		}
		else if (n % i == 0){
			divs.pb(i); divs.pb(n / i);
		}
	}
	sort(divs.begin(), divs.end());
	for (ll i = 0; i < divs.size(); i++){
		dp[i] = binpow(k, (divs[i] + 1) / 2);
		for (ll j = 0; j < i; j++){
			if (divs[i] % divs[j] == 0) (dp[i] += (mod - dp[j])) %= mod;
		}
 	}
 	ll ans = 0;
 	for (ll i = 0; i < divs.size(); i++){
 		if (divs[i] % 2) (ans += (divs[i] * dp[i])) %= mod;
 		else (ans += (divs[i] / 2 * dp[i])) %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    int s;
    cin >> s;
    vi dp(s + 1, 0);
    dp[0] = 1;
    dp[1] = 0;
    dp[2] = 0;

    rep(i, 3, s + 1) {
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= mod;
    }

    print(dp[s]);
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    ll count = 0;
    rep(i, 3) {
        if (s[i] == 'R') {
            count++;
        } else {
            count = 0;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3592
//12
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    string s[2];
    int sum=0;
    for(int i=0;i<2;i++){
      cin>>s[i];
      int f=1;
      for(int j=0;j<s[i].size();j++){
	if(isdigit(s[i][j])){
	  f=s[i][j]-'0';
	}else{
	  int t[128];
	  t['m']=1000;
	  t['c']=100;
	  t['x']=10;
	  t['i']=1;
	  sum+=f*t[s[i][j]];
	  f=1;
	}
      }
    }
    for(int i=0;i<4;i++){
      int d[]={1000,100,10,1};
      const char *s="mcxi";
      if(sum/d[i]){
	if(sum/d[i]>1){
	  cout<<sum/d[i];
	}
	cout<<s[i];
      }
      sum%=d[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int n,k;
    int a[100000],dp[100000];

    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    int x;
    int min=999999999;
    int cnt=0;
    for(int i=2;i<n;i++){
        min=999999999;
        for(int j=i-1,cnt=0;cnt<k&&j>=0;cnt++,j--){
            x=dp[j]+abs(a[i]-a[j]);
            if(min>x)min=x;
        }
        dp[i]=min;
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	inc(i, 8) { s.pop_back(); }
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll; 
#define me(a,b) memset(a,b,sizeof(a))
char s[300];
int main()
{
	int n,i,j,a;
	cin>>n;
	int w=0;
	while(n--)
	{
		cin>>a;
		if(a%2==0)
		if(a%3!=0&&a%5!=0)
		{
			w=1;break;
		}
	}
	if(w==1)cout<<"DENIED";
	else cout<<"APPROVED";
	return 0;
	
}

Measured memory_bytes: 256
a,b = map(int,input().split())

s = input()

ans = 0

if s[a]=='-':
	for i in range(a):
		#print(s[i])
		if s[i]== '-':
			ans = ans + 1
			#print('check'+s[i])
	for j in range(b):
		#print(s[a+j+1])
		if s[a+j+1]=='-':
			ans = ans + 1
			#print('check'+s[a+j])
else:
	ans = ans + 1
	
print('Yes' if ans==0 else 'No')

	


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

void edit(int list[], int i);

int main() {
	// your code goes here
	int n, col, count;
	int *list;
	
	while(cin >> n, n != 0){
		count = 0;
		list = new int[n];
		
		for(int i=0; i<n; i++){
			cin >> col;
			if(i%2 == 0){
				list[i] = col;
			}
			else{
				if(list[i-1] == col) list[i] = col;
				else{
					list[i] = col;
					edit(list, i);
				}
			}
		}
		
		for(int i=0; i<n; i++){
			if(list[i] == 0) count++;
		}
		cout << count << endl;
		
		delete [] list;
	}
	return 0;
}

void edit(int list[], int i)
{
	int col = list[i];
	for(int j=1; j<=i; j++){
		if(list[i-j] != col) list[i-j] = col;
		else break;
	}
}

Measured memory_bytes: 1532
N = int(input())

cake = 4
donut = 7
flg = False

for cake_num in range(N // cake + 1):
    for donut_num in range(N // donut + 1):
        sum = cake * cake_num + donut * donut_num

        if sum == N:
            flg = True

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-


def is_runrun(n):
    str_n = str(n)
    for i, s in enumerate(str_n):
        if i < len(str_n) - 1:
            if abs(int(s) - int(str_n[i + 1])) > 1:
                return False

    return True


def main():
    k = int(input())

    i = 0
    keta = 1
    created = {}
    count = 0
    while True:
        before_runruns = created.get(keta - 1, [])
        now_runruns = created.get(keta, [])

        if keta == 1:
            now_runruns.append(str(i))

            if str(i) != "0":
                count += 1
                if count == k:
                    return str(i)

        for runrun in before_runruns:
            if abs(int(str(runrun)[0]) - i) <= 1:
                now_runruns.append(str(i) + str(runrun))

                if str(i) != "0":
                    count += 1
                    if count == k:
                        return str(i) + str(runrun)

        created[keta] = now_runruns

        if i == 9:
            keta += 1
            i = 0
        else:
            i += 1


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 10852
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
  int n,m,count=0,r;cin>>n>>m;
  int a[n],sum=0;
  for(int i=0;i<n;i++)cin>>a[i],sum+=a[i];
  if(sum%(4*m)==0)
   r=sum/(4*m);
  else r=1+(sum/(4*m));
  sort(a,a+n,greater<int>());
  for(int i=0;i<n;i++)
  {if(a[i]>=r)count++;
   if(count==m)return cout<<"Yes",0;
  }
  cout<<"No";
 
           return 0;
}

Measured memory_bytes: 256
package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const INF = 1000000000

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.Next2Ints()
  g := NewGraph(n+2*m)
  st := make([]map[int]int,n)
  for i:=0;i<n;i++ { st[i] = make(map[int]int) }
  k := n
  for i:=0;i<m;i++ {
    p,q,c := input.Next3Ints()
    p,q = p-1,q-1
    x,pok := st[p][c]
    y,qok := st[q][c]
    if !pok { x = k;st[p][c] = x;k++ }
    if !qok { y = k;st[q][c] = y;k++ }
    g.Add(x,y,0)
    g.Add(y,x,0)
    g.Add(x,p,0)
    g.Add(p,y,1)
    g.Add(y,q,0)
    g.Add(q,x,1)
  }
  c := g.Dijkstra(0)
  if c[n-1] == INF { c[n-1] = -1 }
  fmt.Println(c[n-1])
}

type Item struct { pos,cost,idx int }
type PriorityQueue []*Item
func(pq PriorityQueue) Len() int { return len(pq) }
func(pq PriorityQueue) Less(i,j int) bool { return pq[i].cost < pq[j].cost }
func(pq PriorityQueue) Swap(i,j int) {
  pq[i],pq[j] = pq[j],pq[i]
  pq[i].idx,pq[j].idx = i,j
}
func(pq *PriorityQueue) Push(x interface{}) {
  n := len(*pq)
  item := x.(*Item)
  item.idx = n
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  item.idx = -1
  *pq = old[0:n-1]
  return item
}

type Edge struct { to,cost int }
type Graph [][]Edge
func NewGraph(n int) Graph { return make([][]Edge,n) }
func(g Graph) AddEdge(from int,e Edge) { g[from] = append(g[from],e) }
func(g Graph) Add(from,to,c int) { g.AddEdge(from,Edge{to,c}) }
func(g Graph) Dijkstra(start int) []int {
  n := len(g)
  c := make([]int,n)
  for i:=0;i<n;i++ { c[i] = INF }
  var pq PriorityQueue
  heap.Init(&pq)
  heap.Push(&pq,&Item{pos:start,cost:0})
  c[start] = 0
  for pq.Len() > 0 {
    s := heap.Pop(&pq).(*Item)
    if s.cost > c[s.pos] { continue }
    for _,e := range g[s.pos] {
      if c[e.to] > s.cost+e.cost {
        c[e.to] = s.cost+e.cost
        heap.Push(&pq,&Item{pos:e.to,cost:c[e.to]})
      }
    }
  }
  return c
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) Next2Ints() (int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) Next3Ints() (int,int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}

Measured memory_bytes: 102784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();


	int c=a*b;
	if(c%2==0){
		System.out.println("No");
	}else{
		System.out.println("Yes");
	}


	}}

Measured memory_bytes: 22356
#include"bits/stdc++.h"
#include"math.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  int c=0;
  rep(i,n){ b[i]=a[i]%2;c+=b[i];}
  if(c%2==0)cout << "YES" << endl;
  else cout << "NO" << endl;}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

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

void solve() {
    double h, a;
    cin >> h >> a;
    // int a[N];
    // for (int i=1; i <= n; i++) { 
    //     cin >> a[i];
    // }

    cout << int(ceil(h/a)) << '\n';
}


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

using namespace std;

int main(){
    long long int N,ans=1;
    cin >> N;
    vector<long long int> A(N),sum(N+1,0);
    sum[0] = 3;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    for(int i=0;i<N;i++){
        ans *= sum[A[i]];
        ans %= 1000000007;
        sum[A[i]]--;
        sum[A[i]+1]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define comb(x) ((x * (x + 1)) >> 1)
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, k, a[200007], b[200007], tmp, L, R, mid;


int main () {
    fastIO
    cin >> n >> k;
    for(li i = 0; i < n; i ++) cin >> a[i];
    for(li i = 0; i < n; i ++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);
    L = 0; R = 1000000000007;
    while(R - L > 0) {
        mid = (L + R) >> 1;
        tmp = k;
        for(li i = 0; i < n; i ++) {
            if(a[i] * b[i] > mid) {
                tmp -= (a[i] * b[i] - mid + b[i] - 1) / b[i];
            }
        }

        if(tmp < 0) L = mid + 1;
        else R = mid;
    }

    cout << L;
}


Measured memory_bytes: 3328
/**
*    created: 05.07.2020 20:41:42
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    cin >> n;
    if(n%1000!=0)
        cout << 1000-n%1000 << endl;
    else
    {
        cout << 0 << endl;
    }
    
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string n;
	int k;
	cin>>n;
	cin>>k;
	n = "0" + n;
	
	long long d[112][2][10];
	
	for (int i = 0; i < n.size(); i++)
	for (int eq = 0; eq <= 1; eq++)
	for (int t = 0; t <= k; t++)
		d[i][eq][t] = 0;
	
	
	d[0][1][0] = 1;
		
	for (int i = 1; i < n.size(); i++)
	for (int iseq = 0; iseq <= 1; iseq++)
	for (int cnt = 0; cnt <= k; cnt++) {
		d[i][iseq][cnt] = 0;
		
		if (iseq == 1) {
			d[i][iseq][cnt] += (cnt - (n[i] != '0') >= 0) * d[i - 1][1][cnt - (n[i] != '0')];
			continue;
		}
		
		for (int ch = 0; ch <= 9; ch++) {
			d[i][iseq][cnt] += (cnt >= (ch != 0)) * (d[i - 1][0][cnt - (ch != 0)] + ('0' + ch < n[i]) * d[i - 1][1][cnt - (ch != 0)]);
		}
	}
	long long res = d[n.size() - 1][1][k] + d[n.size() - 1][0][k];
	cout<<res<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    string N;
    cin >> N;

    if (N[0] == '9' || N[1] == '9')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    int N;
    cin >> N;
    VL A(N);
    REP(i, N) cin >> A[i];

    LL ans = 0;
    FOR(i, 1, N) {
        if (A[i - 1] > A[i]) {
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }

    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 4764
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] d = new int[6];
		int n = scan.nextInt();
		Dice[] dices = new Dice[n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 6; j++){
				d[j] = scan.nextInt();
			}
			dices[i] = new Dice(d);
		}

		boolean flag = false;
		boolean ans = true;
		for(int i = 0; i < n - 1; i++){
			for(int j = i + 1; j < n; j++){
				flag = dices[i].equals(dices[j]);
				if(flag == true){
					ans = false;
					break;
				}
			}
		}
		System.out.println(ans? "Yes" : "No");
	}
}

class Dice{
	int[] d_ = new int[6];
	public static final int
		TOP = 0, SOUTH = 1, EAST = 2,
		WEST = 3, NORTH = 4, BOTTOM = 5;

	public Dice(int[] d){
		for(int i = 0; i < 6; i++){
			d_[i] = d[i];
		}
	}

	@Override
	public boolean equals(Object obj){
		boolean result = false;
		Dice diceB = (Dice) obj;
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				result = Arrays.equals(this.d_, diceB.d_);
				if(result == true)break;
				diceB.rollEast();
			}
			for(int j = 0; j < 4; j++){
				result = Arrays.equals(this.d_, diceB.d_);
				if(result == true)break;
				diceB.rollSouth();
			}
			result = Arrays.equals(this.d_, diceB.d_);
			if(result == true)break;
			diceB.rollRight();
		}
		return result;
	}

	public void setTop(int num){
		if(num == d_[EAST]){
			this.rollWest();
		} else if(num == d_[WEST]){
			this.rollEast();
		} else if(num == d_[SOUTH]){
			this.rollNorth();
		} else if(num == d_[NORTH]){
			this.rollSouth();
		} else if(num == d_[BOTTOM]){
			this.rollEast();
			this.rollEast();
		}
	}

	public void setSouth(int num){
		if(num == d_[EAST]){
			this.rollRight();
			this.rollRight();
			this.rollRight();
		} else if(num == d_[WEST]){
			this.rollRight();
		} else if(num == d_[NORTH]){
			this.rollRight();
			this.rollRight();
		}
	}

	public int show(int side){
		return d_[side];
	}

	public void rollEast(){
		int work = d_[TOP];
		d_[TOP] = d_[WEST];
		d_[WEST] = d_[BOTTOM];
		d_[BOTTOM] = d_[EAST];
		d_[EAST] = work;
	}

	public void rollWest(){
		int work = d_[TOP];
		d_[TOP] = d_[EAST];
		d_[EAST] = d_[BOTTOM];
		d_[BOTTOM] = d_[WEST];
		d_[WEST] = work;
	}

	public void rollSouth(){
		int work = d_[TOP];
		d_[TOP] = d_[NORTH];
		d_[NORTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[SOUTH];
		d_[SOUTH] = work;
	}

	public void rollNorth(){
		int work = d_[TOP];
		d_[TOP] = d_[SOUTH];
		d_[SOUTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[NORTH];
		d_[NORTH] = work;
	}

	public void rollRight(){
		int work = d_[SOUTH];
		d_[SOUTH] = d_[WEST];
		d_[WEST] = d_[NORTH];
		d_[NORTH] = d_[EAST];
		d_[EAST] = work;
	}
}

Measured memory_bytes: 29176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>

#line 1 "lib/union_find.hpp"



#include <vector>

class UnionFind {
public:
    UnionFind(int n) : par(n, -1), ran(n, -1) {}

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;

        if (ran[x] < ran[y]) {
            par[find_root(y)] += par[find_root(x)];
            par[x] = y;
        }
        else {
            par[find_root(x)] += par[find_root(y)];
            par[y] = x;
            if (ran[x] == ran[y]) ran[x]++;
        }
    }

    int size(int x) {
        return -par[find_root(x)];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    int find_root(int x) {
        if (par[x] < 0) {
            return x;
        }
        else {
            return par[x] = find_root(par[x]);
        }
    }

private:
    std::vector<int> par, ran;
};


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> p(n + 2);
    for (int i = 1; i <= n; i++) std::cin >> p[i];
    UnionFind uf(n + 2);
    for (int i = 0; i < m; i++) {
        int x, y; std::cin >> x >> y;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += uf.same(i, p[i]);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 1408
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const ll mod = 1e9 + 7;

ll pwr(ll a, ll b);
    

const int A = 2e5+10;





int main(){
   IOS

   int n, a , b;

   cin>>n>>a>>b;

   ll x = (pwr(2, n) - 1 + mod) % mod;


    ll nca = 1ll;
   for(ll i = 1ll; i <= a; i++){
       nca *= (n-i+1)*pwr(i,mod-2)%mod, nca %= mod;
   }

    ll ncb = 1ll;
    for(ll i = 1ll; i <= b; i++){
        ncb *= (n-i+1)*pwr(i,mod-2)%mod, ncb %= mod;
    }

    cout<<(x-nca-ncb + 2*mod)%mod<<"\n";

}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
long long k[101][N];
int main() {
	int n, ww;
	cin>>n>>ww;
	vector<pair<int, int> >v;
	v.pb(mp(0, 0));
	for(int i = 0; i < n; i++ ){
		int a, b;
		cin>>a>>b;
		v.pb(mp(a, b));
	}
	for(int i = 1; i <= n; i++) {
		int w = v[i].x;
		for(int j = 1; j <= ww; j++) {
			long long a = 0, b = 0;
			a = max(k[i - 1][j], k[i][j - 1]);
			if(j >= w) {
				b = k[i - 1][j - w] + v[i].y;
			}
			k[i][j] = max(a, b);
		}
	}
	cout<<k[n][ww]<<endl;
}


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int s,g;
	s = max(a,c);
	g = min(b,d);
	cout << max(0,g-s) << endl;
		
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i = 0;i < n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int max = 0;
    for(auto x:mp){
        int v = x.second;
        if(max < v) max = v;
    }

    for(auto x = mp.begin();x != mp.end();x++){
        if(x->second == max) cout << x->first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);
	const int n = s[0];

	AtCoder::Str pyo;
	AtCoder::input(&pyo);
	AtCoder::exp(&pyo[0], &pyo);

	AtCoder::Ans* ans = new AtCoder::Ans();

	const int nbuf = n - 1;
	for (int i = 0; i < nbuf; i++) {
		if (pyo[i] != pyo[(i + 1)]) {
			ans->increment();
		}
	}

	ans->increment();

	ans->showResult();

	delete(ans);

	return 0;
}


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

Measured memory_bytes: 5928
#include<iostream>
#define long int int
using namespace std;
int32_t main()
{ string s;
string t;
cin >> s;
cin >> t;
int cnt=0;
for(int i=0; i<s.length(); i++)
{ if(s[i]==t[i])
{
    continue;
}

else{cnt++;}

}

    cout << cnt << endl;




}


Measured memory_bytes: 3916
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e5+9;
const ll maxx=1e12+9;

int n,k,ar[maxn];

inline int _ceil(int &a,int &b)
{
    int res=a/b;
    if(a%b==0&&res) res--;
    return res;
}
bool judge(int t)
{
    int cnt=0;
    for(int i=0;i<n;i++) cnt+=_ceil(ar[i],t);
    return cnt<=k;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&ar[i]);
    int ans=inf1;
    int l=1,r=inf1,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(judge(mid)) ans=min(ans,mid),r=mid-1;
        else l=mid+1;
    }
    printf("%d\n",ans);
}


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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long> F(N);
  for (int i = 0; i < N; i++) cin >> F.at(i);
  sort(A.begin(), A.end());
  sort(F.rbegin(), F.rend());
  long ok = 1e18, ng = -1;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      long sum = 0;
      for (int i = 0; i < N; i++) {
        sum += max(0L, A.at(i) - mid / F.at(i));
      }
      (sum <= K) ? ok = mid : ng = mid;
    }
  cout << ok << "\n";
}

Measured memory_bytes: 6336
#include<iostream>
#include<algorithm>
#define X first
#define Y second
using namespace std;
pair<int,int> z[6];
int main(){
	int a,b,t;
	for(int i=0;i<6;i++){
		cin>>a>>b;
		if(a>b)t=a,a=b,b=t;
		z[i].X=a,z[i].Y=b;
	}
	sort(z,z+6);
	bool ok=true;
	if(z[0]!=z[1]||z[2]!=z[3]||z[4]!=z[5])ok=false;
	if(z[0].X!=z[2].X||z[0].Y!=z[4].X||z[2].Y!=z[4].Y)ok=false;
	if(ok)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 3020
#include <iostream>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 10000

int n, M[N][N];


int prim(){
  int u, mincost;
  int color[N], d[N], p[N];
  for(int i = 0 ; i < n ; i++){
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }
  d[0] = 0;

  while(true){
    mincost = INFTY;
    u = -1;
    //TとV-Tをつなぐ辺の中で最小のものを探す
    for(int i = 0 ; i < n ; i++){
      if(color[i] != BLACK && d[i] < mincost ){
        mincost = d[i];
        u = i;
      }
    }
    if(u == -1){
      break;
    }
    color[u] = BLACK;

    //Tの中の各頂点からのV-Tの頂点への最短辺の長さをd[v]に入れる
    for(int v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(M[u][v] < d[v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }

  }
  int sum = 0;
  for(int i = 0 ; i < n ; i ++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }
  return sum;
}

int main(){
  cin >> n ;
  for(int i = 0; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY: e;
    }
  }
  //int sum = prim();
  cout << prim() << "\n";
  return 0;

}



Measured memory_bytes: 3092
#include <atcoder/all>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll digitcal(ll x){
  ll n=0;
  while(x>0){
    x/=10;
    n++;
  }
  return n;
}

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int op(int a,int b){
  return max(a,b);
}

int e(){
  return 0;
}

int main() {
  int n,k;
  cin>>n>>k;
  int a[n]; 
  segtree<int,op,e> seg(300010);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    int l=max(a[i]-k,0),r=min(a[i]+k+1,300010);
    int temp=seg.prod(l,r)+1;
    seg.set(a[i],temp);
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8600
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n,a,b,q,kl=0,l=0;
    cin >> n >> a >> b;
    q = a+b;
    string s;
    cin >> s;
    for ( auto i: s ) {
        if (i=='a') {
            if (kl<q) {kl++;cout << "Yes" << endl;}
            else {cout << "No" << endl;}
        }
        else if (i == 'b') {
            if (kl<q && l<b) {kl++;l++;cout << "Yes" << endl;}
            else {cout << "No" << endl;}
        }
        else {cout << "No" << endl;}
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int ans = 1e9;
	string s;
	cin>>s;
	int n = s.size();
	for(int i = 0;i < n; ++i)
	{
		s[i] -= '0';
	}
	for(int i = 0;i < n - 2; ++i)
	{
		int now = 100 * s[i] + 10 * s[i + 1] + s[i + 2];
		ans = min(ans,abs(753 - now));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256