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

#define int long long

bool is_palin(string s){
    string t(s.rbegin(), s.rend());
    return t == s;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    int N = s.length();
    string first = s.substr(0, (N-1)/2);
    string second = s.substr((N+1)/2);
    if(is_palin(s) && is_palin(first) && is_palin(second)){
        cout << "Yes";
    }
    else cout << "No";
    cout << "\n";
}

Measured memory_bytes: 256
from collections import Counter

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

C1 = list(dict(Counter(A[::2])).items())
C2 = list(dict(Counter(A[1::2])).items())

C1.append([-1, 0])
C2.append([-1, 0])
C1.sort(key=lambda x: x[1], reverse=True)
C2.sort(key=lambda x: x[1], reverse=True)

if C1[0][0] != C2[0][0]:
    print(N - C1[0][1] - C2[0][1])
else:
    ans1 = N - C1[0][1] - C2[1][1]
    ans2 = N - C1[1][1] - C2[0][1]
    print(min(ans1, ans2))


Measured memory_bytes: 20696
import sys

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

for i in A:
    if i == 0:
        print(0)
        sys.exit(0)

ans = 1
for i in A:
    ans *= i
    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)

print(ans)

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

int main(){
    int n;
    cin >> n;
    int F[n][10], P[n][11];
    for(int i = 0 ; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0 ; i < n; i++){
        for(int j = 0; j < 11; j++){   //なんで11個？と最初は思ったがどちらも営業していない場合を含める為
            cin >> P[i][j];
        }
    }

    long long ans = -1 * (1 << 30);   //左シフト  ex.) 1 << 3 == 8
    for(int i = 1; i < (1 << 10); i++){   //i = 1から始めることに注意（i = 0の時は全ての時間帯の営業しない為）
        long long c1 = 0;
        for(int j = 0; j < n; j++){
            int c2 = 0;
            for(int k = 0; k < 10; k++){   //iの二進数表記のk番目のbit
                if(((i >> k) & 1) and (F[j][k])){
                    c2++;
                }
            }
            c1 += P[j][c2];   //もしc2が加算されなかった場合(0) -> 店jと一度も同じ時間帯で営業していない場合
        }
        ans = max(ans, c1);
    }
    cout << ans << endl;

    //入力例2は二つの店が常に営業しているのでP[][0]を選択することはない

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,x,i,j,k,num;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==x && n==0) break;
		num=0;
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x){
						num++;
					}
				}
			}
		}
		printf("%d\n",num);
	}
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

const int mod = 1e9 + 7;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

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

