akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int INF = 1e9 + 239;
const int N = 2e5 + 7;

namespace Fenw {
	int f[N];

	void init() {
		fill(f, f + N, 0);
	}

	int get(int x) {
		int ans = 0;
		for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
			ans += f[i];
		}
		return ans;
	}

	void add(int x) {
		for (int i = x; i < N; i = i | (i + 1)) {
			f[i]++;
		}
	}
}

int solve_01(int n, vector<int> a) {
	vector<int> ps(n + 1);
	for (int i = 0; i < n; i++) {
		ps[i + 1] = ps[i] + a[i];
	}
	for (int i = 0; i <= n; i++) {
		ps[i] += n;
	}
	int ans = 0;
	Fenw::init();
	for (int i = 0; i <= n; i++) {
		ans += Fenw::get(ps[i] - 1);
		Fenw::add(ps[i]);
	}
	return ans;
} 

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int all = n * (n + 1) / 2;
	int need = all / 2;
	auto ch = [&](int x) {
		vector<int> na(n);
		for (int i = 0; i < n; i++) {
			if (a[i] >= x) {
				na[i] = -1;
			} else {
				na[i] = 1;
			}
		}
		return solve_01(n, na);
	};
	int l = 0;
	int r = INF;
	while (r - l > 1) {
		int m = (r + l) >> 1;
		if (ch(m) <= need) {
			l = m;
		} else {
			r = m;
		}
	}
	cout << l << endl;
}


Measured memory_bytes: 5008
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
d={}
s=0
for i in a:
    s+=i
    if i in d:
        d[i]+=1
    else:
        d[i]=1
q=int(input())
for _ in range(q):
    b,c=map(int,input().split())
    if b in d:
        x=d[b]
        s=s-b*x+c*x
        d[b]=0
        if c in d:
            d[c]+=x
        else:
            d[c]=x
    print(s)


Measured memory_bytes: 84192
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n, int k) {
        init(n + 121);
        auto F = [&](long long m) {
            return m * (m - 1) / 2;
        };
        auto C = [&](long long m) {
            return (n + n - m + 1) * m / 2;
        };

        vector<pair<long long, long long>> P;
        for (int i = k; i <= n + 1; ++i) {
            auto l = F(i);
            auto r = C(i);
            P.emplace_back(l, r);
        }
        sort(P.begin(), P.end());

        int m = P.size();
        long long res = 0;
        for (int i = 0; i < m; ++i) {
            auto l = P[i].first;
            auto r = P[i].second;
            // cout << i << " " << l << " " << r << endl;
            // while (i + 1 < m && P[i + 1].first <= r) {
            //     r = max(r, P[++i].second);
            // }
            res += (r - l + 1) % MOD;
        }
        res %= MOD;
        return res;
    }
