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

int main(){
double x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
double d;
d=sqrt(x1*x1+y1*y1+x2*x2+y2*y2-2*x1*x2-2*y1*y2);
cout << fixed << setprecision(10);
cout<<d<<endl;
}


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

typedef long long ll;

#define MAXN 400*1000 + 5
const ll mod = 1000*1000*1000 + 7;

ll fact[MAXN];

ll mul(ll a, ll b) { return a*b % mod; }

ll mpow(ll a, int n) {
	if(n == 0) return 1;
	ll x = mpow(a, n/2);
	x = mul(x, x);
	if(n % 2 == 1) x = mul(x, a);
	return x;
}

ll bin(ll n, ll k) {
	return mul(fact[n], mul(mpow(fact[n-k], mod-2), mpow(fact[k], mod-2)));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//$ https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29
	
	fact[0] = 1;
	for(int i = 1; i < MAXN; i++) fact[i] = mul(i, fact[i-1]);
	int n, k;
	cin >> n >> k;
	
	ll ans = 0;
	
	auto add_self = [&](ll& a, ll b) {
		a += b;
		if(a >= mod) a -= mod;
	};
	
	for(int empty = 0; empty < min(k+1, n); empty++) {
		add_self(ans, mul(bin(n, empty), bin(n-1, n-empty-1)));
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 3328
//==========================================================================
//
//                   Bismillahir-Rahmanir-Rahim
//
// ==========================================================================
#include <bits/stdc++.h>
#define        ll                              long long int
#define        FOR(x,y,z)                      for(int x=y;x<z;x++)
#define        pii                             pair<int,int>
#define        pll                             pair<ll,ll>
#define        CLR(a)                          memset(a,0,sizeof(a))
#define        SET(a)                          memset(a,-1,sizeof(a))
#define        N                               100010
#define        M                               1000000007
#define        pi                              acos(-1.0)
#define        ff                              first
#define        ss                              second
#define        pb                              push_back
#define        inf                             (int)1e9
#define        eps                             1e-9
#define        debug(x)                        cerr << #x << " is " << x << endl;
#define        ALL(x)                          x.begin(),x.end()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
template < class T> inline T biton(T n,T pos){return n |((T)1<<pos);}
template < class T> inline T bitoff(T n,T pos){return n & ~((T)1<<pos);}
template < class T> inline T ison(T n,T pos){return (bool)(n & ((T)1<<pos));}
template < class T> inline T gcd(T a, T b){while(b){a%=b;swap(a,b);}return a;}
template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); }
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
inline ll lxt(){ll aaa;scanf("%lld",&aaa);return aaa;}
inline double dxt(){double aaa;scanf("%lf",&aaa);return aaa;}
template <class T> inline T bigmod(T p,T e,T m){T ret = 1;
for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % m;p = (p * p) % m;
} return (T)ret;}
///******************************************START******************************************

int main(){
     //freopen("out.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
   //cin.tie(0);
  ll n=lxt();
  ll ans=n/11;
  ans*=2;
   ll temp=n%11;
   if(temp){
      if(temp<=6) ans++;
      else ans+=2;

   }
   cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k;
string str;
deque<int> deq;
void convert()
{
    for(int i=0;i<n;i++) if(str[i]=='A') deq.push_back(0); else deq.push_back(1);
}
void go()
{
    if(!deq[0]) {deq[0]=1; k--; return;}
    deq.pop_front();
    for(int i=0;i<(int)deq.size();i++) deq[i]^=1;
    deq.push_back(0); k--;
}
void go2()
{
    int cnt=0;
    if(deq[0]==1&&deq[1]==0) cnt=2;
    if(deq[0]==0&&deq[1]==0) cnt=3;
    if(deq[0]==0&&deq[1]==1) cnt=4;
    if(deq[0]==1&&deq[1]==1) cnt=3;
    deq.pop_front(); deq.pop_front();
    deq.push_back(1); deq.push_back(0); k-=cnt;
}
void print()
{
    for(int i=0;i<n;i++) printf("%c",deq[i]?'B':'A');
}
int main()
{
    scanf("%d%d",&n,&k);
    cin>>str;
    if(n==1)
    {
        if(k&1) str[0]=(str[0]='A'?'B':'A'); 
        cout<<str<<endl; return 0;
    }
    convert(); 
    for(int i=1;i<=n;i++)
    {
        if(k<=4)
        {
            while(k) go();
            break;
        }
        else go2();
    }
    k%=4; while(k) go();
    print();
    return 0;
}



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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1;

int main()
{
    string s;
    cin>>s;
    int lst='.';
    int cnt=0;
    if(s == "RRR"){
        cout<<3;
        return 0;
    }
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            if(lst == 'R')
             cnt=2;
             else
                cnt=1;
        }
    lst=s[i];
    }
    cout<<cnt;

}


