akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#define FUP(i,x,y) for(register int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(register int i=(x);i>=(y);i--)
#define MAXN 40
#define INF 0x3f3f3f3f
using namespace std;
inline int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int n,m1,m2,a,b,c,ans=INF,cnt=1,suma,sumb;
int f[410][410];
int main(){
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	n=read(),m1=read(),m2=read();
	FUP(i,1,n)
	{
		a=read(),b=read(),c=read();
		suma+=a,sumb+=b;
		FDW(j,suma,a)
		{
			FDW(k,sumb,b)
			{
				f[j][k]=min(f[j][k],f[j-a][k-b]+c);
				if(j*1.0/m1==k*1.0/m2) ans=min(ans,f[j][k]);
			}
		}
	}
	printf("%d\n",ans==INF?-1:ans);
    return 0;
}

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

int main(){

    int N;
    cin >> N;

    bool found = false;

    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
            if (i*j == N) {
                found = true;
                break;
            }

    if (found)
        cout << "Yes";
    else
        cout << "No";
    cout << "\n";

    return 0;
}


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

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; }

int main() {
    int r, g;
    cin >> r >> g;
    int ans = g - r;

    cout << ans + g;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3604
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

int main() {
	Get(int, n);
	GetArray(int, v, n);
	Arr2(sort, v);
	Arr2(reverse, v);
	int count = 1;
	co<<Acc(0, v, [&count](auto acc,auto x) {
		return ++count%2 ==0? acc+x:acc-x;
	})<<en
}




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

using namespace std;

int main(void)
{
	int n,k;

	cin>>n>>k;

	int sum[n];
	int a=1;
	int cnt=0;

	for(int i=0;i<n;i++){
		if(a<=n){
			sum[i]=a;
			cnt++;
			a+=2;
		}
		else{
			break;
		}
	}

	if(cnt>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;



	return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

int n , k;
int a[MAXX];

int main()
{
    _FastIO;
    cout.precision(12);
    cin >> n >> k;
    int x = 0 , ans;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i < k)
            x += a[i];
    }
    ans = x;
    for(int i = k; i < n; i++){
        x -= a[i - k];
        x += a[i];
        ans = max(ans , x);
    }
    cout << fixed << ((ans + k) * 1.00 / 2 * 1.00) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}

lli dp[100010][13];
int main() {
    string S; cin >> S;

    int x=0;
    if(S[0]=='?') {
        for (int i = 0; i < 10; i++) {
            dp[0][i]=1;
        }
        for (int i = 10; i < 13; i++) {
            dp[0][i]=0;
        }
    }else{
        for (int i = 0; i < 13; i++) {
            if(S[0]-'0' == i){
                dp[0][i]=1;
            }else{
                dp[0][i]=0;
            }
        }
    }

    for(int i=1; i<S.size(); i++){
        if(S[i]!='?') {
            for(int j=0; j<13; j++){
                dp[i][(j*10+(S[i]-'0'))%13]+=dp[i-1][j];
                dp[i][(j*10+(S[i]-'0'))%13]%=MOD;
            }
        }else{
            for(int j=0; j<13; j++){
                for(int k=0; k<10; k++) {
                    dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
                    dp[i][(j * 10 + k) % 13]%=MOD;
                }
            }
        }
    }

    cout << dp[S.size()-1][5]%MOD << endl;

    return 0;
}

Measured memory_bytes: 10944
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define INF 2e9
using namespace std;
const int N=1e6+1;
const int mod=1e9+7;
ll fastexp(ll base,ll exp){
	base%=mod;
	ll ans=1;
	while(exp>0){
		if(exp&1){
			ans*=base;
			ans%=mod;
		}
		base*=base;
		base%=mod;
		exp/=2;
	}
	return ans;
}
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int sumofdigits(int n){
	int sum = 0;
	while(n!=0){
		sum += n%10;
		n = n/10;
	}
	return sum;
}
int arr[N];
int ar[N];
int main() {
		long long n, d;
		cin >> n >> d;
		int count = 0;
		for(int i = 0; i < n; i++){
			long long  x,y;
			double distance;
			cin >> x >> y;
			distance = sqrt(x*x + y*y);
			if(distance <= d){
				count++;
			}
			else{

			}
		}
		cout << count << endl;
		return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	long long x[n],y[n],z[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i]>>y[i]>>z[i];
	}
	long long ans=0LL,d[4]={1LL,1LL,1LL,1LL};
	while (d[3]!=-1LL)
	{
		long long tmp[n];
		for (int i = 0; i < n; ++i)
		{
			tmp[i]=x[i]*d[0]+y[i]*d[1]+z[i]*d[2];
		}
		sort(tmp,tmp+n);
		reverse(tmp,tmp+n);
		long long nans=0LL;
		for (int i = 0; i < m; ++i)
		{
			nans+=tmp[i];
		}
		ans=max(ans,nans);
		int now=0;
		while (d[now]==-1)
		{
			d[now]=1;
			++now;
		}
		d[now]=-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A*N, B) << endl;
}


