akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<P> p(n);
    rep(i,n){
        int x,l;
        cin >>x >> l;
        p[i].first = x+l;
        p[i].second = x-l;
    }
    sort(p.begin(),p.end());
    int cnt = 1;
    int ind = 0;
    for(int i = 1;i <= n-1;i++){
        if(p[i].second<p[ind].first) continue;
        ind = i;
        cnt ++;
    }
 
    cout << cnt << endl;
}

Measured memory_bytes: 4752
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
ans = 0
for i in range(11, N+1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);
    a[] -= 1;

    auto adj = new int[][](N, 0);
    foreach (i; 1 .. N) {
        adj[a[i - 1]] ~= i;
    }

    debug {
        writeln(adj);
    }

    auto cnt = new int[](N);

    int dfs(int v) {
        foreach (u; adj[v]) {
            cnt[v] += 1;
            dfs(u);
        }
        return cnt[v];
    }

    dfs(0);

    writefln("%(%s\n%)", cnt);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 36884
n,k=[int(i) for i in input().split()]
ans=0
left=[i+1 for i in range(n)]
right=[i+1 for i in range(k, n)]
amari=[0 for i in range(k, n)]

for i in range(len(amari)):
    amari[i]=(n//right[i])*(right[i]-1)-(n//right[i])*(k-1) + max(0,n%right[i]-(k-1))

if k==0:
    print(n**2)
else:
    print(sum(amari))

Measured memory_bytes: 14900
#include <stdio.h>
int main()
{
 int a,b;
 char op;
 scanf("%d %c %d",&a,&op,&b);
 int res;
 switch(op)
 {
 case '+':
  res = a + b;
  break;
 case '-':
  res = a - b;
  break;
 }
 printf("%d\n",res);
 return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
void dfs (int cur, int from, const vector<vector<pair<int, long long>>>& g, vector<long long>& parity, vector<long long>& score) {
  for (auto nbr : g[cur]) if (nbr.first != from && parity[nbr.first] == 0) {
    parity[nbr.first] = parity[cur] * -1;
    score[nbr.first] = nbr.second - score[cur];
    dfs (nbr.first, cur, g, parity, score);
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, long long>>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v, s;
    cin >> u >> v >> s;
    u--;
    v--;
    g[u].emplace_back(v, s);
    g[v].emplace_back(u, s);
  }
  vector<long long> parity(n), score(n);
  parity[0] = 1;
  dfs (0, -1, g, parity, score);
  long long lo = 0, hi = 1LL << 60;
  long long fixed = -1;
  for (int i = 0; i < n; i++) {
    if (parity[i] == -1) {
      hi = min(hi, score[i] - 1);
    } else {
      lo = max(lo, 1 - score[i]);
    }
    for (auto& nbr : g[i]) {
      int p = parity[nbr.first] + parity[i];
      long long s = score[nbr.first] + score[i];
      if (p == 0) {
        if (s != nbr.second) {
          cout << 0 << endl;
          return 0;
        }
      } else {
        if (p == -2) {
          if (s - nbr.second < 0 || (s - nbr.second) % 2 != 0) {
            cout << 0 << endl;
            return 0;
          }
          if (fixed == -1) fixed = (s - nbr.second) / 2;
          if (fixed != (s - nbr.second) / 2) {
            cout << 0 << endl;
            return 0;
          }
        } else {
          if (nbr.second - s < 0 || (nbr.second - s) % 2 != 0) {
            cout << 0 << endl;
            return 0;
          }
          if (fixed == -1) fixed = (nbr.second - s) / 2;
          if (fixed != (nbr.second - s) / 2) {
            cout << 0 << endl;
            return 0;
          }
        }
      }
    }
  }
  cerr << hi << " " << lo << endl;
  cerr << fixed << endl;
  if (fixed != -1) cout << (lo <= fixed && fixed <= hi) << endl;
  else cout << max(0LL, hi - lo + 1) << endl;
  return 0;
}

Measured memory_bytes: 17280
#include <stdio.h>

int main(void)
{
	int h[20];
	int i;
	static int ranc[3];
	
	for (i = 0; i < 10; i++){
		scanf("%d", &h[i]);
		
		if (ranc[0] <= h[i]){
			ranc[2] = ranc[1];
			ranc[1] = ranc[0];
			ranc[0] = h[i];
		}
		else if (ranc[1] <= h[i]){
			ranc[2] = ranc[1];
			ranc[1] = h[i];
		}
		else if (ranc[2] <= h[i]){
			ranc[2] = h[i];
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", ranc[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (h, a) = read_touple::<usize>();
    let ans = (h + a - 1) / a ;
    println!("{}", ans);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<vector<int>> E;

int memo[202020];

int win(int m) {
	if(m==0) return 1;
	if(memo[m]>=0) return memo[m];
	
	memo[m]=0;
	if(m>0 && win(m-1)==0) memo[m]=1;
	if(m>1 && win(m-2)==0) memo[m]=1;
	return memo[m];
	
}

pair<int,int> farthest(vector<vector<int>>& E, int cur,int pre,int d,vector<int>& D) {
	D[cur]=d;
	pair<int,int> r={d,cur};
	FORR(e,E[cur]) if(e!=pre) r=max(r, farthest(E,e,cur,d+1,D));
	return r;
}

pair<int,vector<int>> diameter(vector<vector<int>>& E) { // diameter,center
	vector<int> D[2];
	D[0].resize(E.size());
	D[1].resize(E.size());
	auto v1=farthest(E,0,0,0,D[0]);
	auto v2=farthest(E,v1.second,v1.second,0,D[0]);
	farthest(E,v2.second,v2.second,0,D[1]);
	pair<int,vector<int>> R;
	R.first = v2.first;
	//重心を取る場合
	for(int i=E.size()-1;i>=0;i--) if(D[0][i]+D[1][i]==R.first && abs(D[0][i]-D[1][i])<=1) R.second.push_back(i);
	//両端を取る場合
	R.second.push_back(v1.second);
	R.second.push_back(v2.second);

	return R;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	E.resize(N);
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	MINUS(memo);
	auto R=diameter(E);
	
	if(win(R.first)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
typedef long long ll;

struct point { int x, y; };
typedef pair<int, point> P;
struct edge { int u, v, cost; };

int N;
vector<P> AX, AY;
vector<edge> es;

vector<int> par;
void init(int n) {
    par.resize(n);
    iota(par.begin(), par.end(), 0);
}
int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}
bool same(int x, int y) {
    return root(x) == root(y);
}
void unite(int x, int y) {
    x = root(x);
    y = root(y);
    par[x] = y;
}


ll kruskal() {
    init(N);
    ll ans = 0;
    sort(es.begin(), es.end(), [](edge& e1, edge& e2){ return e1.cost < e2.cost; });
    for (edge& e: es) {
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            ans += e.cost;
        }
    }
    return ans;
}

int main() {
    int x, y;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &x, &y);
        AX.push_back({i, {x, y}});
    }
    AY = AX;
    sort(AX.begin(), AX.end(), [](P& p1, P& p2){ return p1.second.x < p2.second.x; });
    sort(AY.begin(), AY.end(), [](P& p1, P& p2){ return p1.second.y < p2.second.y; });

    for (int i = 1; i < N; i++) {
        es.push_back({AX[i].first, AX[i-1].first, AX[i].second.x - AX[i-1].second.x});
        es.push_back({AY[i].first, AY[i-1].first, AY[i].second.y - AY[i-1].second.y});
    }
    printf("%lld\n", kruskal());
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int arr[26];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        char c=s[i];
        int k=c-'a';
        arr[k]+=1;
    }
    for(int i=0;i<26;i++){
        if(arr[i]==0){
            char c=i+'a';
            cout<<c<<endl;
            break;
        }
        else{
            if(i==25){
                cout<<"None"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;
 
#define prec(i) cout << fixed << setprecision(i)
 
void output_yn(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
 
const long long MOD = 1000000007;
 
long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;
 
	return sum;
}
 
long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;
 
	return sum;
}
 
int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}
 
long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;
 
	return ans;
}
 
long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;
 
	return ans;
}
 
long long modinv(long long a) {
 
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
 
	return u;
}
 
long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);
 
	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}
 
