akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>//printf("%.15f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字)
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


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

	Yes(KIBN(s) &&
		KIBN(s.substr(0, (s.size() - 1) / 2)) &&
		KIBN(s.substr((s.size() + 3) / 2 - 1)));

	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}
// power with modulo
ll powMod(ll b, ll e, const ll m = MOD)
{
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
// factrial with modulo
ll factMod(const ll n, const ll m = MOD)
{
    ll x = 1;
    for (ll i = 1; i <= n; ++i)
        x = (x * i) % m;
    return x;
}
class Combi
{
private:
    const int n_, mod_;
    vector<ll> fac_, finv_;

public:
    Combi(int n = 10000, int mod = MOD);
    ll count(int n, int k);
};
Combi::Combi(int n, int mod) : n_(n), mod_(mod)
{
    fac_.resize(n_);
    finv_.resize(n_);
    vector<ll> inv(n_);

    fac_[0] = fac_[1] = 1;
    finv_[0] = finv_[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < n_; 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 Combi::count(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_;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

// *****************************************************************************

void solve()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

// *****************************************************************************

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(0);

    solve();
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int n, m;
	cin >> n >> m;
	
	vi H(n);
	rep(i,n){
		cin >> H[i];
	}

	#define A first;
	#define B second;
	vector<bool> good(n,true);
	int a, b;
	rep(i,m){
		cin >> a >> b;
		a--;
		b--;
		if(H[a] < H[b]){
			good[a] = false;
		}
		else if(H[a] > H[b]){
			good[b] = false;
		}
		else{
			good[a] = false;
			good[b] = false;
		}
	}

	int ans = 0;
	rep(i,n){
		if(good[i]) ans++;
	}

	cout << ans << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3964
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int M = scan.nextInt();
			
			int[]P = new int[M];
			int[]Y = new int[M];
			int[]p = new int[M];
			int[]y = new int[M];
			
			Map<Integer,Map<Long,Integer>>D = new TreeMap<Integer,Map<Long,Integer>>();
			for(int i = 1;i<=N;i++) {
				D.put(i, new TreeMap<Long,Integer>());
			}
			
			for(int i = 0;i<M;i++) {
				P[i] = scan.nextInt();
				Y[i] = scan.nextInt();
				D.get(P[i]).put((long)Y[i], i+1);
			}
			
			
			
			for(Integer key:D.keySet()) {
				int count = 1;
				for(Long a:D.get(key).keySet()) {
					int s = D.get(key).get(a);
					p[s-1] = key;
					y[s-1] = count;
					count++;
				}
			}
			
			for(int i = 0;i<M;i++) {
				String pi = String.valueOf(p[i]);
				String yi = String.valueOf(y[i]);
				StringBuffer sb = new StringBuffer();
				for(int j =0;j<6-pi.length();j++)sb.append('0');
				sb.append(pi);
				for(int j =0;j<6-yi.length();j++)sb.append('0');
				sb.append(yi);
				
				System.out.println(sb.toString());
				
			}
			
			
			
			
			
			
		}
		
		
	}
		

}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const int mod = 1000000000 + 7;


class RMQ{
public:
    int n;
    vector<ll> dat;
    // 初期化
    void init(int n_){
        n=1;
        while(n<n_)n*=2;
        dat.resize(n * 2 - 1, LONG_LONG_MIN);
    }
    // k番目の値(0-indexed)をaに変更
    void update(int k,ll a){
        // 葉の節点
        k+=n-1;
        dat[k]=a;
        // のぼりながら更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[k*2+1],dat[k*2+2]);
        }
    }
    // [a,b)の最大値を求める
    // kは節点の番号、l,rはその節点が[l,r)に対応づいていることを表す
    // したがって、外からはquery(a,b,0,0,n)として呼ぶ
    ll _query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l)return LONG_LONG_MIN;
        else if(a<=l&&r<=b)return dat[k];
        ll vl=_query(a,b,k*2+1,l,(l+r)/2);
        ll vr=_query(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }
    ll query(int a,int b){
        return _query(a,b,0,0,n);	
    }
};


