akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  string S_t = S;
  reverse(S.begin(),S.end());
  if(S == S_t){
    string T = S.substr(0,int(S.size())/2);
    string T_t = T;
    reverse(T.begin(),T.end());
    if(T == T_t){
      string R = S.substr((S.size()+3)/2-1);
      string R_t = R;
      reverse(R.begin(),R.end());
      if(R == R_t){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,k;
	cin>>n>>k;
	int a[2010]={};
	int cnt[2010]={};
	LL ans=0;
	FOR(i,0,n){
		cin>>a[i];

	}
	FORD(i,n,0){
		FOR(j,0,a[i]){
			ans=add(mul(cnt[j],k),ans);
		}
		cnt[a[i]]++;
	}
	FOR(i,1,2001){
		cnt[i]+=cnt[i-1];
	}
	FOR(i,0,n){
		LL t=cnt[a[i]-1];
		ans=add(dvs(mul(t,mul(k,k-1)),2),ans);
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int maxL[20][200005], maxR[20][200005];
int p_L, p_R;
int dpL[(1<<20)], dpR[(1<<20)]; // dpL prefix, dpR suffix
int N, V;
ll x[200005];
int BIT[200005];
int parts[200005];
vector <pii> dp_range;

int calc_dpL(int mask) {
	//cout << mask << endl;
	if (mask == 0) return 0;
	int &ret = dpL[mask];
	int tmp;
	if (ret != -1) return ret;
	ret = 0;
	for (int i=0;i<20;++i) {
		if (mask&(1<<i)) {
			if (calc_dpL(mask - (1<<i)) == N) ret = N;
			else {
				tmp = calc_dpL(mask-(1<<i));
				tmp = maxR[i][tmp] - tmp + 1;
				ret = max(ret,tmp + calc_dpL(mask-(1<<i)));
			}
		}
	}
	return ret;
}

int calc_dpR(int mask) {
	//cout << mask << endl;
	if (mask == 0) return 0;
	int &ret = dpR[mask];
	int tmp;
	if (ret != -1) return ret;
	ret = 0;
	for (int i=0;i<20;++i) {
		if (mask&(1<<i)) {
			if (calc_dpR(mask - (1<<i)) == N) ret = N;
			else {
				tmp = (N-1) - calc_dpR(mask-(1<<i));
				tmp = tmp - maxL[i][tmp] + 1;
				ret = max(ret,tmp + calc_dpR(mask-(1<<i)));
			}
		}
	}
	return ret;
}

bool cmp(pii a, pii b) {
	return a.se < b.se;
}

int BIT_q(int u) {
	++u;
	int ret = -1;
	while (u) {
		ret=max(ret,BIT[u]);
		u-=u&(-u);
	}
	return ret;
}

void BIT_u(int u,int val) {
	++u;
	for (;u<200005;u+=u&(-u)) BIT[u]=max(BIT[u],val);
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	memset(dpL,-1,sizeof(dpL));
	memset(dpR,-1,sizeof(dpR));
	memset(BIT,-1,sizeof(BIT));
	parts[0]=1;
	for (int i=1;i<200005;++i) {
		parts[i] = 1+parts[i>>1];
	}
	cin >> N >> V;
	for (int i=0;i<N;++i)
		cin >> x[i];
	for (int i=0;i<20;++i) {
		for (int j=N;j>=0;--j) {
			maxR[i][j]=j;
			if ( j+1 < N && x[j+1]-x[j] <= (V>>i) ) maxR[i][j] = maxR[i][j+1];
		}
	}
	for (int i=0;i<20;++i) {
		for (int j=0;j<=N;++j) {
			maxL[i][j]=j;
			if ( j-1 >= 0 && x[j]-x[j-1] <= (V>>i) ) maxL[i][j] = maxL[i][j-1];
		}
	}
	//cout << "Kelar\n";
	//cout << "cuk\n";
	int mask_r;
	for (int mask_l=0;mask_l<(1<<parts[V]);mask_l+=2) {
		//cout << mask_l << endl;
		mask_r = ((1<<parts[V]) - 1) - mask_l - 1;
		//if (mask_r == 0) continue;
		dp_range.push_back(make_pair(calc_dpL(mask_l),calc_dpR(mask_r)));
	}
	//cout << "yy\n";
	sort(dp_range.begin(), dp_range.end(), cmp);
	//cout << "yaya\n";
	for (int i=0;i<(int)dp_range.size();++i) {
		//cout << dp_range[i].fi << " (" << N - dp_range[i].fi << ") " << dp_range[i].se << endl;
		BIT_u(N - dp_range[i].fi,dp_range[i].se);
		//cout << "jalan " << dp_range[i].fi << ' ' << dp_range[i].se << endl;
	}
	//cout << "cihuy\n";
	for (int i=0;i<N;++i) {
		p_L = maxL[0][i];
		p_R = maxR[0][i];
		//cout << i << ' ' << p_L << ' ' << p_R << ' ' << BIT_q(N - p_L) << endl;
		if (BIT_q(N - p_L) >= N-(p_R+1)) cout << "Possible\n";
		else cout << "Impossible\n";
		/*int mask_r;
		for (int mask_l=0;mask_l<(1<<parts[V]);mask_l+=2) {
			mask_r = ((1<<parts[V]) - 1) - mask_l - 1;
			if ((calc_dpL(mask_l) >= p_L) && (calc_dpR(mask_r) >= N - (p_R+1))) { cout << "Possible " << mask_l << ' ' << mask_r << endl; break; }
		}
		//cout << "Impossible\n";*/
	}
	return 0;
}

Measured memory_bytes: 47216
#include <iostream>

using namespace std;

int main() {
    int r, g, b;
    cin >> r;
    cin >> g;
    cin >> b;
    int num = r * 100 + g * 10 + b;
    //cout << num;
    if (num % 4 == 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m, n;
    cin >> m >> n;
    vector<pair<int, int>> ppl(m);
    vector<pair<int, int>> places(n);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        ppl[i] = {x, y};
    }
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        places[i] = {x, y};
    }
    for(int i = 0; i < m; i++) {
        int index, small = INT_MAX;
        for(int j = 0; j < n; j++) {
            int dist = abs(ppl[i].f - places[j].f) + abs(ppl[i].s - places[j].s);
            if(dist < small) {
                small = dist;
                index = j + 1;
            }
        }
        cout << index << endl;
    }
}

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

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

int main()
{
	int a, b;
	while(cin >> a >> b)
	{
		if(a < b) swap(a,b);
		while( b != 0)
		{
			a = a % b;
			swap(a,b);
		}
		cout << a << endl;

	}
	return 0;
}

Measured memory_bytes: 0
/**
*    created: 03.07.2020 01:43:12
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b;
    int r = c + d; 
    if (l > r) cout << "Left" << endl;
    else if (l == r) cout << "Balanced" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 3660
use std::io::stdin;

fn main() {
    let mut input_string = String::new();
    stdin().read_line(&mut input_string).ok();
    let mut itr = input_string.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    println!("{}", (10000 - n) % 1000);
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define PB push_back
#define FI first
#define SE second
#define MP make_pair
#define int long long
using namespace std;
static const int inf = 1ll<<60;
static const int MAX_N = 16777216;
typedef pair<int,int> P;

int N,D;
int X[40],Y[40];
int ans=0;
int dat[MAX_N*2];

class Segment{
    public :
        int n;
        void inti(int n_){
            n=1;
            while(n<n_)n*=2;
            for(int i=0;i<2*n-1;++i)dat[i]=-INT_MAX;
        }

        void update(int k,int a){
            k+=n-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                dat[k]=max(dat[k*2+1],dat[k*2+2]);
            }
        }

        int query(int a,int b,int k,int l,int r){
            if(a<=l&&r<=b)return dat[k];
            if(r<=a||b<=l)return -INT_MAX;
            else {
                int vl=query(a,b,k*2+1,l,(l+r)/2);
                int vr=query(a,b,k*2+2,(l+r)/2,r);
                return max(vl,vr);
            }
        }
};

void half(int n,int last,int x,int y,vector<P> &res) {
    if (n==last) {
        res.PB(P(x,y));
        return;
    }
    half(n-1,last,x+X[n],y+Y[n],res);
    half(n-1,last,x-X[n],y-Y[n],res);
    half(n-1,last,x,y,res);
}

signed main(){
    cin>>N>>D;
    Segment seg;
    int n2=N/2;
    for(int i=1;i<=N;++i){
        cin>>X[i]>>Y[i];
    }
    vector<P> p1;
    vector<P> p2;
    p1.reserve(MAX_N);
    half(n2,0,0,0,p1);
    p2.reserve(MAX_N);
    half(N,n2,0,0,p2);
    sort(p2.begin(),p2.end());
    seg.inti(p2.size());
    for(int i=0;i<p2.size();++i)seg.update(i,p2[i].SE);
    for(int i=0;i<p1.size();++i){
        int x=p1[i].FI+D;
        int y=p1[i].FI-D;
        int r=lower_bound(p2.begin(),p2.end(),MP(y,-inf))-p2.begin();
        int l=upper_bound(p2.begin(),p2.end(),MP(x,inf))-p2.begin();
        if(r==p2.size())continue;
        if(r>=l)continue;
        ans=max(ans,abs(seg.query(r,l,0,0,seg.n)-p1[i].SE));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 715340
import numpy as np

n, k = map(int, input().split())
h = np.array(input().split(), dtype=np.int)

if k < n:
  dp = np.zeros((n - k, n), dtype=np.int)
  dp[0] = h
  for i in range(n - k - 1):
    for j in range(i + 1, n):
      dp[i+1, j] = np.min(dp[i][i:j] + np.maximum(h[j] - h[i:j], 0))
  print(dp[n-k-1, n-k-1:].min())
else:
  print(0)

Measured memory_bytes: 13108
package main

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

func main() {
	nextReader = newScanner()

	W := nextFloat64()
	H := nextFloat64()
	x := nextFloat64()
	y := nextFloat64()

	max := (W * H / 2.0)

	//中心の場合
	if x == (W/2) && y == (H/2) {
		fmt.Println(max, 1)
		return
	}

	fmt.Println(max, 0)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

map<ll, ll> primeFactor(ll x) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= x; i++) {
        while (x % i == 0) {
            res[i]++;
            x /= i;
        }
    }
    if (x != 1) res[x] = 1;
    return res;
}

ll gcd(ll x, ll y) {
    return y ? __gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
    return x/__gcd(x, y)*y;
}

int main() {
    ll n; cin >> n;
    vector<ll> a(n);

    map<ll, ll> allSeenFactors;
    bool isPairWise = true;

    ll allGcd;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i != 0) allGcd = gcd(allGcd, a[i]);
        else allGcd = a[i];

        if (!isPairWise) continue;

        map<ll, ll> res = primeFactor(a[i]);
        for (auto i: res) {
            if (allSeenFactors.count(i.first)) {
                isPairWise = false;
            }
            allSeenFactors[i.first] = 1;
        }
    }

    if (allGcd != 1) {
        cout << "not coprime" << endl;
        return 0;
    }
    if (isPairWise) {
        cout << "pairwise coprime" << endl;
    }
    else {
        cout << "setwise coprime" << endl;
    }
}

Measured memory_bytes: 11168
// i_m_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

ll d,t,s;
cin>>d>>t>>s;
if(s*t>=d) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}


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

Measured memory_bytes: 3648
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for(int i = 0;i < n;i++)a[i]=sc.nextLong();
    long b1 = 0;
    for(int i = 0;i < n;i++)b1+=(long)Math.pow(-1,i+2)*a[i];
    b1/=2;
    System.out.print(b1*2);
    long before = b1;
    long after = b1;
    for(int i = 0;i < n-1;i++){
      before = after;
      System.out.print(" "+((a[i]-before)*2));
      after = a[i]-before;
    }
    System.out.println("");
  }
}

Measured memory_bytes: 67284
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N_MAX=10000;
ll SQ_MAX=1001;
ll p=1e9+7;
ll log2_p_MAX = 32;
ll felmer(ll a)
{
  // a^(2^i) mod p
  ll rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  ll res = 1;
  ll expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  ll n,a,m,t,i,j,k,tl,rr=1,res=0;
  ll r[N_MAX],ma[SQ_MAX],tm[SQ_MAX][20];
  P d[N_MAX][8];
  bool f=1;
  fill(ma,ma+SQ_MAX,0);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    m=(int)sqrt(a)+1;
    k=0;
    for(j=2;j<=m;j++){
      if(a<j*j)
        break;
      t=0;
      while(a%j==0){
        a/=j;
        t++;
      }
      if(t>0){
        ma[j]=max(t,ma[j]);
        d[i][k].first=j;
        d[i][k].second=t;
        k++;
      }
    }
    d[i][k].first=a;
    d[i][k].second=1;
    k++;
    if(a<SQ_MAX){
      ma[a]=max((ll)1,ma[a]);
      r[i]=1;
    }else{
      r[i]=a;
    }
    d[i][k].first=0;
    d[i][k].second=0;
  }
  for(j=2;j<SQ_MAX;j++){
    tm[j][0]=1;
    for(k=0;k<ma[j];k++)
      tm[j][k+1]=(tm[j][k]*j)%p;
  }
  sort(r,r+n,greater<ll>());
  if(r[0]==r[n-1]){
    f=0;
  }else{
    rr=r[0];
    for(i=1;i<n;i++){
      if(r[i]==1)
        break;
      if(r[i]!=r[i-1]){
        rr*=r[i];
        rr%=p;
      }
    }
  }
  for(i=0;i<n;i++){
    tl=rr;
    k=0;
    t=d[i][k].first;
    for(j=2;j<SQ_MAX;j++){
      if(ma[j]==0)
        continue;
      if(j==t){
        tl*=tm[j][ma[j]-d[i][k].second];
        k++;
        t=d[i][k].first;
      }else{
        tl*=tm[j][ma[j]];
      }
      tl%=p;
    }
    if(t>0&&f){
      tl*=felmer(t);
      tl%=p;
    }
    res+=tl;
    res%=p;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5080
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;

typedef struct datum_name {
	int x;
	int y;
	int whosay;
	bool operator==(const datum_name& data) const
	{
		return (x == data.x && y == data.y);
	}
} datum;


bool cmp_who(const datum& left, const datum& right) {
	return left.whosay < right.whosay;
}

typedef vector<vector<int>> Graph;
vector<bool> seen;
vector<int> depth;

void dfs(const Graph& G, int v, int depth_num) {
	seen[v] = true;
	depth[v] = depth_num;

	for (auto next_v : G[v]) {
		if (seen[next_v]) continue;
		dfs(G, next_v, depth_num+1); //再帰探索
	}
}

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

	if (day == "SUN") cout << "7" << endl;
	else if (day == "MON") cout << "6" << endl;
	else if (day == "TUE") cout << "5" << endl;
	else if (day == "WED") cout << "4" << endl;
	else if (day == "THU") cout << "3" << endl;
	else if (day == "FRI") cout << "2" << endl;
	else if (day == "SAT") cout << "1" << endl;
	// SUN, MON, TUE, WED, THU, FRI, SAT


	return 0;

}


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

const int MAXN = 3005;

int N;
int a[MAXN];
vector <int> E[MAXN];

void load() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%d", a + i);
  for (int i = 1; i < N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    E[u].push_back(v);
    E[v].push_back(u);
  }
}

bool dfs(int x, int p) {
  for (int i = 0; i < E[x].size(); i++)
    if (E[x][i] != p && !dfs(E[x][i], x) && a[E[x][i]] < a[x])
      return true;
  return false; 
}

void solve() {
  for (int i = 1; i <= N; i++)
    if (dfs(i, 0))
      printf("%d ", i);
  puts("");
}

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

Measured memory_bytes: 768
import itertools

n = int(input())
lst = []

for _ in range(n):
	x,y=map(int,input().split())
	lst.append([x,y])

cnt = 0
cnt2 = 0
	
for _ in itertools.permutations(lst,n):
	cnt2 +=1
	for i in range(n-1):
		cnt += ((_[i][0]-_[i+1][0])**2+(_[i][1]-_[i+1][1])**2)**0.5

print(cnt/cnt2)

Measured memory_bytes: 3316
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return c*c;
	else
		return c*c*a;
}

int main()
{
    boost
    string s,t;
    cin >> s >> t;
    ll ans=0;
    for(ll i=0;i<s.size();i++)  {
        if( s[i]!=t[i] )
            ans++;
    }
    cout << ans;
    return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);
  return Pow(A * A % MOD, N / 2) * A % MOD;
}

int N, K;
ll nCk[int(1e5+5)];
ll A[int(1e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> A[i];
  sort(A + 1, A + N + 1);

  nCk[K - 1] = 1;
  for (ll i = K; i <= N; i++){
    nCk[i] = nCk[i - 1] * i % MOD;
    nCk[i] *= Pow(i - K + 1, MOD - 2); 
    nCk[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++){
    ll now = A[i] * nCk[i-1] % MOD;
    ll now2 = A[i] * nCk[N - i] % MOD;
    now -= now2; now %= MOD;
    ans += now; ans %= MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1001001001001;

int main(){
    int n,m; cin >> n >> m;
    vector<pair<int,int>> v;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        if(b>a) v.push_back(pair<int,int>(a,b));
        else v.push_back(pair<int,int>(b,a));
    }
    sort(v.begin(),v.end());
    int ans = 1;
    int fi = v[0].first;
    int se = v[0].second;
    rep(i,m){
        if(v[i].first < se){
            se = min(v[i].second,se);
        }
        else{
            ans++;
            fi = v[i].first;
            se = v[i].second;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1400
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      int cnt = 0;
      for(int i=0;i<=9;i++){
        String I = String.valueOf(i);
        int ii = s.indexOf(I);
        if(ii<0)continue;
        for(int j=0;j<=9;j++){
          String J = String.valueOf(j);
          int jj = s.indexOf(J,ii+1);
          if(jj<0)continue;
          for(int k=0;k<=9;k++){
            String K = String.valueOf(k);
            int kk = s.indexOf(K,jj+1);
            if(kk>0)cnt++;
          }
        }
      }
      System.out.println(cnt);
    }
}

Measured memory_bytes: 23760
#include<iostream>
#include<string>
using namespace std;
int c;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=b){
		if(a-1>=b){
			c=2*a-1;
		}
		if(a-1<b){
			c=a+b;
		}
	}
	if(a<b){
		if(a>=b-1){
			c=a+b;
		}
		if(a<b-1){
			c=2*b-1;
		}
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        int n, m; cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> h(n+1), w(m+1);
        loop (n, i) cin >> h[i+1];
        loop (m, i) cin >> w[i+1];

        loop (n, i) h[i+1] += h[i];
        loop (m, i) w[i+1] += w[i];

        vector<int> H, W;
        loop (n+1, i) loop (n+1, j) {
            if (i >= j) continue;
            H.push_back(h[j] - h[i]);
        }
        loop (m+1, i) loop (m+1, j) {
            if (i >= j) continue;
            W.push_back(w[j] - w[i]);
        }
        sort(all(W));

        int ans = 0;
        for (int v : H) {
            ans += distance(lower_bound(all(W), v), upper_bound(all(W), v));
        }

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

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

int main(){
    int a, b, c, x, y;
    std::cin >> a >> b >> c >> x >> y;

    int min = 2147483647;
    min = std::min(min, a * x + b * y);
    min = std::min(min, std::max(x, y) * 2 * c);

    int buf;
    if(x > y){
        buf = (x - y) * a;
    }
    if(y > x){
        buf = (y - x) * b;
    }

    std::cout << std::min(min, std::min(x, y) * 2 * c + buf) << std::endl;;
    
    return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;


void solve()
{
	int n, x;
	cin >> n >> x;
	int l[n];
	for (int i = 0; i < n; i++)
		cin >> l[i];
	int ans =0 ;
	if (ans <= x)
		ans++;
	int curr = 0;
	for (int i =1 ; i <= n; i++)
	{
		curr = curr + l[i - 1];
		if (curr <= x)
			ans++;
	}
	cout << ans;
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




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

int q, l[100000], r[100000];
int x[100001], num[100001];

int main() {
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
	}

	for (int i = 2; i <= 100000; i++) {
		num[i] = 1;
	}

	//素数を計算
	for (int i = 2; i <= 100000; i++) {
		if (num[i]) {
			for (int j = i*2; j <= 100000; j += i) {
				num[j] = 0;
			}
		}
	}

	/*for (int i = 0; i < 10; i++) {
		cout << "num[" << i << "]:" << num[i] << endl;
	}*/

	for (int i = 2; i <= 100000; i++) {
		if (num[i] && ((i + 1) % 2 == 0 && num[(i + 1) / 2])) {
			x[i] =  1;
		}
		x[i] = x[i] + x[i - 1];
	}

	for (int i = 0; i < q; i++) {
		cout << (x[r[i]] - x[l[i] - 1]) << endl;
	}
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<long long> a(n, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		int skip = (n % 2 == 0) ? 1 : 2;
		vector<vector<vector<long long>>> dp(n + 1, vector<vector<long long>>(skip + 1, vector<long long>(2, -(1LL << 60))));
		dp[0][0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= skip; j++) {
				// use
				dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][0] + a[i]);
				// skip
				if (j != skip) dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j][0]);
				// force skip(not counted)
				dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][1]);
			}
		}
		cout << max(max(dp[n][skip - 1][0], dp[n][skip - 1][1]), max(dp[n][skip][0], dp[n][skip][1])) << endl;

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 43864
def Roman_numerals(x):
	if x=='I':
		return 1
	elif x=='V':
		return 5
	elif x=='X':
		return 10
	elif x=='L':
		return 50
	elif x=='C':
		return 100
	elif x=='D':
		return 500
	elif x=='M':
		return 1000