long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}
 
long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;
 
	return sum;
}
 
vector<vector<int>> graph;
vector<bool> seen;
int grpCnt = 0;

void dfs(const vector<vector<int>> &graph, int v) {
	seen[v] = true;
	grpCnt++;
	for (auto next_v : graph[v]) {
		if (seen[next_v])
			continue;
		dfs(graph, next_v);
	}
}


int main()
{
	int n, m, max = 0;
	cin >> n >> m;

	graph = vector<vector<int>>(n);
	seen.assign(n, false);

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
	}

	for (int i = 0; i < n; i++) {
		if (!seen[i]) {
			grpCnt = 0;
			dfs(graph, i);
			if (grpCnt > max)
				max = grpCnt;
		}

	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 23484
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, mod;
int down[N];
int up[N];
map <int, int> id[N];
vector <int> adj[N], pre[N], suf[N];

void dfs(int u, int p) {
  down[u] = 1;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    id[u][v] = pre[u].size();
    down[u] = (1ll * down[u] * (down[v] + 1)) % mod;
    pre[u].push_back(down[u]);
  }
  int cur = 1;
  for (int i = adj[u].size() - 1; i >= 0; i--) {
    int v = adj[u][i];
    if (v == p) continue;
    cur = (1ll * cur * (down[v] + 1)) % mod;
    suf[u].push_back(cur);
  }
  reverse(suf[u].begin(), suf[u].end());
}