int N;
ll H[200010];
ll A[200010];
pll ha[200010];
RMQ rmq;
int main() {

    cin >> N;
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) ha[H[i] - 1] = pll(i, A[i]);
    rmq.init(N);
    // 短い順番に、データ構造を利用して値を更新する
    for(int i = 0; i < N; i++){
        ll max_v = rmq.query(0, ha[i].first);
        if(max_v == LONG_LONG_MIN){
            rmq.update(ha[i].first, ha[i].second);
        }
        else{
            rmq.update(ha[i].first, ha[i].second + max_v);
        }
    }
    ll ans = -1;
    for(int i = 0; i < N; i++)
        ans = max(ans, rmq.query(i, i + 1));
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	stack<int> st;
	int n;
	while(cin >> n) {
		if(!n) {
			cout << st.top() << endl;
			st.pop();
		} else {
			st.push(n);
		}
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0;i < n;i++){
        cin >> v.at(i);
    }
    vector<int> c(n);
    for (int i = 0;i<n;i++){
        cin >> c.at(i);
    }
    int sum = 0;
    for (int i=0;i<n;i++){
        if (v.at(i) - c.at(i) > 0){
            sum += v.at(i) - c.at(i);
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
fun main() {
  val N = readInt()
  val SN = (1..N).map { readString() }
  println("AC x " + SN.count { it == "AC" })
  println("WA x " + SN.count { it == "WA" })
  println("TLE x " + SN.count { it == "TLE" })
  println("RE x " + SN.count { it == "RE" })
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 61100
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val As = readInputLine().split(" ").map { it.toInt() }.sorted().toIntArray()

    for (i in 1 until N) {
        if (As[i] == As[i - 1]) {
            println("NO")
            return
        }
    }

    println("YES")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 81368
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B = MAP()

ans = -1
for i in range(1, 1250):
    if int(i * 0.08) == A and int(i*0.1) == B:
        ans = i
        break

print(ans)

Measured memory_bytes: 38728
/// @file
/// @version Time Limit Exceeded.
#include<bits/stdc++.h>
#define p(f,...) //printf(f,##__VA_ARGS__)
using namespace std;
int N,C,D[30][30],c[500][500];
void solve(){
  vector<vector<int>>sums(3,vector<int>(C));
  for(int mod=0;mod<3;++mod){
    for(int color=0;color<C;++color){
      int sum=0;
      for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
          if((i+j)%3!=mod)continue;
            sum+=D[c[i][j]][color];
        }
      }
      sums[mod][color]=sum;
    }
  }
  int n_min=0x3f3f3f3f;
  for(int c0=0;c0<C;++c0){
    for(int c1=0;c1<C;++c1){
      if(c1==c0)continue;
      for(int c2=0;c2<C;++c2){
        if(c2==c0||c2==c1)continue;
        p("color=%d,%d,%d\n",c0,c1,c2);
        const int sum=sums[0][c0]+sums[1][c1]+sums[2][c2];
        p("sum=%d\n",sum);
        n_min=min(n_min,sum);
      }
    }
  }
  printf("%d\n",n_min);
}
main(){
  cin>>N>>C;
  for(int X=0;X<C;++X){
    for(int Y=0;Y<C;++Y){
      cin>>D[X][Y];
    }
  }
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      cin>>c[i][j];
      --c[i][j];
    }
  }
  solve();
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define LL long long int
using namespace std;


