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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int n; cin >> n;
    v<int> b(n); rep(i,n-1) cin >> b[i];
    b[n-1] = INF;

    int ans = 0;
    rep(i,n) {
        if (i) ans += min(b[i], b[i-1]);
        else ans += b[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
//#define mod 1000000007
#define PI acos(-1.0)
//const long long MAX=200005;
typedef long long ll;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int n,m,t=0;
char s[100005];
int a[100],b[100];
int MIN=24,MAX=24;
int main()
{
    a[0]=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(n==1)
    {
        printf("%d\n",a[1]);
        return 0;
    }
    sort(a+1,a+n+1);
    for(int i=n;i>0;i--)
    {
        if(i%2==0)
        b[i]=24-a[i];
        else b[i]=a[i];
    }
    b[0]=0;
    sort(b,b+n+1);
    for(int i=1;i<=n;i++)
    {
        if(b[i]-b[i-1]<MIN)
            MIN=b[i]-b[i-1];
    }
    printf("%d\n",MIN);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  ll K;
  cin >> s >> K;
  set<string> subs;
  for (int i = 0; i < s.size(); i++) {
    for (int j = min(K, (ll)s.size() - i); j > 0; j--) {
      subs.insert(s.substr(i, j));
    }
  }
  int cnt = 1;
  for (auto str : subs) {
    if (cnt == K) cout << str << endl;
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll mod = 1e9 + 7;
ll h, w;
char a[1009][1009];
ll dp[1009][1009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> h >> w;
    for(ll i = 1; i <= h; ++i)
        for(ll j = 1; j <= w; ++j)
            cin >> a[i][j];
    for(ll i = 1; i <= h; ++i)
        for(ll j = 1; j <= w; ++j){
            if(a[i][j] == '#')
                continue;
            else if(i == 1 && j == 1)
                dp[i][j] = 1;
            else
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }
    cout << dp[h][w] << "\n";
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vvpii = vector<vector<pair<int, int>>>;
using pll = pair<ll, ll>;
using vpll = vector<pair<ll, ll>>;
using vvpll = vector<vector<pair<ll, ll>>>;

int main()
{
    int N;
    cin >> N;

    vvpii talk(N);

    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;

        for (int j = 0; j < a; j++)
        {
            int x, y;
            cin >> x >> y;
            talk[i].push_back(make_pair(--x, y));
        }
    }

    int ans = 0;

    for (int i = 0; i < (1 << N); i++)
    {
        bitset<15> bit(i);
        bool break_flag = false;

        for (int j = 0; j < N; j++)
        {
            for (auto z : talk[j])
            {
                int x = z.first, y = z.second;

                if (bit.test(j) == 1)
                {
                    if (bit.test(x) != y)
                    {
                        break_flag = true;
                        break;
                    }
                }
            }
        }

        if (!break_flag)
        {
            int cnt = bit.count();
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "Even" << endl;
	} else {
		cout << "Odd" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define Iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

char s[200005];

int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s);

	int rnum = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'R')
			rnum++;

	int change = 0;
	for (int i = 0; i < rnum; i++)
		if (s[i] == 'W')
			change++;

	printf("%d", change);
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> hp(n);
    for (int i=0; i<n; i++) {
        cin >> hp[i];
    }
    sort(hp.begin(), hp.end());
    long long ans = 0;
    for (int i=0; i<n-k; i++) {
        ans += hp[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
x, k, d = map(int, input().split())
t = abs(x) // d
a = []
a.append(t - 3)
a.append(t - 2)
a.append(t - 1)
a.append(t)
a.append(t + 1)
a.append(t + 2)
a.append(t + 3)
b = []

for i in a:
    b.append(-i)
for i in b:
    a.append(i)

a.append(k)
a.append(k - 1)
a.append(-k)
a.append(-k + 1)

res = abs(x)
if k % 2:
    res += d
for i in a:
    if i % 2 == k % 2 and abs(i) <= k:
        res = min(res, abs(x - i * d))
print(res)

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int n,k; scanf("%d%d",&n,&k);
   vector<int> a(n);
   rep(i,0,n)scanf("%d",&a[i]);
   vector<double> b(n+1,0);
   rep(i,0,n)b[i+1]=(a[i]+1)/2.0;
   rep(i,0,n)b[i+1]+=b[i];
   double res=0;
   rep(i,0,n-k+1)chmax(res,b[i+k]-b[i]);
   printf("%.12f\n",res);
   return 0;
}

Measured memory_bytes: 2560
use std::io;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    r.read_line();
    let mut lens: Vec<u64> = r.read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    lens.sort();

    let mut count = 0;
    for ci in 2..(lens.len()) {
        let c = lens[ci];
        for ai in 0..(ci - 1) {
            let a = lens[ai];
            for bi in (ai + 1)..ci {
                let b = lens[bi];
                if a + b > c {
                    count += 1;
                }
            }
        }
    }

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

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

class Prime {
public:
    Prime(ll n) {
        mPrimeTbl.clear();
        vector<bool> u(n, false);
        for (ll i = 2; i <= n; ++i) {
            if (u[i])
                continue;
            mPrimeTbl.push_back(i);
            for (ll p = i; p <= n; p += i)
                u[p] = true;
        }
    }

    ~Prime() {}

    ll num() {
        return static_cast<ll>(mPrimeTbl.size());
    }

    ll get(ll index) {
        return mPrimeTbl[index];
    }

private:
    vector<ll> mPrimeTbl;
};

bool P[100005];
ll S[100005];

int main() {
    Prime p(100005);
    memset(P, 0, sizeof(P));
    memset(S, 0, sizeof(S));
    REP(i, p.num()) {
        ll n = p.get(i);
        P[n] = true;
        if (P[(n + 1) / 2])
            S[n]++;
    }

    REP(i, 100002) {
        S[i + 1] += S[i];
    }

    ll Q;
    cin >> Q;
    REP(_, Q) {
        ll l, r;
        cin >> l >> r;
        cout << S[r] - S[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin >> s;
    bool ok1 = 0, ok2 = 0;
    if("01" <= s.substr(0,2) && s.substr(0,2) <= "12") ok1 = 1;
    if("01" <= s.substr(2,2) && s.substr(2,2) <= "12") ok2 = 1;

    if(ok1 && ok2) cout<<"AMBIGUOUS"<<endl;
    else if(ok1) cout<<"MMYY"<<endl;
    else if(ok2) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;

    return 0;
}

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

using namespace std;

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

    sort(a, a+n, greater<int>());

    long long res = 0;
    int m = (n+1) / 2 - 1; 
    for(int i = 0; i < m; i++) {
        res += a[i];
    }
    for(int i = 0; i < m; i++) {
        res += a[i+1];
    }
    if(n % 2 == 0) {
        res += a[m];
    }

    cout << res << endl;
}

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

template<typename T>
class PriorityQueue{
private:
	vector<T> d;
public:
	void push(T t){
        int k = d.size();
		d.push_back(t);
        while(k && d[(k - 1) / 2] < d[k]){
            swap(d[(k - 1) / 2], d[k]);
            k = (k - 1) / 2;
        }
	}
    T top(){
        // assert(d.size() > 0);
        return d[0];
    }
    void pop(){
        // assert(d.size() > 0);
        d[0] = d.back();
        d.pop_back();
        maxHeapify(0);
    }
	void maxHeapify(int k){
		int l = 2 * k + 1;
		int r = 2 * k + 2;
		T largest;
		if(l < d.size() && d[l] > d[k]) largest = l;
		else largest = k;

		if(r < d.size() && d[r] > d[largest]) largest = r;

		if(largest != k){
			swap(d[k], d[largest]);
			maxHeapify(largest);
		}
    }
	void printHeap(){
		for(int i = 0; i < d.size(); i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
};

int main(){
    PriorityQueue<int> pq;
    while(1){
        string s;
        cin >> s;
        if(s == "end") break;
        if(s == "insert"){
            int a;
            cin >> a;
            pq.push(a);
        }else{
            cout << pq.top() << endl;
            pq.pop();
        }
        // pq.printHeap();
    }
}

Measured memory_bytes: 7076
#include<bits/stdc++.h> 
using namespace std;
int fir(int n){
	while(n){
		if(n<10) return n;
		n/=10;
	} 
}
int main(){
	int n,m,ans=0,num[10][10]={0};
	cin>>n;
	for(int i=1;i<=n;i++){
		int a=fir(i),b=i%10;
		num[a][b]++;
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++)
		ans+=num[i][j]*num[j][i];
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	p := readInt()
	fmt.Println(((a * 3) + p) / 2)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main() {
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;

    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int ans = x;

    rep(i, n) {
        
        int j = 0;

        while(j*a[i] + 1 <= d) {
            ans++;
            j++;
        }

    }

    cout << ans << endl;

  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << "\n";
}

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

typedef long long ll;
const int maxn = 100005;
typedef pair<int, int>par;
const ll mod = 1e9+7;

int n, m, q;
int aa[1000], a[maxn], b[maxn], c[maxn], d[maxn];

ll sol = 0;
void getsol(){
    ll sum = 0;
    for( int i = 1; i <= q; i++ ){
        if( aa[b[i]] - aa[a[i]] == c[i] )
            sum += d[i];
    }

    sol = max(sol, sum);
}
void recurse( int pos, int last ){
    if( pos == n+1 ){
        getsol();
        return;
    }

    for( int i = last; i <= m; i++ ){
        aa[pos] = i;
        recurse(pos+1, i);
        aa[pos] = 0;
    }
}


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm



    cin >> n >> m >> q;


    for( int i = 1; i <= q; i++ )
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    recurse(1, 1);

    cout << sol << "\n";
    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<queue>
#include<string>
#include<cstring>


using namespace std;
typedef long long LL;
const int maxn=1e6+7;
LL n;
LL tot=0;
LL mn=0x3f,mx=-0x3f;
LL a[maxn];
LL bit[maxn];

struct node {
LL val,pos;
}arr[maxn];

bool cmp(node n1,node n2)
{
    return n1.val==n2.val?n1.pos<n2.pos:n1.val<n2.val;
}

void update(LL x,LL val)
{
    for(; x< maxn ;x+=(x & -x))
    {
        bit[x]+=val;
    }
}

LL getsum(LL x)
{
    LL ans=0;
    for(;x>0;x-=(x & -x))
    {
        ans += bit[x];
    }
    return ans;
}



bool check(LL x){
    memset(bit,0,sizeof(bit));
     memset(arr,0,sizeof(arr));


	for(int i=1;i<=n;i++)
    {
        if(a[i]<=x)arr[i].val=-1;
        else arr[i].val=1;
        arr[i].pos=i+1;
    }

    arr[0].val=-1;
	arr[0].pos=1;

	for(int i=1;i<=n;i++)
	arr[i].val+=arr[i-1].val;
	sort(arr,arr+n+1,cmp);

	LL ans=0;
	for(int i=0;i<=n;i++)
    {
        ans+=(i-getsum(arr[i].pos));
        update(arr[i].pos,1);
    }
	return ans*2 > tot;
}


int main(){
   scanf("%lld",&n);

   for(int i=1;i<=n;i++)
    {
   	 scanf("%lld",&a[i]);
   	 mn=min(mn,a[i]);
   	 mx=max(mx,a[i]);
   	 tot+=i;
   }

   LL l=mn,r=mx;
   while(r-l>1)
    {
   	  LL mid=(l+r)/2;
   	 if(check(mid)) r=mid;
   	 else l=mid;
   	 //printf("s%d",mid);
   }
   printf("%lld\n",r);

   return 0;
}


Measured memory_bytes: 24832
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

class OrderedSet:
    def __init__(self,a):
        self.c = {}
        self.a_sort = sorted(list(set(a)))
        for i,a in enumerate(self.a_sort):
            self.c[a] = i + 1
        self.r = {v: k for k, v in self.c.items()}
        self.size = len(self.c)
        self.tree = [0]*(self.size + 1)
        self.num = [0]*self.size
        self.all_count = 0  # 全要素数

    # BITのsum関数
    def _sum(self,index):
        s = 0
        while index:
            s += self.tree[index]
            index -= index & (-index)
        return s

    # xをk個挿入する
    def insert(self,x,k=1):
        index = self.c[x]
        self.num[index-1] += k
        while index <= self.size:
            self.tree[index] += k
            index += index & (-index)
        self.all_count += k
    
    # xをk個削除する
    def erase(self,x,k=1):
        self.insert(x,k=-k)

    # 格納しているxの数を返す
    def count(self,x):
        return self.num[self.c[x]-1]

    # 下から数えてk番目の要素を返す（要素がk個未満のときNoneを返す）
    def get_kth_bottom(self,k):
        if k <= 0:
            return None
        elif self.all_count < k:
            return None
        else:
            i = 0
            s = 0
            step = 1 << (self.size.bit_length() - 1)
            while step:
                if i+step <= self.size and s+self.tree[i+step] < k:
                    i += step
                    s += self.tree[i]
                step >>= 1
            return self.r[i+1]
    
    # 上から数えてk番目の要素を返す（要素がk個未満のときNoneを返す）
    def get_kth_top(self,k):
        return self.get_kth_bottom(self.all_count-k+1)
    
    # x以上の最小要素を返す
    def lower_bound(self,x):
        p = bisect_left(self.a_sort,x)
        if p == 0:
            k = 1
        else:
            k = self._sum(p) + 1
        return self.get_kth_bottom(k)
    
    # x以下の最大要素を返す
    def upper_bound(self,x):
        p = bisect_right(self.a_sort,x)
        if p == 0:
            return None
        else:
            k = self._sum(p)
            return self.get_kth_bottom(k)

N = I()
P = LI()

places = [0]*(N+1)
for i in range(N):
    places[P[i]] = i+1

s = OrderedSet(P)
ans = 0
for i in range(1,N+1)[::-1]:
    p = places[i]
    c = s.lower_bound(p)
    d = None if c is None else s.lower_bound(c+1)
    b = s.upper_bound(p)
    a = None if b is None else s.upper_bound(b-1)
    
    a = a if a is not None else 0
    d = d if d is not None else N+1

    if b is None:
        if c is not None:
            ans += i*p*(d-c)
    elif c is None:
        ans += i*(b-a)*(N-p+1)
    else:
        ans += i*((b-a)*(c-p)+(p-b)*(d-c))

    s.insert(p)

print(ans)

Measured memory_bytes: 85400
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


void func()
{
	int64_t X;
	cin >> X;

	int64_t ans = 0;
	int64_t gankin = 100;
	while (gankin < X)
	{
		gankin += gankin/100;
		ans++;
	}
	cout << ans << endl;

}

int main() {

//	while (1)
		func();
	return 0;
}


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

using namespace std;

int main() {
    uint64_t N, C, K;
    cin >> N >> C >> K;
    vector<uint64_t> T(N);
    for (uint64_t& t : T) {
        cin >> t;
    }
    sort(T.begin(), T.end());
    
    uint64_t num_buses = 0;
    uint64_t time_limit = T[0] + K;
    uint64_t num_people = 0;
    
    for (uint64_t i = 0; i < N; i++) {
        if (T[i] <= time_limit && num_people < C) {
            num_people++;
        } else {
            num_buses++;
            num_people = 1;
            time_limit = T[i] + K;
        }
    }
    if (num_people > 0) {
        num_buses++;
    }
    cout << num_buses;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

  int a, b; cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << (d1 + 1 != d2) << endl;
  return 0;
}


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

using namespace std;

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

    if (s.size() == 2) {
        cout << s << endl;
    } else {
        for (auto it = s.rbegin(); it != s.rend(); it++) {
            cout << *it;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;
namespace solver{void solve();} int main() { solver::solve(); return 0; }

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

namespace solver {
string s;
char ops[3] = {'+','-','*'};
int priority[3];
int turn;
typedef string::const_iterator Iter;
Iter it;

void consume(char e) {
  assert(*it == e);
  it ++;
}

bool isconsume(char e) {
  if(*it == e) {
    consume(e);
    return true;
  }
  return false;
}

ll number() {
  assert(isdigit(*it));
  Iter end = s.end();
  stringstream ss(string(it, end));
  ll x; ss >> x;
  int size = to_string(x).size();
  while(size --) it++;
  return x;
}

// 1. solve operator priority
ll expr(int p) {
  if(p == 3) {
    if(isconsume('(')) {
      ll r = expr(0);
      consume(')');
      return r;
    }
    return number();
  }

  ll r = expr(p + 1);

  // 2. solve operator associativity
  auto condition = [&]() { return find(ops, ops+3, *it)-ops < 3 && priority[find(ops, ops+3, *it)-ops] == p; };

  while(condition())
    if(isconsume('+')) r += expr(p + 1);
    else if(isconsume('-')) r -= expr(p + 1);
    else if(isconsume('*')) r *= expr(p + 1);
    
  return r;
}

ll calc() {
  it = s.begin();
  ll r = expr(0);
  assert(it == s.end());
  return r;
}

bool set_piority() {
  int a = 0;
  rep(i, 3) rep(j, 3) rep(k, 3) {
    if(a++ == turn) {
      turn ++;
      priority[0] = i;
      priority[1] = j;
      priority[2] = k;
      return true;
    }
  }
  return false;
}

void solve() {

  cin >> s;
  ll ans = std::numeric_limits<ll>::min();
  while(set_piority())
    ans = max(ans, calc());
  cout << ans << endl;
}

}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 100005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    map < ll , ll > m;
    vector < ll > v;
    f(i, n)
    {
        ll x;
        cin >> x;
        m[x]++;
        if(m[x] == 2)
        {
            v.pb(x);
        }
    }
    if(v.size() < 2)
    {
        cout << "0\n";
        return 0;
    }
    s(v);
    r(v);
    ll ans;
    if(m[v[0]] >= 4) ans = v[0] * v[0];
    else ans = v[0] * v[1];
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string a="CODEFESTIVAL2016";
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(a[i]!=s[i])c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] ss = line.split(" ");
		int[] num = new int[ss.length];
		for (int i = 0; i < ss.length; i++) {
			num[i] = Integer.parseInt(ss[i]);
		}
		int w = num[0];
		int h = num[1];
		int x = num[2];
		int y = num[3];
		int r = num[4];
		if (x < r || y < r || x + r > w || y + r > h) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 26276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

set<ll>S[256];

int main(){

    string s, t;
    cin >> s >> t;
    for(ll i = 0; i < s.size(); i++){
        S[s[i]].insert(i + 1);
    }

    ll tmp = 0;
    ll idx = 0;
    for(ll i = 0; i < t.size(); i++){
        if(S[t[i]].empty()){
            cout << "-1" << endl;
            return 0;
        }
        set<ll>::iterator it = S[t[i]].upper_bound(idx);
        if(it == S[t[i]].end()){
            tmp += s.size();
            it = S[t[i]].upper_bound(0);
        }
        idx = *it;
    }
    cout << tmp + idx << endl;

    return 0;
}

Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val (dt, g) = readLine()!!.split(' ').map(String::toLong)
    val d = dt.toInt()
    val pArray = Array(d + 1) { arrayOfNulls<Long>(101) }
    val scoreArray = Array<Long?>(1001) { null }
    scoreArray[0] = 0L
    for (i in 1..d) {
        val (p, c) = readLine()!!.split(' ').map(String::toLong)
        for (j in 1..p.toInt()) {
            pArray[i][j] = (i.toLong() * 100) * j
            if (j == p.toInt()) pArray[i][j] = pArray[i][j]!! + c
        }
    }

    for (i in 1..d) {
        var selectNum = 1
        val scoreArrayBefore = scoreArray.copyOf()
        while (selectNum != 101 && pArray[i][selectNum] != null) {
            for (k in 1..1000) {
                if (selectNum > k) continue
                val value = scoreArrayBefore[k - selectNum] ?: break
                if (scoreArray[k] == null ||
                        scoreArrayBefore[k] ?: 0 < (value + pArray[i][selectNum]!!)) {
                    scoreArray[k] = value + pArray[i][selectNum]!!
                }
                if (scoreArray[k] ?: 0 >= g) break
            }
            selectNum++
        }
    }
    for (i in 1..1000) {
        if (scoreArray[i] ?: 0 >= g) {
            println(i)
            break
        }
    }
}

Measured memory_bytes: 38668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if (k < a){
    cout << k;
  }else if (k < a + b){
    cout << k;
  }else{
    cout << a - (k-a-b);
  }
}

  

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int>vec(N);
    
    for (int i = 0; i < N; i++) {
        cin>>vec.at(i);
    }
    
    sort(vec.begin(),vec.end(),std::greater<int>());
    int alice_sum = 0;
    int bob_sum = 0;
    for (int i = 0; i < N; i++) {
        if(i%2 == 0){
        alice_sum += vec.at(i);
        }
        else{
            bob_sum += vec.at(i);
        }
    }
    cout<<alice_sum-bob_sum<<endl;
    
    return 0;
    }




Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.math.BigInteger
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val h = sc.nextInt()
    val w = sc.nextInt()
    val n = sc.nextInt()
    val r = sc.nextInt()
    val c = sc.nextInt()
    val s = sc.nextLine()
    val t = sc.nextLine()
    var left = 0
    var right = 0
    var up = 0
    var down = 0
    var ok = true
    for (i in 0 until n) {
        if (s[i] == 'L') left++
        if (s[i] == 'R') right++
        if (s[i] == 'U') up++
        if (s[i] == 'D') down++

        if (c - left <= 0) {
            ok = false
        }
        if (c + right > w) {
            ok = false
        }
        if (r - up <= 0) {
            ok = false
        }
        if (r + down > h) {
            ok = false
        }

        if (t[i] == 'L' && c + right - 1 > 0) right--
        if (t[i] == 'R' && c - left + 1 < w) left--
        if (t[i] == 'U' && r + down - 1 > 0) down--
        if (t[i] == 'D' && r - up + 1 < h) up--
    }
    println(if (ok) "YES" else "NO")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  while (a >= b)
  {
    b *= 2;
    k--;
  }
  while (b >= c)
  {
    c *= 2;
    k--;
  }

  if (k >= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n;
    cin >> n;
    vector<pp> a(n-1);
    map<pp,int> m;
    vector<vector<int>> e(n+1,vector<int>(0));
    int ans=0;
    rep(i,n-1){
        cin >> a[i].first >> a[i].second;
        e[a[i].first].push_back(a[i].second);
        e[a[i].second].push_back(a[i].first);
    }
    vector<int> b(n+1,0);
    b[1]=1;
    queue<pp> q;
    q.push(mk(1,0));
    while(!q.empty()){
        int f=q.front().first,g=q.front().second;
        q.pop();
        int k=1;
        rep(i,e[f].size()){
            if (b[e[f][i]]==0){
                b[e[f][i]]=1;
                if (k==g) k++;
                m[mk(f,e[f][i])]=k;
                q.push(mk(e[f][i],k));
                ans=max(k,ans);
                k++;
            }
        }
    }
    cout << ans << endl;
    rep(i,n-1){
        cout << m[mk(a[i].first,a[i].second)] << endl;
    }
}


Measured memory_bytes: 13440
#include    <bits/stdc++.h>
#define     ll long long
#define     ull unsigned long long
#define     ld long double
#define     prec(k) fixed << setprecision(k)
#define     up(i, k, n) for (int i = k ; i < n ; i ++)
#define     down(i, k, n) for (int i = k ; i >= n ; i --)
#define     ii pair<int, int>
#define     pll pair <ll, ll>
#define     X first
#define     Y second
#define     str basic_string <int>
#define     QuanPham
const int maxN = (int) 1e4 + 7;
const int maxM = (int) 2e5 + 7;
const int maxT = (int) 1e6 + 7;

using namespace std;

int c[maxM], p[maxM], n, cnt, t; vector<int> pos[26];
string s;
ll ans;

void update(int x)
{
	for ( ; x <=n ; x += x & -x) c[x] ++;
}

int query(int x)
{
	int res = 0;
	for ( ; x > 0 ; x -= x & -x) res += c[x];
	return res;
}

int main()
{
	#ifdef QuanPham
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen ("C.INP", "r", stdin);
    //freopen ("C.OUT", "w", stdout);

	cin >> s;
	n = s.length();
	s = ' ' + s;
	up(i, 1, n + 1) pos[s[i] - 'a'].push_back(i);
	up(i, 0, 26)
	{
		int m = pos[i].size(), a = 0, b = m - 1;
		cnt += (m & 1);
		if (cnt >= 2) return cout << -1, 0;
		while (a <= b) p[pos[i][a]] = pos[i][b], a ++, b --;
	}

	up(i, 1, n + 1)
	if (p[i] && p[i] != i) ans += query(p[i]) + query(i), update(p[i]);
	else if (p[i] == i) t = i;

	if (n & 1)
	up(i, 1, n + 1)
	if (p[i])
	if (i < t && p[i] < t || i > t && p[i] > t) ans ++;

	cout << ans;

	#ifdef QuanPham
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int main(){
	fastio;
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R')cnt++;
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  string S , S1 ;
  cin >> S >> S1 ;
  string W = S+S1;
  int A = stoi(W) ;
  for(int i = 1 ; i*i <= 100100 ; i++ ){
    if(i*i == A ){
      cout << "Yes" << endl;
      return 0 ;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn gcd(a: i64, b: i64) -> i64 {
  if a % b == 0 {
    b
  } else {
    gcd(b, a % b)
  }
}

fn lcm(a: i64, b: i64) -> i64 {
  a * b / gcd(a, b)
}

fn main() {
  let n = read::<i64>();
  let mut csf: Vec<Vec<i64>> = vec![];
  for _ in 0..n - 1 {
    let c = read::<i64>();
    let s = read::<i64>();
    let f = read::<i64>();
    csf.push(vec![c, s, f]);
  }

  for i in 0..n - 1 {
    let mut total = 0;
    for j in i..n - 1 {
      let j_size = j as usize;
      if total < csf[j_size][1] {
        total = csf[j_size][1];
        total += csf[j_size][0];
      } else {
        total += csf[j_size][2]
          - if (total % csf[j_size][2]) != 0 {
            (total % csf[j_size][2])
          } else {
            csf[j_size][2]
          };
        total += csf[j_size][0];
      }
    }
    println!("{}", total);
  }
  println!("{}", 0);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
	int A, B;
  	cin >> A >> B;
  	int n = 0;
 	for(int i = A; i <= B; i++){
    	int s = i / 10000;
      	int t = i % 10;
      	int u = (i - s * 10000) / 1000;
      	int v = i / 10 % 10;
      	if(s == t && u == v){
          	n++;
        }
    }
  	cout << n;
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#define MAXN 50
using namespace std;
int A, B;

void solve() {
	cin >> A >> B;
	if(A%3==0 || B %3 ==0|| (A+B)%3==0){
		printf("Possible\n");
	}
	else printf("Impossible\n");
}



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


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	
	string s;
	int k,n;
	cin >> n;
	cin >> k;
	cin >> s;
	--k;
	if (s[k] == 'A')s[k] = 'a';
	if (s[k] == 'B')s[k] = 'b';
	if (s[k] == 'C')s[k] = 'c';
	PRI(s);
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
    int n;
    //cout << "here" << endl;
    cin >> n;
    vec<vec<vec<double>>> dp(302, vvec<double>(302, vec<double>(302, 0)));
    int num[3] = {0, 0, 0};
    rep(i, n) {
        int a; cin >> a;
        num[a-1]++;
    }
    //cout << "here" << endl;
    rep(k, n+1) rep(j, n+1) rep(i, n+1) {
        double d = 0.0;
        //cout << "here1" << endl;
        if (i == 0 && j == 0 && k == 0) continue;
        if (i>0) d += i * dp[i-1][j][k];
        if (j>0) d += j * dp[i+1][j-1][k];
        if (k>0) d += k * dp[i][j+1][k-1];
        dp[i][j][k] = (d + n) / (1.0*(i + j + k));
    }
    cout << setprecision(10) << dp[num[0]][num[1]][num[2]] << endl;
    return 0;
}

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

//define of gcd and lcm//
int gcd(long long int a,long long int b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

char c[510][510];
int dd[510][510];
char tr[] = {'R', 'G', 'B', 'Y'};
int n, m, d;


int main() {
	scanf("%d%d%d", &n, &m, &d);
	if (d % 2 == 1) {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				if ((i + j) % 2 == 0)
					c[i][j] = 'R';
				else
					c[i][j] = 'G';
	}else {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				dd[i][j] += (i + j) / d % 2;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				dd[i][j] += (j - i + n) / d % 2 * 2;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				c[i][j] = tr[dd[i][j]];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			printf("%c", c[i][j]);
		printf("\n");
	}
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,j,k,l,x,y,z,n,count=0,f[10010]={};
    scanf("%d",&n);
    for(l=1; l<=n; l++){
        for(i=1; i<sqrt(1.0*l); i++){
            for(j=i; j<sqrt(1.0*l); j++){
                for(k=j; k<sqrt(1.0*l); k++){
                    if(i*i+j*j+k*k+i*j+j*k+k*i==l){
                        if(i!=j && j!=k && k!=i)f[l]+=6;
                        else if(i==j && j==k)f[l]++;
                        else{f[l]+=3;}
                    }
                }
            }
        }
    }
    for(i=1; i<=n; i++){
        printf("%d\n",f[i]);
    }
    return 0;
}

Measured memory_bytes: 2056
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, m, mx, cnt;
	string s[100], t[100];
	cin >> n;
	lp(n)
		cin >> s[i];
	cin >> m;
	lp(m)
		cin >> t[i];
	mx = 0;
	lp(n) {
		cnt = 0;
		lop(n, j) {
			if (s[i] == s[j])cnt++;
		}
		lop(m, k) {
			if (s[i] == t[k])cnt--;
		}
//		cout << i << ' ' << s[i] << ' ' << cnt << endl;
		mx = max(cnt, mx);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256