mint binomial(ll N, ll K) {
  if (K < 0 || N < K) return 0;
  mint ret = 1;
  for (ll i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  mint ans = -1;
  ans += mod_pow(2, n, mod);
  ans -= binomial(n, a);
  ans -= binomial(n, b);

  cout << ans.x << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  int N, t;
  unsigned long long count[1001] = {}, ans = 1;

  cin >> N;

  for(int i = 2;i <= N;i++){
    t = 2;
    int temp = i;

    while(i >= t*t){
      if(temp % t == 0){
        count[t]++;
        temp /= t;
      } else {
        t++;
      }
    }
    count[temp]++;
  }

  for(int i = 2;i <= N;i++){
    ans *= (count[i] + 1);
    ans %= (1000000000 + 7);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	double xmax = (n + 1) / 1.08, xmin = n / 1.08;
	for (int i = xmin; i < xmax; i++) {
		int ans = i * 1.08;
		if (ans == n) { cout << i << endl; return 0; }
	}
	cout << ":(" << endl;

	return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int not_prime[31625];

vector<ll> factorize(ll n){
    vector<ll> ret;
    ll i = 2, rt = sqrt(n);
    while(n != 1 && i <= rt){
        if(not_prime[i]){
            i++;
            continue;
        }
        ll j = i;
        while(j <= rt){
            not_prime[j] = 1;
            j += i;
        }

        while(n % i == 0){
            n /= i;
            ret.push_back(i);
        }

        i++;
    }
    if(n != 1){
        ret.push_back(n);
    }
    return ret;
}

ll euler_phi_function(ll n){
    vector<ll> facts = factorize(n);
    facts.erase(unique(all(facts)), facts.end());

    ll ret = n;
    for(ll fact: facts){
        ret *= (fact-1);
        ret /= fact;
    }
    return ret;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    cout << euler_phi_function(n) << endl;
    
}



Measured memory_bytes: 3284
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);

using namespace std;

signed main(){
    int n;
    cin >> n;
    set<int> st;
    map<int, bool> mp;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        st.insert(x);
        if(mp.find(x) == mp.end()){
            mp[x] = true;
        }else{
            if(mp[x]){
                mp[x] = false;
            }else{
                mp[x] = true;
            }
        }
    }
    int cnt = 0;
    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        if(mp[*itr]){
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 11136
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


// Union-Find法。無向グラフをつなげる。
void union_init(vector <int>& v, int size)
{
	v.clear();
	for (int i = 0; i<size; i++)
	{
		v.push_back(i);
	}
}

// union_connect後に、union_getすると、vはグループの代表番号が入る。v[n]=t行。
// 
int union_get(vector <int>& v, int n)
{
	int t = n;
	int k;
	while (v[t] != t)
	{
		t = v[t];
	}

	while (v[n] != n)
	{
		k = v[n];
		v[n] = t;
		n = k;
	}
	return n;
}


// ノードaとノードbをつなぐ。
// union_connect後のvには、同じグループに入るノードのうちの1つの番号が入る
bool union_connect(vector <int> & v, int a, int b)
{
	a = union_get(v, a);
	b = union_get(v, b);
	if (a == b)
	{
		return false;
	}

	v[a] = b;
	return true;
}

int main() 
{
	int H, W;
	cin >> H >> W;

	vector <string> board(H);

	for (int y = 0; y < H; ++y)
	{
		cin >> board[y];
	}

	const int N = H * W;

	// セットでつかっとけ
	vector <int> v;
	union_init(v, N);

	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			const static int dy[] = { -1, 0, 1, 0 }; // U,R,D,L
			const static int dx[] = { 0, 1, 0,-1 };
			for (int d = 0; d < 4; ++d)
			{
				const int ny = y + dy[d];
				const int nx = x + dx[d];
				if (INRANGE(ny, 0, H - 1) && INRANGE(nx, 0, W - 1))
				{
					if (board[y][x] != board[ny][nx])
					{
						union_connect(v, y*W + x, ny*W + nx);
					}
				}
			}
		}
	}

	vector <ll> num_nodes_black(N);
	vector <ll> num_nodes_white(N);

	for (int y = 0; y < H; ++y)
	{
		for (int x = 0; x < W; ++x)
		{
			if (board[y][x] == '#')
			{
				num_nodes_black[union_get(v, y*W + x)]++;
			}
			else
			{
				num_nodes_white[union_get(v, y*W + x)]++;
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ans += num_nodes_black[i] * num_nodes_white[i];
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define int long long

const int N = 2e5 + 5;
int n, a[5], f[N], ans = 1e18 + 7;

int cnp1(int l, int r, int i){
    int res = 0;
    while(l <= r){
        int mid = (l + r) / 2;
        if(f[mid] <= f[i] - f[mid]) res = mid, l = mid + 1;
        else r = mid - 1;
    }
    return res;
}

int cnp2(int l, int r, int id){
    int res = id;
    while(l <= r){
        int mid = (l + r) / 2;
        if(f[mid] - f[id] <= f[n] - f[mid])res = mid, l = mid + 1;
        else r = mid - 1;
    }
    return res;
}

int solve(int l, int mid, int r){
    int res = 0;
    a[1] = f[l]; a[2] = f[mid] - f[l];
    a[3] = f[r] - f[mid]; a[4] = f[n] - f[r];
    for(int i = 1 ; i<= 4; ++ i)
        for(int j = i + 1; j <= 4; ++ j) res = max(res, abs(a[i] - a[j]));
    return res;
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++ i) cin >> f[i], f[i] += f[i - 1];
    for(int i = 2; i < n - 1; ++ i){
        int mid_r, mid_l;
        int l = cnp1(1, i, i);
        if(f[i] - 2 * f[l] < 2 * f[l + 1] - f[i]) mid_l = l;
        else mid_l = l + 1;
        int r = cnp2(i + 1, n, i);
        if(f[n] + f[i] - 2 * f[r] < 2 * f[r + 1] - f[i] - f[n]) mid_r = r;
        else mid_r = r + 1;
        ans = min(ans, solve(mid_l, i, mid_r));
    }
    cout << ans;
}


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

int main(){
  int N,K,s;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(x<=K-x)
      s+=x;
    else
      s+=K-x;
  }
  cout<<s*2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    vector<string> v;
    v.push_back("A");
    int ans = v.size();
    string tmp;
    REP(i,n) {
        tmp = "";
        tmp += s[i];
        while(v[ans-1]==tmp && i+1<n) {
            ++ i;
            tmp += s[i];
        }
        v.push_back(tmp);
        if(v[ans-1]!=tmp) ++ ans;
    }
    -- ans;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11016
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[1000010];
    rep(i, N) cin >> A[i];
    int G = 0;
    rep(i, N) G = gcd(G, A[i]);
    set<int> st;
    bool check1 = true;
    rep(i, N) {
        int num = A[i];
        int j = 2;
        while(check1 && num > 1) {
            bool first = true;
            if(j >= 2000) {
                if(st.find(num) != st.end()) {
                    check1 = false;
                }
                st.insert(num);
                break;
            }
            while(num % j == 0) {
                num /= j;
                if(first && st.find(j) != st.end()) {
                    check1 = false;
                    break;
                }
                first = false;
                st.insert(j);
            }
            j++;
        }
    }
    if(check1) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    if(G == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
    //cout << G << endl;


    return 0;
}


Measured memory_bytes: 11420
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
using ll = int; using namespace std;

#ifndef __GNUC__
string text =
R"X(50)X";
stringstream iss{text};
#endif

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

	ll N; iss >> N;
	bool ok{false};
	auto qr = div(N, 1);
	for (ll i = 1; i < 10; ++i) {
		qr = div(N, i);
		if (qr.rem == 0 && qr.quot < 10) ok = true;
	}
	cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 3620
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

//const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500020;

int siz[MAX];//錬結成分のサイズ
int par[MAX];//親
int Rank[MAX];//木の深さ

//n要素で初期化
void init(int n) {
	REP(i, n) {
		par[i] = i;
		Rank[i] = 0;
		siz[i] = 1;
	}
}

//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);//経路圧縮(根に直接つなぎなおす)もしつつ
	}
}

//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	//低いほうを高いほうにつなげる(効率化)
	if (Rank[x] < Rank[y]) {
		par[x] = y;
		siz[x] += siz[y];
		siz[y] = siz[x];
	}
	else {
		siz[y] += siz[x];
		siz[x] = siz[y];
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}

int idx[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	int M; cin >> M;
	init(3*N + 1);
	REP(i, N) {
		int p; cin >> p;
		idx[p] = i + 1;
		unite(p, i + 1 + N);
	}
	REP(i, M) {
		int x, y; cin >> x >> y;
		unite(idx[x] + N, idx[y] + N);
	}
	int ans = 0;
	FOR(i,1,N+1){
		if (same(i, i+N))ans++;
	}
	print(ans);
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
int ca=1;
using namespace std;

int main(){
fast;
    string a;
    cin>>a;
    if(a[2]==a[3]&&a[4]==a[5]){
        cout<<"Yes"<<nl;
    }else{
         cout<<"No"<<nl;

    }
    return 0;
    }


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

int H, W;
// . が白, #が黒
vector<vector<char>> board;
bool bfs();

int main() {
  // input
  cin >> H >> W;

  // 境界に白のマスを足している
  board.assign(H + 2, vector<char>(W + 2, '.'));
  rep(i, H) {
    rep(j, W) { cin >> board[i + 1][j + 1]; }
  }
  // end input

  // solve
  // 貪欲法ですべてのマスについて、孤立している#がないか調べる。
  bool enable = true;
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (board[i][j] == '#') {
        bool case1 = board[i - 1][j] == '.';
        bool case2 = board[i][j - 1] == '.';
        bool case3 = board[i][j + 1] == '.';
        bool case4 = board[i + 1][j] == '.';
        bool is_isolate = case1 && case2 && case3 && case4;
        if (is_isolate) {
          enable = false;
          break;
        }
      }
    }
    if (!enable) {
      break;
    }
  }

  cout << (enable ? "Yes" : "No") << endl;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;

const int N = 1e5 + 10;

int n, q;
int a[N], psum[N], pref[N];

bool check(int x, int mid)    { // check if pos make the right side < the left side
    int val = a[mid - 1] - x;
    int res = lower_bound(a + 1, a + n + 1, x - val) - a;
    return (mid - res) > (n - mid + 1);
}
int solve(int x)     {
    int pos = lower_bound(a + 1, a + n + 1, x) - a;

    int lef = pos + 1, rig = n + 1;
    while(rig > lef)    {
        int mid = (rig + lef) / 2;
        if(check(x, mid)) rig = mid;
        else lef = mid + 1;
    }
    // left = right = correct position
    lef -= 1;
    int val = a[lef - 1] - x;
    int pos1 = lower_bound(a + 1, a + n + 1, x - val) - a;
    pos1 = pos1 - (n - lef + 1 - (lef - pos1));

    int ans = pref[lef - 1] - pref[pos1 - 1];
    if(pos1 >= 3) ans += psum[pos1 - 2];
    return pref[n] - ans;
}

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false);   cout.tie(0);

    cin >> n >> q;
    FOR(i, 1, n)    {
        cin >> a[i];
        pref[i] = a[i] + pref[i - 1];
        psum[i] = a[i]; if(i >= 2) psum[i] += psum[i - 2];
    }
    FOR(i, 1, q)    {
        int x; cin >> x;
        if(x < a[1]) x = a[1];
        if(x > a[n]) x = a[n];
        cout << solve(x) << '\n';
    }

/*    vector<ii> vt;
    FOR(i, 1, q) {
        int x; cin >> x;
        if(x < a[1]) x = a[1];
        if(x > a[n]) x = a[n];
        vt.pb(ii(x, i));
    }
    sort(vt.begin(), vt.end());

    int cnt = 1;
    for(auto i: vt) {
        while(cnt < n && a[cnt] < i.fi) cnt ++;
        if(cnt == 1) qans[i.se] = ans[1];
        else if(cnt == n && ans[n] < i.fi) qans[i.se] = ans[n];
        else qans[i.se] = (a[cnt] - i.fi < i.fi - a[cnt - 1]) ? ans[cnt] : ans[cnt - 1];
    }
    FOR(i, 1, q) cout << pref[n] - qans[i] << '\n';
    return 0;
*/
}


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

