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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  map<ll, int> freqs;
  for (int i = 0; i < N; ++i) {
    ll val;
    scanf("%lld", &val);
    ++freqs[val];
  }
  vector<pair<ll, int> > sticks;
  for (map<ll, int>::iterator iter = freqs.begin(); iter != freqs.end(); ++iter) {
    if (iter->second >= 2) {
      sticks.push_back(make_pair(iter->first, iter->second));
    }
  }
  sort(sticks.begin(), sticks.end(), greater<pair<ll, int> >());
  vector<ll> sides;
  for (int i = 0; i < (int)sticks.size() and sides.size() < 2; ++i) {
    pair<ll, int> p = sticks[i];
    ll len = p.first;
    int freq = p.second;
    if (freq >= 4) {
      sides.push_back(len);
      sides.push_back(len);
      break;
    }
    else {
      sides.push_back(len);
    }
  }
  ll ans = 0;
  if (sides.size() >= 2) {
    ans = sides[0] * sides[1];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main() {
  ll n,k;
  cin >> n >> k;
  k = min(k,n-1);

  combination comb(n);

  mint ans = 0;
  rep(i,k+1){
    ans += comb(n,i)*comb(i+n-i-1,i);
  }

  cout << ans.x << endl;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	static int N;
	static int M;
	static int Left_max=-1;
	static int Right_min=100001;

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		for(int i=1;i<=M;i++){
			Left_max=Math.max(Left_max,sc.nextInt());
			Right_min=Math.min(Right_min,sc.nextInt());
		}


		if (Left_max<=Right_min) {
			System.out.println(Right_min-Left_max+1);
		}
		else{

			System.out.println(0);

		}

		//System.out.print(ans);
    }
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    Vs s(h);
    REP(i,0,h) cin>>s[i];
    map<char,int> ma;
    REP(i,0,h){
        REP(j,0,w){
            ma[s[i][j]]++;
        }
    }
    int c=(h%2)+(w%2);
    bool flag=true;
    if(h%2==1 && w%2==1){
        int count1=0,count2=0;
        for(auto x : ma){
            if(x.second%2==1) count1++;
            if(x.second%4==2) count2++;
        }
        if(count1>1 || count2>h/2+w/2) flag=false;
    }else if(h%2==1){
        int count=0;
        for(auto x : ma){
            if(x.second%2==1) flag=false;
            if(x.second%4==2) count++;
        }
        if(count>w/2) flag=false;
    }else if(w%2==1){
        int count=0;
        for(auto x : ma){
            if(x.second%2==1) flag=false;
            if(x.second%4==2) count++;
        }
        if(count>h/2) flag=false;
    }else{
        for(auto x : ma){
            if(x.second%4>0) flag=false; 
        }
    }

    YesNo(flag);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	int al = 0;
	for (int i = 1; i < n; i++) {
		al += (a[i] - a[i - 1] + m) % m;
	}
	vector<int> st(m * 2 + 5,0);
	vector<int> ed(m * 2 + 5, 0);
	vector<int> edsub(m * 2 + 5, 0);
	vector<int> b(m * 2 + 5, 0);
	int s, e;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] < a[i + 1]) {
			s = a[i];
			e = a[i + 1];
		}
		else {
			s = a[i];
			e = a[i + 1] + m;
		}
		st[s + 2]++;
		ed[e + 1]++;
		edsub[e + 1] += e - s - 1;
	}
	int sum = 0;
	b[0] = 0;
	for (int i = 1; i < 2 * m + 3; i++) {
		sum += st[i];
		sum -= ed[i];
		b[i] += b[i - 1] + sum;
		b[i] -= edsub[i];
	}
	int res = -1;
	int k;
	for (int i = 0; i < m; i++) {
		k = al - b[i] - b[i + m];
		if (res == -1 || res > k) {
			res = k;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 7296
import copy

N = int(input())
X = []
for i in range(N):
  A = int(input())
  X.append([])
  for _ in range(A):
    X[i].append(list(map(int, input().split())))

def rec(condition, i):
  if i==N:
    return condition.count(1)
  _X = X[i]
  _condition = copy.copy(condition)
  through_condition = copy.copy(condition)
  through_condition[i] = 0
  if condition[i]==0:
    return rec(copy.copy(through_condition), i+1)
  for x in _X:
    if _condition[ x[0]-1 ] == -1:
      _condition[ x[0]-1 ] = x[1]
    elif _condition[ x[0]-1 ] != x[1]:
      return 0 if _condition[i]==1 else rec(copy.copy(through_condition), i+1)
  _condition[i] = 1
  return max(rec(copy.copy(through_condition), i+1), rec(copy.copy(_condition), i+1))

print( rec([-1 for _ in range(N)], 0) )


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

int n, m;
int data[35];
int main()
{
	std::cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int k;
		std::cin >> k;
		for (int j = 0; j < k; ++j) {
			int a;
			std::cin >> a;
			++data[a];
		}
	}

	int ans = 0;
	for (int i = 1; i <= m; ++i)
		if (data[i] == n)
			++ans;

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


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

long_degree = M * 6
short_degree = H * 30 + (M * 0.5)

degree = abs(long_degree - short_degree)

if degree > 180:
    degree = 360 - degree

cos = math.cos(math.radians(degree))

ans = math.sqrt(A * A + B * B - 2 * A * B * cos)

print(str(ans))

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

int dp[5005][5005];

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

  for (int i=N-1; i>=0; i--){
    for (int j=N-1; j>=0; j--){
      if (S[i] != S[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int ans = 0;
  for (int i=0; i<N; i++){
    for (int j=0; j<N; j++){
      if (i >= j) continue;
      int now = min(dp[i][j], j-i);
      ans = max(ans, now);
    }
  }
  cout << ans << endl; 

  return 0;
}


Measured memory_bytes: 98048
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    map<int,int> mp;
    map<int,int>::iterator it;
    int N,a,ans = 0;
    scanf("%d",&N);
    while(N--){
        scanf("%d",&a);
        mp[a] ++;
    }
    for(it=mp.begin();it!=mp.end();it++){
        if(it->second%2) ans ++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
struct A{int a,b,m;};
bool comp(A a,A b){
      return a.a<b.a;
}
int main(){
      int n,m,a,b;
      while(cin>>n&&n){
            bool ans=true;
            vector<A>V;
            REP(i,n){
                  cin>>m>>a>>b;
                  V.PB((A){a,b,m});
            }
            sort(ALL(V),comp);
            int sum=0;
            bool f[100];
            memset(f,true,sizeof(f));
            REP(i,V.size()){
                  int now=V[i].a;
                  REP(j,i)if(f[j]&&V[j].b<=now){sum-=V[j].m;f[j]=false;}
                  sum+=V[i].m;
                  if(sum>150){
                        ans=false;
                  }
            }
            if(ans)cout<<"OK"<<endl;
            else cout<<"NG"<<endl;
      }
}

Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

vector<vector<int>> G;
vector<int> used;

void bfs(int cur) {
    queue<int> q;
    q.push(cur);
    while(!q.empty()) {
        int t = q.front();
        q.pop();
        for(int v: G[t]){
            if(used[v] == 0) {
                used[v] = used[t] + 1;
                q.push(v);
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    vector<string> A(N);
    rep(i, N) cin >> A[i];
    G.resize(N);
    rep(i, N) rep(j, i + 1, N) {
        if(A[i][j] == '1') {
            G[i].pb(j);
            G[j].pb(i);
        }
    }
    used.assign(N, 0);
    used[0] = 1;
    
    bfs(0);
    rep(i, N) rep(j, i + 1, N) {
        if(A[i][j] == '1' && abs(used[i] - used[j]) != 1) {
            output(-1);
            return 0;
        }
    }
    
    
    int ans = 0;
    rep(i, N) {
        used.assign(N, 0);
        used[i] = 1;
        bfs(i);
        rep(j, N){
            ans = max(ans, used[j]);
        }
    }
    
    output(ans);
    
    return 0;
}


Measured memory_bytes: 512
def resolve():
    k,n=map(int, input().split())
    l=list(map(int, input().split()))
    a=0
    for i in range(n):
        if i!=0:
            a=max(l[i]-l[i-1],a)
        else:
            a=max(l[0]+k-l[-1],a)
    print(k-a)
resolve()

Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

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

	vector<int>a(N);

	REP(i, N) cin >> a[i];

	int ans = (int)ceil((double)(N - K) / (K - 1)) + 1;

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[3030][2],fact[201010],invfact[201010];

ll comb(int n,int k){
    ll ret=invfact[k]*invfact[n-k]%mod;
    return ret*fact[n]%mod;
}
ll powmod(ll n,ll k=mod-2){
    ll ret=1;
    while(k>0){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

int main(){
    fact[0]=invfact[0]=1;
    rep(i,200001){
        fact[i+1]=fact[i]*(i+1)%mod;
        invfact[i+1]=powmod(fact[i+1]);
    }
    int h,w,n;
    cin>>h>>w>>n;
    pint p[n+2];
    rep(i,n){
        cin>>p[i].first>>p[i].second;
        --p[i].first;
        --p[i].second;
    }
    p[n]={--h,--w};
    p[n+1]={0,0};
    sort(p,p+n+2);
    dp[0][0]=1;
    rep(i,n+2){
        rep(j,i){
            if(p[j].second>p[i].second)continue;
            dp[i][0]+=dp[j][1]*comb(p[i].first+p[i].second-p[j].first-p[j].second,p[i].first-p[j].first)%mod;
            dp[i][1]+=dp[j][0]*comb(p[i].first+p[i].second-p[j].first-p[j].second,p[i].first-p[j].first)%mod;
        }
        dp[i][0]%=mod;
        dp[i][1]%=mod;
    }
    cout<<(dp[n+1][1]-dp[n+1][0]+mod)%mod<<endl;
    return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vec v(n);
    vec c(n);
    init(v);
    init(c);
    rep (i, n)
        v[i] = v[i] - c[i];
    int sum = 0;
    repall (i, v)
        if (i > 0) sum += i;
    print(sum);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC140();
}

void ABC140(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	bool ok{false};
	REP(i, N)
	{
		ll a; cin >> a;
		if (a & 1) ok = true;
	}
	std::cout << (ok ? "first" : "second")<< std::endl;
}

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

int main() {
    long long n, mx(0), W;
    cin >> n >> W;
    long long dp[n + 1][W + 1];
    long long w[n], v[n];
    for (long long i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    for (long long i = 0; i <= n; i++) {
        for (long long j = 0; j <= W; j++) {
            if (i == 0 or j == 0) {
                dp[i][j] = 0;
            }
            else if (w[i - 1] <= j) {
                dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][W] << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int T, p, r;
    
    while (scanf("%d %d %d", &T, &p, &r) && T){
        bool done[128][128] = {0};
        int wa[128][128] = {0};
        pair<int, pair<int, int> > t[128];
        
        for (int i = 1; i <= T; i++){
            t[i].first = t[i].second.first = 0;
            t[i].second.second = i;
        }
        for (int i = 0; i < r; i++){
            int a, b, c;
            char d[128];
            scanf("%d %d %d %s", &a, &b, &c, d);
            
            if (d[0] == 'W'){
                wa[a][b]++;
            }
            else {
                if (done[a][b]) continue;
                done[a][b] = true;
                t[a].first--;
                t[a].second.first += wa[a][b] * 1200 + c;
            }
        }
        
        sort(t + 1, t + 1 + T);
        
        for (int i = 1; i <= T; i++){
            printf("%d %d %d\n", t[i].second.second, -t[i].first, t[i].second.first);
        }
    }
    
    return (0);
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  rep(i,3) {
    string s;cin>>s;
    cout << (char)(s[0]-'a'+'A');
  }
  cout<<endl;
}

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


Measured memory_bytes: 256
from fractions import Fraction
from operator import add, mul

MOD = 10 ** 9 + 7


def inv(n):
    return pow(n, MOD - 2, MOD)


def mod_mul(x, y):
    return mul(x, y) % MOD


def mod_add(x, y):
    return add(x, y) % MOD


def cmb(n, r):
    return mod_mul(
        mod_mul(fact[n], inv(fact[r])),
        inv(fact[n - r]))


N, A, B, C = map(int, input().split())

r = mod_mul(100, inv(A + B))
a = mod_mul(A, inv(A + B))
b = mod_mul(B, inv(A + B))

pow_a = [1]
pow_b = [1]
for n in range(N + 1):
    pow_a.append(mod_mul(pow_a[-1], a))
    pow_b.append(mod_mul(pow_b[-1], b))

fact = [1]
for n in range(1, N * 2):
    fact.append(mod_mul(fact[-1], n))

p = 0
for m in range(N, N * 2):
    pa = pow_a[N] * pow_b[m - N]
    pb = pow_a[m - N] * pow_b[N]
    c = cmb(m - 1, N - 1)

    em = mod_mul(mod_mul(mod_mul(c, mod_add(pa, pb)), m), r)
    p = mod_add(p, em)
    # print(m, c, pa, pb, em, p)

f = Fraction(p, 1)
ans = mod_mul(f.numerator, inv(f.denominator))
print(ans)


Measured memory_bytes: 23032
using static System.Math;
using System;
 
public class ATC
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
      
		var n = int.Parse(line[0]);
		var L = int.Parse(line[1]);
		var absmin = int.MaxValue;
		var min = 0;
      
		for (int i = 1; i <= n; i++)
		{
			var t = Abs(L + i - 1);
			if (t < absmin) { absmin = t; min = L + i - 1; }
		}
		var s = n * (n + 2 * L - 1) / 2;
		Console.WriteLine(s - min);
	}
}

Measured memory_bytes: 13140
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=0,a[200005],ll,rr;
struct node
{
    int l,r;
    bool operator<(const node &a)const
    {return l!=a.l?l<a.l:r>a.r;}
}b[200005];
priority_queue<int,vector<int>,greater<int> > q;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i].l>>b[i].r;
	} 
    sort(b+1,b+n+1);
    ll=1,rr=m;
    for(int i=1;i<=n;i++)
	{
        q.push(b[i].r);
        if(ll<=rr&&ll<=b[i].l)
		{
			ll=ll+1;
		}
        else
		{
            a[++a[0]]=q.top();
            q.pop();
        }
    }
    sort(a+1,a+a[0]+1);
    for(int i=a[0];i>=1;i--)
	{
        if(ll<=rr&&a[i]<=rr)
		{
			rr--;
		}
        else ans++;
    }
    cout<<ans;
}

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

int N;
int A[110],B[110];
int main(){
	cin >> N;
	A[0] = 0;B[0] = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		A[i] += A[i-1];
	}
	for(int i=1;i<=N;i++){
		cin >> B[i];
		B[i] += B[i-1];
	}
	int ans = 0;
	for(int i=1;i<=N;i++){
		if(ans < A[i]+B[N]-B[i-1]) ans = A[i]+B[N]-B[i-1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]
    last = [-1] * 26

    score = 0
    for i in range(D):
        ti = next(it)-1
        score += S[i][ti]
        last[ti] = i
        for ci, la in zip(C, last):
            score -= ci * (i-la)
        print(score)


if __name__ == "__main__":
    resolve()


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


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

    vector<int> A(N+1);
        vector<int> B(N+1);

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

    for(int i = 0; i < N+1; i++){
        B.at(A.at(i)) ++;
    }
  
    for(int i = 1; i < N+1; i++){
        cout << B.at(i) << endl;
    }

}


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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed(n) fixed << setprecision(n)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int h, w, cnt = 0;
   string s[10];
   cin >> h >> w;

   rep(i, 0, h)
   {
      cin >> s[i];
      rep(j, 0, w)
      {
         if (s[i][j] == '#')
            ++cnt;
      }
   }

   if (cnt == (h + w - 1))
      cout << "Possible" << '\n';
   else
      cout << "Impossible" << '\n';
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
prime = set([2])
for i in range(3, 10000, 2):
    for j in prime:
        if i % j == 0:
            break
    else:
        prime.add(i)
n = int(input())
cnt = 0
for i in (int(readline()) for _ in range(n)):
    if i in prime:
        cnt += 1
        continue
    for j in prime:
        if i % j == 0:
            break
    else:
        cnt += 1
print(cnt)



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

using namespace std;
int main() {

ios::sync_with_stdio(false);
	cin.tie(0);
 
	
	int n;
	cin >> n;
 
	set<int> se;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
 
		if (se.count(a)) {
			se.erase(a);
		} else {
			se.insert(a);
		}
	}
 
	int res = se.size();
	cout << res << endl;



}

Measured memory_bytes: 4992
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

char S[110000];
char T[110000];
int main(){
	scanf("%s",S);
	int n=strlen(S);
	for(int i=0;i<n;i++){
		if(S[i]=='p')T[i]='q';
		if(S[i]=='q')T[i]='p';
		if(S[i]=='b')T[i]='d';
		if(S[i]=='d')T[i]='b';
		
	}
	reverse(T,T+n);
	for(int i=0;i<n;i++){
		if(S[i]!=T[i]){
			printf("No\n");return 0;
		}
	}printf("Yes\n");
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String str = sc.nextLine();
				find_JOI_IOI(str);
			}
		sc.close();
	}

	private static void find_JOI_IOI(String str) {
		int joi = 0;
		int ioi = 0;

		for (int i = 0; i < str.length() - 2; i++) {
			if (str.charAt(i) == 'J' && str.charAt(i + 1) == 'O' && str.charAt(i + 2) == 'I') {
					joi++;
			} else if (str.charAt(i) == 'I' && str.charAt(i + 1) == 'O' && str.charAt(i + 2) == 'I') {
					ioi++;
			}
		}

		System.out.printf("%d\n%d\n", joi, ioi);
	}

}


Measured memory_bytes: 27484
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll i=2; i<MAX; i++){
		fac[i] = fac[i-1]*i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

vl dp(202020,-1);
vl siz(202020,0);
vvl G(202020);
vl ans(202020,-1);
ll n;

P cp(ll u, ll p){
	if(dp[u] != -1) return P(dp[u],siz[u]);
	ll res = 1;
	vl sz;
	for(auto v : G[u]){
		if(v == p) continue;
		if(res == 0) res = 1;
		P p = cp(v,u);
		res *= p.first;
		res %= mod;
		siz[u] += p.second + 1;
		sz.push_back(p.second + 1);
	}
	res *= fac[siz[u]];
	res %= mod;
	for(auto i : sz){
		res *= finv[i];
		res %= mod;
	}
	dp[u] = res;
	return P(dp[u],siz[u]);
}

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}


void dfs(ll u, ll p){
	ans[u] = dp[u];
	if(p != -1){
		ans[u] *= siz[u] + 1;
		ans[u] %= mod;
		ans[u] *= ans[p] * modpow(dp[u],mod-2,mod) % mod;
		ans[u] %= mod;
		ans[u] *= inv[n-1-siz[u]];
		ans[u] %= mod;
	}
	for(auto v : G[u]){
		if(v != p) dfs(v,u);
	}
}

int main(){
	cin >> n;
	rep(i,n-1){
		ll a,b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	comInit();
	cp(0,-1);
	dfs(0,-1);
	rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 32624
#include<bits/stdc++.h>
using namespace std;
int a[210],n,sum,i;
int main(){
	scanf("%d",&n);
	for(i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(i=1;i<2*n;i+=2)
		sum+=a[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

const eps = 10e-9

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

LOOP:
	for h := 1; h <= 3500; h++ {
		for n := 1; n <= 3500; n++ {
			a := h * N * n
			b := 4*h*n - h*N - n*N
			if b != 0 {
				w := a / b
				if a%b == 0 && w > 0 {
					out(h, n, w)
					break LOOP
				}
			}
		}
	}
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int N;
struct Pi {
    double x, y;
};
vector<Pi> p;
double dist(Pi a, Pi b) {
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);

}
double f(double x, double y) {
    double res = 0;
    rep(i, N) {
        res = max(res, dist((Pi){x, y}, p[i]));
    }
    return res;
}
double g(double x) {
    double l = 0, r = 1000;
    rep(i, 100) {
        double c1 = (l * 2 + r) / 3;
        double c2 = (l + r * 2) / 3;
        if (f(x, c1) > f(x, c2)) l = c1;
        else r = c2;
    }
    return f(x, l);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    p = vector<Pi>(N);
    rep(i, N) cin >> p[i].x >> p[i].y;

    double l = 0, r = 1000;
    rep(i, 100) {
        double c1 = (l * 2 + r) / 3;
        double c2 = (l + r * 2) / 3;
        if (g(c1) > g(c2)) l = c1;
        else r = c2;
    }
    double ans = g(l);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end

n=gets.to_i
a=gets.to_i

puts n**2-a


Measured memory_bytes: 3836
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MAX(a, b)  a>b?a:b

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

	if(n==m) { 
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}

	return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE_WR freopen("../input.txt", "r", stdin);\
	freopen("../output.txt", "w", stdout);
#define deb(x)	cout << #x << " " << x << endl;
#define ll long long int

int main() {

	
	IOS

	int k, n;
	cin >> k >> n;

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

	int diff[n];
	for (int i = 0; i < n-1; i++)
		diff[i] = a[i+1] - a[i];

	diff[n-1] = k - a[n-1] + a[0];

	sort(diff, diff+n);
	int dist = 0;
	for (int i = 0; i < n-1; i++)
		dist += diff[i];

	cout << dist << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int s[101];
int dp[101][10001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=10000;j++){
			if(dp[i][j]==1){
				dp[i+1][j]=1;
				dp[i+1][j+s[i]]=1;
			}
		}
	}
	for(int i=10000;i>=0;i--){
		if(dp[n][i]==1 && i%10!=0){
			printf("%d\n",i);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}


Measured memory_bytes: 2560
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll h, n; cin >> h >> n;
  rep(i, n) {
    int x; cin >> x;
    h -= x;
  } cout << (h > 0 ? "No" : "Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A!=B && A!=C)cout << A << endl;
    else if(B!=A && B!=C)cout << B << endl;
    else cout << C << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Rectangular Searching
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0116

"""
import sys


def solve(m, height, width):
    def calc_hist(m):
        hist = [[0]* width for _ in range(height)]
        for y, row in enumerate(m):
            for x, ch in enumerate(row):
                if ch == '.':
                    hist[y][x] = hist[y-1][x]+1 if y >0 else 1
        return hist

    def calc_area(hist):
        stack = []
        area = 0
        for x, h in enumerate(hist):
            if not stack or stack[-1][0] < h:
                stack.append((h, x))
            elif stack[-1][0] > h:
                while stack and stack[-1][0] >= h:
                    hh, left = stack.pop()
                    area = max(area, hh*(x-left))
                stack.append((h, left))
        return area

    hist = calc_hist(m)
    ans = 0
    for y in range(height):
        ans = max(ans, calc_area(hist[y]+[0])) #  [0]はヒストグラムを最後にリフレッシュして処理するために必要
    return ans


def main(args):
    while True:
        height, width = map(int, input().split())
        if height == 0 or width == 0:
            break
        m = [input() for _ in range(height)]
        ans = solve(m, height, width)
        print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 7924
import types, math, operator
import numpy as np
from math import sqrt
from collections import Counter
from itertools import product
from functools import reduce
class PrimeUtils:
    @staticmethod
    def _has_numpy():
        g = globals()
        m = g.get('np')
        if m is not None and isinstance(m, types.ModuleType):
            return  m.__name__ == 'numpy'
        return False
    @staticmethod
    def _primes_sieve_pp(n):
        sieve = [True] * (n + 1)
        for i in range(2, int(sqrt(n)) + 1):
            if sieve[i]:
                for j in range(i * i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    def _primes_sieve_np(n):
        sieve = np.ones(n + 1, np.bool)
        sieve[0] = sieve[1] = False
        for i, v in enumerate(sieve[2:int(sqrt(n)) + 1], 2):
            if v: sieve[i*i::i] = False
        return np.nonzero(sieve)[0]
    @staticmethod
    def _primes_sieve_np_fast(n):
        n += 1
        sieve = np.ones(n//3 + (n%6 == 2), dtype=np.bool)
        check_upper = int(sqrt(n)) // 3
        for i, v in enumerate(sieve[1:check_upper + 1], 1):
            if v:
                k = (3*i + 1) | 1
                sieve[k* k           //3::2*k] = False
                sieve[k*(k-2*(i&1)+4)//3::2*k] = False
        sieve[0] = False
        return np.r_[2,3,((3*np.nonzero(sieve)[0] + 1)|1)]
    @classmethod
    def primes_sieve(cls, n):
        if cls._has_numpy():
            return cls._primes_sieve_np_fast(n)
        else:
            return cls._primes_sieve_pp(n)
    # Prime Factor Decomposition
    @classmethod
    def pfd(cls, n):
        primes = cls.primes_sieve(n)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        assert(cur == 1)
        return factors
    # List up aliquots
    @classmethod
    def aliquots(cls, n):
        pf = cls.pfd(n)
        pfc = Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        if not ppv:
            return (1,)
        else:
            return map(lambda x: reduce(operator.imul, x), product(*ppv))

a,b,k = map(int, input().split())

aa = set(PrimeUtils.aliquots(a))
bb = set(PrimeUtils.aliquots(b))
print(sorted(aa & bb, reverse=True)[k-1])


Measured memory_bytes: 21392
#include <iostream>

using namespace std;

int main()
{
    for (int i = 0; i < 9; ++i) {
        for (int j=0;j<9;j++){
            cout<<(i+1)<<"x"<<(j+1)<<"="<<(i+1)*(j+1)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1116
s = input()

ans = 'YES'

while len(s) > 0:
    if s.endswith('dreamer'):
        s = s[:-7]
    elif s.endswith('dream'):
        s = s[:-5]
    elif s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('erase'):
        s = s[:-5]
    else:
        ans = 'NO'
        break

print(ans)

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

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

typedef long long ll;

ll lcm(ll A, ll B){
    return (A*B)/__gcd(A, B);
}

int main() {
    ll A,B,C,D;
    cin>>A>>B>>C>>D;

    ll e = B/C + B/D - B/lcm(C, D);
    //cout << e << endl;
    e -= (A-1)/C + (A-1)/D - (A-1)/lcm(C, D);
    //cout << (A-1)/C + (A-1)/D - (A-1)/lcm(C, D) << endl;

    cout << B-A-e+1 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;
static const int INF = (1 << 21);

ll int a[100001] = { 0 };

ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	while (b > 0) {
		ll int r = a%b;
		a = b;
		b = r;
	}
	return a;
}

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

int main() {
	int N;
	cin >> N;
	ll T[100];
	ll ans = 1;
	for (int i = 0;i < N;i++) {
		cin >> T[i];
		ans = lcm(ans, T[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

template<typename T>
class Stack {
public:
    Stack() {}

    void push(T a) {
        v.push_back(a);
    }

    T pop() {
        T last = v.back();
        v.pop_back();
        return last;
    }

private:
    vector<T> v;
};

int64_t calc(Stack<string> &s) {
    string str = s.pop();
    if (str == "+") {
        return calc(s) + calc(s);
    } else if (str == "-") {
        int64_t a = calc(s);
        int64_t b = calc(s);
        return b - a;
    } else if (str == "*") {
        return calc(s) * calc(s);
    } else {
        return stoi(str);
    }
}

int main() {
    string str;
    Stack<string> s;

    while (cin >> str) s.push(str);
    cout << calc(s) << endl;

    return 0;
}

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

int main()
{
	int h = 0, w = 0;

	cin >> h >> w;

	while ((h != 0) | (w != 0)) {
		for (int j = 0; j < h; j++) {
			for (int i = 0; i < w; i++) {
				if (((i + j) % 2) == 0)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}			
		cout << endl;
		cin >> h >> w;
	}

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll N = SZ(S);
    vec A(N, 0);
    set<ll> P;
    REP(i,0,N-1) {
        if(S[i] == 'R' && S[i+1] == 'L') {
            P.insert(i);
        }
    }
    REP(i,0,N) {
        ll k;
        if(S[i] == 'R') {
            k = *(P.lower_bound(i));
            if((k - i) % 2 == 0) ++A[k];
            else ++A[k+1];
        }
        else {
            k = *prev(P.lower_bound(i));
            if((i - k) % 2 == 0) ++A[k];
            else ++A[k+1];
        }
    }

    REP(i,0,N) PS(A[i]);
    PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 6248
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
int water[3010];
int sug[3010];
int a,b,c,d,e,f;
 
int dpW(int val) {
	if (val<100*a) return 0;
	if (water[val]!=-1)return water[val];
	if (val==100*a||val==100*b) return 1;
	return water[val]=(dpW(val-100*a)||dpW(val-100*b));
}
 
int dpS(int val) {
	if (val<0) return 0;
	if (sug[val]!=-1) return sug[val];
	if (val<c) return sug[val]=0;
	if (val==c||val==d) return sug[val]=1;
	return sug[val]=(dpS(val-c)||dpS(val-d));
}
 
int solve(int val) {
	int mx=0;
	for (int i=1;i<=val/100;i++) {
		if (dpW(i*100)==0) continue;
		if (val-i*100>e*i) continue;
		if (sug[val-i*100]==0) continue;
		//printf("-- %d %d %d\n",i,e*i,val-i*100);
		//if (val==2635) printf("-- %d\n",val-i*100);
		mx=max(mx,val-i*100);
		break;
	}
	return mx;
}
 
int main () {
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	memset(sug,-1,sizeof(sug));
	memset(water,-1,sizeof(water));
	for (int i=0;i<=3000;i++) {
		dpS(i);
		//if (sug[i]==1) printf("-- %d\n",i);
	}
	//for (int i=1;i<=3000;i++) {
		//if (sug[i]==1) sug[i]=i;
		//else sug[i]=sug[i-1];
	//}
	//printf("%d\n",sug[10]);
	int aa=100*a,bb=0;
	for (int i=100*a;i<=f;i++) {
		//printf("%d\n",i);
		int now = solve(i);
		//printf("** %d\n",now);
		//if (i==2635) printf("-- %d\n",now);
		if (bb*i<now*aa) {
			aa=i;
			bb=now;
		}
	}
	printf("%d %d\n",aa,bb);
	return 0;
}


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

typedef vector<int> vec;
typedef vector<vec> mat;

int calc_rank(mat A) {
	const int n = A.size();
	const int m = A[0].size();

	int res = 0;
	int col = -1;

	for(int i = 0; i < n; ++i) {
		int pivot;
		for(;;) {
			if(++col == m) goto rank_end;
			pivot = -1;
			for(int j = i; j < n; ++j) {
				if(A[j][col]) {
					pivot = j;
					goto pivot_end;
				}
			}
		}

	pivot_end:;
		A[i].swap(A[pivot]);
		++res;

		for(int j = i + 1; j < n; ++j) {
			if(A[j][col]) {
				for(int k = col + 1; k < m; ++k) {
					A[j][k] ^= A[i][k];
				}
			}
		}
	}

rank_end:;
	return res;
}

int calc_rank(const mat &A, const vec &b) {
	const int n = A.size();
	const int m = A[0].size() + 1;
	mat B(n, vec(m));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m - 1; ++j) {
			B[i][j] = A[i][j];
		}
	}
	for(int i = 0; i < n; ++i) {
		B[i][m - 1] = b[i];
	}
	return calc_rank(move(B));
}

int w, h, d;

inline bool solve(const mat &A, const vec &b) {
	return calc_rank(A) == calc_rank(A, b);
}

inline int get_index(int x, int y) {
	return x + y * w;
}

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

	while(cin >> w >> h >> d && h) {
		const int number_of_cell = w * h;
		vec right(number_of_cell);
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				cin >> right[get_index(x, y)];
			}
		}

		mat left(number_of_cell, vec(number_of_cell, 0));
		for(int i = 0; i < number_of_cell; ++i) {
			left[i][i] = 1;
		}

		for(int y = 0; y < h; ++y) {
			for(int ty = max(0, y - d); ty <= min(h - 1, y + d); ++ty) {
				for(int sign = -1; sign <= 1; sign += 2) {
					const int dx = sign * (d - abs(y - ty));
					for(int x = 0; x < w; ++x) {
						const int tx = x + dx;
						if(tx < 0 || tx >= w) continue;
						left[get_index(x, y)][get_index(tx, ty)] = 1;
					}
				}
			}
		}

		cout << solve(left, right) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5828