akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long n,k;cin>>n>>k;
    vector<long long>a(n),f(n),c(n);
    vector<pair<long long,long long>>b(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=0;i<n;++i){
        cin>>f[i];
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
    reverse(f.begin(),f.end());
    for(int i=0;i<n;++i){
        b[i].first=a[i]*f[i];
        b[i].second=f[i];
    }
    sort(b.begin(),b.end());
    for(int i=0;i<n;++i)c[i]=b[i].first;
    long long r=b[n-1].first,l=0;
    while(r-l>1){
        long long m=(r+l)/2,cnt=0;
        int h=upper_bound(c.begin(),c.end(),m)-c.begin();
        for(int i=h;i<n;++i){
            if(b[i].first-m>0){cnt+=(b[i].first-m)/b[i].second;
            if((b[i].first-m)%b[i].second>0)cnt++;}
        }
        if(cnt>k)l=m;
        else{
            r=m;
        }
    }
    long long ans=r;
    long long m=(r+l)/2,cnt=0;
    int h=upper_bound(c.begin(),c.end(),l)-c.begin();
    for(int i=h;i<n;++i){
        if(b[i].first-m>0){cnt+=(b[i].first-m)/b[i].second;
        if((b[i].first-m)%b[i].second>0)cnt++;}
    }
    if(cnt<=k)ans=l;
    cout<<ans<<endl;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  vector<bool> p(55556, true);
  p[0] = p[1] = false;
  for (int i = 2; i < p.size(); ++i) {
    if (!p[i]) continue;
    for (int j = 2 * i; j < p.size(); j += i) {
      p[j] = false;
    }
  }

  int n = in();
  vector<int> ans;
  for (int i = 6; n; i += 5) {
    if (p[i]) {
      ans.pb(i);
      n--;
    }
  }

  cout << ans << endl;
}


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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    vector<string> t(1<<(n-1));
    for(int i=0;i<(1<<(n-1));i++){
        int temp=i;
        int j=0;
        while(1){
            t[i]+=s[j];
            if((temp>>j)%2 and 1) t[i]+='+';
            j++;
            if(j==n) break;
        }
    }
    ll ans=0;
    stack<int> stack;
    for(int i=0;i<t.size();i++){
        for(int j=0;j<t[i].size();j++){
            if(t[i][j]!='+'){
                stack.push(t[i][j]-'0');
                continue;
            }
            ll ten=1;;
            while(!stack.empty()){
                int top=stack.top(); 
                stack.pop();
                ans+=top*ten;
                ten*=10;
            }
        }
        ll ten=1;
        while(!stack.empty()){
            int top=stack.top(); 
            stack.pop();
            ans+=top*ten;
            ten*=10;
        }        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  out(b * (c / a));
  memi;
}

Measured memory_bytes: 256
#include <stdio.h>
long xxx[10][901][101];
long pattern(int n,int s,int from){
	long i,x=0;
	if(s>100*n)return 0;
	if(xxx[n][s][from]>=0)x=xxx[n][s][from];
	else{
		for(i=(s-100*(n-1)>from?s-100*(n-1):from); i<100 && i*n<=s ;i++){x+=pattern(n-1,s-i,i+1);}
		xxx[n][s][from]=x;
	}
	return x;
}
int main(void){
	int n,s,i,j,k;
	for(j=0;j<101;j++){for(k=0;k<101;k++){xxx[1][j][k]=( (j<=100 && k<=j)?1:0 );}}
	for(i=2;i<10;i++){for(j=0;j<=i*100;j++){for(k=0;k<101;k++){xxx[i][j][k]=-1;}}}
    while(scanf("%d %d",&n,&s)*(n+s)){printf("%ld\n",pattern(n,s,0));}
    return 0;
}

Measured memory_bytes: 5844
def find(n):
  dif = 0
  i = 0
  while dif <=n:
    i+=1
    dif=i**5-(i-1)**5
  return i