int main(){
  ll n;
  cin >> n;
  
  vector<ll> v(n);
  for(ll i=0; i<n; i++) cin >> v[i];
  
  vector<ll> ans(n);
  ans[0] = 0;
  ans[1] = abs(v[1] - v[0]);

  
  for(ll i=2; i<n; i++)
    ans[i] = min(ans[i-2] + abs(v[i]-v[i-2]), ans[i-1] + abs(v[i]-v[i-1]));
  
  cout << ans[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>

int main() {
  int n, x;
  std::cin >> n >> x;
  while (n != 0 || x != 0) {
    int count = 0, n1 = 1, n2 = 2, n3 = 3;
    for (int i = 1; i < n; i++) {
      for (int j = 2; j < n; j++) {
        if (j <= i)
          continue;
        for (int k = 3; k <= n; k++) {
          if (k <= j)
            continue;
          if (i + j + k == x) {
            count++;
          }
        }
      }
    }
    std::cout << count << std::endl;
    std::cin >> n >> x;
  }
  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    REP(i,ty-sy) cout << 'U';
    REP(i,tx-sx) cout << 'R';
    cout << 'U';
    REP(i,tx-sx+1) cout << 'L';
    REP(i,ty-sy+1) cout << 'D';
    cout << 'R';
    REP(i,tx-sx) cout << 'R';
    REP(i,ty-sy) cout << 'U';
    cout << 'R';
    REP(i,ty-sy+1) cout << 'D';
    REP(i,tx-sx+1) cout << 'L';
    cout << 'U' << endl;
}       

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

int main(){
    int N;
    cin >> N;
    long long A[N];
    long long ans = 0;

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

    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){
            long long dif = abs(A[i] - A[j]);
            ans = max(ans, dif);
        }
    }
    cout << ans << endl;
}


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

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

