akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


void solve1(int N, int K, string S){
    vector<int> Nums;
    int now = 1;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == (char)('0' + now)) cnt++;
        else{
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) Nums.push_back(cnt);
    if(Nums.size() % 2 == 0) Nums.push_back(0);
    int Add = 2 * K + 1;
    int ans = 0;
    for(int i = 0; i < Nums.size(); i += 2){
        int tmp = 0;
        int left = i;
        int right = min(i + Add, (int)Nums.size());
        for(int j = left; j < right; j++){
            tmp += Nums[j];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

void solve2(int N, int K, string S){
    vector<int> Nums;
    int now = 1;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == (char)('0' + now)) cnt++;
        else{
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) Nums.push_back(cnt);
    if(Nums.size() % 2 == 0) Nums.push_back(0);
    int Add = 2 * K + 1;
    int ans = 0;
    int left = 0;
    int right = 0;
    int tmp = 0;

    for(int i = 0; i < Nums.size(); i += 2){
        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());
        while(Nextleft > left){
            tmp -= Nums[left];
            left++;
        }
        while(Nextright > right){
            tmp += Nums[right];
            right++;
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

void solve3(int N, int K, string S){
    vector<int> Nums;
    int now = 1;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == (char)('0' + now)) cnt++;
        else{
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) Nums.push_back(cnt);
    if(Nums.size() % 2 == 0) Nums.push_back(0);
    int Add = 2 * K + 1;
    vector<int> sum(Nums.size() + 1);
    for(int i = 0; i < Nums.size(); i++){
        sum[i + 1] = sum[i] + Nums[i];
    }

    int ans = 0;
    for(int i = 0; i < Nums.size(); i += 2){
        int left = i;
        int right = min(i + Add, (int)Nums.size());
        int tmp = sum[right] - sum[left];
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    //solve1(N, K, S);
    //solve2(N, K, S);
    solve3(N, K, S);
    return 0;
}

Measured memory_bytes: 1400
import sys
from itertools import accumulate

readline = sys.stdin.readline
n, q = map(int, readline().split())
s = readline().rstrip()
ac = [False] * (n - 1)
for i, x in enumerate(zip(s, s[1:])):
    if x == ('A', 'C'):
        ac[i] = True
ac = [0] + list(accumulate(ac))
for _ in range(q):
    l, r = map(int, readline().split())
    print(ac[r-1] - ac[l-1])


Measured memory_bytes: 8996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N, Q;
    cin >> N >> Q;

    vector<int> a(N + 1), b(N + 1);
    for (int i = 1; i <= N; ++i) a[i] = b[i] = N;

    ll black = ll(N - 2) * (N - 2);

    int H = N, W = N;

    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < W) {
                for (int i = x; i < W; ++i) {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;

        } else {
            if (x < H) {
                for (int i = x; i < H; ++i) {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  int n ;
  cin >> n ;
  vector<pair<int,pair<int,int>>> vec(n+1) ;
  vec.at(0) = make_pair(0,make_pair(0,0)) ;
  REP(i,n){
    int a, b, c ;
    cin >> a >> b >> c ;
    vec.at(i+1) = make_pair(a,make_pair(b,c)) ;
  }
  REP(i,n){
    if((vec.at(i+1).FT-vec.at(i).FT)%2!=(abs(vec.at(i+1).SC.FT-vec.at(i).SC.FT)+abs(vec.at(i+1).SC.SC-vec.at(i).SC.SC))%2 || vec.at(i+1).FT-vec.at(i).FT<abs(vec.at(i+1).SC.FT-vec.at(i).SC.FT)+abs(vec.at(i+1).SC.SC-vec.at(i).SC.SC)){
      cout << "No" <<endl ;
      return 0 ;
    }
  }
  
  cout << "Yes" <<endl ;


  return 0 ;
}



Measured memory_bytes: 1408
/*
    coder:xxjAc
    name:
    time:2017/8/5
*/
#include <sstream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <fstream>
#include <numeric>
#include <cstring>
using namespace std;
int n;
int have=0;
int c4=0,c1=0;
int main(){
	scanf("%d",&n);
	int x;
	for (int i=0;i<n;i++){
		scanf("%d",&x);
		if (x%4==0){
			c4++;
		}
		else if(x%2==0){
			have=1;
		}
		else{
			c1++; 
		}
	}
	if (c4+1>=have+c1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int a = n / x;
    if (n%x == 0) cout << a*t << endl;
    else cout << a*t + t << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>b>>a;
	ll r0=a+b*2-1;
	ll s1=(a+r0)*b;
	ll s2=(r0+1+r0+b)*b/2;
	//cout<<s1<<' '<<s2<<endl;
	ll ans;
	if (s1>s2) {
		cout<<-1<<endl;
		return 0;
	}
	else
	{
		ll u=a+1,v;
		if (b%2==1)
		   v=r0-b/2-1;
		else v=r0-b/2;
		for (ll i=r0+1;i<=r0+b;i++)
		{
			cout<<u<<' '<<v--<<' ';
			cout<<i<<endl;
			u+=2;
			if (u>=a+b) u=a;
			if (v<a+b) v=r0;
		}
	}
}

Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i==s.size()-8){
			break;
		}
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define rep(i,n) for(int i=0;i<(int)(n);++i)
  #define repone(i,n) for(int i=1;i<(int)(n);++i)

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

  #define int long long

  using namespace std;

  signed main()
  {
    int x=0,i,j;
    std::cin >> x;
    std::vector<int> v(x);
if(x==1){
std::cin >> v[x-1];
  std::cout << v[x-1] << '\n';
}else{

      rep(i,x){
        std::cin >> v[i];
      }

    for(i=x-1;i>=0;i=i-2){
      cout<<v[i]<<" ";
    }
if(i==-2)j=1;
else j=0;
    for(j;j<x;j=j+2){
      std::cout <<v[j]<<" ";
    }
}
      return 0;
  }


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

int main(){
	int n,x;
	cin>>n>>x;

	int mindont = 1e5+10;
	for(int i=0;i < n;i++){
		int kind;
	    cin>>kind;
	   mindont = min(mindont,kind);
	   x-=kind;
	}

	cout<<n+(x/mindont);
}

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

int main(){ 
double R, l;
cin >> R;

l = 2 * R * 3.1415926535;

std::setprecision(4);

cout << l << endl;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> W(N, 0);
    vector<int> sum(N, 0);
    for(int i = 0;i < N; i++) {
        cin >> W[i];
        if(i >= 1) {
            sum[i] = sum[i-1] + W[i];
        } else {
            sum[i] = W[i];
        }
    }

    int all = sum[N-1];
    for(int i = 0;i < N; i++) {
        int min_v = min(sum[i], all - sum[i]);
        int max_v = max(sum[i], all - sum[i]);
        sum[i] = max_v - min_v;
    }
 
    sort(sum.begin(), sum.end() );

    cout << sum[0] << endl;

}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/11
// Problem:ABC 090 . d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

bool state[101010];

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

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

  /*
  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }
  */

  ll ans = 0ll;
  FOR(bi, K + 1, N + 1) {
    ll tmp = (N + 1) / bi;
    ans += tmp * (bi - min(K, bi));
    ans += max(0, ((N + 1) % bi) - K);
    if (K == 0) {
      // グループを形成できない中途半端なものを求めるときに、+1(0の分)を引く必要がある
      ans--;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) {
cin>>A[i];
  }
  sort(all(A));
  cout<<A.back()-A[0]<<endl;
}
  

Measured memory_bytes: 3624
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

pair<string, int> queue_shift(vector<pair<string, int>> &v, int &fronti) {
  pair<string, int> tmp;
  tmp.first  = v[fronti].first;
  tmp.second = v[fronti].second;
  fronti = (fronti + 1) % v.size();
  return tmp;
}

void queue_push(vector<pair<string, int>> &v, int &backi, pair<string, int> &tmp) {
  v[backi].first  = tmp.first;
  v[backi].second = tmp.second;
  backi = (backi + 1) % v.size();
}

int main() {

  int num, quantum;
  cin >> num >> quantum;

  vector<pair<string, int>> task(200000, pair<string, int>());
  pair<string, int> tmp;

  int fronti = 0;
  int backi  = 0;

  rep (i, num) {
    cin >> tmp.first >> tmp.second;
    queue_push(task, backi, tmp);
  }

  int nexttask;
  int timeleft = 0;
  
  vector<pair<string, int>> ans(num + 1, pair<string, int>());
  int ans_backi = 0;

  int cnt = 0;
  while (cnt < num) {

    nexttask = task[fronti].second;
    timeleft += min(nexttask, quantum);

    if (nexttask > quantum) {
      tmp.first = task[fronti].first;
      tmp.second = nexttask - quantum;
      queue_push(task, backi, tmp); 
    }
    else {
      tmp.first = task[fronti].first;
      tmp.second = timeleft;
      queue_push(ans, ans_backi, tmp);
      cnt ++;
    }
    queue_shift(task, fronti);
  }

  rep (i, num) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

class Union_find
{
public:
    vector<int> par;
    vector<int> sz;

    Union_find(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 1);
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

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

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

    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

    int union_size(int x){
        return sz[find(x)];
    }

};


signed main(){

    int N, M; cin >> N >> M;
    vec p(N); readi(p);
    int x, y;
    Union_find UF(N);
    REP(i, M){
        cin >> x >> y;
        UF.unite(x - 1, y - 1);
    }
    int ans = 0;
    REP(i, N) if(UF.is_union(i, p[i])) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;
 
//int dy[8]={1,1,1,0,0,-1,-1,-1};
//int dx[8]={-1,0,1,-1,1,-1,0,1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
 
int N,M,l,r;
vi a,b,c,d;
int A,B;
void input(){
	cin>>N>>A>>B;
}
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	P(min(N*A,B))
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
ll furo[200001];
int main() {
  ll n, t;
  cin >> n>>t;
  ll ans = 0;
  rep(i,n) cin >> furo[i];
  rep(i,n-1) {
    ll now = furo[i+1]-furo[i];
    ans += min(now, t);
  }
  ans += t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	int n, k, h, ans = 0;
	cin >> n >> k;
	rep(i, n) {
		cin >> h;
		if(h >= k) ans++;
	}
	cout << ans << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];
    bool possible = false;
    int ans = 0, t = 1;
    REP(i, N)
    {
        if(a[i] != t) ans++;
        else 
        {
            t++;
            possible = true;
        }
    }
    if(!possible)
    {
        cout << -1 << endl;
    }
    else cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define range(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define reversed_range(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using coord = tuple<int, int, int>;

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

int main() {
    int H, W;
    cin >> H >> W;
    vec<string> grid;
    range(i, H) {
        string row;
        cin >> row;
        grid.emplace_back(row);
    }
    assert(grid.at(0).size() == W);
    vec<vec<bool>> visited(H, vec<bool>(W, false));
    deque<coord> que;
    range(i, H) {
        range(j, W) {
            if (grid.at(i).at(j) == '#') {
                que.emplace_back(i, j, 0);
            }
        }
    }
    vec<int> dx = {0, 0, 1, -1};
    vec<int> dy = {1, -1, 0, 0};
    int max_dist = 0;
    while (!que.empty()) {
        coord cur_coord = que.front(); que.pop_front();
        int i = get<0>(cur_coord), j = get<1>(cur_coord), dist = get<2>(cur_coord);
        // cout << i << " " << j << " " << dist << "\n";
        for (int k = 0; k < 4; k++) {
            int next_i = i + dx.at(k);
            int next_j = j + dy.at(k);
            if (!(0 <= next_i && next_i < H && 0 <= next_j && next_j < W)) continue;
            else if (visited.at(next_i).at(next_j)) continue;
            else if (grid.at(next_i).at(next_j) == '#') continue;
            else {
                que.emplace_back(next_i, next_j, dist + 1);
                visited.at(next_i).at(next_j) = true;
                max_dist = max(max_dist, dist + 1);
            }
        }
    }
    cout << max_dist << "\n";
}

Measured memory_bytes: 13584
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int h,w;
int dp[101][101];
const int INF=1001001001;

int main() {
  cin >> h >> w;
  vvi maze(h+1,vi(w+1,-1));
  rep(i,h) rep(j,w) {
    char c;
    cin >> c;
    if(c=='.') maze.at(i).at(j) = 1;
    else maze.at(i).at(j) = 0;
  }

  rep(i,h) rep(j,w)  {
    dp[i][j] = INF;
  }
  if(maze[0][0]==0) dp[0][0] = 1;
  else dp[0][0] = 0;
  rep(i,h) rep(j,w) {
    if(maze.at(i).at(j)==1 and maze.at(i+1).at(j) == 0) dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1);
    else dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
    if(maze.at(i).at(j)==1 and maze.at(i).at(j+1) == 0) dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1);
    else dp[i][j+1] = min(dp[i][j+1],dp[i][j]);
  }

  cout << dp[h-1][w-1] << endl;



  return 0;
}


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

using namespace std;

int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
char board[2000][2000];
int psum[2000][2000][4];
int h,w;

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

	cin >> h >> w;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin >> board[i][j];
		}
	}

	int res = 0;

	for(int j=0;j<w;j++)
	{
		int cnt = 0;
		for(int i=h-1;i>=0;i--)
		{
			if(board[i][j]=='#')
			{
				cnt = 0;
			}
			else
			{
				cnt++;
			}
			psum[i][j][0] = cnt;
		}
	}

	for(int i=0;i<h;i++)
	{
		int cnt = 0;
		for(int j=0;j<w;j++)
		{
			if(board[i][j]=='#')
			{
				cnt = 0;
			}
			else
			{
				cnt++;
			}
			psum[i][j][1] = cnt;
		}
	}

	for(int j=0;j<w;j++)
	{
		int cnt = 0;
		for(int i=0;i<h;i++)
		{
			if(board[i][j]=='#')
			{
				cnt = 0;
			}
			else
			{
				cnt++;
			}
			psum[i][j][2] = cnt;
		}
	}

	for(int i=0;i<h;i++)
	{
		int cnt = 0;
		for(int j=w-1;j>=0;j--)
		{
			if(board[i][j]=='#')
			{
				cnt = 0;
			}
			else
			{
				cnt++;
			}
			psum[i][j][3] = cnt;
		}
	}

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(board[i][j]=='#')
			{
				continue;
			}
			int sum = 0;
			for(int k=0;k<4;k++)
			{
				sum += psum[i][j][k];
			}
			sum-=3;
			res = max(res,sum);
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 66688
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll f(ll b, ll n){
    if(n < b) return n;
    else return f(b, n / b) + (n % b);
}

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

    ll n, s; cin>>n>>s;

    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }

    for(ll b=2; b*b<=n; b++){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }

    // n = α * b + β
    // s = α + β
    ll ans = INF;
    for(ll alpha=1; alpha*alpha<=n; alpha++){
        ll b = (n - s) / alpha + 1;
        
        if(b < 2) continue;
        if(f(b, n) != s) continue;

        chmin(ans, b);
    }

    cout << (ans == INF ? -1 : ans) << endl;
}


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

int calculateMoves(int N,int h,int moves[1000]) {
    if(N == 0 && h <= 0){
        cout << "Yes";
        return 0;
    }else if(N != 0 && h <= 0){
        cout << "Yes";
        return 0;
    }else if(N == 0 && h > 0){
        cout << "No";
        return 0;
    }

    return calculateMoves(N - 1, h - moves[0], moves + 1);
}

int main(){
    int h,N;
    cin >> h >> N;
    int moves[N];


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

 calculateMoves(N,h,moves);
}


Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	string s;
	cin >> n >> k;

	k=2*k+1;

	int l=k;
	int i=1;

	while(n>l){
		l=l+k;
		i++;
	}
	
	cout << i << endl;
	
	
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]

h.sort()
ans = max(h)
for i in range(0, n - k + 1):
    h_diff = h[i + k - 1] - h[i]
    ans = min(ans, h_diff)
print(ans)


Measured memory_bytes: 13372
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll H,W,D;
    cin >> H >> W >> D;
    vector<pair<ll,ll>> pos = vector<pair<ll,ll>>(H * W + 1);
    vector<ll> cost = vector<ll>(H * W + 1);
    for(ll i = 0; i < H * W + 1; i++){
        pos[i].first = 0;
        pos[i].second = 0;
        cost[i] = -1;
    }
    for(ll yi = 0; yi < H; yi++){
        for(ll xi = 0; xi < W; xi++){
            ll tmp;
            cin >> tmp;
            pos[tmp].first = xi;
            pos[tmp].second = yi;
        }
    }
    for(ll i = 1; i <= D; i++){
        cost[i] = 0;
    }
    for(ll i = D + 1; i < H * W + 1; i++){
        cost[i] = cost[i - D] + abs(pos[i].first - pos[i - D].first) + abs(pos[i].second - pos[i - D].second);
    }
    ll Q = 0;
    cin >> Q;
    for(ll i = 0; i < Q; i++){
        ll L,R;
        cin >> L >> R;
        cout << cost[R] - cost[L] << endl;
    }
    
}

Measured memory_bytes: 3200
package main

import (
	"fmt"
)

func main() {
	var N, ans int

	fmt.Scan(&N)

	for i := 0; i <= N; i++ {
		if 0 < i && i < 10 {
			ans++
		}
		if 99 < i && i < 1000 {
			ans++
		}
		if 9999 < i && i < 100000 {
			ans++
		}
	}

	fmt.Println(ans)

}


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

int main() {

    // 宣言文
    int a, b;
    cin >> a >> b;

    int test = (a*b)%2;

    if( test == 0 ) {
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000001


int main(){

	int H,W,M;
	cin>>H>>W>>M;
	
	vector<int> X(W+1,0),Y(H+1,0);
	set<pair<int,int>> S;
	
	for(int i=0;i<M;i++){
		int h,w;
		scanf("%d %d",&h,&w);
		X[w]++;
		Y[h]++;
		S.insert(make_pair(h,w));
	}
	
	int mX=0,mY=0;
	for(int i=0;i<=W;i++)mX = max(mX,X[i]);
	for(int i=0;i<=H;i++)mY = max(mY,Y[i]);
	
	int ans = mX+mY-1;
	vector<int> okX,okY;
	for(int i=0;i<=W;i++){
		if(X[i]==mX)okX.push_back(i);
	}
	for(int i=0;i<=H;i++){
		if(Y[i]==mY)okY.push_back(i);
	}
	
	for(int i=0;i<okX.size();i++){
		for(int j=0;j<okY.size();j++){
			if(!S.count(make_pair(okY[j],okX[i]))){
				ans ++;
				goto L;
			}
		}
	}
	L:;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 23936
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n;
//SUN, MON, TUE, WED, THU, FRI, or SAT.
void solve(){
	cin>>n;
	cout<<n*n; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int n, k;
	sii(n, k);
	if(k > ((n-2)*(n-1))/2)
		printf("-1\n");
	else
	{
		vp vec;
		for(int i = 2; i <= n; i++)
			vec.push_back({1, i});
		int curr = ((n-2)*(n-1))/2;
		curr -= k;
		bool sw = 0;
		for(int i = 2; i <= n && sw == 0; i++)
			for(int j = i+1; j <= n && sw == 0; j++)
			{
				if(curr == 0)
				{
					sw = 1;
					break;
				}
				vec.push_back({i, j});
				curr--;
			}
		printf("%d\n",(int)vec.size());
		for(int i = 0; i < vec.size(); i++)
			printf("%d %d\n", vec[i].fst, vec[i].scn);
		printf("\n");
	}
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
static const int N=100;

int main(){
  int origin[N][N];
  int i,n,u,k,v,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)origin[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      origin[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",origin[i][j]);
    }
    printf("\n");
  }
  return 0;
}

  

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll answer = 0;
    vector<pll> remains; // B, A
    ll evenCount = 0;
    ll bNeedReduce = 0;
    for (int i = 0; i < N; i++)
    {
        ll A, B;
        cin >> A >> B;
        if (A < B)
        {
            answer += A;
            bNeedReduce += B - A;
        }
        else if (A == B)
        {
            evenCount += A;
        }
        else
        {
            remains.emplace_back(B, A);
        }
    }
    if(bNeedReduce > 0)
    {
        answer += evenCount;
    }
    sort(remains.begin(), remains.end(), greater<pll>());
    for (auto remain : remains)
    {
        ll A, B;
        tie(B, A) = remain;
        bNeedReduce -= A - B;
        answer += A - B;
        if (bNeedReduce == 0)
        {
            break;
        }
        answer += B;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
 
int main(void){
int a, b, c, i;
 
while(scanf("%d %d", &a, &b) != EOF){
c = a + b;
for( i=0; c != 0;i++)
c /= 10;
printf("%d\n", i);
}
return 0;
}
 

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

using namespace std;

typedef long long ll;
typedef long double ld;

ll dp1[2019];
ll dp2[2019];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    dp1[s[0] - '0'] = 1;
    ll ans = dp1[0];
    for (int i = 1; i < n; i++) {
        dp2[s[i] - '0']++;
        for (int j = 0; j < 2019; j++) {
            dp2[(j * 10 + (s[i] - '0')) % 2019] += dp1[j];
        }
        for (int j = 0; j < 2019; j++) {
            dp1[j] = dp2[j];
            dp2[j] = 0;
        }
        ans += dp1[0];
    }
    cout << ans;
}

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

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    ll x; cin >> x;
    ll y=360;
    ll g=gcd(x,y);
    cout << 360/g << endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 998244353;

signed main(){

    ll n;
    cin >> n;

    vector<double> v(n);
    rep(i,n)cin >> v[i];
    SORT(v);
    rep(i,n-1){
        v[i+1] = (v[i]+v[i+1])/2.0;
    }
    printf("%.9lf\n",v[n-1]);

    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc138.contest.atcoder.jp/tasks/abc138_b

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

#define OM ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define pi 3.14159265358979323846

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF MAHADEV*/

int main(){
	int d, t, s;
	cin >> d >> t >> s;
	if(d <= t * s)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <cassert>
#include <utility>

template <class Abelian, template <class T> class Container>
class potentialized_union_find {
	class node_type;

public:
	using value_structure = Abelian;
	using value_type = typename value_structure::value_type;
	using container_type = Container<node_type>;
	using size_type = typename container_type::size_type;

protected:
	container_type c;

private:
	class node_type {
	public:
		typename potentialized_union_find::size_type parent, size;
		typename potentialized_union_find::value_type value;
	};
	value_type potential(size_type x) {
		value_type ret = value_structure::identity();
		while (x != c[x].parent) {
			c[x].value = value_structure::operation(c[x].value, c[c[x].parent].value);
			ret = value_structure::operation(ret, c[x].value);
			x = c[x].parent = c[c[x].parent].parent;
		}
		return ::std::move(ret);
	}

public:
	potentialized_union_find() : c() {}
	explicit potentialized_union_find(const size_type size)
		: c(size, { 0, 1, value_structure::identity() }) {
		for (size_type i = 0; i < size; ++i)
			c[i].parent = i;
	}

	bool empty() const { return c.empty(); }
	size_type size() const { return c.size(); }

	size_type find(size_type x) {
		assert(x < size());
		while (x != c[x].parent) {
			c[x].value = value_structure::operation(c[x].value, c[c[x].parent].value);
			x = c[x].parent = c[c[x].parent].parent;
		}
		return x;
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		assert(same(x, y));
		return value_structure::operation(potential(y),
			value_structure::inverse(potential(x)));
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return c[find(x)].size;
	}

	::std::pair<size_type, size_type> unite(size_type x, size_type y,
		value_type d) {
		assert(x < size());
		assert(y < size());
		d = value_structure::operation(value_structure::operation(d, potential(x)),
			value_structure::inverse(potential(y)));
		x = find(x);
		y = find(y);
		if (x != y) {
			if (c[x].size < c[y].size) {
				::std::swap(x, y);
				d = value_structure::inverse(d);
			}
			c[x].size += c[y].size;
			c[y].parent = x;
			c[y].value = ::std::move(d);
		}
		return { x, y };
	}
};

template <class T> class plus_abelian {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type inverse(const value_type &x) { return -x; }
	static value_type reverse(const value_type &x) { return x; }
};

#include<iostream>
#include<vector>
template<class T>
using vec = ::std::vector<T>;

int main() {
	int n, q;
	std::cin >> n >> q;
	potentialized_union_find<plus_abelian<int>, vec> T(n);
	while (q--) {
		int t, x, y, z;
		std::cin >> t >> x >> y;
		if (t) {
			if (T.same(x, y))
				::std::cout << T.diff(x, y) << ::std::endl;
			else
				::std::cout << "?" << ::std::endl;
		}
		else {
			::std::cin >> z;
			T.unite(x, y, z);
		}
	}
	return 0;
}



Measured memory_bytes: 5216
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		string[] str2 = Console.ReadLine().Split();
		long[] A = new long[N];
		long[] A2 = new long[N];
		long amax = 0;
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
			if(A[i] > amax){
				amax = A[i];
			}
		}
		long aans = 0;
		for(var i=0;i<N;i++){
			if(amax != A[i]){
				if(Math.Abs(amax/2 - A[i]) < Math.Abs(amax/2 - aans)){
					aans = A[i];
				}
			}
		}
		Console.WriteLine(amax+" "+aans);
	}
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    int A, B, C;
    cin >> A >> B >> C;
    int m = max(max(A, B), C);
    int ans = A + B + C - m;
    cout << ans << endl;

}

Measured memory_bytes: 256
class Syakutori
  attr_reader :a, :n, :lo, :hi, :ans, :xs, :cx

  def initialize(n, a)
    @a = a
    @n = n
    @lo = 0
    @hi = 0
    @ans = 0
    @cs = 0
    @cx = 0
    yield self
  end

  def move_hi
    @cs += a[hi]
    @cx ^= a[hi]
    @hi += 1
  end

  def move_lo
    @cs -= a[lo]
    @cx ^= a[lo]
    @lo += 1
  end

  def update
    # pp [lo,hi,hi-lo]
    @ans += hi - lo
  end

  def valid?
    @cs == @cx
  end

  def solve_hi
    while hi < n
      move_hi
      move_lo until valid?
      update
    end
    return @ans
  end

  def solve_lo
    while lo < n
      move_hi while valid?
      update
      move_lo
    end
    return @ans
  end
end

n = gets.to_s.to_i
a = gets.to_s.split.map { |v| v.to_i }

Syakutori.new(n, a) do |s|
  puts s.solve_hi
end


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

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

    while (s.size() < 15)   s+='o';
    int cnt = 0;
    for (char c: s)
        if (c=='o')
            ++cnt;

    if (cnt > 7)    cout<<"YES"<<endl;
    else            cout<<"NO"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long start =100;
		int count=0;
		while (true) {
			count ++;
			start = (long) (start*1.01);
			if (start >=X) {
				break;
			}
		}
		System.out.println(count);
	}
}


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

int main(){

    int n;
    ll mo=1000000007;

    cin >> n;

    bool var=false;
    bool dbl=false;
    string a,b;
    ll ans=1;

    cin >> a >> b;
    int i;

    if(a[0]==a[1]){
        i=2;
        ans=ans*6%mo;
        dbl=true;
    }else{
        i=1;
        ans=ans*3%mo;
        var=true;
    }

    for(;i<n;){
        if(a[i]==a[i+1]&&var){
            dbl=true;
            var=false;
            ans=ans*2%mo;
            i+=2;
        }else if(a[i]==a[i+1]&&dbl){
            dbl=true;
            var=false;
            ans=ans*3%mo;
            i+=2;
        }else if(var){
            dbl=false;
            var=true;
            ans=ans*2%mo;
            i++;
        }else if(dbl){
            dbl=false;
            var=true;
            ans=ans*1%mo;
            i++;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import copy
n=int(input())
p=list(map(int,input().split()))
p_copy=copy.copy(p)
p.sort()
for i in range(n):
  for j in range(i+1,n):
    p_copy[i],p_copy[j]=p_copy[j],p_copy[i]
    if p==p_copy:
      break
    else:
      p_copy[i],p_copy[j]=p_copy[j],p_copy[i]
  if p==p_copy:
    break
if p==p_copy:
  print('YES')
else :
  print('NO')

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int n,W;
    cin >> n >> W;
    int dp[10100];
    vector<int>v(n),w(n);
    rep(i,n) cin >> v[i] >> w[i];
    rep(i,10100) dp[i] = 0;
    for(int i = 0;i<n;i++) {
        for(int j = W;j-w[i] >= 0;j--) {
            dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
    
}


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

struct Point {double x,y;};

void koch(int n,struct Point a,struct Point b){
  if(n == 0) return;
  struct Point s,t,u;
  double th = M_PI*60.0/180.0;

  s.x = (2.0*a.x+1.0*b.x) / 3.0;
  s.y = (2.0*a.y+1.0*b.y) / 3.0;
  t.x = (1.0*a.x+2.0*b.x) / 3.0;
  t.y = (1.0*a.y+2.0*b.y) / 3.0;
  u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);

  a.x = 0; a.y =0; b.x = 100; b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}
  



Measured memory_bytes: 2040
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())
    # print(S)

    # 最初を書き換えない
    iro = S[0]
    cnt1 = 0
    for idx, s in enumerate(S):
        if idx % 2 == 0 and s != iro:
            cnt1 += 1
        elif idx % 2 != 0 and s == iro:
            cnt1 += 1

    # 最初を書き換える
    cnt2 = 0
    for idx, s in enumerate(S):
        if idx % 2 == 0 and s == iro:
            cnt2 += 1
        elif idx % 2 != 0 and s != iro:
            cnt2 += 1

    print(min(cnt1, cnt2))



if __name__ == '__main__':
    solve()


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


int n, c;
int x[101], y[101], h[101];

int max(int x, int y) {
    if (x > y)return x;
    else return y;
}

int kkk(int a, int b) {
    int h0 = abs(a-x[c])+abs(b-y[c])+ h[c];

    for (int i = 1; i <= n; ++i)
        if (max(0, h0-(abs(a - x[i]) + abs(b - y[i]))) != h[i])
            return 0;
    return 1;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i] >> y[i] >> h[i];

    for (int i = 1; i <= n; i++)
        if (h[i] != 0) c = i;

    for (int i = 0; i < 101; ++i)
        for (int j = 0; j < 101; ++j) {
            if (kkk(i, j)) {
                cout << i << " " << j << " " << abs(i - x[c]) + abs(j - y[c]) + h[c] << endl;
                return 0;
            }
        }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint N, K, P[5000], C[5000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> K;
	REP(i, N) {
		cin >> P[i]; P[i]--;
	}
	REP(i, N) {
		cin >> C[i];
	}
	lint maxv = -INF;
	REP(i, N) {
		lint nxt = P[i];
		vector<lint> score_sum;
		score_sum.push_back(0);
		while (nxt != i) {
			score_sum.push_back(score_sum.back() + C[nxt]);
			nxt = P[nxt];
		}
		score_sum.push_back(score_sum.back() + C[i]);
		lint sz = SZ(score_sum) - 1;
		lint score = max(0ll, K / sz * score_sum[sz]);
		lint _maxv = -INF;
		if (score == 0 && score_sum[sz] != 0) {
			REP(j, min(K, sz)) {
				chmax(_maxv, score_sum[j + 1]);
			}
		}
		else if (score_sum[sz] == 0) {
			REP(j, min(K, sz) + 1) {
				chmax(_maxv, score_sum[j]);
			}
		}
		else {
			score = (K / sz - 1) * score_sum[sz];
			REP(j, sz + 1) {
				chmax(_maxv, score + score_sum[j]);
			}
			score = (K / sz) * score_sum[sz];
			REP(j, K% sz + 1) {
				chmax(_maxv, score + score_sum[j]);
			}
		}
		chmax(maxv, _maxv);
	}
	cout << maxv << endk;
}	

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

int main(){
	long long n, i, time = 0;
	cin >> n;

	vector<pair<long long, long long>> pairs(n);
	for (i = 0; i < n; i++){
		long long a, b;
		cin >> a >> b;
		pairs[i] = make_pair(b, a);
	}
	sort(pairs.begin(), pairs.end());
	for (i = 0; i < n; i++){
		time += pairs[i].second;
		if (time > pairs[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3328
package main

import (
	"fmt"
	"sort"
)

func main() {
	var X, Y, Z, K int
	fmt.Scanln(&X, &Y, &Z, &K)

	a := make([]int, X, X+1)
	for i := 0; i < X; i++ {
		fmt.Scan(&a[i])
	}
	b := make([]int, Y, Y+1)
	for i := 0; i < Y; i++ {
		fmt.Scan(&b[i])
	}
	c := make([]int, Z, Z+1)
	for i := 0; i < Z; i++ {
		fmt.Scan(&c[i])
	}

	// fmt.Println(a, b, c, K)

	d := make([]int, 0, X*Y)
	for x := 0; x < X; x++ {
		for y := 0; y < Y; y++ {
			d = append(d, a[x]+b[y])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(d)))
	if len(d) > K {
		d = d[0:K]
	}

	e := make([]int, 0, len(d)*Z)
	for i := 0; i < len(d); i++ {
		for z := 0; z < Z; z++ {
			e = append(e, d[i]+c[z])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(e)))
	if len(e) > K {
		e = e[0:K]
	}

	for _, v := range e {
		fmt.Println(v)
	}
}


Measured memory_bytes: 33024
# -*- coding: utf-8 -*-
from math import sqrt
import sys
from collections import defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N = int(input())
S = input()
x = "*"
ans = 0
for s in S:
    if s != x:
        ans += 1
        x = s
print(ans)

Measured memory_bytes: 39920