akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
S[++top] = x;
}

int pop(){
top--;
return S[top+1];
}

int main(){
int a, b;
top = 0;
char s[100];

while(scanf("%s", s) != EOF){
if(s[0] == '+'){
a = pop();
b = pop();
push(a + b);
}else if(s[0] == '-'){
b = pop();
a = pop();
push(a - b);
}else if(s[0] == '*'){
a = pop();
b = pop();
push(a * b);
}else{
push(atoi(s));
}
}

printf("%d\n", pop());

return 0;
}


Measured memory_bytes: 2744
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[30][30],dp[3000000];

int main()
{
  cin>>n;
  rep(i,n) rep(j,n) cin>>a[i][j];
  dp[0]=1;
  rep(i,1<<n)
  {
    if(dp[i]==0) continue;
    int num=__builtin_popcount(i);
    rep(j,n)
    {
      if(a[num][j]==0||(i&(1<<j))>0) continue;
      dp[i|(1<<j)]=(dp[i|(1<<j)]+dp[i])%MOD;
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
  return 0;
}

Measured memory_bytes: 18688
#include <cstdio>

const int MOD = 1e9+7;
const int MAXN = 21;

bool solved[1 << MAXN];
int mem[1 << MAXN];
int n;
int a[MAXN][MAXN];


int dp(int mask) {
  int x = __builtin_popcount(mask);
  if (x == n) return 1;

  int &ret = mem[mask];
  if (solved[mask]) return ret;
  solved[mask] = 1;

  for (int i = 0; i < n; ++i) {
    if ((mask >> i) & 1) continue;
    if (a[x][i] == 0) continue;
    ret = (ret + dp(mask | (1 << i))) % MOD;
  }

  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }

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


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

const int INF = 2e9;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector c(n,0);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = INF;
    rep(i,1<<n){
        vector d(m,0);
        int sum = 0;
        rep(j,n){
            if(i >> j & 1){
                sum += c[j];
                rep(s,m) d[s] += a[j][s];
            }
        }
        bool ok = true;
        rep(s,m)if(d[s] < x)ok = false;
        if(ok) ans = min(sum,ans);
    }
    if(ans != INF) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

vector<ll> calc_primes(ll n) {
  vector<ll> primes;
  vector<bool> filtered(n + 1);

  for (ll i = 2; i <= n; i++) {
    filtered[i] = false;
  }

  for (ll i = 2; i <= n; i++) {
    if (!filtered[i]) {
      primes.push_back(i);
      for (ll j = i; j <= n; j += i) {
        filtered[j] = true;
      }
    }
  }

  return primes;
}

set<ll> prime_factors(ll n, vector<ll> &primes) {
  set<ll> ans;
  for (ll p : primes) {
    while (n % p == 0) {
      ans.insert(p);
      n /= p;
    }
  }
  if (n > 1) {
    ans.insert(n);
  }
  return ans;
}

int main() {
  const ll nmax = 1000001;

  ll a, b;
  cin >> a >> b;

  vector<ll> primes = calc_primes(nmax);
  set<ll> ap = prime_factors(a, primes);
  set<ll> bp = prime_factors(b, primes);

  ll cnt = 1;
  for (ll p : ap) {
    if (bp.count(p)) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  long a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a)cout << k;
  else if(a<k && k<=a+b)cout << a;
  else cout << a+(a+b-k); 
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define MOD 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < X; 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){
  COMinit();
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(void){
  int a,b,x,y,z;
  scanf("%d %d",&a,&b);
  x=min(a,b);
  y=max(a,b);
  z=(x+y)/3;
  if(x*2<y||(x+y)%3){
    PRN(0);
    return 0;
  }
  PRL(COM(z,x-z));
  return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N;
VL A;
ll po[40];
map<int, int> amap;

ll mod_pow(ll base, ll index, ll mod) {
    if(index == 0) return 1LL;
    ll res = mod_pow((base * base) % mod, index / 2, mod);
    if(index & 1) (res *= base) %= mod;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    A.resize(N);
    vector<bool> used(N, false);
    VECCIN(A);
    ll AM = 0;
    REP(i, N) {
        AM = max(AM, A[i]);
        amap[A[i]]++;
    }
    REP(i, 40) { po[i] = mod_pow(2, i + 1, LINF); }
    ll cnt = 0;
    sort(All(A));
    REPR(j, N - 1) {
        if(amap[A[j]] == 0) continue;
        amap[A[j]]--;
        ll sum = po[distance(po, upper_bound(po, po + 40, A[j]))];
        ll pr = sum - A[j];
        if(amap[pr]) {
            cnt++;
            amap[pr]--;
        }
    }
    cout << cnt << "\n";
    return 0;
}

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

int main()
{
  	long long n;
  	cin>>n;
	size_t ans=INT_MAX;
  	for(long long i=1ll ; (i*i)<=n ; ++i)
    {
    	if(n%i)
        continue;
    	long long j=n/i;
      	string a=to_string(i),b=to_string(j);
      	ans=min(ans,max(a.length(),b.length()));
    }
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

s = S.dup
100.times { s.gsub!(/\(\)/, '') }
right_count = s.chars.count { |c| c == '(' }
left_count = s.chars.count { |c| c == ')' }
puts('(' * left_count + S + ')' * right_count)

Measured memory_bytes: 1788
/* ITP1_10_A: Distance */

#include <iostream>
#include <iomanip>
#include <cmath>

struct Point { double x, y; };

int main() {
    Point p1, p2;
    std::cin >> p1.x >> p1.y >> p2.x >> p2.y;

    double distance = sqrt( pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2) );
    std::cout
        << std::fixed << std::setprecision(5)
        << distance
        << std::endl;

    return 0;
}

Measured memory_bytes: 1284
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        int a=ni();
        int p=ni();
        p+=a*3;
        out.println(p/2);
    }
}

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

long long n, s, b;
inline long long f(long long b, long long n){
    if(n < b) return n;
    return f(b, n / b) + n % b;
}
int main()
{
    scanf("%lld%lld", &n, &s);
    for(long long b = 2; b * b <= n ; ++b){
        long long sum = f(b, n);
        if(sum == s){
            printf("%lld", b);
            return 0;
        }
    }
    long long d;
    long long m = n - s;
    for(d = 1; d * d <= m ; ++d){
        if(m % d == 0 && f(d + 1, n) == s){
            printf("%lld", d + 1);
            return 0;
        }
    }
    --d;
    for(;d; --d){
        if(m % d == 0 && f(m / d + 1, n) == s){
            printf("%lld", m / d + 1);
            return 0;
        }
    }
    if(n == s) printf("%lld", n + 1);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 256
while True:
  n = input()
  if (n == -1):
    break
  if (n <= 10):
    print 4280 - 1150
  elif (n <= 20):
    print 4280 - (1150 + (n - 10) * 125)
  elif (n <= 30):
    print 4280 - (1150 + 1250 + (n - 20) * 140)
  else:
    print 4280 - (1150 + 1250 + 1400 + (n - 30) * 160)

Measured memory_bytes: 6420
package main

import "fmt"
import "bufio"
import "strconv"
import "os"
import "sort"

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

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

type Book struct {
	id    int
	name  string
	point int
}

func swap(b Book, c Book) (Book, Book) {
	return c, b
}

func main() {
	var N int
	fmt.Scan(&N)

	S := make([]string, N)
	P := make([]int, N)
	M := make([]Book, N)

	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		S[i] = nextString()
		P[i] = nextInt()
		M[i].id = i + 1
		M[i].name = S[i]
		M[i].point = P[i]
	}

	sort.Slice(M, func(i, j int) bool { return M[i].name < M[j].name })

	for j := 0; j < N; j++ {
		for i := 0; i < N-1; i++ {
			if M[i].name == M[i+1].name && M[i].point < M[i+1].point {
				M[i], M[i+1] = swap(M[i], M[i+1])
			}
		}
	}

	for i := 0; i < N; i++ {
		fmt.Println(M[i].id)
	}

}


Measured memory_bytes: 1844
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 998244353
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,a[300005],k,dp[300005],ab[3000005],st,fn,mx,pos,val;
void Update(int,int,int);
void Query(int,int,int);
int32_t main(){
CODE_START;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    st=max(0,a[i]-k);
    fn=min(300000,a[i]+k);
    mx=-1;
    Query(1,1,300001);
    //cout<<mx<<' ';
dp[a[i]]=mx+1;
//cout<<dp[a[i]]<<' ';
//cout<<a[i];
//cout<<endl;
pos=a[i];
val=dp[a[i]];
Update(1,1,300001);
}
//cout<<endl;
int ans=0;
for(int i=1;i<=n;i++)
{
    ans=max(ans,dp[a[i]]);
}
cout<<ans<<endl;
}

void Update(int nod,int left,int right){
    if(left==right){
        ab[nod]=val;
        return;
    }
    int mid=(left+right)/2;
        if(pos<=mid){
            Update(2*nod,left,mid);
        }else Update(2*nod+1,mid+1,right);
        ab[nod]=max(ab[2*nod],ab[2*nod+1]);
}
void Query(int nod,int left,int right){
if(st<=left&&right<=fn){
    if(mx<ab[nod]){
        mx=ab[nod];
    }
    return;
}
int mid=(left+right)/2;
if(st<=mid) Query(2*nod,left,mid);
if(mid<fn) Query(2*nod+1,mid+1,right);
}




Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int mgcd(int a,int m){
    if(m==0) return a;
    return mgcd(m,a%m);
}

int mlcm(int x,int y){
    return x*y/mgcd(x,y);
}

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    sort(A.begin(),A.end());
    int lcm=A[0];
    rep(i,n-1) lcm=mlcm(lcm,A[i+1]);
    double under=0;
    rep(i,n) under+=(double)lcm/A[i];
    cout<<fixed<<setprecision(10)<<lcm/under<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int i;
  for(i=0;i<n;i++) cin >> s[i];
  for(i=0;i<n-1;i++){
    if(s[i].back() != s[i+1].front()){
      cout << "No" << "\n";
      return 0;
    }
  }
  sort(s.begin(),s.end());
  for(i=0;i<n-1;i++) if(s[i]==s[i+1]){
      cout << "No" << "\n";
      return 0;
    }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){if((ll)(a)==inf)cout<<"inf"<<'\n';else if((ll)(a)==-inf)cout<<"-inf"<<'\n';else cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';if((ll)(v[i])==inf)cout<<"inf";else if((ll)(v[i])==-inf)cout<<"-inf";else cout<<(ll)(v[i]);}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi color;
vvi g;
bool is_nibu=true;
void dfs(int i,int c){
    if(!is_nibu)return;
    if(color[i]==c)return;
    if(color[i]!=-1){
        is_nibu=false;
        return;
    }
    color[i]=c;
    for(auto x:g[i])if(color[x]!=1-c)dfs(x,1-c);
}
int main(){
    ll n,m;cin>>n>>m;
    g=vvi(n);
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    color=vi(n,-1);
    dfs(0,0);
    if(is_nibu){
        ll cnt=0;
        rep(i,n)if(color[i])cnt++;
        dame(cnt*(n-cnt)-m);
    }
    out(n*(n-1)/2-m);
}

Measured memory_bytes: 7424
#include<cmath>
#include<cstdio>
#include<vector>

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

using namespace std;

const double INF=1e77;

template<class T>
struct point{
	T x,y;
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
struct segment:vector< point<T> >{
	segment(){}
	segment(const point<T> &a,const point<T> &b){ push_back(a), push_back(b); }
};

template<class T>
T dot(const point<T> &a,const point<T> &b){ return a.x*b.x+a.y*b.y; }

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

enum {CCW=1,CW=-1,ON=0};
template<class T>
int ccw(const point<T> &a,const point<T> &b,const point<T> &c){
	T rdir=cross(b-a,c-a);
	if(rdir>0) return CCW;
	if(rdir<0) return CW;
	return ON;
}

template<class T>
bool intersect(const segment<T> &S1,const segment<T> &S2){
	if(max(S1[0].x,S1[1].x)<min(S2[0].x,S2[1].x)
	|| max(S1[0].y,S1[1].y)<min(S2[0].y,S2[1].y)
	|| max(S2[0].x,S2[1].x)<min(S1[0].x,S1[1].x)
	|| max(S2[0].y,S2[1].y)<min(S1[0].y,S1[1].y)) return false;
	return ccw(S1[0],S1[1],S2[0])*ccw(S1[0],S1[1],S2[1])<=0
		&& ccw(S2[0],S2[1],S1[0])*ccw(S2[0],S2[1],S1[1])<=0;
}

template<class T>
T dist2(const point<T> &a,const point<T> &b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

template<class T>
double dist2(const segment<T> &S,const point<T> &p){
	if(dot(S[1]-S[0],p-S[0])<=0) return dist2(p,S[0]);
	if(dot(S[0]-S[1],p-S[1])<=0) return dist2(p,S[1]);
	return (double)cross(S[1]-S[0],p-S[0])*cross(S[1]-S[0],p-S[0])/dist2(S[0],S[1]);
}

template<class T>
double dist2(const segment<T> &S1,const segment<T> &S2){
	if(intersect(S1,S2)) return 0;
	return min(min(dist2(S1,S2[0]),dist2(S1,S2[1])),
			   min(dist2(S2,S1[0]),dist2(S2,S1[1])));
}

int main(){
	int n; scanf("%d",&n);
	if(n>5100){ puts("0"); return 0; }
	segment<int> S[5100];
	rep(i,n){
		point<int> p[2];
		rep(j,2) scanf("%d%d",&p[j].x,&p[j].y);
		S[i]=segment<int>(p[0],p[1]);
	}

	double ans=INF;
	rep(j,n) rep(i,j) ans=min(ans,dist2(S[i],S[j]));
	printf("%.9f\n",sqrt(ans));

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef vector<int> vi;

int main(){
  int r,n;
  int xl, xr, h;
  int H[50], base = 25;
  while(cin >> r >> n, r){
    memset(H,0,sizeof(H));
    rep(i,n){
      cin >> xl >> xr >> h;
      for(int j=xl;j<xr;j++){
	H[base+j] = max(H[base+j], h);
      }
    }

    int L=0, R=0;
    double ans = 10000;

    rep(i,25){
      if(i>=r)break;;
      double len = i;
      double height = sqrt(r*r-len*len);
      ans = min(ans, H[base-i-1]-height + r);
    }
    rep(i,25){
      if(i>=r)break;
      double len = i;
      double height = sqrt(r*r-len*len);
      ans = min(ans, H[base+i]-height + r);
    }
    cout << fixed << setprecision(4) << ans << endl;
  } 
}

Measured memory_bytes: 1236
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 1e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].fe << " " << v[i].se << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void PP(int n) { cout << n << " ";}
inline void PP(int n, int m) { cout << n << " " << m << endl;}
inline void PP(int n, int m, int q) {  cout << n << " " << m << " " << q << endl;}
inline void PP(int n, int m, int q, int u) {  cout << n << " " << m << " " << q << " " << u << endl;}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================


signed  main() {
    //op();
    lets_go
    int i, j, x, y, u, l;
    //int t; cin >> t; while (t--)
    {
        i = j = x = y = u = l = 0;


        int n;
        cin >> n;
        map<int, int> m;
        for ( i = 0; i < n; i++) {
            cin >> x;
            y += x;
            m[x]++;
        }
        cin >> x;
        while (x--) {
            cin >> u >> l;
            j = m[u];// PP(u,l,j);
            y += j * (l - u);
            m[l] += j;
            m[u] = 0;
            PT(y);
        }



        /* */

    }
    return 0;

}


Measured memory_bytes: 9496
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 998244353
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline int fastpow(int bas, int ex){
	register int res = 1;
	for(; ex; ex >>= 1, bas = bas * (ll)bas % MOD) if(ex & 1) res = res * (ll)bas % MOD;
	return res;
}

inline int kazu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}
inline int hiku(int a, const int &b) {return (a -= b) < 0 ? a + MOD : a;}

int N, sum = 0, f[90005], g[90005];

int main(){
	getint(N), f[0] = g[0] = 1; 
	for(register int i = 1, a; i <= N; i++){
		getint(a), sum += a;
		for(register int j = sum; j >= 0; j--){
			f[j] = f[j] * 2LL % MOD;
			if(j >= a) f[j] = kazu(f[j], f[j - a]), g[j] = kazu(g[j], g[j - a]);
		}
	}
	int ans = fastpow(3, N);
	for(register int i = sum + 1 >> 1; i <= sum; i++) ans = hiku(ans, f[i] * 3LL % MOD);
	if(!(sum & 1)) ans = kazu(ans, g[sum >> 1] * 3LL % MOD);
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 896
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    Z = []
    W = []
    for i in range(1, N + 1):
        x, y = i_map()
        Z.append(x + y)
        W.append(x - y)
    Z.sort()
    W.sort()
    ans = max([Z[-1] - Z[0], W[-1] - W[0]])
    print(ans)

if __name__ == "__main__":
    main()


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	map<char,int> M;
	REP(i,N){
		string s=in<string>();
		switch(s[0]){
		case 'M':
		case 'A':
		case 'R':
		case 'C':
		case 'H':
			M[s[0]]++;
			break;
		default:break;
		}
	}
	ll num = 0;
	vector<ll> P(5,0);
	P[0] = M['M'];
	P[1] = M['A'];
	P[2] = M['R'];
	P[3] = M['C'];
	P[4] = M['H'];
	for(int a=0;a<5;a++){
		for(int b=a+1;b<5;b++){
			for(int c=b+1;c<5;c++){
				ll snum = P[a]*P[b]*P[c];
				num += snum;
			}
		}
	}
	out(num);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = a/100;
        int c = a%100;
        if(b*5>=c){
            System.out.println(1);
        }else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 23116
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

void solve(){
    string s;
    cin >> s;
    map<int, int> m;
    int rem = 0, mult = 1, res = 0;
    m[0] = 1;
    for(int i = (int)s.size() - 1; i >= 0; i--){
        rem = rem + (s[i] - '0') * mult;
        rem %= 2019;
        mult = (mult * 10) % 2019;
        res += m[rem];
        m[rem]++;
    }
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3736
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);

  int i,h,count = 0;
  for(i = 0; i<n; i++) {
    scanf("%d", &h);
    if (h >= k) count++;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

struct Node {
  int id;
  // int deep = 0;
  Node *parent = NULL;
  Node *children = NULL;
  Node *right = NULL;
} *map[100001];
int children[100001];

int main () {
  int n, m, id;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> id >> m;

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

    Node *node = map[id];

    if (node == NULL) {
      node = (Node *)malloc(sizeof(Node));
      node->id = id;
      // node->deep = 0;
      map[node->id] = node;
    }
    
    if (m > 0) {
      Node *child;

      if (map[children[0]] == NULL) {
        child = (Node *)malloc(sizeof(Node));

        child->id = children[0];
        // child->deep = node->deep + 1;
        child->parent = node;
        map[child->id] = child;
      } else {
        // map[children[0]]->deep = node->deep + 1;
        map[children[0]]->parent = node;
        child = map[children[0]];
      }

      node->children = child;

      for (int j = 1; j < m; j++) {
        Node *_child;

        if (map[children[j]] == NULL) {
          _child = (Node *)malloc(sizeof(Node));
          _child->id = children[j];
          // _child->deep = node->deep + 1;
          _child->parent = node;
          child->right = _child;
          child = _child;
          map[child->id] = child;
        } else {
          // map[children[j]]->deep = node->deep + 1;
          map[children[j]]->parent = node;
          child->right = map[children[j]];
          child = map[children[j]];
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    int deep = 0;
    Node *parent = map[i]->parent;

    printf("node %d: ", map[i]->id);
    printf("parent = %d, ", map[i]->parent != NULL ? map[i]->parent->id : -1);
    // printf("depth = %d, ", map[i]->deep);

    while (parent != NULL) {
      deep++;
      parent = parent->parent;
    }

    printf("depth = %d, ", deep);

    if (map[i]->parent == NULL)
      printf("root, ");
    else if (map[i]->children == NULL)
      printf("leaf, ");
    else
      printf("internal node, ");
    
    printf("[");

    if (map[i]->children != NULL) {
      Node *child = map[i]->children;

      while (true) {
        printf("%d", child->id);

        child = child->right;

        if (child == NULL)
          break;
        else
          printf(", ");
      }
    }

    printf("]\n");
  }

  return 0;
}


Measured memory_bytes: 9004
def binary_search(S, key):
    left = 0
    right = len(S)
    while left < right:
        mid = int((left + right) / 2)
        # ???????????£????????????????????? return
        if S[mid] == key:
            return 'Found'
        # ??????????????????????°????????????°??????????????????????????????????????´??°
        elif S[mid] > key:
            right = mid
        # ???????????????????????§???????????°???????????? + 1 ?????????????????§??????????????´??°
        elif S[mid] < key:
            left = mid + 1
    return False

if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    cnt = 0
    for key in T:
        if binary_search(S, key):
            cnt += 1

    print(cnt)

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

int main() {
  vector<int> x(3001), y(3001);
  int idx = 0;
  while(true) {
    cin >> x.at(idx) >> y.at(idx);
    if (x.at(idx) == 0 && y.at(idx) == 0) break;
    idx++;
  }
  idx = 0;
  while(!(x.at(idx) == 0 && y.at(idx) == 0)) {
    if (x.at(idx) <= y.at(idx)) cout << x.at(idx) << " " << y.at(idx) << endl;
    else cout << y.at(idx) << " " << x.at(idx) << endl;
    idx++;
  }
}


Measured memory_bytes: 3028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int a = Integer.parseInt(sa[1]);
		int b = Integer.parseInt(sa[2]);
		int c = Integer.parseInt(sa[3]);
		String[] s = new String[n + 5];
		for (int i = 0; i < n; i++) {
			s[i] = br.readLine();
		}
		br.close();

		List<String> list = new ArrayList<>(n);
		label:
		for (int i = 0; i < n; i++) {
			if (a < 0 || b < 0 || c < 0) {
				System.out.println("No");
				return;
			}
			if ("AB".equals(s[i])) {
				if (a > b) {
					list.add("B");
					a--;
					b++;
				} else if (a < b) {
					list.add("A");
					a++;
					b--;
				} else {
					for (int j = i + 1; j < i + 3; j++) {
						if ("AC".equals(s[j])) {
							list.add("A");
							a++;
							b--;
							continue label;
						}
						if ("BC".equals(s[j])) {
							list.add("B");
							a--;
							b++;
							continue label;
						}
					}
					list.add("B");
					a--;
					b++;
				}
			} else if ("AC".equals(s[i])) {
				if (a > c) {
					list.add("C");
					a--;
					c++;
				} else if (a < c) {
					list.add("A");
					a++;
					c--;
				} else {
					for (int j = i + 1; j < i + 3; j++) {
						if ("AB".equals(s[j])) {
							list.add("A");
							a++;
							c--;
							continue label;
						}
						if ("BC".equals(s[j])) {
							list.add("C");
							a--;
							c++;
							continue label;
						}
					}
					list.add("C");
					a--;
					c++;
				}
			} else {
				if (b > c) {
					list.add("C");
					b--;
					c++;
				} else if (b < c) {
					list.add("B");
					b++;
					c--;
				} else {
					for (int j = i + 1; j < i + 3; j++) {
						if ("AB".equals(s[j])) {
							list.add("B");
							b++;
							c--;
							continue label;
						}
						if ("AC".equals(s[j])) {
							list.add("C");
							b--;
							c++;
							continue label;
						}
					}
					list.add("C");
					b--;
					c++;
				}
			}
		}
		if (a < 0 || b < 0 || c < 0) {
			System.out.println("No");
			return;
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println("Yes");
		for (String str : list) {
			pw.println(str);
		}
		pw.flush();
	}
}


Measured memory_bytes: 43700
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    int a,b,c,max;
    cin>>a>>b>>c;
    if(a>=b){max=a;}else{max=b;}
    if(c>max){max=c;}
    int ans=a+b+c-max;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        private ArrayList<Double> ar;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ar = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                ar.add((double) in.nextInt());
            }
            ArrayList<Double> temp = new ArrayList<>(ar);
            double ans1 = f1();
            ar = new ArrayList<>(temp);
            double ans2 = f2();
            double ans = Math.max(ans1, ans2);
            out.println(ans);
        }

        private double f1() {
            while (ar.size() > 1) {
                sortD();
                double next = (ar.get(0) + ar.get(1)) / 2.0;
                ar.remove(0);
                ar.remove(0);
                ar.add(next);
            }
            return ar.get(0);
        }

        private double f2() {
            while (ar.size() > 1) {
                sortU();
                double next = (ar.get(0) + ar.get(1)) / 2.0;
                ar.remove(0);
                ar.remove(0);
                ar.add(next);
            }
            return ar.get(0);
        }

        private void sortU() {
            Collections.sort(ar);
        }

        private void sortD() {
            Collections.sort(ar, (o1, o2) -> {
                if (o1 < o2)
                    return -1;
                if (o1 > o2)
                    return 1;
                return 0;
            });
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(in) in.begin(),in.end()
using ll = long long;
using namespace std;

vector<ll> compress(vector<ll> &vals) {
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    return vals;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<ll> x, y;
    vector<ll> a(n), b(n), c(n), d(m), e(m), f(m);

    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
        x.push_back(a[i]);
        x.push_back(b[i]);
        y.push_back(c[i]);
    }
    rep(i,m){
        cin >> d[i] >> e[i] >> f[i];
        x.push_back(d[i]);
        y.push_back(e[i]);
        y.push_back(f[i]);
    }
    x.push_back(1001001001ll);
    x.push_back(-1001001001ll);
    x.push_back(0ll);
    y.push_back(1001001001ll);
    y.push_back(-1001001001ll);
    y.push_back(0ll);
  
    auto xx = compress(x);
    auto yy = compress(y);
    int nx = (int)xx.size() * 2 - 1;
    int ny = (int)yy.size() * 2 - 1;

    vector<vector<pair<ll,ll>>> data(nx,vector<pair<ll,ll>>(ny,make_pair(1ll,0ll)));
    rep(i,(int)xx.size()-1) rep(j,(int)yy.size()-1) {
        data[i*2+1][j*2+1].second = (xx[i+1] - xx[i]) * (yy[j+1] - yy[j]);
    }
    rep(i,n){
        int id = lower_bound(all(yy),c[i]) - yy.begin();
        int from = lower_bound(all(xx),a[i]) - xx.begin();
        int to = lower_bound(all(xx),b[i]) - xx.begin();
        for(int j = from * 2; j <= to * 2; j++) data[j][id*2].first = 0;
    }
    rep(i,m){
        int id = lower_bound(all(xx),d[i]) - xx.begin();
        int from = lower_bound(all(yy),e[i]) - yy.begin();
        int to = lower_bound(all(yy),f[i]) - yy.begin();
        for(int j = from * 2; j <= to * 2; j++) data[id*2][j].first = 0;
    }
    int sx = (lower_bound(all(xx),0ll) - xx.begin()) * 2;
    int sy = (lower_bound(all(yy),0ll) - yy.begin()) * 2;

    queue<pair<int,int>> que;
    que.push(make_pair(sx,sy));
    ll ans = 0;
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        rep(i,4){
            int nnx = p.first + dx[i], nny = p.second + dy[i];
            if(0 <= nnx && nnx < nx && 0 <= nny && nny < ny){
                if(!data[nnx][nny].first) continue;
                if(nnx == 0 || nnx == nx || nny == 0 || nny == ny){
                    cout << "INF" << endl;
                    return 0;
                }
                else{
                    data[nnx][nny].first = 0;
                    ans += data[nnx][nny].second;
                    que.push(make_pair(nnx,nny));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 567088
N = int(input())
ball = []
dif = [[] for i in range(N-1)]
for i in range(N):
    x,y = map(int,input().split())
    ball += [[x,y]]
ball = sorted(ball)

for i in range(N-1):
    for j in range(N-i-1):
        dif[i].append([ball[j+1+i][0] - ball[i][0], ball[j+1+i][1] - ball[i][1]])

ans = 0
for i in range(N-1):
    for j in range(N-i-1):
        base = dif[i][j]
        point = 0
        for k in range(i+1,N-1):
            for l in range(N-k-1):
                if base == dif[k][l]:
                    point += 1
                    break
        if ans < point: ans = point

if N != 1:  print(N-ans-1)
else:   print(1)

Measured memory_bytes: 3188
n = int(input())
h = list(map(int, input().split()))

h.reverse()
ans = 0
temp = 0
for i in range(n-1):
    if h[i+1] >= h[i]:
        temp += 1
    else:
        ans = max(temp, ans)
        temp = 0

ans = max(temp, ans)
print(ans)


Measured memory_bytes: 14252
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

const double pi = 3.141592653589793;
vector<double> x(101), y(101);
int n; 

inline double naiseki(const double& x1, const double& y1, const double& x2, const double& y2) {
  return x1 * x2 + y1 * y2;
}

// 角度 theta の方向を最終的に向くとして計算
// theta は radian
double calc(const double& theta) {
  double res = 0.0;
  double dx = cos(theta), dy = sin(theta);
  for (int i = 0; i < n; ++i) {
    res += max(0.0, naiseki(dx, dy, x[i], y[i]));
  }
  return res;
}

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

  auto start = chrono::system_clock::now();

  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];

  int step = 7777777;

  double ans = 0.0;

  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> r(0, step);

  auto msec = 0.0;

  do {
    double theta = 2.0 * pi * r(mt) / step;
    chmax(ans, calc(theta));
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  } while (msec <= 1998);

  cout << setprecision(15) << ans << '\n';

  return 0;
}


Measured memory_bytes: 384
n=int(input())
s=input()
if s[0]=="W":
    exit(print(0))
t=[1]
for i in range(1,2*n):
    if s[i]==s[i-1]:
        t.append(-t[-1])
    else:
        t.append(t[-1])
now=1
for i in range(1,2*n):
    now+=t[i]
    if now<0:
        exit(print(0))
if now!=0:
    exit(print(0))
#左は確実に余ってるので右がきたら組み合わせる方向性で
ans=1
mod=10**9+7
ca=0
for i in range(2*n):
    if t[i]==1:
        ca+=1
    else:
        ans*=ca
        ans%=mod
        ca-=1
#この時点のansは組み合わせの数のみその順番を考慮していない
for i in range(1,n+1):
    ans*=i
    ans%=mod
print(ans)

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

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

    constexpr int64_t BIT_SIZE = 32;
    vector<bitset<BIT_SIZE>> A(N);
    for (bitset<BIT_SIZE>& a : A) {
        int64_t b;
        cin >> b;
        a = b;
    }


    //ひと桁ずつ決めていく
    vector<bitset<BIT_SIZE>> ans(N);
    for (int64_t i = 0; i < BIT_SIZE; i++) {
        int64_t one_num = 0;
        for (int64_t j = 0; j < N; j++) {
            if (A[j][i]) {
                one_num++;
            }
        }

        if (one_num % 2 == 0) {
            //そのまま
            for (int64_t j = 0; j < N; j++) {
                ans[j][i] = A[j][i];
            }
        } else {
            for (int64_t j = 0; j < N; j++) {
                ans[j][i] = ~A[j][i];
            }
        }
    }

    for (int64_t i = 0; i < N; i++) {
        cout << ans[i].to_ullong() << " \n"[i == N - 1];
    }
}

Measured memory_bytes: 6424
import sys
sys.setrecursionlimit(10**6)

n = int(input())
ed = [tuple(map(int, input().split())) for _ in range(n-1)]
g = [list() for _ in range(n)]
for a,b in ed:
  g[a-1].append(b-1)
  g[b-1].append(a-1)
bi = [0]*n

def dfs(v, p):
  for x in g[v]:
    if x == p: continue
    bi[x] = 1 - bi[v]
    dfs(x, v)
  return


dfs(0,-1)
one = sum(bi)
two = n - one
if one < two:
  one, two = two, one
  bi = [1-x for x in bi]
# print(bi)
on = 1
tw = 2
th = 3
ans = [0]*n
if two <= n//3:
  for i in range(n):
    if bi[i]:
      if on > n and tw > n:
        ans[i] = th
        th += 3
      elif on > n:
        ans[i] = tw
        tw += 3
      else:
        ans[i] = on
        on += 3
    else:
      ans[i] = th
      th += 3
  print(*ans)
  exit(0)

for i in range(n):
  if bi[i]:
    if on > n:
      ans[i] = th
      th += 3
    else:
      ans[i] = on
      on += 3
  else:
    if tw > n:
      ans[i] = th
      th += 3
    else:
      ans[i] = tw
      tw += 3
print(*ans) 

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

def judge():
    if a==5:
        if b==5:
            if c==7:
                return print("YES")
            else:
                return print("NO")
        elif b==7:
            if c==5:
                return print("YES")
            else:
                return print("NO")

    elif a==7:
        if b==5:
            if c==5:
                return print("YES")
            else:
                return print("NO")
        else:
            return print("NO")


    else:
        return print("NO")

judge()


Measured memory_bytes: 3060
X,Y,Z,K=map(int,input().split())
     
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
     
r=[]
out=[]
     
for i in range(X):
    for j in range(Y):
        r.append(A[i]+B[j])
     
r.sort(reverse=True)
     
if len(r)>K:
    for i in range(K):
        for j in range(Z):
            out.append(r[i]+C[j])
else:
    for i in range(len(r)):
        for j in range(Z):
           out.append(r[i]+C[j])
     
out.sort(reverse=True)
     
for i in range(K):
    print(out[i])

Measured memory_bytes: 151088
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

lst1 = ["o"]*15
s = readline().rstrip().decode('utf-8')
for i in range(len(s)):
    lst1[i] = s[i]

if lst1.count("o") >= 8:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38256
N,M=gets.split.map &:to_i
sum = Array.new(N+2){0}
M.times do
  l, r = gets.split.map &:to_i
  sum[l] += 1
  sum[r+1] -= 1
end
1.upto(N) do |i|
  sum[i+1] += sum[i]
end
p sum.count(M)

Measured memory_bytes: 2556
# cook your dish here
s = input()
a=[0,0,0,0]
b=[1,1,1,1]
for i in range(4):
    for j in range(4):
        if(s[i]==s[j] and i != j):
            a[i]+=1 
if(a==b):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060