Measured memory_bytes: 3596
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, m; cin >> n >> m;
    vector<int> a(m);
    int sum = 0;
    rep(i, m){
        cin >> a[i];
        sum += a[i];
    }

    cout << (sum > n ? -1 : n - sum) << endl;

return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;

// 各ノードの情報
template <typename T>
struct node {
	T v, lazy;
	node(){
		v = 0;
		lazy = 0;
	}
	// ノードの値の更新
	void merge(T vl, T vr){
		v = vl + vr;
	}
	// ノードの値の更新(lazy適用)
	T add(int l, int r, T _v=0){
		T sum = lazy*(r-l) + _v;
		v += sum;
		lazy = 0;
		return sum;
	}
	// 遅延分の変更(加算)
	void addLazy(T v){
		lazy += v;
	}
};

template <typename T, typename NODE=node<T> >
class SegTree{
	// 遅延分の適応と伝播(現在のノードの値を確定させてLazyを伝搬させる)
	void propLazy(int a, int b, int k, T v=0){
		T lazy = data[k].add(a, b, v);
		if( k < N ){
			data[k*2+0].addLazy(lazy);
			data[k*2+1].addLazy(lazy);
		}
	}
	// セグメントツリーをたどる
	T prop(int l, int r, T v, int a, int b, int k=1){
		// 今いるノードの値を確定させる
		propLazy(a, b, k);
		// たどる
		NODE nd;	// 結果保存用(範囲外の場合は初期値が返る)
		if( l <= a && b <= r ){
			// 完全に範囲内の場合
			propLazy(a, b, k, v);
			return data[k].v;
		}else if( l < b && a < r ){
			// 中途半端に含まれる場合
			int m = (a+b) / 2;
			T vl = prop(l,r,v, a, m, k*2);
			T vr = prop(l,r,v, m, b, k*2+1);
			data[k].merge( data[k*2].v, data[k*2+1].v );
			nd.merge( vl, vr );
		}
		return nd.v;
	}

public:
	vector<NODE> data;
	int N;
	SegTree(int _N){
		// _N <= (N = 2^k) を満たすNを見つける
		N = 1;
		while( N < _N ) N<<=1;
		data.resize(N*2);
	}
	// セグメントツリーの更新(指定した場所の値をvに変更)
	void update(int l, T v){
		prop(l, l+1, v-get(l), 0, N);
	}
	// セグメントツリーの更新(範囲に加算)
	T add(int l, int r, T v){
		return prop(l,r,v,0,N);
	}
	// 値を取得 [l,r)
	T get(int l, int r){
		return prop(l,r,0,0,N);
	}
	// 値を取得 [l,l+1)
	T get(int l){
		return prop(l,l+1,0,0,N);
	}
};



int main(){
	//ios_base::sync_with_stdio(0);
	ll N, K, ans=0;
	ll a[200005];

	cin >> N >> K;
	rep(i,N) cin >> a[i];

	ll sum[200005]={};
	rep(i,N){
		sum[i+1] = sum[i] + a[i] - K;
	}

	SegTree<ll> seg(N);

	vector<ll> v(N);
	rep(i,N) v[i] = sum[i+1];
	sort( all(v) );
	rep(i,N){
		ll t = sum[i];
		int pos = lower_bound( all(v), t ) - v.begin();
		ans += v.size() - pos - seg.get(pos, N+1);
		//v.erase( lower_bound( all(v), sum[i+1] ) );
		pos = lower_bound( all(v), sum[i+1] ) - v.begin();
		seg.add(pos, pos+1, 1);
	}

//	priority_queue<ll> que;
//	rrep(i,N){
//		ll t = sum[i];
//		que.push( -sum[i+1] );
//		while( !que.empty() && que.top() > -t ) que.pop();
//		cout << i << " " << que.size() << endl;
//		ans += que.size();
//	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13184
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    string s;
    cin >> s;
    if (s.length()%2 != 0) {
        cout << "No" << "\n";
        return 0;
    }

    for (int i = 0; i < (int)s.length(); i+=2)
        if (!(s[i] == 'h' and s[i+1] == 'i')) {
            cout << "No" << "\n";
            return 0;
        }
    cout << "Yes" << "\n";
}