X= int(input())
lim = find(X)
condition = True 
for i in range(lim):
  if condition:
    puissance = i**5-X
    signe = (abs(puissance)//puissance)
    entier = int(((puissance*signe)**(1/5)))
    if entier**5 == signe*puissance:
      print(i, entier*signe)
      condition = False

Measured memory_bytes: 9488
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,k,q;cin>>n>>k>>q;
	vi a(n,k-q);
	while(q--)
	{
		ll x;cin>>x;x--;
		a[x]++;
	}

	rep(i,0,n) if(a[i]>0) cout<<"Yes\n"; else cout<<"No\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  long long x,y,ans = 2000000000000;
  scanf("%ld%ld",&x,&y);
  if(y - x >= 0 && y - x < ans)ans = y - x;
  if(y + x >= 0 && 1 + y + x < ans)ans = 1 + y + x;
  if(-y - x >= 0 && 1 - y - x < ans)ans = 1 - y - x;
  if(-y + x >= 0 && 2 - y + x < ans)ans = 2 - y + x;
  printf("%lld\n",ans);
  return 0;
}

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

using namespace std;

int main() {
  string s;
  getline(cin, s);
  for (int i = 0; i < s.length(); i++) {
    if ('A' <= s[i] && s[i] <= 'Z') cout << (char)(s[i]-'A'+'a');
    else if ('a' <= s[i] && s[i] <= 'z') cout << (char)(s[i]-'a'+'A');
    else cout << (char)s[i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> a(n),ans;
	for(int i=0;i<n;++i){
		cin >> a[i];
	}
	ans.push_back(a[0]);
	for(int i=1;i<n;++i){
		if(a[i]<ans.back())
			ans.push_back(a[i]);
	}
	cout << ans.size() << '\n';
	return 0;
}

Measured memory_bytes: 5076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<ctime>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cstdlib>
#include<ctime>
#include<random>
#define ll long long
using namespace std;

int k,n,ans,a[200007];

int main(){
    scanf("%d%d",&k,&n);
    for (int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }
    ans=k;
    for (int i=2;i<n;++i){
        ans=min(ans,k-(a[i+1]-a[i]));
        ans=min(ans,k-(a[i]-a[i-1]));
    }
    ans=min(ans,a[n]-a[1]);
    printf("%d\n",ans);
}

Measured memory_bytes: 4616
x1, y1, x2, y2 = map(int, input().split())
x = x1 - x2
y = y1 - y2
point3 = [x2 + y, y2 - x]
point4 = [x1 + y, y1 - x]
print(*[point3[0], point3[1], point4[0], point4[1]], sep=' ')


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

int main(){
    int a,b,c,buf;
    cin >> a >> b >> c;
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    if(b>c){
        buf=b;
        b=c;
        c=buf;
    }
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1000000007)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  ll n, k, ans=0, nm;
  cin >> n >> k;
  vector<ll> a(n), c(n, 0), r(n, 0);
  rep(i, n) cin >> a.at(i);
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      if(a.at(i) > a.at(j)) c.at(i)++;
    }
    for(int j = 0; j < i; j++) {
      if(a.at(i) > a.at(j)) r.at(i)++;
    }
  }
  nm = (k * (k+1)) / 2;
  for(int i = 0; i < n; i++) {
    ans += (r.at(i) * ((k * (k - 1) / 2) % mod)) % mod;
    ans += (c.at(i) * ((nm) % mod)) % mod;
  }
  cout << ans % mod;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())

left_count = 0
right_count = 0
dif = 0

for i in range(len(s)):
    if s[i] == '(':
        left_count += 1
    elif s[i] == ')':
        if left_count > 0:
            left_count -= 1
        else:
            right_count += 1

ans = '(' * right_count  + s + ')' * left_count
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
constexpr auto MAX = 10E9+1;
using namespace std;
using ll = long long;
using VI = vector<int>;