Measured memory_bytes: 3600
#include <cstdio>
#include <map>
#include <cstring>
using namespace std;

const int MAX_Q = 400000;

int ids[MAX_Q];

struct BinaryIndexedTree{

	typedef int bit_t;

	static const int MAX_BIT = MAX_Q;
	bit_t data[MAX_BIT+1];
	int SIZE;

	void init(int size){
		memset(data, 0, sizeof(data));
		SIZE = size;
	}

	bit_t sum(int n){
		bit_t ret = 0;
		for(n++;n;n-=n&-n){
			ret += data[n];
		}
		return ret;
	}

	bit_t sum(int from, int to){
		return sum(to)-sum(from);
	}

	void add(int n, bit_t x){
		for(n++;n<=SIZE;n+=n&-n){
			data[n]+=x;
		}
	}

	int search(int s){
		int p = p=(1<<(31-__builtin_clz(SIZE)));
		for(int q=p; q>0; q>>=1, p|=q){
			if(p >= SIZE + 1 || s < data[p]){
				p ^= q;
			}
			else{
				s -= data[p];
			}
		}
		return p;
	}
};

BinaryIndexedTree bitree;

int LIM, Q;

bool init(){
	scanf("%d%d", &Q, &LIM);
	return Q > 0;
}

void proc(){
	map<int, int> id_to_idx;
	int counter = 0;
	bitree.init(Q);
	for(int i=0; i<Q; i++){
		int cmd, x;
		scanf("%d%d", &cmd, &x);
		if(cmd == 0){
			id_to_idx[x] = counter;
			ids[counter] = x;
			bitree.add(counter++, 1);
			if(bitree.sum(counter) > LIM){
				bitree.add(bitree.search(0), -1);
			}
		}
		else if(cmd == 1){
			bitree.add(bitree.search(x-1), -1);
		}
		else if(cmd == 2){
			printf("%d\n", ids[bitree.search(x-1)]);
		}
		else if(cmd == 3){
			bitree.add(id_to_idx[x], -1);
		}
	}

	puts("end");
}

int main(){
	while(init()){
		proc();
	}

	return 0;
}

Measured memory_bytes: 16000
a,b=map(int,input().split())
s,t="Alice","Bob"
if a==1 and b!=1:
  print(s)
elif a!=1 and b==1:
  print(t)
elif a>b:
  print(s)
elif a<b:
  print(t)
else:
  print("Draw")
  
  
  

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

int main(){
  ll a,b,c;
  cin >>a >>b >>c;
  int cnt = 0;
  bool can = true;
  while(true){
    if(a%2==0 && b%2==0 && c%2==0){
      cnt++;
      ll A=a, B=b, C=c;
      a = (B+C)/2;
      b = (A+C)/2;
      c = (B+A)/2;
    }
    if(a%2!=0 || b%2!=0 || c%2!=0){
      break;
    }
    if(a==b && b==c){
      can = false;
      break;
    }
  }
  if(!can) cout << -1 << endl;
  else cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = ll;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

int digit(Int a){
    int res = 1;
    while(a / 10 != 0){
        a /= 10;
        res++;
    }
    return res;
}

int f(Int a, Int b){
    return digit(max(a, b));
}

Int solve(Int n){
    int res = 11;
    for(Int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res = min(res, f(i, n / i));
        }
    }
    return res;
}


int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    Int n;
    cin >> n;
    cout << solve(n) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

int a, b;