void dfs1(int u, int p) {
  up[u] = 1;
  if (p != -1) {
    up[u] = up[p];
    int pos = id[p][u];
    if (pos > 0) {
      up[u] = (1ll * up[u] * pre[p][pos - 1]) % mod;
    }
    if (pos + 1 < suf[p].size()) {
      up[u] = (1ll * up[u] * suf[p][pos + 1]) % mod;
    }
    up[u] = (up[u] + 1) % mod;
  }
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs1(v, u);
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie();
  cin >> n >> mod;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  dfs1(1, -1);
  for (int i = 1; i <= n; i++) {
    cout << (1ll * up[i] * down[i]) % mod << endl;
  }
  return 0;
}


Measured memory_bytes: 34816
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1e6 + 10, mod = 1e9 + 7;
int fact[maxn], inv[maxn];
inline int ad(int x,int y){
	x += y;
	if(x < mod)
		return x;
	return x - mod;
}
inline int mu(int x,int y){
	return 1LL * x * y % mod;
}
inline int bpow(int x,int y){
	int res = 1;
	while(y){
		if(y & 1) res = mu(res, x);
		x = mu(x, x);
		y >>= 1;
	}
	return res;
}
void prep(){
	for(int i=0; i<maxn; i++)
		fact[i] = (!i ? 1 : mu(i, fact[i-1]));
	inv[maxn-1] = bpow(fact[maxn-1], mod - 2);
	for(int i=maxn-2; i>=0; i--)
		inv[i] = mu(i+1, inv[i+1]);
}
int C(int r,int n){
	if(r > n || n < 0 || r < 0) return 0;
	return mu(fact[n], mu(inv[r], inv[n-r]));
}
int f(int r,int n){
	if(r == 0) return (n == 0);
	return C(r-1, n+r-1);
}
int a[maxn];
int32_t main(){
    IOS;
	prep();
	int sum = 0, ans = 0;
	//cout << f(2, 2) << endl;
	int n;
	cin >> n;
	for(int i=n; i>=1; i--){
		if(i * 2 > n) continue;
		int tot = f(i, n-i-i);
		int aft = i-1;
		int bef = n-1-aft;
		int now = mu(fact[aft], mu(fact[bef], tot));
		//cout << "HAHA" << i << " " << now << endl;
		int bia = ad(now, mod - sum);
		ans = ad(ans, mu(bef, bia));
		sum = now;
	}
	cout << ans << endl;
}


Measured memory_bytes: 9984
#include<iostream>
#include<cstdio>
#define max(a,b) a>b?a:b
using namespace std;
int a[2005];
long long int dp[2005][2005];
int main(){
	int n;
	int i,j,k;
	int b,c,d;
	long long int s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		dp[i][i]=a[i];
	}
	for(i=1;i<n;i++){
		for(j=0;j<n;j++){
			b=(j+i)%n;
			c=(j+i-1)%n;
			if(i%2==0){
				dp[j][b]=max(dp[j][b],dp[j][c]+a[b]);
				dp[j][b]=max(dp[j][b],dp[(j+1)%n][b]+a[j]);
			}else{
				if(a[b]>=a[(j+n-1)%n]){
					dp[j][b]=max(dp[j][b],dp[j][c]);
				}
				if(a[j]>=a[(b+1)%n]){
					dp[j][b]=max(dp[j][b],dp[(j+1)%n][b]);
				}
			}
		}
	}
	for(i=0;i<n;i++){
		b=(i+n-1)%n;
		s=max(s,dp[i][b]);
	}
	cout<<s<<endl;
	return 0;
}
	

