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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin2(n, k);
    for1(i, n) cin1(a[i]);

    fora(i, k+1, n) {
        (a[i] > a[i-k]) ? cout << "Yes\n" : cout << "No\n";
    }

    return 0;
}



Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}



vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back(make_pair(a, ex));
    }
    if (N != 1) res.push_back(make_pair(N, 1));
    return res;
}

int main() {
    ll n,ans=0;
    cin >> n;
    for (ll i=1;i<=n;i++){
        for (ll j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll asum = 0;
    rep(i,n){
        scanf("%lld",&a[i]);
        asum += a[i];
    }
    ll b[n] = {};
    ll bsum = 0;
    rep(i,n){
        scanf("%lld",&b[i]);
        bsum = b[i];
    }

    ll c = bsum - asum;

    ll ca = 0;
    ll cb = 0;

    rep(i,n){
        if(a[i]<b[i]){
            if((a[i]-b[i])%2==1){
                ca++;
                cb++;
                a[i] += 2;
                b[i] += 1;
            }
            ca += (b[i]-a[i])/2;
        }
        if(a[i]>b[i]){
            cb += a[i] - b[i];
        }
    }
    //cout << ca << ' ' << cb;
    if(ca>=cb)yn;

    return 0;
}
 
 


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    map <int, int> d;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        d[x]++;
    }
    int m;
    cin >> m;
    vector <int> t(m);
    for(int i = 0; i < m; i++) {
        cin >> t[i];
    }

    if(n < m) {
        cout << "NO" << endl;
        return 0;
    }
    
    for(int i = 0; i < m; i++) {
        d[t[i]]--;
        // cout << "d[" << t[i] << "]: " << d[t[i]] << endl;
        if(d[t[i]] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 10368
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();
        int countW=0;
        int countE=0;
        int[] numW = new int[N];
        int[] numE = new int[N];
        int[] sum = new int[N];
        int min = N;
        
        for(int i=0; i<N; i++){
            if(str.charAt(i)=='W'){
                countW++;
                numW[i] = countW;
                numE[i] = countE;
            }else{
                countE++;
                numW[i] = countW;
                numE[i] = countE;
            }
            //System.out.println(i+">"+numW[i]+":"+numE[i]);
        }
        for(int i=0; i<N; i++){
            sum[i] = numW[i]+(numE[N-1]-numE[i]);
            if(min>sum[i]){
                if(i==0){
                    min=sum[i]-1;
                }else{
                min=sum[i];
                }
                //System.out.println(min);
            }
        }
        System.out.println(min);
    }
}

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

int main(void)
{
	int n, an[256];

	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> an[i];

	for(int i = 0; i < n; i++)
		cout << an[i] << (i == n - 1 ? "\n" : " ");

	for(int j = 1; j < n; j++){
		int key = an[j];
		int i = j - 1;
		for( ; i >= 0 && an[i] > key; i--) {
			an[i + 1] = an[i];
		}
		an[i + 1] = key;
		for(int i = 0; i < n; i++)
			cout << an[i] << (i == n - 1 ? "\n" : " ");
	}

	return 0;
}

Measured memory_bytes: 1160
//dwango5_a.cpp
//Sun Nov 25 18:26:52 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

	int ans = -1;
	double dif = 10000;
	for (int i=0;i<n;i++){
		double tempdif;
		if (a[i]>total){
			tempdif = a[i]-total;
		}else {
			tempdif = total-a[i];
		}
		if (tempdif<dif){
			dif = tempdif;
			ans = i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int C2(int x){
    return x*(x-1)/2;
}

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

    int lim = C2(n-1);
    if(lim<k){
        cout << -1 << "\n";
        return 0;
    }

    vector<pair<int,int>> e;
    if(k == 0) rep(i,n)rep(j,i) e.pb({j,i});
    else{
        int v = 3;
        while(C2(v-1)<k) ++v;

        rep(i,v-1) e.pb({i,v-1});
        for(int i=v; i<n; ++i)rep(j,i) e.pb({i,j});

        int num = C2(v-1);
        rep(i,num-k) e.pb({i,(i+1)%(v-1)});
    }

    int m = e.size();
    cout << m << "\n";
    rep(i,m) cout << e[i].fi+1 << " " << e[i].se+1 << "\n";
    return 0;
}


Measured memory_bytes: 384
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
const long double PI = acos((-1.0));
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
long double a,b,x;
cin >> a >> b >> x;
x /= a;
if(x > a * b / 2){
    cout << fixed << setprecision(10) << atan2((a* b - x) * 2, a * a) * 180 / PI << endl;
}else{
    cout << fixed << setprecision(10) << atan2(b * b, x * 2) * 180 / PI << endl;
}
}

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

using namespace std;

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

  int N; cin>>N;
  vector<double> A(N); for(auto& a : A) cin>>a;
  double all = 1;
  for (auto a : A) all *= a;
  double m = 0;
  for (auto a : A) m += all/a;
  cout << fixed << setprecision(6) << all/m << endl;

  return 0;
}


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

