akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

string S;

int dreameraser(int idx) {
    if (S.substr(idx,6)=="eraser") {
        if (dreameraser(idx+4)==-1) {
            return idx+6;
        } else {
            return idx+4;
        }
    } else if (S.substr(idx,5)=="erase") {
        if (dreameraser(idx+4)==-1) {
            return idx+5;
        } else {
            return idx+4;
        }
    } else if (S.substr(idx,7)=="dreamer") {
        if (dreameraser(idx+5)==-1) {
            return idx+7;
        } else {
            return idx+5;
        }
    } else if (S.substr(idx,5)=="dream") return idx+5;
    return -1;
}

int main() {
    cin>>S;
    int idx = 0;
    while (idx<S.size()) {
        idx = dreameraser(idx);
        if (idx==-1) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 512
import sys
import itertools
from typing import Callable, List, NoReturn, Tuple

import numpy as np


def main() -> NoReturn:
    scan: Callable[[], str] = sys.stdin.readline

    n, m, x = map(int, scan().rstrip().split())  # type: int, int, int
    book_matrix: np.ndarray = np.array(
        tuple(
            tuple(int(_1) for _1 in scan().rstrip().split()) for _2 in range(n)
        )
    )

    grasp_matrix = np.split(book_matrix, [1], axis=1)[1]
    max_grasp: np.ndarray = np.sum(grasp_matrix, axis=0)

    if not (max_grasp >= x).all():
        print(-1)
        return

    all_books = tuple(range(n))
    prices: List[int] = []

    for k in range(1, n + 1):
        for combs in itertools.combinations(all_books, k):
            total: np.ndarray = np.zeros(m + 1)
            for book in combs:
                total += book_matrix[book]
            if (total[1:] >= x).all():
                prices.append(total[0])

    print(int(min(prices)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27644
x,n = gets.split.map(&:to_i)
if n == 0
  puts x
  exit
end
p = gets.split.map(&:to_i).sort
min = 1000
res = 0
[*(-1..101)].each do |i|
  next if p.include?(i)
  if min > (x - i).abs
    res = i
    min = (x - i).abs
  end
end
puts res

Measured memory_bytes: 14376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    
    int a[26]={0};
    
    for(int i=0; i<s.size(); i++){
        int te=(int)((char)s[i]-'a');
        
        a[te]++;
    }
    
    bool b=true;
    for(int i=0; i<26; i++){
        if(a[i]%2!=0){
            b=false;
        }
    }
    
    if(b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;} 




#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point{
public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p) {return Point(x + p.x, y + p.y);}
	Point operator - (Point p) {return Point(x - p.x, y - p.y);}
	Point operator * (double a) {return Point(x * a, y * a);}
	Point operator / (double a) {return Point(x / a, y / a);}
	double abs(){return sqrt(norm());}
	double norm(){return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x != p.x ? x<p.x : y<p.y;
	}
	bool operator == (const Point &p) const {
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
class Circle{
public:
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0):c(c),r(r){}
};

typedef Point Vector;
double arg(Vector p){return atan2(p.y,p.x);}
Vector polar(double a,double r){ return Point(cos(r) * a, sin(r)*a); }

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
	//assert(intersect(c1,c2));
	double d = (c1.c - c2.c).abs();
	double a = acos((c1.r*c1.r + d*d - c2.r*c2.r ) / (2.0*c1.r*d) );
	double t = arg(c2.c - c1.c);
	return make_pair(c1.c+polar(c1.r,t+a), c1.c + polar(c1.r ,t-a));
}

int main(){
	Circle c1,c2;
	cin >> c1.c.x >> c1.c.y >> c1.r;
	cin >> c2.c.x >> c2.c.y >> c2.r;

	auto ans = getCrossPoints(c1,c2);
	if(ans.first.x < ans.second.x){
		out(7) << ans.first.x << " " << ans.first.y << " " << ans.second.x << " " << ans.second.y << endl;
	}else if(ans.first.x > ans.second.x){
		out(7) << ans.second.x << " " << ans.second.y << " " << ans.first.x << " " << ans.first.y << endl;
	}else if(ans.first.y < ans.second.y){
		out(7) << ans.first.x << " " << ans.first.y << " " << ans.second.x << " " << ans.second.y << endl;
	}else{
		out(7) << ans.second.x << " " << ans.second.y << " " << ans.first.x << " " << ans.first.y << endl;
	}

}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include<random>
#include <chrono>
#define lowbit(i) (i&(-i))
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'A'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}



int main()
{
	//file(1);
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0,c - (a - b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(){
  /*
  int t; cin >> t;
  vector<string> ans = {};
  while(t--){
    
  }
  rep(i,ans.size()) cout << ans[i];
  */
  ll h; cin >> h;
  if(h == 1) cout << 1 << "\n";
  else{
    ll ans = 0; ll d = 1;
    while(h > 0){
      ans += d;
      h /= 2;
      d<<= 1;
    } 
    cout << ans << "\n";
  }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n;cin >> n;
    vl d(3);
    rep(i,3)cin>>d[i];
    vpii q;
    rep(i,n){
        string s;cin >> s;
        int a,b;
        if(s == "AB")a = 0,b=1;
        else if(s == "AC")a = 0,b=2;
        else a = 1,b=2;
        q.emplace_back(a,b);
    }
    string res;
    q.emplace_back(0,1); //番兵
    rep(i,n){
        int a = q[i].first;
        int b = q[i].second;
        if(d[a] == 0 && d[b] == 0){
            out("No");
            return 0;
        }
        if(!d[a]){
            d[a]++;
            d[b]--;
            res += 'A'+a;
        }
        else if(!d[b]){
            d[a]--;
            d[b]++;
            res += 'A'+b;
        }
        else{ //1手先を読む必要がある
            int na = q[i+1].first;
            int nb = q[i+1].second;
            if(a == na || a == nb){
                d[a]++;
                d[b]--;
                res += 'A'+a;
            }
            else{
                d[a]--;
                d[b]++;
                res += 'A'+b;
            }
        }
    }
    out("Yes");
    rep(i,n)out(res[i]);
}

Measured memory_bytes: 4296
N = int(input())
S = input()

countE = [0]*(N+1)
countW = [0]*(N+1)

for i in range(N):
    countW[i + 1] = countW[i]
    if S[i] == 'W':
        countW[i+1] += 1

for i in range(1, N):
    countE[N-i-1] = countE[N-i]
    if S[N-i] == 'E':
        countE[N-i - 1] += 1

minx = N+1
for i in range(N):
    newv = countW[i] + countE[i]
    if minx > newv:
        minx = newv

print(minx)


Measured memory_bytes: 23420
#include<stdio.h>
int main()
{
	int A,B,C,x=1,kaunt;
	while(scanf("%d %d",&A,&B)!=EOF)
	{
		kaunt=1;
		C=A+B;
		while(1)
		{
			C=C/10;
			if(C!=0)
				kaunt++;
			else
				break;
		}
		printf("%d\n",kaunt);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int D, N;
    cin >> D >> N;
    if(N != 100) {
        cout << setprecision(10) << pow(100, D) * N << endl;
    }else{
        cout << setprecision(10) << pow(100, D) * 101 << endl;
    }
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;


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

    int N, T, L, B;
    char c[101];
    double p[101][101];
    while (cin >> N >> T >> L >> B && N) {
        rep(i, N + 1) c[i] = '.';
        rep(i, L) {
            int l;
            cin >> l;
            c[l] = 'L';
        }
        rep(i, B) {
            int b;
            cin >> b;
            c[b] = 'B';
        }

        rep(i, 101) rep(j, 101) p[i][j] = 0;
        p[0][0] = 1;
        rep(t, T) {
            rep(i, N) {
                rep2(d, 1, 6 + 1) {
                    int ni = i + d;
                    if (ni > N) {
                        ni = N - (ni - N);
                    }

                    if (c[ni] == 'B') {
                        p[t + 1][0] += p[t][i] / 6;
                    } else if (c[ni] == 'L') {
                        if (t + 2 <= T) p[t + 2][ni] += p[t][i] / 6;
                    } else {
                        p[t + 1][ni] += p[t][i] / 6;
                    }
                }
            }
            p[t + 1][N] += p[t][N];
        }

        printf("%.10f\n", p[T][N]);
    }
}

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

int main()
{
    stack<int> stk;
    string s;
    while (cin >> s) {
        if (s == "+") {
            int op1 = stk.top(); stk.pop();
            int op2 = stk.top(); stk.pop();
            stk.push(op2 + op1);
        } else if (s == "-") {
            int op1 = stk.top(); stk.pop();
            int op2 = stk.top(); stk.pop();
            stk.push(op2 - op1);
        } else if (s == "*") {
            int op1 = stk.top(); stk.pop();
            int op2 = stk.top(); stk.pop();
            stk.push(op2 * op1);
        } else {
            stk.push(stoi(s));
        }
    }
    cout << stk.top() << endl;
}


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

#define MAXN 10005
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define INF 2147483647
#define EPS 1e-9
#define PI 3.141592653589793238462
#define MOD 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<PII > VPII;
typedef vector<VPII > VVPII;
typedef map<int,int> MII;

double density;
int a, b, c, d, e, f, sugar[MAXN], water [MAXN], ans1, ans2;

int main()
{
    density = -1;
    cin >> a >> b >> c >> d >> e >> f;
    sugar[0] = 1;
    for (int i = 0; i <= f; ++i) {
        if (sugar[i])
            sugar[i + c] = sugar[i + d] = 1;
    }
    water[0] = 1;
    for (int i = 0; i <= f; i += 100) {
        if (water[i]) {
            water[i + a * 100] = water[i + b * 100] = 1;
            for (int j = 0; j <= f; ++j) {
                if (sugar[j] && (j <= e * (i / 100)) && (j + i <= f) && (density < ((j * 1.0) / (j + i)))) {
                    ans1 = j + i;
                    ans2 = j;
                    density = (j * 1.0) / (j + i);
                }
            }
        }
    }
    // wcout << endl;
    cout << ans1 << " " << ans2;
    return 0;
}


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

// ------ disjoint set ------ //
struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n; cin >> n;
    UnionFind uf(n * 2);
    for (int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w; u--, v--;
        if (w % 2) {    // x と y は異なる色
            uf.unionSet(u, v + n);
            uf.unionSet(u + n, v);
        } else {
            uf.unionSet(u, v);
            uf.unionSet(u + n, v + n);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << uf.findSet(0, i) << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(H: int, W: int, K: int):
    comb_ = [[] for _ in range(W)]
    comb_[0] = [0, 1] # yes, no
    for i in range(1, W):
        comb_[i] = [comb_[i - 1][1], sum(comb_[i - 1])]
    comb = []
    for c in comb_:
        comb.append(c[0] + c[1])
    #print(comb)
    # dp[h + 1][w][2]
    dp = [[[0] * 2 for i in range(W)] for _ in range(H + 1)]
    dp[0][0][1] = 1
    for h in range(1, H + 1):
        for w in range(W):
            dp[h][w][0] = dp[h - 1][w][1]
        #print(dp)
        for w in range(W):
            dp[h][w][1] += dp[h][w][0] * comb[max(0, w - 1)] * comb[max(0, W - w - 2)]
            if w > 0:
                dp[h][w][1] += dp[h][w - 1][0] * comb[max(0, w - 2)] * comb[max(0, W - w - 2)]
            if w < W - 1:
                dp[h][w][1] += dp[h][w + 1][0] * comb[max(0, w - 1)] * comb[max(0, W - w - 3)]
    #print(dp)
    ret = dp[H][K - 1][1] % MOD
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(H, W, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        string s;
        cin >> s;
        vector<int> b(N + 2), w(N + 2);
        for (int i = 0; i < N; ++i) {
            if (s[i] == '#') b[i + 1] = 1;
            else w[i + 1] = 1;
        }
        for (int i = 0; i <= N; ++i) {
            b[i + 1] += b[i];
            w[i + 1] += w[i];
        }

        int ans = INF;
        for (int i = 0; i <= N; ++i) {
            int B = b[i];
            int W = w.back() - w[i];
            int tmp = B + W;
            chmin(ans, tmp);
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 2172
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;


int main() {
  ll n;
  cin >> n;
  ll mon = 100;
  ll count = 0;
  while (n > mon) {
    count += 1;
    mon += mon*0.01;
    debug(mon);
  }
  cout << count << endl;
}


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

long n;

long partition(long A[], long p, long r){
	long x = A[n - 1];
	long i = p - 1;
	long j;
	for (j = p; j < r; j++){
		if (A[j] <= x){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[n - 1]);
	return i + 1;
}

int main(){
	cin >> n;
	long A[100000];
	for (long i = 0; i < n; i++) cin >> A[i];
	long p = partition(A, 0, n - 1);
	for (long i = 0; i < n; i++){
		if (i) cout << " ";
		if (i == p) cout << "[" << A[i] << "]";
		else cout << A[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1936
import sys

input = sys.stdin.readline

def main(n, lst):
	cnt = 0
	for i in range(n-1):
		if lst[i] > lst[i+1]:
			cnt += lst[i] - lst[i+1]
			lst[i+1] = lst[i]
	return cnt

n = int(input())
lst = list(map(int, input().split()))
print(main(n, lst))

Measured memory_bytes: 31348
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::map<i64, i64> tally;
  for (const i64& A_i : A) {
    ++tally[A_i];
  }

  i64 answer = 0;
  std::vector<bool> is_divisible(1000001, false);
  for (const std::pair<i64, i64>& pair : tally) {
    if (!is_divisible[pair.first]) {
      if (pair.second == 1) {
        ++answer;
      }
      for (i64 i = pair.first * 2; i <= 1000000; i += pair.first) {
        is_divisible[i] = true;
      }
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 17404
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
char s[maxn];ll k;
vector<int> t;
int main()
{
 	ios::sync_with_stdio(false);
	cin>>s>>k;
	int n = strlen(s);
	bool ok = 1;
	int cur = 1;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			ok = 0;
			t.pb(cur);
			cur = 1;
		}
		else  cur++;
	}
//	cout<<"!"<<ok<<endl;
	t.pb(cur);
	if(ok){
		k *= n;
//		cout<<"!"<<k<<" "<<(k/2)<<endl;
		cout << k/2 << endl;
		return 0;
	}
	ll ans = 0;
	for(int x:t){
		ans += (x/2)*k;
	}
	if(s[0]==s[n-1]){
		int a = t[0];
		int b = t.back();
		ans -= (a/2)*(k-1);
		ans -= (b/2)*(k-1);
		ans += ((a+b)/2)*(k-1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
int main(){
  int x[3000], y[3000];
  int count=0;
  int temp;

  for(int i=0; i<3000; i++){
  std::cin >> x[i] >> y[i];
  if( x[i]==0 && y[i]==0 ) { break; }
  count++;
  }

  for(int i=0; i<count; i++){
    if( x[i] > y[i] ){
      temp = x[i];
      x[i] = y[i];
      y[i] = temp;
    }
  std::cout << x[i] << " " << y[i] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n+1),B(n),AA;
  for(auto &a:A){cin>>a;AA.pb(a);}
  for(auto &a:B)cin>>a;
  ll ans=0;
  for(int i=0;i<n;i++){
    ll mi=min(A[i],B[i]);
    A[i]-=mi;
    B[i]-=mi;
    A[i+1]=max(0LL,A[i+1]-B[i]);
  }
  for(int i=0;i<n+1;i++)
    ans+=AA[i]-A[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    int n;
    cin>>n;
    vi a(n);
    int b[100];
    rep(i,n){cin>>a[i];b[i]=a[i];}
    
    //sort(all(a));
    sort(a.begin(),a.end());
    sort(b,b+n);
    //rep(i,n){cout<<a[i]<<' ';}
    //rep(i,n){cout<<b[i]<<' ';}
    cout<<a[n-1]-a[0]<<endl;

}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  map<string, int> c;
  string S;
  rep(i, N){
    cin >> S;
    c[S]++;
  }

  
  cout << "AC x " << c["AC"] << endl;
  cout << "WA x " << c["WA"] << endl;
  cout << "TLE x " << c["TLE"] << endl;
  cout << "RE x " << c["RE"] << endl;

  return 0;
}


Measured memory_bytes: 3644
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = []
for i in n : P.append([int(x) for x in input().split()])
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

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

int main() {
    int n;
    cin >> n;
    string w[n];
    rep(i, n) cin >> w[i];

    bool ok = true;
    rep(i, n - 1) if (w[i][w[i].size() - 1] != w[i + 1][0]) ok = false;
    rep(i, n-1) for (int j = i+1; j < n; j++) {
        if (w[i] == w[j]) ok = false;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    int n;
    cin>>n;
    vi a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int sum=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=sum;
        if(a[i]%b[i]==0)
            continue;
        sum+=(b[i]-a[i]%b[i]);
    }
    cout<<sum;

}

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

int main()
{
    double a,b,x,y;
    cin>>a>>b>>x>>y;
    printf("%f ",a*b/2.0);
    if(x==a/2.0&&y==b/2.0)
        cout<<1;
    else cout<<0;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define ld long double
int power_mod(int num,int g)
{
    if(g==0)return 1;
    if(g%2==1)return (num*power_mod((num*num)%mod,g/2))%mod;
    return power_mod((num*num)%mod,g/2);
}
int power(int num,int g)
{
    if(g==0)return 1;
    if(g%2==1)return (num*power((num*num),g/2));
    return power((num*num),g/2);
}
int32_t main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    

    int a[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int c;
    cin>>c;
    cout<<a[c-1]<<endl;
    return 0;
}

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

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

  int ans = 1;
  for (int i = 2; i*i <= n; i++) {
    int tmp = i;
    while (tmp <= n) tmp*=i;
    tmp /= i;
    ans = max(ans, tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream> 
#include<vector>
#include <algorithm>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;

int main(){
    int n ;
    cin >> n ;
    vector<int> A(n) ;
    rep(i,n) cin >> A[i] ;
    rep(i,n) A[i] -= i + 1 ;
    sort(A.begin(),A.end()) ;
  	ll ans = 0 ;
    if( n % 2 == 1 ) rep(i,n) ans += abs( A[i] - A[ (n+1)/2 - 1 ] );
    else rep(i,n) ans += abs( A[i] - A[ n / 2 ] );
  	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n; ll k;
    cin >> n >> k;
    vector<int> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(rall(f));

    auto ok = [&](ll x) {
                  ll cost = 0;
                  rep(i, n) cost += max(0LL, a[i] - x / f[i]);
                  return cost <= k;
              };
    ll l = -1, r = 1e12;
    while (r - l > 1) {
        ll mid = (l + r) >> 1;
        if (ok(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define rrep(i, j) for (int i = j - 1; i >= 0; i--)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 998244353;
const ll inf = (1LL << 50);

template <class Monoid>
struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid &unity) : F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }
        return F(vleft, vright);
    }
    inline Monoid operator[](int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R - 1) cout << ",";
        }
        cout << endl;
    }
};

void solve(long long N, std::vector<long long> X, std::vector<long long> D) {

    vector<pair<int, int>> vp(N);
    rep(i, N) {
        vp[i].first = X[i];
        vp[i].second = D[i];
    }
    sort(all(vp));

    vi dp(N + 1, 0);
    dp[N] = 1;
    SegTree<int> seg(N, [](int a, int b) { return max(a, b); }, 0);
    rrep(i, N) {
        int ri = lower_bound(all(vp), make_pair(vp[i].first + vp[i].second, 0LL)) - vp.begin();
        ri = max(i + 1, seg.get(i + 1, ri));
        dp[i] = (dp[i + 1] + dp[ri]) % mod;
        seg.update(i, ri);
    }

    cout << dp[0] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    std::vector<long long> D(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &D[i]);
    }
    solve(N, std::move(X), std::move(D));
    return 0;
}


Measured memory_bytes: 12160
#include <stdio.h>
int main(void){
    int i,j;
    char n[100000]={0};
    int x[1001]={0};

    i=0;
    j=0;

    while(1){
        scanf("%c",&n[i]);
        if((n[i] == '0' && n[i-1] == '\n')|| n[0] == '0'){break;}

        if((n[i] >= '1' && '9' >= n[i]) && n[i] != '\n') {
            x[j] += n[i]-48;
        }
        if(n[i] == '\n') {
            j = j + 1;
        }
    i= i+1;
    }

    for(i=0; i < j;i++) {
        printf("%d",x[i]);
        printf("\n"); 

    } 

return 0;

}


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

#define ll long long
#define ld long double
#define debug(x) \
	//    (cout << #x << ": " << (x) << endl)
#define eb emplace_back
#define fi first
#define se second

using namespace std;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ll a;
	long double b;
	cin >> a >> b;
	ll tmp = a * (ll) ((b + 1e-6) * 100.0);
	cout << tmp / 100 << "\n";
}


Measured memory_bytes: 3732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

unsigned long long int fac(int n) {
    unsigned long long int r = 1;
    for (int i = 1; i <= n; i++) {
        r *= 2;
    }
    return r;
}

void genbin(int n, char *bin, int l) {
    int i = 0;
    memset(bin, '\0', 11); //sizeof(bin));
    bin[0] = '0';
    while (n >= 1) {
        bin[i++] = (n % 2) + '0';
        n = n / 2;
    }
    // 6 -> 011

    // 0埋め（後ろへ０を詰めて、）
    int m = strlen(bin);
    for (;m < l; m++) {
        bin[m] = '0';
    }
    bin[m] = '\0';
    // 6 -> 011 -> 0110

    // swap（最初と最後を交換すると、ヒューマンリーダブルなバイナリ文字列ができる）
    m = strlen(bin);
    i = m - 1;
    for (int j = 0; j < m/2; j++) {
        char t = bin[i];
        bin[i] = bin[j];
        bin[j] = t;
        i -= 1;
    }
    // 6 -> 011 -> 0110 -> 0110
}

unsigned long long int ebal(char *s, char *op) {
    unsigned long long int r = 0;
    char t[10+10+1] = {0};

    //  s[i] = 123
    // op[k] =  01z
    //  t[j] = 12+3+
    for (int i = 0, j = 0, k = 0, l = 0; i < strlen(s); i++, k++) {
        t[j++] = s[i];
        if (op[k] == '1' || op[k] == 'z') {
            char u[10+1] = {0};
            strncpy(u, t+l, j-l);
            u[j-l+1] = '\0';
            //printf("i=%d j=%d k=%d l=%d s=%s op=%s u=%s\n", i, j, k, l, s, op, u);
            r += atol(u);
            t[j++] = '+';
            l = j;
        }
    }
    //printf("%s %s\n", op, t);
    //eval(t);

    return r;
}

int main() {
    char s[10+1];
    scanf("%s", s);

    int l = strlen(s);
    if (l == 1) {
        printf("%s\n", s);
        return 0;
    }

    char bin[9+1+1] = {0};
    unsigned long long int r = 0;
    for (unsigned long long int i = 0; i < fac(l-1); i++) {
        genbin(i, bin, l-1);
        bin[strlen(bin)] = 'z'; // 終端文字番兵
        bin[strlen(bin)+1] = '\0';
        r += ebal(s, bin);
    }

    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 128
// 何で合わないのかわからない.考察が間違っている可能性がある.
#include<iostream>
#include<set>
#include<map>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

bool x[1000001] = {};
bool y[1000001] = {};

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

    int a[n], b[m];
    bool valid = true;
    map<int,int> reva, revb;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(x[a[i]]) valid = false;
        x[a[i]] = true;
        reva[a[i]] = i;
    }

    for(int i = 0; i < m; i++){
        cin >> b[i];
        if(y[b[i]]) valid = false;
        y[b[i]] = true;
        revb[b[i]] = i;
    }

    if(!valid){
        cout << 0 << endl;
        return 0;
    }

    bool usei[n], usej[m];
    int cnti = 0, cntj = 0;
    for(int i = 0; i < n; i++)  usei[i] = false;
    for(int j = 0; j < m; j++)  usej[j] = false;

    ll ans = 1;
    ll vacant = 0;
    for(int i = n*m; i >= 1; i--){
        int tmp = 0, add = 0;
        if(reva.count(i)){
            tmp++;
            usei[reva[i]] = true;
            vacant += cntj;
            add += cntj;
            cnti++;
        }
        if(revb.count(i)){
            tmp++;
            usej[revb[i]] = true;
            vacant += cnti;
            add += cnti;
            cntj++;
        }

        if(tmp == 2){
            // iは固定
            vacant--;
            continue;
        }

        if(vacant == 0){
            // 空きマス無し
            cout << 0 << endl;
            return 0;
        }

        if(add != 0){
            ans *= add;
        }else{
            ans *= vacant;
        }
        ans %= mod;
        vacant--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	D.push_back(0);
	map<int, int> cnt;
	for (int i = 0; i < D.size(); i++) cnt[D[i]]++;
	vector<int> DD;
	int sign = 1;
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		if (itr->second >= 3) {
			cout << 0 << endl;
			system("pause");
			return 0;
		}
		else {
			if (itr->second == 2) {
				DD.push_back(itr->first);
				DD.push_back(- itr->first);
			}
			else {
				DD.push_back(sign * itr->first);
				sign *= -1;
			}
		}
	}
	int ans = 24;
	for (int i = 0; i < DD.size() - 1; i++) {
		for (int j = i + 1; j < DD.size(); j++) {
			int buf = min(abs(DD[i] - DD[j]), 24 - abs(DD[i] - DD[j]));
			ans = min(ans, buf);
		}
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

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

int main()
{
    int N, Q;
    unordered_map<int, int> A;
    uint64_t ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int A_i;
        cin >> A_i;
        ans += A_i;
        A[A_i]++;
    }
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int B_i, C_i, count;
        cin >> B_i >> C_i;
        count = A[B_i];
        A[B_i] = 0;
        A[C_i] += count;
        ans += (C_i - B_i) * count;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6984
#include "bits/stdc++.h"

using namespace std;

int main()
{
    while (true) {
        size_t n, x;
        cin >> n >> x;
        if (n + x == 0) break;
        size_t m1 = x / 3;
        size_t m2 = (x + 2) / 3;
        size_t count = 0;
        for (size_t i = 1; i < m1; ++i) {
            for (size_t j = n; j > m2; --j) {
                int64_t k = x - i - j;
                if (k > i && k < j) ++count;
            }
        }
        cout << count << endl;
    }
    
    return 0;
}



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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N + 1), v(N + 1);
  rep(i, N) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(N + 2, vector<ll>(N * 1005, INF));
  dp[0][0] = 0; // 最初の重さは0
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N * 1000; j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (0 <= j - v[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
    }
    // dumpv(i, dp, N, 60);
  }
  ll ans = 0;
  for (int j = 1; j <= N * 1000; j++) {
    if (dp[N][j] <= W)
      ans = max(ans, (ll)j);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("e.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 81408
h,w=map(int,input().split())
b=[]
b.append(list('.'*(w*2)))
for i in range(h):
    a=list('.'+str(input())+'.')
    b.append(a)

b.append(list('.'*(w*2)))

for y in range(1,h+1):
    for x in range(1,w+1):
        if b[y][x]=='#':
            up   = b[y-1][x]
            down = b[y+1][x]
            left = b[y][x-1]
            right= b[y][x+1]

            if up=='.' and down=='.' and left=='.' and right=='.':
                print('No')
                exit()

print('Yes')








Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mm=1000000007;
const int n=10000000;

void solve()
{
	int a,b;
	cin>>a>>b;
	if(a*b%2==0)
		cout<<"Even\n";
	else
		cout<<"Odd\n";

}

int main(){
	ios::sync_with_stdio(0);
	//int t; cin >> t; while(t--)
	solve();
	//cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ??\?????°????????????????????°
		int input = sc.nextInt();

		// ???????????????
		int[][] card = new int[4][13];

		// ?????°????????????????????????????????°????????????
		String mark;
		int num;

		// ?????????????????°?????????
		int cnt;

		// ??????????????????????????????
		for (cnt = 0; cnt < input; cnt++) {

			mark = sc.next();
			num = sc.nextInt();

			switch (mark) {

			case "S":
				card[0][num - 1] = 1;
				break;

			case "H":
				card[1][num - 1] = 1;
				break;

			case "C":
				card[2][num - 1] = 1;
				break;

			case "D":
				card[3][num - 1] = 1;
				break;
			}

		}

		// ???????????????????????\????????????
		// ????¨?????????°???num???cnt???????????¨
		for (num = 0; num <= 3; num++) {

			for (cnt = 0; cnt <= 12; cnt++) {

				if (card[num][cnt] == 0) {

					switch (num) {

					case 0:
						System.out.println("S " + (cnt+1));
						break;

					case 1:
						System.out.println("H " + (cnt+1));
						break;

					case 2:
						System.out.println("C " + (cnt+1));
						break;

					case 3:
						System.out.println("D " + (cnt+1));
						break;
					}

				}

			}

		}
		sc.close();
	}

}

Measured memory_bytes: 26172