int main()
{
    
    int n;
    cin >> n;
    VI a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    bool flag = 1;
    while (flag) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            }
            else { 
                flag = 0; 
                break;
            }
        }
        if (flag) ans++;
    }
        
    cout << ans << endl;

    

    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner itr = new Scanner(System.in);
        int N = itr.nextInt();
        int W = itr.nextInt();

        int[] weight = new int[N];
        int[] value = new int[N];

        for (int i = 0; i < N; i++) {
            weight[i] = itr.nextInt();
            value[i] = itr.nextInt();
        }

        int[] dp = new int[100001];

        Arrays.fill(dp, Integer.MAX_VALUE);

        //dp[value[0]] = weight[0];

        for (int i = 0; i < N; i++) {
            int[] newdp = Arrays.copyOf(dp, 100001);

            if (weight[i] <= W)
                newdp[value[i]] = Math.min(dp[value[i]], weight[i]);

            for (int j = 0; j <= 100000; j++) {
                if ((dp[j] != Integer.MAX_VALUE) && (dp[j] + weight[i] <= W)) {
                    newdp[j + value[i]] = Math.min(dp[j + value[i]], dp[j] + weight[i]);
                }
            }
            dp = newdp;
        }

        int res = 0;
        for (int i = 0; i <= 100000; i++) {
            if (dp[i] != Integer.MAX_VALUE)
                res = i;
        }
        System.out.println(res);
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int H[N],dp[N];
  for(int i=0;i<N;i++) cin >> H[i];
  
  dp[0]=0;
  for(int i=1;i<N;i++){
    dp[i] = dp[i-1]+abs(H[i]-H[i-1]);
    for(int j=2;j<=min(K,i);j++) dp[i] = min(dp[i] , dp[i-j]+abs(H[i]-H[i-j]));
  }
  
  cout << dp[N-1] << endl;
  return 0;
}


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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,0,m) cin >> b[i];
  int ans = 0;
  rep(i,0,n) {
    int code = c;
    rep(j,0,m) {
      int a;
      cin >> a;
      code += a*b[j];
    }
    if (code > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,k;
Graph F,B;
bool seen[100010];
int friends[100010];
int ID[100010];
int block[100010];
void dfs(int v,int id){
    seen[v]=true;
    friends[id]++;
    ID[v]=id;
    for(int x :F[v]){
        if(seen[x])continue;
        dfs(x,id);
    }
}
int main(){
    cin >> n >> m >> k;
    F.resize(n);
    B.resize(n);
    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        F[a].push_back(b);
        F[b].push_back(a);
    }
    int now=0;
    rep(i,n){
        if(seen[i])continue;
        dfs(i,now);
        now++;
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--;d--;
        B[c].push_back(d);
        B[d].push_back(c);
    }
    rep(i,n){
        for(int y:B[i]){
            if(ID[y]==ID[i])block[i]++;
        }
    }
    rep(i,n){
        int fri=friends[ID[i]];
        int ans=fri-F[i].size()-block[i]-1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12800
//#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include "bits/stdc++.h"

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;

string stringsum(string s1, string s2) {
	if (s1 == s2 && s1 == "0") return "0";
	string s;
	reverse(all(s1));
	reverse(all(s2));
	int len1 = s1.size();
	int len2 = s2.size();
	bool up = false;
	for(int i=0;i<=100;i++) {
		//cout << i << endl;
		if (len1 <= i && len2 <= i)break;
		int k = 0;
		if (up) {
			k++;
			up = false;
		}
		string c;
		if (len1>i){
			c = s1[i];
			k += stoi(c);
		}
		if (len2 > i) {
			c = s2[i];
			k += stoi(c);
		}
		if (k >= 10) {
			up = true;
			k -= 10;
		}
		s += to_string(k);
		//cout << k << " ";
		//cout << s << endl;
	}
	if (up)s += '1';
	reverse(all(s));
	return s;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	rep(i, n) {
		string s1, s2;
		cin >> s1 >> s2;
		string s;
		s = stringsum(s1, s2);
		if (s.size() > 80) cout << "overflow" << endl;
		else cout << s << endl;
	}
}



Measured memory_bytes: 3304
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<String>();
        
        while (n-- > 0) {
            set.add(sc.next());
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 78548
use proconio::input;
use rand::Rng;
use std::collections::BTreeSet;

const N: i64 = 1000000;

fn main() {
   input! {
      dn: usize,
      c: [i64; 26],
      s: [[i64;26]; dn],
   }

   let mut t = vec![];
   let mut last = vec![BTreeSet::new(); 26];
   for i in 0..26 {
      last[i].insert(0);
      last[i].insert(dn + 1);
   }
   for d in 0..dn {
      let mut mx = std::i64::MIN;
      let mut tn = 0;
      for t in 0..26 {
         let mut score = 0i64;
         score += s[d][t];
         for j in 0..26 {
            if j != t {
               score -= c[j] * (d + 1 - last[j].range(..=d).rev().next().unwrap()) as i64;
            }
         }
         if score > mx {
            mx = score;
            tn = t;
         }
      }
      last[tn].insert(d + 1);
      t.push(tn);
   }

   let mut rng = rand::thread_rng();
   for i in 0..N {
      let d = rng.gen_range(0, dn);
      let q = rng.gen_range(0, 26);
      if t[d] == q {
         continue;
      }
      let p = t[d];
      let mut score = 0;
      score -= s[d][p];
      score += s[d][q];
      let f1 = last[p].range(..=d).rev().next().unwrap();
      let b1 = last[p].range(d + 2..).next().unwrap();
      let f2 = last[q].range(..=d).rev().next().unwrap();
      let b2 = last[q].range(d + 2..).next().unwrap();
      score -= c[p] * (d + 1 - f1) as i64 * (b1 - (d + 1)) as i64;
      score += c[q] * (d + 1 - f2) as i64 * (b2 - (d + 1)) as i64;
      let temp: f64 = 1000.0 / (((2*i/N - 1) as f64).exp() + 1.0);
      if score > 0 || rng.gen_range(0.0, 1.00) <= (score as f64 / temp).exp() {
         t[d] = q;
         last[p].remove(&(d + 1));
         last[q].insert(d + 1);
      }
   }
   for &t in t.iter() {
      println!("{}", t + 1);
   }
}


Measured memory_bytes: 3336
//@author Khaled Alam(Ninjo) ~ KhaledAlam.net
#include <bits/stdc++.h>
using namespace std;
// Template(v0.0.1)  |  Github.com/khaledalam/templates/tree/master/cpp
typedef long long ll;
typedef vector<int> vi;
typedef stringstream ss;
typedef pair<int, int> pii;
//#########################
#define endl         '\n'
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define out(x)       return cout<<x,0
#define all(x)       x.begin(),x.end()
#define sz(x)        ((int)(x.size()))
#define clr(x)       memset(x,0,sizeof x)
#define rep(i,n)     for(int i=0;i<n;i++)
#define ifile(x)     freopen(#x,"r",stdin)
#define ofile(x)     freopen(#x,"w",stdout)
#define pin0(x)      size_t x = time(NULL)
#define pin1(x)      fprintf(stderr,"time: %.2fs\n",(float)time(NULL)-x)
#define foreach(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();i++)
#define ios          ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define val(x)       cerr<<"[l#: "<<__LINE__<<"] "<< " "<<#x<<" = "<<x<<'\n'
//##########################################################################

int main()
{
//	ios;
//	ifile(input.txt); //ofile(output.txt);

//	cout << __gcd(0, 5);
//	return 0;
	int n;
	cin>>n;
	long long res = 0;
	rep(i,n)
	{
		int a,b;
		cin>>a>>b;
		res += b-a+1;
	}
	cout<<res;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		
		
		for ( int i = 1;i <10;i++) {
			if(n%i==0 & n/i<10) {
				System.out.println("Yes");
				break;
			}else if (i==9) {
				System.out.println("No");
			}
			
		}
		
	}
 
}


Measured memory_bytes: 23760
/*#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
}*/

#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
int main()
{
    int n;
    std::string s;
    std::cin >> n >> s;
    std::string s1 = s.substr(0, n), s2 = s.substr(n);
    std::vector<std::pair<std::string, std::string>> v1(1 << n), v2(1 << n);
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j)
            (i & (1 << j) ? v1[i].first : v1[i].second) += s1[j];
    }
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j)
            (i & (1 << j) ? v2[i].first : v2[i].second) += s2[j];
        std::reverse(v2[i].first.begin(), v2[i].first.end());
        std::reverse(v2[i].second.begin(), v2[i].second.end());
    }
    sort(v2.begin(), v2.end());
    long long ans = 0;
    for (auto vv : v1) {
        auto p = std::make_pair(vv.second, vv.first);
        ans += std::upper_bound(v2.begin(), v2.end(), p) - std::lower_bound(v2.begin(), v2.end(), p);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 36008
#include<bits/stdc++.h>
#include<queue>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,X;
  cin>>N>>X;
  int tmp,tmp2=0;
  int ans = 1;
  REP(i,N){
    cin>>tmp;
    tmp2 += tmp;
    if(tmp2<=X)ans++;
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;



pair<ll,ll> trans(ll x, ll y){
  if(x == 9){
    return make_pair(9LL, 2*(y-1));
  }
  if(x == 8){
    return make_pair(9LL-(y%9), 2*(y-1)-y/9);
  }
  if(x == 7){
    return make_pair(9LL-(2*y%9), 2*(y-1)-y/9-(y+4)/9);
  }
  if(x == 6){
    return make_pair(9LL-(3*y%9), 2*(y-1)-y/3);
  }
  if(x == 5){
    return make_pair(9LL-(4*y%9), 2*(y-1)-y/9-(y+6)/9-(y+4)/9-(y+2)/9);
  }
  if(x == 4){
    return make_pair(9LL-(5*y%9), 2*(y-1)-y/9-(y+7)/9-(y+5)/9-(y+3)/9-(y+1)/9);
  }
  if(x == 3){
    return make_pair(9LL-(6*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+4)/9-(y+3)/9-(y+1)/9);
  }
  if(x == 2){
    return make_pair(9LL-(7*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+5)/9-(y+3)/9-(y+2)/9-(y+1)/9);
  }
  if(x == 1){
    return make_pair(9LL-(8*y%9), 2*(y-1)-y/9-(y+7)/9-(y+6)/9-(y+5)/9-(y+4)/9-(y+3)/9-(y+2)/9-(y+1)/9);
  }
  return make_pair(0, y-1);
}

int main(){
  int M;
  cin >> M;
  
  ll ret = 0;
  stack<ll> st;
  rep(i,M){
    ll d, c;
    cin >> d >> c;
    pair<ll,ll> res = trans(d, c);
    st.push(res.first);
    ret += res.second;
  }
  
  while(!st.empty()){
    if(st.size() == 1 && st.top()<10) break;
    if(st.top() >= 10){
      ll a = st.top(); st.pop();
      ll b = (a/10) + (a%10);
      //cout << a << "->" << b << endl;
      st.push(b);
      ret++;
    }
    else {
      ll a = st.top(); st.pop();
      ll b = st.top(); st.pop();
      ll c = a + b;
      //cout << a << " " << b << "->" << c << endl;
      st.push(c);
      ret++;
    }
  }
  
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
int a[N] = {};

int main(){
	int n; scanf("%d", &n);
	REP(i, n-1){
		int b; scanf("%d", &b);
		a[b]++;
	}
	FOR(i, 1, n+1){
		printf("%d\n", a[i]);
	}
}


Measured memory_bytes: 4616
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

void zeta(vec<P>& f)
{
   int n = f.size();
   vec<int> tmp;
   for (int i = 0; (1 << i) < n; i++) {
      for (int j = 0; j < n; j++) {
         if ((j >> i) & 1) {
            tmp.clear();
            tmp.PB(f[j].first);
            tmp.PB(f[j].second);
            tmp.PB(f[j ^ (1 << i)].first);
            tmp.PB(f[j ^ (1 << i)].second);
            RSORT(tmp);
            f[j].first = tmp[0];
            f[j].second = tmp[1];
         }
      }
   }
}

signed main()
{
   int N; cin >> N;
   vec<int> A(1 << N);
   rep(s, 0, 1 << N) {
      cin >> A[s];
   }


   vec<P> f(1 << N, MP(0,0));
   rep(s, 0, 1 << N) {
      f[s].first = A[s];
   }

   dump(f)

   zeta(f);

   int MAX = 0;
   rep(s, 1, 1 << N) {
      MAX = max(MAX, f[s].first + f[s].second);
      cout << MAX << endl;
   }

   return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    ll ans=0;
    FOR(i,1,n+1){
        ans+=(n/i)*(n/i+1)/2*i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(void)
{
  int n,m,ans[51],i,a,b;
  for(i=0;i<51;i++)
    {
      ans[i] = 0;
    }
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)
    {
      scanf("%d %d",&a,&b);
      ans[a-1]++;
      ans[b-1]++;
    }
  for(i=0;i<n;i++)
    {
      printf("%d\n",ans[i]);
    }
  return 0;
}
      


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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    string s;
    cin >> s;
    string ans(s.size(), 'x');
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    ll S = 0;
    FOR(a, A)
    {
        S += a;
    }
    ll ans = INF;
    ll L = 0;
    FOR(a, A)
    {
        L += a;
        CH(min, ans, abs(S - 2 * L));
    }
    OUT(ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int h,w;
int a[1000][1000];
ll dp[1000][1000];
set<pair<int,int> >s;
ll grid(int x,int y)
{
	
	if(x==h-1&&y==w-1)
	return 1;
	if(x==h||y==w)
	return 0;
	if(a[x][y]==1)
	return 0;
	if(s.find({x,y})!=s.end())
	return dp[x][y]%1000000007;
	else
	s.insert(make_pair(x,y));
	dp[x][y]=grid(x+1,y)+grid(x,y+1);
	return dp[x][y]%1000000007;
}
int main()
{
	cin>>h>>w;
	char c;
	ll res;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>c;
			if(c=='#')
			a[i][j]=1;	
		}
	}
	res=grid(0,0);
	cout<<res%1000000007<<"\n";
}

Measured memory_bytes: 57344
K = int(input())
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(N[K-1])

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = cin.int()
    ans = (N // 11) * 2
    if N % 11 == 0:
        ans
    elif N % 11 <= 6:
        ans += 1
    else:
        ans +=2
    print(ans)
    return

if __name__ == "__main__":
    main()


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a < b) cout << "a < b" << endl;
    if (a > b) cout << "a > b" << endl;
    if (a == b) cout << "a == b" << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
int inf=1e9+7;
signed main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> a(n,vector<int>(n+1,inf));
    rep(i,m){
        int s,t,d;cin>>s>>t>>d;
        a[s][t]=d;
        //a[t][s]=d;
    }
    int res=inf;
    rep(x,n){
        vector<vector<int>> dp(n,vector<int>((1<<n),inf));
        dp[x][(1<<x)]=0;
        rep(j,(1<<n)){
            rep(i,n){
                if(j&(1<<i)){
                    rep(k,n){
                        if(j&(1<<k))continue;
                        dp[k][j+(1<<k)]=min(dp[k][j+(1<<k)],dp[i][j]+a[k][i]);
                    }
                }
            }
        }
        int buf=inf;
        rep(y,n){
            if(y==x)continue;
            buf=min(dp[y][(1<<n)-1]+a[x][y],buf);
        }
        res=min(buf,res);
    }
    if(res==inf)res=-1;
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 7096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const ll mod=1e9+7;
const int maxn=2e5;
pair<ll,ll> a[maxn+5];
ll x[maxn+5],y[maxn+5];
ll dp[maxn+5][40];
ll b[maxn+5];
bool cmp(const pair<ll,ll> a,const pair<ll,ll> b)
{
    return a.second*(b.first-1)<b.second*(a.first-1);
}
ll T;
int n,tot,m;
int main()
{

    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>T;
    for(int i=1;i<=n;++i) 
    {
        int x,y;
        cin>>x>>y;
        if(x>0)
            a[++tot]=mp(x+1,x+y+1);
        else
            b[++m]=x+y+1;
    }
    sort(a+1,a+tot+1,cmp);
    sort(b+1,b+m+1);
    for(int i=0;i<=30;++i) dp[0][i]=T+1;
    dp[0][0]=0;
    for(int i=1;i<=tot;++i)
        for(int j=0;j<=30;++j)
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]*a[i].first+a[i].second);
    int ans=0;
    for(int j=0;j<=30;++j)
    {
        ll now=dp[tot][j];
        if(now>T) continue;
        ans=max(ans,j);
        for(int i=1;i<=m;++i)
        {
            now=now+b[i];
            if(now<=T) ans=max(ans,j+i);else break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
// #include "../../cxx-prettyprint/prettyprint.hpp"
 
#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, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>
 
using namespace std;
typedef long long ll;
// typedef pair<int, int> P;
 
const ll INF = (ll)1e18;
 
struct edge {
    int to;
    int cost;
};
 
// <最短距離, 頂点の番号>
using P = pair<ll, int>;
 
int V;
vector<edge> G[100001];
vector<ll> d(100001);

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));
 
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
 
        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
 
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述
 
	int N, M;
	cin >> N >> M;
 
	V = N+1;
 
	vector<int> L,R,C;
	int l,r,c;
	for(int i=0; i<M; i++){
		cin >> l >> r >> c;
		L.push_back(l);
		R.push_back(r);
		C.push_back(c);
	}
 
	for(int i=N;i>1;i--){
		edge e = {i-1, 0};
		G[i].push_back(e);
	}
	REP(i,M){
		edge e = {R[i], C[i]};
		G[L[i]].push_back(e);
	}
 
	dijkstra(1);
 
	// cout << d << "\n";
 
	cout << setprecision(15);
	
	if(d[N] == INF){
		cout << -1 << "\n";
	}
	else{
		cout << d[N] << "\n";
	}
 
return 0;
}

Measured memory_bytes: 9708
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int q;
    cin >> q;
    bitset<64> akarin;
    akari<bitset<64>> masks(q);
    for (auto &b : masks)
    {
        int k, x;
        cin >> k;
        while (k--)
        {
            cin >> x;
            b.set(x);
        }
    }
    cin >> q;
    while (q--)
    {
        int x, i;
        cin >> x >> i;
        switch (x)
        {
        case 0:
            cout << akarin.test(i) << '\n';
            break;
        case 1:
            akarin |= masks[i];
            break;
        case 2:
            akarin &= ~masks[i];
            break;
        case 3:
            akarin ^= masks[i];
            break;
        case 4:
            cout << (masks[i] == (akarin & masks[i])) << '\n';
            break;
        case 5:
            cout << (akarin & masks[i]).any() << '\n';
            break;
        case 6:
            cout << (akarin == (akarin & ~masks[i])) << '\n';
            break;
        case 7:
            cout << (akarin & masks[i]).count() << '\n';
            break;
        case 8:
            cout << (akarin & masks[i]).to_ullong() << '\n';
            break;
        default:
            break;
        }
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3100
length = input()
nums = input().split(" ")

numdict = {}
for i, num in enumerate(nums):
	if num not in numdict:
		numdict[str(num)] = 1
	else:
		numdict[str(num)] += 1

ret = 0
for k,v in numdict.items():
	if int(k) > int(v):
		ret += int(v) 
	else:
		ret += int(v) - int(k)

print(ret)

Measured memory_bytes: 20600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  print(max({a+b,a-b,a*b}));
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'
#define fs first
#define sd second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << en;
    }else{
        cout << "ABC" << en;
    }

}

