akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string a,b; cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(b.size()>a.size()){
        cout<<"LESS"<<endl;
        return 0;
    }else {
        rep(i,a.size()){
            if(a[i]==b[i])continue;
            else if(a[i]>b[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }else{
                cout<<"LESS"<<endl;
                return 0;
            }
        }
    }
    cout<<"EQUAL"<<endl;
    
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int u = a*x+b*y;
  int s = (2*x)*c + max(0,y-x)*b;
  int t = (2*y)*c + max(0,x-y)*a;
    cout << min(u,min(s,t)) << endl;
  return 0;
}


Measured memory_bytes: 256
// maximum difference

#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100

int main(void){
    int n;
    scanf("%d", &n);
    int ar[MAXSIZE];
    int i;
    for(i = 0; i < n; i++){
        scanf("%d", &ar[i]);
    }
    
    int j;
    int max = -5142;
    for(i = 0; i < n - 1; i++){
        for(j = i + 1; j < n; j++){
            if(abs(ar[i] - ar[j]) > max){
                max = abs(ar[i] - ar[j]);
            }
        }
    }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto p:mp){
        if(p.first>p.second){
            ans+=p.second;
        }
        else if(p.first<p.second){
            ans += p.second-p.first;
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 5120
#include<stdio.h>
#include<math.h>
int main()
{
	int n,s[1005],i;
	double a,x;
	for(;scanf("%d",&n),n;)
	{
		for(i=a=0;i<n;a+=s[i++])
			scanf("%d",&s[i]);
		a/=n;
		for(i=x=0;i<n;i++)
			x+=(s[i]-a)*(s[i]-a);
		printf("%.8f\n",sqrt((double)x/n));
	}
	return 0;
}

Measured memory_bytes: 640
S = input()
rev_S = S.replace("x", "")

if rev_S != rev_S[::-1]:
    print(-1)
    exit()

res = 0

N = len(S)
l, r = 0, N - 1
while l < r:
    if S[l] == S[r]:
        l, r = l + 1, r - 1
    elif S[l] == "x":
        l += 1
        res += 1
    elif S[r] == "x":
        r -= 1
        res += 1

print(res)


Measured memory_bytes: 3316
(declaim (optimize (speed 3) (safety 0) (debug 0)))
(defun solve (n a b)
  (cond
    ((> a b) 0)
    ((= n 1) (if (= a b) 1 0))
    (t (1+ (* (- n 2) (- b a))))))
(format t "~A~%" (solve (read) (read) (read)))

Measured memory_bytes: 3812
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    vector<int> bfs_fwd(n, 1 << 30);
    bfs_fwd[0] = 0;

    queue<int> que_fwd;
    que_fwd.push(0);
    while (!que_fwd.empty()) {
        int q = que_fwd.front();
        que_fwd.pop();

        for (int i = 0; i < static_cast<int>(graph[q].size()); i++) {
            if (bfs_fwd[graph[q][i]] > bfs_fwd[q] + 1) {
                bfs_fwd[graph[q][i]] = bfs_fwd[q] + 1;
                que_fwd.push(graph[q][i]);
            }
        }
    }

    vector<int> bfs_rev(n, 1 << 30);
    bfs_rev[n - 1] = 0;

    queue<int> que_rev;
    que_rev.push(n - 1);
    while (!que_rev.empty()) {
        int q = que_rev.front();
        que_rev.pop();

        for (int i = 0; i < static_cast<int>(graph[q].size()); i++) {
            if (bfs_rev[graph[q][i]] > bfs_rev[q] + 1) {
                bfs_rev[graph[q][i]] = bfs_rev[q] + 1;
                que_rev.push(graph[q][i]);
            }
        }
    }

    int f_pt = 0, s_pt = 0;
    for (int i = 0; i < n; i++) {
        if (bfs_fwd[i] <= bfs_rev[i]) {
            f_pt++;
        } else {
            s_pt++;
        }
    }

    cout << (f_pt > s_pt ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi in(7368792);
		int t=n;
		while(m--){
			while(in[t])t++;
			for(int i=t;i<7368792;i+=t)in[i]=true;
		}
		while(in[t])t++;
		cout<<t<<endl;
	}
}

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

using namespace std;

int main()
{
    int n;
    string a,b;

    cin >> a >> b;
    
    n = stoi(a+b);
    for(int i = 1;i <= 1000;i++){
        if(i*i == n){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> a(h+1);
  REP(i,h) cin>>a[i];

  int cnt=0;
  REP(i,h){
    REP(j,w){
      if(a[i][j]=='#') cnt++;
    }
  }
  cout<<((cnt==h+w-1)? "Possible":"Impossible")<<endl;

  return 0;
}

Measured memory_bytes: 256
// arock - 2019-02-16

#include <iostream>
#include <vector>

template <class T> std::vector<T> read(int n) {
    std::vector<T> res(n);
    for (auto& r : res) {
        std::cin >> r;
    }

    return res;
}

template <class T> T gcd(T a, T b) {
    return b == 0? std::abs(a) : gcd(b, a % b);
}

int main() {
    int N;
    std::cin >> N;
    auto A = read<int>(N);

    int ans = 0;
    for (int a : A) ans = gcd(ans, a);

    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-(a-b)) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

n, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
if x < a[0]:
    print(0)
    exit()

if sum(a) < x:
    print(n-1)
    exit()

cnt = 0 
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        cnt += 1

ans = cnt 
print(ans)


Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()


using namespace std;

const bool dbg_flg = 1;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n'
 
const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

ll h, w, n;

int main() {

	cin >> h >> w >> n;

	cout << n / max(h, w) + (n % max(h, w) != 0);
	
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, x, k;
	cin >> n;
	int l = 1e6;
	while (n--) {
		cin >> x;
		k = 0;
		while (x%2 == 0) {
			x /=2;
			++k;
		}
		
		k = min(k, l);
		l = k;

	}
	
	cout << k;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    double a, b;
    cin >> a >> b;
    int a_min = ceil(a * 12.5), a_max = ceil(((a + 1) * 12.5) - 1);
    int b_min = b * 10, b_max = (b + 1) * 10 - 1;
    int ans = 0;
    if(b_max < a_min || a_max < b_min){
        ans = -1;
    }else{
        ans = max(a_min, b_min);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int A, B;
	cin >> A >> B;
	if (A >= 13)cout << B << endl;
	else if (A >= 6)cout << B / 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, L, R; cin >> N >> K >> L >> R;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int> A[41], B[41];
	A[0].emplace_back(0);
	B[0].emplace_back(0);
	rep(i, 0, N / 2) {
		rrep(k, 0, K) {
			rep(j, 0, A[k].size()) {
				A[k + 1].emplace_back(A[k][j] + a[i]);
			}
		}
	}
	rep(i, N / 2, N) {
		rrep(k, 0, K) {
			rep(j, 0, B[k].size()) {
				B[k + 1].emplace_back(B[k][j] + a[i]);
			}
		}
	}
	int ans = 0;
	rep(k, 0, K + 1) {
		sort(all(A[k]));
		sort(all(B[K - k]));
		rep(i, 0, A[k].size()) {
			ans += upper_bound(all(B[K - k]), R - A[k][i]) - lower_bound(all(B[K - k]), L - A[k][i]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

int main() {
  long long N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i], --A[i], --B[i];
  }
  UnionFind uf(N);
  long long cur = N * (N - 1) / 2;
  vector<long long> res;
  for (int i = 0; i < M; ++i) {
    res.push_back(cur);

    int a = A[M - 1 - i], b = B[M - 1 - i];
    if (uf.issame(a, b)) continue;

    long long sa = uf.size(a), sb = uf.size(b);
    cur -= sa * sb;
    uf.merge(a, b);
  }

  reverse(res.begin(), res.end());
  for (int i = 0; i < res.size(); ++i) cout << res[i] << endl;
}


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

int main(void) {
    int N;

    cin >> N;

    int a[N+1];

    for(int i=1; i<=N; i++)
      a[i] = i;

    long long int ans=0;

     for(int i=1; i<=N; i++){
       if(a[i]%3==0 || a[i]%5==0)
        a[i] = 0;

        ans += a[i];
     }

     cout << ans << endl;



    return 0;
}


Measured memory_bytes: 7440
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left

def main():
	A, B = map(int, input().split(" "))
	
	if B % A == 0:
		print(A+B)
	else:
		print(B-A)
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	ios::sync_with_stdio(false);
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n), y(n), a(n);
	int kbx = 0;
	int kby = 0;
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) kbx = max(x[i], kbx);
		if (a[i] == 2) w = min(x[i], w);
		if (a[i] == 3) kby = max(y[i], kby);
		if (a[i] == 4) h = min(y[i], h);
	}
	int d = 0;
	if (h > kby && w > kbx) d = (h - kby) * (w - kbx);
	cout << d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y){x=x%MOD;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=MOD;y=y>>1;x=x*x;x%=MOD;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];


    ll pre[n][n]; // to store sums from i..j
    for(int i=0;i<n;i++)
    for(int j=i;j<n;j++)
    {
      if(i==j)
      pre[i][j]=a[i];
      else
      pre[i][j]=pre[i][j-1]+a[j];
    }

    ll dp[n][n]; // dp[i][j] denotes the minimum cost to combine subarray i to j {i and j inclusive}
    // initialize the dp array with infinity
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      dp[i][j]=LLONG_MAX;

    for(int i=0;i<n;i++)
      dp[i][i]=0;
    // cost of merging single element is 0 as nothing to merge with

    for(int i=n-1;i>=0;i--)// filling backwards
    for(int j=i;j<n;j++)
    {
      // we are trying to find mincost of array i..j
      // now consider an example:
      // lets say 3....6 it can be formed by merging 3..4 and 5..6 or 3..5 and 6 or 3 and 4...6  and so on
      // we'll try all such possible split points
      // lets call a split point as k so we'll iterate over k
      // so for i,...j we are using results for i...k and k+1...j & try all possible k
      if(j==i)continue; // we have already computed the result as 0
      else if(j==i+1) dp[i][j]=min(dp[i][j],a[i]+a[j]); // cost of combining two slimes is a[i]+a[j]
      else
      {
        for(int k=i;k<j;k++)
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+pre[i][k]+pre[k+1][j]);// now since we are combining slimes i..k and and k+1...j, we need to add their weights as well
      }
    }

    cout<<dp[0][n-1]<<"\n"; // this should contain the minimum cost for complete array 0....n-1;
    // lets test
/*
    for(int i=n-1;i>=0;i--)
    {
      for(int j=i;j<n;j++)
      cout<<dp[i][j]<<" ";

      cout<<"\n";
    }*/

    // ok so we forgot to add the weights of the individual slimes
    // now obviously weight of slime from i to j will be a[i]+a[i+1]+......a[j]
    // we can precompute this using prefix sums & lets store it in 2d array


    // done
    // ill mail you the code
    // go through it , any doubts then call
}


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