typedef long long Int;

const Int INF = 1e18;


int main() {
    Int N;
    cin >> N;
    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    vector<Int> dp0(N, -INF), dp1(N, -INF);

    dp0[0] = 0;
    dp1[0] = A[0];
    dp0[1] = max(A[0], A[1]);

    for(int i = 2; i<N; i++) {
        if (i % 2 == 1) {
            dp0[i] = max(dp1[i-1], A[i]+dp0[i-2]);
        }
        else {
            dp0[i] = max(dp0[i-1], A[i] + dp0[i-2]);
            dp1[i] = A[i] + dp1[i-2];
        }
    }

    cout << dp0[N-1] << endl;
}


Measured memory_bytes: 8012
#include <iostream>

using namespace std;

void calc(string& s){
    int mask;
    for(int i=0; i<1<<(s.size()-1); ++i){
        int acc=s[0]-'0';
        for(int j=0; j<s.size()-1; ++j){
            if((i >> (s.size()-j-2)) & 1){
                acc+=s[j+1]-'0';
            } else{
                acc-=s[j+1]-'0';
            }
        }
        if(acc==7){
            mask=i;
            break;
        }
    }
    cout << s[0];
    for(int i=0; i<s.size()-1; ++i){
        if((mask >> (s.size()-i-2)) & 1){
            cout << '+';
        } else{
            cout << '-';
        }
        cout << s[i+1];
    }
    cout << "=7\n";
}