using namespace std;


///------------------- O(|E|*sqrt(|V|)) -------------------///
struct hopcroft_karp {
    int l, r;
    vector<int> last, prev, head, matching, d;
    vector<bool> used, vis;
    hopcroft_karp(int l, int r) : l(l), r(r), last(l, -1), matching (r, -1), d(l), used(l), vis(l) {}
    /// u -> 0 to l, v -> 0 to r
    void add_edge(int u, int v) {
        head.push_back(v);
        prev.push_back(last[u]);
        last[u] = prev.size()-1;
    }
    void bfs() {
        fill(d.begin(), d.end(), -1);
        queue<int> q;
        for(int u = 0; u < l; u++) {
            if(!used[u]) {
                q.push(u);
                d[u] = 0;
            }
        }
        while(q.size()) {
            int u = q.front(); q.pop();
            for(int e = last[u]; e >= 0; e = prev[e]) {
                int v = matching[ head[e] ];
                if(v >= 0 && d[v] < 0) {
                    d[v] = d[u]+1;
                    q.push(v);
                }
            }
        }
    }
    bool dfs(int u) {
        vis[u] = true;
        for(int e = last[u]; e >= 0; e = prev[e]) {
            int v = head[e];
            int k = matching[v];
            if(k < 0 || ( !vis[k] && d[k] == d[u]+1 && dfs(k) )) {
                matching[v] = u;
                used[u] = true;
                return true;
            }
        }
        return false;
    }
    int max_matching() {
        int ans = 0;
        while(true) {
            bfs();
            fill(vis.begin(), vis.end(), false);
            int f = 0;
            for(int u = 0; u < l; u++)
                if(!used[u] && dfs(u)) f++;
            if(f == 0) return ans;
            ans += f;
        }
        return 0;
    }
};