private:
    const static long long MOD = 1e9 + 7;

    vector<long long> pow2;
    vector<long long> F;
    vector<long long> IF;

    long long norm(long long a) {
        a %= MOD;
        if (a < 0) {
            a += MOD;
        }
        return a;
    }

    long long inverse(long long a) {
        long long b = MOD;
        long long u = 0, v = 1;
        a = norm(a);
        while (a != 0) {
            long long d = b / a;
            b -= d * a;
            u -= d * v;
            swap(a, b);
            swap(u, v);
        }
        return norm(u);
    }

    long long powM(long long x, long long e) {
        long long res = 1;
        while (e > 0) {
            if (e & 1) {
                res = res * x % MOD;
            }
            x = x * x % MOD;
            e >>= 1;
        }
        return res;
    }

    void init(int n) {
        F.clear();
        F.resize(n + 1, 1);
        IF = F;
        pow2.clear();
        pow2.resize(n + 1, 1);
        for (int i = 1; i <= n; ++i) {
            pow2[i] = pow2[i - 1] * 2 % MOD;
        }

        for (int i = 1; i <= n; ++i) {
            F[i] = F[i - 1] * i % MOD;
        }
        IF[n] = inverse(F[n]);
        for (int i = n - 1; i > 0; --i) {
            IF[i] = IF[i + 1] * (i + 1) % MOD;
        }
    }

    long long nCr(int n, int r) {
        if (r < 0 || r > n) {
            return 0;
        }
        long long res = F[n] * IF[r] % MOD * IF[n - r] % MOD;
        return res;
    }

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int k;
    cin >> k;

    Solution sol;
    cout << sol.solve(n, k) << "\n";

    return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int k=0,m=0;
	bool flg=false;
	for(int i=1;i<=100000;++i){
		k+=i;
		if(k==n){
			flg=true;
			m=i;
			break;
		}
		if(k>n) break;
	}
	if(flg){
		vector<vector<int>> a(m+1,vector<int>(m));
		k=1;
		rep(i,m){
			for(int j=i;j<m;++j){
				a.at(i).at(j)=k;
				a.at(j+1).at(i)=k;
				k++;
			}
		}
		cout << "Yes" << endl;
		cout << m+1 << endl;
		rep(i,m+1){
			cout << m;
			rep(j,m){
				cout << " " << a.at(i).at(j);
			}
			cout << endl;
		}
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> pii;

const int N=2e5+5;
int sum[N],de[N],top;

inline int idx(int x){return lower_bound(de+1,de+top+1,x)-de;}
vector<int>vec[N];
vector<int>tr[N];
void add(vector<int>&tr,int i,int k){
    if(!i){
        tr[0]+=k;
        return;
    }
    while(i<tr.size()){
        tr[i]+=k;
        i+=i&-i;
    }
}
int ask(vector<int>&tr,int i){
    int re=0;
    if(i<0) return re;
    while(i>0){
        re+=tr[i];
        i-=i&-i;
    }
    return re+tr[0];
}


void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,k;cin>>n>>k;
    ll ans=0;
    for(int i=1;i<=n;i++){
        cin>>sum[i];
        sum[i]+=sum[i-1];
        sum[i]%=k;
        de[++top]=sum[i]-i;
    }
    de[++top]=0;
    sort(de+1,de+top+1);
    top=unique(de+1,de+top+1)-de-1;
    vec[idx(0)].push_back(0);
    for(int i=1;i<=n;i++){
        int j=idx(sum[i]-i);
        vec[j].push_back(sum[i]);
    }
    for(int i=1;i<=top;i++){
        sort(vec[i].begin(),vec[i].end());
        vec[i].erase(unique(vec[i].begin(),vec[i].end()),vec[i].end());
        tr[i].resize(vec[i].size(),0);
    }
    int j=idx(0);
    int t=lower_bound(vec[j].begin(),vec[j].end(),0)-vec[j].begin();
    add(tr[j],t,1);
    for(int i=1;i<=n;i++){
        int j=idx(sum[i]-i);
        int t=lower_bound(vec[j].begin(),vec[j].end(),sum[i])-vec[j].begin();
        if(t>0){
            ans+=ask(tr[j],t-1);
        }
        add(tr[j],t,1);
    }
    for(int i=1;i<=top;i++){
//        tr[i].resize(vec[i].size(),0);
        for(auto&x:tr[i]) x=0;
    }
    add(tr[j],tr[j].size()-t-1,1);
    for(int i=1;i<=n;i++){
        int j=lower_bound(de+1,de+top+1,sum[i]+k-i)-de;
        if(0<j&&j<=top&&de[j]==sum[i]+k-i){
            int t=upper_bound(vec[j].begin(),vec[j].end(),sum[i])-vec[j].begin();
            ans+=ask(tr[j],tr[j].size()-t-1);
        }
        j=idx(sum[i]-i);
        int t=lower_bound(vec[j].begin(),vec[j].end(),sum[i])-vec[j].begin();
        add(tr[j],tr[j].size()-t-1,1);
    }
    cout<<ans;
}


