akhauriyash/Code-Regression huggingface dataset:
#include <vector>

using namespace std;

using u8 = unsigned char;
using uint = unsigned int;

class bitVector {
public:
    uint length, cnum, bnum;
    // bit列の長さ、chunk数、chunk毎のblock数

    static int cw, bw;
    // chunkの幅、blockの幅 今回は1024, 32

    vector<uint> bit;
    vector<uint> chunk;
    vector<vector<u8>> blocks;


    explicit bitVector(int N) : length(N) {
        cnum = (length + cw - 1) / cw;
        // length / cwを切り上げたものが必要なchunkの個数
        bnum = cw / bw;

        bit.assign(cnum * bnum, 0);
        chunk.assign(cnum + 1, 0);
        // +1は先頭の0が入っているやつの分
        blocks.assign(cnum, vector<u8>(bnum, 0));
    }

    // pos桁目をbに変える
    void set(int pos, int b) {
        int bpos = pos / bw;
        // bit内でposが存在するblockの番号
        int offset = pos % bw;
        // そのblock内でのposのindex

        if (b == 0) {
            bit[bpos] &= ~(1 << offset);
        } else if (b == 1) {
            bit[bpos] |= (1 << offset);
        }
    }

    // pos桁目のbitを返す
    int access(int pos) const {
        // assert(pos < length);

        int bpos = pos / bw;
        int offset = pos % bw;
        return bit[bpos] >> offset & 1;
    }

    uint popCount(uint num) const {
        // __builtin_popcountが使えなければ黒魔術
        return __builtin_popcount(num);
    }

    // chunkとblocksを適切に埋める
    void build() {
        chunk[0] = 0;
        for (int i = 0; i < cnum; ++i) {
            blocks[i][0] = 0;
            for (int j = 0; j < bnum - 1; ++j) {
                blocks[i][j + 1] = blocks[i][j] + popCount(bit[i * bnum + j]);
            }
            chunk[i + 1] = chunk[i] + blocks[i][bnum - 1] + popCount(bit[(i + 1) * bnum - 1]);
        }
    }

    // [0, pos)にあるkindの数を返す
    int rank(int pos, int kind) const {
        // assert(kind <= 1);
        if (kind == 0) {
            return pos - rank1(pos);
        } else {
            return rank1(pos);
        }
    }

    // [0, pos)にある1の数を返す
    int rank1(int pos) const {
        int cpos = pos / cw;
        int bpos = pos % cw / bw;
        int offset = pos % bw;

        uint masked = (bit[cpos * bnum + bpos]) & ((1 << offset) - 1);
        return chunk[cpos] + blocks[cpos][bpos] + popCount(masked);
    }

    // rank(idx, kind)=numなる最小のidxを返す
    // そもそもkindがnum個なかったら-1を返す
    int select(int num, int kind) const {
        if (num == 0) return 0;
        if (rank(length, kind) < num) return -1;

        int ok = length, ng = 0;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;
            if (rank(mid, kind) >= num) {
                ok = num;
            } else {
                ng = num;
            }
        }

        return ok;
    }
};

int bitVector::cw = 256;
int bitVector::bw = 32;

#include <iostream>
#include <string>

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

    bitVector bv(N);

    for (int i = 0; i < N; ++i) {
        bv.set(i, S[i] == 'W' ? 1 : 0);
    }

    bv.build();
    int ans = N;

    for (int i = 1; i <= N; ++i) {
        int turn = bv.rank(i - 1, 1) + (bv.rank(N, 0) - bv.rank(i, 0));
        ans = min(ans, turn);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include <vector>
#include <algorithm>

struct low_link {
    int n;
    std::vector<std::vector<int>> adj;
    std::vector<int> ord, low;
    std::vector<int> articulations;
    std::vector<std::pair<int, int>> bridges;
    low_link(const std::vector<std::vector<int>> &adj) : n(adj.size()), adj(adj), ord(n), low(n) {
        std::vector<bool> visited(n);
        int k = 0;
        auto dfs = [&](auto &&self, int cur, int par) -> void {
            visited[cur] = true;
            ord[cur] = k++;
            low[cur] = ord[cur];
            int cnt = 0;
            bool is_articulation = false;
            for (int to : adj[cur]) {
                if (!visited[to]) {
                    self(self, to, cur);
                    low[cur] = std::min(low[cur], low[to]);
                    is_articulation |= ord[cur] <= low[to];
                    if (ord[cur] < low[to]) { bridges.emplace_back(std::minmax(cur, to)); }
                } else if (to != par) { low[cur] = std::min(low[cur], ord[to]); }
            }
            if (par == -1) { is_articulation = cnt >= 2; }
            if (is_articulation) { articulations.emplace_back(cur); }
        };
        dfs(dfs, 0, -1);
    }
};

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

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> adj(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        adj[s].emplace_back(t);
        adj[t].emplace_back(s);
    }
    low_link ll(adj);
    sort(ll.bridges.begin(), ll.bridges.end());
    for (auto p:ll.bridges) { cout << p.first << " " << p.second << endl; }
}