while True:
	try:
		s=0
		string=input()
		for i in range(len(string)):
			tmp_now =Roman_numerals(string[i:i+1])
			tmp_next=Roman_numerals(string[i+1:i+2])
			if (tmp_now==1 and tmp_next==5):
				s+=-1
			elif (tmp_now==1 and tmp_next==10):
				s+=-1
			elif (tmp_now==10 and tmp_next==50):
				s+=-10
			elif (tmp_now==10 and tmp_next==100):
				s+=-10
			elif (tmp_now==100 and tmp_next==500):
				s+=-100
			elif (tmp_now==100 and tmp_next==1000):
				s+=-100
			else:
				s+=tmp_now
		print(s)

	except EOFError:
		break

Measured memory_bytes: 7424
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    bool flg = false;
    bool ok = false;
    rep(i, s.length()) {
        if ( s[i] == 'C' ) flg = true;
        if ( s[i] == 'F' && flg ) ok = true;
    }
    if ( ok ) cout << "Yes" << endl;
    else      cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;

int main() {
	ios_base::sync_with_stdio(false);
	int x, l;
	cin >> n >> x;
	cout << 10 * (n >= x);
}	

	

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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e6+6;

void solve(){
    int n; cin >> n;

    int a[n];
    int sum=0;

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

    map<int,int> mp;
    for(int i=0;i<n;i++) mp[a[i]]++;

    int q; cin >> q;

    while(q--){
        int b,c; cin >> b >> c;
        sum-=mp[b]*b;
        sum+=mp[b]*c;
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<endl;
    }
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}