int main() { 

  cin >> a >> b;

  for (int i = 1; i <= 3; i++) {
    if (i != a && i != b) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
#define vll			vector<ll>
#define sll			set<ll>
const ll inf = 1000000000000000;
ll in = 1000000000000000000;
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

int main()
{
	FastIO;
	ll t, a, i, j, k, q, c, d, b, r,n;
	cin >> n;
	vll v, u, w;
	map<ll, ll>m, ma;
	f(i, n)
	{
		cin >> a;
		v.pb(a-1);
	}
	f(i, n)
	{
		cin >> a;
		m[i] = a;
	}
	f(i, n - 1)
	{
		cin >> a;
		ma[i] = a;
	}
	ll sum = 0;
	f(i, n)
	{
		sum = sum + m[v[i]];
		if (i && v[i-1]+1==v[i])
		{
			sum += ma[v[i - 1]];
		}
	}
	cout << sum << endl;
	return 0;
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T& y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T& y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;



signed main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> l(m), r(m);
    vector<int> v(n, 0);
    iota(v.begin(), v.end(), 1);
    for(int i = 0; i < m; ++i){
        cin >> l[i] >> r[i];
        chmax(v[--l[i]], r[i]);
    }
    for(int i = 0; i < n - 1; ++i)
        chmax(v[i + 1], v[i]);

    vector<int> cnt(n + 1, 0);
    for(int i = 0; i < n; ++i)
        cnt[i + 1] = cnt[i] + (s[i] == '1');

    vector<vector<mint>> dp(n + 1, vector<mint>(n + 1, 0));
    dp[0][0] = 1;

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            int one = cnt[v[i]] - j;
            int zero = (v[i] - cnt[v[i]]) - (i - j);
            if(one > 0)
                dp[i + 1][j + 1] += dp[i][j];
            if(zero > 0)
                dp[i + 1][j] += dp[i][j];
        }
    }
    cout << dp.back()[cnt.back()] << endl;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <vector>
#include <algorithm>

int main(){
    int n;
    std::scanf("%d", &n);
    std::vector<int> a(n, 0);
    std::vector<int> b(n, 0);
    std::unordered_map<int, int> hash;
    for(int i = 0; i < n; ++i){
        std::scanf("%d", &a[i]);
        b[i] = a[i];
        hash.insert(std::make_pair(a[i], i));
    }
    std::sort(b.begin(), b.end());

    int totalCost = 0;
    int i = 0;
    int s = b[0];
    for(int i = 0; i < n; ++i){
        if(a[i] == b[i]) continue;
        int sum = 0;
        int op = 0;
        while(1){
            ++op;
            std::pair<int, int> minp;
            minp.first = hash.find(b[i])->second;
            minp.second = hash.find(b[minp.first])->second;
            sum += a[minp.second];
            std::swap(a[minp.first], a[minp.second]);
            hash.find(b[i])->second = minp.second;
            hash.find(b[minp.first])->second = minp.first;
            if(a[i] == b[i]) break;
        }
        totalCost += std::min(sum + op * b[i], sum + (op + 2) * s + 2 * b[i]);
    }
    std::printf("%d\n", totalCost);
    return 0;
}


Measured memory_bytes: 2836
N,A=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*2600 for j in range(N+10)] for i in range(N+10)]
dp[0][0][0]=1
for i in range(N):
    for j in range(N+1):
        for k in range(2501):
            if(dp[i][j][k]!=0):
                dp[i+1][j][k]+=dp[i][j][k]
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
print(sum(dp[N][i][i*A] for i in range(1,N+1)))

Measured memory_bytes: 114140
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
#define MAX 100000

struct Node {
    int parent, left, right;
};

int n;
vector<Node> T(MAX);
vector<int> D(MAX);

void setDepth(int u, int p)  {
    D.at(u) = p;
    if (T.at(u).left != NIL) {
        setDepth(T.at(u).left, p + 1);
    }
    if (T.at(u).right != NIL) {
        setDepth(T.at(u).right, p);
    }
}

void setDepth() {
    int u;
    for (int i = 0; i < n; i++) {
        if (T.at(i).parent == -1) {
            u = i;
        }
    }

    setDepth(u, 0);
}

void printChildren(int u) {
    int c = T.at(u).left;
    
    cout << "[";
    while (c != NIL) {
        cout << c;
        c = T.at(c).right;
        if (c != NIL) {
            cout << ", ";
        }
    }
    cout << "]" << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        T.at(i).parent = NIL;
        T.at(i).left = NIL;
        T.at(i).right = NIL;
    }

    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        
        vector<int> c(k);
        for (int j = 0; j < k; j++) {
            cin >> c.at(j);
        }
        for (int j = 0; j < k; j++) {
            T.at(c.at(j)).parent = u;
            if (j != k - 1) {
                T.at(c.at(j)).right = c.at(j + 1);
            }
        }
        
        if (c.size() != 0) {
            T.at(u).left = c.at(0);
        }
    }

    setDepth();

    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": ";
        cout << "parent = " << T.at(i).parent << ", ";
        cout << "depth = " << D.at(i) << ", ";
        if (T.at(i).parent == NIL) {
            cout << "root, ";
        } else if (T.at(i).left == NIL) {
            cout << "leaf, ";
        } else {
            cout << "internal node, ";
        }
        printChildren(i);
    }
}


Measured memory_bytes: 4620
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

const double PI=(acos(-1));