int main() {
    string s;
    cin >> s;
    calc(s);
    return 0;
}

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

int main(){
    int a,e=0,b=0,c=0,d=0;
    char h;
    string s;
    while(cin>>a>>h>>s){
        if(s=="A")e++;
        if(s=="B")b++;
        if(s=="AB")c++;
        if(s=="O")d++;
    }
    cout<<e<<endl<<b<<endl<<c<<endl<<d<<endl;
}

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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d)
        cout << "Yes\n";
    else
        cout << "No\n";
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
using namespace std ;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N=3e5+500 ;
int n,m,p[N],ra[N],dir[N],ans[N] ;
bool cmp(int x,int y) { return p[x]<p[y] ; }
int s ;
int main() {
	scanf("%d%d%d",&n,&m,&s) ;
	rep(i,0,n-1) {
		char ch[10] ; scanf("%d %s",p+i,ch) ;
		p[i] = m - p[i];
		ra[i]=i ;
		dir[i]=ch[0]=='1'?-1:1 ;
	}
	sort(ra,ra+n,cmp) ;
	int t=0 ;
	rep(i,0,n-1) {
		if (dir[i]==1) t+=(p[i]+s)/m%n ;
			else t+=(p[i]-s-m+1)/m%n ;
		t=(t%n+n)%n ;
		p[i]=p[i]+s%m*dir[i] ;
		p[i]=(p[i]%m+m)%m ;
	}
	sort(p,p+n) ;
	rep(i,0,n-1) ans[ra[(i+n-t)%n]]=p[i];
	rep(i,0,n-1) printf("%d\n",(m-ans[i])%m) ;
	return 0 ;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli x;
    cin >> x;
    lli sum = 1000 * (x/500);
    x %= 500;
    sum += 5 * (x/5);

    cout << sum << endl;
}

Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;
const int inf = 1000000000;

int abs(int a){
    if(a < 0) return -a;
    return a;
}

//int max(int a, int b){
  //  if(a > b) return a;
    //else return b;
//}

int main(){
    int n;
    cin >> n;
    int stages[n];
    int dp[n];
    for(int i = 0; i<n; i++){
        cin >> stages[i];
        dp[i] = inf;
    }
    
    for(int i = 0; i < n; i++){
        if(i == 0){
            dp[i] = 0;
        }else if(i == 1){
            dp[i] = dp[i-1] + abs(stages[i] - stages[0]);
        }else{
            dp[i] = min((dp[i-2] + abs(stages[i]-stages[i-2])) , (dp[i-1] + abs(stages[i]-stages[i-1])));
        }
    }

    

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int asumikana(const void* x, const void* y) {
	int64_t a = *(const int64_t*)x, b = *(const int64_t*)y;
	return a < b ? -1 : a > b;
}

int64_t zettaiti(int64_t x) {
	return x < 0 ? -x : x;
}

int32_t N;
int64_t A[271828];

int64_t kiten[271828];

int main(void) {
	int32_t i;
	int64_t b;
	int64_t sum = 0;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		kiten[i] = A[i] - (i + 1);
	}
	qsort(kiten, N, sizeof(*kiten), asumikana);
	b = kiten[N / 2];
	for (i = 0; i < N; i++) {
		sum += zettaiti(kiten[i] - b);
	}
	printf("%" PRId64 "\n", sum);
	return 0;
}


