akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    // 無向辺の追加
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
    // 有向辺の追加
    void addArc(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
    }
    // ノードの追加
    void addNode(){
        size++;
        node.emplace_back();
    }
};

// Dijkstra(Heap); 単一始点最短路（優先度付きキューを利用したダイクストラ法）
// ：負辺がある場合はループにハマる可能性があるため、Bellman-Fordを使うこと。[O((E+V)logV)]
vector<long long> Dijkstra(const Graph &g, long long src){
    const long long WeightINF = numeric_limits<long long>::max()/2-1;
    using state = pair<long long, long long>;
    priority_queue<state> que;
    vector<long long> d(g.size, WeightINF);
    d[src] = 0;
    que.emplace(0, src);
    while(!que.empty()){
        auto p = que.top(); que.pop();
        long long w = -p.first;
        long long v = p.second;
        if(d[v] < w) continue;
        for(auto &edge: g.node[v]){
            if(d[edge.dst] > d[v] + edge.weight){
                d[edge.dst] = d[v] + edge.weight;
                que.emplace(-d[edge.dst], edge.dst);
            }
        }
    }
    return d;
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    Graph g(3*n);

    rep(i, m){
        ll u, v;
        cin >> u >> v;
        u--; v--;
        g.addArc(3*u+0, 3*v+1, 1);
        g.addArc(3*u+1, 3*v+2, 1);
        g.addArc(3*u+2, 3*v+0, 1);
    }
    ll s, t; cin >> s >> t; s--; t--;
    s *= 3; t *= 3;
    auto dij = Dijkstra(g, s);
    cout << (dij[t]%3 == 0 ? dij[t]/3 : -1) << endl; 
}

Measured memory_bytes: 26688
x,y=gets.split.map &:to_i
a=[];b=[];c=[];d=[]
x.times{|i|a[i],b[i]=gets.split.map &:to_i;c[i]=100*(i+1)
d[i]=a[i]*c[i]+b[i]}
ans=a.zip(c,d).reverse
answer=10**9
[0,1].repeated_permutation(x).each{|i|
#０が使わない、1は使う
  ka1=0;kai=0;zero=0;ze=0
  for j in 0...x
    if i[j]==1
      kai+=ans[j][2]
      ka1+=ans[j][0]
    else
      (zero=j;ze=1) if ze==0
    end
  end
  for j in 0..ans[zero][0]
    kai+=ans[zero][1] if j!=0
    ka1+=1 if j!=0
    if kai>=y
      answer=[answer,ka1].min
      break
    end
  end
}
puts answer


Measured memory_bytes: 14380
#include<iostream>
#include<vector>
#include<utility>

int main(){

    size_t n;
    std::cin >> n;

    std::vector<std::pair<size_t, size_t>> ab(n);

    for(auto&& e : ab){
        std::cin >> e.first >> e.second;
    }

    size_t cnt = 0;
    for(size_t i = 0; i < n; i++){
        if((ab.at(n - i - 1).first + cnt) % ab.at(n - i - 1).second != 0){
            cnt += ab.at(n - i - 1).second - ((ab.at(n - i - 1).first + cnt) % ab.at(n - i - 1).second);
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#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)
{
    int N, M;
    cin >> N >> M;
 
    vector<vector<char>> A(N, vector<char>(N));
    vector<vector<char>> B(M, vector<char>(M));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }
 
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> B[i][j];
        }
    }
 
    bool exist = false;
 
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i + M - 1 >= N || j + M - 1 >= N)
            {
                continue;
            }
 
            bool match = true;
            for (int k = 0; k < M; k++)
            {
                for (int l = 0; l < M; l++)
                {
                    if (A[i + k][j + l] != B[k][l])
                    {
                        match = false;
                    }
                }
            }
            if (match == true)
            {
                exist = true;
            }
        }
    }
 
    if (exist == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return (0);
}