int main()
{
    LL n,ans;
    scanf("%lld",&n);
    LL sq=sqrt(n)+0.5;
    for(LL i=sq;i>0;i--)
    {
        if(n%i==0)
        {
           ans=i+n/i-2;
           printf("%lld\n",ans);
           return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s,t; cin>>s>>t;
    int n=s.size(),m=t.size();
    vector<string> q;
    rep(i,n-m+1){
        rep(j,m){
            if(s[i+j]!='?' && s[i+j]!=t[j])
            break;
            if(j==m-1){
                string S=s;
                rep(k,m) S[i+k]=t[k];
                rep(k,n)if(S[k]=='?') S[k]='a';
                q.push_back(S);
            }
        }
    }
    if(q.size()==0) cout<<"UNRESTORABLE"<<endl;
    else{
        sort(al(q));
        cout<<q[0]<<endl;
    }
}


Measured memory_bytes: 256
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n, root = 0;
vector<int> g[100011];
int dp[100011];
void dfs(int v = 1, int p = -1){
	if((int)g[v].sz() > 2){
		root = v;
		return;
	}
	for(auto to : g[v]){
		if(to != p)
			dfs(to, v);
	}
}
void calc(int v, int p = -1){
	int sum = 0;
	for(auto to : g[v]){
		if(to == p)
			continue;
		calc(to, v);
		dp[v] += dp[to];
		if(dp[to] == 0)
			sum ++;
	}
	dp[v] += max(0, sum - 1);
}
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n;
	for(int i = 1; i < n; i ++){
		int x, y;
		cin >> x >> y;
		x ++;
		y ++;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs();
	int ans = inf;
	if((int)g[root].sz() <= 2){
		ans = 1;
		cout << ans;
		return 0;
	}
	calc(root);
	cout << dp[root];
	return 0;
}

Measured memory_bytes: 10880
import collections

mod = 998244353

n = int(input())
d = list(map(int, input().split()))
dc = collections.Counter(d).most_common()
dc = sorted(dc)
if d[0] == 0 and dc[0][1] == 1:
    count = 0
    ans = 1
    last = 1
    for i in dc:
        if i[0] == count:
            ans = ans * (last ** i[1]) % mod
            last = i[1]
            count += 1
        else:
            print(0)
            exit()
    print(ans % mod)
else:
    print(0)


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


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

    int N;
    cin >> N;
    string s;
    unordered_map<string, int> m;
    for (int i = 0; i < N; ++i) {
        cin >> s;
        ++m[s];
    }

    vector<pair<int, string>> v;
    for (auto it = m.begin(); it != m.end(); ++it) {
        v.push_back({it->second, it->first});
    }

    sort(v.begin(), v.end(), [](const auto& l, const auto& r){
            if (l.first == r.first) return l.second < r.second;
            return l.first > r.first;
            });

    cout << v[0].second << endl;
    for (int i = 1; i < v.size(); ++i) {
        if (v[i].first == v[i-1].first) cout << v[i].second << endl;
        else {
            break;
        }
    }

    return 0;
}





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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define x first
#define y second
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
const int mod=1e9+7;
const int N=1e5+10;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

string getBase(int x,int b){
    string ans;
    while(x){
        ans+=('0'+x%b);
        x/=b;
    }
    return ans;
}

string L,R;
int dp[10010][2][2][101],D;

int getAns(int level,int tlo,int thi,int rem){
    if(level>=L.size()){
        if(rem==0)return 1;
        return 0;
    }
    if(dp[level][tlo][thi][rem]==-1){
        int blo=0;
        int bhi=9;
        if(tlo){
            blo=L[level]-'0';
        }
        if(thi){
            bhi=R[level]-'0';
        }

        int ans=0;
        for(int i=blo;i<=bhi;i++){
            int ntlo=tlo;
            int nthi=thi;
            if(i>L[level]-'0'){
                ntlo=0;
            }
            if(i<R[level]-'0'){
                nthi=0;
            }

            ans+=getAns(level+1,ntlo,nthi,(rem+i)%D);
            ans%=mod;
            
        }
        dp[level][tlo][thi][rem]=ans;
    }
    return dp[level][tlo][thi][rem];
}

void solve(){
    L="1";
    cin>>R;
    reverse(all(R));
    // L=getBase(l,2);
    // R=getBase(r,2);
    while(L.length()<R.length()){
        L+='0';
    }
    while(R.length()<L.length()){
        R+='0';
    }
    reverse(all(L));
    reverse(all(R));
    //pr(L,R);
    cin>>D;
    memset(dp,-1,sizeof(dp));
    cout<<getAns(0,1,1,0)<<endl;
}


int32_t main()
{
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        solve(); 
        t1++;
        if(t1>T)
            break;
    }
}   

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