Measured memory_bytes: 5372
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local function getComb(n, k)
  local ret = 1
  for i = 1, k do
    ret = bmul(ret, n + 1 - i)
    ret = bmul(ret, modinv(i))
  end
  return ret
end

local n, m, k = io.read("*n", "*n", "*n")
local c = getComb(n * m - 2, k - 2)
local a = bmul(n, bmul(n, bmul(m - 1, bmul(m, bmul(m + 1, modinv(6))))))
local b = bmul(m, bmul(m, bmul(n - 1, bmul(n, bmul(n + 1, modinv(6))))))
print(bmul(c, badd(a, b)))


Measured memory_bytes: 256
import sys
# -*- coding: utf-8 -*-

#calc("",1234) = calc("1",234) + calc("1+"",234)
#calc("1",234) = calc("12",34) + calc("12+",34)
#calc("12+",34) = calc("12+3",4) + calc("12+3+",4)
#calc("12+3",4) = calc("12+34")
def calc(express,i):
    if i == len(nums):
        return sum(list(map(int,express.split("+"))))
    return calc(express + nums[i],i+1) + calc(express + "+"+ nums[i] ,i+1) 

nums = list(input())
print(calc(nums[0],1))


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
int main()
{
    int a , b , c;
    cin >> a >> b >> c;
    if(c >= a && c <= b)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
import java.util.*;


class Main{
public static void main(String[] args) {
  Scanner reader=new Scanner(System.in);
  String a =reader.next();
  if(a.charAt(2)==a.charAt(3)&&a.charAt(4)==a.charAt(5))
  {
    System.out.println("Yes");
    return;
  }
  System.out.println("No");


}
}


Measured memory_bytes: 23636
import java.util.Scanner;

class Daice{
	int mas[];
	Daice(int[] mas){
		this.mas = mas;
	}
	
	void north() {
		int temp = mas[4];
		mas[4] = mas[0];
		mas[0] = mas[1];
		mas[1] = mas[5];
		mas[5] = temp;
	}
	
	void south() {
		int temp = mas[0];
		mas[0] = mas[4];
		mas[4] = mas[5];
		mas[5] = mas[1];
		mas[1] = temp;
	}
	
	void east() {
		int temp = mas[0];
		mas[0] = mas[3];
		mas[3] = mas[5];
		mas[5] = mas[2];
		mas[2] = temp;
	}
	
	void west() {
		int temp = mas[0];
		mas[0] = mas[2];
		mas[2] = mas[5];
		mas[5] = mas[3];
		mas[3] = temp;
	}
}

class Main {

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

		int m[] = {sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};

		Daice d = new Daice(m);
		
		String[] spen = sc.next().split("", 0);
		
		for(int i = 0; i < spen.length; i++) {
			if(spen[i].equals("N")){
				d.north();
			}else if(spen[i].equals("E")) {
				d.east();
			}else if(spen[i].equals("S")) {
				d.south();
			}else {
				d.west();
			}
		}
		System.out.println(d.mas[0]);
	}
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll s(ll n){
    int sum=0;
    while(n){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

void solve() {
    ll K; cin >> K;
    ll a=0, d=1;
    while(K--){
        if(d*s(a+d)<a+d) d *= 10;
        a += d;
        cout << a << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,A;
    cin >>N>>A;
    if(N%500<=A){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    



    return 0;
    

}

Measured memory_bytes: 3632
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    bool z_flg = false;
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 0) z_flg = true;
    }
    if (z_flg) {
        cout << 0 << endl;
        return 0;
    } 
    ll lim = 1e18;
    ll m = a[0];
    for (int i = 1; i < n; ++i) {
        if (lim / a[i] < m) {
            cout << -1 << endl;
            return 0;
        }
        m *= a[i];
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 4020
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    x=int(input())
    y=0
    yen=100
    while True:
        temp=yen//100
        yen+=temp
        y+=1
        if yen>=x:
            break
    print(y)



if __name__ == "__main__":

    main()

Measured memory_bytes: 68212
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	multiset<ll> st;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		st.insert(ar[i]);
	}

	for(i=1;i<=n;i++){
		st.erase(st.find(ar[i]));
		cout<<(*(--st.end()))<<endl;
		st.insert(ar[i]);
	}
	return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int ans[111111];

signed main(){
    int N;
    scanf("%lld",&N);
    vpint v;
    rep(i,N){
        int a;scanf("%lld",&a);
        v.pb({a,i});
    }

    sort(all(v));
    reverse(all(v));

    int cur=0;
    int mi=INT_MAX,cnt=0;
    while(cur<N){
        int next=cur;
        while(next<N&&v[cur].fi==v[next].fi){
            chmin(mi,v[next].se);
            next++;
            cnt++;
        }
        if(next==N)ans[mi]+=v[cur].fi*cnt;
        else ans[mi]+=(v[cur].fi-v[next].fi)*cnt;
        cur=next;
    }

    rep(i,N){
        printf("%lld\n",ans[i]);
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const string& s)
{
    int ans = 0;

    for (int i = 0; i < N/2; ++i)
        ans += (s[i] != s[N - 1 - i]) ? 1 : 0;

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    auto ans = solve(s.size(), s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register 
#define ll long long
#define in inline
using namespace std;
inline ll read(){
	int t=0;
	char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+v-'0';
		v=getchar();
	}
	return t;
}
string s,t;
ll n,m;
int main(){
	n=read();
	m=read();
	printf("%lld",(n-2*m>0)?n-2*m:0);
}

Measured memory_bytes: 256
// AOJ ALDS 1_12_A
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

struct edge
{
	int from, to, cost;

	edge( int from, int to, int cost )
	:	from( from ), to( to ), cost( cost )
	{}
};

int n;
std::vector<edge> es;

int par[100], rank[100];

void init()
{
	rep( i, n )
		par[i] = i, rank[i] = 0;

	return;
}

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

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

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

	return;
}

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

int main()
{
	scanf( "%d", &n );
	rep( i, n )
	{
		rep( j, n )
		{
			int a;
			scanf( "%d", &a );
			if( ~a )
				es.push_back( edge( i, j, a ) );
		}
	}

	std::sort( es.begin(), es.end(), []( const edge& e1, const edge& e2 ){ return e1.cost < e2.cost; } );

	init();

	int ans = 0;
	rep( i, es.size() )
	{
		if( !same( es[i].from, es[i].to ) )
		{
			ans += es[i].cost;
			unite( es[i].from, es[i].to );
		}
	}

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

	return 0;
}

Measured memory_bytes: 1144
import sys

N, L = map(int, sys.stdin.readline().split())
As = map(int, sys.stdin.readline().split())

tot = sum(As)

res = []

a = 0
b = N-1
for _ in range(N-1):
    if tot < L:
        print "Impossible"
        sys.exit()

    na = As[a] + As[a+1]
    nb = As[b] + As[b-1]

    if na < nb:
        #tot -= na
        tot -= As[a]
        res.append(a)
        a += 1
    else:
        #tot -= nb
        tot -= As[b]
        res.append(b-1)
        b -= 1

print "Possible"
for a in res:
    print a+1



Measured memory_bytes: 13012
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

const ll MOD = (ll) 1e9 + 7;

int quant[30];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    ll ans = 1;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) quant[s[i] - 'a']++;
    for (int i = 0; i < 26; i++) ans = (ll) (quant[i] + 1) * ans % MOD;
    if (ans != 0) ans--;
    else ans = MOD - 1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> dp(N + 1, vector<int>(3));
  dp[0][0] = 1;
  for (int i = 1; i <= N * 3; ++i) {
    vector<vector<int>> newDp(N + 1, vector<int>(3));
    for (int j = 0; j <= N; ++j)
      for (int k = 0; k < 3; ++k) {
        newDp[j][0] = (newDp[j][0] + dp[j][k]) % M;
        if (k != 2 && j + !k <= N)
          newDp[j + !k][k + 1] = (newDp[j + !k][k + 1] + dp[j][k] * (ll)(i - 1)) % M;
      }
    swap(dp, newDp);
  }
  int ans = 0;
  for (const auto& vec : dp)
    ans = (ans + accumulate(vec.begin(), vec.end(), 0LL)) % M;
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 512