Measured memory_bytes: 34436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
set<int> st;
int N;
cin >> N;
for(int i = 0; i < N; i++) {
int a;
cin >> a;
st.insert(a);
}
if(st.size() == N) cout << "YES";
else cout << "NO";
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int a[10010], sum;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) scanf("%d", &a[i]), sum += a[i];
    if (n < sum) {
        puts("-1");
    } else {
        cout << n - sum;
    }
    return 0;
}

Measured memory_bytes: 3808
class SkewQ {
  constructor(v,r,l) {
    this.h = {v,r,l};
  }
  static meld(a,b) {
    if ( a === void 0 ) return b;
    if ( b === void 0 ) return a;
    if ( a.v < b.v ) [a,b] = [b,a];
    a.r = SkewQ.meld(a.r,b);
    [a.r,a.l] = [a.l,a.r];
    return a;
  }
  pop(){
    const v = this.h.v;
    this.h = SkewQ.meld(this.h.r,this.h.l);
    return v;
  }
  push(v,r,l){
    const b = {v,r,l};
    this.h = SkewQ.meld(this.h,b);
  }
}
console.log((args=>{
  const [[N,M],A] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const q = new SkewQ(A[0]);
  for ( let i = 1; i < N; i++ ) q.push(A[i]);
  for ( let i = 0; i < M; i++ ) q.push( q.pop()>>1 );
  let s = 0;
  for ( let i = 0; i < N; i++ ) s += q.pop();
  return s;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 57380
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);

	unsigned c;

	while ((c = a % b)) {
		a = b;
		b = c;
	}
	return b;
}

ll lcm(ll a, ll b) {
	ll c = gcd(a, b);
	return a / c * b;
}


int main() {

	int x;

	cin >> x;

	int ans = lcm(x, 360) / x;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3632
N = int(input())
P = 10**9+7
  
memo = [0]*(N+1)

for i in range(1,N+1):
  j = i
  while j % 2 == 0:
    memo[2] += 1
    j //= 2
  k = 3
  while k*k <= j:
    if j % k == 0:
      memo[k] += 1
      j //= k
    else:
      k += 2
  if j != 1:
    memo[j] += 1
    
rlt = 1  
for i in range(1,N+1):
  rlt *= (memo[i]+1)%P
  rlt %= P
  
print(rlt)

Measured memory_bytes: 67164
//23
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>

using namespace std;

string s,c;
int tf;
int p;

bool form(){
  if(isupper(s[p])){
    return s[p++]=='T';
  }else if(islower(s[p])){
    return tf>>c.find(s[p++],0)&1;
  }else if(s[p]=='-'){
    p++;
    return !form();
  }else{
    p++;
    bool a=form();
    char o=s[p];
    p+=1+(o=='-');
    bool b=form();
    p++;
    if(o=='*'){
      return a&b;
    }else if(o=='+'){
      return a|b;
    }else{
      return !a|b;
    }
  }
}

bool equ(){
  bool a=form();
  p++;
  bool b=form();
  return a==b;
}

int main(){
  while(getline(cin,s),s!="#"){
    s+='=';
    c.clear();
    for(int i=0;i<s.size();i++){
      if(islower(s[i])){
	c+=s[i];
      }
    }
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(),c.end()),c.end());
    for(tf=0;tf<1<<c.size();tf++){
      p=0;
      if(!equ())break;
    }
    cout<<((tf<1<<c.size())?"NO":"YES")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    lli a=0,b=0,i;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A')
         a++;
        else if(s[i]=='B')
          b++;
    }
    if(a==3 || b==3)
     cout<<"No"<<"\n";
    else 
      cout<<"Yes"<<"\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    std::vector<int> a(n); rep(i,n) cin >> a[i];

    bool ok = true;

    rep(i,n) if((a[i]%3!=0 && a[i]%5!=0) && a[i]%2==0) ok = false;
    
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;



    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline ll read() {
    ll res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

int n, T, f[N], max;
Pair a[N];

int main() {
    scanf("%d %d", &n, &T);
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i].fir >> a[i].sec;
        max = std::max(max, a[i].fir);
    }
    std::sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = T + max; j >= a[i].fir; j--) {
            if (j - a[i].fir < T) {
                f[j] = std::max(f[j], f[j - a[i].fir] + a[i].sec);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= T + max; i++) ans = std::max(ans, f[i]);
    printf("%d\n", ans);
    return 0;
}

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

int N, Z, W;
vector<int> a;