Measured memory_bytes: 3652
#include<stdio.h>

int main(int argc, char *argv[]){
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  int start = a;
  if(a < c) start = c;

  int end = b;
  if(b > d) end = d;

  int out = end - start;
  if(out < 0) out = 0;

  printf("%d\n", out);

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    long N;
    map<long, int> table;
    long A;
    bool isPossible = true;

    scanf("%ld", &N);

    long i;

    for (i = 0; i < N; i++) {
        scanf("%ld", &A);

        if (table.find(A) == table.end()) {
            if ((N % 2 == 0 && A % 2 == 0) || (N % 2 != 0 && A % 2 != 0)) {
                isPossible = false;

                break;
            }

            table[A] = 1;
        } else {
            table[A]++;

            if ((A == 0 && 1 < table[A]) || (A != 0 && 2 < table[A])) {
                isPossible = false;

                break;
            }
        }
    }

    if (!isPossible) {
        printf("0\n");
    } else {
        if (N % 2 == 0) {
            for (i = 1; i < N; i += 2) {
                if (table.find(i) == table.end() || table[i] != 2) {
                    isPossible = false;

                    break;
                }
            }
        } else {
            if (table.find(0) == table.end() || table[0] != 1) {
                isPossible = false;
            } else {
                for (i = 2; i < N; i += 2) {
                    if (table.find(i) == table.end() || table[i] != 2) {
                        isPossible = false;

                        break;
                    }
                }
            }
        }

        if (isPossible) {
            if (N == 1) {
                printf("1\n");
            } else if (N == 2) {
                printf("2\n");
            } else if (N == 3) {
                printf("2\n");
            } else {
                long ans = 1;

                long len = N / 2;

                for (i = 0; i < len; i++) {
                    ans *= 2;

                    if (1000000007 <= ans) ans -= 1000000007;
                }

                printf("%ld\n", ans);
            }
        } else {
            printf("0\n");
        }
    }

    return 0;
}


Measured memory_bytes: 3328
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
ans=0
for val in arr:
  for i in range(40):
    if val<2**i:
      persuit=2**i
      break
  if persuit-val==val:
    if val in dic:
      if dic[val]>=2:
        ans+=1
        dic[val]-=2
        if dic[val]==0:
          del dic[val]
      else:
        continue
    else:
      continue
  else:
    if val in dic and persuit-val in dic:
      ans+=1
      dic[val]-=1
      if dic[val]==0:
        del dic[val]
      dic[persuit-val]-=1
      if dic[persuit-val]==0:
        del dic[persuit-val]
    else:
      continue
print(ans)

Measured memory_bytes: 109780
import heapq


N,M = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
data = list(map(lambda x: x*(-1), data))
heapq.heapify(data)
#print(data)
while M != 0:
    x = heapq.heappop(data)*(-1)
    heapq.heappush(data,-1*(x//2))
    M -= 1
    #print(data)
 
print(-sum(data))

Measured memory_bytes: 14180