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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n = 0, m = 0;
    while((1 << n) <= l) {
        n++;
    }
    m += 2 * (n - 1);
    m += __builtin_popcount(l) - 1;
    cout << n << " " << m << endl;
    for(int i = 0; i < n - 1; i++) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (1 << i) << endl;
    }
    int curr = 1 << (n - 1); // we already have this as our range, now lets "increase" our range bit by bit
    // if we know a bit is on in l, then that means from the previous node before we should be able to create any values + the curr highest (but we cant include the current one!)
    // so its like, if we know a certain bit is on, we take the previous curr value without the bit on to include that we want every possible value that includes the higher bits and doesnt include this bit and has values lower
    for(int i = n - 2; i >= 0; i--) {
        if(l & (1 << i)) {
            cout << i + 1 << " " << n << " " << curr << endl;
            curr += 1 << i;
        }
    }

    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()


int main(void){
    int H, W, h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << H * W - H * w - W * h + h * w << endl;

    return 0;
}

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

int main()
{
    int n,k,i,temp;
    cin >> n >> k;
    vector<int> a(n,0);
    for(i = 0;i < n;++i){
        cin >> temp;
        ++a.at(temp-1);
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for(i = 0;i < n-k;++i){
        ans += a.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sum = 0; long ret1 = 0;
            for (int i = 0; i < n; i++)
            {
                sum += x[i];
                if (i % 2 == 0 && sum <= 0)
                {
                    ret1 += 1 - sum;
                    sum = 1;
                }
                if (i % 2 == 1 && sum >= 0)
                {
                    ret1 += sum + 1;
                    sum = -1;
                }
            }
            sum = 0; long ret2 = 0;
            for (int i = 0; i < n; i++)
            {
                sum += x[i];
                if (i % 2 == 1 && sum <= 0)
                {
                    ret2 += 1 - sum;
                    sum = 1;
                }
                if (i % 2 == 0 && sum >= 0)
                {
                    ret2 += sum + 1;
                    sum = -1;
                }
            }
            Console.WriteLine(Math.Min(ret1, ret2));
        }
    }
}

