akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, d, s[11][11], ans;
int main() {
	cin >> n >> d;
	REP(i, n) {
		REP(j, d) {
			cin >> s[i][j];
		}
	}
	REP(i, n) {
		FOR(j, i + 1, n) {
			ll now = 0;
			REP(k, d) {
				now += (s[i][k] - s[j][k]) * (s[i][k] - s[j][k]);
			}
			if (now % (ll)sqrt(now) == 0 and now / (ll)sqrt(now) == sqrt(now))ans++;
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define ft first
#define sd second
#define pii pair<int,int>
#define all(vect) vect.begin(),vect.end()
#define rall(vect) vect.rbegin(),rend() 
const int num = 500001;
typedef long long ll;


typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;

int occs[(int)1e6 + 5], tree[num], n, ans[num];

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
{
    int l,r,q,s;
    vector<node> v;
    cin >> n >> q;
    rep(i,1,n+1)
    {
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    rep(i,0,q)
    {
        scanf("%d %d", &l, &r);
        v.push_back(node(l, r, 0, i));
    }
    
    sort(v.begin(), v.end());
    
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
    
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
    
    return 0;
}



Measured memory_bytes: 25316
#include <cmath>
#include <string.h>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, j, n) for (int i = j; i < n; i++)
#define rep_nested(i, s, n) for (ull i = s; i <= n; i++)
#define ll long long
#define ull unsigned long long

const int N = 500;
const ll INF = 1e9 + 7;

using namespace std;

template <class T>
T limit(T n, T k) {
	return (n > k) ? k : n;
}

template <class T>
T has_order(T a, T b, T c) {
	return (b > a && b < c) || (b < a && b > c);
}

template <class T>
float points_distance(T a) {
	return sqrt(a);
}

template <class T>
T is_integer(T a) {
	return floor(a) == a;
}

int main() {
	int n, k, min, count = 0;
	vector<int> v;
	
	cin >> n;
	
	rep(i, 0, n) {
		cin >> k;
		v.push_back(k);
	}
	
	rep(i, 0, n - 1) {
		min = i;
		
		rep(j, i + 1, n) {
			if (v[min] > v[j]) {
				min = j;
			}
		}
		
		if (min != i) {
			k = v[min];
			v[min] = v[i];
			v[i] = k;
			count++;
		}
		
		if (count > 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

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

const int inf=1e9+10;
const int maxn=2e5+10;

string s;
int n;

int main(){
	cin>>n>>s;
	int have=0,sum=0;
	for(int i=0;i<n;i++) if(s[i]=='R') sum++;
	int ans=inf;
	for(int i=0;i<=n;i++){
		if(i>0&&s[i-1]=='R'){
			have++;
		}
		int need=i-have,got=sum-have;
		int now;
		if(need<=got){
			now=need+got-need;
		}
		else{
			now=got+need-got;
		}
		ans=min(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b < c+d)
  {
    cout << "Right" << endl;
  }
  else if (a+b > c+d)
  {
    cout << "Left" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < K; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int N, M;
vector<int64> x, y, z;

int main(void){
	cin >> N >> M;
	x.resize(N); y.resize(N); z.resize(N);
	REP(i, N) cin >> x[i] >> y[i] >> z[i];

	int64 res = -INF_LL;
	REP(a, 1 << 3){
		vector<PLL> v;
		REP(i, N){
			int64 sum = 0;
			if(a >> 0 & 1) sum += x[i];
			else sum += -x[i];
			if(a >> 1 & 1) sum += y[i];
			else sum += -y[i];
			if(a >> 2 & 1) sum += z[i];
			else sum += -z[i];
			v.push_back(PLL(sum, i));
		}
		int64 sx = 0, sy = 0, sz = 0;
		sort(all(v), greater<PLL>());
		REP(i, M){
			if(a >> 0 & 1) sx += x[v[i].sc];
			else sx += -x[v[i].sc];
			if(a >> 1 & 1) sy += y[v[i].sc];
			else sy += -y[v[i].sc];
			if(a >> 2 & 1) sz += z[v[i].sc];
			else sz += -z[v[i].sc];
		}
		chmax(res, abs(sx)+abs(sy)+abs(sz));
	}
	cout << res << endl;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

if a == 0 :
    print(0)
elif n <= a :
    print(n)
elif a < n <= a + b :
    print(a)
else:
    if n%(a+b) <= a :
        print((n//(a+b))*a + (n%(a+b)))
    else:
        print((n//(a+b))*a + a )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n, h;
    scanf("%d%d", &n, &h);
    int amax = 0;
    pii p[n];
    rep(i, n){
        int a, b;
        scanf("%d%d", &a, &b);
        p[i] = pii(b, a);
        amax = max(amax, a);
    }
    
    sort(p, p+n, greater<pii>());
    int cnt = 0;
    rep(i, n)if(p[i].fi >= amax){
        h -= p[i].fi;
        ++cnt;
        if(h <= 0){
            printf("%d\n", cnt);
            return 0;
        }
    }
    
    cnt += (h-1)/amax + 1;
    printf("%d\n", cnt);
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}


int n;
int main()
{
	std::cin >> n;
	std::vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];
	for (int i = 0; i < n; ++i)
		std::cin >> b[i];

	int ans = 0;
	for (int i = 0; i < 29; ++i) {
		int x = 1 << i;
		std::vector<int> v(n);
		for (int j = 0; j < n; ++j)
			v[j] = b[j] % (x << 1);
		std::sort(v.begin(), v.end());

		int cnt = 0;
		for (int j = 0; j < n; ++j) {
			int c = a[j] % (x << 1);
			std::vector<int> y = { x, x << 1, (x << 1) | x };
			std::vector<int> index(3);
			for (int k = 0; k < 3; ++k)
				index[k] = std::lower_bound(v.begin(), v.end(), y[k] - c) - v.begin();
			cnt += (index[1] - index[0]) + (n - index[2]);
		}
		if (cnt % 2 != 0)
			ans ^= x;
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 2560
N = int(input())
s = [int(input()) for i in range(N)]
sums = sum(s)

if sums % 10 != 0:
    print(sums)
else:
    s.sort()
    for i in s:
        if i % 10 != 0:
            print(sums - i)
            exit()
    else:
        print(0)




Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x[n],y[n],a[n];
  for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> a[i];
  int b[h][w]={};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      b[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    if(a[i]==1){
      for(int j=0;j<h;j++){
        for(int k=0;k<x[i];k++){
          b[j][k]=1;
        } 
      }
    }
    else if(a[i]==2){
      for(int j=0;j<h;j++){
        for(int k=x[i];k<w;k++){
          b[j][k]=1;
        } 
      }
    }
    else if(a[i]==3){
      for(int j=h-y[i];j<h;j++){
        for(int k=0;k<w;k++){
          b[j][k]=1;
        } 
      }
    }
    else if(a[i]==4){
      for(int j=0;j<h-y[i];j++){
        for(int k=0;k<w;k++){
          b[j][k]=1;
        } 
      }
    }
  }
  int count=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(b[i][j]==0)count++;
    }
  } 
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
#include <random>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  std::array<int, 26> c; rep(i,26) std::cin >> c[i];
  std::vector<std::array<int,26>> s(D);
  rep(i,D) rep(j,26) std::cin >> s[i][j];

  std::random_device rnd;
  std::mt19937 mt(rnd());
  std::uniform_int_distribution<int> rand(1, 26);
  rep(i,365) {
    std::cout << rand(mt) << std::endl;
  }



  return 0;
}



Measured memory_bytes: 3708
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e2+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = 3.14159265358979323846;

void solve(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<Endl;
    }
    else
        cout<<"No"<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3640
n,m,x=map(int,input().split())
lis=[tuple(map(int,input().split()))for _ in range(n)]
ans = 2**60
for i in range(2**n):
    tmp = []
    vals=[0]*m
    for j in range(n):
        if i>>j&1:
            tmp.append(lis[j])
    cost=0
    flag=0
    for t in tmp:
        cost += t[0]
        for k in range(m):
            vals[k]+=t[k+1]
    for k in range(m):
        if vals[k]<x:
            flag=1
            break
    if flag:continue
    else:
        ans = min(ans,cost)
if ans == 2**60:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9232
a, b = map(int, input().split())

#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)
print(lcm(a,b))

Measured memory_bytes: 2940
n = gets.to_i
a = gets.split.map(&:to_i)
len = a.max.to_s(2).length

ans = 0
len.times do |l|
  n_1 = a.count { |x| x[l] == 1 }
  ans += (n - n_1) * n_1 * (2 ** l)
end
puts ans % 1000000007


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

const int kInf = 2'000'000'000;
int main() {
    int n; scanf("%d", &n);
    vector<pair<int, int>> s;
    for (int i = 0; i < n; ++i) {
        int x, l; scanf("%d%d", &x, &l);
        s.emplace_back(x - l, x + l);
    }
    sort(s.begin(), s.end(), [](auto a, auto b) { return a.second < b.second; });
    int r = -kInf, ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i].first < r) continue;
        ans++;
        r = s[i].second;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1400
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, K;
    cin >> N >> K;
    ll INF = 1LL << 60;

    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    ll t = INF;
    ll b = -INF;

    while(t - b > 1) {
        ll m = (t + b) / 2;
        ll c = 0;
        REP(i, A.size()) {
            if (A[i] * A[i] <= m) --c;
            if (A[i] < 0) {
                ll mn = (m / A[i]) - 1;
                while(mn * A[i] > m) ++mn;
                int pos = lower_bound(A.begin(), A.end(), mn) - A.begin();
                c += N - pos;
            } else if(A[i] > 0) {
                ll mx = (m / A[i]) + 1;
                while(mx * A[i] > m) --mx;
                int pos = upper_bound(A.begin(), A.end(), mx) - A.begin();
                c += pos;
            } else {
                if (m >= 0) {
                    c += N;
                }
            }
        }


        c /= 2;
        if (c >= K) {
            t = m;
        } else {
            b = m;
        }
    }

    cout << t << endl;




    
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

signed main() {
  int a = in(), b = in(), c = in(), d = in();

  if (a > c) {
    swap(a, c);
    swap(b, d);
  }

  cout << max(0, min(b - c, d - c)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int X[N];
    for(int i=0;i<N;i++){
        cin>>X[i];
    }
    int Y[N];
    for(int i=0;i<N;i++){
        cin>>Y[i];
    }
    int sum=0;
    for(int i=0;i<N;i++){
        if(X[i]-Y[i]>0){
            sum+=X[i]-Y[i];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	char a, b, ans;
	cin >> a >> b;
	if (a == 'H') {
		if (b == 'H') {
			ans = 'H';
		}
		else {
			ans = 'D';
		}
	}
	else {
		if (b == 'H') {
			ans = 'D';
		}
		else {
			ans = 'H';
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int dp[(int)3e5][16];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vi a(n);
    FOR(i, n)cin >> a[i];
    for(int i = n-2; i >=0; i--){
       int cur = a[i];
       int nex = a[i+1];
       int times = 0;
       FOR(j, 16){
           while(nex < cur){
               nex *= 4;
               times++;
           }
           dp[i][j] = dp[i+1][min(times, 15LL)] + 2*times + (n - i - 2)*max(0LL,times - 15LL)*2; 
           cur *= 4;
       } 
    }
    int ans = dp[0][0];
    vi dp2(16), prv(16);
    FOR1(i, n - 1){
        ans = min(ans, prv[0] + (i) + dp[i][0]); 
        
        int nex = a[i-1];
        int cur = a[i];
        int times = 0;
        FOR(j, 16){
           while(nex < cur){
             nex *= 4;
             times++;
           } 
           dp2[j] = prv[min(times, 15LL)] + 2*times + (i - 1)*max(0LL, times - 15LL)*2;
           cur *= 4;
        }
        swap(dp2, prv);
    }
    ans = min(ans, prv[0] + n);
    cout << ans;

}




Measured memory_bytes: 28416
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n, m;

int main(){

  n = in();
  m = in();

  ll ans = min( n , m/2 );
  m -= ans * 2;
  ans += m / 4;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
    int n,ac(0),wa(0),tle(0),re(0);
    cin>>n;
    string c[n];
    for(int i=0;i<n;i++) {
        cin >> c[i];
        if(c[i]=="AC")
            ac++;
        else if(c[i]=="WA")
            wa++;
        else if(c[i]=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re<<"\n";
    return 0;
}


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

using namespace std;

int main()
{
    int n,m,a[100000][2],x=1,y;
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d",&a[i][0],&a[i][1]);
        x=max(a[i][0],x);
    }
    y=a[0][1];
    for(int i=0;i<m;i++)
    {
        y=min(a[i][1],y);
    }
    if(y<x)
        printf("0");
    else
    printf("%d",y-x+1);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  double R; 
  cin >> R;

  cout << 2*R*PI << "\n";

  return 0;
}


Measured memory_bytes: 3764
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)1e5 + 9;
vector<int> T[N];

int n;
int pi[N];
int dd[N];
int subt[N];

void dfs(int u, int par){
    pi[u] = par;
    subt[u] = 1;
    for(auto x : T[u]){
        if(x == par)
            continue;
        dd[x] = dd[u] + 1;
        dfs(x, u);
        subt[u] += subt[x];
    }
}

int main(){
    fastIO;
    cin >> n;
    int u, v;
    for(int i = 1; i < n; i ++ ){
        cin >> u >> v;
        T[u].push_back(v);
        T[v].push_back(u);
    }
    dfs(1,-1);
    int climb = (dd[n]-1)/2;
    int k = n;
    for(int j = 0 ; j < climb; j ++ ){
        k = pi[k];
    }
    int v1 = subt[k];
    int v2 = n - v1;
    if(v1 < v2){
        cout << "Fennec\n";
    }
    else{
        cout << "Snuke\n";
    }
    return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>
#include <chrono>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793

/*vector<ll> c;
vector<vector<ll>> s;
vector<ll>last;
vector<ll>t;
vector<bool>did;*/


ll Score(ll d, vector<vector<ll>> &s, vector<ll> &c, vector<ll> &last, vector<ll> &t, vector<bool> &did) {
    ll S = 0;
    ll C;
    
        S += s.at(d).at(t.at(d));
        did.at(t.at(d)) = 1;
        
        rep(cnt, 0, 26) {
            last.at(cnt)++;
        }
        last.at(t.at(d)) = 0;
        rep(cnt, 0, 26) {
                S -= c.at(cnt) * last.at(cnt);
        }
    
    return S;
}



int main() {
    ll d;
    cin >> d;
    vector<ll> c(26);
    vector2(ll, s, d, 26);
    rep(cnt, 0, 26) {
        cin >> c.at(cnt);
    }
    rep(i,0,d){
        rep(cnt, 0, 26) {
            cin >> s.at(i).at(cnt);
        }
    }
    vector<ll> last(26,0);
    vector<ll> t(d,0);
    vector<bool> did(26);
    /*rep(cnt, 0, d) {
        cin >> t.at(cnt);
        t.at(cnt)--;
    }*/
    ll S = 0;
    srand(time(NULL));
    rep(cnt, 0, d) {

        t.at(cnt) = rand()%26 +1 ;

    }

    rep(cnt, 0, d) {
        cout << t.at(cnt) << endl;
    }

    /*rep(cnt, 0, d) {
        S += Score(cnt, s, c, last, t, did);
        cout << S << endl;
    }*/
    return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W, K;
string S[330];
bool ichigo[330][330];
int ans[330][330];
signed main() {
    cin >> H >> W >> K;
    int max_x = 0;
    int cnt = 0;
    rep(i, H) {
        cin >> S[i];
        rep(j, W) {
            if (S[i][j] == '#') {
                ichigo[i][j] = true;
                chmax(max_x, j);
                cnt++;
                ans[i][j] = cnt;
            }
        }
    }
    rep(i, H) {
        for (int j = 1; j < W; j++) { if (ans[i][j] == 0) { ans[i][j] = ans[i][j - 1]; }}
        for (int j = W - 2; j >= 0; j--) { if (ans[i][j] == 0) { ans[i][j] = ans[i][j + 1]; }}
    }
    rep(j, W) {
        for (int i = 1; i < H; i++) { if (ans[i][j] == 0) { ans[i][j] = ans[i - 1][j]; }}
        for (int i = H - 2; i >= 0; i--) { if (ans[i][j] == 0) { ans[i][j] = ans[i + 1][j]; }}
    }
    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 1;
		for(int i = 1;i <= 3; i++)ans *= n; 
		System.out.println(ans);
		sc.close();
	}
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer s;
  s = nil->next;
  while((s->key != key) && (s != nil)){
    s = s->next;
   }
  return s;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0 )  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil)return;
  deleteNode(t);
}

void delete(int key){
  NodePointer u = listSearch(key);
  if(u != NULL){
   if(u == nil) return;
    deleteNode(u);
    } 
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next; 
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;


}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 34976
#include <stdio.h>
int main()
{
	char a[5], b[5];
	scanf("%s%s", a, b);
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) printf("YES\n");
	else printf("NO\n");
	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	long long n,k,ans=1,plone;
	cin>>n>>k;
	plone=k;
	while(n>plone-1){
		plone*=k;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fo(i,n) for(i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
vector<int>g[100005];

int main()
{
	IOS
    int t,n,m,i,j,x,y;
     cin>>n>>i>>j;
     if(i*n<j)cout<<i*n;
  else cout<<j;
   
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

typedef double P_type; //座標(integer or real)
typedef double G_real; //実数の戻り値(float or double or long double)
typedef complex<P_type> P;
const G_real P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return abs(a.real() - b.real()) < P_eps ? a.imag() + P_eps < b.imag() : a.real() + P_eps < b.real();
  }
};

P rotate(P p, double theta){
  return p * P(cos(theta), sin(theta));
}

//内積
P_type dot(P a, P b) {
  return (a * conj(b)).real();
}

//外積
P_type cross(P a, P b) {
  return (conj(a) * b).imag();
}

//反時計回り
int ccw(P a, P b, P c){
  if(cross(b-a, c-a) > P_eps) return 1; //COUNTER_CLOCKWISE(center:a)
  if(cross(b-a, c-a) < -P_eps) return -1; //CLOCKWISE(center:a)
  if(dot(b-a, c-a) < -P_eps) return -2; //c -> a -> b
  if(dot(a-b, c-b) < -P_eps) return 2; //a -> b -> c
  return 0; //a -> c -> b
}


int main(){
  int N, x[100], y[100];
  pair<P,int> p[200];

  cin >> N;

  for (int i=0; i<N; i++) {
    cin >> x[i] >> y[i];
    p[i] = {arg(P(x[i], y[i])), i};
  }

  sort(p, p+N);

  for (int i=0; i<N; i++) {
    p[i+N] = p[i];
    p[i+N].first += M_PI * 2;
  }

  double ans = 0;

  int r = 0;
  for (int i=0; i<N; i++) {
    while(abs(p[i].first - p[r].first) < M_PI + P_eps) {
      r++;
    }

    ll sumx = 0, sumy = 0;

    for (int j=i; j<r; j++) {
      sumx += x[p[j].second];
      sumy += y[p[j].second];
      ans = max(ans, sqrt(sumx * sumx + sumy * sumy));
    }
  }

  printf("%.15lf\n", ans);

  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 00:28:02 2020

@author: Aruto Hosaka
"""


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

mod = 10**9+7
N,K = map(int, input().split())

ans1 = N+1
ans1 *= N+K+1
ans1 %= mod
ans1 *= N+2-K
ans1 %= mod
ans1 *= modinv(2)
ans1 %= mod

ans2 = N+1
ans2 *= N+2
ans2 %= mod
ans2 *= 2*N+3
ans2 %= mod
ans2 *= modinv(6)
ans2 %= mod

ans3 = K-1
ans3 *= K
ans3 %= mod
ans3 *= 2*K-1
ans3 %= mod
ans3 *= modinv(6)
ans3 %= mod

ans4 = N+2-K

ans = ans1 - ans2 + ans3 + ans4
ans %= mod
print(ans)

Measured memory_bytes: 9196
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int m,n,con[5005];
LL dp[5005][5005];
LL save[5005][5005];
int main(){
	fastio;
	cin>>n>>m;
	for(int i=1,j=1;i<=n-1;i++,j++)
	{
		con[i]=j;
	}
	for(int i=n-1,j=2;i>=1;i--,j++){
		con[i]=min(con[i],j);
	}
	dp[0][0]=1;
	save[0][0]=1;
	rb(j,0,n-1){
		rb(i,1,n-1){
			dp[i][j]=save[i-1][j%con[i]];
			if(i!=n-1){
				save[i][j%con[i+1]]+=dp[i][j];
				save[i][j%con[i+1]]%=m;
			}
		}
	}
	LL res=0;
	rb(i,0,n-1){
		res+=dp[n-1][i]*(n-i);
		res%=m;	
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 389632
while true do
   string = gets.chomp
   break if string == "-"
   count = gets.chomp.to_i
   i = 0
   while true do
      break if i == count
      shuffle_num = gets.chomp.to_i
      partial = string.slice!(0, shuffle_num)
      string = string + partial
      i += 1
   end
   puts string
end

Measured memory_bytes: 8692
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;

}
int main(){
    int n;cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    ll cnt=0,u=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]) cnt+=(a[i]-b[i]);
        else if(a[i]<b[i]) u+=(b[i]-a[i])/2;
    }
    if(u>=cnt) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef long long lint;

vector<char> stk;
char str[200005];

int main(){
	cin >> str;
	for(int i=0; str[i]; i++){
		if(!stk.empty() && stk.back() == 'S' && str[i] == 'T'){
			stk.pop_back();
			continue;
		}
		stk.push_back(str[i]);
	}
	cout << stk.size() << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
const int MAX = 2147483647;
int min(int a, int b) {
	return a < b ? a : b;
}
int getSegTreeSize(int len) {
	if (len == 0)
		return 0;
	int ret, cnt = 0, memo = 1;
	while (memo < len) {
		memo *= 2;
		cnt++;
	}
	ret = 1 << (cnt + 1);
	return ret;
}
class RAQ {
private:
	int size, length;
	std::vector<int> node;
	RAQ() {}
	int find(int return_index, int index, int left, int right) {
		if (index == size + return_index - 1)
			return node[index];
		if ((left + right) / 2 < return_index)
			return find(return_index, index * 2 + 1, (left + right) / 2 + 1, right) + node[index];
		return find(return_index, index * 2, left, (left + right) / 2) + node[index];
	}
	void update(int left, int right, int element, int index, int i_left, int i_right) {
		if (left <= i_left && i_right <= right) {
			node[index] += element;
			return;
		}
		int middle = (i_left + i_right) / 2;
		if (middle >= left)
			update(left, right, element, index * 2, i_left, middle);
		if (middle < right)
			update(left, right, element, index * 2 + 1, middle + 1, i_right);
	}

public:
	RAQ(int size) {
		this->size = getSegTreeSize(size) / 2;
		this->length = getSegTreeSize(size);
		node.resize(this->length);
		fill(node.begin(), node.end(), 0);
	}
	void update(int left, int right, int element) {
		update(left, right, element, 1, 1, size);
	}
	int find(int index) {
		return find(index, 1, 1, size);
	}
};
int main() {
	int n, q;
	std::cin >> n >> q;
	RAQ segTree(n);
	for (int i = 0; i < q; i++) {
		int com;
		std::cin >> com;
		if (com == 0) {
			int l, r, e;
			std::cin >> l >> r >> e;
			segTree.update(l, r, e);
		}
		else {
			int index;
			std::cin >> index;
			std::cout << segTree.find(index) << std::endl;
		}
	}
}



Measured memory_bytes: 3888
#include <iostream>
#include <algorithm>
#include <string>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  string s, t; cin >> s >> t;
  sort(all(s));
  sort(all(t), greater<char>());

  cout << (s < t ? "Yes" : "No") << '\n';
  return 0;
}


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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
struct Edge{ int to, cost; };
typedef vector<Edge> Node;
typedef vector<Node> Graph;

typedef tuple<int, vector<int>> State;
typedef pair<int, State> Key;

int main(){
    iostream_init();
    int n, m, k, p;
    cin >> n >> m >> k >> p;
    p--;
    Graph G(n);
    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    vector<int> S(k), T(k);
    REP(i, k) cin >> S[i] >> T[i];
    REP(i, k) S[i]--;
    REP(i, k) T[i]--;

    priority_queue<Key, vector<Key>, greater<Key>> que;
    map<State, int> memo;

    State init = make_tuple(p, vector<int>(k, 0));
    memo[init] = 0;
    que.push(make_pair(0, init));

    int ans = -1;
    while(!que.empty()) {
        int d; State state;
        tie(d, state) = que.top(); que.pop();
        int u; vector<int> b;
        tie(u, b) = state;

        if(b == vector<int>(k, 2)) {
            ans = d;
            break;
        }

        for(Edge edge : G[u]) {
            int nu = edge.to;
            int nd = d + edge.cost;
            vector<int> nb = b;
            REP(i, k) if(nb[i] == 0 && S[i] == nu) nb[i]++;
            REP(i, k) if(nb[i] == 1 && T[i] == nu) nb[i]++;
            State nstate = make_tuple(nu, nb);
            if(memo.count(nstate) && memo[nstate] <= nd) continue;
            memo[nstate] = nd;
            que.push(make_pair(nd, nstate));
        }
    }
    cout << (ans == -1 ? "Cannot deliver" : to_string(ans)) << endl;
    return 0;
}

Measured memory_bytes: 82580
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main()
{
	dhoom;
	ll n;
	cin >> n;
	cout << lcm(2 , n) << endl;
	return 0;
} 



Measured memory_bytes: 256
/*
[agc017] D - Game on Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 100000;

int N;
vector<int> g[MAX_N];

int dfs(int v, int par = -1) {
    int grundy = 0;
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        grundy ^= dfs(to, v) + 1;
    }
    return grundy;
}

bool solve() { return dfs(0); }

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        g[x - 1].push_back(y - 1);
        g[y - 1].push_back(x - 1);
    }

    cout << (solve() ? "Alice" : "Bob") << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
map<int,int> m;
int mypow(int a,int b,int c){
	if(b==0)return 1;
	else if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n,a,ans=1;
	cin>>n;
	f(i,n){
		cin>>a;
		if(i==0&&a){
			puts("0");
			return 0;
		}
 		if(i)m[a]++;
	}
	int z=0,zz=1;
	for(P p:m){
		if(p.F-z!=1){
			puts("0");
			return 0;
		}
		ans*=mypow(zz,p.S,998244353);
		ans%=998244353;
		z++;
		zz=p.S;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define ll long long

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int num = 0;
    int j = 1;
    for (int i = 1; i <= n && j <= n; i++, j++) {
        if (i != v[j]) {
            num++;
            i--;
        }
    }
    cout << ((num == n) ? -1 : num) << "\n";
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define fre(i,t,n)  for(int i =(t);i<=(n);++i)
#define fer(i,n,t)  for(int i =(n);i>=(t);--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
void smain();
int main(){
    ios::sync_with_stdio(false);
    smain();
    return 0;
}
map<ll,ll> cnt;
const int maxn=2e5+100;
ll A[maxn];
void smain(){
    int n;
    cin>>n;
    fre(i,1,n)  cin>>A[i];
    ll ans=0;
    ll tot=0;
    cnt[0]=1;
    fre(i,1,n)
    {
        tot+=A[i];
        if(cnt.count(tot)!=0)  ans+=cnt[tot];
        else cnt[tot]=0;
        cnt[tot]++;
    }
    cout<<ans<<endl;
}


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

void dfs(vector<vector<int>>& G, int u, vector<int>& dist) {
  for (auto v : G[u]) {
    if (dist[v] != -1) continue;
    dist[v] = dist[u] + 1;
    dfs(G, v, dist);
  }
}

int main(void) {
  ios::sync_with_stdio(false);
  int N, u, v;
  cin >> N >> u >> v;
  --u, --v;

  vector<vector<int>> G(N);
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<int> distT(N, -1);
  distT[u] = 0;
  dfs(G, u, distT);

  vector<int> distA(N, -1);
  distA[v] = 0;
  dfs(G, v, distA);

  int answer = 0;
  rep(i, N) {
    if (distT[i] < distA[i]) {
      answer = max(answer, distA[i] - 1);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 13224