Measured memory_bytes: 23680
#include <stdio.h>
int main(void) {
    int a,b,c;
    int tmp;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    for( i = 1 ; i <= 2 ; i++ ){
        if( a > b ){
            tmp = a;
            a = b;
            b = tmp;
        }if( b > c ){
            tmp = c;
            c = b;
            b = tmp;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 1820
#include<stdio.h>
int main(){
 int a,b;

 scanf("%d %d",&a,&b);
 if(a>b){
  printf("a > b\n");
 } else if(a<b){
  printf("a < b\n");
 } else if(a==b){
  printf("a == b\n");
 }

 return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n, m;
    int ans = 0;
    char s[100][10];
    char t[100][10]; 

    scanf("%d", &n);
    for (int i = 0; n > i; i++) {
        scanf("%s", s[i]);
    }
    scanf("%d", &m);
    for (int i = 0; m > i; i++) {
        scanf("%s", t[i]);
    }
    for (int i = 0; n > i; i++) {
        int tmp = 0;
        for (int j = 0; n > j; j++) {
            if (0 == strcmp(s[i], s[j])) {
                tmp++;
            }
        }
        for (int j = 0; m > j; j++) {
            if (0 == strcmp(s[i], t[j])) {
                tmp--;
            }
        }
        if (tmp > ans) {
            ans = tmp;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, _) = scan!(i64, i64);
    let vs = scan!(u32;;);
    for i in n.. {
        let mut valid = true;
        for d in i.to_string().chars() {
            if vs.iter().any(|&v| v == d.to_digit(10).unwrap()) {
                valid = false
            }
        }
        if valid {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 4352
//                                  _                 ______   ______   ______   ______
//                                 | |               |  __  | |  __  | |  __  | |____  |
//    __ _   ____    _____    _  _ | |____           | |__| | | |__| | | |__| |      | |
//  / _` | |  __| /  __  |  / _` | |  __  |          |____  | |____  | |____  |      | |
// | (_| | | |    | |  | | | (_| | | |__| |  ______   ____| |  ____| |  ____| |      | |
//  \__,_| |_|    |_|  |_|  \__,_| |______| |______| |______| |______| |______|      |_|

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

#define ll long long
#define endl '\n'
#define REP(i, n) for(int i=0; i<n; i++)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9+7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
  // #endif
  FAST();
  //Code goes past here:

  ll a, b, m, i, small = 1e9+9;

  cin>>a>>b>>m;
  ll A[a], B[b];
  REP(i, a) cin>>A[i];
  REP(i, b) cin>>B[i];

  ll x, y, c;

  while(m--){
    cin>>x>>y>>c;
    if(A[x-1] + B[y-1] - c < small){
      small = A[x-1] + B[y-1] - c;
    }
  }
  sort(A, A+a);
  sort(B, B+b);

  if(small>A[0]+B[0])
        small = A[0]+B[0];
  cout<<small<<endl;
  return 0;
}


Measured memory_bytes: 1792
#! /usr/local/bin/python3
# coding: utf-8

n = int(input())

min_r = int(input())
max_margin = -1000000001

for i in range(n - 1):
    r = int(input())
    max_margin = max(r - min_r, max_margin)
    min_r = min(r, min_r)

print(max_margin)


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    string s,t;
    cin >> s >> t;
    VL sc(26,0),tc(26,0);
    for (int i = 0; i < s.size(); i++) {
        sc[s[i] - 'a']++;
        tc[t[i] - 'a']++;
    }
    SORT(sc);
    SORT(tc);
    for (int i = 0; i < 26; i++) {
        if (sc[i] != tc[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;


int main(){
    ll n, x, l, ans = 1, judge = 0;
    cin >> n >> x;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        cin >> l;
        v.push_back(l);
    }
    
    for (int i = 0; i < n; i++)
    {
        judge += v[i];
        if(judge > x) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto X = RD;
	auto T = RD;

	writeln((N+X-1)/X * T);
	stdout.flush;
	debug readln;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) B[A[i]-1]=i+1;
    //-----------------------------------
    rep(i,N) cout <<((i==0) ? "" : " ")<<B[i];
    cout <<endl;
    return (0);
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s, t;
  cin >> s >> t;

  int cnt = 0;
  REP(i,3){
    if(s[i] == t[i]){
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}



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

using namespace std;

int a, b, c, ans;

int main()
{
    cin >> a >> b >> c;
    if(b >= c) ans = b+c;
    else if(b < c)
    {
        ans += b*2;
        c -= b;
        ans += min(c, a+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//package  com.company;

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        if(Character.isUpperCase(s.charAt(0))) System.out.println("A");
        else System.out.println("a");
    }
}

Measured memory_bytes: 27040
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	int tower = 0;
	
	cin >> a >> b;
	
	for (int i = 1; i <= b - a; i++) {
		tower += i;
	}
	
	cout << tower - b << endl;
	
	return (0);
}

Measured memory_bytes: 256
n = gets.to_i
ab = []
n.times{ab << gets.split.map(&:to_i)}
ab.sort_by!{|e| e[1]}
(n-1).times{|i| ab[i+1][0] += ab[i][0]}
puts ab.all?{|e| e[0] <= e[1]} ? "Yes" : "No"

Measured memory_bytes: 22520
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    int n,i,j,x;
    in(n);
    vi v(n);
    read(v,i,n);
    x=0;
    i=0;
    while(i<n)
    {
        j=i+1;
        while(j<n && v[j-1]>=v[j])
            j++;
        x=max(x,j-i);
        i=j;
    }
    out(x-1);
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main(){
    int c[3][3]={0};
    for (int i=0;i<3;i++){
	for (int j=0;j<3;j++){
	    cin >> c[i][j];
	}
    }

    bool can=true;
    for (int i=0;i<2;i++){
	int a=c[i][0]-c[i+1][0];
	for (int j=1;j<3;j++){
	    if (a != (c[i][j]-c[i+1][j])) can=false;
	}
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
const ll infty = (ll)1e18*4 + 10;

int N, K;
ll x[100];
ll y[100];

set<ll> Sx, Sy;

int ok(int k, ll X0, ll X1, ll Y0, ll Y1) {
  if (X0 <= x[k] && x[k] <= X1 && Y0 <= y[k] && y[k] <= Y1) {
    return 1;
  }
  return 0;
}

int cnt(ll X0, ll X1, ll Y0, ll Y1) {
  int ans = 0;
  for (auto i = 0; i < N; ++i) {
    ans += ok(i, X0, X1, Y0, Y1);
  }
  return ans;
}

ll area(ll X0, ll X1, ll Y0, ll Y1) {
  if (cnt(X0, X1, Y0, Y1) >= K) {
    return (Y1 - Y0) * (X1 - X0);
  }
  return infty;
}

int main () {
  cin >> N >> K;
  for (auto i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
    Sx.insert(x[i]);
    Sy.insert(y[i]);
  }
  ll ans = infty;
  for (auto itx0 = Sx.begin(); itx0 != Sx.end(); ++itx0) {
    for (auto itx1 = itx0; itx1 != Sx.end(); ++itx1) {
      for (auto ity0 = Sy.begin(); ity0 != Sy.end(); ++ity0) {
        for (auto ity1 = ity0; ity1 != Sy.end(); ++ity1) {
          ans = min(ans, area(*itx0, *itx1, *ity0, *ity1));
        }
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(vector<A> v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int a_max = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a_max = max(a_max, a[i]);
  }
  vector<int> cnt(a_max + 1, 0);
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  vector<bool> grid(a_max + 1, 1);
  for (auto ai : a) {
    for (int j = ai + ai; j <= a_max; j += ai) {
      if (cnt[j] != 0) {
        grid[j] = 0;
      }
    }
  }
  debug(cnt, grid);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (cnt[a[i]] == 1 && grid[a[i]] == 1) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
  long long N,H;
  cin >> N >> H;
  
  vector<long long> V(N);
  for (long long i = 0; i < N; i++)
    cin >> V.at(i);
    
  if (H >= N)
    cout << 0 << endl;
  
  else {
    sort(V.begin(),V.end());
    long long ans = 0;
    for (long long j = 0; j < N - H; j++)
      ans += V.at(j);
    
    cout << ans << endl;
  }
      
}


Measured memory_bytes: 1792
#include <iostream>
#include <array>
using namespace std;
int main(){
	array<bool,31> submited;
	submited.fill(false);
	for (int i = 0; i < 28; i++) {
		int a;
		cin>>a;
		submited[a] = true;
	}
	for (int i = 1; i <= 30; i++)
		if(!submited[i])cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, D):
    if D[0] != 0:
        return 0
    C = Counter(D)
    if C[0] != 1:
        return 0
    ans = 1
    M = Mod(998244353)
    for i in range(max(D)):
        if C[i] == 0:
            return 0
        ans = M.mul(ans, M.pow(C[i], C[i+1]))
    return ans


def main():
    N = read_int()
    D = read_int_n()
    print(slv(N, D))


if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;

int main()
{
  int L, K;
  cin >> L >> K;

  int64 dp1[101] = {}, dp2[101] = {};
  dp2[0] = 1;
  int64 ret = 0;
  for(int i = 1; i <= L; i++) {
    dp1[i] += dp2[i - 1];
    dp2[i] += dp1[i - 1];
    if(i >= K) dp1[i] += dp2[i - K];
    ret += dp1[i];
  }
  cout << ret << endl;
}

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

using namespace std;

int N;
int P[201010], dp[201010];

int rec(int n) {
  if (dp[n] != 0) return dp[n];
  if (n == 0) return 1;
  if (P[n - 1] < P[n])
    return dp[n] = rec(n - 1) + 1;
  else
    return dp[n] = 1;
}

int main() {
  cin >> N;
  int x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    P[x - 1] = i;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, rec(i));
  }
  cout << N - ans << endl;

  return 0;
}

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

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type& r) {
		return min(l, r);
	}
};

class seg_node {
public:
	using M = RMQ;
	using T = typename M::type;
	using U = int;

	T get() const {
		if (!flag) return val;
		return lazy;
	}
	void update(U v) {
		if (!flag) {
			lazy = v;
			flag = true;
			return;
		}
		lazy = v;
	}
	bool is_updated() const {
		return flag;
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		val = get();
		flag = false;
	}
	void init(const seg_node& l, const seg_node& r) {
		val = M::op(l.val, r.val);
	}
	void init(const T& v) {
		val = v;
	}
	seg_node() : val(M::id()), flag(false) {}

public:
	T val;

private:
	U lazy;
	bool flag;

};

class segment_tree {
	using M = typename seg_node::M;
	using T = typename seg_node::T;
	using U = typename seg_node::U;
	const int h, n;
	vector<seg_node> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].val = M::op(data[node << 1].get(), data[(node << 1) | 1].get());
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		init();
	}
	segment_tree(int n_, T v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		for (int i = 0; i < n_; i++) {
			data[i + n].init(v1);
		}
		init();
	}
	segment_tree(const vector<T>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++) {
			data[i + n].init(data_[i]);
		}
		init();
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) {
			data[i].init(data[i << 1], data[(i << 1) | 1]);
		}
	}
	void update(int l, int r, U val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].get());
			if (r & 1) res2 = M::op(data[--r].get(), res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	segment_tree st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}



Measured memory_bytes: 6212
// Code by : h_mm 

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ull unsigned long long
#define ll long long
#define test ll t; cin>>t; while(t--)
using namespace std;

int main(void) {
    fast;
    float d, t, s;
    cin>>d>>t>>s;
    if((d/s) <= t) {
        cout<<"Yes";
    } else {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3716
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
char shima[13][13];
void tansaku(int x,int y){
	if(x<0||x>11||y<0||y>11||shima[y][x]=='0')
		return ;
	if(shima[y][x]=='1'){
		shima[y][x]='0';
	}
	tansaku(x+1,y);
	tansaku(x-1,y);
	tansaku(x,y+1);
	tansaku(x,y-1);
	
}
int main(){
	
	while(cin>>shima[0][0]){
	for(int i=0;i<12;i++){
		for(int j=0;j<12;j++){
			if(i==0&&j==0)
			continue;
			else
			cin>>shima[i][j];
		}
	}
		int a=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(shima[i][j]=='1'){
					tansaku(j,i);
					a++;
				}
			}
		}
		cout<<a<<endl;
	}
}

	

Measured memory_bytes: 1144
k,i,j,b[999];
main(n)
{
  for(;scanf("%d%d",&n,&k),n;puts(b[i]<0?"No":"Yes"))
    {
      for(i=0;i<k;)
	scanf("%d",&b[i++]);
      for(;n--;)
	for(j=0;j<k;b[j++]-=i)
	  scanf("%d",&i);
      for(i=0;i<k-1;i++)
	if(b[i]<0)break;
    }
  exit(0);      
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 main(){ 
    int n, m; cin >> n >> m;
    int res = (n + m)%24;
    cout << res << ln;
}


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

int cnt[100010];

int main(){
    int n;
    // scanf("%d", &n);
    cin >> n;
    int a[n];
    ll sum = 0;
    for(int i = 0;  i < n; i++){
        // scanf("%d", &a[i]);
        cin >> a[i];
        sum += a[i];
        cnt[a[i]]++;
    }
    int q, b, c;
    // scanf("%d", &q);
    cin >> q;
    for(int i = 0; i < q; i++){
        // scanf("%d%d", &b, &c);
        cin >> b >> c;
        // if(cnt[b]){
            sum += cnt[b]*(c-b);
            cnt[c] += cnt[b];
            cnt[b] = 0;
        // }
        // printf("%ld\n", sum);
        cout << sum << "\n";
    }
}


Measured memory_bytes: 4348
n = map(int,raw_input().split())
for i in range(0,3):
	for k in range(i,3):
		if n[i]>n[k]:
			temp = n[i]
			n[i] = n[k]
			n[k]= temp
for j in range(0,3):
	print str(n[j]),

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,a,b;
	cin >>n >>a >>b;
	cout << min(n*a, b) <<"\n";
	return 0;
}

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


int main() {
  int n; cin >> n;
  if(n%2==0)cout << 0.5 << endl;
  else cout << 1.0*(n/2+1)/n << endl;
  return 0;
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(pow(10, 7))

def dfs(v, c, parent):
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		if color[u] != -1:
			continue
		if w%2 == 0:
			dfs(u, c, v)
		else:
			dfs(u, 1-c, v)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, parent=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)

Measured memory_bytes: 79408
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n, k;
  cin >> n >> k;

  vll csum(n + 1, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    csum[i + 1] = csum[i] + a;
  }

  vll bs;
  repLRE(i, 0, n - 1) {
    repLRE(j, i + 1, n) { bs.push_back(csum[j] - csum[i]); }
  }

  ll const blmax = 50;

  rrepLRE(i, blmax, 0) {
    vll nxt;
    rep(j, (ll)bs.size()) {
      if (bs[j] >> i & 1) nxt.push_back(bs[j]);
    }
    if (k <= (ll)nxt.size()) bs = nxt;
  }
  ll ans = (1LL << blmax) - 1;
  rep(i, (ll)bs.size()) ans &= bs[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int n;
	int a = 0;
	int b = 0;
	cin >> n;
	int ans = 0;
	rep0(i, n) {
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,a,b,n,c,y,m,prev,sum,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n;
       ans=-1;
       int arr[100007];
       memset(arr,0,sizeof(arr));
       for(i=1;i<=n;i++)
       {
           cin>>a;
           arr[a]++;
       }
       for(i=0;i<=100000;i++)
       {
           if(arr[i]+arr[i+1]+arr[i+2]>ans)
           {
               ans=arr[i]+arr[i+1]+arr[i+2];
           }
       }
       cout<<ans;
    }
}

Measured memory_bytes: 640
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    int i,j,n,m,k,a,b,c,d,w,r=0,l,t;
    //double d;
    char s[262144];
    scanf("%d%d%d%d",&a,&b,&c,&d);
    //l=strlen(s);
    //for(i=0;i<n;i++){scanf("%d",&a[i]);}
    //qsort(a,n,sizeof(int),sortfncsj);
    printf("%d\n",min(a,b)+min(c,d));
    return 0;
}

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

ll f(ll n) { return n*(n+1)/2;}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  // vector<int> d(n+1);
  for (int i = 1; i <= n; i++) {
    // for (int j = i; j <= n; j += i) d[j]++;
    ll r = n/i;
    ans += f(r)*i;
  }
  // for (int i = 1; i <= n; i++) ans += ll(i)*d[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<ll> a, sum;
auto dp = make_vec<ll>(0, 0);
const ll inf = 5e18;
// dp[l][r] = minimum cost to merge from a[l] to a[r-1].
ll rec(int l, int r) {
    if (r - l == 1) return 0;
    if (r - l == 2) return a[l] + a[r-1];
    ll &res = dp[l][r];
    if (res != inf) return res;
    for (int i = l+1; i < r; ++i) {
        chmin(res, rec(l, i) + rec(i, r) + sum[r] - sum[l]);
    }
    return res;
}

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

    int n;
    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sum.resize(n+1);
    rep(i, n) sum[i+1] = sum[i] + a[i];
    dp.resize(n+1, vector<ll>(n+1, inf));
    cout << rec(0, n) << endl;
}


Measured memory_bytes: 4488
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

vector<int> v(105);
vector<bool> dp(100005, false);

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    for(int i = 1; i <= k; i++)
        for(int j = 0; j < n; j++)
            if(i-v[j] >= 0 && !dp[i-v[j]])
                dp[i] = true;
    cout << (dp[k] ? "First" : "Second") << endl;
}

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

int digit_sum(string s) {
  int ans = 0;
  rep(i, s.size()) ans += s[i] - '0';
  return ans;
}

int main() {
  string s, t;
  cin >> s;
  t = s;
  rep(i, t.size() - 1) { t[i + 1] = '9'; }

  int ans = digit_sum(t);
  if (s == t) {
    cout << ans << endl;
  } else {
    cout << ans - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s,t;
    cin >> s;
    cin >> t;
    int ok=0;
    for(int i=0;i<s.length();i++){
        s.insert(0,1,s[s.length()-1]);
        s.erase(s.end()-1);
        if(s==t){
            ok=1;
            cout << "Yes" << endl;
            break;
        }
    }
    if(ok==0){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256