akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define M cin>>
int s[200001];
main() {
    int n,c,l,z,x,h=1e9+7;
    M n;
    M z;
    c=l=s[z] = 1;
    for(int i = 2; i <= n; i ++) {
        M x;
        if(x!=z) {
            c+=s[x];
            c%=h;
            s[x]+=l;
            s[x]%=h;
        }
        l=c;
        z=x;
    }
    cout<<c;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
  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(0);
  ios::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);

  cout<< st.size() << endl;

  return 0;
}


Measured memory_bytes: 256
//
// Created by gary on 27.07.17.
//

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int) (x).size())

const int N = 223456;

int a[N];

int c[N];
int cov[N];

int covered = 0;

void update(int i, int x) {
    if (i <= 0)
        return;
    if (cov[i] == 0) covered++;
    cov[i] += x;
    if (cov[i] == 0) covered--;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        update(a[i] - c[a[i]]++, +1);
    }

    for (int it = 0; it < q; it++) {
        int i, x;
        scanf("%d%d", &i, &x);
        i--;
        update(a[i] - --c[a[i]], -1);
        a[i] = x;
        update(a[i] - c[a[i]]++, +1);
        printf("%d\n", n - covered);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

char s[27];

int main(void){
	scanf("%s",s);
	int i,j,len=strlen(s),memo[26]={0};
	if(len < 26){
		for(i=0;i<len;i++)memo[s[i]-'a'] = 1;
		for(i=0;memo[i];i++);
		s[len] = 'a'+i;
		s[len+1]='\0';
		printf("%s",s);
		return 0;
	}else{
		for(i=len-1;i>=0;i--){
			memo[s[i]-'a'] = 1;
			for(j=s[i]-'a'+1;j<26&& !memo[j];j++);
			if(j<26){
				s[i] = 'a'+j;
				s[i+1] = '\0';
				printf("%s",s);
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    REP(i, n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b;
  double cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合
  double sum;

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  double kruskal() {
    // コストが小さい順にソート
    sort(es.rbegin(), es.rend());

    UnionFind uf(n);
    double min_cost = 0;

    REP(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int n, m;
  cin >> n >> m;
  g.n = n;
  vi x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
  }
  REP(i, m) {
    Edge e;
    cin >> e.a >> e.b;
    e.a--;
    e.b--;
    e.cost = hypot(x[e.a] - x[e.b], y[e.a] - y[e.b]);
    g.sum += e.cost;
    g.es.push_back(e);
  }
  return g;
}

int main(){
  Graph g = input_graph();
  printf("%.3lf\n", g.sum - g.kruskal());
}

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

using namespace std;
int main(){
	int n;
	int W;
	cin>>n;
	cin>>W;
	vector<long long int> w(n);
	vector<long long int> v(n);
	for(int i = 0 ; i <  n ; i++){
		cin>>w[i]>>v[i];
	}
	
	long long int dp[n+1][W+1];
	
	for(int i = 0 ; i <= n ;i++){
		for(int j = 0 ; j <=W ; j++){
			if(i==0||j==0) dp[i][j] = 0;
			else if(w[i-1]>j){
				dp[i][j] = dp[i-1][j];
			}
			else{
				dp[i][j] = max(dp[i-1][j] , dp[i-1][j-w[i-1]] + v[i-1]);
			}
		}
	}
	cout<<dp[n][W];
	return 0;
}


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


    using namespace std;


    int main()
    {
      int n,sum=0;
      cin>>n;
      int arr[n];
      for(int i=0;i<n;i++)
        cin>>arr[i];
        bool flag=false;
        while(true)
        {
            for(int i=0;i<n;i++)
            {
                if(arr[i]%2!=0)
                {
                    flag=true;
                    break;
                }

            }
            if(flag)
                break;
            for(int i=0;i<n;i++)
            {
                arr[i]=arr[i]/2;

            }
            sum++;

        }
        cout<<sum;


        return 0;
    }


Measured memory_bytes: 256
H,N = map(int,input().split())
dp= [float("INF")]*(H+1)
dp[0]=0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(1,H+1):
        dp[j] = min(dp[j],dp[max(j-a,0)]+b)

print(dp[-1])

Measured memory_bytes: 50396
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, m;

class UnionFind {
public:
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x != y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }
  int size(int x) {
    return -data[find(x)];
  }
};

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

  cin >> n >> m;
  vector<P> v(m);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[i] = P(a, b);
  }

  UnionFind uf(n);

  vector<ll> ans(m, 0);

  RREP(i, m) {
    P p = v[i];
    ll fs = (ll)uf.size(p.first);
    ll ss = (ll)uf.size(p.second);

    if(uf.find(p.first) != uf.find(p.second)) ans[i] = fs * ss;
    uf.unite(p.first, p.second);
  }

  ll sum = 0;
  REP(i, m) {
    sum += ans[i];
    cout << sum << endl;
  }
}


Measured memory_bytes: 5316
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>

using namespace std;

#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(int argc, char *argv[]) {
  string s,t;
  cin >> s >> t;
  ll ans = 0;
  rep(i, s.size()){
	  if(s[i] != t[i]){
		  ans++;
	  }
  }
  cout << ans << endl;

  return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

lli dp[100010];

void tejas_919(int kkkk)
{
    int n, W;
    cin>>n>>W;
    fol(i,1,n+1)
    {
        int w, v;
        cin>>w>>v;
        loop(j,W-w,0)
            dp[j+w]=max(dp[j+w],dp[j]+v);
    }
    cout<<*max_element(dp,dp+W+1)<<endl;
}

int main()
{
    #ifndef tejasp
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #endif
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int dp[11][156];

string unj(string s) {
    int n = s.length();
    return s.substr(n - 1) + s.substr(0, n - 1);
}

string unc(string s) {
    int n = s.length();
    return s.substr(1) + s.substr(0, 1);
}

string une(string s) {
    int n = s.length();
    if (s.size() & 1) {
        return s.substr(n / 2 + 1) + s.substr(n / 2, 1) + s.substr(0, n / 2);
    } else {
        return s.substr(n / 2) + s.substr(0, n / 2);
    }
}

string una(string s) {
    return string(s.rbegin(), s.rend());
}

string unp(string s) {
    for (char &c : s) if (isdigit(c)) c = '0' + (c - '0' + 9) % 10;
    return s;
}

string unm(string s) {
    for (char &c : s) if (isdigit(c)) c = '0' + (c - '0' + 1) % 10;
    return s;
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    int n; cin >> n;
    rep(i, 0, n) {
        string ins, str; cin >> ins >> str;
        reverse(all(ins));
        for (char c : ins) {
            if (c == 'J') str = unj(str);
            if (c == 'C') str = unc(str);
            if (c == 'E') str = une(str);
            if (c == 'A') str = una(str);
            if (c == 'P') str = unp(str);
            if (c == 'M') str = unm(str);
        }
        cout << str << endl;
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0) cout << (a + b) / 2;
    else cout << (a + b) / 2 + 1; 
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()

typedef pair< int, int > pii;

int N, Q;
vector< int > s, id;
set< int > leader;

int count(int r) {
	if ((int)leader.size() == 0) return N;
	
	set< int >::iterator it = leader.begin(), eit = leader.end();
	int res = 0, p = -1;
	
	for (; it != eit; ++it) {
		int L = lower_bound(allof(s), s[*it] - r) - s.begin();
		res += max(0, L - (p + 1));
		int R = upper_bound(allof(s), s[*it]) - s.begin() - 1;
		p = R;
	}
	
	res += N - (p + 1);
	return res;
}

int check(int x) {
	int lb = -1, ub = (int)1e9 + 10;
	
	while (ub - lb > 1) {
		int med = (lb + ub) / 2;		
		if (x < count(med)) lb = med;
		else ub = med;
	}
	
	return ub;
}

void query() {
	for_(i,0,Q) {
		string t; int a; cin >> t >> a;
		
		if (t == "ADD") leader.insert(id[a-1]);	
		
		if (t == "REMOVE") leader.erase(id[a-1]);
		
		if (t == "CHECK") {
			int res = check(a);
			if (res > (int)1e9) cout << "NA" << endl;
			else cout << res << endl;
		} 
	}
}

int main() {
	cin >> N >> Q;
	
	vector< pii > vp;
	for_(i,0,N) {
		int s; cin >> s;
		vp.push_back(pii(s, i));
	}
	
	sort(allof(vp));
	
	s.assign(N, 0);
	id.assign(N, 0);
		
	for_(i,0,N) {
		s[i] = vp[i].first;
		id[vp[i].second] = i;
	}
	
	query();
	
	return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    int xl = 0;
    int yl = 0;
    int xr = 1;
    int yr = 1;
    int F[100000]{};
    F[1] = 1;
    F[2] = F[1] + F[0];
    for (int i = 1; i < 100000; i++) {
        F[i + 1] = F[i] + F[i - 1];
        if (xl <= x && x < xr && yl <= y && y < yr) {
            int ans = i % 3;
            if (ans == 0) ans = 3;
            cout << ans<< "\n";
            return 0;
        }
        // cout << xl << " " << xr << "\n";
        // cout << yl << " " << yr << "\n";
        // cout << "-------------\n";
        if (i % 4 == 1) {
            xl = xr;
            xr += F[i + 1];
            yr = yl + F[i + 1];
        } else if (i % 4 == 2) {
            xl = xr - F[i + 1];
            yl = yr;
            yr += F[i + 1];
        } else if (i % 4 == 3) {
            xr = xl;
            xl -= F[i + 1];
            yl = yr - F[i + 1];
        } else {
            xr = xl + F[i + 1];
            yr = yl;
            yl -= F[i + 1];
        }
    }
    return 0;
}


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

void dfs (int x, int y, vector<vector<int>> &V, int H, int W, int INF, queue<vector<int>> &qq) {
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  int nx, ny;
  qq.push({x, y});
  
  for (int i=0; i<4; i++) {
    nx = x + dx[i];
    ny = y + dy[i];
    if (0 <= nx && nx < H && 0 <= ny && ny < W && V[nx][ny] == INF) {
      V[nx][ny] = V[x][y];
      dfs(nx, ny, V, H, W, INF, qq);
    }
  }
  
  return;
}



void bfs (queue<vector<int>> &qq, queue<vector<int>> &Q, vector<vector<int>> &V, int H, int W, int INF) {
  while (qq.size()) {
    vector<int> q = qq.front();
    qq.pop();
    int nx, ny;
    for (int dx=-2; dx<=2; dx++) {
      for (int dy=-2; dy<=2; dy++) {
        nx = q[0] + dx;
        ny = q[1] + dy;
        if (0 <= nx && nx < H && 0 <= ny && ny < W && V[nx][ny] == INF) {
          V[nx][ny] = V[q[0]][q[1]] + 1;
          Q.push({nx, ny});
        }
      }
    }
  }
  return;
}



int main() {

  int H, W;
  cin >> H >> W;
  vector<int> C(2);
  vector<int> D(2);
  cin >> C[0] >> C[1];
  cin >> D[0] >> D[1];
  vector<vector<int>> V(H, vector<int>(W));
  char v;
  int INF = 10000000;
  
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> v;
      if (v == '.') {
        V[i][j] = INF;
      }
      else {
        V[i][j] = -10;
      }
      //cout << V[i][j] << " ";
    }
    //cout << endl;
  }
  
  using vvv = vector<int>;
  queue<vvv> Q, qq;
  vvv P;
  
  V[C[0]-1][C[1]-1] = 0;
  Q.push({C[0]-1, C[1]-1});
  
  //cout << Q.size() << endl;
  
  //int c=0;
  while (Q.size()) {
    //c++;
    while (Q.size()) {
      P = Q.front();
      Q.pop();
      dfs(P[0], P[1], V, H, W, INF, qq);
      //cout << c << endl;
    }
    
    while (qq.size()) {
      bfs(qq, Q, V, H, W, INF);
    }
    if (V[D[0]-1][D[1]-1] != INF) {break;}
    
  }
  
  
  if (V[D[0]-1][D[1]-1] == INF) {
    cout << -1 << endl;
  }
  else {
    cout << V[D[0]-1][D[1]-1] << endl;
  }
  
  /*
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << V.at(i).at(j) << " ";
    }
    cout << endl;
  }
  */
}

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

#define N_MAX n+1

int main() {
	
	string s;
	cin >> s;
	
	int ans=700;
	if(s[0]=='o')ans+=100;
	if(s[1]=='o')ans+=100;
	if(s[2]=='o')ans+=100;
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// hoge hoge

fn main() {
    input! {
        mut a: [i64; 5],
        k: i64,
    }

    a.sort();

    let ans = if a[4] - a[0] > k { ":(" } else { "Yay!" };

    println!("{}", ans);
}


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

map<char, string> S;

signed main()
{
	cin >> S['a'] >> S['b'] >> S['c'];
	char turn = 'a';
	while (true) {
		if (S[turn].length() == 0) {
			cout << (char)('A' + (turn - 'a')) << endl;
			return 0;
		} else {
			char next = S[turn][0];
			//turn = S[turn][0];
			S[turn] = S[turn].substr(1);
			turn = next;
		}
	}
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>
#define ll long long
#define F(i,s,t) for(int i=s;i<=t;i++)
#define DF(i,s,t) for(int i=s;i>=t;i--)
#define mp make_pair
using namespace std;
map<pair<string,string>,ll>sa;
char s[233];
ll sum=0;
int n;
string a,b;

int main(){
	scanf("%d",&n);
    scanf("%s",s);
    F(i,0,(1<<n)-1){
        a="",b="";
        F(j,0,n-1) (i&(1<<j))?(a+=s[j]):(b+=s[j]);
        sa[mp(a,b)]++;
    }
    F(i,0,(1<<n)-1){
        a="",b="";
        DF(j,n-1,0) (i&(1<<j))?(b+=s[j+n]):(a+=s[j+n]);
        sum+=sa[mp(a,b)];
    }
    printf("%lld\n",sum);
    return 0;
}

/*


*/


Measured memory_bytes: 91904
#include <iostream>
#include <string>

int main()
{
	int W, H, x, y, r;
	std::string answer;

	std::cin >> W >> H >> x >> y >> r;
	
	if (x - r < 0 || x + r > W)
	{
		answer = "No";
	}
	else if (y - r < 0 || y + r > H)
	{
		answer = "No";
	}
	else
	{
		answer = "Yes";
	}

	std::cout << answer << std::endl;

	return 0;
}


Measured memory_bytes: 3204
#入力
n,k,q = map(int,input().split())
#変数point
point = [k-q]*n

for i in range(q):
    a = int(input()) - 1
    point[a] += 1

for j in range(n):
    if point[j] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 6584
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

vector<string> split(string s, string delimiter) {
  int first = 0;
  int last = s.find_first_of(delimiter);
  vector<string> result;

  while (first < s.size()) {
    string sub = s.substr(first, last - first);
    result.push_back(sub);
    first = last + 1;
    last = s.find_first_of(delimiter, first);

    if (last == string::npos) {
      last = s.size();
    }
  }

  return result;
}

string join(vector<string> strings, string delimiter) {
  string result = "";
  for (int i = 0; i < strings.size(); i++) {
    if (result != "") result += delimiter;
    result += strings[i];
  }
  return result;
}

class Solution {
 public:
  void solve() {
    int N;
    cin >> N;

    int cost = 0;
    int sum = 0;
    vector<int> nums;
    for (int i = 0; i < N; i++) {
      int n;
      cin >> n;
      sum += n;
      nums.push_back(n);
    }
    double avg = sum / (double)N;

    if (abs(ceil(avg) - avg) < abs(floor(avg) - avg)) {
      avg = ceil(avg);
    } else {
      avg = floor(avg);
    }

    for (int i = 0; i < N; i++) {
      cost += (nums[i] - avg) * (nums[i] - avg);
    }

    cout << cost << endl;
  }
};

int main() { Solution().solve(); }

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

int n;
int a[100000];
int p[100001];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  p[0] = -1e9;
  for (int i = 0; i < n; ++i) p[i + 1] = max(p[i], a[i]);
  
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    if (p[i] >= a[i] + 2) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
x = [0]*n
for i in range(1, n):
    x[i] = x[i-1] + abs(a[i-1]-a[i])
y = [0]*n
for i in range(n-1)[::-1]:
    y[i] = y[i+1] + abs(a[i+2]-a[i+3])
for i in range(n):
    print(x[i] + abs(a[i+2]-a[i]) + y[i])

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

typedef struct {
	int x;
	int y;
	int h;
} point;

int main(void) {
	int N;
	vector <point> pt;

	cin >> N;
	for (int i = 0; i < N; i++) {
		point tmp;
		cin >> tmp.x >> tmp.y >> tmp.h;
		pt.push_back(tmp);
	}

	// N==1の場合はそこが中心でないとひとつに定まらない
	if (pt.size() == 1) {
		cout << pt.at(0).x << " " << pt.at(0).y << " " << pt.at(0).h << endl;
		return 0;
	}

	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			// 仮に中心がCx, Cyだった場合のHを計算する
			int H;
			for (unsigned int i = 0; i < pt.size(); i++) {
				// すべて h = 0 はありえない (高さを特定できない)
				// N = 100*100-1ならあり得るが、N <=100
				if (pt.at(i).h > 0) {
					H = pt.at(i).h + abs(pt.at(i).x - Cx) + abs(pt.at(i).y - Cy);
					break;
				}
			}

			bool found = true;
			for (unsigned int i = 0; i < pt.size(); i++) {
				if (pt.at(i).h != max(H - abs(pt.at(i).x - Cx) - abs(pt.at(i).y - Cy), 0)) {
					found = false;	
					break;
				}
			}
			if (found) {
				cout << Cx << " " << Cy << " " <<  H << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 


    fast;

    ll n;
    cin>>n;

    ll ans=1;
    ll mn;

    for(ll i=0;i<n;i++)
    {
      ll x;
      cin>>x;
      if(i==0)
        mn=x;
      else
      {
        if(x<=mn)
        {
          ans++;
          mn=x;
        }
      }
    }
cout<<ans<<endl;
}

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

using namespace std;


int main() {
    int h, n;
    cin >> h >> n;
    vector <vector <long long>> dp(n, vector <long long>(h + 1));
    vector <pair<int, int> > s(n);
    vector <long long> mins(h + 1);
    mins[1] = 10000000000;
    for (int i = 0; i < n; ++i) {
        cin >> s[i].first >> s[i].second;
        dp[i][1] = s[i].second;
        mins[1] = min(mins[1], dp[i][1]);
    }
    for (int i = 2; i <= h; ++i) {
        mins[i] = 1000000000000;
        for (int j = 0; j < n; ++j) {
            if (s[j].first >= i)
                dp[j][i] = s[j].second;
            else {
                dp[j][i] = s[j].second + mins[i - s[j].first];
            }
            mins[i] = min(mins[i], dp[j][i]);
        }
    }
    cout << mins[h];
    return 0;
}

Measured memory_bytes: 80640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N; cin>>N;
  int x=0, y=0;
  int t=0;
  bool ok = true;
  rep(i,N) {
    int t2;
    int x2,y2;
     cin>>t2>>x2>>y2;
    int time = t2-t;
    int dist = abs(x2-x) + abs(y2-y);
    if (dist > time || ((dist&1) != (time&1)) ) {
      ok = false; 
    }

   t=t2;
    x=x2, y=y2;
  }
  ok();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A,B;
    cin >> A >> B;
    cout <<  max(A-B, max(A+B, A*B)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long long n;
  while (cin >> n && n) {
    long long i,ret=0;
    double sum = 0,a[n];
    for(i=0;i<n;i++){
      cin >> a[i];
      sum+=a[i];
    }
    sum/=(double)n;
    for(i=0;i<n;i++){
      if(sum>=a[i])ret++;
    }
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3);
  for(int i = 0;i < 3;i++) {
    cin >> a.at(i);
  }
  int k;
  cin >> k;
  sort(a.begin(),a.end());
  for(int i = 0;i < k;i++) {
    a.at(2) *= 2;
  }
  int sum = 0;
  for(int i = 0;i < 3;i++) {
    sum += a.at(i);
  }
  cout << sum << endl;
}

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

const int MAX = 10001;

char p[MAX] = {0};

void prime() { // f©¬©¾¯»f·éB1ÈçfB0Èç¬
  for(int i = 2 ; i < MAX ; i++ ) p[i] = 1;

  for(int i = 2 ; i * i < MAX ; i++ ) {
    if( p[i] == 1 ) {
      for(int j = i + i ; j < MAX ; j += i ) {
	p[j] = 0;
      }
    }
  }
}

int main(void) {
	int n;
	prime();
	while( cin >> n ) {
	  int cnt = 0;
	  for(int a = 1 ; a <= n ; a++) {
	    int b = n + 1 - a;
	    if( p[a] && p[b] == 1 ) cnt++; //p[a], p[b]ÇÁ¿àfÈçCOUNT
	  }
	  cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const ll MX = 1000000;
bool p[MX + 5];

int main() {
    FOR(i, 2, MX) {
        if (p[i]) continue;
        for (int j =  i +i; j <= MX; j += i)
            p[j] = 1;
    }
    ll n, ans = 0; cin >> n;
    for (int i = 2; i <= MX; i++) {
        if (p[i]) continue;
        ll t = i;
        while (n % t == 0)
            n /= t, t *= i, ans++;
    }
    if (n > MX) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//(double)clock() / CLOCKS_PER_SEC;
ll n, m;


//from https://github.com/ADJA/algos/blob/master/NumberTheory/DiophantineEquation.cpp
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

// Finds such x and y, that a * x + b * y = gcd(a, b)
long long extended_gcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1; y = 0;
        return a;
    }
    long long x1, y1;
    long long g = extended_gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - (a / b) * y1;
    return g;
}

// Solves equation a * x + b * y = c, writes answer to x and y
void solveDiophantine(long long a, long long b, long long c, long long &x, long long &y) {
    long long g = extended_gcd(a, b, x, y);

    if (c % g != 0) {
        puts("Impossible");
        exit(0);
    }

    c /= g;

    x = x * c; y = y * c;
}


ll solve(ll a, ll b)
{
    ll g = gcd(a, b);

    ll x, y;

    solveDiophantine(a, b, 1, x, y);

    long long add = b / g;
    long long num = 0;
    if (add < 0)
        num = (long long) floor(1.0 * -x / add);
    else
        num = (long long) ceil(1.0 * -x / add);

    x = x + b / g * num;

    return a*x-1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    n*=2;
    m=n;
    vll ps;
    ll cnt=2;
    while(cnt*cnt<=m)
    {
        if(m%cnt==0)
        {
            ll x=1;
            while(m%cnt==0)
            {
                x*=cnt;
                m/=cnt;
            }
            ps.push_back(x);
        }
        cnt++;
    }
    if(m>1)
    {
        ps.push_back(m);
    }
    int P=ps.size();
    ll ans=(n-1);
    for(int msk=0; msk<(1<<(P-1)); msk++)
    {
        ll x=1;
        ll y=1;
        for(int i=0; i<P; i++)
        {
            if((msk & (1<<i))>0) x*=ps[i];
            else y*=ps[i];
        }
        ll s1=solve(x, y);
        ll s2=solve(y, x);
        //cout<<x<<" "<<y<<endl;
        //cout<<s1<<" "<<s2<<endl;
        if(s1>0) ans=min(ans, s1);
        if(s2>0) ans=min(ans, s2);
        /*if(x>y) swap(x, y);

        for(ll yc=1; yc*y<=n; yc++)
        {
            if((yc*y-1)%x==0)
            {
                ans=min(ans, (yc*y-1));
                break;
            }
            if((yc*y+1)%x==0)
            {
                ans=min(ans, yc*y);
                break;
            }
        }*/
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3744
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int s=0;
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        s+=(a[i]-'0');
    }
    if(s%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3748
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
struct st{
    string s;
    int index;
    int p;
};


bool cmp_name(const st &a, const st &b)
{
    return a.s < b.s;
}

bool cmp_p(const st &a, const st &b)
{
    return a.p > b.p;
}


int main(int argc, const char * argv[]) {
    
    int n; 
    cin >> n;

    vector<pair<pair<string, int>, int> > rev(n);

    for (int i=0; i< n; i++){
        int p;
        cin >> rev[i].first.first >> p;
        rev[i].first.second = -p;
        rev[i].second = i+1;
    }

    //sort(rev.begin(), rev.end(), cmp_p); 
    // sort(rev.begin(), rev.end(), cmp_name); 
    sort(rev.begin(), rev.end());

    for (int i=0; i< n; i++){
        cout << rev[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i;
	char blood[3];
	int a,b,o,ab;

	a=b=o=ab=0;
	while(scanf("%d,",&i)!=EOF){
		scanf("%s",blood);
		if(blood[0]=='A' && blood[1]=='B'){
			ab++;
		}
		else if(blood[0]=='A'){
			a++;
		}
		else if(blood[0]=='B'){
			b++;
		}
		else if(blood[0]=='O'){
			o++;
		}
	}
	printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s=="ABC") cout << "ARC" << endl;
  if(s=="ARC") cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using namespace atcoder;
using ll = long long;

int op (int a, int b) {
    return max(a, b);
}
int e () {
    return 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    segtree<int, op, e> seg(300005);
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        int l = max(a[i] - k, 0);
        int r = min(a[i] + k + 1, 300001);
        int m = seg.prod(l, r);
        seg.set(a[i], m + 1);
    }
    cout << seg.all_prod() << endl;
    return 0;
}

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

int main() {
  int k;
  string s;
  cin >> k >> s;

  if (s.length() > k) {
    s = s.substr(0, k);
    s += "...";
  }
  cout << s << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int l,r;
int ans,a;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>l>>r;
	a=l;
	while(1){
		ans++;
		a*=2;
		if(a>r) break;	
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct data{
	int l,r;
	int calc(int x,int &w){
		if (l<=x&&x<=r){
			w=x;return 0;
		}
		if (x<l){
			w=l;return l-x;
		}else{
			w=r;return x-r;
		}
	}
}a[210001];
typedef long long ll;
ll ans1,ans2;
int p,i,j,k,n,m,v[210001],b[210001],c[210001],t1,t2;
bool cmp1(int x,int y){
	return a[x].l>a[y].l;
}
bool cmp2(int x,int y){
	return a[x].r<a[y].r;
}
bool cmp3(int x,int y){
	return a[x].r<a[y].r;
}
bool cmp4(int x,int y){
	return a[x].l>a[y].l;
}
int main(){
	scanf("%d",&n);memset(v,0,sizeof(v));
	for (i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r),b[i]=c[i]=i;
	sort(b+1,b+1+n,cmp1);sort(c+1,c+1+n,cmp2);
	for (i=j=k=1,p=ans1=0;i<=n;i++){
		if (i&1){
			while (v[b[j]]) j++;
			ans1+=a[b[j]].calc(p,t1);v[b[j]]=1;
			p=t1;
		}else{
			while (v[c[k]]) k++;
			ans1+=a[c[k]].calc(p,t1);v[c[k]]=1;
			p=t1;
		}
	}
	ans1+=(p>=0)?p:-p;
	sort(b+1,b+1+n,cmp3);sort(c+1,c+1+n,cmp4);
	memset(v,0,sizeof(v));
	for (i=j=k=1,p=ans2=0;i<=n;i++){
		if (i&1){
			while (v[b[j]]) j++;
			ans2+=a[b[j]].calc(p,t1);v[b[j]]=1;
			p=t1;
		}else{
			while (v[c[k]]) k++;
			ans2+=a[c[k]].calc(p,t1);v[c[k]]=1;
			p=t1;
		}
	}
	ans2+=(p>=0)?p:-p;
	printf("%lld\n",max(ans1,ans2));
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a,b,c;
    int k,m,l,x;
    int cnt = 0;

    if(n >= 777777753){
        cout << 26484 << endl;
        return 0;
    }

    for(int i = 357;i <=n;){
        if((i%100)/10!=3&&(i%100)/10!=5&&(i%100)/10!=7){
            if(i%10 == 3 || i % 10 == 5){
                i += 2;
            }else if(i % 10 == 7){
                i += 6;
            }
            continue;
        }

        if((i%1000)/100!=3&&(i%1000)/100!=5&&(i%1000)/100!=7){
            if(i%10 == 3 || i % 10 == 5){
                i += 2;
            }else if(i % 10 == 7){
                i += 6;
            }
            continue;
        }

        a = 0;
        b = 0;
        c = 0;
        k = 1;
        m = i;
        l = i;
        for(;;){
            if(m / 10 != 0){
                m /= 10;
                k ++;
            }else{
                break;
            }
        }

        for(int j = 0;j < k;j ++){
            x = l % 10;
            if(x == 3){
                a ++;
            }else if(x == 5){
                b ++;
            }else if(x == 7){
                c ++;
            }
            l /= 10;
        }

        if(a != 0 && b != 0 && c != 0 && a+b+c == k){
            cnt ++;
        }

        if(i%10 == 3 || i % 10 == 5){
            i += 2;
        }else if(i % 10 == 7){
            i += 6;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, m, k;
  cin >> n >> m >> k;
  for (ll i = 0; i <= m; i++) {
    ll ans = n*i;
    for (ll j = 0; j <= n; j++) {
      ll c = ans + (m-i)*j -i*j;
      if (c == k) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  cout << "No" << '\n';
}

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


int main(){   
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1; i<=n; ++i){
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    x = int(input())

    n = 0
    y = 100
    while True:
        if y >= x:
            print(n)
            return

        n += 1
        y = int(y*1.01)

if __name__ == "__main__":
    resolve()


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

int main(void)
{
    int c,a,b;
    scanf("%d %d %d",&a,&b,&c);
    a+b>=b+c?a+c>=b+c?printf("%d",b+c):printf("%d",a+c):a+b>=a+c?printf("%d",a+c):printf("%d",a+b);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
 
using namespace std;
long long arr[450];
long long dp[450][450];
long long pref[450];
long long dprec(long long l,long long r){
    
    if(dp[l][r]){
        return dp[l][r];
    }
    if(l == r){
        
        return dp[l][r] = 0;
    }
    long long holdmin = dprec(l+1,r);
    for(int i=l+1;i<r;i++){
        holdmin = min(holdmin,dprec(l,i)+dprec(i+1,r));
    }
    return dp[l][r] = holdmin + pref[r]-pref[l-1];
}
int main() {
    long long n;
    cin>>n;
    vector<long long> v1;
    pref[0] = 0;
    for(long long i=0;i<n;i++){
        cin>>arr[i];
        v1.push_back(arr[i]);
        pref[i+1] = arr[i]+pref[i];
    }
    cout<<dprec(1,n);
    
}

Measured memory_bytes: 1664
N = input()
color = [0] * N
d = [0] * N
f = [0] * N
nt = [0] * N
m = [[0] * N for i in range(N)]
S = []
tt = 0

def next(u):
    global nt
    w = nt[u]
    for v in range(w, N):
        nt[u] = v + 1
        if( m[u][v] ):
            return v
    return -1

def dfs_visit(r):
    global tt 
    S.append(r)
    color[r] = 1
    tt += 1
    d[r] = tt

    while( len(S) != 0 ):
        u = S[-1]

        v = next(u)
        if ( v != -1 ):
            if ( color[v] == 0 ):
                color[v] = 1
                tt += 1
                d[v] = tt
                S.append(v)
        else:
            S.pop()
            color[u] = 2
            tt += 1
            f[u] = tt
        
def dfs():
    global color
    for u in range(N):
        if( color[u] == 0 ):
            dfs_visit(u)

if __name__ == '__main__':

    for i in range(N):
        v = map(int, raw_input().split())
        for j in v[2:]:
            m[i][j-1] = 1
    
    dfs()

    for i in range(N):
        print (i+1), d[i], f[i]

Measured memory_bytes: 6432
/*
* @author:  codancer
* @createTime:  2020-04-12, 20:03:49
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0) continue;
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;


int main(){
    int n;
    int answer=0;
    int b=0;
    cin >> n;
    FOR(i,2,n+1){
        b=0;
        if(i%2){
            int tmp = i;
            FOR(i,1,n+1){
                if(tmp%i==0)
                    b++;
            }
        }
        if(b>=8){
            answer++;
        }
    
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256