Measured memory_bytes: 10344
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
long long  mod = 1000000007;
int N, K;
string S;
vector<int> P;
int main()
{
	cin >> N >> K >> S;
	int an = 0;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			an++;
		}
	}
	int count = 0;
	if (S[0] == S[N - 1]) {
		if (S[0] == 'R') {
			for (int i = 0; i < N; i++) {
				count = 0;
				if (S[i] == 'L') {
					P.push_back(2);
					while (S[i + 1] == 'L') {
						i++;
					}
				}
			}
			sort(P.begin(), P.end());
			int j = P.size() - 1;
			for (int i = 0; i < K; i++) {
				if (j < 0) break;
				an += P[j];
				j--;
			}
			cout << an;
			return 0;
		}
		else if (S[0] == 'L') {
			for (int i = 0; i < N; i++) {
				count = 0;
				if (S[i] == 'R') {
					P.push_back(2);
					while (S[i + 1] == 'R') {
						i++;
					}
				}
			}
			sort(P.begin(), P.end());
			int j = P.size() - 1;
			for (int i = 0; i < K; i++) {
				if (j < 0)break;
				an += P[j];
				j--;
			}
			cout << an;
			return 0;
		}
	}
	else if (S[0] != S[N - 1]) {
		P.push_back(1);
		for (int i = 0; i < K; i++) {
			if (an < N - 2) {
				an += 2;
			}
			else {
				an++;
				break;
			}
		}
		cout << an;
		return 0;
	}
}

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

