akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 1<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };


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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}


ll c[4010][4010];
void init(){
	c[0][0] = 1;
	rep(i, 4001){
		rep(j, i+1){
			c[i+1][j] += c[i][j];
			c[i+1][j] %= MOD;
			c[i+1][j+1] += c[i][j];
			c[i+1][j] %= MOD;
		}
	}
}

ll comb(int n, int k){
	return c[n][k];
}


ll func2(int n, int k){
	return comb(n+k-1, k-1);
}

ll func(int n, int k){
	if(n < k) return 0;
	if(n == 0 && k == 0) return 1;
	if(k < 1) return 0;
	return func2(n-k, k);
}

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

	init();
	rep2(i, 1, k+1){
		ll b = func(k, i);
		ll r = 0;
		r += func(n-k, i-1); r %= MOD;
		r += func(n-k, i); r %= MOD;
		r += func(n-k, i); r %= MOD;
		r += func(n-k, i+1); r %= MOD;
		cout << (b*r) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 123904
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    printf("%.10f\n",a*b/3.305785);
    
    return 0;
}



Measured memory_bytes: 3200
possible_appearances = ->(dice) {
  table = 
     [[0, 1, 2, 3, 4, 5], [3, 1, 0, 5, 4, 2], [1, 5, 2, 3, 0, 4], [5, 1, 3, 2, 4, 0],
      [1, 2, 0, 5, 3, 4], [3, 5, 1, 4, 0, 2], [5, 4, 2, 3, 1, 0], [2, 1, 5, 0, 4, 3],
      [1, 0, 3, 2, 5, 4], [5, 2, 1, 4, 3, 0], [2, 4, 0, 5, 1, 3], [4, 5, 3, 2, 0, 1],
      [3, 4, 5, 0, 1, 2], [4, 0, 2, 3, 5, 1], [1, 3, 5, 0, 2, 4], [2, 0, 1, 4, 5, 3],
      [0, 4, 3, 2, 1, 5], [4, 2, 5, 0, 3, 1], [4, 3, 0, 5, 2, 1], [2, 5, 4, 1, 0, 3],
      [3, 0, 4, 1, 5, 2], [0, 3, 1, 4, 2, 5], [0, 2, 4, 1, 3, 5], [5, 3, 4, 1, 2, 0]]
  result = []
  table.each do |dice1|
    next_dice = Array.new(6, 0)
    dice1.each_with_index {|n, i| next_dice[n] = dice[i]}
    result << next_dice
  end
  result.uniq
}

dice = gets.split.map(&:to_i)
puts possible_appearances.(gets.split.map(&:to_i)).include?(dice) ? "Yes" : "No"



Measured memory_bytes: 6876
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
struct TREE { int w,d; }t[N<<2];
#define w(p) t[p].w
#define d(p) t[p].d
void build (int p,int l,int r)
{
	w(p)=1e9;
	if (l==r) return ;
	int mid=(l+r)>>1,ls=p<<1,rs=ls|1;
	build (ls,l,mid),build (rs,mid+1,r);
}
void change (int p,int l,int r,int w,int d)
{
	if (l==r) return w(p)=min (w(p),d),void ();
	int mid=(l+r)>>1,ls=p<<1,rs=ls|1;
	(w<=mid)?change (ls,l,mid,w,d):change (rs,mid+1,r,w,d);
	w(p)=min (w(ls),w(rs));
}
int query (int p,int l,int r,int L,int R)
{
	if (L<=l&&r<=R) return w(p);
	int mid=(l+r)>>1,ls=p<<1,rs=ls|1,ans=1e9;
	if (L<=mid) ans=min (ans,query (ls,l,mid,L,R));
	if (R> mid) ans=min (ans,query (rs,mid+1,r,L,R));
	return ans;
}
vector <int> v[N];
int a[N],f[N];
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	int n,s=0; sc(n);
	for (int i=1; i<=n; i++)
		sc(a[i]),s+=!a[i];
	int m; sc(m);
	for (int i=1; i<=m; i++)
	{
		int l,r; sc(l),sc(r);
		v[l].push_back (r);
	}
	build (1,0,n);
	change (1,0,n,0,0);
	memset (f,63,sizeof (int)*(n+1));
	f[0]=0;
	for (int i=1; i<=n; i++)
	{
		for (int r:v[i])
		{
			int g=min (f[i-1],query (1,0,n,i-1,r));
			// printf ("%d %d %d\n",i,r,g);
			if (g< f[r]) change (1,0,n,r,f[r]=g);
		}
		f[i]=min (f[i],f[i-1]+(a[i]?1:-1));
		// for (int i=1; i<=n; i++) printf ("%d ",f[i]);putchar('\n');
	}
	pr(f[n]+s);


	return 0;
}


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