int main() {
  int N; cin >> N;
  vector<int> L(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
    sum += L.at(i);
  }
  sort(L.begin(), L.end());
  bool ok = false;
  if (sum - L.at(L.size() - 1) > L.at(L.size() - 1)) {
    ok = true;
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int MAX = 101010;
    vb is_prime(MAX+1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 2 ; i <= MAX ; i++){
        if(!is_prime[i]) continue;
        for(int j = 2 * i ; j <= MAX ; j += i){
            is_prime[j] = false;
        }
    }

    vector<int> a(MAX, 0);
    for(int i = 0 ; i <= MAX ; i++){
        if(i%2==0) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    vector<int> s(MAX+1, 0);
    for(int i = 0 ; i <= MAX ; i++){
        s[i+1] = s[i] + a[i];
    }

    int q;
    cin >> q;
    for(int i = 0 ; i < q ; i++){
        int a, b;
        cin >> a >> b;
      b++;
        cout << s[b] - s[a] << endl;
    }
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);

if((A>=1&&A<=9)&&(B>=1&&B<=9)&&(C>=1&&C<=9)){
    if(A==B&&A==C&&B==C){
        printf("No\n");
    }

     else if(A==B&&A!=C){
            printf("Yes\n");
        }
    else if(B==C&&A!=B){
        printf("Yes\n");

    }
    else if(A==C&&B!=C){
        printf("Yes\n");
    }
else{
    printf("No\n");
}
  }  return 0;
    }

Measured memory_bytes: 128
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] a = new int[m];
      int[] b = new int[m];
      HashSet<Integer> set1 = new HashSet<>();
      HashSet<Integer> set2 = new HashSet<>();
      for(int i = 0;i < m;i++){
      	a[i]=sc.nextInt();
        b[i]=sc.nextInt();
        if(a[i]==1)set1.add(b[i]);
        if(b[i]==n)set2.add(a[i]);
      }
      set1.retainAll(set2);
      if(set1.size()>0)System.out.println("POSSIBLE");
      else
      System.out.println("IMPOSSIBLE");
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 120352
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String W = scan.next();
		int cnt = 0;
		for(;;){
			String T = scan.next();
			if(T.equals("END_OF_TEXT")){
				break;
			} else{
				String TT = T.toLowerCase();
				String WW = W.toLowerCase();
				if(TT.equals(WW)){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26128
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    S = input()
    bs = S[0]
    ans = 1
    for s in S[1::]:
        if bs != s:
           bs = s 
           ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5880
# -*- coding: utf-8 -*-
X = int(input())


def exponential(X):
    value = 1
    for n in range(34):
        for p in range(2, 10):
            tmp = n ** p
            if tmp > X:
                break
            else:
                value = max(value, tmp)
    return value


print(exponential(X))


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

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, a, b; cin >> n >> a >> b;
	cout << n/(a+b)*a + min(n%(a+b), a);
	
	return 0;
} 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if (A==B&&B==C) {
    if (A%2==0) cout << -1 << endl;
    else cout << 0 << endl;
  }
  else {
    ll ans = 0LL;
    while (A%2==0&&B%2==0&&C%2==0) {
      ll A0 = A, B0 = B, C0 = C;
      A = (B0+C0)/2;
      B = (C0+A0)/2;
      C = (A0+B0)/2;
      ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define pb          push_back
#define ff          first
#define ss          second
#define ll          int64_t
#define ld          long double
#define mod         1000000007
#define mod2        998244353
#define inf         1000000000000007
#define pi          3.14159265358979323846
#define nl          cout<<"\n"
#define dbg(x)      cerr<<#x<<" = "<<x<<"\n"
#define all(v)      v.begin(),v.end()
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

template<typename T,typename U> static inline void amin(T &x,U y)   {if(y<x)x=y;}
template<typename T,typename U> static inline void amax(T &x,U y)   {if(x<y)x=y;}  

ll lcm(ll a,ll b)       {return (a*b)/__gcd(a,b);} 
ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
string dec_bin_32(ll n) {string s;for(ll i=31;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
string dec_bin_64(ll n) {string s;for(ll i=63;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 

//-------------------------------L_I_Erq34-------------------------------

vector<ll> dp(100007,inf);

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n>>k;
	pair<ll,ll> a[n];
	forn(i,0,n)
		cin>>a[i].ff>>a[i].ss;
	dp[0]=0;
	forn(i,0,n)
		forb(j,100000,a[i].ss)
			dp[j]=min(dp[j],dp[j-a[i].ss]+a[i].ff);
	z=0;
	forb(i,100000,0)
		if(dp[i]<=k)
		{
			z=i;
			break;
		}
	cout<<z<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;

    if(b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s.at(i);

    int sum = 0;
    rep(i, n){
        sum += s.at(i);
    }

    sort(s.begin(), s.end());
    if(sum%10!=0){
        cout << sum << endl;
        return 0; 
    }

    for(int i=0; i<n; i++){
        if(s.at(i)%10==0){
            dump(s.at(i));
            continue;
        }
        else {
            sum -= s.at(i);
            break;
        }
    }

    if(sum%10==0){
        cout << 0 << endl;
        return 0;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a[100],i,j,tmp,flag=1,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	sum++;
        tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  printf("%d\n",sum);
}



Measured memory_bytes: 2108
from heapq import*;L,R=[],[];B=t=0;Q,*E=open(0)
for e in E:
  if' 'in e:_,a,b=map(int,e.split());t^=1;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
  else:print(-L[0],B-L[0]*t)

Measured memory_bytes: 28656
from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)

Measured memory_bytes: 19928
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {

  int k, s;
  in, k, s;

  int cnt = 0;
  k++;
  rep(x, k)rep(y, k) {
    int tmp = s - x - y;
    if (0<=tmp && tmp < k) {
      cnt += 1;
    }
  }

  cout << (cnt) << endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Pair implements Comparable<Pair>{
	int A, B;
	public Pair(int _A, int _B) {
		A = _A;
		B = _B;
	}
	public int compareTo(Pair o) {
		return A - o.A;
	}

}

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		Pair[] energy = new Pair[N];
		for(int i = 0; i < N; i++) {
			energy[i] = new Pair(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(energy);
		long cost = 0;
		for(int i = 0; i < N; i++) {
			if(M == 0) break;
			int buy = Math.min(energy[i].B, M);
			M -= buy;
			cost += (long)buy * (long)energy[i].A;
		}
		System.out.println(cost);
	}
}


Measured memory_bytes: 88044
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int count = scanner.nextInt();
		Card[] sortListb = new Card[count];
		Card[] sortLists = new Card[count];
		for(int i = 0; i < count; i++){
			Card card = new Card(scanner.next());
			sortListb[i] = card;
			sortLists[i] = card;
		}
		bubbleSort(sortListb, count);
		selectionSort(sortLists, count);
		print(sortListb, count);
		System.out.println("Stable");
		print(sortLists, count);
		if(isStable(sortListb, sortLists, count)){
			System.out.println("Stable");
		}else{
			System.out.println("Not stable");
		}
	}

	private static void bubbleSort(Card[] sortListb, int count){
		Card temp;
		for(int j = 0; j < count; j++){
			for(int i = count - 1; i > j; i--){
				if(sortListb[i].value < sortListb[i - 1].value){
					temp = sortListb[i];
					sortListb[i] = sortListb[i - 1];
					sortListb[i - 1] = temp;
				}
			}
		}
	}

	private static void selectionSort(Card[] sortLists, int count){
		int min;
		Card temp;
		for(int i = 0; i < count - 1; i++){
			min = i;
			for(int j = i; j < count; j++){
				if(sortLists[j].value < sortLists[min].value){
					min = j;
				}
			}
			temp = sortLists[i];
			sortLists[i] = sortLists[min];
			sortLists[min] = temp;
			if(min != i){
			}
		}
	}

	private static void print(Card[] list, int count){
		for(int i = 0; i < count; i++){
			if(i != count - 1){
				System.out.print(list[i] + " ");
			}else{
				System.out.println(list[i]);
			}
		}
	}

	private static boolean isStable(Card[] lista, Card[] listb, int count){
		for(int i = 0; i < count; i++){
			if(lista[i].suit != listb[i].suit){
				return false;
			}
		}
		return true;
	}

	private static class Card{
		private char suit;
		private int value;
		Card(String value) {
			suit = value.charAt(0);
			this.value = Integer.parseInt(String.valueOf(value.charAt(1)));
        }

        @Override
        public String toString() {
            return suit + String.valueOf(value);
        }
	}
}

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

int main(){
char s[100];
cin >> s;
int count = 0;
for(int i=0; i<strlen(s); i++){
for(int j=i + 1; j<strlen(s); j++){
if(s[i] == s[j]){
cout << "no" << endl;
return 0;
}
}
}

cout << "yes" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

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

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll gcd(ll a,ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}

int main()
{
    fsscan();
    ll a,b;
    cin>>a>>b;
    cout<<ceil((b-1)/(double)(a-1));
    return 0;
}


Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <memory.h>
#include <sstream>
#include <queue>
#include <cassert>
#include <ctime>
#include <complex>
#include <unordered_map>
#include <random>
 
using namespace std;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pll;
typedef pair<int64, int> pli;
typedef pair<pii, pii> piiii;
typedef pair<int64, int> pli;
typedef pair<int, char> pic; 

#define pb push_back
#define sq(x) ((x)*(x))
#define cube(x) (((x)*(x))*(x))
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define rand32() (((unsigned int)(rand()) << 16) | (unsigned int)(rand()))
#define rand64() (((unsigned int64)(rand32()) << 16) | (unsigned int64)(rand32()))
#define bit(mask, b) ((mask >> b) & 1)
#define biton(mask, bit) (mask | (((uint64)(1)) << bit))
#define bitoff(mask, bit) (mask & (~(((uint64)(1)) << bit)))
#define bitputon(mask, bit) (mask |= (((uint64)(1)) << bit))
#define bitputoff(mask, bit) (mask &= (~(((uint64)(1)) << bit)))
#define FAIL() (*((int*)(0)))++
#define INF ((int)(1e9) + 1337)
#define EPS (1e-9)
#define y1 yy1
#define y0 yy0
#define j0 jj0

const long double PI = acosl((long double)-1.0);
const int64 LINF = (int64)4e18;//((1ull << 63) - 1ull);
const int MOD = 1000000007;
int test;

int64 a[3];
int64 diff;

void init()
{
	scanf ("%lld%lld%lld", &a[0], &a[1], &a[2]);
}

void solve()
{
	init();
	for (int i = 0; i < 3; i++)
	{
		if (!(a[i] & 1LL))
		{
			printf("0\n");
			return;
		}
	}
	sort (a, a + 3);
	printf("%lld\n", a[0] * a[1]);
}

void precalc()
{
	
}

void test_output()
{
	
}

int main()
{
	//srand(time(0)); test_output(100, 100, 100); 
    //ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
	double start = clock();
	precalc();
	int tests = 1;
	//scanf ("%d", &tests);
	for (test = 1; test <= tests; test++)
	{
		solve();
	}
	//fprintf(stderr, "%.5lf\n", (clock() - start) / CLOCKS_PER_SEC);
    return 0;
}

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

const lli mod = 998244353;

lli inverse(lli a){
	lli r0 = a, r1 = mod, ri, s0 = 1, s1 = 0, si;
	while(r1){
		si = s0 - s1 * (r0 / r1), s0 = s1, s1 = si;
		ri = r0 % r1, r0 = r1, r1 = ri;
	}
	assert(r0 == 1);
	if(s0 < 0) s0 += mod;
	return s0;
}

lli rec(const vector<lli> & P, const vector<lli> & init, lli n){
	int deg = P.size();
	vector<lli> ans(deg), R(2*deg);
	ans[0] = 1;
	lli p = 1;
	for(lli v = n; v >>= 1; p <<= 1);
	do{
		int d = (n & p) != 0;
		fill(R.begin(), R.end(), 0);
		for(int i = 0; i < deg; i++)
			for(int j = 0; j < deg; j++)
				(R[i + j + d] += ans[i] * ans[j]) %= mod;
		for(int i = deg-1; i >= 0; i--)
			for(int j = 0; j < deg; j++)
				(R[i + j] += R[i + deg] * P[j]) %= mod;
		copy(R.begin(), R.begin() + deg, ans.begin());
	}while(p >>= 1);
	lli nValue = 0;
	for(int i = 0; i < deg; i++)
		(nValue += ans[i] * init[i]) %= mod;
	return nValue;
}

int ncr(lli n, lli r){
	if(r < 0 || r > n) return 0;
	r = min(r, n - r);
	lli ans = 1;
	for(lli den = 1, num = n % mod; den <= r; den++, num--){
		ans = ans * num % mod * inverse(den) % mod;
	}
	return ans;
}

auto mult(const vector<int> & a, const vector<int> & b){
	vector<int> c(a.size() + b.size() - 1);
	for(int i = 0; i < a.size(); ++i){
		for(int j = 0; j < b.size(); ++j){
			c[i+j] += (lli)a[i] * b[j] % mod;
			if(c[i+j] >= mod) c[i+j] -= mod;
		}
	}
	return c;
}

void clean(vector<int> & poly){
	while(!poly.empty() && poly.back() == 0) poly.pop_back();
	if(poly.empty()) poly.push_back(0);
}

auto quotient(const vector<int> & a, const vector<int> & b){
	vector<int> r = a, ans;
	while(r.size() >= b.size() && !(r.size() == 1 && r[0] == 0)){
		size_t g = r.size() - b.size();
		lli q = r.back() * inverse(b.back()) % mod;
		if(ans.size() <= g) ans.resize(g+1);
		ans[g] += q;
		if(ans[g] >= mod) ans[g] -= mod;
		for(int i = 0; i < b.size(); ++i){
			r[i+g] -= b[i] * q % mod;
			if(r[i+g] < 0) r[i+g] += mod;
		}
		clean(r);
		clean(ans);
	}
	assert(r.size() == 1 && r[0] == 0);
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; lli m;
	cin >> n >> m;
	--n;
	if(n == 0){
		cout << rec({1, 1}, {0, 1}, m) << "\n";
		return 0;
	}
	vector<int> num(n+1);
	lli curr = 1;
	for(int i = 0; i <= n; ++i){
		num[i] = curr;
		if(!(i & 1)) num[i] = mod - num[i];
		curr = curr * (n - i) % mod * inverse(i + 1) % mod;
	}
	num = mult(num, {(int)rec({1, 1}, {0, 1}, 2*n), (int)rec({1, 1}, {0, 1}, 2*n-1)});
	num[1] = (num[1] + 1) % mod;
	vector<int> den = {1, mod-1, mod-1};
	auto P = quotient(num, den);
	lli ans = (rec({1, 1}, {0, 1}, 2*n) * rec({1, 1}, {1, 1}, m) % mod + rec({1, 1}, {0, 1}, 2*n-1) * rec({1, 1}, {0, 1}, m) % mod) % mod;
	curr = ncr(m + n-1, n-1);
	for(int i = 0; i <= m && i < P.size(); ++i){
		ans += (lli)P[i] * curr % mod;
		if(ans >= mod) ans -= mod;
		if((m - i + n - 1) % mod == 0){
			curr = ncr(m-(i+1) + n-1, n-1);
		}else{
			curr = curr * ((m - i) % mod) % mod * inverse((m - i + n - 1) % mod) % mod;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2544
#include<math.h>
#include<stdio.h>
int main(void){
  long long int N;
  int i,z;
  long long int a;
  double j;
  scanf("%lld",&N);
  j=sqrt((double)N);
  a=1;
  for(i=(int)j;i>2;i--){
    if(N%i==0){
      a=i;
      N=N/i;
      break;
    }
  }
  z=0;
  if(a>=N){
    while(a>0){
      z++;
      a=a/10;
    }
  }else{
    while(N>0){
      z++;
      N=N/10;
    }
  }
  printf("%d\n",z);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <cstdio>
#include <iomanip>
#include <list>
#include <set>
#include <cmath>

using namespace std;

int getNumber(vector<int> bits, int count) {
	int result = 0;
	for (int i = 0; i < bits.size(); i++) {
		if (i < count) {
			continue;
		}
		if (bits[i] > 0) {
			result += pow(2, i);
		}
		
	}
	return result;
}

int main(void) {
	long long L;
	scanf("%lld\n", &L);
	auto ll = L;
	auto bits = vector<int>(20, 0);
	int count = 0;
	int bits_sum = 0;
	while (L > 0) {
		bits[count] = L % 2;
		bits_sum += bits[count];
		L /= 2;
		count++;
	}


	printf("%d %d\n", count, 2 * (count - 1) + (bits_sum-1));
	for (int i = 1; i < count; i++) {
		printf("%d %d %d\n", i, i + 1, 0);
		int p = pow(2, i-1);
		printf("%d %d %d\n", i, i + 1, p);

		if (bits[i-1] == 1) {
			printf("%d %d %d\n", i, count, getNumber(bits, i));
		}
	}

	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(((n-1)/2+1)*2, 0);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int d = 0;
	for (int i = 0; i < n; i += 2)
		d += a[i+1] - a[i];
	cout << d << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt = dict()

nodes = [set() for _ in range(N+1)]

for _ in range(N-1):
    a, b = [int(x) for x in input().split()]
    cnt[a-1] = cnt.get(a-1,0) + 1
    cnt[b-1] = cnt.get(b-1,0) + 1
    nodes[a-1].add(b-1)
    nodes[b-1].add(a-1)


C = [int(x) for x in input().split()]
C = sorted(C, reverse=True)

Z = cnt.items()
Z = sorted(Z, key=lambda x:x[1], reverse=True)
# print(Z)

opennodes = {Z[0][0]}
closednodes = set()

ans = [-1] * N


for i in range(N):
    n = opennodes.pop()
    closednodes.add(n)
    ans[n] = C[i]

    for nn in nodes[n]:
        if not nn in closednodes:
            opennodes.add(nn)

print(sum(C) - max(C))
print(" ".join([str(x) for x in ans]))




Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll h,sum=1,sum1,p=1;
    cin>>h;
    while(h!=1)
    {
        h/=2;
        sum1=pow(2,p);
        sum+=sum1;
        p++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int mod=1e9+7;
const int N=410;
int n;
int a[N],b[N],f[N/3][N][N][2],s[N][N],pa[N],pb[N],mk[N];
int mul(int a,int b)
{
	return (1LL*a*b%mod+mod)%mod;
}
void inc(int&a,int b)
{
	a=(a+b)%mod;
}
int main()
{
	cin>>n;
	ref(i,1,n)cin>>a[i],pa[a[i]]=i;
	ref(i,1,n)cin>>b[i],pb[b[i]]=i;
	ref(i,0,n)
	{
		ref(j,1,n)mk[j]=0;
		int tot=0;
		ref(j,1,i){mk[a[j]]++;if(mk[a[j]]==1)tot++;}
		s[i][0]=tot;
		ref(j,1,n){
			mk[b[j]]++;
			if(mk[b[j]]==1)tot++;
			s[i][j]=tot;
		}
	}
	f[0][0][0][0]=1;
	ref(t,0,n/3)ref(i,0,n)ref(j,0,n)
	{
		if(f[t][i][j][0]&&i<n){
			int F=f[t][i][j][0];
			if(pb[a[i+1]]>j){
				int tt=t-(s[i][j]-t*2);
				if(tt>0)inc(f[t][i+1][j][0],mul(tt,F));
			}
			if(pb[a[i+1]]<=j)inc(f[t][i+1][j][0],F);
		}
		if(t<n/3||i==n) 
			inc(f[t][i][j][1],f[t][i][j][0]);
		if(f[t][i][j][1]&&j<n){
			int F=f[t][i][j][1];
			if(pa[b[j+1]]>i){
				int tt=t-(s[i][j]-t*2);
				if(tt>0)inc(f[t][i][j+1][1],mul(tt,F));
			}
			if(pa[b[j+1]]<=i)inc(f[t][i][j+1][1],F);
			if(t<n/3&&i<n&&pb[a[i+1]]>j+1&&pa[b[j+1]]>i+1)
				inc(f[t+1][i+1][j+1][0],F);
		}
	}
	int ans=f[n/3][n][n][0]+f[n/3][n][n][1];
	for(int i=0;i<n;i+=3)ans=mul(ans,mul(i+1,i+2));
	cout<<ans<<endl;
}

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

using namespace std;
using ll = long long int;

int main()
{
    int n, m;
    cin >> n >> m;

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

    if (sum <= n)
    {
        cout << (n - sum) << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3624
n, u, v = map(int, input().split())
matrix = [[] for _ in range(n)]
import sys
sys.setrecursionlimit(10**8)
for _ in range(n-1):
    a,b = map(int, input().split())
    matrix[a-1].append(b-1)
    matrix[b-1].append(a-1)

C = [0]*n
D = [0]*n

def dfs(x, pre, cnt, c):
    c[x] = cnt
    cnt += 1
    for a in matrix[x]:
        if a == pre:
            continue
        dfs(a, x, cnt, c)

dfs(v-1, -1, 0, C)
dfs(u-1, -1, 0, D)
ans=0

for i in range(n):
    if C[i] > D[i]:
        ans = max(ans, C[i]-1)
print(ans)

Measured memory_bytes: 98328
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
#include<functional>
using namespace std;

int main(void) {
    int N,A;
    
    cin >>N >>A;
    if(N<A)
        cout << "0"<<endl;
    else
        cout << "10"<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int table[55];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string a,b;cin>>a>>b;
    int n=a.size();
    int m=b.size();
    if(n<m) cout << "LESS";
    else if(n>m) cout << "GREATER";
    else {
        if(a<b) cout << "LESS";
        else if(a>b) cout << "GREATER";
        else cout << "EQUAL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n, s = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    s += r - l + 1;
  }
  cout << s << endl;
}



Measured memory_bytes: 256