Measured memory_bytes: 256
N,T = map(int,input().split())
L = list(map(int,input().split()))
ans = 0
for i in range(len(L)) :
    if i != N-1 :
        if L[i+1]-L[i] > T :
            ans += T
        else :
            ans += L[i+1]-L[i]
    else :
        ans += T
print(ans)


Measured memory_bytes: 26708
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n = 0;
    string str;
    cin >> str;
    int i = 0;
    int size = str.size();
    for(i = 0; i < size; i++ ){
      char tmp = str[i];
        if(tmp == '+'){
            n++;
        }else{
            n--;
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int cnt = 0;
  rep(i, n){
    if(s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3852
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true, flag = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };
string abc = "abcdefghijklmnopqrstuvwxyz";

int n;
vector<int>v[100010];
ll od[100010], nd[100010];

void obfs(int p) {
		for (int i = 0;i < v[p].size();i++) {
			if (od[v[p][i]] == INF) {
				od[v[p][i]] = od[p] + 1;
				obfs(v[p][i]);
			}
		}
}

void nbfs(int p) {
		for (int i = 0;i < v[p].size();i++) {
			if (nd[v[p][i]] == INF) {
				nd[v[p][i]] = nd[p] + 1;
				nbfs(v[p][i]);
			}
		}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n - 1;i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	fill(od, od + n + 1, INF);
	fill(nd, nd + n + 1, INF);
	od[1] = 0, nd[n] = 0;
	obfs(1);
	nbfs(n);
	int bc = 0, wc = 0;
	for (int i = 1;i <= n;i++) {
		if (od[i] <= nd[i])bc++;
		else wc++;
	}
	if (bc > wc)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}

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

long long M[105][100005];
int A[105];

void filly(int n, int k)
{
    for(int i = 1; i < n; i++)
    {
        M[i][0] = 1;
        for(int j = 1; j <= k; j++)
        {
                M[i][j] = M[i][j-1];
                M[i][j] += (M[i-1][j] - (j - A[i] - 1 >= 0 ? M[i-1][j - A[i] - 1] : 0) + 1000000007) % 1000000007;
                M[i][j] %= 1000000007;
        }
    }
}

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

    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i <= A[0]; i++)
        M[0][i] = i+1;
    for(int i = A[0]+1; i <= k; i++)
        M[0][i] = M[0][A[0]];

    filly(n, k);
    cout << (M[n-1][k] - M[n-1][k-1] + 1000000007) % 1000000007;

    return 0;
}


Measured memory_bytes: 80128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::string S){
  string t = "ABC";
  ll ans = 0;
  for(ll i=0; i+2<S.size(); i++) {
    if(S[i]=='A' and S[i+1]=='B' and S[i+2]=='C')
      ans++;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;

  cout << v[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> h >> w >> a >> b;
	c = 499;
	num = (h/a) * (w/b);
	ll pos,nega;
	pos = (h * w - num) * c;
	nega = ((a * b - 1) * c + 1) * num;
	if(pos > nega){
		p("Yes");
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if(i % a == 0 && j % b == 0){
					pe(-1 * (a * b - 1) * c - 1);
				}else{
					pe(c);
				}
			}
			el;
		}
	}else{
		p("No");
	}
	return 0;
}


