akhauriyash/Code-Regression huggingface dataset:
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

struct UnionFind{
  vector<int> parents;
  UnionFind(int n){
    parents.assign(n, -1);
  }

  int root(int x){
    if(parents[x] < 0) return x;
    else return parents[x] = root(parents[x]);
  }

  int size(int x){
    return -parents[root(x)];
  }

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

  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(size(x) < size(y)) swap(x, y);
    parents[x] += parents[y];
    parents[y] = x;
    return true;
  }
};

int A[100000];
int B[100000];
ll diff;
ll ans[100000];

int main(){
  ll N, M;
  cin >> N >> M;
  rep(i, M){
    cin >> A[i];
    cin >> B[i];
    A[i]--;
    B[i]--;
  }

  UnionFind uni(N);

  rrep(i, M){
    if(i == M - 1){
      ans[i] = (ll)N * (N - 1) / 2;
    }else{
      ans[i] = ans[i + 1] - diff;
    }
    int a = A[i];
    int b = B[i];
    if(uni.same(a, b)){
      diff = 0;
    }else{
      int sizeA = uni.size(a);
      int sizeB = uni.size(b);
      uni.unite(a, b);
      diff = (long long)sizeA * sizeB;
    }
  }
  rep(i, M){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
import sys
import os
import itertools
from math import *

pos = []
for i in range(5):
  pos.append(int(input()))
  
dist = int(input())

for i in list(itertools.product(range(5), range(5))):
  if abs(pos[i[0]] - pos[i[1]]) > dist:
    print(':(')
    exit()

print('Yay!')

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


int K,S;

int main(){
	cin >> K >> S;
	int k;
	int ans=0;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
			k = S - i - j;
			if(k <=K && k>=0){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int N; cin >> N;
    int oddnum = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a % 2 == 1) ++oddnum;
    }
    if (oddnum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






long long power(long long a, unsigned long long b, long long m){
    long long ret(1);
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
        if(ret < 0) ret += m;
        if(a < 0) a += m;
    }
    return ret;
}


int main(){
    long long m(998244353);
    int A, B, C, D; std::cin >> A >> B >> C >> D;
    int c(C-A), d(D-B);
    std::vector<std::vector<long long>> dp(c+1, std::vector<long long>(d+1, 0));
    dp[0][0] = 1;
    for(int i(1); i <= c; ++i) dp[i][0] = power(B, i, m);
    for(int j(1); j <= d; ++j) dp[0][j] = power(A, j, m);
    for(int i(1); i <= c; ++i){
        for(int j(1); j <= d; ++j){
            dp[i][j] = ((dp[i-1][j]*(B+j) % m) + (dp[i][j-1]*(A+i) % m)) % m;
            dp[i][j] -= (A+i-1)*(B+j-1) % m * dp[i-1][j-1] % m;
            if(dp[i][j] < 0) dp[i][j] += m;
        }
    }
    std::cout << dp[c][d] << std::endl;
    return 0;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

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

    int n;
    string str;
    cin >> str;
    n = (int)str.size();
    for (int i = 0; i < n; i++){
        vi letters(26, 0);

        for (int j = 0; j < n-i; j++){
            vi used(26, 0);
            for (int k = j; k <= j+i; k++){
                int c = str[k] - 'a';
                if (used[c] == 0){
                    letters[c]++;
                    used[c] = 1;
                }
            }
        }
        int Ma = *max_element(letters.begin(), letters.end());
        if (Ma == n-i) {
            cout << i << endl;
            return 0;
        }
    }
}


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

const int MAX = 210000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int n, a;
    cin >> n;
    map<int, int> mp;
    int left = -1, right = -1;
    for(int i = 0; i <= n; i++){
        cin >> a;
        if(mp.count(a)) left = mp[a], right = i;
        else mp[a] = i;
    }
    for(int k = 1; k <= n + 1; k++){
        ll t1 = COM(n + 1, k);
        ll t2 = COM(left + n - right, k - 1);
        cout << (t1 - t2 + MOD) % MOD << endl;;
    }
    return 0;
}

Measured memory_bytes: 10880
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int M = s[1];
            List<int> Lls = new List<int>();
            List<int> Rls = new List<int>();
            for (int i = 0; i < M; i++)
            {
                int[] input = ReadLine().Split(' ').Select(int.Parse).ToArray();
                Lls.Add(input[0]);
                Rls.Add(input[1]);
            }
            
            WriteLine(
                Rls.Min() - Lls.Max() +1 >= 0 ? Rls.Min() - Lls.Max() + 1 : 0
                );
        }
    }
}