Measured memory_bytes: 256
x,y = map(int,input().split())
mod = 10**9 + 7
if (x+y)%3 != 0:
    print(0)
    exit()
n = (x+y)//3
a = (2 * x - y) // 3
b = (2 * y - x) // 3
if a == 0 or b == 0:
    print(1)
    exit()
if a < 0 or b < 0:
    print(0)
    exit()
MAX = 700000
fac = [1,1] + [0] * MAX     #累積積
finv = [1,1] + [0] * MAX    #modにおける逆元
inv = [0,1] + [0] * MAX     #invの累積積
for i in range(2,MAX):
    fac[i] = fac[i-1] * i % mod
    inv[i] = -inv[mod%i] * (mod//i)%mod
    finv[i] = finv[i-1] * inv[i]%mod


def nCr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n] * (finv[r] * finv[n-r]%mod)%mod

print(nCr(n,a))

Measured memory_bytes: 91540
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;
int arr[1010];
int dp[1010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    for (int i = 0; i < K; ++i)
    {
        int a, b;
        cin >> a >> b;

        int t = min({a - 1, b - 1, N - a, N - b}) % 3;
        cout << t + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
n=int(input())
M=10**9+7
F=[1]
for i in range(1,2001): F+=[i*F[-1]%M]
c=lambda n,r: F[n]*pow(F[r]*F[n-r],M-2,M)%M
a=0
for i in range(n//3):
  n-=3
  a=(a+c(n+i,n))%M
print(a)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
string s;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>s;
    ll sum=0;
    ll now;
    for(int bit=0;bit<(1<<s.size()-1);++bit){
        now=0;
        rep(i,s.size()){
            now=now*10+s[i]-'0';
            if(bit&(1<<i)){
                sum+=now;
                now=0;
            }
        }
        sum+=now;
    }
    cout<<sum<<endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long r = count(begin(s), end(s), 'R');
  long long g = count(begin(s), end(s), 'G');
  long long b = count(begin(s), end(s), 'B');
  auto ans = r * g * b;
  for (int j = 1; j < n; j++) {
    for (int i = 0; i < j; i++) {
      int k = 2 * j - i;
      if (k < n) {
        if (s[i] != s[j] and s[j] != s[k] and s[k] != s[i])
          ans --;
      }
    }
  }
  cout << ans << endl;
}


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

int par[100010];
int r[100010];
int64_t a[100010];
using P = pair<int64_t, int>;
P p[100010];
bool used[100010];
int64_t m1[100010];
int64_t mn[100010];
bool only[100010];
constexpr int64_t INF = 1000000010;

void init(int n){
    for(int i = 0; i < n; ++i){
        par[i] = i;
        r[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(r[x] < r[y]){
        par[x] = y;
    } else {
        par[y] = x;
    }
    if(r[x] == r[y]) r[x]++;
}

bool same(int x, int y){
    return find(x) == find(y);
}

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

    for(int i = 0; i < N; ++i){
        cin >> a[i];
        p[i] = P(a[i], i);
        only[i] = true;
    }

    init(N);
    for(int i = 0; i < M; ++i){
        int x, y;
        cin >> x >> y;
        unite(x, y);
        only[x] = false;
        only[y] = false;
    }

    int64_t ans = 0;
    for(int i = 0; i < N; ++i){
        m1[i] = INF;
    }
    
    for(int i = 0; i < N; ++i){
        int f = find(i);
        if(a[i] < m1[f]){
            m1[f] = a[i];
            mn[f] = i;
        }
    }

    int cnt = 0;
    for(int i = 0; i < N; ++i){
        if(m1[i] != INF){
            ans += m1[i];
            p[mn[i]].first = INF;
            cnt++;
        }
    }
    if(N - M <= 1){
        cout << 0 << endl;
        return 0;
    }
    sort(p, p + N);
    for(int i = 0; i < 2 * (N - M - 1) - cnt; ++i){
        if(p[i].first == INF){
            cout << "Impossible" << endl;
            return 0;
        }
        ans += p[i].first;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
 
#define fi first
#define se second
 
#define mp make_pair
#define pb push_back
 
#define all(x) (x).begin(), (x).end()
 
#define F return
#define DBG 1

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)

#define debug(x) if(DBG) cerr << #x << " is " << x << '\n';
#define sz(x) (int)x.size()

typedef long long ll;

using namespace std;                             

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

typedef vector<int> vi;
typedef vector<ll> vl;
 
const int MAXN = 1e5 + 500;
const int INF = 1e9 + 23;
    
const int MOD = 1e9 + 7;

int n, W;
ll dp[MAXN];

void max_self(ll& a, ll b) {
	a = max(a, b);
}

void solve() {
	scanf("%d%d", &n, &W);
	
	for (int i = 1; i <= n; i++) {
		int w, v;
		scanf("%d%d", &w, &v);
		for (int cur = W - w; cur >= 0; cur--) {
			max_self(dp[cur + w], dp[cur] + v);
		}
	}
	
	ll ans = 0;
	for (int i = 0; i <= W; i++) ans = max(ans, dp[i]);
	printf("%lld", ans);
}
         
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int tt = 1;
	
	while (tt--) {
		solve();
	}

    // you should actually read the stuff at the bottom
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
*/


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

bool like_number[127160];
bool prime_judge(int N) {
  if (N == 1) return false;
  bool flag = true;
  for (int i = 2; i * i <= N; i++) {
    if (N % i == 0) return false;
  }
  return true;
}

int main() {
  int Q;
  cin >> Q;
  vector<pair<int, int>> num(Q);
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    num[i] = make_pair(l, r);
  }

  for (int i = 1; i < 127160; i++) {
    if (prime_judge(i) && prime_judge((i + 1) / 2))
      like_number[i] = true;
    else
      like_number[i] = false;
  }

  like_number[1] = like_number[2] = false;
  like_number[3] = true;

  vector<int> sum(127160, 0);
  sum[0] = like_number[0];
  for (int i = 0; i < 127160; i++) {
    sum[i] = sum[i - 1] + like_number[i];
  }

  for (int i = 0; i < Q; i++) {
    int l = num[i].first, r = num[i].second;
    if (l == 0)
      cout << sum[r] << endl;
    else
      cout << sum[r] - sum[l - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2048
s = input()                                                                                                                                                                  

list_sorted = sorted([s[i] for i in range(4)])
if list_sorted[0] == list_sorted[1] and  list_sorted[2] == list_sorted[3] and list_sorted[1] != list_sorted[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	vector<int> foodTimer(5);
	vector<int> foodCompleteTimer(5);
	int foodDiff = 0;
	int lastFoodIndex = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> foodTimer[i];
		double digit = foodTimer[i] / 10.0;
		foodCompleteTimer[i] = (int)ceil(digit) * 10;
		int diff = foodCompleteTimer[i] - foodTimer[i];
		if (i == 0)
		{
			foodDiff = diff;
		}
		else {
			if (diff > foodDiff)
			{
				lastFoodIndex = i;
			}
		}
	}
	
	int answer = 0;
	for (int i = 0; i < 5; i++)
	{
		if (i != lastFoodIndex)
		{
			answer += foodCompleteTimer[i];
		}
	}
	
	// 最後の料理
	answer += foodTimer[lastFoodIndex];
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main() {
  int n;
  ll k;
  cin>>n>>k;
  int a[n];
  int f[n];
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>f[i];
  sort(a,a+n);
  sort(f,f+n);
  
  ll b=0;
  ll c=1e12+1;
  while(c-b>0){
    ll d=(b+c)/2;
    ll e[n];
    rep(i,0,n) e[i]=d/f[i];
    ll cur=0;
    rep(i,0,n){
      if(e[i]<a[n-1-i]) cur+=a[n-1-i]-e[i];
    }
    if(cur>k) b=d+1;
    else c=d;
  }
  cout<<b<<endl;
}



Measured memory_bytes: 3328
n,m=map(int,input().split())
h=list(map(int,input().split()))
g=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for i in range(n):
    f=0
    for j in g[i]:
        if h[i]>h[j]:
            f+=1
    if f==len(g[i]):
        ans+=1
print(ans)

Measured memory_bytes: 92748
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
using pint = pair<int, int>;

double kyori(int masu, int shortcut, int ukai)
{
    return 100.0 * masu + shortcut * (M_PI * 5.0 - 20.0) + ukai * (M_PI * 10.0 - 20.0);
}

pint x1, x2;
int N;
constexpr int Nmax = 200000;
array<pint, Nmax> X;

bool yswap = false;
constexpr int ymax = 100000000 - 1;

int main()
{
    cin >> x1.first >> x1.second >> x2.first >> x2.second >> N;
    if (x1.first > x2.first) swap(x1, x2);

    if (x1.second > x2.second) {
        yswap = true;
        x1.second = ymax - x1.second;
        x2.second = ymax - x2.second;
    }

    {
        int count = 0;
        int x, y;
        REP(i, N) {
            cin >> x >> y;
            if (yswap) y = ymax - y;
            if (x >= x1.first && x <= x2.first && y >= x1.second && y <= x2.second)
            {
                X[count].first = x;
                X[count].second = y;
                count++;
            }
        }
        N = count;
    }
    sort(X.begin(), X.begin() + N);

    vector<int> leasty(N + 1, 1000000000);
    leasty[0] = x1.second;
    REP(i, N) {
        int pos = distance(leasty.begin(), upper_bound(leasty.begin(), leasty.end(), X[i].second));
        leasty[pos] = X[i].second;
    }

    int count = distance(leasty.begin(), upper_bound(leasty.begin(), leasty.end(), x2.second)) - 1;

    int ukai = 0;
    if (count == x2.first - x1.first + 1 || count == x2.second - x1.second + 1) {
        count -= 1;
        ukai = 1;
    }

    cout << fixed << setprecision(12) << kyori(x2.second - x1.second + x2.first - x1.first, count, ukai) << endl;
}


Measured memory_bytes: 2560
def tax_increase(a,b):
    t8  = 0.08
    t10 = 0.1
    for i in range(b*10,(b+1)*10,1):
        if int(i*t8) == a:
            return i
    return -1
    
if __name__ == '__main__':
    a,b = map(int,input().split())
    ans = int(tax_increase(a,b))
    print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int min,max,div,ans=0;
    
    scanf("%d %d %d",&min,&max,&div);
    
    while(min<=max){
        if(div%min==0){
            ans++;
        }
            min++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 596
N = int(input())
l = [list(map(int, input().split())) for j in range(N-1)]

t = []
for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < l[j][1]:
            t = l[j][1] 
           
        elif 0 == (t%(l[j][2])): 
            pass
        
        else:
            t += -(t%(l[j][2])) + l[j][2] 
        
        t += l[j][0] 

    print(t)




Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int a, b, sum;
    cin >> a >> b;
    int A[999];
    for (int i = 1; i <= 999; i++) {
        if (i == 1) {
            A[i - 1] = i;
            sum = i;
        } else {
            sum += i;
            A[i - 1] = sum;
        }
    }

    for (int i = 1; i < 999; i++) {
        if ((A[i] - A[i - 1]) == (b - a)) {
            cout << A[i] - b << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int repaint(string s, bool color)
{
	int cnt = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] - '0' != color)
			++cnt;
		color = !color;
	}
	return cnt;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	cout << min(repaint(s, 0), repaint(s, 1)) << '\n';
	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
int main(void)
{
    char x,y;
    int a = 1,b = 0,c = 0;
    int xx=0;

    while(scanf("%c,%c",&x,&y) != EOF){
        if(x == 'A' && y =='B' || y == 'A' && x =='B'){
            xx = a;
            a = b;
            b = xx;
         }
         else if(x == 'A' && y == 'C' || y == 'A' && x == 'C'){
             xx = a;
             a = c;
             c = xx;
         }
         else if(x == 'B' && y == 'C' || y == 'B' && x == 'C'){
             xx = b;
             b = c;
             c = xx;
         }
    }
    if(a == 1)printf("A\n");
    else if(b == 1)printf("B\n");
    else printf("C\n");

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,n2;
    cin >> n;
    n2 = n;
    int cnt = 0;
    while(n2 > 0){
        cnt += (n2%10);
        n2 /= 10;
    }
    if(n%cnt == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
While ($line = fgets(STDIN) ) {
    $stdin[] = trim($line);
}
$v = explode(" ", $stdin[1] );

$v_sort=$v;
sort($v_sort);

$cnt=0;
for($i=0; $i<$stdin[0]; $i++){
  if($v[$i]!=$v_sort[$i]){
    $cnt+=1;
  }
}
if($cnt==0 || $cnt==2){
  echo 'YES';
}else{
  echo 'NO';
}

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

typedef long long ll;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int leftCount = 0;
    int leftMax = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == ')'){
            leftCount++;
            leftMax = max(leftMax, leftCount);
        }else{
            leftCount--;
        }
    }
    string answer = "";
    for(int i = 0; i < leftMax; i++){
        answer += '(';
    }
    answer += S;
    int rightCount = 0;
    for(int i = 0; i < answer.size(); i++){
        if(answer[i] == '('){
            rightCount++;
        }else{
            rightCount--;
        }
    }
    for(int i = 0; i < rightCount; i++){
        answer += ')';
    }
    cout << answer << endl;
    return 0;
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, X;
  cin >> N >> X;
  int L[N];
  REP(i, N) cin >> L[i];

  int cnt = 0;
  int D = 0;
  int i = 0;

  while(D<=X&&i<=N){
    D += L[i];
    i++;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            if (X >= 30)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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


using ll = long long;
const int Mod = 1e9+7;
const int L = 2e6+10;
ll fac[L];
int r1, c1, r2, c2;


void exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0) {x = 1, y = 0; return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}


ll invmod(ll a, ll m) {
    ll x, y;
    exgcd(a, m, x, y);
    return (x % m + m) % m;
}


void init()
{
    fac[0] = 1;
    for (int i = 1; i < L; i++) fac[i] = fac[i - 1] * i % Mod;
}


ll g(int r, int c)
{
    // sum(i = 0, r, sum(j = 0, c, binomial(i + j, i)))
    // = binomial(c + r + 2, c + 1) - 1
    // = (c + r + 2)! / (c + 1)! / (r + 1)! - 1
    ll ans = fac[c + r + 2] * invmod(fac[c + 1], Mod) % Mod;
    ans = ans * invmod(fac[r + 1], Mod) % Mod;
    ans = (ans - 1 + Mod) % Mod;
    return ans;
}


void solve()
{
    ll ans = g(r2, c2) - g(r1 - 1, c2) - g(r2, c1 - 1) + g(r1 - 1, c1 - 1);
    ans = (ans % Mod + Mod) % Mod;
    cout << ans << endl;
}


int main()
{
    cin >> r1 >> c1 >> r2 >> c2;
    init();
    solve();
    return 0;
}


Measured memory_bytes: 15872
N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
A_point=[0]*N

for a in A:
  A_point[a-1]+=1

for aa in A_point:
  if K-(Q-aa)<=0:
    print("No")
  else:
    print("Yes")
  
  

Measured memory_bytes: 56024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static ArrayList<Integer> fun(int n){
        ArrayList<Integer> prime = new ArrayList<>();
        prime.add(2);
        for(int i = 3;i < n ;i++){
            boolean flag = true;
            for(Integer num : prime){
                if(i%num==0){
                    flag = false;
                    break;
                }
            }
            if(flag){prime.add(i);}
        }
        return prime;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        ArrayList<Integer> prime_l = fun(N);
        while(true){
            boolean a = true;
            for(Integer p_num : prime_l){
                if(N%p_num==0){
                    a = false;
                    break;
                }
            }
            if(a || N == 2){
                System.out.println(N);
                break;
            }
            N++;
        }
    }
}

Measured memory_bytes: 25776
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := pronounce(n)
	fmt.Println(answer)
}

func pronounce(n int) string {
	digits := strconv.Itoa(n)
	switch a, _ := strconv.Atoi(string(digits[len(digits)-1])); a {
	case 3:
		return "bon"
	case 0, 1, 6, 8:
		return "pon"
	default:
		return "hon"
	}
}


Measured memory_bytes: 1820
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
typedef long long LL;
using namespace std;
LL x, y;
int main() 
{
	while(~scanf("%lld%lld", &x, &y)) {
		LL res = 1, tmp = 2;
		while(tmp * x <= y) res++, tmp = tmp * 2LL;
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	if n%2 != 0 {
		for i := 0; i < m; i++ {
			fmt.Println(i+1, n-i)
		}
	} else if m%2 == 0 {
		for i := 0; i < m; i++ {
			if i < m/2 {
				fmt.Println(i+1, n-i)
			} else {
				fmt.Println(i+2, n-i)
			}
		}
	} else {
		for i := 0; i < m; i++ {
			if i <= m/2 {
				fmt.Println(i+1, n-i)
			} else {
				fmt.Println(i+2, n-i)
			}
		}
	}
}


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

int main() {
  int a,b,c;
  
cin >> a >> b >> c;

if(a==b){
    if(b!=c){cout << "Yes" << endl;}
    if(b==c){cout << "No"<<endl;}
}
else if(a==c){
    if(a!=b){cout << "Yes" << endl;}
}
else if(b==c){
    if(a!=b){cout << "Yes" << endl;}
}
else cout << "No" << endl;

}

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

int main()
{
 int n,m;
 cin>>n;
  map<string,int> b,r;
  for(int i=0;i<n;i++)
  {
    string h;
    cin>>h;
    if(b.find(h)==b.end())
      b[h]=1;
    else
      b[h]++;
  }
  cin>>m;
  
  for(int i=0;i<m;i++)
  {
    string h;
    cin>>h;
    if(r.find(h)==r.end())
      r[h]=1;
    else
      r[h]++;
  }
  int maxa=0;
  for(auto i:b)
  {
  	
   int l=0;
    if(r.find(i.first)!=r.end())
      l=r[i.first];
    maxa = max(maxa,i.second-l);
  }
  cout<<maxa<<"\n";
  
  return 0;
}


Measured memory_bytes: 256
<?php
    

    $N = intval(trim(fgets(STDIN)));
    
    $W = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $ans = INF;
    for($i=0;$i<$N;$i++){
        $S1=0;
        $S2=0;
        foreach($W as $key => $value){
    
            if($i>$key){
                $S1+=$value;
            }else{
                $S2+=$value;
            }
            
        }
        if($ans > abs($S1-$S2)){
            $ans =  abs($S1-$S2); 
        }
    }
    echo $ans;
    
    
    
    

?>

Measured memory_bytes: 15740
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
l.sort()
cnt = 0
a = 0
b = 0
c = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        a = l[i]
        for j in range(i+1,n-1):
            b = l[j]
            for k in range(j+1,n):
                c = l[k]
                if a+b > c and a != b and b != c:
                    cnt += 1
    print(cnt)

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

int main(void){
    int N, M, ans;
    int L, R, maxL = 0, minR = 1e5;

    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> L >> R;
        maxL = max(maxL, L);
        minR = min(minR, R);
    }
    if(maxL <= minR){
        ans = minR - maxL + 1;
    }else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int p = sc.nextInt();
		int ans = (a*3+p)/2;
		System.out.println(ans);
		sc.close();
	}
	
    
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define eb emplace_back
#define EQ(a, b) abs(a - (b)) < 1e-10
const double eps = 1e-10;
using P = complex<double>;
double dot(P a, P b) {return real(conj(a) * b);}
double cross(P a, P b) {return imag(conj(a) * b);}
struct L : vector<P> {L(const P &a = P(), const P &b = P()) {push_back(a); push_back(b);}};
double distLP(L l, P p) {return abs(cross(l[0] - l[1], p - l[0])) / abs(l[1] - l[0]);
    /*return abs(p - projection(l, p));*/}
double distSP(L l, P p) {
    if (dot(l[1] - l[0], p - l[0]) < eps) return abs(l[0] - p);
    if (dot(l[0] - l[1], p - l[1]) < eps) return abs(l[1] - p);
    return distLP(l, p);
}
double norm(P a) {return a.real() * a.real() + a.imag() * a.imag();}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(P p0, P p1, P p2) {
    P a = p1 - p0;
    P b = p2 - p0;
    if (cross(a, b) > eps) return COUNTER_CLOCKWISE;
    if (cross(a, b) < -eps) return CLOCKWISE;
    if (dot(a, b) < -eps) return ONLINE_BACK;
    if (norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool isec(P p1, P p2, P p3, P p4) {
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);}
bool isec(L s1, L s2) {return isec(s1[0], s1[1], s2[0], s2[1]);}
double distSS(L a, L b) {
    if (isec(a, b)) return 0.0;
    return min({distSP(a, b[0]), distSP(a, b[1]), distSP(b, a[0]), distSP(b, a[1]), distSP(b, a[0])});
}
int main() {
    int q; cin >> q;
    while (q--) {
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
        L s0(p0, p1), s1(p2, p3);
        cout << fixed << setprecision(10) << distSS(s0, s1) << endl;
    }
}



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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

#define MAX_N 100000
#define NIL -1
#define ROOT 0
#define LEAF 1
#define INTERNAL 2

// left-child, right-sibling representation
struct Node {
  int parent, left, right;
};

Node T[MAX_N + 5];
int D[MAX_N + 5];

void setDepth(int i, int d) {
  D[i] = d;
  if (T[i].right != NIL) setDepth(T[i].right, d);
  if (T[i].left != NIL) setDepth(T[i].left, d + 1);
}

int getType(Node n) {
  if (n.parent == NIL)
    return ROOT;
  else if (n.left == NIL)
    return LEAF;
  else
    return INTERNAL;
}

string convertType(int n) {
  if (n == ROOT)
    return "root";
  else if (n == LEAF)
    return "leaf";
  else
    return "internal node";
}

void printChild(int i) {
  if (T[i].left == NIL) return;
  int n = T[i].left;
  int cnt = 0;
  while (n != NIL) {
    if (cnt > 0) cout << ", ";
    cout << n;
    n = T[n].right;
    cnt++;
  }
}

void printNode(int i) {
  printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);
  cout << convertType(getType(T[i])) << ", [";
  printChild(i);
  cout << "]" << endl;
}

int findRoot(int n) {
  rep(i, n) if (getType(T[i]) == ROOT) return i;
  return -1;
}

int main() {
  int n;
  cin >> n;
  // initialize T
  rep(i, n) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  rep(i, n) {
    int p_id, k;
    cin >> p_id >> k;
    int prev = NIL;
    rep(j, k) {
      int c_id;
      cin >> c_id;
      T[c_id].parent = p_id;
      if (j == 0) T[p_id].left = c_id;
      if (j > 0) T[prev].right = c_id;
      prev = c_id;
    }
  }
  setDepth(findRoot(n), 0);
  rep(i, n) printNode(i);
  return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


vector<int> plist;
bool IsPrime(ll x){
  for(auto e:plist){
    if(x%e==0)return false;
  }
  return true;
}

void Mkplist(){
  plist.push_back(2);
  for(int i = 3; i < 1010; ++i){
    if(IsPrime(i))plist.push_back(i);
  }
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};


int main(){
  Mkplist();
  int n;
  cin >> n;
  const ll mod = 7 + (1e+9);
  map<int,modint<mod>> st;
  for(int i = 2; i <= n; ++i){
    int j = i;
    while(j!=1){
      for(auto e:plist){
	while(j%e==0){
	  st[e]++;
	  j/=e;
	}
      }      
    }
  }
  modint<mod> ans = 1;
  for(auto e:st){
    ans *= (e.second+1);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int64_t S;
  cin >> S;
  int64_t N;
  int64_t ans=0;
  int64_t p;
  int64_t kumi[S][S];
  for (int i=0; i<S; i++){
    kumi[i][0]=1;
    kumi[i][i]=1;
  }
  for (int i=1; i<S; i++){
    for (int j=1; j<i; j++){
      kumi[i][j]=kumi[i-1][j-1]+kumi[i-1][j] % 1000000007;
    }
  }
  /*
  for (int i=0; i<S; i++){
    for (int j=0; j<=i; j++){
      cout << kumi[i][j] << " ";
    }
    cout << endl;
  }
  */
  N=S/3;
//  cout << S << "," << N << endl; 
  for (int i=1; i<=N; i++){
    p=S-3*i;
//    cout << p << endl;
    if (p>=0){
      ans += kumi[p+i-1][p];
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 26160
K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Measured memory_bytes: 9116