#define int long long

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    string s, t;
    cin >> s >> t;
    int moves_cnt = t.size();
    for (int i = 0; i + t.size() <= s.size(); i++) {
    	int cnt = 0;
    	for (int j = 0; j < t.size(); j++) {
    		cnt += (s[i + j] == t[j] ? 0 : 1);
    	}
    	moves_cnt = min(moves_cnt, cnt);
    }
    cout << moves_cnt << endl;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();

        long ans = 0;
        int tmp = 0;

        while(H != 0){
            H /= 2;
            ans += Math.pow(2,tmp);
            tmp++;
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 23124
#include <cstdio>
#include <stack>
using namespace std;

typedef long long ll_t;

int N;
int A[200000];
int L[200000];
int R[200000];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) 
        scanf("%d", &A[i]);
    
    stack<int> s;
    for (int i = 0; i < N; i++) {
        while (!s.empty() && A[i] < A[s.top()]) 
            s.pop();
        if (s.empty())
            L[i] = -1;
        else
            L[i] = s.top();
        s.push(i);
    }

    while (!s.empty()) s.pop();
    for (int i = N - 1; i >= 0; i--) {
        while (!s.empty() && A[i] < A[s.top()])
            s.pop();
        if (s.empty())
            R[i] = N;
        else
            R[i] = s.top();
        s.push(i);
    }
    
    ll_t r = 0;
    for (int i = 0; i < N; i++) 
        r += (ll_t) A[i] * (i - L[i]) * (R[i] - i);
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>