Measured memory_bytes: 5004
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 10000000007
typedef long long ll;

using namespace std;
#define N 200010
ll n,m,k,a[N];
ll F(int lim){
	ll R=-1,cnt=0,sum=0;
	for(ll L=0;L<n;L++){
		while(R<n&&cnt<k){
			R++;
			if(a[R]<=lim)cnt++;
		}
		if(cnt<k)break;
		sum+=n-R;
		if(a[L]<=lim)cnt--;
	}
	return sum;
}
int main(){
	cin>>n>>k>>m;
	lol(i,n)cin>>a[i];
	ll L=0,R=n,mid;
	while(L<R-1){
		mid=(L+R)/2;
		if(F(mid)<m)L=mid;
		else R=mid;
	}
	cout<<R<<endl;
	return 0;
}



Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int n;
int a[10];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	a[1] = 9;
	a[2] = 0;
	a[3] = 900;
	a[4] = 0;
	a[5] = 90000;
	if(n == 100000)
	{
		cout << a[1] + a[2] + a[3] + a[4] + a[5] << endl;
		return 0;
	}
	if(n<10)
	{
		cout<<n<<endl;
	}
	else if(n<100)
	{
		cout << a[1] << endl;
	}
	else if(n < 1000)
	{
		cout << a[1] + a[2] + n - 99 << endl;
	}
	else if(n < 10000)
	{
		cout << a[1] + a[2] + a[3] << endl;
	}
	else if(n < 100000)
	{
		cout<< a[1] + a[2] + a[3] + a[4] + n - 9999 << endl;
	}
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d %d" , &n , &m);

    vector < int > a(n , 0);
    int ans = 0;
    int sum = 0;
    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &a[i]);
            sum += a[i];
    }

    for(int i = 0 ; i < n ; i ++){
            if(1.0*a[i] >= (1.0 * sum / (4.0*m))) ans ++;
    }

    printf("%s\n" , ans >= m ? "Yes" : "No");
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...) std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz, U u) {
  return make_vector(sz, T(u));
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

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

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v)
{
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    os << (i > 0 ? "," : "") << v[i];
  return os << "}";
}