int main()
{
    cin >> N >> Z >> W;
    a.resize(N+1);
    a[0] = W;
    for (int i = 1; i <= N; i++) cin >> a[i];

    vector<int> Max(N);
    vector<int> Min(N);
    Max[N-1] = abs(a[N] - a[N - 1]);
    int maxtmp = Max[N - 1];
    Min[N-1] = abs(a[N] - a[N - 1]);
    int mintmp = Min[N - 1];
    for (int i = N-2; i >= 0; i--)
    {
        Max[i] = max(mintmp, abs(a[N] - a[i]));
        Min[i] = min(maxtmp, abs(a[N] - a[i]));
        maxtmp = min(maxtmp, Max[i]);
        mintmp = max(mintmp, Min[i]);
    }
    // for (int i = 0; i < N; i++)
    // {
    //     cout << Max[i] << " " << Min[i] << endl;
    // }
        cout << Max[0] << endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    int N, L;
    
    cin >> N >> L;
    
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];
    
    sort(S.begin(), S.end());
    
    for (int i = 0; i < S.size(); i++) {
        cout << S[i];
    }
    cout << endl;
    
    return 0;
}

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

int main(void)
{
  int n,k;
  cin>>n>>k;
  if(k==1)
    cout<<0<<endl;
  else if(n<k)
   cout<<1<<endl;
  else if(n==k)
    cout<<0<<endl;
  else
    cout<<n-k<<endl;
  return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<int>b;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (i % 2 == 0) {
			b.pb(a[i]);
		}
		else {
			auto it = b.begin();
			b.insert(it, a[i]);
		}
	}
	if (n % 2 == 0) {
		rep(i, n) {
			print(b[i]);
		}
	}
	else {
		rrep(i, n) {
			print(b[i]);
		}
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

int N,Q;
int A[201010];
int B[201010];
multiset<int> p,n;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	ll S=0,T=0;
	FOR(i,2*N) cin>>A[i], S+=A[i];
	FOR(i,2*N) {
		cin>>B[i];
		B[i]-=A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.insert(B[i]);
				T+=B[i];
			}
			else {
				n.insert(-B[i]);
			}
		}
	}
	while(Q--) {
		cin>>i>>x>>y;
		i--;
		S-=A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.erase(p.find(B[i]));
				T-=B[i];
			}
			else {
				n.erase(n.find(-B[i]));
			}
		}
		
		A[i]=x;
		S+=x;
		B[i]=y-A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.insert(B[i]);
				T+=B[i];
			}
			else {
				n.insert(-B[i]);
			}
		}
		
		ll ma=0;
		if(p.size()%2==0) ma=S+T;
		else ma=S+max(T-*p.begin(),T-*n.begin());
		cout<<ma<<endl;
	}
}
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 12672
#include <stdio.h>
#include <string.h>



int main(){
	
	int i,j,N;
	
		scanf("%d",&N);
	i = N%10;
	if(i==2 || i==4 ||i==5 || i==7 ||i==9){
		printf("hon\n");
	}
	else if(i==3){
		printf("bon\n");
	}
	else printf("pon\n");
		
	return 0;
}


Measured memory_bytes: 1640
#include <stdio.h>

#define max(a, b) a > b ? a : b;