int main(){
    char b;
    cin>>b;
    char ans;
    switch(b){
        case 'A':
            ans='T';
            break;
        case 'C':
            ans='G';
            break;
        case 'G':
            ans='C';
            break;
        case 'T':
            ans='A';
            break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int east[n], west[n];
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            east[i] = 1;
            west[i] = 0;
        } else {
            east[i] = 0;
            west[i] = 1;
        }
    }
    for (int i = 1; i < n; i++) {
        east[i] += east[i-1];
        west[i] += west[i-1];
    }
    int ans = (1 << 30);
    for (int i = 0; i < n; i++) {
        int sum = 0;
        if (i > 0) sum = west[i-1];
        sum += east[n-1] - east[i];
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

const int MAX_N = 105;

int slimes[MAX_N];

int main() {
	
	int N, spells = 0; 
	scanf("%d", &N);

	for(int i = 0; i < N; ++i) {
		scanf("%d", &slimes[i+1]);
	}

	for(int i = 1; i < N; ++i) {
		//adjacent equal slimes
		if(slimes[i] == slimes[i+1]) {
			if(slimes[i+2] != 1 && slimes[i] != 1) {
				slimes[i+1] = 1;
			} else if(slimes[i+2] != 2 && slimes[i] != 2) {
				slimes[i+1] = 2;
			} else if(slimes[i+2] != 3 && slimes[i] != 3) {
				slimes[i+1] = 3;
			}

			spells++;
		}
	}

	cout << spells << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    int soma, sub, mul;
    soma = a+b;
    sub = a-b;
    mul = a*b;
    
    if(soma>=sub && soma>=mul)
        printf("%d", soma);
    else if (sub>=soma && sub>=mul) 
        printf("%d", sub);
    else 
        printf("%d", mul);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<deque>
#include<vector>
#include<map>
#include<iterator>
#include<utility>
#include<algorithm>
#include<bitset>
#include<set>
 
 
 
 
using namespace std;
 
typedef long long ll;
 
int main() {
 
	int n; cin >> n;
	vector<ll>camels(n);
	set<ll>xo;
	for (int i = 0; i < n; i++) {
		ll j; cin >> j;
		camels[i] = j;
		xo.insert(j);
	}
	bool b = true;
 
	sort(camels.begin(), camels.end());
	if (n % 3 == 0) {
 
		if((camels[0]!=camels[n/3-1])||(camels[n/3]!=camels[2*n/3-1])||(camels[2*n/3]!=camels[n-1])){
			b=false;
		}
 
 
 
 
		if (xo.size() == 1) {
			if (camels[0] == 0) {
				cout << "Yes";
			}
			else{
				cout<<"No";
			}
		}
		else if (xo.size() == 2 && b) {
			ll num = 0;
			for (int i = 0; i < camels.size(); i++) {
				if (camels[i] == 0) {
					num++;
				}
			}
			if (num == n / 3) {
				cout << "Yes";
			}
			else {
				cout << "No";
			}
		}
		else if (xo.size() == 3 &&b) {
			
			vector<string>binary(3);
			ll maxlen = 0; int index=0;
			for (auto itr = xo.begin() ; itr!=xo.end() ; itr++) {
				string bin = bitset<64>(*itr).to_string();
				binary[index] = bin;
				index++;
				ll binsize = 0;
				for (ll j = 0; j < 64; j++) {
					if (bin[j] == '1') {
						binsize = 64 - j;
						break;
					}
				}
				if (binsize >= maxlen) {
					maxlen = binsize;
				}
			}
 
			vector<int>counting(64, 0);
			for (int i = 0; i < 3; i++) {
				for (int j = 63; j >= 64 - maxlen; j--) {
					if (binary[i][j] == '1') {
						counting[j]++;
					}
				}
			}
			bool ans = true;
			for (int i = 63; i >= 64 - maxlen; i--) {
				
				if (counting[i] != 2 && counting [i]!=0) {
					ans = false;
				}
 
			}
 
			if (ans) {
				cout << "Yes";
			}
			else {
				cout << "No";
			}
		}
		else {
			cout << "No";
		}
	}
 
	else {
		if (xo.size() == 1) {
			if (camels[0] == 0) {
				cout << "Yes";
			}
		}
		else {
			cout << "No";
		}
	}
	int l ; cin>>l;
	
}

Measured memory_bytes: 4480
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

constexpr ll INF = 1e9;
constexpr ll MOD = 2019;

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll l, r;
    std::cin >> l >> r;

    ll ans = INF;
    for (ll i = l; i <= std::min(l + MOD, r); i++)
        for (ll j = r; j >= std::max(r - MOD, l); j--)
            if (i < j) chmin(i * j % MOD, ans);

    std::cout << ans << '\n';
}


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

def find_parent(x):
    y=parent[x]
    if y<0:
        return x
    parent[x]=find_parent(y)
    return parent[x]

def connect(a,b):
    c=find_parent(a)
    d=find_parent(b)
    if c==d:
        return
    if parent[c]<parent[d]:
        parent[c]+=parent[d]
        parent[d]=c
    else:
        parent[d]+=parent[c]
        parent[c]=d
    return

N=int(input())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append([x,i])
    Y.append([y,i])

X.sort()
Y.sort()
edge=[]
for i in range(1,N):
    edge.append([X[i][0]-X[i-1][0],X[i-1][1],X[i][1]])
    edge.append([Y[i][0]-Y[i-1][0],Y[i-1][1],Y[i][1]])
edge.sort()
parent=[-1]*N

ans=0
for l,a,b in edge:
    if find_parent(a)==find_parent(b):
        continue
    else:
        ans+=l
        connect(a,b)

print(ans)

Measured memory_bytes: 122204
N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i
BC = Q.times.map{ gets.split.map(&:to_i) }
sum = A.sum

h = A.each_with_object(Hash.new(0)){|i,h| h[i] += 1}
BC.each do |b,c|
  sum += (c-b) * h[b]
  h[c] += h[b]
  h[b] = 0
  puts sum
end

Measured memory_bytes: 27956
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll N;
    in(N);
    vector<ll> A(N);
    rep(i, N) in(A[i]);
    map<ll, ll> zeroPos;
    ll ans = 0;
    rep(i, N) {
        ll target = -A[i] + i + 1;
        ans += zeroPos[target];
        ll nextZero = i + 1 + A[i];
        zeroPos[nextZero]++;
    }
    out(ans);

	return 0;
}