int main() {

  string S;
  cin >> S;

  string res = "AC";

  if ((int) S.at(0) != 65) {
    res = "WA";
  }

  if ((int) S.at(1) < 97 || 122 < (int) S.at(1)){
    res = "WA";
  }

  if ((int) S.at(S.size() - 1) < 97 || 122 < (int) S.at(S.size() - 1)){
    res = "WA";
  }

  int countC = 0;
  int positionC = 0;

  for (int i = 2; i < S.size() - 1; i++) {

    int s = (int) S.at(i);

    if (s == 67) {
      countC++;
      positionC = i;
    }

  }

  if (countC != 1) {
    res = "WA";
  }

  for (int i = 2; i < S.size() - 1; i++) {

    int s = (int) S.at(i);

    if (i != positionC) {
      if (s < 97 || 122 < s) {
        res = "WA";
        break;
      }
    }

  }

  cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	vector<pair<pair<int,bool>,int> > e;
	for (int i=0;i<2*n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		e.push_back({{x,1-i/n},y});
	}
	sort(e.begin(),e.end());
	int ans=0;
	set<int> s;
	for (auto p:e)
	{
		if (p.first.second)
		s.insert(p.second);
		else
		{
			auto it=s.lower_bound(p.second);
			if (it==s.begin())
			continue;
			it--;
			s.erase(it);
			ans++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	long pow(long a,long n,long p) {
		long ret=1;
		for(;n>0;n>>=1,a=a*a%p) {
			if(n%2==1)ret=ret*a%p;
		}
		return ret;
	}
	
	long inv(long a,long p) {
		if(a==0)throw new AssertionError();
		return pow(a,p-2,p);
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int P=sc.nextInt();
		char[] cs=sc.next().toCharArray();
		if(P==2||P==5) {
			long ans=0;
			for(int i=0;i<cs.length;++i) {
				if((cs[i]-'0')%P==0) {
					ans+=i+1;
				}
			}
			System.out.println(ans);
			return;
		}//3***,354*,***3,
		long[] cnt=new long[P];
		long ans=0;
		long cur=0;
		for(int i=0;i<cs.length;++i) {
			int v=(int)(cs[i]-'0')%P;
			cur=(cur*10+v)%P;
			if(cur==0)++ans;
			long i10=inv(pow(10,i,P),P);
			ans+=cnt[(int)(i10*cur%P)];
			cnt[(int)(i10*cur%P)]++;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    int nextInt() {
    	return (int)nextLong();
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

int main() {
    int N;
    int M;

    cin >> N >> M;

    vector <int> val (N, -1);
    bool illegal = false;

    for (int i = 0; i < M; ++i) {
        int d;
        int v;
        cin >> d >> v;

        --d;
        if (val[d] == -1 || val[d] == v) {
            val[d] = v;
        } else { // contradicts
            illegal = true;
            break;
        }
    }

    if (val[0] == 0 && N > 1) {
        illegal = true;
    }

    if (illegal) {
        cout << -1 << endl;
    } else {
        if (val[0] == -1) {
            val[0] = N > 1 ? 1 : 0; // no leading zero
        }

        for (int i = 0; i < val.size(); ++i) {
            if (val[i] == -1) {
                cout << 0;
            } else {
                cout << val[i];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int k;
    cin>>k;
    if(k%2==0){
        cout<<pow(k/2, 2.0)<<endl;
    }else{
        cout<<(k/2)*(k/2 +1)<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))

ave = sum(X)//N
sum0 = 0
sum1 = 0

for i in range(N):
  sum0 += (X[i]-ave-1)**2
  sum1 += (X[i]-ave)**2
  
print(min(sum0,sum1))  
  

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  
  cin >> A >> B >> C >> X;
  
  while((A>=B)&&!(X==0)){
    B=B*2;
    X--;
  }
    while((B>=C)&&!(X==0)){
    C=C*2;
    X--;
  }
  if((A < B)&&(B < C))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
  string s;
  i64 k;
  cin >> s >> k;
  i64 len = s.size();
  for (i64 i = 0; i < len; i++)
    if (s[i] != 'a' && 'z' - s[i] + 1 <= k)
    {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  k %= 26;
  s[len - 1] = (s[len - 1] - 'a' + k) % 26 + 'a';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t A, B, C, K;

    std::cin >> A >> B >> C >> K;

    auto calc = [&](){

        int64_t ans = 0;

        if (A > K) return K;

        ans = A;
        K -= A;

        if (B > K) return ans;

        K -= B;

        ans -= K;

        return ans;
    };

    std::cout << calc() << std::endl;

    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(w);
    out(w*32);
}
















Measured memory_bytes: 3208
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  a,b,c;
    cin>>a>>b>>c;
    int  n1=sz(a) ,n2=sz(b), n3=sz(c) ; 
    int i,j,k;
    char cur=a[0];
    while (true){
    	if (cur=='a') {
    		if (sz(a)==0) cout << "A"<< endl,exit(0);
    		else {
    			cur=a[0];
    			a.erase(a.begin());
    		}
    	}
    	else if (cur=='b') {
    		if (sz(b)==0) cout << "B"<< endl,exit(0);
    		else {
    			cur=b[0];
    			b.erase(b.begin());
    		}
    	}
    	else {
    		if (sz(c)==0) cout << "C"<< endl,exit(0);
    		else {
    			cur=c[0];
    			c.erase(c.begin());
    		}
    	}
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3568
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func main() {
	A := nextInt()
	B := nextInt()
	C := nextInt()
	D := nextInt()
	ANS := B - A + 1 - divisorNum(A, B, C) - divisorNum(A, B, D) + divisorNum(A, B, lcm(C, D))
	fmt.Println(ANS)
}

func divisorNum(a, b, c int) int {
	return b/c - (a-1)/c
}

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 1808
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Measured memory_bytes: 9052
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

//正剰余を求める
int posmod(int left, int right) {
    int res = left % right;
    return res < 0 ? res + abs(right) : res;
}

//正剰余に対応した除算
int posdiv(int left, int right) {
    return (left - posmod(left, right)) / right;
}

list<int> chbase(int n, int base) {
    list<int> res;
    while(n != 0) {
        res.push_front(posmod(n, base));
        n = posdiv(n, base);
    }
    if(res.size() == 0) res.push_back(0);
    return res;
}

int main(int argc, char **argv) {
    int N;
    cin >> N;
    list<int> res = chbase(N, -2);

    for(list<int>::iterator it = res.begin(); it != res.end(); ++it)
        cout << *it;
    
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int pos=0;
   string s[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
   string day="";
   cin>>day;
   if(day=="SUN")
   {
       cout<<"7"<<endl;
   }
   else
   {
       
   for(int i=0;i<7;i++)
   {
       if(day==s[i])
       pos=i;
    

   }
   

   cout<<6-pos<<endl;
   }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int r;
  int n;
  cin>>n;
  vi a(n);
  int ans=0;
  rep(r,n)cin>>a[r];
  for(r=1;r<n;r++){
    if(a[r]==a[r-1])continue;
    if(a[r]<a[r-1]){
      for(;r<n;r++)if(a[r]>a[r-1])break;
      if(n-r)ans++;
    }else{
      for(;r<n;r++)if(a[r]<a[r-1])break;
      if(n-r)ans++;
    }
  }
  cout<<ans+1<<endl;
}


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

int keta(int n){
    int x;
    while(n>0){
        x += n%10;
        n /= 10;
    }
    return x;
}

int main(){
    int n;
    cin >> n;
    int a = keta(n);
    if(n%a==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
// }}}

// misc {{{
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
// }}}

// debug(...) {{{
static bool debug_enabled = false;
static int debug_max_elms = 10;

static int debug_max_count = 50;
static int debug_current_count = 0;

void debug1(char const * x) { cout << x; }
template<class T> void debug1(const T& x) { cout << x; }
template<class T1, class T2> void debug1(const pair<T1, T2>& x) { cout << "(" << x.first << ", " << x.second << ")"; }
template<class T> void debug1(const vector<T>& x) {
  cout << "[";
  auto i = x.begin();
  while(i != x.end()) {
    debug1(*i);
	++i;
	if(i != x.end()) cout << ", ";
    if(std::distance(x.begin(), i) > debug_max_elms) {
      cout << "...";
      break;
    }
  }
  cout << "]";
}
template<class K, class V> void debug1(const map<K, V>& x) {
  cout << "{";
  auto i = x.begin();
  while(i != x.end()) {
    debug1(get<0>(*i));
    cout << ": ";
    debug1(get<1>(*i));
    ++i;
    if(i != x.end()) cout << ", ";
  }
  cout << "}";
}

void debug2() { cout << endl; }
template<class T, class... Ts> void debug2(const T& x, const Ts&... xs) {
  cout << ' ';
  debug1(x);
  debug2(xs...);
}

template<class T, class... Ts> void debug(const T& x, const Ts&... xs) {
  if(debug_enabled) {
    ++debug_current_count;
    if(debug_current_count > debug_max_count) {
      cout << "... (debug log disabled)" << endl;
      debug_enabled = false;
    }
	cout << "[D] ";
	debug1(x);
	debug2(xs...);
  }
}
// }}}

// main {{{
void solve();
int main() {
  auto v = getenv("DEBUG");
  if(v && string(v) == "1") debug_enabled = true;
  if(false) debug("dummy for suppress warnings", vector<int>(0));
  solve();
}
// }}}


int dp[30][100001];

int next(unsigned char c, const string& s, int i) {
  if(i == s.size()) return -1;

  int idx = c - 'a';

  if(dp[idx][i] > -2) return dp[idx][i];

  if(s[i] == c) {
    return dp[idx][i] = i;
  }

  return dp[idx][i] =  next(c, s, i + 1);
}

ll calc(const string& s, const string& t, int i, int j) {
  debug("calc:", i, s[i], j, t[j]);
  if(j == t.size()) return 0;
  // debug(s.substr(i, s.size() - i), t.substr(j, t.size() - j));
  int nx = next(t[j], s, i);
  debug("nx", nx);
  if(nx == -1) {
    if(i == 0) return -1;
    ll rest = calc(s, t, 0, j);
    if(rest == -1) return -1;
    else return s.length() - i + rest;
  }

  ll rest = calc(s, t, nx + 1, j + 1);
  if(rest == -1) return -1;
  return nx - i + 1 + rest;
}

void solve() {
  string s, t;
  getline(cin, s);
  getline(cin, t);

  rep(i, 30) rep(j, 100001) dp[i][j] = -2;

  cout << calc(s, t, 0, 0) << endl;
}


Measured memory_bytes: 29184
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  ll sum=0;
  ll resum=0;
  vll A(3*n);
  priority_queue<ll> front;
  priority_queue<ll> back;

  FOR(i,0,3*n){
    ci(A[i])
    if(i<n){
      front.push(-A[i]);
      sum+=A[i];
    }

    if(2*n-1<i){
      back.push(A[i]);
      resum+=A[i];
    }
  }
  //cout<<sum<<" "<<resum<<endl;
  vpll ans(n+1);
  ans[0].fi=sum;
  ans[n].se=resum;
  
  for(int i=n;i<2*n;i++){
    front.push(-A[i]);
    sum+=A[i];

    ll a=front.top();
    sum+=a;
    front.pop();
    ans[i-n+1].fi=sum;
  }

  for(int i=(2*n-1);n<=i;i--){
    back.push(A[i]);
    resum+=A[i];

    ll a=back.top();
    resum-=a;
    back.pop();
    ans[i-n].se=resum;
  }

  ll Ans=-INF;
  FOR(i,0,n+1){
    ll now=ans[i].fi-ans[i].se;
    //cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    chmax(Ans,now);
  }

  co(Ans)
    
}

Measured memory_bytes: 5876
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int a;
void input()
{
    cin>>a;
}

void solve()
{
    cout<<a+a*a+a*a*a<<endl;
}

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

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[]) {

    int N, K, X, Y;
    std::cin >> N >> K >> X >> Y;

    if (N > K) {
        std::cout << K * X + (N - K) * Y << '\n';
    } else {
        std::cout << N * X << '\n';
    }

    return 0;
}


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

using namespace std;
int n,t1,a,t[1000002];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i=1;i <= n-1;i++)
	{
		cin >> a;
		t[a]++;
	}
	for(int i=1;i <= n;i++)
		cout << t[i] << endl;

}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

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

int N;

void solve() {
    int ans = 0;
    {
        auto V = divisor(N - 1);
        ans += V.size() - 1;
    }
    {
        auto V = divisor(N);
        for (auto d : V) {
            if (d == 1)
                continue;
            itn n = N;
            while (n != 0 && n % d == 0)
                n /= d;
            if (n % d == 1)
                ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;


    solve();
    return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	int N;

	string s;

	cin >> N >> s;

	vi R(N), W(N);

	for (int i = 0; i < N; ++i) {
		char c = s[i];
		R[i] += (c == 'R');
		W[i] += (c == 'W');
		if (i)
			R[i] += R[i - 1], W[i] += W[i - 1];
	}

	int ans = min(R[N - 1], W[N - 1]);

	for (int i = 1; i <= N - 1; ++i)
		ans = min(ans, max(W[i], R[N - 1] - R[i]));

	cout << ans << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 5172
use proconio::input;
use proconio::marker::Chars;
use std::cmp::max;
use std::collections::VecDeque;

fn main()
{
    input! {
    n:i32,
    mut k:i32,
    s:Chars
    }

    let mut ans = 0;
    let mut q: VecDeque<char> = VecDeque::new();
    let mut index = 0;
    while index < n {
        let c = s[index as usize];
        while index < n && c == s[index as usize] {
            q.push_back(c);
            index += 1;
        }
        if c == '0' {
            k -= 1;
        }
        if k < 0 {
            while *q.front().unwrap() == '1' {
                q.pop_front();
            }
            while *q.front().unwrap() == '0' {
                q.pop_front();
            }
            k += 1;
        }
        ans = max(ans, q.len() as i32);
    }

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

Measured memory_bytes: 2876