Measured memory_bytes: 30044
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int x, y, s;
  while (cin >> x >> y >> s && x && y) {
    int m = -1;
    for (int i = 1; i < s; ++i) {
      for (int j = 1; j < s; ++j) {
        int p1 = i * (100 + x) / 100, p2 = j * (100 + x) / 100;
        if (p1 + p2 == s) {
          m = max(m, i * (100 + y) / 100 + j * (100 + y) / 100);
        }
      }
    }
    cout << m << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

//#define __int64 long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
	string s;
	cin >> s;
	
	for(int i=0; i<4; i++){
		cout << s[i];
	}
	cout << " ";
	for(int i=4; i<12; i++){
		cout << s[i];
	}
	cout << endl;
	
	
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    string S;
    cin >> S;
    if (S[0] == S[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    int wcount[n];
    int ecount[n];
    rep(i,n)
    {
        wcount[i] = 0;
        ecount[i] = 0;
    }
    rep(i,n) {
        if (i==0 && s[i]=='W'){
            wcount[0]=1;
            continue;
        }
        else if (i==0)
        {
            continue;
        }
        
        if (s[i]=='W')
        {
            wcount[i] = wcount[i-1]+1;
        }
        else
        {
            wcount[i] = wcount[i-1];
        }
    }

    for (int i=n-1;i>=0;i--)
    {
        if (i==n-1 && s[i]=='E') {
            ecount[n-1]=1;
            continue;
        }
        else if (i==n-1)
        {
            continue;
        }
        
        if (s[i]=='E')
        {
            ecount[i] = ecount[i+1]+1;
        }
        else
        {
            ecount[i] = ecount[i+1];
        }
    }
    int ans = 1e6;
    // rep(i,n)
    // {
    //     cout << ecount[i];
    // }
    // cout << endl;
    // rep(i,n)
    // {
    //     cout << wcount[i];
    // }
    // cout << endl;
    rep(i,n)
    {
        int l;
        if (i==0)
        {
            l = 0;
        }
        else
        {
            l = wcount[i-1];
        }
        int r;
        if (i==n-1)
        {
            r = 0;
        }
        else
        {
            r = ecount[i+1];
        }
        
        ans = min(ans, r+l);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2964
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

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

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    double ans;
    ans = (double)(n - (n / 2)) / (double)n;
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 3768
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

long long int search(const vector<pair<long long int, long long int>> &sushi, const long long int &C)
{
    auto leftSum = [&sushi, &C](int A, bool reset = false) {
        static vector<long long int> leftSum(sushi.size() + 2);
        static bool cached = false;
        if (!cached || reset)
        {
            for (int i = sushi.size() + 1; i >= 1; i--)
            {
                if (i == sushi.size() + 1)
                {
                    leftSum[i] = 0;
                }
                else
                {
                    leftSum[i] = leftSum[i + 1] + sushi[i - 1].second;
                }
            }
            cached = true;
        }
        if (A <= sushi.size())
        {
            return leftSum[A] - (C - sushi[A - 1].first) * 2;
        }
        else
        {
            return leftSum[A];
        }
    };
    auto rightSum = [&sushi](int B, bool reset = false) {
        static vector<long long int> rightSum(sushi.size() + 2);
        static bool cached = false;
        if (!cached || reset)
        {
            for (size_t i = 0; i < sushi.size() + 1; i++)
            {
                if (i == 0)
                {
                    rightSum[i] = 0;
                }
                else
                {
                    rightSum[i] = rightSum[i - 1] + sushi[i - 1].second;
                }
            }
            cached = true;
        }
        if (B != 0)
        {
            return rightSum[B] - sushi[B - 1].first;
        }
        else
        {
            return rightSum[B];
        }
    };
    leftSum(0, true);
    rightSum(0, true);
    long long int ans = 0;
    vector<long long int> maxAtoO(sushi.size() + 1);
    for (int B = sushi.size(); B >= 0; B--)
    {
        if(B == sushi.size()){
            maxAtoO[B] = leftSum(B+1);
        }
        else
        {
            maxAtoO[B] = max(leftSum(B + 1), maxAtoO[B + 1]);
        }
        long long int sum = 0;
            sum += maxAtoO[B];
            sum += rightSum(B);
            if (ans < sum)
            {
                ans = sum;
            }
    }
    return ans;
}

int main(int argc, char const *argv[])
{
    int N;
    long long int C;
    scanf("%d %lld\n", &N, &C);
    vector<pair<long long int, long long int>> sushi(N), sushiReversed(N);
    for (size_t i = 0; i < N; i++)
    {
        scanf("%lld %lld\n", &(sushi[i].first), &(sushi[i].second));
        sushiReversed[N - i - 1].first = C - sushi[i].first;
        sushiReversed[N - i - 1].second = sushi[i].second;
    }
    long long int leftStart, rightStart;
    leftStart = search(sushi, C);
    rightStart = search(sushiReversed, C);
    cout << max(leftStart, rightStart) << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define FOR(i, m, n) for(int i = (int)m; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;
ll mod = 1000000007;
using namespace std;

int main() {
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++) {
        if((int)(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nof(T) [](T a){return a;}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	int ans = 0;
	while (pow(k, ans) > 0) {
		if (pow(k, ans) > n)break;
		else ++ans;
	}
	printf("%d\n", ans);

	Please AC;
}


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

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

  vector<vector<bool>> adj(N, vector<bool>(N, false));
  for(int m = 0; m < M; m++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a][b] = true;
    adj[b][a] = true;
  }

  long long ans = 0;
  vector<int> path(N);
  for(int i = 0; i < N; i++){
    path[i] = i;
  }
  do{
    if(path[0] != 0){
      continue;
    }
    bool ok = true;
    for(int i = 0; i + 1 < N; i++){
      if(!adj[path[i]][path[i + 1]]){
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }while(next_permutation(path.begin(), path.end()));
  cout << ans << endl;
}



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

const ll maxs = 3e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

ll n;
ll c[maxs];
vector<ll> ans;
vector<ll> tree[maxs];
ll cnt[maxs];
ll sz[maxs];
ll all;

ll get(ll n){
    return n*(n-1)/2;
}

void dfs(ll s,ll p){
    sz[s] = 1;
    ll bfr = cnt[c[s]];
    for(auto d : tree[s]){
        if(d!=p){
            ll pre = all - cnt[c[s]];
            dfs(d,s);
            sz[s] += sz[d];
            ll nxt = all - cnt[c[s]];
            ans[c[s]] -= get(nxt-pre);
        }
    }
    cnt[c[s]] = bfr + sz[s];
    all++;
}

void solve(){    
    cin >> n;
    for(ll i=1;i<n+1;i++){
        cin >> c[i];
    }

    for(ll i=0;i<n-1;i++){
        ll s,d;
        cin >> s >> d;
        tree[s].pb(d);
        tree[d].pb(s);
    }

    ans = vector<ll>(n+1,get(n));
    dfs(1,0);

    for(ll i=1;i<n+1;i++){
        ll pre = 0,nxt = n - cnt[i];
        ans[i] -= get(nxt-pre);
    }

    for(ll i=1;i<=n;i++){
        ans[c[i]]++;
    }

    for(ll i=1;i<n+1;i++){
        cout << ans[i] << endl;
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    while(T--){  
        solve();
    }
    return 0;
}

Measured memory_bytes: 41300
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a,b;
	cin >> a >> b;

	if (a <= b) {
		cout << a << endl;
	} else {
		cout << a-1 <<endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define l long long
using namespace std;
int main()
{
    l k;
    cin>>k;
    l sum=0;
    for(l i=1; i<=k; i++)
    {
        for(l j=1; j<=k; j++)
        {
            for(l a=1; a<=k; a++)
            {
                sum+=__gcd(i,__gcd(j,a));
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    vector<int> b(n);
    for (int i = n - 1; i >= 0; i--) {
        b[i] = a[i];
        if (b[i] == 0) continue;
        int i1 = i + 1;
        for (int j1 = 1; j1 * j1 <= i1; j1++) {
            if (i1 % j1 == 0) {
                int j = j1 - 1;
                a[j] ^= 1;
                if (j1 * j1 != i1) a[i1 / j1 - 1] ^= 1;
            }
        }
    }

    int m = 0;
    for (int i = 0; i < n; i++) {
        m += b[i];
    }
    cout << m << endl;
    for (int i = 0; i < n; i++) {
        if (b[i]) cout << i + 1 << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 2560
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a.at(i);
    if (n == 1) {
        cout << abs(w - a.back()) << '\n';
    } else {
        cout << max(abs(w - a.back()), abs(a.at(n-1) - a.at(n-2))) << '\n';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
A,B =list(map(int, input().split()))

if B-A==0:
    ans = A
elif B-A==1:
    ans = A ^ B
elif B-A==2:
    ans = A ^ (A+1) ^ B
elif B-A==3:
    ans = A ^ (A+1) ^ (A+2) ^ B
else:
    if A%4==0:
        mod = (B-A+1)%4
        if mod==0:
            ans=0
        elif mod==1:
            ans=B
        elif mod==2:
            ans=B^(B-1)
        elif mod==3:
            ans=B^(B-1)^(B-2)
    elif A%4==1:
        ans = A^(A+1)^(A+2)
        mod = ((B-A+1)-3)%4
        if mod==0:
            ans = ans
        elif mod==1:
            ans = ans ^ B
        elif mod==2:
            ans = ans ^ B ^ (B-1)
        elif mod==3:
            ans = ans ^ B ^ (B-1) ^ (B-2)
    elif A%4==2:
        ans = A^(A+1)
        mod = ((B-A+1)-2)%4
        if mod==0:
            ans = ans
        elif mod==1:
            ans = ans ^ B
        elif mod==2:
            ans = ans ^ B ^ (B-1)
        elif mod==3:
            ans = ans ^ B ^ (B-1) ^ (B-2)
    elif A%4==3:
        ans = A
        mod = ((B-A+1)-1)%4
        if mod==0:
            ans = ans
        elif mod==1:
            ans = ans ^ B
        elif mod==2:
            ans = ans ^ B ^ (B-1)
        elif mod==3:
            ans = ans ^ B ^ (B-1) ^ (B-2)
            
print(ans)

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

using namespace std;

const int md = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
  return x;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
  return x;
}

int mul(int x, int y) {
  return (long long)x * y % md;
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> inv(n + 1);
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    inv[i] = mul(md - md / i, inv[md % i]);
  }
  int coef = 0;
  for (int i = 1; i <= n; ++i) {
    coef = add(coef, inv[i]);
  }
  int answer = 0;
  for (int i = 0; i < n; ++i) {
    answer = add(answer, mul(coef, a[i]));
    if (i + 1 < n) {
      coef = add(coef, inv[i + 2]);
      coef = sub(coef, inv[n - i]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    answer = mul(answer, i);
  }
  cout << answer << endl;
  return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int T; cin >> T;
  REP(_,T){
	int N, D; cin >> N >> D;
	--N;
	LL ans = 0;
	for(int b=1;b<128;b<<=1){
	  if(D&b){
		ans += b * (N/2*2+1);
	  }
	  else{
		ans += b * ((N+1)/2*2);
	  }
	}
	cout << ans << endl;
  }
  
  return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ll a;
	int b,c;
	char ch;
	cin>>a>>b>>ch>>c;;
	b=b*100+c;
	a=a*b;  a/=100;
	cout<<a<<endl; 
	return 0;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  int ans = 1;
  while (ans * 2 <= n) ans *= 2;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int number_of_people;
	int number_of_food_item;
	cin >> number_of_people >> number_of_food_item;
 
	int cnt_of_foodliked[number_of_food_item + 1] = {0};
	for(int i = 0; i < number_of_people ; i = i + 1){
		int his_prefereferences;
		cin >> his_prefereferences;
		for(int j = 0; j < his_prefereferences; j = j + 1){
			int food_he_likes;
			cin >> food_he_likes;
			cnt_of_foodliked[food_he_likes] = cnt_of_foodliked[food_he_likes] + 1;
		}
	}
	int ans = 0;
	for(int food_item = 1; food_item <= number_of_food_item; food_item++){
		//cout << food_item << " " << cnt_of_foodliked[food_item] << '\n'; 
		if(cnt_of_foodliked[food_item] == number_of_people){
			ans = ans + 1;
		}
	}
	cout << ans << '\n';
 
}
    
    

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

int main() {
    std::string in;

    cin >> in;

    string::size_type pos = in.find(",");
    while (pos != string::npos) {
        in.replace(pos, 1, " ");
        pos = in.find(",", pos + 1);
    }

    cout << in << endl;
    return 0;
}


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

using namespace std;

template< typename T >
struct FordFulkerson
{
  struct edge
  {
    int to;
    T cap;
    int rev;
  };

  vector< vector< edge > > graph;
  vector< int > used;
  const T INF;
  int timestamp;

  FordFulkerson(int n) : INF(numeric_limits< T >::max()), timestamp(0)
  {
    graph.resize(n);
    used.assign(n, -1);
  }

  void add_edge(int from, int to, T cap)
  {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  T dfs(int idx, const int t, T flow)
  {
    if(idx == t) return flow;
    used[idx] = timestamp;
    for(auto &e : graph[idx]) {
      if(e.cap > 0 && used[e.to] != timestamp) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    for(T f; (f = dfs(s, t, INF)) > 0; timestamp++) {
      flow += f;
    }
    return flow;
  }
};


int main()
{
  int V, E;
  scanf("%d %d", &V, &E);
  FordFulkerson< int > flow(V);
  for(int i = 0; i < E; i++) {
    int x, y, c;
    scanf("%d %d %d", &x, &y, &c);
    flow.add_edge(x, y, c);
  }
  cout << flow.max_flow(0, V - 1) << endl;
}





Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
int INF = 100000;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  while (1){
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0){
      break;
    }
    vector<vector<char>> c(h + 2, vector<char>(w + 2, 'x'));
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        cin >> c[i][j];
      }
    }
    vector<pair<int, int>> T;
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        if (c[i][j] == '*'){
          T.push_back(make_pair(i, j));
          c[i][j] = '.';
        }
        if (c[i][j] == 'o'){
          T.insert(T.begin(), make_pair(i, j));
          c[i][j] = '.';
        }
      }
    }
    int N = T.size();
    vector<vector<int>> E(N, vector<int>(N));
    for (int i = 0; i < N; i++){
      vector<vector<int>> d(h + 2, vector<int>(w + 2, INF));
      d[T[i].first][T[i].second] = 0;
      queue<pair<int, int>> Q;
      Q.push(make_pair(T[i].first, T[i].second));
      while (!Q.empty()){
        int y = Q.front().first;
        int x = Q.front().second;
        Q.pop();
        for (int j = 0; j < 4; j++){
          int y2 = y + dy[j];
          int x2 = x + dx[j];
          if (c[y2][x2] == '.' && d[y2][x2] == INF){
            d[y2][x2] = d[y][x] + 1;
            Q.push(make_pair(y2, x2));
          }
        }
      }
      for (int j = 0; j < N; j++){
        E[i][j] = d[T[j].first][T[j].second];
      }
    }
    bool ok = true;
    for (int j = 1; j < N; j++){
      if (E[0][j] == INF){
        ok = false;
      }
    }
    if (!ok){
      cout << -1 << endl;
    } else {
      vector<int> p(N);
      for (int j = 0; j < N; j++){
        p[j] = j;
      }
      int ans = INF;
      while (1){
        int sum = 0;
        for (int j = 0; j < N - 1; j++){
          sum += E[p[j]][p[j + 1]];
        }
        ans = min(ans, sum);
        next_permutation(p.begin(), p.end());
        if (p[0] > 0){
          break;
        }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3100
n=int(input())
k=int(input())
def main(N,K):
  ans=0
  if N<=100+10**6:
    for i in range(1,N+1):
      a=str(i)
      if len(a)-list(a).count("0")==K:
        ans+=1
    return ans
  L=list(map(int,list(str(N))))
  ans=0
  L=list(map(int,list(str(N))))
  if K==1:#おけ
    return (len(str(N))-1)*9+int(str(N)[0])
  elif K==2:#おけ
    for i in range(len(L)-1):
      ans+=(9*(int(str(N)[0])-1))
      for j in range(i+1,len(L)):
        if i==0:
          if j==1:
            ans+=int(str(N)[1])
          else:
            ans+=9
        else:
          ans+=81
    return ans
  else:
    le=len(L)
    for i in range(le-2):
      for j in range(i+1,le-1):
        for k in range(j+1,le):
          if i==0:
            ans+=81*(int(str(N)[0])-1)
            if j==1:
              ans+=9*(int(str(N)[1])-1)
              if k==2:
                ans+=int(str(N)[2])
              else:
                ans+=9
            else:
              ans+=81
          else:
            ans+=729
    return ans
ans2=0
L=list(str(n))
a=len(L)
for i in range(a):
  L=list(str(n))
  s=L[:a-i-1]
  t=L[a-i-1:]
  t=int("".join(t))
  p=s.count("0")
  p=len(s)-p
  if p>k:
    n-=t+1
  elif p==k:
    n-=t+1
    ans2+=1
  else:
    ans2+=main(t,k-p)
    n-=t+1
print(ans2)

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

int main() {
  char s;
  cin >> s;
  
  if(s=='a' || s=='i' || s=='u' || s=='e' || s=='o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
from heapq import heappush, heappop
V, E, s = map(int, input().split())
Adj = [[] for i in range(V)]

for i in range(E):
    ui, vi, ci = map(int, input().split())
    Adj[ui].append([vi, ci])

d = [float("inf")] * V
d[s] = 0
pq = [[0, s]]
fixed = 0

while pq:
    di, v = heappop(pq)

    if di > d[v]:
        continue

    for u, c in Adj[v]:
        if d[v] + c < d[u]:
            d[u] = d[v] + c
            heappush(pq, [d[u], u])

    fixed += 1

    if fixed == V - 1:
        break

for di in d:
    print(di if di != float("inf") else 'INF')

Measured memory_bytes: 97996
#include <iostream>
#include <cstring>
#include <algorithm>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 1000 + 5;



int main(){
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8) cout << ":(";
    else cout << "Yay!";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import copy
import sys
import numpy as np

MOD = 1000000007  # type: int


def debug(s):
    print(s)


def solve(N: int, K: int, a):
    dp = np.zeros((N + 1, K + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(1, N + 1):
        ai = a[i - 1]
        ndp = np.cumsum(dp[i - 1, :])
        dp[i, :] = ndp
        dp[i, ai + 1 :] -= ndp[: -ai - 1]
        dp[i, :] %= MOD
    return dp[N, K]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = np.array([int(next(tokens)) for _ in range(N)], dtype=np.int64)
    print(solve(N, K, a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 92464
k = int(input())

lst = [1,2,3,4,5,6,7,8,9]
count = 0

for i in range(k):
    num = lst[count]
    if num%10!=0:
        lst.append(num*10+num%10-1)
    lst.append(num*10+num%10)
    if num%10!=9:
        lst.append(num*10+num%10+1)
    count += 1

print(lst[k-1])


Measured memory_bytes: 15780
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << (s=="ABC"?"ARC":"ABC");
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<bitset<10>> S(m, bitset<10>(0));
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int s; cin >> s;
            S[i].set(--s);
        }
    }
    vector<int> P(m);
    for (int i = 0; i < m; i++) cin >> P[i];

    int out = 0;
    for (int i = 0; i < pow(2, n); i++) {
        bitset<10> t(i);
        bool flag = true;
        for (int j = 0; j < m; j++) {
            if ((S[j] & t).count() % 2 != P[j]) {
                flag = false;
                break;
            }
        }
        out += flag;
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main(){
  int i=0,A[100];
  char stuck[100];
 

  while(scanf("%s",stuck)!=EOF){
    if(stuck[0]=='+'){
      A[i-2]=A[i-2]+A[i-1];
      i--;
    }
    else if(stuck[0]=='-'){
      A[i-2]=A[i-2]-A[i-1];
      i--;
    }
    else if(stuck[0]=='*'){
      A[i-2]=A[i-2]*A[i-1];
      i--;
    }
    else{
      A[i]=atoi(stuck);
      i++;
    }
  }
  printf("%d\n",A[i-1]);      
  return 0;
}

Measured memory_bytes: 548
/* Author rumoisen */
/* created 2018/11/08 */

#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <iostream>

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

using namespace std;

int main(void)
{
    int n,t,a[212345];
    cin>>n>>t;
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(i==n-1){
            ans+=t;
            break;
        }
        else {
            int tmp=a[i+1]-a[i];
            if(tmp>=t) ans+=t;
            else ans+=tmp;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    int sqrt_num;

    int max_sqrt = N;
    for (int i = N; i >= 1; i--)
    {
        sqrt_num = sqrt(i);
        if (sqrt_num * sqrt_num == i)
        {
            max_sqrt = i;
            break;
            // max_sqrt = max(max_sqrt, i);
        }
    }

    // int max_sqrt = 1;
    // for (int i = 1; i <= N; i++)
    // {
    //     sqrt_num = sqrt(i);
    //     if (sqrt_num * sqrt_num == i)
    //     {
    //         // printf("i = %d\n", i);
    //         max_sqrt = max(max_sqrt, i);
    //     }
    // }
    cout << max_sqrt << endl;
    return (0);
}

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

typedef long long ll;

using namespace std;


const ll MOD=1000000007ll;
/*
struct UnionFind{
	vector<int> par;
	UnionFind(int N):par(N){
		for(int i=0;i<N;i++){
			for (int i = 0; i < N; i++){
				par[i]=i;
			}
		}
	}
	int root(int x){
			if(par[x]==x)return x;
			return par[x]=root(par[x]);
	}
     void unite(int x,int y){
			int rx=root(x);
			int ry=root(y);
			if(rx==ry){
				return;
			}
			par[rx]=ry;
	}
	bool same(int x,int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}


};
*/

typedef vector<vector<int> > Graph;




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

  int p[N];
  int vis[N];
  for(int i=0;i<N;i++){
	  vis[i]=-1;
  }
  int x,y;

  Graph g(N);

  for(int i=0;i<N;i++){
	  cin>>p[i];
	  --p[i];
  }
   
  for(int i=0;i<M;i++){
	  cin>>x>>y;
	  --x;--y;
    g[x].push_back(y);
	g[y].push_back(x);
  }

   int num=1;
  for(int i=0;i<N;++i){
	 
	  if(vis[i]!=-1){
		  continue;
	  }
	  stack<int> st;
	  st.push(i);
	  while(!st.empty()){
		  int v=st.top();
		  st.pop();
		  for(int i=0;i<g[v].size();i++){
			  int k=g[v][i];
			  if(vis[k]==-1){
				  st.push(k);
				  vis[k]=num;
			  }
			  
		  }
	  }
	  ++num;
  }
/*
  for(int i=0;i<N;++i){
	  cout<<vis[i]<<" ";
  }
  cout<<endl;
*/

	  int count=0;
	  for(int i=0;i<N;++i){
		  if(vis[p[i]]!=-1){
		  if(vis[p[i]]==vis[i]){
			  ++count;
		  }
		  }else if(vis[p[i]]==-1&&p[i]==i){
			  ++count;
		  }
	  }

	  cout<<count<<endl;

}



Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
int main(void){
	bool a[5][14]={false};
	int n;
	int i,j;
	cin>>n;
	char x;
	int y;
	for(i=0;i<n;i++){
		cin>>x>>y;
		if(x=='S'){
			a[1][y]=true;
		}
		else if(x=='H'){
			a[2][y]=true;
		}
		else if(x=='C'){
			a[3][y]=true;
		}
		else{
			a[4][y]=true;
		}
	}
	for(i=1;i<5;i++){
		for(j=1;j<14;j++){
			if(!a[i][j]){
				if(i==1){
					cout<<"S"<<" "<<j;
				}
				else if(i==2){
					cout<<"H"<<" "<<j;
				}
				else if(i==3){
					cout<<"C"<<" "<<j;
				}
				else{
					cout<<"D"<<" "<<j;
				}
				cout<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3096
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
s=[]
m.times do
  tmp = gets.chomp.split.map(&:to_i)
  tmp.shift
  s.push tmp
end
q = gets.chomp.split.map(&:to_i)

ans = 0
d=n
(2**d).times do |i|
  bits = i.to_s(2)
  bits = "0" * (n-bits.size) + bits
  bits = bits.split(//).map!(&:to_i)

  flg = true
  s.each_with_index do |sw, index|
    sum = sw.each.map{|e| bits[e-1]}.inject(&:+)
    if sum % 2 != q[index]
      flg = false
      break
    end
  end
  ans += 1 if flg
end

puts ans


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


bool solve() {
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  A--;
  B--;
  C--;
  D--;
  string s; cin >> s;
  // A < B < D

  if (C == D) return false;

  if (C <= B) {
    return (s.substr(A, C-A+1).find("##") == string::npos &&
            s.substr(B, D-B+1).find("##") == string::npos);
  } else if (C < D) {
    return (s.substr(A, C-A+1).find("##") == string::npos &&
            s.substr(B, D-B+1).find("##") == string::npos);
  } else {
    bool res1 = (s.substr(A, C-A+1).find("##") == string::npos &&
                 s.substr(B, D-B+1).find("##") == string::npos);
    bool res2 = (s.substr(B-1, (D+1)-(B-1)+1).find("...") != string::npos);
    return res1 && res2;
  }
  return false;
}
int main2() {
  bool res = solve();
  cout << (res ? "Yes":"No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 772
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int N, i, max=0, cnt[200001];
	char s[200000][11];
	
	scanf("%d", &N);
	lop(i, N){
		scanf("%s", s[i]);
	}
	
	qsort(s, N, 11 ,strcmp);
	
	cnt[0]=1;
	for(i=1; i<N; i++){
		if(strcmp(s[i-1],s[i])==0){
			cnt[i]=cnt[i-1]+1;
		}
		else{
			cnt[i]=1;
			if(max<cnt[i-1])max=cnt[i-1];
		}
	}
	
	if(max<cnt[N-1]) max=cnt[N-1];
	lop(i, N){
		if(cnt[i]==max)printf("%s\n", s[i]);
	}
	
	return 0;
}

Measured memory_bytes: 4988
import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense
N = int(sys.stdin.buffer.readline())
S = np.frombuffer(sys.stdin.buffer.read(),
                  dtype='S1').reshape(N, -1)[:, :N].astype(int)
G = csgraph_from_dense(S)
F = floyd_warshall(G).astype(int)
F2 = F % 2
I0 = np.where(F2[0] == 0)
I1 = np.where(F2[0] == 1)
if (S[I0][:, I0] == 0).all() and (S[I1][:, I1] == 0).all():
    print(F.max() + 1)
    exit()
print(-1)


Measured memory_bytes: 16020
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, M);
    vector<ll> a(M + 10);
    vector<ll> step(N + 10, 0);

    ll MOD = 1e9 + 7;

    for (int i = 1; i <= M; i++) {
        int A;
        cin >> A;
        step[A] = -1;
    }

    step[0] = 1;
    if (step[1] != -1) step[1] = 1;

    for (int i = 2; i <= N; i++) {
        int a_1 = 0, a_2 = 0;
        if ( step[i - 1] >= 0 ) a_1 = step[i - 1];
        if ( step[i - 2] >= 0 ) a_2 = step[i - 2];

        if ( step[i] >= 0 ) step[i] = (a_1 + a_2) % MOD;
    }

    cout << step[N] << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> l(n);
    int max = 0, index;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        if(l[i] > max){
            max = l[i];
            index = i;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i == index) continue;
        sum += l[i];
    }

    if(max < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]

a,b,c,d=NM()
dp=[[0]*(d+1) for i in range(c+1)]
dp[a][b]=1
mod=998244353
for i in range(a+1,c+1):
    dp[i][b]=dp[i-1][b]*b%mod
for j in range(b+1,d+1):
    dp[a][j]=dp[a][j-1]*a%mod
for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j]=(dp[i][j-1]*i+dp[i-1][j]*j-(i-1)*(j-1)*dp[i-1][j-1])%mod
print(dp[c][d])

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

int main() {
    string S;
    cin >> S;
    int zero = 0, one = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '0') zero++;
        else one++;
    }
    cout << min(zero, one) * 2 << endl;
}

Measured memory_bytes: 3744
import Control.Monad.State
import Control.Applicative

data Tree = Null | Node { end :: Bool
                        , a :: Tree
                        , c :: Tree
                        , g :: Tree
                        , t :: Tree
                        } deriving (Show)

main = do
    n <- readLn
    evalStateT (query n) Null

insertT :: String -> Tree -> Tree
insertT [] Null = Node True Null Null Null Null
insertT [] tr = tr {end = True}
insertT (ch:cs) Null = insertT (ch:cs) (Node False Null Null Null Null)
insertT (ch:cs) tr
  | ch == 'A' =  tr {a = insertT cs (a tr)}
  | ch == 'C' =  tr {c = insertT cs (c tr)}
  | ch == 'G' =  tr {g = insertT cs (g tr)}
  | ch == 'T' =  tr {t = insertT cs (t tr)}

findT :: String -> Tree -> Bool
findT _ Null = False
findT [] tr = end tr
findT (ch:cs) tr = findT cs . getNode ch $ tr

getNode ch tree
  | ch == 'A' = a tree
  | ch == 'C' = c tree
  | ch == 'G' = g tree
  | ch == 'T' = t tree

type Query = StateT Tree IO ()

query :: Int -> Query
query 0 = return ()
query n = do
    doQuery
    query (n-1)

doQuery = do
    [com,str] <- liftIO (words<$>getLine)
    case com of
      "insert" -> insertQ str
      "find"   -> findQ str

insertQ :: String -> Query
insertQ str = modify (insertT str)

findQ :: String -> Query
findQ str = do
    tree <- get
    let res = findT str tree
    if res then liftIO (putStrLn "yes")
           else liftIO (putStrLn "no")



Measured memory_bytes: 86076