int main(void) {
    int ncube, nchoose;
    scanf("%d %d", &ncube, &nchoose);
    int cubes[ncube];
    int sums[ncube+1];
    int ans = 0;
    sums[0] = 0;
    int now;
    for(int i = 0; i < ncube; i++) {
        scanf("%d", &cubes[i]);
        sums[i+1] = sums[i] + cubes[i];
    }
    int memo;
    for(int i = nchoose; i < ncube + 1; i++) {
        if(ans < sums[i] - sums[i - nchoose]) {
            ans = sums[i] - sums[i - nchoose];
            memo = i - nchoose;
        }
    }
    double ret = 0.0;
    for(int i = memo; i < memo + nchoose; i++) {
        int c = cubes[i];
        int cubesum = 0;
        for(int j = 1; j <= c; j++) {
            cubesum += j;
        }
        ret += (double)(cubesum) / (double)(c);
    }
    printf("%lf", ret);
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <cstring>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int main() {
    ll a, b;
    char *sa, *sb;

    cin >> a >> b;

    sa = new char[b];
    for (int i = 0; i < b; i++) {
        sa[i] = (char)a + '0';
    }

    sb = new char[a];
    for (int i = 0; i < a; i++) {
        sb[i] = (char)b + '0';
    }

    if (strcmp(sa, sb) <= 0) cout << sa << endl;
    else cout << sb << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
def m():
    n, cn = map(int, input().split())
    d = [list(map(int, input().split())) for _ in range(cn)]
    c = [list(map(int, input().split())) for _ in range(n)]
    l = [[] for _ in range(3)]
    ans = [[] for _ in range(3)]
    for i in range(n):
        for j in range(n):
            l[(i+1+j+1) % 3].append(c[i][j])

    for k in range(3):
        for s in range(cn):
            cost = 0
            for p in l[k]:
                cost += d[p-1][s]
            ans[k].append((s,cost))

    for k in range(3):
        ans[k].sort(key=lambda x: x[1])

    result = 999999999
    for elem in itertools.permutations(range(3)):
        used = []
        tmp = 0
        for e in elem:
            i = 0
            while len(used) < 3:
                if ans[e][i][0] in used:
                    i += 1
                    continue
                tmp += ans[e][i][1]
                used.append(ans[e][i][0])
                break
        result = min(result, tmp)
    return result

print(m())

Measured memory_bytes: 7692
#include <stdio.h>
int MAX(int a,int b){
    return a>=b?a:b;
}
int main()
{   int n,x=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int max=x;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
            max=MAX(max,x);
        }else{
            x--;
        }
    }
    printf("%d",max);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 234567;
const LL MOD = (LL)1e9 + 7;
LL pw2[MAXN];

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

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

int main() {
    pw2[0] = 1;
    for (int i = 1; i < MAXN; i++)
        pw2[i] = (pw2[i - 1] * 2) % MOD;
    int N;
    scanf("%d", &N);
    map<pll, LL> mp;
    LL a0b0 = 0, a0 = 0, b0 = 0;
    for (int i = 0; i < N; i++) {
        LL a, b;
        scanf("%lld %lld", &a, &b);
        if (a == 0 && b == 0) a0b0++;
        else if (a == 0) a0++;
        else if (b == 0) b0++;
        else {
            LL coef = 1;
            if ((a < 0 && b > 0) || (a > 0 && b < 0))
                coef = -1;
            a = abs(a), b = abs(b);
            assert(a > 0);
            assert(b > 0);
            LL g = gcd(a, b);
            a /= g, b /= g;
            pll tmp = make_pair(coef * a, b);
            mp[tmp]++;
        }
    }
    LL ans = 1;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        pll p = it->first;
        LL a = p.first, b = p.second;
        //printf("a = %lld b = %lld sz = %d\n", a, b, mp.size());
        LL x = it->second;
        //if (used.count(p)) continue;
        pll rv = make_pair(-b, a);
        if (a < 0) {
            rv.first *= -1;
            rv.second *= -1;
        }
        assert(rv.second > 0);
        if (mp.count(rv)) {
            LL y = mp[rv];
            LL tmp = (pw2[x] + pw2[y] - 1) % MOD;
            mp.erase(mp.find(rv));
            ans = (ans * tmp) % MOD;
        } else {
            ans = (ans * pw2[x]) % MOD;
        }
    }    ans = mul(ans, (pw2[a0] + pw2[b0] - 1) % MOD) % MOD;
    printf("%lld\n", (ans + a0b0 -1 + MOD) % MOD);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 18076
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,f=1;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		ret=(ret<<1)+(ret<<3)+ch-'0';
		ch=getchar();
	}
	return ret*f;
}
int h,w,ans1[501][501],ans2[501][501];
int main()
{
	h=read();
	w=read();
	for(register int i=1;i<=h;i++)
	{
		for(register int j=1;j<=w;j++)
			scanf("%c",&ans1[i][j]),ans2[i][j]=ans1[i][j];
		getchar();
	}
	for(register int i=1;i<=h;i+=2)
	{
		for(register int j=1;j<w;j++)
			ans1[i][j]='#';
	}
	for(register int i=2;i<=h;i+=2)
	{
		ans1[i][1]='#';
	}
	for(register int i=2;i<=h;i+=2)
	{
		for(register int j=2;j<=w;j++)
			ans2[i][j]='#';
	}
	for(register int i=1;i<=h;i+=2)
	{
		ans2[i][w]='#';
	}
	for(register int i=1;i<=h;i++)
	{
		for(register int j=1;j<=w;j++)
			printf("%c",ans1[i][j]);
		printf("\n");
	}
	printf("\n");
	for(register int i=1;i<=h;i++)
	{
		for(register int j=1;j<=w;j++)
			printf("%c",ans2[i][j]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

vector<int> G[100100];
int n;
vector<int> P;

bitset<100100> visit;

bool getP(int idx){

    visit[idx]=1;

    if(idx==n) return 1;

    bool ans = false;
    for(int i = 0; i<G[idx].size(); i++){
        if(!visit[G[idx][i]]){
            if(getP(G[idx][i])) P.push_back(G[idx][i]), ans = 1;
        }
    }

    return ans;

}


int bfs(int idx){

    visit[idx] = 1;
    int ans = 0;
    for(int i = 0; i<G[idx].size(); i++){
        if(!visit[G[idx][i]]){
            ans += 1+bfs(G[idx][i]);
        }
    }

    return ans;
}

int main(){


    scanf("%d",&n);


    for(int i = 0, a, b; i<n-1; i++){

        scanf("%d%d",&a,&b);

        G[a].push_back(b);
        G[b].push_back(a);
    }

    visit.reset();

    getP(1);

    P.push_back(1);
    reverse(P.begin(),P.end());

    visit.reset();

    for(int i = 0; i<P.size(); i++){
        visit[P[i]]=1;
    }


    int contF, contS;

    contF = contS = 0;

    contF += bfs(1);
    contS += bfs(n);

    for(int i = 1, j = P.size()-2; ;){
        if(i>j) break;
        contF += 1+bfs(P[i]);
        i++;
        if(i>j) break;
        contS += 1+bfs(P[j]);
        j--;

    }

    if(contF>contS){
        puts("Fennec");
    }else{
        puts("Snuke");
    }
    return 0;
}

Measured memory_bytes: 11004
#include<iostream>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

string run_length(string s) {
    char now = '#';
    string res;
    rep(i, 0, s.size()) {
        if (s[i] != now) {
            res += s[i];
            now = s[i];
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    string res = run_length(S);
    cout << res.size() << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin>>x[i];
  }
  ll ans = 0;
  for(int i = 0; i < n-1; i++){
    ll diff = x[i+1]-x[i];
    ans+=lmin(diff*a,b);
  }
  cout<<ans<<endl;
  return 0;
}


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

const int mod = 1000000000+7;

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    ll ans = 0;
    rep(i, 60){
        ll count = 0;  //1の数
        rep(j, n){
            if(a[j] >> i & 1) count++;
        }
        ll tmp = count*(n-count)%mod;
        rep(j, i) tmp = tmp*2%mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

bool func(int x){
  int temp = x;
  int y = 0;
  while(temp){
    y += temp%10;
    temp /= 10;
  }
  if(x % y == 0) return true;
  return false;
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  while(true){
    bool flg = true;
    for(int i = 0; i < n; i++){
      if(a[i] % 2) flg = false;
      else a[i] /= 2;
    }
    if(flg) ans++;
    else break;
  }
  cout << ans << endl;
  return 0;
}


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

void solve()
{
    int n, k; cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        double m = 1.0 / n;
        int curr = i;
        while (curr < k) {
            curr *= 2;
            m /= 2;
        }
        ans += m;
    }
    cout << fixed << setprecision(12) << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3796
s = input()
ans = 0
tmp = 0
mods = [0]*2019
mods[0] = 1
order = 1
for i in reversed(s):
    tmp += int(i) * order
    mods[tmp % 2019] += 1
    order *= 10
    order %= 2019
ans = sum(n*(n-1)//2 for n in mods)
print(int(ans))


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
	int N;
    cin >> N;
    int n = N % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <stack>
#include <set>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    int x;cin>>x;
    x=(x-400)/200;
    cout<<8-x<<'\n';
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define mod (int(1e9+7))
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<vector<char>> grid(n, vector<char>(m));
	vector<vector<int>> dp(n, vector<int>(m, 0));

	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			cin>>grid[i][j];
			
		}
	}
	if(grid[0][0]=='#' or grid[n-1][m-1]=='#' ){
		cout<<0;
		return 0;
	}

	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++)
			if(grid[i][j]=='#'){
				dp[i][j] = 0;
			}
			else{
				if(i==0 && j==0){
					dp[i][j]=1;
				}
				else if(i==0){
					dp[i][j] = dp[i][j-1];
				}
				else if(j==0){
					dp[i][j]= dp[i-1][j];
				}
				else{
					dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
				}
			}
	}
	cout<<dp[n-1][m-1];
	
	return 0;
};


Measured memory_bytes: 8216
<?php
fscanf(STDIN, "%d%d", $n, $k);
$count = 0;
for($i = 1; $i <= $n; $i++){
  //iで割ったときのあまりが$k以上になればよい。
  $count += floor($n/$i) * max(0, $i - $k);
  $count += max(0, $n - intdiv($n, $i)*$i - $k + 1);
}
if($k == 0)$count-=$n;
echo $count;


Measured memory_bytes: 4604
use proconio;
use num::integer::gcd;
fn main() {
    proconio::input!{
        k: usize
    }
    let mut sum = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                sum += gcd(a, gcd(b, c));
            }
        }
    }
    println!("{}", sum);
}


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


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int S;
	cin >> S;
	
	cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << S % 60 << "\n";

	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