Measured memory_bytes: 27452
from collections import deque
white, black = '.', '#'
H, W = map(int, input().split())
S = [[j for j in input()] for i in range(H)]
mvv, mvh = [0, 0, -1, 1], [-1, 1, 0, 0]
q = deque([(0, 0)])
S[0][0] = 0
while q:
  y, x = q.popleft()
  for i in range(4):
    if 0 <= y + mvv[i] <= H-1 and S[y + mvv[i]][x] == white:
      S[y + mvv[i]][x] = S[y][x] + 1
      q.append((y + mvv[i], x))
    if 0 <= x + mvh[i] <= W-1 and S[y][x + mvh[i]] == white:
      S[y][x + mvh[i]] = S[y][x] + 1
      q.append((y, x + mvh[i]))
if S[H-1][W-1] == white:
  print(-1)
else:
  r = 0
  c = set()
  for y in range(H):
    for x in range(W):
      if S[y][x] == black:
        continue
      if S[y][x] == white or S[y][x] in c or S[y][x] > S[H-1][W-1]:
        r += 1
      else:
        c.add(S[y][x])
  print(r)

Measured memory_bytes: 41968
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll q;
    cin >> q;
    ll aaa=0;
    for(ll i=0;i<q;i++){
        ll t;
        cin >> t;
        if(t==1){
            aaa++;
        }
        if(t==2){
            ll f;
            cin >> f;
            if((f+aaa)%2==1){
                string ss;
                cin >> ss;
                s.insert(0,ss);
            }
            if((f+aaa)%2==0){
                char ss;
                cin >> ss;
                s.push_back(ss);
            }
        }
    }
    
    if(aaa%2==1){
        reverse(s.begin(),s.end());
    }
    
    cout << s << endl;
    
    return 0;
}











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

int main() {
  int a,b;
  cin>>a>>b;
  if (b >= a) {
    cout<<((b-1)%(a-1) == 0 ? (b-1)/(a-1):(b-1)/(a-1)+1)<<endl;
  }
  else if (b == 1) {
    cout<<0<<endl;
  }
  else {
    cout<<1<<endl;
  }
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,y = readInts()
a = [300000,200000,100000] + [0] * 2000
print(a[0] + a[0] + 400000 if x == y == 1 else a[x-1] + a[y-1])


Measured memory_bytes: 5148
n, m, x, y = map(int, input().split())
X = sorted(map(int,input().split()))
Y = sorted(map(int,input().split()))
x_result = False
y_result = False
is_war = True


for z in range(x + 1, y + 1):
    
    if max(X) < z:
        x_result = True
    else:
        x_result = False

    if min(Y) >= z:
        y_result = True
    else:
        y_result = False

    if x_result and y_result:
        is_war = False
        break

if is_war:
    print("War")
else:
    print("No War")
    

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    string s[50];
    int t[50];
    cin >> n;
    for (int i = 0;i < n;++i) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    int ans = 0;
    bool f = false;
    for (int i = 0;i < n;++i) {
        if (f) ans += t[i];
        if (s[i] == x) f = true;
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int N, now_move=0, max_move=0;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }

    for (int i = 0; i < N-1; i++){
        if (H[i] < H[i+1]){
            if (now_move > max_move){
                max_move = now_move;
            }
            now_move = 0;
        } else {
            now_move++;
        }
    }
    if (now_move > max_move){
        max_move = now_move;
    }

    cout << max_move << endl;

    return 0;
}


Measured memory_bytes: 768
//Bairstow

#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <complex>
#include <cmath>
using namespace std;
 
#define EPS_S 1e-9
#define EPS 1e-4
 
typedef complex<double> P;
typedef pair<int,int> pii;
 