Measured memory_bytes: 28672
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int count;
    count = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bool flag = true;
    while(flag == true){
        for(int i=0;i<n;i++){
            if(a[i]%2!=0){
                 flag = false;
                 break;
            }else if(i==n-1){
                count++;
            }
            a[i]=a[i]/2;
        }
        if(flag == false){
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

string s;
int p,q,r;

int number(int& pos);
int term(int& pos);
int expr(int& pos);

int number(int& pos){
    if(isdigit(s[pos])){
        return s[pos++] - '0';
    }else{
        if(s[pos] == 'P'){
            pos++;
            return p;
        }else if(s[pos] == 'Q'){
            pos++;
            return q;
        }else{
            pos++;
            return r;
        }
    }
}

int term(int& pos){
    if(isalpha(s[pos]) || isdigit(s[pos])){
        return number(pos);
    }else if(s[pos] == '-'){
        pos++;
        return 2-term(pos);
    }else{
        pos++;
        int res = expr(pos);
        pos++;
        return res;
    }
}

int expr(int& pos){
    int res = term(pos);
    while(s[pos] == '+' || s[pos] == '*'){
        if(s[pos] == '+'){
            res = max(res,term(++pos));
        }else{
            res = min(res,term(++pos));
        }
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> s;
        if(s == "."){
            break;
        }
        int num = 0;
        rep(i,3){
            rep(j,3){
                rep(k,3){
                    int pos = 0;
                    p = i,q = j,r = k;
                    if(expr(pos) == 2){
                        num++;
                    }
                }
            }
        }
        cout << num << "\n";
    }
    return 0;
}

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

using namespace std;

int main(){
    int r1,c1,r2,c2;
    cin >> r1 >> c1 >> c2;
    r2 = c1;
    vector<vector<int>> matrix1(r1,vector<int>(c1,0));
    vector<vector<int>> matrix2(r2,vector<int>(c2,0));
    vector<vector<unsigned long>> matrix3(r1,vector<unsigned long>(c2,0));

    for(int i = 0;i < r1; i++){
        for(int j= 0; j < c1;j++){
            cin >> matrix1[i][j];
        }
    }
    for(int i = 0;i < r2; i++){
        for(int j= 0; j < c2;j++){
            cin >> matrix2[i][j];
        }
    }

    for(int i = 0;i < r1;i++){
        for(int j = 0;j < c2;j++){
            for(int k = 0;k < c1;k++){
                matrix3[i][j] += matrix1[i][k]*matrix2[k][j];
            }
            cout << matrix3[i][j];
            if(j!=c2-1) cout << " "; 
        }
        cout << "\n";
    }

   
    return 0;   
}



Measured memory_bytes: 3224
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000007;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

namespace Segment_tree {
	template<typename T>
	class segment_tree {
		vector<T> dat;
		int n;
		T e;
		std::function<T(T, T)> f;
		T query_implement(int a, int b, int k, int l, int r) {
			if (r <= a || b <= l) return e;
			if (a <= l && r <= b) return dat[k];

			T v1 = query_implement(a, b, 2 * k + 1, l, (l + r) / 2);
			T v2 = query_implement(a, b, 2 * k + 2, (l + r) / 2, r);
			return f(v1, v2);
		}
	public:
		segment_tree(int n_, T _e, T(*calc)(T lhs, T rhs)) {
			e = _e;
			f = calc;
			n = 1;
			while (n < n_) n *= 2;
			dat.resize(2 * n - 1);
			for (int i = 0; i < 2 * n - 1; i++)
				dat[i] = e;
		}

		void update(int k, int a) {
			k += n - 1;
			dat[k] = a;

			while (k > 0) {
				k = (k - 1) / 2;
				dat[k] = f(dat[k * 2 + 2], dat[k * 2 + 1]);
			}
		}

		T query(int a, int b) { return query_implement(a, b, 0, 0, n); }
	};
}



long long int ma(long long int lef, long long int rig) { return max(lef, rig); }
int main(){
	long long int n;
	long long int t;
	cin >> n >> t;
	vector<long long int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	Segment_tree::segment_tree<long long int> maxtree(n, -1, ma);
	for (int i = 0; i < n; i++) {
		maxtree.update(i, a[i]);
	}
	long long maxpro = 0;
	for (int i = 0; i < n-1; i++) {
		maxpro = max(maxpro, (maxtree.query(i + 1, n)-a[i])*t/2);
	}
	long long int cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		if (maxpro == (maxtree.query(i + 1, n) - a[i])*t / 2)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
	
}


Measured memory_bytes: 3072
import java.util.*;
import java.io.*;
public class Main {
	static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
		int N = readInt();
		int[] coor = new int[N+2];
		
		coor[0] = 0;
		coor[N+1] = 0;
		for (int i=1; i<=N; i++){
			coor[i] = readInt();
		}
		int total = 0;
		for (int i=1; i<=N+1; i++){
			
		    total+=Math.abs(coor[i]-coor[i-1]);
		}
		for (int i=1; i<=N; i++){
			System.out.println(total-Math.abs(coor[i]-coor[i-1])-Math.abs(coor[i+1]-coor[i])+Math.abs(coor[i+1]-coor[i-1]));
		}

	}
	static String next () throws IOException {
        while (st == null || !st.hasMoreTokens())
        st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
 
    static long readLong () throws IOException {
        return Long.parseLong(next());
    }
 
    static int readInt () throws IOException {
        return Integer.parseInt(next());
    }
 
    static double readDouble () throws IOException {
        return Double.parseDouble(next());
    }
 
    static char readCharacter () throws IOException {
        return next().charAt(0);
    }
 
    static String readLine () throws IOException {
        return br.readLine().trim();
    }
}


Measured memory_bytes: 68192
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define umi unordered_map<int,int>
#define uml unordered_map<ll,ll>
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"

ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

ll gcd(ll a, ll b)
{ 
	return !b ? a : gcd(b, a % b); 
}
ll lcm(ll a, ll b)
{ 
	return (a / gcd(a, b)) * b; 
}
ll fastExponentiation(ll n, ll x, ll modulo) 
{
	ll res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}


ll power(ll n , ll p ){
	if(p==0)
	   return 1;
 
	 ll res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}

void solve()
{
    // cout<<fixed<<setprecision(20)<<endl;
	
	int n,m;
	cin>>n>>m;
	
	int ans=0;
	
	ans+=((n*(n-1))/2);
// 	cout<<ans<<endl;
	ans+=((m*(m-1))/2);
	cout<<ans<<endl;
}


int main()
{
	fastio
	
	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int X;

    cin >> X;

    if(X < 30)cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;

}

Measured memory_bytes: 3032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

const int max = 1000005;

std::string text;
int textSize, k = 1;
int rank[max + 1], tmp[max + 1], sa[max + 1];

bool compare_sa(int i, int j){
	if (rank[i] != rank[j])return rank[i] < rank[j];
	else {
		int ri = (i + k <= textSize ? rank[i + k] : -1);
		int rj = (j + k <= textSize ? rank[j + k] : -1);
		return ri < rj;
	}
}

void construct_sa(){
	textSize = text.size();
	rep(i, textSize + 1){
		sa[i] = i;
		rank[i] = (i < textSize ? text[i] : -1);
	}

	for (; k <= textSize; k *= 2){
		std::sort(sa, sa + textSize + 1, compare_sa);

		tmp[sa[0]] = 0;
		REP(j, 1, textSize + 1)tmp[sa[j]] = tmp[sa[j - 1]] + (compare_sa(sa[j - 1], sa[j]) ? 1 : 0);
		rep(j, textSize + 1)rank[j] = tmp[j];
	}
}

bool find(std::string t){
	int l = 0, r = text.size();
	while (l <= r){
		int m = (l + r) / 2;
		if (text.compare(sa[m], t.size(), t) < 0)l = m + 1;
		else r = m - 1;
	}
	return (text.compare(sa[r + 1], t.size(), t) == 0);
}

int n;

int main(){
	std::cin >> text >> n;
	construct_sa();
	rep(i, n){
		char str[1005];
		scanf("%s", &str);
		printf("%d\n", (find(str) ? 1 : 0));
	}

	return 0;
}

Measured memory_bytes: 13924
// A - One out of Three

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int ans;
	if (A == B) {
		ans = C;
	} else {
		if (B == C) {
			ans = A;
		} else {
			ans = B;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;


int main() {
	int N;
	int M;
	cin >> N;
	cin >> M;
	vector<long long> A;
	vector<pair<int, long long>> B;

	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());

	for (int i = 0; i < M; ++i) {
		int b, c;
		cin >> b >> c;
		B.push_back(make_pair(c, b));
	}
	sort(B.rbegin(), B.rend());

	bool endF = false;
	long long value = 0;
	int j = 0;
	for (int i = 0; i < N; ++i) {
		if (A[i] < B[j].first) {
			A[i] = B[j].first;
			--B[j].second;
		}

		if (B[j].second == 0) {
			++j;
			if (M - 1 < j) {
				break;
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		value += A[i];
	}

	cout << value << endl;
	return 0;
}

Measured memory_bytes: 3188
n = int(input())
X = [int(i) for i in input().split(" ")]
Y = [int(i) for i in input().split(" ")]

for p in range(1, 4):
    print("{:.6f}".format(sum( [abs(a - b) ** p for a, b in zip(X,Y) ] ) ** (1 / p) ) )

print("{:.6f}".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )
 

Measured memory_bytes: 7712
/*
    B - Collatz Problem
    https://atcoder.jp/contests/abc116/tasks/abc116_b
*/
#include <bits/stdc++.h>
using namespace std;

int collatz(int num) {
    if (num % 2 == 0)
        return num / 2;
    return 3 * num + 1;
}
void solve(int s) {
    set<int> st;
    while (true) {
        st.insert(s);
        s = collatz(s);
        if (st.count(s) == 1) {
            break;
        }
    }
    cout << st.size() + 1 << endl;
}

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

    int s;
    cin >> s;
    solve(s);
}

Measured memory_bytes: 256
a, b , k = map(int, input().split(' '))
count = 0
result = 1
if a < b:
    i = a
else:
    i = b
while count != k:
    if a%i == 0 and b%i == 0:
        count += 1
        result = i
    i -= 1
print(result)

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

int main(){
  int N,i;
  int alice=0;
  int bob=0;
  cin >> N;
  vector<int> card(N);

  for(i=0 ; i<N ; i++ ){
    cin >> card.at(i);  
  }
  sort(card.begin(), card.end(), greater<int>() );

  for(i=0 ; i<N ; i++ ){
    //cout << card.at(i) << endl;
    if(i%2 == 0){
      alice += card.at(i);
    }else{
      bob += card.at(i);
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
import collections
import random

N = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(1, len(a)):
    if a[i] == a[i-1]:
        count += 1
        random.seed(i)
        a[i] = random.randrange(0, 1)
print(count)

Measured memory_bytes: 4068
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<int> waters, sugars;
    for (int a = 0; a <= 50; a++) {
        for (int b = 0; b <= 50; b++) {
            int water = 100 * A * a + 100 * B * b;
            if (water == 0) continue;
            if (water <= F)waters.insert(water);
        }
    }
    for (int c = 0; c <= 1000; c++) {
        for (int d = 0; d <= 1000; d++) {
            int sugar = C * c + D * d;
            if (sugar <= F) sugars.insert(sugar);
        }
    }

    int WATER = 0, SUGAR = 0;
    double percent;
    bool first = true;

    for (auto water: waters) {
        for (auto sugar : sugars) {
            if (water + sugar > F) break;
            if (E * water < 100 * sugar) continue;
            if (first) {
                WATER = water;
                SUGAR = sugar;
                first = false;
                percent = (100 * SUGAR) / (double) (WATER + SUGAR);
                continue;
            }
            double p = (100 * sugar) / (double) (water + sugar);
            if (p > percent) {
                WATER = water;
                SUGAR = sugar;
                percent = (100 * sugar) / (double) (water + sugar);
            }
        }
    }

    cout << (WATER + SUGAR) << " " << SUGAR << endl;

}






















































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

int main(){
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i =0; i < n ; ++i){
    cin >> a[i];
  }
  a.push_back(a[0]+k);
  int l = 0;
  for (int i =0; i < n ; ++i){
    l= max(l,a[i+1]-a[i]);
  }
  int ans = k-l;
  cout << ans <<endl;
  return 0;
}
    
  


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;
const long double PI = (acos(-1));

int main()
{
    ll n;
    cin >> n;
    ll ans = inf;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            ans = min(i + n/i - 2, ans);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n = int(input())
s = input()
r, g, b = [], [], []
cnt = 1
for i in s:
    if i == 'R':
        r.append(cnt)
    elif i == 'G':
        g.append(cnt)
    else:
        b.append(cnt)
    cnt += 1
rd = set(map(lambda x: x * 2, r))
gd = set(map(lambda x: x * 2, g))
bd = set(map(lambda x: x * 2, b))
ddc = 0
for i in r:
    for j in g:
        if i + j in bd:
            ddc += 1
for j in g:
    for k in b:
        if j + k in rd:
            ddc += 1
for i in r:
    for k in b:
        if i + k in gd:
            ddc += 1
print(len(r) * len(g) * len(b) - ddc)

Measured memory_bytes: 9644
//MD. HASNAIN ALI (UNSOLVED)
#include <bits/stdc++.h>

#define ll long long
#define pii pair<int,int>

#define distance(a,b) (sq(a.x-b.x) + sq(a.y-b.y))
#define MAX3(a,b,c) max(a,max(b,c))
#define SQ(x) ((x) * (x))
#define SWAP(a,b) {        \
                    a=a+b; \
                    b=a-b; \
                    a=a-b; }

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d",&a);
    if(a>=1 && a<=9) b=a;
    else if(a>=10 && a<=99) b=9;
    else if(a>=100 && a<=999) b=a-90;
    else if(a>=1000 && a<=9999) b=909;
    else if(a>=10000 && a<=99999) b=a-9090;
    else if(a>=100000) b=90909;

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

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
#define elasped_time 1.0 * clock() / CLOCKS_PER_SEC
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
long double dp[3000][3000];
int solve(){
 int n;cin>>n;          
 dp[0][0]=1;
 for(int i=1;i<=n;i++){
    long double p;cin>>p;
     for(int j=0;j<=i;j++){
        dp[i][j]=0; 
        if(j>0)dp[i][j]=dp[i-1][j-1]*p;
        dp[i][j]+=dp[i-1][j]*(1-p);
     }
 }           
 long double ans=0;
 for(int i=ceil(n/2.0);i<=n;i++)ans+=dp[n][i];
 cout<<fixed<<setprecision(11)<<ans<<endl;
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 139008
def main():
    from collections import namedtuple

    Dish = namedtuple('Dish', 'idx x v')

    n, c = map(int, input().split())

    ds = []
    for i in range(n):
        x, v = map(int, input().split())
        ds.append(Dish(idx=i, x=x, v=v))

    gol = [0] * n  # 時計回りの最大値
    s = 0
    ma = 0
    for d in ds:
        s += d.v
        ma = max(ma, s - d.x)
        gol[d.idx] = ma

    gor = [0] * n  # 反時計回りの最大値
    s = 0
    ma = 0
    for d in reversed(ds):
        s += d.v
        ma = max(ma, s - (c - d.x))
        gor[d.idx] = ma

    gol0 = [0] * n  # 時計回りから0に戻ったときのカロリー
    for d in reversed(ds):
        gol0[d.idx] = gol[d.idx] - d.x

    gor0 = [0] * n  # 反時計回りから0に戻ったときのカロリー
    for d in reversed(ds):
        gor0[d.idx] = gor[d.idx] - (c - d.x)

    ret = max(max(gol), max(gor))
    for l in range(n - 1):
        t = gol0[l] + gor[l + 1]
        ret = max(ret, t)

    for r in range(n - 1, 0, -1):
        t = gor0[r] + gol[r - 1]
        ret = max(ret, t)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37576
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_counter = Counter(string_list)
most_count = 0
l = []
for v in str_counter.values():
  if v > most_count:
    most_count = v

for k,v in str_counter.items():
  if v == most_count:
    l.append(k)
l.sort()
for i in l:
  print(i)

Measured memory_bytes: 35572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
	int i,n;
	int a,b;
	int m;
	int x[10] = {0};
	int j;
	int ans = 0;
	scanf("%d %d", &a, &b);
	for(i = a ; i <= b ; i++)
	{
		n = i;
		j = 1;
		while(n)
		{
			m = n % 10;
			n = n / 10;
			x[j] = m;
			j++;
		}
		if(x[1] == x[5] && x[2] == x[4])
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

ll GCD(ll a, ll b){
    ll s = a, t = b;
    while(s%t != 0){
        ll u = s%t;
        s=t; t=u;
    }
    return t;
}

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

    ll n,m;cin>>n>>m;
    vll a(n);
    rep(i,n) {cin>>a[i];}
    vll b(n,0);
    auto c = a;
    for(int i=0; i<n; i++){
        while(c[i]%2==0){
            c[i]/=2;
            b[i]++;
        }
    }

    rep(i,n) a[i]/=2;

    bool ok = false;
    rep(i,n-1){
        if(b[i]!=b[i+1]) ok = true;
    }

    if(ok){
        cout<<'0'<<endl;
        return 0;
    }else{
        
        ll t=1;
        rep(i,n){
            ll g = GCD(t, a[i]);
            t = t/g*a[i];
            if(t > m){
                cout<<0<<endl;
                return 0;
            }
        }

        if(t<=m){
        ll ans = 1;
        ll cnt = 0;
        while(true){
            cnt++;
            ll T;
            T = t*ans;
            if(T>m){
                cnt--;
                break;
            }
            if(T==m) break;
            ans+=2;
        }

        cout<<cnt<<endl;
        return 0;

    }
    }
}

Measured memory_bytes: 5568
import collections
S = list(str(input()))
C = collections.Counter(S)
LEN = len(C)
count = 0
if LEN == 2:
    for i in range(3):
        if S[0] == S[i+1]:
            count += 1
#print(LEN,count)
if LEN == 2 and count == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


void solve(LL N, LL x, vector<LL> a){
	SORT(a);
	LL i;
	for (i = 0; i < N && x > 0; i++) {
		x -= a[i];
	}
	if (x != 0) {
		i--;
	}
	cout << i << endl;	
}


int main(){	
	LL N;
	LL x;
	scanf("%lld",&N);
	vector<LL> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}



Measured memory_bytes: 256
S = input()[::-1]
keta = len(S)
mod = 10 ** 9 + 7

dp = [[0 for _ in range(13)] for _ in range(keta + 1)]
dp[0][0] = 1
tmp = 1
for i in range(1, keta + 1):
    if S[i - 1] != "?":
        x = int(S[i - 1]) * (tmp) % 13
        for j in range(13):
            dp[i][(x + j) % 13] += dp[i - 1][j] % mod
    else:
        for k in range(10):
            x = k * (tmp) % 13
            for j in range(13):
                dp[i][(x + j) % 13] += dp[i - 1][j] % mod
    tmp *= 10
    tmp %= 13

print(dp[keta][5] % mod)


Measured memory_bytes: 66268
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int dp[100100][2];
string s;

int Rec(int i , bool last){

    if(i == s.size())  return 0;

    if(dp[i][last] != -1)  return dp[i][last];

    int Res = 1e9;
    if(i == 0){
        Res = min(Res , Rec(i + 1 , s[i] - '0'));
        Res = min(Res , 1 + Rec(i + 1 , !(s[i] - '0')));
    }
    else {
        if((s[i] - '0') != last)  Res = min(Res , Rec(i + 1 , s[i] - '0'));
        Res = min(Res , 1 + Rec(i + 1 , !last));
    }
    return dp[i][last] = Res;

}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin >> s;
    cout << Rec(0 , 0);
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k,0);
  rep(i,k) cin >> d[i];

  while(1){
    bool flag = false;
    rep(i,k){
      string s = to_string(n);
      rep(j,s.size()) {
        if ((int)s[j] - (int)'0' == d[i]) {
          n++;
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) {
      cout << n << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
using namespace std;
int main()
{

	string S;
	getline(cin,S);
	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == ',')
		{
			S[i] = ' ';
		}
	}

	cout << S;
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    ll t,i,j;
    cin>>t;
    for( i=-2000; i<=2000; ++i)
    {
        for(j=-2000; j<=2000; ++j)
        {
            if(i*i*i*i*i-j*j*j*j*j==t)
            {
                cout<<i<<' '<<j<<nl;
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

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

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll mod = 1e9+7;
ll add(ll a, ll b) { return (a + b) % mod; }
ll mul(ll a, ll b) { return a * b % mod; }
ll fact(ll n) {
    ll res = 1;
    FOR(i, 1, n+1) {
        res = mul(res, i);
    }
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m; cin >> n >> m;
    if (m < n) {
        cout << 0 << endl;
        return 0;
    }
    vector< vector< vector<ll> > > dp(2, vector<vector<ll>>(n, vector<ll>(n, 0)));
    dp[0][0][0] = 1;
    REP(i, m) {
        dp[i+1&1].assign(n, vector<ll>(n, 0));
        REP(j, n) REP(k, n) {
            if (dp[i&1][j][k] == 0) continue;
            // キーアイテム(k以下)挿入
            dp[i+1&1][j][j] = add(dp[i+1&1][j][j], mul(dp[i&1][j][k], k+1));
            // 新しいもの(j+1)を挿入
            if (j+1 < n) {
                dp[i+1&1][j+1][k] = add(dp[i+1&1][j+1][k], dp[i&1][j][k]);
            }
            // それ以外(k+1以上j以下)挿入
            dp[i+1&1][j][k] = add(dp[i+1&1][j][k], mul(dp[i&1][j][k], j-k));
        }
    }
    // cout << dp[m][n-1] << endl;
    ll ans = mul(dp[m&1][n-1][n-1], fact(n-1));
    cout << ans << endl;
    // cout << endl;
    // cout << dp[m&1] << endl;
    // cout << endl;
    // cout << dp[m+1&1] << endl;
}


Measured memory_bytes: 2432
# Synthetic Kadomatsu
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9


def dfs(cur, a, b, c):
	if cur == N:
		return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
	ret0 = dfs(cur + 1, a, b, c) 
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 04 September 2020 11:10:32 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
           int ar[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

           int n;
           cin>>n;
           cout<<ar[n-1]<<endl;
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



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

constexpr int INF = numeric_limits<int>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

const signed is = 1 << 16;
char ib[is], *ip = ib, it;
char S[201][201];
signed main() {
	fread_unlocked(ib, 1, is, stdin);
	int N = 0;
	while ((it = *ip++) != '\n') {
		N = N * 10 + it - '0';
	}
	REP(i, N) {
		REP(j, N) {
			S[i][j] = *ip++;
		}
		ip++;
	}
  queue<int> que;
  que.push(0);
  vector<bool> used(N, false);
  used[0] = 1;
  vector<int> parity(N, -1);
  parity[0] = 0;
  while (que.size()) {
    int i = que.front();
    que.pop();
    REP(j, N) {
      if (S[i][j] == '1') {
        if (used[j]) {
          if (parity[i] == parity[j]) {
		puts("-1\n");
		return 0;
          }
        } else {
          que.push(j);
          used[j] = true;
          parity[j] = 1 - parity[i];
        }
      }
    }
  }
	vector<vector<int>> d(N, vector<int>(N));
	REP(i, N) REP(j, N) {
		d[i][j] = i == j ? 0 : S[i][j] == '1' ? 1 : INF;
	}
	REP(k, N) REP(i, N) REP(j, N) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	int ans = 0;
	REP(i, N) REP(j, N) {
		if (d[i][j] < INF)
			ans = max(ans, d[i][j]);
	}
	printf("%d\n", ans + 1);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+10;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/

signed main(){
  vector<int> a(3);
  rep(i,3)cin>>a[i];
  sort(a.begin(),a.end());
 
  if(a[0]==a[1]&&a[0]!=a[2]) cout<<"Yes"<<endl;
  else if(a[1]==a[2]&&a[0]!=a[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256