bool ok[101][101];

int main() {
    ll N, K;
    cin >> N >> K;

    // 2
    if (N == 2 and K == 0) {
        cout << 1 << endl;
        cout << "1 2" << endl;
        return 0;
    }
    else if (N == 2) {
        cout << -1 << endl;
        return 0;
    }

    ll ma = 1, cur = 2;
    for (int i=4; i<=N; ++i) {
        ma += cur;
        cur++;
    }

    // できるかどうか判定
    if (ma < K) {
        cout << -1 << endl;
        return 0;
    }

    // 最大ケース
    if (ma == K) {
        cout << N-1 << endl;
        for (int i=2; i<=N; ++i) {
            cout << "1 " << i << endl;
        }
        return 0;
    }
    else {

        rep(i, N) rep(j, N) ok[i][j] = true;

        // rep(i, N) {
        //     rep(j, N) cout << ok[i][j] << ", ";
        //     cout << endl;
        // }

        int num = 0, cnt = K;
        rep(i, N) rep(j, N) {
            if (num == cnt) break;
            if (i == j) continue;
            if (i == 0 or j == 0) continue;
            if (!ok[i][j]) continue;
            ok[i][j] = ok[j][i] = false;
            num++;
        }

        // rep(i, N) {
        //     rep(j, N) cout << ok[i][j] << ", ";
        //     cout << endl;
        // }

        //
        cout << N*(N-1)/2 - K << endl;
        // {
        //     int num = 0;
        //     rep(i, N) rep(j, N) {
        //         if (i == j) continue;
        //         if (num == K) break;
        //         if (i == 0 or j == 0) continue;
        //         if (ok[i][j]) {
        //             ok[i][j] = ok[j][i] = false;
        //             num++;
        //         }
        //     }
        // }


        rep(i, N) for (int j=0; j<i; ++j) {
            if (ok[i][j]) cout << i+1 << " " << j+1 << endl;
        }

    }

}


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

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

    int64_t ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int ab = Math.abs(a-b);
        int ac = Math.abs(a-c);
        int bc = Math.abs(b-c);
        if(ac <= d || (ab <= d && bc <= d)){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22100
#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;
    }
}