void bairstow(double &p, double &q, vector<double> &a){
    int n = a.size() - 1;
     
    vector<double> b(n + 1), c(n + 1);
    double dp, dq, e;
     
    p = q = 0.12345;
    int cnt = 0;
    do{
        b[0] = a[0];
        b[1] = a[1] - p * b[0];
         
        for(int k = 2; k <= n; ++k){
            b[k] = a[k] - p * b[k-1] - q * b[k-2];
        }
        c[0] = b[0];
        c[1] = b[1] - p * c[0];
        for(int k = 2; k <= n; ++k){
            c[k] = b[k] - p * c[k-1] - q * c[k-2];
        }
        e = c[n-2] * c[n-2] - c[n-3] * (c[n-1] - b[n-1]);
		if(abs(e) < EPS_S){ break; }
        dp = (b[n-1] * c[n-2] - b[n] * c[n-3]) / e;
        dq = (b[n] * c[n-2] - b[n-1] * (c[n-1] - b[n-1])) / e;
        p += dp;
        q += dq;
    }while(++cnt < 10000 && min(abs(dp), abs(dp)) > EPS_S);
     
    a.swap(b);
}
 
vector<P> solve_powered(vector<double> a){
    vector<P> ret;

	while(abs(a.back()) < EPS_S){
		ret.push_back(0.0);
		a.pop_back();
	}

    while(a.size() > 1){
        if(a.size() == 2){
            ret.push_back(-a[1] / a[0]);
        }
        else{
            double p, q;
            if(a.size() == 3){
                p = a[1] / a[0];
                q = a[2] / a[0];
            }
            else{
                bairstow(p, q, a);
            }
 
            P rt = sqrt(P(p * p - 4.0 * q));
            ret.push_back((-p + rt) * 0.5);
            ret.push_back((-p - rt) * 0.5);
        }
         
        a.resize(a.size() - 2);
    }
     
    return ret;
}
 
int main(){
    int d;
    scanf("%d", &d);
    vector<double> a(d + 1);
    for(int i = d; i >= 0; --i){
        scanf("%lf", &a[i]);
    }
 
    vector<P> ret = solve_powered(a);
    vector<pii> ans;
    for(int i = 0; i < ret.size(); ++i){
        double re = real(ret[i]), im = imag(ret[i]);
        double rei = floor(re + 0.5), imi = floor(im + 0.5);
        if(abs(re - rei) < EPS && abs(im - imi) < EPS){
            ans.push_back(pii(rei, imi));
        }
    }

    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    printf("%d\n", ans.size());
    for(int i = 0; i < ans.size(); ++i){
        if(i != 0){ putchar(' '); }
         
        int re = ans[i].first, im = ans[i].second;
        if(re == 0){
            if(im == 0){ printf("0"); }
            else if(im == 1){
                printf("i");
            }
            else if(im == -1){
                printf("-i");
            }
            else{ printf("%di", im); }
        }
        else{
            printf("%d", re);
            if(im == 1){
                printf("+i");
            }
            else if(im == -1){
                printf("-i");
            }
            else if(im != 0){
                printf("%+di", im);
            }
        }
    }
    puts("");
}

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

int main() {
  int n;
  cin >> n;
  int a[n-1], b[n-1], c[n], d[n+1], ch[n+1];
  vector<vector<int> > p(n+1);
  for ( int i = 1; i <= n; i++ ) {
    d[i] = 0;
    ch[i] = 0;
  }
  for ( int i = 0; i < n-1; i++ ) {
    cin >> a[i] >> b[i];
    p[a[i]].push_back(b[i]);
    p[b[i]].push_back(a[i]);
    ch[a[i]]++;
    ch[b[i]]++;
  }
  for ( int i = 0; i < n; i++ ) {
    cin >> c[i];
  }
  sort(c, c+n, greater<>());

  int max = 0, point;
  vector<int> next;
  for ( int i = 1; i <= n; i++ ) {
    if ( max < ch[i] ) {
      point = i;
      max = ch[i];
    }
  }
  next.push_back(point);
  int x = 0;
  for ( int i = 0; x < n; i++ ) {
    d[next[i]] = c[x++];
    for ( int j = 0; j < ch[next[i]]; j++ ) {
      if ( d[p[next[i]][j]] == 0 ) {
        next.push_back(p[next[i]][j]);
      }
    }
  }

  int ans = 0;
  for ( int i = 0; i < n-1; i++ ) {
    ans += ( d[a[i]] > d[b[i]] ) ? d[b[i]] : d[a[i]];
  }
  cout << ans << endl;
  for ( int i = 1; i < n; i++ ) {
    cout << d[i] << " ";
  }
  cout << d[n] << endl;

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a[55];
ll b[55];
ll c[55];
ll d[55];
ll A( ll a, ll b ){
  ll c = a - b;
  if( c < 0 ) return -c;
  return c;
}
int main( void )
{
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for( int i=0; i<N; i++ ) cin >> a[i] >> b[i];
  for( int i=0; i<M; i++ ) cin >> c[i] >> d[i];
  ll INF = (1LL) << 50;
  for( int i=0; i<N; i++ ){
    ll v = INF;
    int r = -1;
    for( int j=0; j<M; j++ ){
      ll vv = A(a[i], c[j]) + A(b[i], d[j]);
      if( v > vv ){
        r = j;
        v = vv;
      }
    }
    cout << r+1 << endl;
  }
}

Measured memory_bytes: 256
#pragma region Include
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
#pragma endregion

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> price;
  int a, b, c;
  int prev;
  price[0] = 0;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    int S = 0;
    rep(j, b) {
      cin >> c;
      --c;
      S = S | 1 << c;
    }
    for (auto itr = price.begin(); itr != price.end(); ++itr) {
      int key = itr->fi;
      int val = itr->se;
      int merge = key | S;
      auto m = price.find(merge);
      if (m != price.end()) {
        price[merge] = min(val + a, m->se);
      } else {
        price[merge] = val + a;
      }
    }
  }

  int ans = price[(1 << N) - 1];
  if (ans == 0) {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    vector<ll> B(N,0);
    vector<ll> C(N,0);
    for(ll i=0;i<N;i++)cin>>A[i];
    for(ll i=0;i<N;i++)cin>>B[i];
    for(ll i=0;i<N;i++)cin>>C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<ll> dpb(N,0);
    vector<ll> dpc(N,0);
    vector<ll> until(N,0);
    for(ll i=0;i<N;i++)dpb[i]=lower_bound(A.begin(), A.end(), B[i])-A.begin();
    for(ll i=0;i<N;i++){
        if(i>0)until[i]=until[i-1];
        until[i]+=dpb[i];
    }
    for(ll i=0;i<N;i++){
        ll d=lower_bound(B.begin(), B.end(), C[i])-B.begin();
        if(d!=0)
        dpc[i]=until[d-1];
    }
    ll ans=0;
    for(ll i=0;i<N;i++)ans+=dpc[i];
    print(ans)
    return 0;
}