int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n1, n2, m;
  cin>>n1>>n2>>m;
  hopcroft_karp hp(n1, n2);
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      hp.add_edge(u, v);
  }
  cout<<hp.max_matching()<<"\n";
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	ll ans = 0;
	int na = 0;
	rep(i, n) {
		if (s[i] == 'A') na++;
		else if (s.substr(i, 2) == "BC") {
			ans += na;
			i++;
		}
		else na = 0;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> s(N);
  
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  
  sort(s.begin(), s.end());
  
  string T;
  
  for (int j = 0; j < N; j++) {
    T += s[j];
  }
  
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
abc = sorted([a,b,c])

d1 = abc[1]-abc[0]
d2 = abc[2]-abc[1]

ans=d2
if d1%2==0:
    ans+=d1//2
else:
    ans+=(d1+1)//2+1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;

int arr[N];
inline ll sqr(ll n) {return n * n;}

int main()
{
    int n, pos;
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> arr[i];
    ll minv = 1 << 30;
    for(int i = 1; i <= 100; ++i) {
       ll ans = 0; 
        for(int j = 1; j <= n; ++j) {
            ans += sqr(abs(i - arr[j]));
        }
        minv = min(minv, ans);
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>  
using namespace std;
const int INF = 1 << 30;
class DisjointSet{
private:
  vector<int> rank, p;
  void link(int x,int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
public:
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
  }
  void build(){
    for(int i = 0; i < rank.size(); i++){
      makeSet(i);
    }
  }
  void makeSet(int x){
    p[x] = x, rank[x] = 0;
  }
  void Union(int x,int y){
    if(findSet(x) != findSet(y))
      link(findSet(x),findSet(y));
  }
  int findSet(int x){
    return( x != p[x] ? p[x] = findSet(p[x]) : p[x]);
  }
};

struct edge{
  int u, v, cost;
  bool operator<(const edge& hoge)const{
    return cost < hoge.cost;
  }
};
typedef vector< edge > Edges;
void add_edge(Edges& info, int u, int v, int cost){
  info.push_back( (edge){ u, v, cost});
}
bool used[50000];

int kruskal(Edges& edges, int V, int donot){
  DisjointSet uf_tree(V); uf_tree.build();
  int ret = 0;
  for(int i = 0; i < edges.size(); i++){
    edge& e = edges[i];
    if(i != donot && uf_tree.findSet(e.u) != uf_tree.findSet(e.v)){
      uf_tree.Union( e.u, e.v);
      ret += e.cost;
      if(donot == -1) used[i] = true;
    }
  }
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  Edges edges;
  for(int i = 0; i < M; ++i){
    int u, v, c;
    cin >> u >> v >> c;
    --u, --v;
    add_edge( edges, u, v, c);
  }
  sort( edges.begin(), edges.end());
  int get = kruskal( edges, N, -1);
  int a = 0, b = 0;
  for(int i = 0; i < edges.size(); ++i){
    if(used[i] && kruskal( edges, N, i) != get){
      ++a, b += edges[i].cost;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 2004
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>
#include <iomanip>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
set<char> alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };

int main() {
    int N, M;
    cin >> N >> M;
    vector<set<int>> sr(M);
    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            a--;
            sr[i].insert(a);
        }
    }
    ll ans = 0;
    vi p(M);
    rep(i, M)cin >> p[i];
    for (int bit = 0; bit < (1 << N); ++bit) {
        vi counter(M,0);
        rep(i, N) {
            if (bit & (1 << i)) {
                rep(j, M) {
                    if (sr[j].count(i))counter[j]++;
                }
            }
        }
        int sum = 0;
        rep(i, M) {
            if (counter[i] % 2 == p[i])sum++;
        }
        ans += sum / M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = nextInt()
    val L = listOfInt().sorted()
    val D = L.map { it.toDouble()}
    var ans = 0L
    for (a in 0 until N-2) {
        for (b in a+1 until N-1) {
            val ab = (L[a] + L[b]).toDouble()
            val l = b + 1
            var r = D.binarySearch(element = ab - 0.1, fromIndex = l, toIndex = N - 1)
            if (r < 0) r = r.inv()
            if (ab > L[r]) r++
            val c = Math.max(0, r - l)
            ans += c
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

Measured memory_bytes: 40752
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

long long K, N, A[1 << 19];

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

	long long maxn = 0;
	for (int i = 0; i < 2 * N - 1; i++) maxn = max(maxn, A[i + 1] - A[i]);
	cout << K - maxn << endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a[11],ans;
  while(cin>>a[1]){
    ans=a[1];
    for(int i=2;i<11;i++){
      if(i%2)a[i]=a[i-1]/3.0;
      else a[i]=a[i-1]*2.0;
      ans+=a[i];
    }
    printf("%.8f\n",ans);
  }
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

double eps = 1e-16;
struct V {
    double x, y;
    V(double x=0, double y=0): x(x), y(y) {}
    V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}
    V operator+(const V& v) const { return V(*this) += v;}
    V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}
    V operator-(const V& v) const { return V(*this) -= v;}
    V& operator*=(double s) { x *= s; y *= s; return *this;}
    V operator*(double s) const { return V(*this) *= s;}
    V& operator/=(double s) { x /= s; y /= s; return *this;}
    V operator/(double s) const { return V(*this) /= s;}
    double dot(const V& v) const { return x*v.x + y*v.y;}
    double cross(const V& v) const { return x*v.y - v.x*y;}
    double norm2() const { return x*x + y*y;}
    double norm() const { return sqrt(norm2());}
    V rotate90() const { return V(y, -x);}
    int ort() const { // orthant
        if (abs(x) < eps && abs(y) < eps) return 0;
        if (y > 0) return x>0 ? 1 : 2;
        else return x>0 ? 4 : 3;
    }
    bool operator<(const V& v) const {
        int o = ort(), vo = v.ort();
        if (o != vo) return o < vo;
        return cross(v) > 0;
    }
};
istream& operator>>(istream& is, V& v) {
    is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
    os<<"("<<v.x<<","<<v.y<<")"; return os;
}

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

    int N;
    cin>>N;
    vector<V> vs(N);
    rep(i, N) cin>>vs[i];
    sort(vs.begin(), vs.end());

    double ans = 0;
    rep(i, N) {
        V v;
        double m = 0;
        rep(j, N) {
            if ((v + vs[(i + j) % N]).norm() > m) {
                v += vs[(i + j) % N];
                m = v.norm();
            }
        }
        if (ans < m) ans = m;
    }
    printf("%.15f\n", ans);
}

Measured memory_bytes: 256
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define scan(n) scanf("%lld",&n)
#define scan2(a,b) scanf("%lld %lld",&a,&b)
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define print(n) printf("%lld\n",n)
#define scanS(s) scanf("%s",&s)
#define printS(s) printf("%s",s)

#define ff first
#define ss second
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define pb push_back
#define popb pop_back
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli a, b, k, turn = 0;
    cin >> a >> b >> k;
    while (k--) {
        if (turn == 0) {
            turn = 1;
            if (a & 1) a--;
            lli temp = a / 2;
            b += temp;
            a -= temp;
        } else {
            turn = 0;
            if (b & 1) b--;
            lli temp = b / 2;
            a += temp;
            b -= temp;
        }
    }
    cout << a << " " <<  b << endl;
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n, k;
	cin >> n >> k;
	int h;
	int res = 0;
	for(int i = 0; i < n; ++i){
		cin >> h;
		if(h >= k) res++;
	}

	cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int vis[26]={0},a[26];
char s[30];
int main(){
	scanf("%s",s);
	int i,j,k,l,len=strlen(s);
	for(i=0;i<len;i++){
		a[i]=s[i]-'a';
		vis[a[i]]=1;
	}
	if(len<26){
		for(i=0;i<26;i++){
			if(vis[i]==0)s[len]='a'+i;
			else continue;
			for(i=0;i<=len;i++)cout<<s[i];
			cout<<endl;
			return 0;
		}
	}
	vis[a[25]]=0;
	for(i=24;i>=0;i--){
		for(j=a[i]+1;j<26;j++){
			if(vis[j]==0){
				a[i]=j;len=i+1;
				for(k=i+1;k<len;k++){
					for(l=25;l>=0;l--){
						if(vis[l]==0){
							vis[l]=1;
							a[k]=l;
							break;
						}
					}
				}
				for(i=0;i<len;i++){
					printf("%c",a[i]+'a');
				}
				printf("\n");
				return 0;
			}
		}
		vis[a[i]]=0;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())

    if H == 0 and W == 0:
        break

    for x in range(H):
        for y in range(W):
            if (x + y) % 2 == 0: print('#', end='')
            else: print('.', end='')
        print()
    
    print()


Measured memory_bytes: 7000
a, op, b = input().split()

while (str(op) != "?"):
     a = int(a)
     b = int(b)

     if (str(op) == "+"):
          print(a + b)
     elif (str(op) == "-"):
          print(a - b)
     elif (str(op) == "*"):
          print(a * b)
     elif (str(op) == "/"):
          print(a // b)
     a, op, b = input().split()


Measured memory_bytes: 5588
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;

	if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



int main(){
  init();
  int n,x;
  int a[110000];
  cin>>n>>x;
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  
  rep(i,n-1){
    int s=a[i]+a[i+1]-x;
    if(s>0){
      ans+=s;
      a[i+1]=max(0,x-a[i]);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 640
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def cell(i, j, A, B):
    if (i < A and j < B) or (i >= A and j >= B):
        return '1'
    return '0'


def solve():
    H, W, A, B = read_ints()
    print('\n'.join([
        ''.join([cell(i, j, A, B) for i in range(W)]) for j in range(H)
    ]))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 76248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline char GET(void)
{
  static char buf[1<<15],*ptr=buf,*end=buf;
  if(ptr==end){ptr=buf,end=buf+fread(buf,1,1<<15,stdin);}return *ptr++;
}
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline void Add(int *fwt,int idx,int v){while(idx<=*fwt){fwt[idx]+=v;idx+=(idx&-idx);}}
static inline int Sum(int *fwt,int x){int v=0;while(x){v+=fwt[x];x-=(x&-x);}return v;}
int main()
{
  int N=IN(),Q=IN(),after[500001],dat[500001],fenwick[500001]={0},id[500001],left[500001],pos[500001]={0},result[500001];
  rep(i,N){dat[i+1]=IN();}
  rep(i,Q){left[i+1]=IN();int r=IN();after[i+1]=id[r];id[r]=i+1;}
  fenwick[0]=N;
  for(int r=1;r<=N;++r)
  {
    if(pos[dat[r]]){Add(fenwick,pos[dat[r]],-1);}
    Add(fenwick,r,1);
    for(int i=id[r];i;i=after[i]){result[i]=Sum(fenwick,r)-Sum(fenwick,left[i]-1);}
    pos[dat[r]]=r;
  }
  rep(i,Q){OUT(result[i+1]);}
}

Measured memory_bytes: 17208
def solve(inp):
    N = int(inp.readline().strip())
    A = list(map(int, inp.readline().strip().split(' ')))
    B = list(map(int, inp.readline().strip().split(' ')))
    C = list(map(int, inp.readline().strip().split(' ')))

    r = sum(B)
    for i in range(N - 1):
        if A[i] + 1 == A[i + 1]:
            r += C[A[i] - 1]
    return str(r)


def test(s):
    from io import StringIO
    print(solve(StringIO(s)))


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    # test('')
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

pair<int, int> blocks[4][4];
string S[4];
pair<int, int> empty[12];

void clear() {
    REP(i, 12) {
        int r = empty[i].first;
        int c = empty[i].second;
        S[r][c] = '.';
    }
}

bool can_set(int r, int c, int idx) {
    REP(i, 4) {
        int nr = r + blocks[idx][i].first;
        int nc = c + blocks[idx][i].second;
        if (nr < 0 || nr >= 4 || nc < 0 || nc >= 10) {
            return false;
        }
        if (S[nr][nc] != '.') {
            return false;
        }
    }
    return true;
}

pair<int, int> can_set_first(int idx) {
    REP(i, 12) {
        int r = empty[i].first;
        int c = empty[i].second;
        if (S[r][c] == '.') {
            if (can_set(r, c, idx)) {
                return {r, c};
            } else {
                return {-1, -1};
            }
        }
    }
    return {-1, -1};
}

void set_(int r, int c, int idx) {
    REP(i, 4) {
        int nr = r + blocks[idx][i].first;
        int nc = c + blocks[idx][i].second;
        S[nr][nc] = '#';
    }
}

void solve() {
    int H[4];
    int W[4];
    string tmp[4];

    REP(i, 4) {
        cin >> H[i] >> W[i];
        REP(j, H[i]) cin >> tmp[j];
        int cnt = 0;
        REP(j, H[i]) REP(k, W[i]) if (tmp[j][k] == '#') blocks[i][cnt++] = {j, k};
        REP(j, 4) {
            blocks[i][3-j].first -= blocks[i][0].first;
            blocks[i][3-j].second -= blocks[i][0].second;
        }
    }


    int Q;
    cin >> Q;

    while (Q--) {
        int cnt = 0;
        REP(i, 4) cin >> S[i];
        REP(i, 4) REP(j, 10) if (S[i][j] == '.') empty[cnt++] = {i, j};
        vector<int> ord = {0, 1, 2, 3};
        bool result;
        do {
            result = true;
            clear();
            REP(i, 3) {
                int idx = ord[i];
                auto p = can_set_first(idx);
                if (p.first == -1) {
                    result = false;
                    break;
                }
                set_(p.first, p.second, idx);
            }
            if (result) break;
        } while (next_permutation(ord.begin(), ord.end()));

        cout << (result ? "Yes" : "No") << "\n";
    }
}

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



Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	int N, D, x, y, ans = 0;
	cin >> N >> D;
	vector<pair<int, int>> XY;
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		XY.push_back(make_pair(x, y));
	}
	for (int i = 0; i < N; i++) {
		if (pow(XY[i].first, 2) + pow(XY[i].second, 2) <= pow(D, 2)) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 5360
#include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];void k();using namespace std;main(){int n;p[0]=2;m[1]=0;m[2]=1;k();while(cin>>n){cout<<m[n]<<endl;}}void k(){int i,j,e=1;for(i=3;i<N+1;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

Measured memory_bytes: 5376
from collections import defaultdict
N ,M = list(map(int,input().split(" ")))
di = defaultdict(lambda :[])
for _ in range(M):
    a,b = list(map(int,input().split(" ")))
    di[a].append(b)
    di[b].append(a)
ans = "IMPOSSIBLE"
for v in di.values():
    if 1 in v and N in v:
        ans = "POSSIBLE"
        break
print(ans)


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

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = a*b/__gcd(a,b);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
using namespace std;
typedef long long ll;
const int N = 210;
ll read() {
	ll x = 0,f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1; c = getchar();
	}
	while(c >= '0' && c <= '9') {
		x = x * 10 + c - '0'; c = getchar();
	}
	return x * f;
}
int d[N][N],f[N][N],A,B,X[N],Y[N];
int main() {
	A = read(),B = read();
	
	for(int i = 1;i <= A;++i)
		for(int j = 1;j <= B;++j)
			d[i][j] = read();
	
	
	for(int i = 0;i <= 100;++i)
		for(int j = 0;j <= 100;++j)
			for(int x = 1;x <= A;++x)
				for(int y = 1;y <= B;++y)
					f[i][j] = max(f[i][j],d[x][y] - i * x - j * y);
	
	for(int x = 1;x <= A;++x) {
		for(int y = 1;y <= B;++y) {
			int tmp = 1e9;
			for(int i = 0;i <= 100;++i) {
				for(int j = 0;j <= 100;++j) {
					tmp = min(tmp,f[i][j] + i * x + j * y);					
				}
			}
			if(tmp != d[x][y]) return puts("Impossible"),0;
		}
	}
	
	
	
	puts("Possible");
	
	puts("202 10401");
	
	for(int i = 1;i <= 100;++i) printf("%d %d X\n",i,i + 1);
	for(int i = 102;i < 202;++i) printf("%d %d Y\n",i,i + 1);
	
	for(int i = 0;i <= 100;++i)
		for(int j = 0;j <= 100;++j)
			printf("%d %d %d\n",1 + i,202 - j,f[i][j]);
	puts("1 202");
	
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
ll INF = 1LL << 60;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> P(N), C(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P[i]--;
	}
	for (int i = 0; i < N; i++) cin >> C[i];
	
	ll ans = -INF;

	for (int i = 0; i < N; i++) {
		int v = i;
		ll cycle_sum = 0;
		int cycle_cnt = 0;

		while (true) {
			cycle_cnt++;
			cycle_sum += C[v];
			v = P[v];
			if (v == i) break;
		}

		ll remainder = 0;
		int cnt = 0;

		while (true) {
			cnt++;
			remainder += C[v];

			if (cnt > K) break;
			
			int roop = (K - cnt) / cycle_cnt;
			ll score = remainder + max(0LL, cycle_sum) * roop;
			ans = max(ans, score);

			v = P[v];
			if (v == i) break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <map>
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
typedef long long ll;

int n;
char s[40];
std::map<std::pair<std::string,std::string>,int> C;

int main()
{
    scanf("%d%s",&n,s);
    std::reverse(s+n,s+(n<<1));
    for(int i=0;i<(1<<n);++i)
    {
        std::string a,b;
        for(int j=0;j<n;++j)
            if(i>>j&1)a+=s[j];
            else b+=s[j];
        ++C[std::make_pair(a,b)];
    }
    ll Ans=0;
    for(int i=0;i<(1<<n);++i)
    {
        std::string a,b;
        for(int j=0;j<n;++j)
            if(i>>j&1)a+=s[n+j];
            else b+=s[n+j];
        Ans+=C[std::make_pair(a,b)];
    }
    printf("%lld\n",Ans);
    return 0;
}

Measured memory_bytes: 91904
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

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

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N);
    i64 ans = 0;
    rep(i, 1, N + 1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(a: int, b: int, c: int):
    abc = sorted([a, b, c])
    if abc[0]+abc[1] == abc[2] or abc[0] == abc[1]+abc[2]:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
/* ***********************************************
Author        :yang12138
Created Time  :2018/9/25 10:56:24
File Name     :110_d.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=1e5+100;
const int mod=1e9+7;

ll fac[N],inv[N];

void init(){
	fac[0]=inv[0]=1;
	fac[1]=inv[1]=1;
	for(int i=2;i<N;i++){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	}
	for(int i=2;i<N;i++) (inv[i]*=inv[i-1])%=mod;
}

ll C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

typedef pair<int,int>pii;

vector<pii> resolve(int n){
	vector<pii>ans;
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			int cnt=0;
			while(n%i==0) n/=i,cnt++;
			ans.push_back(pii(i,cnt));
		}
	}
	if(n!=1) ans.push_back(pii(n,1));
	return ans;
}

void solve(){
	int n,m;
	scanf("%d%d",&n,&m);
	vector<pii>vec = resolve(m);
	ll ans=1;
	for(int i=0;i<(int)vec.size();i++){
		ans=ans*C(n+vec[i].second-1,n-1)%mod;
	}
	cout<<ans<<endl;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	init();
	solve();
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long N,M,L;
char S[100005],T[100005];
long long getmin(long long a,long long b){
	long long m=a,n=b,r;
	if(m<n){
		long long temp=m;
		m=n;
		n=temp;
	}
	r=m%n;
	while(r){
		m=n;
		n=r;
		r=m%n; 
	}
	return a*b/n;
}
int main()
{
	cin>>N>>M;
	scanf("%s%s",S,T);
	if(N!=strlen(S)||M!=strlen(T)){
		printf("%d",-1);
		return 0;
	}
	long long num=N*M;
	long long x1=num/N;
	long long x2=num/M;
	long long i1=strlen(S);
	long long j1=strlen(T);
	long long j=0,i=0;
	for(j=0;j<j1;j++){
		while(j*x2>=i*x1&&i<i1){
			if(i*x1==j*x2){
				if(S[i]==T[j]){
					break;
				}
				else{
					printf("%d",-1);
					return 0;
				}
			}
			i++;
		}
	}
	num=getmin(N,M);
	printf("%lld",num);
	return 0;
}

Measured memory_bytes: 384
from sys import stdin

def main():
    a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
    k = int(input())

    n = 0
    bb = b
    while bb <= a:
        bb = bb * 2
        n += 1
    
    if n > k:
        print("No")
        return

    m = k - n

    cc = c
    for i in range(m):
        cc = cc * 2

    if cc > bb:
        print("Yes")
    else:
        print("No")
    
    

if __name__ == "__main__":
    main()

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  for (int i = n - m; i > - 1; i--) {
    bool flag = true;
    for (int j = 0; j < m; j++) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        flag = false;
        break;
      }
    }
    if (flag) {
      for (int j = 0; j < m; j++) {
        s[i+j] = t[j];
      }
      for (int j = 0; j < n; j++) {
        if (s[j] == '?') s[j] = 'a';
      }
      cout << s << '\n';
      return 0;
    }
  }
  cout << "UNRESTORABLE" << '\n';
  return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(Q)]
s = [0] * N
for i in range(N-1):
    if S[i:i + 2] == 'AC':
        s[i+1] = s[i] + 1
    else:
        s[i+1] = s[i]
for l, r in lr:
    print(s[r-1] - s[l-1])

Measured memory_bytes: 30664
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(t.begin(), t.end());

    int ans = 0;
    int i = 0;
    while(i < n){
        int cc = c;
        int limit = t[i] + k;
        while(i < n && t[i] <= limit && cc > 0){
            cc--;
            i++;
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
def main():
    n, m = map(int,input().split()) 
    startlis = []
    endlis = []

    for i in range(m):
        a, b = map(int, input().split())
        startlis.append(a)
        endlis.append(b)
    
    start = max(startlis)
    end = min(endlis)

    print(max(0,end - start + 1))





    
if __name__ == "__main__":
    main()


Measured memory_bytes: 57272
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let a = S.iter().filter(|&&s| s == 'a').count();
    let b = S.iter().filter(|&&s| s == 'b').count();
    let c = S.iter().filter(|&&s| s == 'c').count();
    let ans = if *vec![a, b, c].iter().max().unwrap() - *vec![a, b, c].iter().min().unwrap() <= 1 { "YES" } else { "NO" };

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

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

int main()
{
  int x, y;
  while(1)
  {
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x < y)
    {
      cout << x << " " << y << endl;

    }
    else
    {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <sstream>
#define MAX 100000
using namespace std;

struct Queue{
    int head;
    int tail;
    int q[MAX];

    void initialize(){
        head = 0;
        tail = 0;
    }
    bool isEmpty(){
        return (head == tail);
    }
    bool isFull(){
        return (head == (tail+1)%MAX);
    }
    void enqueue(int x){
        if(isFull()){
            cout << "queue overflow\n";
            //exit(0);
        }
        q[tail] = x;
        if(tail == MAX-1){
            tail = 0;
        }
        else{
            tail += 1;
        }
    }
    int dequeue(){
        if(isEmpty()){
            cout << "queue underflow\n";
            //exit(0);
        }
        int x = q[head];
        if(head == MAX-1){
            head = 0;
        }
        else{
            head += 1;
        }
        return x;
    }
};

void calc(Queue q_name, string name[], Queue q_time, int quantum){
    int t_sum = 0;
    while(q_name.head != q_name.tail){
        if(q_time.q[q_time.head] <= quantum){
            t_sum += q_time.dequeue();
            cout << name[q_name.dequeue()] << " " << t_sum << '\n';
        }
        else{
            t_sum += quantum;
            q_name.enqueue(q_name.q[q_name.head]);
            q_time.enqueue(q_time.q[q_time.head]-quantum);

            if(q_name.head == MAX-1){
                q_name.head = 0;
                q_time.head = 0;
            }
            else{
                q_name.head += 1;
                q_time.head += 1;
            }
        }
    }
}

int main(){
    Queue q_name, q_time;
    int num, quantum;
    string name[MAX];
    int t;

    q_name.initialize();
    q_time.initialize();

    cin >> num >> quantum;
    for(int i=0; i<num; i++){
        cin >> name[i] >> t;
        q_name.enqueue(i);
        q_time.enqueue(t);
    }

    calc(q_name, name, q_time, quantum);

    return 0;
}


Measured memory_bytes: 7404
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;



int main() {
	int n,m;
	cin >> n>>m;
	vector<int> x(m);

	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}

	sort(x.begin(), x.end());
	priority_queue<int> d;
	for (int i = 0; i < m - 1; i++) {
		d.push(x[i + 1] - x[i]);
	}

	for (int i = 0; i < n-1;i++) {
		if (d.empty()) {
			break;
		}

		d.pop();
	}

	int cnt = 0;
	while (!d.empty()) {
		cnt += d.top();
		d.pop();
	}

	cout << cnt << endl;
	
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  map<string, int> m;
  int n;
  cin>>n;
  frn(i,n) {
    string s;
    cin>>s;
    m[s]++;
  }
  
  cin>>n;
  frn(i,n) {
    string s;
    cin>>s;
    m[s]--;
  }
  int ans = 0;
  for(auto x: m) {
    ans = max(ans, x.second);
  }
  cout<<ans;
}

Measured memory_bytes: 256