Measured memory_bytes: 19272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 100005
#define mod 1000000007

int n;
int a[maxn];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int k = upper_bound(a, a + n, a[j] + a[i] - 1) - a;
            ans += k - 1 - j;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    if (N == 10 || N == 100 || N == 1000 || N == 10000 || N == 100000) cout << 10 << endl;
    else cout << N%10 + N/10 % 10 + N/100%10 + N/1000%10 + N/10000%10 << endl;
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k, s; cin >> n >> k >> s;
    if (s == 1e9) {
        for (int i = 0; i < n; i++) {
            if (i) cout << " ";
            cout << (i < k ? s : 1);
        }
        cout << "\n";
    } else {
        for (int i = 0; i < n; i++) {
            if (i) cout << " ";
            cout << (i < k ? s : (int) 1e9);
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
    int n;
    cin >> n;
    int now = INF;
    int ans = 0;
    REP(i,n){
        int p1;
        cin >> p1;
        if(now > p1){
            ans ++;
            now = p1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

  int n; cin >> n;
  ll prev; cin >> prev;
  bool ok = 1;

  if(prev > 0) {
    ok = 0;
  }

  ll ans = 0;
  rep(i, n - 1) {
    ll tmp; cin >> tmp;
    if(!ok) continue;

    if(tmp == 0) {
      prev = tmp;
      continue;
    }

    ll diff = tmp - prev;
    if(diff > 1) {
      ok = 0;
      continue;
    }

    if(diff == 1) {
      ++ans;
    } else {
      ans += tmp;
    }

    prev = tmp;
  }

  if(ok) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, x, a, b);
	cout << ((abs(a - x) > abs(b - x)) ? 'B' : 'A') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	cout << "ABC" << setfill('0') << right << setw(3) << n << endl;

	return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush

def resolve():
  N, M = map(int, input().split(" "))
  A = [(-1)*int(x) for x in input().split(" ")]
  heapify(A)

  for _ in range(M):
    max_A = (-1)*heappop(A)
    heappush(A, (-1)*(max_A//2))
  
  print((-1)*sum(A))

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 85640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int H, W, K; cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    // cout << "1 " << endl;
    // 横方向に切れるのが1 <= H <= 10より、最大で2**9
    int ans = H-1 + W-1 + 1;
    rep(i, 1 << (H-1)) {
        bool bf = false;
        vector<int> sp;
        rep(j, H-1) {
            if (i & (1 << j)) {
                // j桁目が1なら
                sp.emplace_back(j);
            }
        }
        vector<int> asum(sp.size()+1, 0);
        // cout << "4" << endl;
        int tans = sp.size();
        // cout << "tans1: " << tans << endl;
        rep(j, W) {
            vector<int> tsum(asum.size(), 0);
            int sum_row = 0;
            rep(k, H) {
                if (S[k][j] == '1') {
                    tsum[sum_row] += 1;
                }
                if (sum_row < sp.size() && sp[sum_row] == k) {
                    sum_row += 1;
                }
            }
            rep(k, asum.size()) {
                if (tsum[k] > K) {
                    bf = true;
                    break;
                } else if (asum[k] + tsum[k] > K) {
                    tans += 1;
                    asum = tsum;
                    break;
                } else {
                    asum[k] += tsum[k];
                }
            }
        }
        if (!bf) {
            ans = min(tans, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


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

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n, k;
	cin>>n>>k;
	vll a(n);
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	for(int i = k; i < n; i++)
	{
		if(a[i] > a[i-k])
		{
			cout<<"Yes"<<endl;
		}
		else cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD{1000000007};
    // my fast in
    constexpr unsigned long buf_size = 5UL;
    char buffer[buf_size];
    fread(buffer, 1, buf_size, stdin);
    unsigned long tmp_buf = 0;
    const auto &read = [&tmp_buf, &buffer] {
        unsigned long ret;
        from_chars(begin(buffer) + tmp_buf, end(buffer), ret);
        return ret;
    };
    // fast in kokomade
    const unsigned long S{read()};
    vector<unsigned long> k(S + 1);
    k[0] = 1;
    for(unsigned long i{3}; i <= S; ++i){
        k[i] = k[i - 3] + k[i - 1];
        k[i] -= MOD * (k[i] >= MOD);
    }
    cout << k.back() << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,y,z;
  cin >> x >> y >> z;
  if(x % (y + z) < z) {
    cout << x / (y + z) - 1 << endl;
  }else {
    cout << x / (y + z) << endl;
  }
}

Measured memory_bytes: 256
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u

#include <stdio.h>

// バッファを経ずstdinから数値を得る
#define gc() getchar_unlocked()
//#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char tr['T'+1];
char f[33554432];

int trans()
{
	int c, k;

	k = 1; while ((c = gc()) >= ' ') k = (k<<2) | tr[c];
	return k;
}

int main()
{
	int n, k;

	tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
	n = in();
	while (n--) {
		if (gc() == 'i') {
			k = 6; while (k--) gc();
			f[trans()] = 1;
		} else {
			k = 4; while (k--) gc();
			puts(f[trans()]? "yes": "no");
		}
	}
	return 0;
}



Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;cin>>n;
  vector <int> cnt(n+1,0);
  for(int i=1;i<n;i++){
    cin>>t;
    cnt[t]++;
  }
  for(int i=1;i<=n;i++)cout<<cnt[i]<<endl;
}


Measured memory_bytes: 4048
class SegmentTree:
    __slots__ = ('n', 'op', 'tree')

    def __init__(self, seq, op=max):
        self.n = len(seq)
        self.op = op
        self.tree = [-1] * (2 * self.n)

        for i in range(self.n):
            self.tree[i+self.n] = seq[i]

        for i in reversed(range(1, self.n)):
            self.tree[i] = op(self.tree[2*i], self.tree[2*i+1])

    def modify(self, pos, val):
        assert pos < self.n
        pos += self.n
        self.tree[pos] = val
        while pos > 1:
            self.tree[pos//2] = self.op(self.tree[pos], self.tree[pos ^ 1])
            pos //= 2

    def query(self, L, R):
        assert L <= R and L >= 0 and R <= self.n
        res = 0
        L += self.n
        R += self.n
        while L < R:
            if L % 2 == 1:
                res = self.op(res, self.tree[L])
                L += 1
            if R % 2 == 1:
                R -= 1
                res = self.op(res, self.tree[R])

            L //= 2
            R //= 2

        return res


def solve(n, heights, beauty):
    dp = SegmentTree([0] * (n+1), op=max)

    for pos, b in zip(heights, beauty):
        best = dp.query(0, pos)
        dp.modify(pos, best + b)

    return dp.query(0, n+1)


def main():
    n = int(input())
    heights = [int(c) for c in input().split()]
    beauty = [int(c) for c in input().split()]
    ans = solve(n, heights, beauty)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 120956
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll solve(ll N, ll a, ll A, ll b, ll B, ll c, ll C){
    V dp(N + 1, 0);
    rep(i, N){
        if(i + a <= N)chmax(dp[i + a], dp[i] + A - a);
        if(i + b <= N)chmax(dp[i + b], dp[i] + B - b);
        if(i + c <= N)chmax(dp[i + c], dp[i] + C - c);
    }
    ll ret = 0;
    for(ll i = 0; i <= N; i++)chmax(ret, dp[i]);
    return N + ret;
}

int main(){

    ll N;
    cin >> N;
    ll a, b, c, A, B, C;
    cin >> a >> b >> c;
    cin >> A >> B >> C;
    N = solve(N, a, A, b, B, c, C);
    N = solve(N, A, a, B, b, C, c);
    cout << N << endl;
    
    return 0;
}

Measured memory_bytes: 195584
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
ll n, k;
vector<P> dt;
map<ll, ll> max_mp;
bool used[half_inf];
priority_queue<ll, vector<ll>, greater<>> others;

void solve() {
    sort(dt.begin(), dt.end(), greater<>());

    ll ans = 0;
    ll tmp = 0, tmp2 = 0;
    rep(i, k) {
        if (!used[dt[i].second] && dt[i].first == max_mp[dt[i].second]) {
            tmp++;
            used[dt[i].second] = true;
        } else {
            others.push(dt[i].first);
        }
        ans += dt[i].first;
        tmp2 += dt[i].first;
    }
    ans += tmp * tmp;
    vector<pair<ll, ll> > v(max_mp.begin(), max_mp.end());

    // sort from bigger.
    sort(v.begin(), v.end(),
         [](pair<ll, ll> a, pair<ll, ll> b) { return a.second > b.second; });

    each(m, v) {
        if (used[m.first]) continue;
        if (others.empty()) break;
        ll minus = others.top();
        others.pop();
        tmp++;

        tmp2 = tmp2 - minus + m.second;
        ans = max(tmp2 + tmp * tmp, ans);
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> k;
    dt.resize(n);
    rep(i, n) {
        ll t, d;
        cin >> t >> d;
        dt[i] = make_pair(d, t);
        max_mp[dt[i].second] = max(max_mp[dt[i].second], dt[i].first);
    }
    solve();
    return 0;
}

Measured memory_bytes: 9728
N = int(input())
S = input()
bet = list("abcdefghijklmnopqrstuvwxyz")
countlist = []
for i in range(len(bet)):
    if S.count(bet[i]) != 0:
        countlist.append(S.count(bet[i]))
result = 1

for j in range(len(countlist)):
    result *= countlist[j]+1
    result %= 10**9+7


print(result-1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
char s[1000];
int n,Ans;
int c[1001],b[1001];
void dfs(int x,int ans){
	if(x==n){
		int res=0,js=0;
		for(int i=1;i<=ans;i++){
			js=0;
			for(int j=c[i-1]+1;j<=c[i];j++)
				js=js*10+s[j]-'0';
			res+=js;
		}
		Ans+=res;
		return ;
	}
	for(int i=x+1;i<=n;i++)
		c[ans]=i,dfs(i,ans+1);
}
main(){
    //file("");
	scanf("%s",s+1);
	n=strlen(s+1);
	dfs(0,1);
	printf("%lld",Ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b  = map(int, input().split())
array = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]

result='No'
for arr in array:
  if  a in arr and b in arr:
    result='Yes'
print(result)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;
set<int> s;

int main()
{
    int cnt = 3;
    while(cnt--)
    {
        int t;
        cin >> t;
        s.insert(t);
    }
    int ans = s.size();
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        int n;
        float ave;
        float s;
        
        Scanner scanner = new Scanner(System.in);

        while(true){
            n = scanner.nextInt();
            if(n == 0) break;

            int[] score;
            score = new int[n];

        
            int i;
            ave = 0;
            for(i = 0; i < n; i++){
                score[i] = scanner.nextInt();
                ave = ave + score[i];
            }

            ave = ave / n;

            s = 0;
            for(i = 0; i < n; i++){
                s = s + (ave - score[i]) * (ave - score[i]);
            }

            s = s / n;
            s = (float)Math.sqrt(s);
            System.out.println(s);

            

        }


        scanner.close();
    }
}


Measured memory_bytes: 31324
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
s = 0
t = 0
for x in a:
    s += x
    s %= MOD
    t += x * x
    t %= MOD
ans = (s * s - t) * pow(2, MOD-2, MOD) % MOD
print(ans)

Measured memory_bytes: 105264
S = input()
N = len(S)
cnts = []
now = "<"
if S[0] == ">":
    cnts.append(0)
    now = ">"
cnt = 0
for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        cnts.append(cnt)
        cnt = 1
        now = ">" if now == "<" else "<"

if cnt > 0:
    cnts.append(cnt)

if len(cnts) % 2 != 0:
    cnts.append(0)

ans = 0
for i in range(0, len(cnts), 2):
    if cnts[i] < cnts[i+1]:
        ans += sum([x for x in range(cnts[i])])
        ans += sum([x for x in range(cnts[i+1] + 1)])
    else:
        ans += sum([x for x in range(cnts[i] + 1)])
        ans += sum([x for x in range(cnts[i + 1])])
print(ans)


Measured memory_bytes: 24092
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 300001;
const int M = 998244353;
int f[N] = { 1 };
int Pow(int b, int p) {
	if (!p)
		return 1;
	ll z = Pow(b, p / 2);
	if (p & 1)
		return z*z%M*b%M;
	return z*z%M;
}
ll nCk(int n, int k) {
	return f[n] * (ll)Pow(f[n - k], M - 2) % M*Pow(f[k], M - 2) % M;
}
int main()
{
	for (int i = 1; i < N; ++i)
		f[i] = (ll)i*f[i - 1] % M;
	int n, a, b;
	cin >> n >> a >> b;
	ll k;
	cin >> k;
	ll res = 0;
	for (ll i = 0; i <= n && i*a <= k; ++i) {
		if ((k - i*a) % b == 0) {
			ll j = (k - i*a) / b;
			if (j > n)
				continue;
			res = (res + nCk(n, i)*(ll)nCk(n, j)) % M;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

// struct item {
//     ll y; ll x; ll v;
// };

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k; cin >> h >> w >> k;
    // vector<item> p(k);
    // for (auto &e : p) cin >> e.y >> e.x >> e.v;
    vector<vector<ll>> a(h, vector<ll>(w));
    rep (i, k) {
        ll y, x, v; cin >> y >> x >> v;
        y--; x--;
        a[y][x] = v;
    }
    vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w, vector<ll>(4)));
    if (a[0][0] > 0) dp[0][0][1] = a[0][0];
    rep (i, h) {
        rep (j, w) {
            if (i > 0) {
                dp[i][j][0] = max({dp[i - 1][j][0], dp[i - 1][j][1], 
                                   dp[i - 1][j][2], dp[i - 1][j][3]});
                if (a[i][j] > 0) {
                    dp[i][j][1] = a[i][j] + max({dp[i - 1][j][0], dp[i - 1][j][1], 
                                                 dp[i - 1][j][2], dp[i - 1][j][3]});
                }
            }
            if (j > 0) {
                rep (k, 4) chmax(dp[i][j][k], dp[i][j - 1][k]);
                if (a[i][j] > 0) {
                    rep (k, 3) {
                        chmax(dp[i][j][k + 1], a[i][j] + dp[i][j - 1][k]);
                    }
                }
            }
        }
    }
    // rep (k, 4) {
    //     rep (i, h) {
    //         rep (j, w) {
    //             eprintf("%d ", dp[i][j][k]);
    //         }
    //         eprintf("\n");
    //     }
    //     eprintf("\n");
    // }
    ll ans = dp[h - 1][w - 1][0];
    rep (k, 4) chmax(ans, dp[h - 1][w - 1][k]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 705952
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int k,mini,maxi;
  cin >> k >> mini >> maxi;
  int l = (maxi/k)*k;
  if( l >= mini){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
  
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int t[200005];
int seg[600005][2];//min,max
int seg_N;

void seg_set(int a,int p){
	if(seg[p][0]<=a && a<=seg[p][1])return;
	if(seg[p][0]>a)seg[p][0]=a;
	if(a>seg[p][1])seg[p][1]=a;
	if(p==0)return;
	seg_set(a,(p-1)/2);
}

void seg_init(int n){
	int i;
	for(i=0;n>(1<<i);i++);
	seg_N=(1<<i)-1;

	for(i=0;i<seg_N+n;i++){
		seg[i][0]=INF;
	}
	for(i=0;i<n;i++){
		seg_set(t[i],seg_N+i);
	}
}

P seg_search(int a,int b,int r=0,int l=seg_N+1,int p=0){
	P pa,pb;
	if(a>=b)return make_pair(INF,0);
	if(a<=r && l<=b)return make_pair(seg[p][0],seg[p][1]);
	int m=(r+l)/2;
	if(b<=m)return seg_search(a,b,r,m,2*p+1);
	if(m<=a)return seg_search(a,b,m,l,2*p+2);
	pa=seg_search(a,m,r,m,2*p+1),pb=seg_search(m,b,m,l,2*p+2);
	pa.first=min(pa.first,pb.first),pa.second=max(pa.second,pb.second);
	return pa;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	seg_init(n);
	int s=n-m+1;
	for(i=0;i<n-m;i++){
		P pa;
		pa=seg_search(i,i+m);
		if(t[i]==pa.first && t[i+m]>pa.second)s--;
	}
	a=0,b=0;
	for(i=0;i<n-1;i++){
		if(t[i]<t[i+1])b++;
		else{
			if(b>=m-1)a++;
			b=0;
		}
	}
	if(b>=m-1)a++;
	if(a>1)s-=a-1;
	cout<<s<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  ll n,k; cin >> n >> k;
  ll a = n/k;
  ll ans = a*a*a;
  if(k%2 == 0){
    k /= 2;
    a = n/k - a;
    ans += a*a*a;
  }
  std::cout << ans << '\n';
}


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

int main(){
  int N,K;cin>>N>>K;
  bool A[N];
  for(int i=0;i<N;i++){
    A[i]=false;
  }
  int d,a;
  for(int i=0;i<K;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>a;
      A[--a]=true;
    }
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(A[i]==false) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3196
#include <iostream>

using namespace std;

int main(){
	int N, M;
	int *a = NULL;
	int *b = NULL;
	int toshi_num;

	cin >> N >> M;

	a = new int[M];
	b = new int[M];


	for(int i = 0; i < M; i++){
		cin >> a[i] >> b[i];
	}

	for(int i = 0; i < N; i++){
		toshi_num = 0;
		for(int j = 0; j < M; j++){
		if(i + 1 == a[j]){
			toshi_num++;
		}
		if(i + 1 == b[j]){
			toshi_num++;
		}
	}
		cout << toshi_num << endl;
	}


	delete[] a;
	delete[] b;
	return 0;

}

Measured memory_bytes: 256
H,W=map(int, raw_input().split())
A=[ raw_input() for i in range(H) ]

dp=[ [ 0 for j in range(W) ]  for i in range(H) ]
dp[0][0]=1
mod=10**9+7

for  i in range(H):
	for j in range(W):
		if A[i][j]==".":
			if 0<=i-1<H:   dp[i][j]+=dp[i-1][j]
			if 0<=j-1<W:   dp[i][j]+=dp[i][j-1]
	dp[i][j]%=mod

print dp[-1][-1]%mod

Measured memory_bytes: 218524
//
// Created by Myabu on 2020/01/26.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


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

    string ans = "";

    for (int i = 0; i < s.length(); ++i) {
        if(i%2==0){
            ans += s[i];
        }
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 576
#include <stdio.h>

int temp[10000000];
void merge(int *,int,int);
int count=0;

int main(){
  
  int i,a,n,m,cont1=0,cont2=0;
  int x[500000],y[50000];
  
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&x[i]);
  }     

  
  merge(x, 0, a - 1);
  
  for (i = 0; i < a; i++){
    if(i!=a-1){ 
      printf("%d ", x[i]);
    }
    else printf("%d",x[i]);
  }
  printf("\n%d\n",count);
  
}


void merge(int x[ ], int left, int right)
{
  int mid, i, j, k;
  
  if (left >= right){
    return;
  }
  
  
  mid = (left + right) / 2;       
  merge(x, left, mid);
  merge(x, mid + 1, right);   
  
  
  for (i = left; i <= mid; i++)
    temp[i] = x[i];
  
  
  
  for (i = mid + 1, j = right; i <= right; i++, j--){
    
    temp[i] = x[j];
    
  }  
  i = left;        
  j = right;       
  
  for (k = left; k <= right; k++)   
    if (temp[i] <= temp[j]){
      count++;
      x[k] = temp[i++];
      
    }
    else{
      count++;
      x[k] = temp[j--];      
    }
}



Measured memory_bytes: 5600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int cal(int a){
	int ret=0;
	while(a>0){
		ret+=a%10;a/=10;
	}
	return ret;
}
int main()
{
	int n,out=1001001001;
	cin>>n;
	REP(i,1,n){
		out=min(out,cal(i)+cal(n-i));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b,c = LI()
    t = [a,b,c]
    q = [S() for _ in range(n)] + ["ABC"]
    r = []
    for qi in range(n):
        s = q[qi]
        if s == "AB":
            i = 0
            j = 1
        elif s == "AC":
            i = 0
            j = 2
        else:
            i = 1
            j = 2

        if t[i] < t[j]:
            r.append(i)
            t[i] += 1
            t[j] -= 1
        elif t[i] > t[j]:
            r.append(j)
            t[i] -= 1
            t[j] += 1
        else:
            if t[i] < 1:
                return "No"
            if chr(ord("A") + i) in q[qi+1]:
                r.append(i)
                t[i] += 1
                t[j] -= 1
            else:
                r.append(j)
                t[i] -= 1
                t[j] += 1

    return JA(["Yes"] + list(map(lambda x: chr(ord("A") + x), r)), "\n")

print(main())





Measured memory_bytes: 20456
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
#define N 10000000 
#define lg 19
 
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main() 
{ 
 
/////////////////////////////////////
    
    fastio;////////////////////////////    
    
    lli n;
    cin>>n;

    pll p[n];

    loopl(i,0,n)
    {
        lli x;
        cin>>x;
        p[i] = {x,i+1};
    }

    sort(p,p+n);

    loopl(i,0,n)
    cout<<p[i].ss<<" ";
}   

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int S,W;
  cin >> S >> W;
  cout << (W >= S ? "unsafe" : "safe") << endl;

}


Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

int n,a,b,cnt=0;
int flag[M];
int dist1[M]={},distn[M]={};
vi g[M];

void __dist(int node,int y[]){
	flag[node]=true;
	for(auto x:g[node])
		if(!flag[x]){
			y[x]=(y[node]+1);
			__dist(x,y);
		}
}

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	print(z<<" "<<x<<" "<<y);
}

Measured memory_bytes: 6400
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
using namespace std;


int main(void){
        int i,n;
        string s;
        vector<string> v;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                cin >> s;
                v.push_back(s);
        }
        sort(v.begin(), v.end() );
        int c=1;
        for(i=1;i<n;i++){
                if(v[i] != v[i-1]){
                        c++;
                }
        }
        printf("%d\n",c);

        return 0;

}


Measured memory_bytes: 11676
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define endl '\n' 
#define fast() ios_base::sync_with_stdio(0) ; cin.tie(0) ; 
using namespace std ; 
int main(){
	  fast() ; 
	  int n , m ; 
	  cin>>n >> m ; 
	  vector<int> a(n  ,-1 ) ; 
	  int p = 0 ; 
	  for(int i = 0 ; i < m ; ++i){
		  int x , y ; 
		  cin>> x >> y ; 
		  x-- ; 
		  if(a[x] != -1){
			  if(a[x] != y){
				  p = 1 ; 
			  }
		  }
		  else {
		    a[x] = y ; 
		}
		}
		for(int i = 0 ; i < n ; ++i){
			if(i == 0 ){
				if(a[i] == 0 && n >= 2 ){
					p = 1 ; 
					break ;  
				}
				else if(a[i] == -1&& n >= 2){
					a[i] = 1 ; 
				}
			}
			else if(a[i] == -1)
			  a[i] = 0 ; 
		}
		if(m == 0&& n == 1){
			cout<<0<<endl;
		}
		else if(p == 1 )
		  cout<<-1<<endl;
		else 
		{  
			for(int i = 0 ; i < n ; ++i)
			        cout<<a[i] ; 
			
			}
	}
	
	
	




Measured memory_bytes: 256
// Date: 2020-05-30

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, 0, n-1) {
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    cin(i,a);
    intl cnt = 0;
    rep(i,n - 1){
        if(a[i] == i + 1){
            swap(a[i], a[i + 1]);
            cnt++;
        }
    }
    if(a[n - 1] == n){
        swap(a[n - 1],a[n - 2]);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024