Measured memory_bytes: 4992
// 2011/08/16 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a1, a2, a3, a4;
	cin >> a1 >> a2 >> a3 >> a4;
	int b1, b2, b3, b4;
	cin >> b1 >> b2 >> b3 >> b4;

	int S = a1+a2+a3+a4;
	int T = b1+b2+b3+b4;

	if(S>=T)
		cout << S << endl;
	else
		cout << T << endl;

	return 0;
}

Measured memory_bytes: 0
<?php
$n = int();
$count = 0;
for($i = 1; $i <= $n; $i++){
  if(strlen($i) % 2 == 1)$count++;
}
echo $count;
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll t,n,sum=0,ans=0,j,s,i,ar[200005];
	cin>>n;
	for(i=0;i<n;i++)cin>>ar[i];
	for(i=0;i<n;i++)
	{
		sum=(sum+ar[i])%1000000007;
	}
	for(i=0;i<n;i++)
	{
		sum=sum-ar[i];
		if(sum<0)sum+=1000000007;
		ans=(ans+(sum*ar[i])%1000000007)%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
using namespace std;
long long MAX = 1e18;
int main(){
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N), b(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    long long ans = MAX;
    for(long long i = 0; i < N; i++){
        long long temp = 0;
        temp += i * x;
        for(int j = 0; j < N; j++){
            b[j] = min(b[j], a[(N + j - i) % N]);
            temp += b[j];
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
using namespace std;
int a[10],b[10];
int main(){
	int n,t;
	for(int i=0;i<9;i++)
		cin >> a[i];
	cin >> n;
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++){
		cin >> t;
		for(int j=0;j<9;j++) {
			if(t == a[j]) {
				b[j] =1;
			} 	
		}
	}
	if( (b[0]==1 && b[1] ==1 && b[2]==1)||
	(b[3]==1 && b[4] ==1 && b[5]==1)||
	(b[6]==1 && b[7] ==1 && b[8]==1)||
	(b[0]==1 && b[1] ==1 && b[2]==1)||
	(b[0]==1 && b[3] ==1 && b[6]==1)||
	(b[1]==1 && b[4] ==1 && b[7]==1)||
	(b[2]==1 && b[5] ==1 && b[8]==1)||
	(b[0]==1 && b[4] ==1 && b[8]==1)||
	(b[2]==1 && b[4] ==1 && b[6]==1) )
		cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
S = input()
month = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if (S[:2] in month):
    if (S[2:] in month):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if (S[2:] in month):
        print('YYMM')
    else:
        print('NA')

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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  
  if (-a+b<=0) cout << "delicious" << endl;
  else if (-a+b>0 && -a+b<=x) cout << "safe" <<endl;
  else cout << "dangerous" << endl;
}

Measured memory_bytes: 384
S = input()
A = [0]*len(S)
countR = 0
countL = 0
count = 0
pre = S[0]
for l in range(len(S)):
  if S[l]==pre:
    count += 1
  else:
    if pre == "R":
      countR = count
    elif pre == "L":
      countL = count
      if (countR + countL)%2 == countR%2:
        A[l-countL-1] = (countR+countL)//2 + (countR+countL)%2
        A[l-countL] = countR+countL - A[l-countL-1]
      else:
        A[l-countL] = (countR+countL)//2 + (countR+countL)%2
        A[l-countL-1] = countR+countL - A[l-countL]
      countR = 0
      countL = 0
    count = 1
    pre = S[l]
countL = count
if (countR + countL)%2 == countR%2:
  A[len(S)-countL-1] = (countR+countL)//2 + (countR+countL)%2
  A[len(S)-countL] = countR+countL - A[len(S)-countL-1]
else:
  A[len(S)-countL] = (countR+countL)//2 + (countR+countL)%2
  A[len(S)-countL-1] = countR+countL - A[len(S)-countL]
print(" ".join(map(str, A)))

Measured memory_bytes: 10612
# にぶたん　二分探索
n, k = map(int, input().split())
A = list(map(int, input().split()))

ng = 0
ok = max(A)

while abs(ok - ng) > 1:
  mid = (ok + ng) // 2
  cnt = 0
  for a in A:
    cnt += (a - 1) // mid
  if cnt <= k:
    ok = mid
  else:
    ng = mid

print(ok)


Measured memory_bytes: 30844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	REP(i,n){
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> dp(3, vector<int>(n + 1, 0));
	for(int i = 0; i < n; i++){
		dp[0][i + 1] = max(dp[1][i] + b[i], dp[2][i] + c[i]);
		dp[1][i + 1] = max(dp[0][i] + a[i], dp[2][i] + c[i]);
		dp[2][i + 1] = max(dp[0][i] + a[i], dp[1][i] + b[i]);
	}
	cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;
	return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

const int N = 2e5 + 10;

int n, q;
int segs[2][4*N];

void upd(int *seg, int p, int val, int node, int l, int r) {
	if(l <= p and p <= r) { 
		seg[node] = max(val, seg[node]);
		if(l < r) {
			int node_l = 2*node;
			int node_r = 2*node+1;
			upd(seg, p, val, node_l, l, (l+r)/2);
			upd(seg, p, val, node_r, (l+r)/2 + 1, r);
		}
	}
}

int qry(int *seg, int val, int node, int l, int r) {
	if(seg[node] >= val) { 
		if(l < r) {
			int node_l = 2*node;
			int node_r = 2*node+1;
			int ret = qry(seg, val, node_l, l, (l+r)/2);
			if(ret)
				return ret;
			return qry(seg, val, node_r, (l+r)/2 + 1, r);
		} else
			return l;
	} else
		return 0;
}

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

	cin >> n >> q;
	ll ans = 0;
	upd(segs[0], n, n, 1, 1, n);
	upd(segs[1], n, n, 1, 1, n);
	while(q--) {
		int opt, x;
		cin >> opt >> x;
		if(opt == 1) {
			int maxi = qry(segs[0], x, 1, 1, n);
			maxi--;
			// cout << "maxi = " << maxi << '\n';
			ans += maxi-1;
			upd(segs[1], x, maxi, 1, 1, n);
		}
		else {
			int maxi = qry(segs[1], x, 1, 1, n);
			maxi--;
			// cout << "maxi = " << maxi << '\n';
			ans += maxi-1;
			upd(segs[0], x, maxi, 1, 1, n);
		}
	}
	cout << (n-2)*1ll*(n-2) - ans << '\n';

	return 0;
}


Measured memory_bytes: 7684
def fact(n):
    p_factors = []

    for i in range(2, int(n**0.5)+1):
        while n%i == 0:
            p_factors.append(i)
            n //= i
    if n>1:
        p_factors.append(n)
    return p_factors



n = int(input())

factors = fact(n)
# print(factors)
factors_set = set(factors)
# print(factors_set)

nums = []
for i in factors_set:
    nums.append(factors.count(i))

# print(nums)

count = 0
for i in nums:
    temp = i
    j = 1
    while True:
        temp -= j
        if temp < 0:
            break
        count += 1
        j += 1

print(count)

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

int main(){
  int e = 1;
  while(e > 0){
    cin >> e;
    int x,y,z,s;
    s = e;
    y = 0;
    z = 0;
    while(z*z*z<=e){
      while(y*y<=e-z*z*z){
	int s1;
	x = e-z*z*z-y*y;
	s1 = x+y+z;
	if(s>s1){
	  s = s1;
	}
	y+=1;
      }
      z+=1;
      y=0;
    }
    if(e > 0){
    cout << s <<endl;
    }
  }
}

Measured memory_bytes: 3060
N, M = map(int, input().split())

X = []
for i in range(M):
    p, y = map(int, input().split())
    X.append((i, p, y))

X.sort(key=lambda x: (x[1], x[2]))

XX = []
p = None
n = 0
for x in X:
    if x[1] != p:
        p = x[1]
        n = 1
    else:
        n += 1
    XX.append(x + (n,))

XX.sort(key=lambda xx: xx[0])

for xx in XX:
    print("{:06}{:06}".format(xx[1], xx[3]))


Measured memory_bytes: 83800