using namespace std;


// 選挙区ごとに勝つために必要な最小数をもとめてく
// s[l..r-1] ; [l, r)
long long solve(const std::string& s, int l, int r){
//    cerr << s.substr(l, r-l) << '\n';
    if(s[l] != '['){
        int c = stoi(s.substr(l, r - l));
        return (c + 1) / 2;
    }
    vector<long long> needs;
    int i = l;
    i++;
    r--;
    while(i < r){
        // s[i] == '['
        int right = i;
        int d = 1;
        while(d > 0){
            if(s[right] == '['){
                d++;
            }
            else if(s[right] == ']'){
                d--;
            }
            right++;
        }
        needs.push_back(solve(s, i, right-1));
        i = right + 1;
    }
    sort(needs.begin(), needs.end() );
    int size = needs.size();
    int kahan = (size + 1) / 2;
    int ans = 0;
    for (int i = 0; i < kahan; ++i) {
        ans += needs[i];
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string inar;
        cin >> inar;
        cout << solve(inar, 1, inar.size()-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int show(int n){
    int sw = 0;
    while(n > 0){
        sw += n % 10;
        n /= 10;
    }
    return sw;
}
int main(){
    int A, B, N;
    cin >> N >> A >> B;
    int sum = 0;
    for(int i = 1; i <= N; i++){
        int sw = show(i);
        if(sw >= A && sw <= B)
            sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
if b<=c or d<=a:
    print(0)
elif a<=c and d<=b:
    print(d-c)
elif c<=a and b<=d:
    print(b-a)
elif a<=c<=b:
    print(b-c)
else:
    print(d-a)


Measured memory_bytes: 2940
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 1005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    
    int n,k;
    cin>>n>>k;
    ll ans=0;

    for(int i=k;i<=n+1;i++){
        ans=(ans+(i*(n-i+1))+1)%mod;
    }

    cout<<ans;

    return;
}
// how r u bro

Measured memory_bytes: 3504
#include<iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int* a=new int[n]{};
  for(int i=0;i<k;i++){
    int di;cin>>di;
    for(int j=0;j<di;j++){
      int ai;cin>>ai;
      a[ai-1]++;
    }
  }
  int c=0;
  for(int i=0;i<n;i++){
    if(!a[i])c++;
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 3568
#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>
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 ;

string s;
int n,k;

bool vIs0(int i){
  if((s[0]=='0' && i%2==0) || (s[0]=='1' && i%2==1))return true;
  else return false;
}

int main(){
  cin >> n >> k;
  cin >> s;
  vector<ll> v;
  bool Is0=true;
  ll length=0;
  if(s[0]=='1')Is0=false;
  rep(i,n){
    if(s[i]=='0' && Is0){
      length++;
    }
    else if(s[i]=='0' && !Is0){
      v.push_back(length);
      length=1;
      Is0=true;
    }
    else if(s[i]=='1' && Is0){
      v.push_back(length);
      length=1;
      Is0=false;
    }
    else if(s[i]=='1' && !Is0){
      length++;
    }
    if(i==n-1)v.push_back(length);
  }
  ll ans=0;
  if((s[0]=='1' && v.size()/2<=k) || (s[0]=='0' && (v.size()+1)/2<=k)){
    cout << n << endl;
    return 0;
  }
  ll sum[(int)v.size()]={};
  sum[0]=v[0];
  rep(i,v.size()-1){
    sum[i+1]=sum[i]+v[i+1];
  }
  for(int i=0;i<v.size();i++){
    ll subsum=0;
    int range=0;
    int m=(int)v.size()-1;
    if(i==0 && vIs0(i)){
      range=min(2*k-1,m);
      subsum=sum[range];
    }
    else if(i==0 && !vIs0(i)){
      range=min(2*k,m);
      subsum=sum[range];
    }
    else if(i==1 && vIs0(i)){
      range=min(m,2*k);
      subsum=sum[range];
    }
    else if(vIs0(i)){
      int right=min(m,i+2*k-1);
      int left=i-2;
      subsum=sum[right]-sum[left];
    }
    else if(!vIs0(i)){
      int right=min(m,i+2*k);
      int left=i-1;
      subsum=sum[right]-sum[left];
    }
    ans=max(ans,subsum);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 2164
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#include <random>
#include <chrono>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n][n];
  REP(i, n){
    REP(j, n) cin >> a[i][j];
  }
  bool b[n][n] = { };
  REP(i, n){
    REP(j, n){
      REP(k, n){
        if(a[i][j] + a[j][k] < a[i][k]){
          cout << -1 << endl;
          return 0;
        }
        if(a[i][j] + a[j][k] == a[i][k] && i != j && j != k){
          b[i][k] = true;
        }
      }
    }
  }
  ll tmp = 0;
  REP(i, n){
    REP(j, n){
      if(!b[i][j]) tmp += a[i][j];
    }
  }
  cout << tmp/2 << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  vector<PII> v(n);
  REP(i, n) cin >> a[i], v[i] = {a[i], i};
  REP(i, n) cin >> b[i];

  sort(ALL(v)); sort(ALL(b));

  ll win = 0, idx = 0;
  REP(i, n) {
    if(idx == n) break;
    if(v[idx].first < b[i]) {
      idx++, win++;
    }
  }

//  cout << can << endl;

  auto check = [&](ll pre, ll mid) {
    ll idx = 0, w = 0;
    REP(i, b.size()) {
      if(i == mid) continue;
      while(idx < v.size() && v[idx].second <= pre) idx++;
      if(idx == v.size()) break;
      if(v[idx].first < b[i]) {
        idx++;
        w++;
      }
    }
    if(w + (b[mid] > a[pre]) == win) return true;
    return false;
  };

//  cout << endl;

  vector<ll> ans(n);
  REP(i, n) {
    ll lb = 0, ub = b.size();
    ll tmp = upper_bound(ALL(b), a[i]) - b.begin();
    if(tmp != ub) lb = tmp;
//    if(lb == ub) {
//      cerr << "err" << endl;
//    }
    while(ub-lb>1) {
      ll mid = (lb+ub)/2;
      if(check(i, mid)) lb = mid;
      else ub = mid;
    }
//    cout << b[lb] << endl;
    ans[i] = b[lb];
    win -= a[i] < b[lb];
    b.erase(b.begin() + lb);
  }

  REP(i, n) cout << ans[i] << (i==n-1?'\n':' ');
  cout << flush;

  return 0;
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=41;
const int M=(1<<17)+5;
const int P=1e9+7;
int n,A,B,C,D,U,tr[M][11],f[N][M];
int Mod(int x){return x>=P?x-P:x;}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),A=read(),B=A+read(),C=B+read(),U=(1<<C);
	for(int S=1;S<=U;S++)
	for(int i=1;i<=10;i++){
		tr[S][i]=1;
		for(int j=0;j<=C;j++)if(S>>j&1){
			if(j<A&&j+i>A)continue;
			if(j<B&&j+i>B)continue;
			if(j+i<=C)tr[S][i]|=1<<(j+i);
		}if((S==U)||(tr[S][i]>=U))tr[S][i]=U;
	}f[0][1]=1;
	for(int i=1;i<=n;i++)
	for(int S=1;S<=U;S++)
	for(int j=1;j<=10;j++)f[i][tr[S][j]]=Mod(f[i][tr[S][j]]+f[i-1][S]);
	printf("%d",f[n][U]);
	return 0;
}


Measured memory_bytes: 29840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

bool is_prime(int x){
    if(x <= 1) return false;
    for (int i = 2; i*i < x; i++){
        if(x%i == 0)
            return false;
    }
    return true;
}


int main(){
    int x;
    cin >> x;
    int p = x;
    while(!is_prime(p)) p++;
    cout << p << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e5+10,inf=0x3f3f3f3f,mod=1;
using namespace std;
pair<ll,ll>nt[maxn];
ll sum=1;
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first>b.first;
}
ll ksm(ll a,ll b)
{
    ll ans=1;
    for(; b; b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
ll C(ll m,ll n)
{
    n=min(n,m-n);
    ll s1=1,s2=1;
    for(int i=1; i<=n; i++)
    {
        s1=s1*i%mod;
        s2=s2*(m-i+1)%mod;
    }
    return s2*ksm(s1,mod-2)%mod;
}
int a[100010],b[100010];
int main()
{
    ios::sync_with_stdio(false);
    int A,B,M;cin>>A>>B>>M;
    int ma=inf,mb=inf;
    for(int i=0;i<A;i++)
    {
        cin>>a[i];
        if(a[i]<ma) ma=a[i];
    }
    for(int i=0;i<B;i++)
    {
        cin>>b[i];
        if(mb>b[i])mb=b[i];
    }

    //sort(a,a+A);sort(b,b+B);
    int sum=ma+mb;
    for(int i=0;i<M;i++)
    {
        int t1,t2,t3;cin>>t1>>t2>>t3;
        sum=min(sum,a[t1-1]+b[t2-1]-t3);
    }
    if(sum<0) sum=0;
    cout<<sum<<endl;

}









Measured memory_bytes: 1024
import java.util.Scanner;

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

		while(true){
			int H = stdIn.nextInt();
			int W = stdIn.nextInt();

			if( H == 0 && W == 0) {
				break;
			}

			for (int i = 0; i < H; i ++) {
				for (int j = 0; j < W; j++) {
					if(i%2 == 0) {
						if(j%2==0){
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} else {
						if(j%2==0){
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		stdIn.close();

	}
}



Measured memory_bytes: 36512
a, b, c = map(int, input().split())

now = a
#loop = 2
check = 0

for i in range(1000000):
#  print(now, now//a,  b, now%b)
  if now % b == c:
    check += 1
    break
  else:
#    now += a*loop
    now += a
#    loop += 1
    
if check > 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
eval"N,*A="+$<.read.split*?,
_4 = A.count{|a|a%4<1}
_1 = A.count(&:odd?)
_2 = N - _1 - _4
if _1 > _4+1 || (_4 == 0 && _1 > 0) || (N == 1 && _2 == 1) || (_1 == _4+1 && _2 > 0)
  puts :No
else
  puts :Yes
end


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

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

  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);

  vector<int> X(N+1);
  for( int i = 0; i < N; i++ ){
    X.at(A[i]) = X.at(A[i]-1)+1;
  }

  int hiku = 0;
  for( int i = 1; i <= N; i++ ) hiku = max(hiku, X[i]);
  cout << N-hiku << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;


signed main()
{
  int N;
  string S;
  set<string> st;
  
  cin >> N;

  Rep(i, N) {
    cin >> S;
    st.insert(S);
  }

  bool state = false;
  int M;
  cin >> M;
  while(M--) {
    cin >> S;
    if(st.find(S) != st.end()) {
      if(state) { cout << "Closed by "; state = false; }
      else { cout << "Opened by "; state = true; }
      cout << S << endl;
    } else {
      cout << "Unknown " << S << endl;
    }
  }

  return 0;
}
	  

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;



int main() {
	string s;
	char v[20];
	/*getline(cin,s);

	for (auto itr = s.end(); itr != s.begin(); itr--) {
		cout << *itr;
	}
	cout << endl;*/

	cin >> v;
	for (int i = strlen(v)-1; i > -1; i--) {
		cout << v[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <math.h>

int main(){
  std::string s;
  int sum=0,d=0;
  while(std::cin>>s){
    if(!s.compare("abc"))break;
    if(std::cin.eof())break;
    for(int i=s.length()-1;i>=0;i--){
      d=0;
      //ツづつアツづ慊づ堕アツつッツづァツづェツづゥツつゥツづーツ板サツ津ィツつオツづつ「ツづ慊つキツ。
      int k = i;
      for(int j=i;j>=0;j--){
	if(s[j]>='0'&&s[j]<='9')
	  d+=(static_cast<int>(s[j]-'0')*pow(10,k-j)),i--;
	else{break;}
      }
      sum+=d;
    }
  }
  std::cout<<sum<<std::endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();

    	int[] A=new int[N];

    	for(int i=0;i<N;i++) {
    		A[i]=sc.nextInt()-1;
    	}

    	int now=A[0];
    	int next=0;

    	int counter=1;

    	while(true) {

    		if(now==1) {
    			break;
    		}

    		next=A[now];

    		A[now]=-1;
    		counter++;

    		if(next==-1) {
    			counter=-1;
    			break;
    		}else {
    			now=next;
    		}

    	}


    	System.out.println(counter);


    }

}



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

#define int long long

int gcd(int a, int b) {
  if (a < b) { a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

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

signed main() {
  int A,B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
}


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

int main() {
  std::string K, K_cut;
  int S;
  std::cin >> S >> K;
  if ((int)K.length() > S) {
    K_cut = K.substr(0, S);
    std::cout << K_cut << "..." << std::endl;
  }
  else {
    std::cout << K << std::endl;
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
struct s{
	int b,c;
}d[55];
int n,ans,a[55];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>d[i].b;
	for(int i=1;i<=n-1;i++)
		cin>>d[i].c;
	for(int i=1;i<=n;i++)
	{
		ans+=d[a[i]].b;
		if(a[i-1]&&a[i]-a[i-1]==1)
			ans+=d[a[i-1]].c;
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 256
function main()
	N,K=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	ans=0
	mod=10^9+7
	for i=1:N
		a=A[i]
		cnt=0
		for j=1:i-1
			if A[j]>a
				cnt+=1
			end
		end
		ans+=cnt*K%mod
		for j=i+1:N
			if A[j]>a
				cnt+=1
			end
		end
		ans+=div(K*(K-1),2)%mod*cnt%mod
	end
	println(ans%mod)
end
main()


Measured memory_bytes: 167652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int n;cin>>n;
    int a=n%1000;
    if(a==0){cout<<0<<endl;return 0;}
    else{cout<<1000-a<<endl;return 0;}
}

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

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

    int ans;
    if (n == 100) {
        ans = pow(100, d) * (n + 1);
    }
    else {
        ans = pow(100, d) * n;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

class Slide_Max {
public:
	vector<long long>dat; long long size_, L = 0, R = -1;
	deque<pair<long long, long long>>Q;

	void init(int size__) {
		size_ = size__;
		dat.resize(size_, 0);
	}
	void update(long long p, long long x) {
		dat[p] = x;
	}
	long long query(long long l, long long r) {
		while (R < r) {
			R++;
			while (!Q.empty()) {
				pair<long long, long long>A = Q.back();
				if (A.first <= dat[R])Q.pop_back();
				else break;
			}
			Q.push_back(make_pair(dat[R], R));
		}
		while (L < l) {
			while (!Q.empty()) {
				pair<long long, long long>A = Q.front();
				if (A.second <= L)Q.pop_front();
				else break;
			}
			L++;
		}
		return Q.front().first;
	}
};

long long N, M, K, a[100009], dp[309][100009];

int main() {
	cin >> N >> M >> K;
	for (int i = 1; i <= N; i++)cin >> a[i];
	for (int i = 0; i < 309; i++) { for (int j = 0; j < 100009; j++)dp[i][j] = (-1LL << 62); }
	for (int i = 0; i < 100009; i++)dp[0][i] = 0;
	for (int i = 0; i < K; i++) {
		Slide_Max X; X.init(N + 3);
		for (int j = 0; j <= N; j++) X.update(j, dp[i][j]);
		for (int j = 1; j <= N; j++) {
			long long L = j - M, R = j - 1; if (L < 0)L = 0;
			dp[i + 1][j] = 1LL * (i + 1)*a[j] + X.query(L, R);
		}
	}
	long long maxn = 0;
	for (int i = 0; i <= N; i++)maxn = max(maxn, dp[K][i]);
	cout << maxn << endl;
	return 0;
}

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

namespace ProblemE
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = new List<int>();
            var Bs = new List<int>();

            for (int i = 0; i < N; i++)
            {
                var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                As.Add(read[0]);
                Bs.Add(read[1]);
            }
            As.Sort();
            Bs = Bs.OrderBy(x => x).ToList();

            if(N % 2 == 0)
            {
                var median_ind1 = (N / 2) - 1;
                var median_ind2 = (N / 2 + 1) - 1;
                var lower1 = As[median_ind1];
                var lower2 = As[median_ind2];
                var upper1 = Bs[median_ind1];
                var upper2 = Bs[median_ind2];
                var res = (upper1 + upper2) - (lower1 + lower2) + 1;
                Console.WriteLine(res);
            }
            else
            {
                var median_ind = (N + 1) / 2 - 1;
                var lower = As[median_ind];
                var upper = Bs[median_ind];

                Console.WriteLine(upper - lower + 1);
            }
        }
    }
}


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

int main(){
	char b;
	cin >> b;
	if(b=='A'){
		cout << "T" << endl;
	}
	else if(b=='T'){
		cout << "A" << endl;
	}
	else if(b=='C'){
		cout << "G" << endl;
	}
	else if(b=='G'){
		cout << "C" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	a := make([]int, n)
	s := 0
	for i := 0; i < n; i++ {
		con.Scan(&a[i])
		s += a[i]
	}
	t := a[0]
	m := t - (s - t)
	if m < 0 {
		m = -m
	}
	for i := 1; i < n-1; i++ {
		t += a[i]
		l := t - (s - t)
		if l < 0 {
			l = -l
		}
		if l < m {
			m = l
		}
	}
	con.Println(m)
	return nil
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define all(a) (a).begin(), (a).end() 
#define MAXN 2005
using namespace std;

ll h, w, m=1e9+7;
char arr[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w;
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++) cin>>arr[i][j];
	}
	dp[1][1]=1;
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			if(dp[i][j]==0 && arr[i][j]=='.')
			{
				if(i>=2 && j>=2 && arr[i-1][j]=='.' && arr[i][j-1]=='.')
				{
					dp[i][j] = (dp[i-1][j]+dp[i][j-1])%m;
				}
				else if(i>=2 && arr[i-1][j]=='.') dp[i][j]=dp[i-1][j]%m;
				else if(j>=2 && arr[i][j-1]=='.') dp[i][j]=dp[i][j-1]%m;
			}
		}
	}
	cout<<dp[h][w]%m<<endl;
	return 0;
}

Measured memory_bytes: 20224
#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;
#define X real()
#define Y imag()
#define EPS (1e-10)
double dot(P a, P b){
  return a.X*b.X + a.Y*b.Y;
}
double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}
int main(){
  P points[4];
  int q, x, y;
  cin >> q;
  for(int i = 0; i < q; ++i){
    for(int j = 0; j < 4; ++j){
      cin >> x >> y;
      points[j] = P(x,y);
    }
    if(abs(dot(points[0]-points[1],points[2]-points[3])) < EPS) cout << 1 << endl;
    else if(abs(cross(points[0]-points[1],points[2]-points[3])) < EPS) cout << 2 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

int main()
{
	string ss, tt;
	cin >> ss >> tt;
	vector<char>s;
	vector<char>t;

	for (int i = 0; i < ss.length(); i++)s.push_back(ss[i]);
	for (int i = 0; i < tt.length(); i++)t.push_back(tt[i]);

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	int a, b;
	for (a = 0, b = t.size() - 1; a < s.size() && b >= 0; a++, b--)
	{
		if (s[a] - 'a' < t[b] - 'a')
		{
			cout << "Yes" << endl;
			return 0;
		}
		else if (s[a] - 'a' == t[b] - 'a') {
			continue;
		}
		else {
			cout << "No" << endl;
			return 0;
		}

	}

	if (a >= s.size() && b < 0)cout << "No" << endl;
	else if (a != s.size())cout << "No" << endl;
	else if (b > -1)cout << "Yes" << endl;

	/*
	if (s[0] - 'a' < t[t.size()- 1] - 'a')cout << "Yes" << endl;
	else if (s[0] - 'a' == t[t.size() - 1] - 'a') {
		if (s.size() < t.size()) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else cout << "No" << endl;
	*/


	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,p; cin>>n>>p;
  ll odd=0, even=0;
  rep(i,n){
    ll a; cin>>a;
    if(a%2) odd++;
    else even++;
  }
  
  if(odd==0){
    if(p==1){
      cout<<0<<endl;
    }else{
      ll ans=round(pow(2,even));
      cout<<ans<<endl;
    }
  }else{
    ll ans=round(pow(2,even+odd-1));
    cout<<ans<<endl;
  }
  
 }

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

from collections import Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)

ans = 0
for v in C.values():
    ans += v*(v-1)//2

for a in A:
    v = C[a]
    if v == 1:
        print(ans)
    else:
        print(ans - v*(v-1)//2 + (v-1)*(v-2)//2)

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int ans = 0;
   int n; cin >>n;
   string s; cin >> s;
   int tmp = 0;
   for(int i =0; i < s.size(); i++)
   {
      if(s[i] == 'I')
      {
         tmp++;
         ans = max(ans, tmp);
      }
      else
      {
         tmp--;
      }
   }
   cout << ans << nl;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// べき乗
ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  int X;
  cin >> X;
  if (X>=30) cout << "Yes";
  else cout << "No";
  cout << endl;
}


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

struct Edge {int to, cost;};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int mind(vector<int> &a,vector<int> &b){
	int n=a.size();
	int min=INT_MAX;
	int ind=0;
	for (int i=0;i<n;i++){
		if((min>a[i])&&(b[i]==0)){
			min=a[i];
			ind=i;
		}
	}
	if(min==INT_MAX){
		return -1;
	}else{
		return ind;
	}
}

int min(vector<int> &a){
	int n=a.size();
	int min=a[0];
	int ind=0;
	for (int i=0;i<n;i++){
		if(min>a[i]){
			min=a[i];
			ind=i;
		}
	}
	return min;
}

void dijkstra(Graph &G,vector<int> &d,int n,int s){
	fill(d.begin(),d.end(),INT_MAX);
	vector<int> c(n,0);
	int t;
	
	d[s]=0;
	
	while((t=mind(d,c))!=-1){
		c[t]=1;
		for(int i=0;i<G[t].size();i++){
			Edge e=G[t][i];
			if(d[e.to] > d[t]+e.cost){
				d[e.to] = d[t]+e.cost;
			}
		}
	}
}

int main(){
	int n,i,j,k;
	vector<int> d(n);
	Edge e;
	
	cin >> n;
	
	Graph G(n);
	
	for (i=0;i<n;i++){
		cin >> k >> k;
		for (j=0;j<k;j++){
			cin >> e.to >> e.cost;
			G[i].push_back(e);
		}
	}
	
	dijkstra(G,d,n,0);
	
	for (i=0;i<n;i++){
		cout << i << " " << d[i] << endl;
	}
	
	return 0;
}

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

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

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

    int m;
    cin >> m;

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

    // ドリンクを飲まない場合の合計時間を求める
    int t_sum = 0;
    for(int i = 0; i < n; ++i) {
        t_sum += t[i];
    }

    // ドリングごとに発生する差を足して出力
    for(int i = 0; i < m; ++i) {
        int index = p[i]-1;
        cout << t_sum - t[index] + x[i] << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
 
ll N;
vector<ll> v(4000);
ll j=0;
 
void input(){
    cin >> N;
}
 
void swapmin(){
    if(v[j-1] < v[j]){
        int i = v[j];
        v[j] = v[j-1];
        v[j-1] = i;
    }
}
 
 
void solve(){
	
    v[0] = N + 1;
    for (ll i = 2;i*i<=N;i++){
        if (0 == N % i){
           j++;
           v.at(j) = i + (N/i); 
           swapmin();
        }
    }
    cout << v[j] - 2 << endl;
    return;
}
 
 
 
int main() {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

long long mod = 1000000007;

bool sieve[110];
vector<int> prime;
int pwr[120]; // N in prime factorization form

void prime_factor(int i) {
  for(int j = 0;j < prime.size();j++) {
    while(i % prime[j] == 0) {
      i /= prime[j];
      pwr[prime[j]]++;
    }
  }
}

// 74
int PART1(int N) {
  int ans = 0;
  for(int i = 2;i <= N;i++) if(pwr[i] >= 74) ans++;
  return ans;
}

// 2 24
int PART2(int N) {
  int c1 = 0, c2 = 0;
  for(int i = 2;i <= N;i++) {
    if(pwr[i] < 24 and pwr[i] >= 2) c1++;
    if(pwr[i] >= 24) c2++;
  }

  return c1*c2 + c2*(c2-1);
}

// 4 14
int PART3(int N) {
  int c1 = 0, c2 = 0;
  for(int i = 2;i <= N;i++) {
    if(pwr[i] < 14 and pwr[i] >= 4) c1++;
    if(pwr[i] >= 14) c2++;
  }

  return c1*c2 + c2*(c2-1);
}

// 2 4 4
int PART4(int N) {
  int c1 = 0, c2 = 0;
  for(int i = 2;i <= N;i++) {
    if(pwr[i] < 4 and pwr[i] >= 2) c1++;
    if(pwr[i] >= 4) c2++;
  }

  return c1*(c2-1)*c2/2 + c2*(c2-1)*(c2-2)/2;
}


int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  int N = 0; // N belongs to 1:100
  cin >> N;

  for(int i = 2;i <= N;i++) sieve[i] = true;
  for(int i = 2;i <= N;i++) {
    if(sieve[i]) {
      int j = 2 * i;
      while (j <= N) {
        sieve[j] = false;
        j += i;
      }
    }
  }
  for(int i = 2;i <= N;i++) if(sieve[i]) prime.push_back(i);

  for(int i = 2;i <= N;i++) {
    prime_factor(i);
  }

  cout << PART1(N) + PART2(N) + PART3(N) + PART4(N);

  return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int N, a, min = 0, max = 0;
  vector<int> C(9, 0);
  cin >> N;
  REP(i, N) {
    cin >> a;
    if (a >= 3200) {
      C[8] += 1;
    } else {
      C[a / 400] += 1;
    }
  }
  REP(i, 8) {
    if (C[i] > 0) {
      min++;
      max++;
    }
  }
  max += C[8];
  if (min == 0) {
    min = 1;
  }
  cout << min << " " << max << endl;
}

signed main() {
  solve();

  return 0;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string n;
    int k;
    vector<int> dislike, like;
    cin >> n >> k;
    for(int i = 1; i <= k; ++i) {
        int d;
        cin >> d;
        dislike.push_back(d);
    }
    auto likes = [&dislike] (int x) {
        return !binary_search(begin(dislike), end(dislike), x);
    };
    for(int i = 0; i < 10; ++i) {
        if(likes(i)) like.push_back(i);
    }

    string ans = n;
    bool nomd = false;
    bool got_that = false;
    for(int i = 0; i < ans.size(); ++i) {
        int d = ans[i] - '0';
        if(likes(d)) continue;
        if(got_that) {
            ans[i] = like[0] + '0';
            continue;
        }
        auto change = upper_bound(begin(like), end(like), d);
        if(change == like.end()) {
            nomd = true;
            int ch = like[0];
            if(i == 0 && ch == 0) ch = like[1];
            ans[i] = ch + '0';
        } else {
            int ch = *change;
            ans[i] = ch + '0';
            got_that = true;
        }
    }

    if(nomd == true) {
        ans += like[0] + '0';
        for(int i = 0; i < ans.size(); ++i) {
            int ch = like[0];
            if(like[0] == 0 && i == 0) ch = like[1];
            ans[i] = ch + '0';
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >>d;
	int begin = max(a, c);
	int end = min(b, d);
	int ans = (end - begin >= 0)? end- begin: 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append((a,b))
ab.sort()
for i in range(n):
    if ab[i][1]>=k:
        print(ab[i][0])
        break
    else:
        k = k - ab[i][1]

Measured memory_bytes: 16944
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	P, Q, R := sc.nextInt(), sc.nextInt(), sc.nextInt()
	max := max(P, Q, R)
	fmt.Println(P + Q + R - max)
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
A.sort()
#print(N,A)

num = []
cnt = 1
for i in range(N):
    if i == 0:
        cnt = 1
    else:
        if A[i-1] == A[i]:
            cnt += 1
            if i == N-1:
                num.append([A[i-1],cnt])
        else:
            if cnt > 1:
                num.append([A[i-1],cnt])
                cnt = 1
#print(num)
a = 0
b = 0
if len(num) == 0:
    pass
elif len(num) == 1:
    if num[-1][1] >= 4:
        a = num[-1][0]
        b = a
else:
    if num[-1][1] >= 4:
        a = num[-1][0]
        b = a
    else:
        a = num[-1][0]
        b = num[-2][0]
print(a*b)

Measured memory_bytes: 14672
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll n,a,b,x[100000],sum;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n>>a>>b;
  REP(i,n)cin>>x[i];
  for(ll i=0;i<n-1;i++){
    if((x[i+1]-x[i])*a > b){
      sum+=b;
    }else{
      sum+=(x[i+1]-x[i])*a;
    }
  }
  P(sum);
  return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define br cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pp pair<int,int>
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 100005;
const int INF = 1e9+7;
const ll LINF = 1e18 + 7;

/***************************************************************************/

int main()
{
    ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    int x[n+5]={0},r=0;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        x[a]++;
        x[b+1]--;
    }
    for(int i=1;i<=n;i++)
    {
       x[i]=x[i]+x[i-1];
       if(x[i]==m)
       {
           r++;
       }
    }
    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
const int N=200005;
int dis[N],q[N];
int head[N],tot,n;
struct edge{
	int to,next;
}e[N*2];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
pii bfs(int S){
	For(i,1,n) dis[i]=0;
	int h=0,t=1;
	dis[S]=1; q[1]=S;
	while (h!=t){
		int x=q[++h];
		for (int i=head[x];i;i=e[i].next)
			if (!dis[e[i].to]){
				dis[e[i].to]=dis[x]+1;
				q[++t]=e[i].to;
			}
	}
	return pii(q[t],dis[q[t]]);
}
int main(){
	scanf("%d",&n);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	pii ans=bfs(1);
	ans=bfs(ans.fi);
	puts(ans.se%3==2?"Second":"First");
}

Measured memory_bytes: 5760
use proconio::{input, fastout};

const MOD: usize = 998_244_353;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: usize,
        a: [usize; n],
    }

    let mut dp = vec![vec![0usize; s+1]; n+1];
    dp[0][0] = 1;

    for i in 0..n {
        for j in 0..=s {
            dp[i+1][j] += 2 * dp[i][j];
            dp[i+1][j] %= MOD;
            if j + a[i] <= s {
                dp[i+1][j + a[i]] += dp[i][j];
                dp[i+1][j + a[i]] %= MOD;
            }
        }
    }

    println!("{}", dp[n][s]);
}

Measured memory_bytes: 72452
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<unordered_set<int>> paths(n);
    for(int i=0; i<m; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        paths[a].insert(b);
        paths[b].insert(a);
    }
    int i;
    for(i=1; i<n-1; ++i){
        if(paths[i].find(0)==paths[i].end()) continue;
        if(paths[i].find(n-1)==paths[i].end()) continue;
        break;
    }
    cout << (i!=n-1 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 31944