using namespace std;

void GetCount(long long N, long long A, long long B, long long& result){
    if(((A+B)&1) == 0) {
        result += (B-A)/2;
        return;
    }
    if(A == 1){
        result += std::min(B-1, (B-A)/2 + 1);
        return ;
    }
    if(B == N){
        result += std::min(N-A, (B-A)/2 + 1);
        return ;
    }
    
    long long diff;
    if(A-1 < N-B){
        diff = A-1;
        A -= diff, B -= diff;
    }
    else{
        diff = N-B;
        A += diff, B += diff;        
    }
    result += diff;
    return GetCount(N, A, B, result);
}

int main()
{
    long long N, A, B;
    std::cin >> N >> A >> B;
    long long result = 0;
    GetCount(N,A,B,result);
    std::cout << result;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (i=0; i <= a && 500*i<=x; i++)
    {
        for (j=0; j <= b && 100*j+500*i<=x; j++)
        {
            for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
            {
                if (500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def combination(n, r, mod):
    numerator, denominator = 1, 1
    for _ in range(r):
        numerator = numerator * n % mod
        denominator = denominator * r % mod
        n -= 1
        r -= 1
    return numerator * pow(denominator, mod - 2, mod) % mod


n, k = map(int, input().split())

mod = 10**9 + 7
for i in range(1, k + 1):
    answer = combination(n - k + 1, i, mod) * combination(k - 1, i - 1, mod) % mod
    print(answer)


Measured memory_bytes: 3316
//https://www.geeksforgeeks.org/maximal-disjoint-intervals
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
  
// Function to sort the vector elements 
// by second element of pairs 
bool sortbysec(const pair<ll, ll>& a, 
               const pair<ll,ll>& b) 
{ 
    return (a.second < b.second); 
} 
  
// Function to find maximal disjoint set 
void maxDisjointIntervals(vector<pair<ll, ll> > list) 
{ 
  
    // Sort the list of intervals 
    sort(list.begin(), list.end(), sortbysec); 
  

    // End point of first interval 
    ll r1 = list[0].second; 
  ll c=1;
    for (int i = 1; i < list.size(); i++) { 
        ll l1 = list[i].first; 
        ll r2 = list[i].second; 
  
        // Check if given interval overlap with 
        // previously included interval, if not 
        // then include this interval and update 
        // the end point of last added interval 
        if (l1 >= r1) {c++; 
            r1 = r2; 
        } 
    }
    std::cout << c << std::endl;
} 
int main()
{
    int n;
    std::cin >>n;
    vector<pair<ll,ll>> v;
    ll a,b;
    for(int i=0;i<n;i++)
    {
        std::cin >>a;
        std::cin >>b;
        v.push_back( make_pair(a-b,a+b));
    }
    maxDisjointIntervals(v);
    return 0;
}
    

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

const int MOD = 1000000007;
int n;
vector<int> a, s; //s= 累積和

int main() {
  cin >> n;
  s.push_back(0);
  for (int i = 0; i< n; i++) {
    int b;
    cin >> b;
    a.push_back(b);
    s.push_back((s[i] + b) % MOD);
  }
  
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] * ((s[n] - s[i+1] + MOD) % MOD);
    ans %= MOD;
  }
  
  cout << ans;
}

Measured memory_bytes: 4772
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log,floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a,b,c,d = MAP()

print(max(a*c,a*d,b*c,b*d))

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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
 
 
}
 
Node treeSearch(Node u, int k){
  Node x;
  x=u;
 
  while(x!=NIL && k!=x->key){
    if(k < x->key)x=x->left;
    else x=x->right;
  }
 
  return x;
 
}
 
Node treeSuccessor(Node x){
 
 
}
 
void treeDelete(Node z){
  Node y; 
  Node x; 
 
 
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->p=y;
 
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
 
}
 
void inorder(Node u){
  if (u==NIL)return;
 
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 
}
void preorder(Node u){
if (u==NIL)return;
 
 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);
 
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19360
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 998244353;
const INF: i64 = std::i64::MAX/3;

fn solve() {
    let s = read!([char]);
    let t = read!([char]);
    let n = s.len();
    let mut ans = 0;
    for i in 0..n {
        if s[i]!=t[i] {
            ans += 1;
        }
    }
    println!("{}",ans);
    
}

fn run() {
    solve();
}

Measured memory_bytes: 3168