template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (T&& t) noexcept
      : T(std::forward<T>(t)) {}
    template<typename... Args>
    constexpr decltype(auto) operator()(Args&&... args) const
      {return T::operator()(*this, std::forward<Args>(args)...);}
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{std::forward<T>(t)};
}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  std::vector<int> a(n); std::cin >> a;
  for (auto& x : a) x--;
  int ret = a.front() != 0;
  auto graph = make_higher_vector<2, int>(n, 0);
  rep(i, 1, n) graph.at(a.at(i)).push_back(i);
  auto root = 0;
  std::vector<int> ht(n, 0);
  fix ([&](auto dfs, int crr, int p) -> void {
    for (auto const& nxt : graph.at(crr)) {
      if (nxt == p) continue;
      dfs(nxt, crr);
      auto x = ht.at(nxt) + 1;
      if (x == k + (crr == root))
      {
        ret++;
        x = 0;
      }
      cmx(ht.at(crr), x);
    }
  })(root, root);
  // debug(graph);
  // debug(ht);
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  ll have = 0;
  rep(i, n) {
    cin >> A[i];
    have += A[i];
  }
  vector<int> S;
  ll need = 0;
  rep(i, n) {
    cin >> B[i];
    need += B[i];
    if(B[i] <= A[i]) {
      S.push_back(A[i] - B[i]);
    }
  }
  if(need > have) {
    cout << -1 << endl;
    return 0;
  }

  sort(S.begin(), S.end());
  int ans = n;

  rep(i, S.size()) {
    if(need + S[i] <= have) {
      need += S[i];
      --ans;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

template<typename Itr, typename Comp>
Itr bsearch2(Itr ng, Itr ok, const Comp& comp){
  while(ok-ng>1){
    Itr mid = ng+(ok-ng)/2;
    if(comp(*mid)) ok=mid;
    else ng=mid;
  }
  return ok;
}

int main(){
  int n; cin>>n;
  vector<int> s(n);
  for(auto&& e:s) cin>>e;
  int q; cin>>q;
  vector<int> t(q);
  for(auto&& e:t) cin>>e;
  int c=0;
  for(const auto& e:t){
    auto maybe=bsearch2(--begin(s), end(s), [e](int x){ return x>=e; });
    if(maybe>=begin(s) && maybe<=end(s) && *maybe==e) ++c;
  }
  cout<<c<<'\n';
  return 0;
}


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

long long gcd(long long a,long long b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

long long lcm(long long a,long long b){
  long long g = gcd(a,b);
  return a/g*b;
}

int main(void){
	long long int  a,b[a],c[10],d;
  cin >> a ;
  
  
  d =1ll;
  
  for(int i=0;i<a;i++){
    cin >> b[i];
    d = lcm(d,b[i]);
  }
 
  cout << d << endl;
  return 0;
}
      
  
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    vector<ll> dist = {1,1,2,3,5,8,13,21};
    ll H,W,K;
    cin >> H >> W >> K;
    vector<vector<ll>> dp(H+1,vector<ll>(W));
    dp[0][0] = 1;
    REP(i,H){
        REP(l,W){
            dp[i+1][l] += dp[i][l]*dist[l]*dist[W-l-1];
        }
        REP(l,W-1){
            dp[i+1][l+1] += dp[i][l]*dist[l]*dist[W-l-2];
        }
        REPS(l,W-1){
            dp[i+1][l-1] += dp[i][l]*dist[l-1]*dist[W-l-1];
        }
        REP(l,W){
            dp[i+1][l] %= mod;
        }
    }
    cout << dp[H][K-1] << "\n";
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
#include <algorithm>

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

using namespace std;

typedef long long ll;

int n;
char x[80001];
int dp[80001][11];

int main(){
	while(scanf("%s", x), strcmp(x, "0")){
		n = strlen(x);
		ll ans = 0;
		for(int i = 1; i <= n; ++i){
			rep(j, 11){
				dp[i][(j * 10 + x[i - 1] - '0') % 11] = dp[i - 1][j];
			}
			if(x[i - 1] != '0'){
				++dp[i][x[i - 1] - '0'];
			}
			ans += dp[i][0];
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

vector<int> topo_sort(const vector<vector<int>>& g) {
	const int V = g.size();
	vector<int> indeg(V, 0);
	stack<int> S;

	for(auto& vs : g) {
		for(auto& v: vs) {
			indeg[v]++;
		}
	}

	for (int i = 0; i < V; ++i) {
		if (indeg[i] == 0) {
			S.push(i);
		}
	}

	vector<int> ans;
	while( S.size() > 0) {
		int u = S.top();
		S.pop();
		ans.emplace_back(u);
		for (auto& v : g[u]) {
			indeg[v] --;
			if (indeg[v] == 0) {
				S.push(v);
			}
		}
	}
	return ans;
}

signed main() {
	int V, E;
	cin >> V >> E;
	vector<vector<int>> vs(V);
	for (int i = 0; i < E; ++i) {
		int from, to;
		cin >> from >> to;
		vs[from].push_back(to);
	}
	vector<int> res = topo_sort(vs);
	for (int t: res) {
		cout << t << endl;
	}
}

Measured memory_bytes: 3724
const val mod = 1000000007
fun main(args: Array<String>) {
    val l = readLine()!!.map { it=='1' }

    var eq = 1L
    var ok = 0L

    l.forEach {
        if(it) {
            ok = (eq+ok*3)%mod
            eq = (eq*2)%mod
        } else {
            ok = (ok*3)%mod
        }
    }
    println( (eq+ok)%mod )
}

Measured memory_bytes: 33660
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

ll n, k;
vector<ll>a;
vector<ll>sum(1010,0);
vector<ll>v;

int main() {
	cin >> n >> k;
	rep(i, 0, n) {
		ll x;
		cin >> x;
		a.pb(x);
	}

	rep(i, 0, n) {
		sum[i + 1] = sum[i] + a[i];
	}

	rep(i, 0, n+1)rep(j, 0, n+1) {
		if (i < j) {
			v.pb(sum[j]-sum[i]);
		}
	}

	ll s = v.size();
	

	vector<ll>sel(s,1);
	vector<ll>selrec(s,1);

	for (int i = 50;i>=0;i--) {
		ll cnt = 0;
		rep(j, 0, s)selrec[j] = sel[j];
		rep(j, 0, s)sel[j] = 0;

		rep(j, 0, s) {
			if ((selrec[j]==1) && (v[j] & (1LL << i))) {
				sel[j] = 1;
				cnt++;
			}
		}

		if (cnt >= k)continue;
		else {
			rep(j, 0, s)sel[j] = selrec[j];
		}
	}

	ll ans = -1;
	rep(i, 0, s) {
		if (sel[i] == 1) {
			if (ans == -1) {
				ans = v[i];
			}
			else {
				ans = ans & v[i];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12280
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    
    const [a, b, c, d] = input.split(/\s/).map(v => BigInt(+v));
    const max = [a * c, a * d, b * c, b * d].sort((a, b) => (a < b) ? -1 : ((a > b) ? 1 : 0))[3];
    console.log(max.toString());
})();


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

using namespace std;

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 3e5;
const double PI = 3.141592653589 , eps = 1e-9;


void solve(){
    ll h , w; cin >> h >> w;
    if (h == 1 || w == 1){
        cout << 1 << '\n';
        return;
    }
    ll ans = (h - h%2)*(w - w%2) / 2;
    if (h % 2){
        ans += (w - w%2) / 2;
    }
    if (w % 2){
        ans += (h - h%2) / 2;
    }
    if (h % 2 && w % 2) ans++;
    cout << ans;

}


int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 256
open Hashtbl;;let t=create 26 open Bytes;;let rec f()=let l=read_line()in iter(fun c->if c>'@'&&c<'['||c>'`'&&c<'{'then let x=(if c>'@'&&c<'['then Char.chr(Char.code c+32)else c)in if mem t x then add t x(find t x+1)else add t x 1)l;f()in try f()with _->iter(fun c->Printf.printf"%c : %d
"c(if mem t c then find t c else 0))"abcdefghijklmnopqrstuvwxyz"

Measured memory_bytes: 2404
S = input()
N = len(S)

ans = 0
for i in range(1<<N-1):
    p = 0
    for j in range(N-1):
        if i >> j & 1:
            ans += int(S[p:j+1])
            p = j + 1
    ans += int(S[p:])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    vector<int> num(26);
    vector<int> count(1000);
    rep(i, 26){
        num.at(i) = 'a' + i;
    }
    while(true){
        string s;
        getline(cin, s);
        if(cin.eof()) break;
        rep(i, s.size()){
            rep(j, 26){
                if(tolower(s.at(i)) == num.at(j) ){
                count.at(num.at(j))++;  
                }
            }
        }
    }
    rep(i, 26){
        char ch =num.at(i);
        cout << ch << " " << ":" << " " 
        << count.at(num.at(i)) << endl;
    }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

template <typename T, int n>
class BIT{
public:
    BIT(){
        bit.fill(0);
    }
    // add v to k-th
    void add(int k, T v, T modulo = -1){
        while(k <= n){
            if(modulo > 0){
                bit[k] = (bit[k] + v) % modulo;
                bit[k] = (bit[k] + modulo) % modulo;
            }else{
                bit[k] += v;
            }
            k += k & -k;
        }
    }
    // the sum of [1, k] (閉区間!!!)
    T sum(int k, T modulo = -1){
        T res = 0;
        while(k > 0){
            if(modulo > 0){
                res = (res + bit[k]) % modulo;
                res = (res + modulo) % modulo;
            }else{
                res += bit[k];
            }
            k -= k & -k;
        }
        return res;
    }
    std::array<T,n+1> bit;
};

std::vector<int> factors[100100];

std::vector<int> computeFactors(int n){
    std::vector<int> res;

    for(ll i=1;i*i<=n;++i){
        if(n % i > 0){continue;}
        if(i == n / i){
            res.emplace_back(i);
        }else{
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }

    return res;
}

int N, M;
priority_queue<P, std::vector<P>, std::greater<P> > rs;
int cnt[100100];
BIT<int, 100100> bit;

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        int l, r;
        std::cin >> l >> r;

        rs.emplace(l, r);
    }
    
    for(int i=1;i<=M;++i){
        while(!rs.empty() && fst(rs.top()) == i){
            bit.add(snd(rs.top()), 1);
            rs.pop();
        }
        
        vector<int> v = std::move(computeFactors(i));

        for(int d : v){
            int n = bit.sum(min(i + d - 1, M)) - bit.sum(i - 1);
            cnt[d] += n;
        }
    }

    for(int i=1;i<=M;++i){
        std::cout << cnt[i] << std::endl;
    }
}


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


const int maxn = 3e3+200;

typedef pair<int,int> II;

II a[maxn];

int f[maxn][maxn][2];


int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	int t = 0;
	cin >> n >> t;
	for(int i=0;i<n;i++) {
		cin >> a[i].first >> a[i].second;
	}
	
//	sort(a, a+n);
	
	int res = 0;
	for(int i=0;i<n;i++) {
		for(int j=t-1;j>=0;j--) {
			//f[i][j][0] = max(f[i][j][0], f[i-1][j][0]);
			//f[i][j][1] = max(f[i][j][1], f[i-1][j][1]);
			int x = a[i].first;
			int val = a[i].second;
			if (j + x  <= t) {
				f[i + 1][j + x][0] = max(f[i + 1][j + x][0], f[i][j][0] +  val);
				f[i + 1][j + x][1] = max(f[i + 1][j + x][1], f[i][j][1] + val);
			}
			f[i + 1][j][1] = max(f[i + 1][j][1], f[i][j][0] + val);
			f[i + 1][j][1] = max(f[i][j][1], f[i+1][j][1]);
			f[i + 1][j][0] = max(f[i][j][0], f[i+1][j][0]);
			res = max(f[i][j][0], res);
			res = max(f[i][j][1], res);
		}
	}
	
//	for(int i=0;i<=n;i++) {
//		for(int j=0;j<=t;j++) {
//			cerr << i <<" " << j <<" " << f[i][j][0] <<" " << f[i][j][1] << endl;
//		}
//	}
//	
//	cerr << f[2][11][1] << endl;
	
	for(int i=0;i<n;i++) {
		res = max(f[i][t][0], res);
	}
	for(int i=0;i<t;i++) {
		res = max(res, f[n][i][0]);
		res = max(res, f[n][i][1]);
	}
	
	cout << res;
	
	
	return 0;
}


Measured memory_bytes: 76160
#include<iostream>
using namespace std;
int n=0;
int num=0;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c&&a%2==0)  {
		cout<<"-1";
		return 0;
	}
	while(1)
	{
		int x,y,z;
		x=a,y=b;z=c;
		if(a%2==1||b%2==1||c%2==1)   {
			n=2;
			break;
		}
		if((a+b)%2!=0||(b+c)%2!=0||(a+c)%2!=0)  {
			cout<<a<<endl;
			n=1;
			break;
		}  
		else{
			num++;
			a=(y+z)/2;
			b=(x+z)/2;
			c=(x+y)/2;
		}
	}
	if(n==1)   cout<<"-1";
	if(n==2)
	{
		cout<<num;
	}   
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

struct Pos{int y, x;}
int[] dx = [1,0,-1,0];
int[] dy = [0,1,0,-1];
void main() {
    int[] input = readln.split.to!(int[]);
    int H = input[0];
    int W = input[1];
    int N = input[2];

    int[][] grid = new int[][](H, W);
    Pos[] ary = new Pos[N+1];
    foreach(i; 0..H) {
        grid[i] = readln.chomp.enumerate.tee!((a) {
            if (a[1]=='S') ary[0] = Pos(i, a[0].to!int);
            if (a[1].isDigit) ary[a[1]-'0'] = Pos(i, a[0].to!int);
        }).map!(a => a[1]).map!(a => a=='X' ? -1:1).array;
    }

    int[] ans = new int[N];

    foreach(i; 0..N) {
        auto list = DList!Pos(ary[i]);
        bool[][] flag = new bool[][](H, W);
        flag[ary[i].y][ary[i].x] = true;
        int[][] dist = new int[][](H, W);
        while (!list.empty) {
            Pos p = list.front;
            if (p == ary[i+1]) {
                ans[i] = dist[p.y][p.x];
                break;
            }
            list.removeFront;
            foreach(j; 0..4) {
                Pos _p = Pos(p.y+dy[j], p.x+dx[j]);
                if (0<=_p.y && _p.y<H && 0<=_p.x && _p.x<W) {
                    if (!flag[_p.y][_p.x] && grid[_p.y][_p.x]!=-1) {
                        dist[_p.y][_p.x] = dist[p.y][p.x]+1;
                        list.insertBack(_p);
                        flag[_p.y][_p.x] = true;
                    }
                }
            }
        }
    }
    ans.reduce!"a+b".writeln;
}

Measured memory_bytes: 38576
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
n = int(input())
l = []
for i in range(n):
  li = int(input())
  l.append(li)
for x in [a,b,c,[a[0],b[0],c[0]],[a[1],b[1],c[1]],[a[2],b[2],c[2]],[a[0],b[1],c[2]],[a[2],b[1],c[0]]]:
  flag = True
  for xi in x:
    if xi not in l:
      flag = False
      break
  if flag:
    print("Yes")
    exit()
print("No")
      
  
  


Measured memory_bytes: 38384
void main(){
	int r = _scan();
	(3*r^^2).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int a,b,c,i,x,y,z;
    cin >> x >> y >> a >> b >> c;
    PQ<int>pqr,pqg,pqc;
    for(i=0;i<a;i++)cin >> z,pqr.PS(z);
    for(i=0;i<b;i++)cin >> z,pqg.PS(z);
    for(i=0;i<c;i++)cin >> z,pqc.PS(z);
    PQ<int,V<int>,greater<int> >pqr1,pqg1;
    LL ans=0;
    while(x--)
    {
        pqr1.emplace(pqr.T);
        ans+=pqr.T;
        pqr.PP;
    }
    while(y--)
    {
        pqg1.emplace(pqg.T);
        ans+=pqg.T;
        pqg.PP;
    }
    while(!pqc.EM)
    {
        x=pqc.T;
        pqc.PP;
        y=min(pqr1.T,pqg1.T);
        if(y >= x)break;
        ans+=x-y;
        if(y == pqr1.T)
        {
            pqr1.PP;
            pqr1.emplace(x);
        }
        else
        {
            pqg1.PP;
            pqg1.emplace(x);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String S1 = in.next();
		String S2 = in.next();
		
		int MAX = 1000000007;
		long ans = 1;
		
		int i=0;
		boolean vartical;
		if(S1.charAt(0)==S2.charAt(0)){
			ans *= 3;
			vartical = true;
			i++;
		}else{
			ans *= 6;
			vartical = false;
			i += 2;
		}
		
		while(i<N){
			if(S1.charAt(i)==S2.charAt(i)){
				ans *= (vartical)? 2: 1;
				ans %= MAX;
				vartical = true;
				i++;
			}else{
				ans *= (vartical)? 2: 3;
				ans %= MAX;
				vartical = false;
				i += 2;
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<map>
#include<string>
using namespace std;

int main()
{
    map<string,int> m1;
    string str1, str2, str3;        //入力、頻度最大文字列、最長文字列

    int length = 0;
    while( cin >> str1 )
    {
        m1[str1]++;                 //出現頻度
        if( length < str1.size() )
        {
            length = str1.size();
            str3 = str1;
        }
    }

    int max = 0;
    for( map<string,int>::iterator itr = m1.begin(); itr != m1.end(); itr++ )
    {
        if( max < itr -> second )
        {
            max = itr -> second;
            str2 = itr -> first;
        }
    }

    cout << str2 << " " << str3 << endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 5;

vector < vector < pair < ll, ll > > > adj(MAXN, vector < pair < ll, ll > > ());

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

  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int u, v, wt;
    cin >> u >> v >> wt;
    adj[u].push_back({v, wt});
  }

  for(int i = 1; i < n; i++){
    adj[i + 1].push_back({i, 0});
  }
  priority_queue < pair < ll, int > , vector < pair < ll, ll > >, greater < pair < ll, ll > > > q;
  vector < ll > d(n + 1, 1e17);
  vector < bool > used(n + 1, false);
  used[1] = true;
  d[1] = 0;
  q.push({d[1], 1});
  while(!q.empty()){
    int u = q.top().second;
    ll d_u = q.top().first;
    q.pop();
    if(d_u != d[u]) continue;
    for(auto edge : adj[u]){
      int to = edge.first;
      int len = edge.second;
      if(!used[to] && d[u] + len < d[to]){
        d[to] = d[u] + len;
        q.push({d[to], to});
      }
    }
  }

  if(d[n] == 1e17) cout << -1 << '\n';
  else cout << d[n] << '\n';
}


Measured memory_bytes: 9468
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
char sa[100010];
int i,n;
int main()
{
	while((sa[n]=getchar())!='\n') n++;
	n--;
	while((sa[i]=='p'&&sa[n-i]=='q')||(sa[i]=='q'&&sa[n-i]=='p')||(sa[i]=='b'&&sa[n-i]=='d')||(sa[i]=='d'&&sa[n-i]=='b')) i++;
	if(i>n/2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}  

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

int main() {
    int n;
    cin >> n;
    int ans = 0; 
    for (int i=0; i<=10; ++i) {
        ans = i*1000-n;
        if (ans>=0) {
            cout << ans << endl;
        }
        if (ans>=0) break;
    }
    return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())


l_max = 1
r_min = n
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

 
print(max(r_min - l_max + 1, 0))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2010;
const ll bits = 30;
const ll mod = 998244353;



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

    vector< vector<ll> >dp(n+1,vector<ll>(3,-inf)),arr(n+1,vector<ll>(3,0));
    dp[0][0]=dp[0][1]=dp[0][2] = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp[i][j] = max(dp[i][j],dp[i-1][k]+arr[i][j]);
                }
            }
        }
    }

    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<"\n";



    
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
const int maxn = 710, maxm = maxn * maxn;
int tot, e, n, m; 
int vis[maxn], a[maxn], b[maxn], E[maxn][maxn], c[maxn];
bitset<maxn> f;
int to[maxm], nxt[maxm], head[maxn];
void add(int x, int y)
{
	to[++e] = y; nxt[e] = head[x]; head[x] = e;
	to[++e] = x; nxt[e] = head[y]; head[y] = e;
}
int dfs(int x, int col)
{
	vis[x] = 1;
	c[x] = col;
	if(col) a[tot]++; else b[tot]++;
	for(int i = head[x]; i; i = nxt[i])
	{
		int v = to[i];
		if(vis[v]) { if(c[v] == col) return 0; }
		else if(!dfs(v, col ^ 1)) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		int x, y; scanf("%d%d", &x, &y);
		E[x][y] = 1; E[y][x] = 1;
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < i; ++j)
			if(!E[i][j]) add(i, j);
	for(int i = 1; i <= n; ++i)
		if(!vis[i])
		{
			++tot;
			if(!dfs(i, 0)) { puts("-1"); return 0; }
		}
	f[0] = 1;
	for(int i = 1; i <= tot; ++i) f = (f << a[i]) | (f << b[i]);
	for(int i = n / 2; i >= 0; --i)
		if(f[i]) 
		{	
			printf("%d\n", i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
bool is(int x)
{
	stringstream a;
	string p;
	a<<x;
	a>>p;
	string q(p.rbegin(),p.rend());
	if(p==q)
	{
		return true;
	}
	return false;
}
int ans;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(is(i))
		{
			ans++;
		} 
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define maxn 200005
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    ll i;
    ll flag=1;
    for(i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        {
            flag=0;
        }
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string a;
long long l;
int main()
{
	cin>>a;
	l=a.size();
	for(int i=0;i<=l;i++)
 	{
 		if(a[i]=='C')
 		{
 			for(int j=i;j<=l;j++)
 			if(a[j]=='F')
 			{
			 	cout<<"Yes"<<endl;
			 	return 0;
			}
		 }
	 }
	 cout<<"No"<<endl;
	 return 0;
	 }

Measured memory_bytes: 256
n = gets.to_i
as = [*"a".."z"]
num = []
while n > 0
  num.unshift(n % 26)
  if n % 26 == 0
    n /= 26
    n -= 1
  else
    n /= 26
  end
end

puts num.map{|a| as[a-1]}.join


Measured memory_bytes: 14372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {

		HashMap<String, Integer> map = new HashMap<>();

		// --- input ---
		int n = Integer.parseInt(in.readLine());
		for(int i=0; i < n; i++) {
			String key = in.readLine();
			if(map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		int m = Integer.parseInt(in.readLine());
		for(int i=0; i < m; i++) {
			String key = in.readLine();
			if(map.containsKey(key)) {
				map.put(key, map.get(key) - 1);
			} else {
				map.put(key, -1);
			}
		}
		in.close();

		int max = 0;
		for(int val : map.values()) {
			if(max < val) {
				max = val;
			}
		};

		// --- resolv ---
		System.out.println(max);
	}
}

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

bool include3(int n)
{
    while(n != 0)
    {
        if(n % 10 == 3)
            return true;
        n /= 10;
    }
    return false;
}

void call(int n)
{
    for(int i = 1; i <= n; i++)
    {
        if(i%3 == 0 || include3(i))
        {
            if(i > 1)
                cout << " ";
            cout << i;
        }
    }
    cout << endl;
}

int main()
{
    int n;

    cin >> n;
    call(n);
}

Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
n, h = map(int, input().split())
a, b = [0]*n, [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())
a_max = max(a)
b_thr = []
for i in b:
    if i > a_max:
        b_thr.append(i)
b_thr.sort(reverse=True)
ans = 0
for i in b_thr:
    if h > 0:
        h -= i
        ans += 1
    else:
        print(ans)
        exit()
if h % a_max == 0:
    ans += h // a_max
else:
    ans += h // a_max + 1
print(ans)

Measured memory_bytes: 17988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define ld long double
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    ll x;
    cin>>x;
    bool dp[x+1];
    dp[0]=true;
    for(int i=1;i<=x;i++)
    {
        if((dp[i-100]==true && i-100>=0 )|| (dp[i-101]==true && i-101>=0 ) || (dp[i-102]==true && i-102>=0) || (dp[i-103]==true && i-103>=0) || (dp[i-104]==true && i-104>=0) || (dp[i-105]==true && i-105>=0))
        {
            dp[i]=true;
        }
        else
        {
            dp[i]=false;
        }
    }
    if(dp[x])
    {
        cout<<1<<'\n';
    }
    else
    {
        cout<<0<<'\n';
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<ll> makeDivisors(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i*i != n) ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

bool check(ll n, ll k) {
  while (n >= k) {
    if (n%k == 0) n /= k;
    else n %= k;
  }
  return n == 1;
}

int main() {
  // N%Kは0か1
  ll N;
  cin >> N;
  vector<ll> cand = makeDivisors(N);
  vector<ll> cand2 = makeDivisors(N-1);
  for (ll x : cand2) {
    cand.push_back(x);
  }
  int ans = 0;
  for (ll x : cand) {
    if (x >= 2 && check(N, x)) ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3716
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	p := make([]int, N)
	pp := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = nextInt()
		pp[i] = p[i]
	}

	sort.Ints(pp)

	cnt := 0
	for i := 0; i < N; i++ {
		if p[i] != pp[i] {
			cnt++
		}
	}

	if cnt <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int x, y;
    cin >> x >> y;
    vector<int> p(15);
    p[1] = p[3] = p[5] = p[7] = p[8] = p[10] = p[12] = 1;
    p[4] = p[6] = p[9] = p[11] = 2;
    p[2] = 3;
    if (p[x]==p[y])
        cout << "Yes" << endl;
    else
     cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] arr = new int[n];
      for(int i=0;i<n;i++)
        	arr[i]=s.nextInt();
      
        int[] dp = new int[n + 1];
        dp[n - 2] = Math.abs(arr[n - 2] - arr[n - 1]);
        for (int i = n - 3; i >= 0; i--) {
            int op1 = Math.abs(arr[i] - arr[i + 1]) + dp[i + 1];
            int op2 = Math.abs(arr[i] - arr[i + 2]) + dp[i + 2];

            dp[i] = Math.min(op1, op2);
          
        }
      
        System.out.println(dp[0]);
    }
}

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

using namespace std;

int n;
vector<int> cnt(4, 0);
double dp[305][305][305];

double solve(int x, int y, int z){
    if(x == 0 && y == 0 && z == 0) return 0.0;
    if(x < 0 || y < 0 || z < 0) return 0.0;
    if(dp[x][y][z] != -1) return dp[x][y][z];
    double k = x + y + z;
    double u = n - k;
    double res = (u/k) + (1/k)*(x*solve(x-1, y, z) + y*solve(x+1, y-1, z) + z*solve(x, y+1, z-1) + k);
    return dp[x][y][z] = res;
}

int main(){
    cin>>n;
    int x;
    for(int i = 0; i < n; i++){
        cin>>x;
        cnt[x]++;
    }
    for(int i = 0; i < 305; i++){
        for(int j = 0; j < 305; j++){
            for(int k = 0; k < 305; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    double res = solve(cnt[1], cnt[2], cnt[3]);
    cout<<setprecision(15);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 221952
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next()),m=Integer.parseInt(in.next());
		List<Integer> coins=new ArrayList<>();
		
		for(int i=0;i<m;i++){
			coins.add(Integer.parseInt(in.next()));
		}
		
		int DP[]=new int[n+1],INF=2000000000;
		for(int i=1;i<=n;i++)DP[i]=INF;
		
		for(int i=0;i<m;i++){
			int c=coins.get(i);
			for(int j=0;j+c<=n;j++){
				DP[j+c]=Math.min(DP[j]+1, DP[j+c]);
			}
		}
		
		System.out.println(DP[n]);
		
	}

}



Measured memory_bytes: 27020
import numpy as np
def finalFunc(n,s,A):
    var=np.array([0 for i in range(min(3001,s+1))])
    var[0]=1
    for i in A:
        tmp=var[:-i].copy()
        var*=2
        var[i:]+=tmp
        var%=998244353
    return var[s]
n,s=map(int,input().split())
A=list(map(int,input().split()))
print(finalFunc(n,s,A))

Measured memory_bytes: 27388
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(a<b)
    {
    	cout<<"Yes";
	}
    else
    {
    	cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  /* j = 4, o = 2, i = 1 */
  int i, j, k, n;
  scanf("%d", &n);
  char a[n + 10];
  scanf("%s", a);
  int dp[n][8];
  for(i = 0; i < n; ++i) for(j = 0; j < 8; ++j) dp[i][j] = 0;
  for(i = 4; i < 8; ++i) {
    if(a[0] == 'J') dp[0][i] = 1;
    else if(a[0] == 'O') {
      if(i & 2) dp[0][i] = 1;
    } else {
      if(i & 1) dp[0][i] = 1;
    }
  }
  for(i = 1; i < n; ++i) {
    for(j = 0; j < 8; ++j) {
      if((a[i] == 'J' && j & 4) || (a[i] == 'O' && j & 2) || (a[i] == 'I' && j & 1)) {
        for(k = 0; k < 8; ++k) {
          if(j & k) dp[i][j] += dp[i - 1][k];
          dp[i][j] %= 10007;
        }
      }
    }
  }
  int ans = 0;
  for(i = 0; i < 8; ++i) ans += dp[n - 1][i];
  ans %= 10007;
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  ll sum = accumulate(A.begin(), A.end(), 0LL);
  int p;
  for (p = N; 0 < p && A[p - 1] <= (sum - A[p - 1]) * 2; --p) sum -= A[p - 1];
  cout << N - p + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
A = li()

ans = N- sum(A)
if ans <0:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 10004
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n; cin >> n;
    V<ll> A(n);
    loop (n, i) cin >> A[i];

    ll b = 0;
    loop (n - 1, i) {
        b = A[i] * 2 - b;
    }
    ll a = (A[n - 1] * 2 - b) / 2;
    cout << a;
    loop (n - 1, i) {
        a = A[i] * 2 - a;
        cout << " " << a;
    }
    cout << endl;
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
  	cout << "a > b" << endl;
  } else if (a < b) {
  	cout << "a < b" << endl;
  } else {
  cout << "a == b" << endl;
  }
  return 0;
}

Measured memory_bytes: 3068
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion

s = input()[:-1]
if s[-1] == "s":
    print(s + "es")
else:
    print(s + "s")


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


ll a, b, c;

int main() {
    cin>>a;

    if(a==3||a==5||a==7){
        p("YES");
    }else{
        p("NO");
    }


    return 0;
}


Measured memory_bytes: 764
N = int(input())
A = []
global_max = 1
second_max = 0
for i in range(N):
    new_a = int(input())
    A.append(new_a)
    if new_a > global_max:
        second_max = global_max
        global_max = new_a
    elif new_a > second_max:
        second_max = new_a


for a in A:
    if a < global_max:
        print(global_max)
    else:
        print(second_max)


Measured memory_bytes: 12532