Measured memory_bytes: 3096
h, w = list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))

g = [[0 for __ in range(w)] for _ in range(h)]

cur = 1
cnt = 0
for y in range(h):
    for x in range(w):
        if y % 2 == 0:
            g[y][x] = cur
        else:
            g[y][w-x-1] = cur

        cnt += 1
        if a[cur-1] == cnt:
            cnt = 0
            cur += 1


for row in g:
    print(" ".join(map(str, row)))

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

int main() {
  int n;
  cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++) cin>>p[i];
  int ans=0;
  int nibu=n;
  for(int i=0;i<n;i++){
    nibu=min(nibu,p[i]);
    if(p[i]<=nibu) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {

	long double A, B;
	long long ans;

	cin >> A >> B;

	ans = (long long)A * B;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
#define lowb(x) (x & (-x))
int t[maxn], n, c[maxn], d[maxn];
long long a[maxn], b[maxn];
void add(int x) {
	for (int i = x; i <= n + 1; i += lowb(i)) {
		t[i]++;
	}
}
long long query(int x) {
	long long s = 0;
	for (int i = x; i > 0; i -= lowb(i)) {
		s += t[i];
	}
	return s;
}
int cmp(int i, int j) {
	return b[i] < b[j];
}
int main()
{
	int k;
	
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	b[0] = 0;
	c[0] = 0;
	for (int i = 1; i <= n; i++) {
		c[i] = i;
		b[i] = b[i - 1] + a[i] - k;
	}
	stable_sort(c, c + n + 1, cmp);
	for (int i = 0; i <= n; i++) {
		d[c[i]] = i + 1;
	}/*
	for (int i = 0; i <= n; i++) {
		printf("%d\n", d[i]);
	} */
	long long s = 0;
	for (int i = 0; i <= n; i++) {
		s += query(d[i]);
		//printf("%d\n", s);
		add(d[i]);
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 5752