akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cassert>
using namespace std;

int n;
int len;
int a[234567];

struct block
{
	enum st{ SOLID0, SOLID1, MESH0, MESH1, HALF0, HALF1 }state;
	int length;
};

bool deck[234567];
bool condition(int x)
{
	for (int i = 0; i < len; ++i)
	{
		deck[i] = (a[i] >= x);
	}
	bool flag = true;
	for (int i = 1; i < len; ++i)
	{
		if (deck[i] == deck[i - 1])
		{
			flag = false;
			break;
		}
	}
	if (flag)return deck[0];
	vector<block> fold, real;
	int size = 1;
	for (int i = 1; i < len; ++i)
	{
		if (deck[i] != deck[i - 1])
		{
			fold.push_back({ deck[i - 1] ? block::SOLID1 : block::SOLID0 ,size });
			size = 1;
		}
		else
		{
			++size;
		}
	}
	fold.push_back({ deck[len - 1] ? block::SOLID1 : block::SOLID0 ,size });
	for (auto itr = fold.begin(); itr != fold.end();)
	{
		auto move = itr;
		while (move != fold.end() && move->length == 1)
		{
			++move;
		}
		if (move != itr)
		{
			block tmp;
			tmp.length = move - itr;
			if (tmp.length % 2 == 0)
			{
				tmp.state = ((itr->state == block::SOLID0) ? block::HALF0 : block::HALF1);
			}
			else
			{
				tmp.state = ((itr->state == block::SOLID0) ? block::MESH0 : block::MESH1);
			}
			real.push_back(tmp);
			itr = move;
		}
		else
		{
			real.push_back(*itr);
			++itr;
		}
	}
	int xepher = 0;
	for (const auto& elm : real)
	{
		xepher += elm.length;
		if (xepher > n - 1)
		{
			switch (elm.state)
			{
			case block::SOLID0:
			case block::SOLID1:
				return (elm.state == block::SOLID1);
				break;
			case block::MESH0:
			case block::MESH1:
				return (elm.state == block::MESH0);
				break;
			case block::HALF0:
			case block::HALF1:
			{
				int cas = xepher - elm.length / 2;
				return (cas > n - 1) == (elm.state == block::HALF0);
			}
				break;
			default:
				assert(false);
				return true;
				break;
			}
		}
	}
}

int main(void)
{
	scanf("%d", &n);
	len = 2 * n - 1;
	for (int i = 0; i < len; ++i)scanf("%d", a + i);
	int big = len + 1, sml = 1;
	for (int time = 0; time < 30; ++time)
	{
		int cen = (big + sml) / 2;
		if (condition(cen))
		{
			sml = cen;
		}
		else
		{
			big = cen;
		}
	}
	printf("%d\n", sml);
	return 0;
}


Measured memory_bytes: 4884
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
char t3[1510];
int main(){
    int n;
    int a,b;
    int i,j;
    char t;
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            while(a<b){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
            puts("");
        }
    }
    return 0;
}

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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int total = 0;
    rep(i, n) {
        cin >> a[i];
        total += a[i];
    }

    int cnt = 0;
    rep(i, n) {
        if (a[i] * 4 * m >= total) {
            cnt++;
        }
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define maxn 1500000
#define INF 199999999
int W, H, n, top, top2, S[maxn], S2[maxn];
int ans, mark[maxn], mx[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct node
{
	int x, y;
	friend bool operator <(const node& a, const node& b)
	{ return a.y < b.y; }
}P[maxn];

void Push_Down(int p)
{
	if(!mark[p]) return;
	mark[p << 1] += mark[p], mark[p << 1 | 1] += mark[p];
	mx[p << 1] += mark[p], mx[p << 1 | 1] += mark[p];
	mark[p] = 0;
}

void Update(int p, int l, int r, int L, int R, int x)
{
	if(L > R) return;
	if(L <= l && R >= r)
	{
		mark[p] += x, mx[p] += x;
		return;
	}
	if(L > r || R < l) return;
	Push_Down(p);
	int mid = (l + r) >> 1;
	Update(p << 1, l, mid, L, R, x); Update(p << 1 | 1, mid + 1, r, L, R, x);
	mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
}

int Query(int p, int l, int r, int L, int R)
{
	if(L <= l && R >= r) return mx[p];
	if(L > r || R < l) return 0;
	int mid = (l + r) >> 1; Push_Down(p);
	return max(Query(p << 1, l, mid, L, R), Query(p << 1 | 1, mid + 1, r, L, R));
}

void Work()
{
	memset(mx, 0, sizeof(mx)); memset(mark, 0, sizeof(mark));
	top = top2 = 0; int mid = W >> 1; 
	for(int i = 1; i <= n; i ++)
	{
		if(i > 1) ans = max(ans, (P[i].y + Query(1, 1, n, 1, i - 1)) * 2);
		Update(1, 1, n, i, i, W - P[i].y);
		if(P[i].x <= mid)
		{
			int last = 0, rec = i;
			while(top && P[S[top]].x <= P[i].x)
			{
				Update(1, 1, n, S[top], rec - 1, -(P[i].x - last));
				last = P[S[top]].x, rec = S[top]; top --;	
			}
			Update(1, 1, n, S[top], rec - 1, -(P[i].x - last));
			S[++ top] = i;
		}
		else
		{
			int last = W, rec = i;
			while(top2 && P[S2[top2]].x >= P[i].x)
			{
				Update(1, 1, n, S2[top2], rec - 1, P[i].x - last);
				last = P[S2[top2]].x, rec = S2[top2], top2 --;	
			}
			Update(1, 1, n, S2[top2], rec - 1, P[i].x - last);
			S2[++ top2] = i;
		}
	}
}

int main()
{
	W = read(), H = read(), n = read();
	int X1 = 0, Y1 = 0, X2 = INF, Y2 = INF;
	for(int i = 1; i <= n; i ++) P[i].x = read(), P[i].y = read();
	for(int i = 1; i <= n; i ++)
	{
		X1 = max(X1, P[i].x), Y1 = max(Y1, P[i].y);
		X2 = min(X2, P[i].x), Y2 = min(Y2, P[i].y);
	}
	if(X2 && Y2) P[++ n].x = 0, P[++ n].y = 0;
	if(X1 != W && Y1 != H) P[++ n].x = W, P[++ n].y = H;
	ans = max(ans, (H + max(X2, (W - X1))) * 2);
	ans = max(ans, (W + max(Y2, (H - Y1))) * 2);
	sort(P + 1, P + 1 + n); Work();
	for(int i = 1; i <= n; i ++) swap(P[i].x, P[i].y);
	swap(W, H); sort(P + 1, P + 1 + n); Work();
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  int rangecnt[2001] = {0};
  for (int i=0; i<n; i++){
      cin >> arr[i];
      rangecnt[arr[i]]++;
  }
  for (int i=1; i<=2000; i++){
      rangecnt[i] = rangecnt[i]+rangecnt[i-1];
  }
  sort(arr, arr+n);
  long long res = 0;
 
  for (int i=0; i<n; i++){
      for (int j=i+1; j<n; j++){
          int small = arr[i];
          int big = arr[j];
          int lo = big-small;
          int hi = big+small;
          if (small > lo && small < hi){
              res--;
          }
          if (big > lo && big < hi){
              res--;
          }
          res += rangecnt[hi-1]-rangecnt[lo];
          
      }
  }
  cout << res/3;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
int h,w;
bool inside(int x,int y)
{
    return x>=0&&x<h&&y>=0&&y<w;
}
vector<int> dx={1,-1,0,0},dy={0,0,1,-1};
vector<int> ind(255);
int main()
{
    ind['L']=3;
    ind['R']=2;
    ind['U']=1;
    ind['D']=0;
	scanf("%i %i",&h,&w);
	int n,xx,yy;
	scanf("%i %i %i",&n,&xx,&yy);
	xx--;yy--;
    string s,t;
    cin >> s >> t;
    bool izasao=false;
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<2;j++)
        {
            int x=xx,y=yy;
            vector<int> ss,tt;
            if(i)
                ss.pb(1),ss.pb(0);
            else
                ss.pb(0),ss.pb(1);
            if(j)
                ss.pb(1),ss.pb(0);
            else
                ss.pb(0),ss.pb(1);
            if(!i)
                tt.pb(1),tt.pb(0);
            else
                tt.pb(0),tt.pb(1);
            if(!j)
                tt.pb(1),tt.pb(0);
            else
                tt.pb(0),tt.pb(1);
            for(int k=0;k<n;k++)
            {
                if(ss[ind[s[k]]])
                    x+=dx[ind[s[k]]],y+=dy[ind[s[k]]];
                if(!inside(x,y))
                {
                    izasao=true;
                    goto here;
                }
                if(tt[ind[t[k]]])
                    x+=dx[ind[t[k]]],y+=dy[ind[t[k]]];
                if(!inside(x,y))
                {
                    x-=dx[ind[t[k]]];
                    y-=dy[ind[t[k]]];
                }
            }
        }
    }
    here:
    if(izasao)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


Measured memory_bytes: 776
#include <assert.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1005;
const int INF = 0x3f3f3f3f;

int main() {
    int a, b, c;
    while(~scanf("%d %d %d", &a, &b, &c)) {
        int t1 = a*10 + b + c;
        int t2 = a + 10*b + c;
        int t3 = b + a + c*10;
        printf("%d\n", max(t3, max(t1, t2)));
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int long long
#define mp make_pair
//#define for(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define N 1000000007
#define pq priority queue
#define pb push_back
#define mt make_tuple
#define prec(a) fixed<<setprecision(9)<<a
#define endl "\n"
#define fast_set s.max_load_factor(0.25);s.reserve(500);
const long double PI = (long double)(3.1415926535897932384626433832795);
int parity_check(int n)
{
	int par=n;
	par = par ^ (par >> 1); 
    par = par ^ (par >> 2); 
    par = par ^ (par >> 4); 
    par = par ^ (par >> 8); 
    par = par ^ (par >> 16); 
  
    if(par%2==1)
    {
    	return 1;
    }
    else
    {
    	return 0;
    }
    // true means odd parity
    // false means even parity
}
ll gcd(ll a,ll b)
{
	if(a==0)
	{
		return b;
	}
	return gcd(b%a,a);
}
int sz[100001];
ll lcm(ll a,ll b)
{
	ll pro=a*b;
	ll ans=gcd(a,b);
	pro=pro/ans;
	return pro;
}
ll fast_power(ll a,ll b,ll p)
{
	if(b==0)
	{
		return (1%p);
	}
	ll t=fast_power(a,b/2,p);
	ll ans=(t*t)%p;
	if(b%2)
	{
		ans=(ans*(a%p))%p;
	}
	return ans;
}

void dfs(ll s,vector<ll>vert,map<ll,ll>&visited,set<pair<ll,ll> >se)
{
	visited[s]=1;
	for(ll i=0;i<vert.size();i++)
	{
		if(!visited[vert[i]]&&se.find(mp(s,vert[i]))!=se.end())
		{
			visited[vert[i]]=1;
			dfs(vert[i],vert,visited,se);
			//sz[s] = sz[v[s][i]]+sz[s];
		}
	}
	//sz[s]=sz[s]+1;
}


ll connec(vector<ll> vert,map<ll,ll>visited,set<pair<ll,ll> >s)
{
	ll count=0;
	for(ll i=0;i<vert.size();i++)
	{
		if(!visited[vert[i]])
		{
			dfs(vert[i],vert,visited,s);
			count++;
		}
	}
	return count;
}
int main()
{
	fast;
	
	ll n,a,b,i,j,k;
	
	cin>>n>>a>>b;
	if((b-a)%2==0)
	{
		cout<<(b-a)/2;
		return 0;
	}
	cout<<min(a-1,n-b)+1+(b-a-1)/2  ;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var map = new int[3, 3];
        for (int i = 0; i < 3; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 3; j++)
                map[i, j] = int.Parse(line[j]);
        }
        var a = new int[3];
        var b = new int[3];
        var t = map[0, 0];
        for (int i = 0; i <= t; i++)
        {
            b[0] = map[0, 0] - i;
            b[1] = map[0, 1] - i;
            b[2] = map[0, 2] - i;
            a[0] = map[0, 0] - b[0];
            a[1] = map[1, 0] - b[0];
            a[2] = map[2, 0] - b[0];
            if (check(a, b, map)) { Console.WriteLine("Yes"); goto end; }
        }
        Console.WriteLine("No");
        end:;
    }
    public static bool check(int[] a, int[] b, int[,] map)
    {
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (map[i, j] != a[i] + b[j]) return false;
        return true;
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
signed main() {
	int n, z, w, a; cin >> n >> z >> w;
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = a;
	}
	if (n == 1) { cout << abs(test[0] - w) << endl; return 0; }
	cout << max(abs(test[n - 2] - test[n - 1]), abs(test[n - 1] - w)) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  b[n] = 0;
  ll ans = 0;
  rep(i,n+1) {
    if((a[i] - b[i]) < 0) {
      ans += a[i];
      if (a[i+1] > (b[i] - a[i])) {
	a[i+1] -= b[i] - a[i];
	ans += b[i] - a[i];
      } else {
	ans += a[i+1];
	a[i+1] = 0;
      }
    }
    else {
      ans += b[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

int32_t main() {
	_ __

#ifdef LOCAL_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 0;
	set<pair<pair<int, int>, int>> p;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
					count++;
				}
			}
		}
	}
	cout << count << "\n";

#ifdef LOCAL_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>

int main(){
	int n;
	scanf("%d", &n);
	double seisu[n];
	for(int i=0; i<n; i++){
		scanf("%lf", &seisu[i]);
	}
	
	double gyakuwa=0;
	for(int i=0; i<n; i++){
		gyakuwa+= 1/seisu[i];
	}
	printf("%lf", 1/gyakuwa);
	
	return 0;
}

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

#define FOR(x,y,z) for(int x=y,x##_=z;x<=x##_;++x)
#define DOR(x,y,z) for(int x=y,x##_=z;x>=x##_;--x)
#define FOR_(x,y,z,s) for(int x=y,x##_=z;x<=x##_;x+=s)
#define FOR__(x,y,z) for(int x=y,x##_=z;x<=x##_;x<<=1)
#define EOR(x,y) for(int x##_=head[x],y=edge[x##_].e;x##_;y=edge[x##_=edge[x##_].to].e)
#define EGOR(x,y,z) for(int x##_=head[x],y=edge[x##_].e,z=edge[x##_].c;x##_;y=edge[x##_=edge[x##_].to].e,z=edge[x##_].c)

#define clr(x,y) memset(x,y,sizeof(x))
#define szf(x) sizeof(x)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)

#define read2(x,y) read(x),read(y)
#define read3(x,y,z) read(x),read(y),read(z)
#define read4(x,y,z,w) read3(x,y,z),read(w)
#define reads(str) sf("%s",str)

#define ts (*this)
#define sf scanf
#define pf printf

#define ll long long
#define ull unsigned long long
#define db double
#define ct clock_t
#define ck() clock()
#define rd rand()
#define rmx RAND_MAX
#define RD T*(rd*2-rmx)


using namespace std;

template<class T>bool tomin(T &x,T y){return x>y?x=y,1:0;}
template<class T>bool tomax(T &x,T y){return x<y?x=y,1:0;}
template<class T>void read(T &x){
	char c;
	x=0;
	int f=1;
	while(c=getchar(),c<'0'||c>'9')if(c=='-')f=-1;
	do x=(x<<3)+(x<<1)+(c^48);
	while(c=getchar(),c>='0'&&c<='9');
	x*=f;
}

const db Pi=acos(-1);
int n,m;
int A[15][15];
int pw(int x,int y){
	return (x-y)*(x-y);
}
int main(){
	srand(time(NULL));
	read2(n,m);
	FOR(i,1,n)FOR(j,1,m)read(A[i][j]);
	int ans=0;
	FOR(i,1,n)FOR(j,i+1,n){
		int res=0;
		FOR(k,1,m)res+=pw(A[i][k],A[j][k]);
		int re=sqrt(res);
		if(re*re==res)ans++;
	}
	pf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
money = 1000
sell = 0
num = 0
for i in range(N-1):
    if A[i] < A[i+1]:
        num += int(money / A[i])
        money %= A[i]
        sell = 1
    elif sell == 1:
        money += num * A[i]
        num = 0
        sell = 0
if num > 0:
    money += num*A[N-1]
print(money)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;

  ll mx = 0;
  mx = min({a, b, c, d, e});

  ll ans = n/mx;
  if(n%mx != 0) ++ans;
  ans += 4;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
b=[0]*3
for i in range(n-2,-1,-1):
    for j in range(3):
        t=0
        for k in range(3):
            if j!=k:
                t=max(t,a[i][j]+a[i+1][k])
        a[i][j]=t
print(max(a[0]))

Measured memory_bytes: 56024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 200020
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

int N;
string S;

void mul(ll &a,ll b){
  a=a*b%MOD;
}

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

  setComb();

  ll ans=1;
  int lef=0;
  for(int i=0;i<2*N;i++){
      if(S[i]=='W'){
          if(lef==0) ans=0;
          else if(lef%2) lef++;
          else{
              mul(ans,lef);
              lef--;
          }
      }else{
          if(lef==0) lef++;
          else if(lef%2){
              mul(ans,lef);
              lef--;
          }else lef++;
      }
  }

  if(lef>0) ans=0;

  mul(ans,fac[N]);
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 5252
#include<iostream>
using namespace std;
int len[100000];
int main(){
	int n,a;
	cin>>n;
	int top=0,set;
	bool end=true;
	for(int i=0;i<n;i++){
		cin>>a;
		if(!end){
			if(a!=set){
				top++;
				end=true;
			}
			else len[top]++;
		}
		set=1-set;
		if(end){
			len[top]=1;
			set=1-a;
			end=false;
		}
	}
	top++;
	int ans;
	if(top==1)ans=len[0];if(top==2)ans=len[0]+len[1];
	if(top>=3){ans=0;for(int i=0;i<top-2;i++)ans=max(ans,len[i]+len[i+1]+len[i+2]);}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1360
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {

			int n = sc.nextInt();

			TreeSet<Integer> list = new TreeSet<>();
			int[] numCount = new int[1000001];
			int max = 0;
			for (int i = 0; i < n; i++) {
				int value = sc.nextInt();
				numCount[value]++;
				list.add(value);
				max = Math.max(max, value);
			}

			if(numCount[1] > 1) {
				System.out.println(0);
				return;
			}else if(numCount[1] == 1) {
				System.out.println(1);
				return;
			}

			boolean[] dp = new boolean[max+1];
			for(int i = 1; i < dp.length; i++ ) {
				dp[i] = true;
			}

			for(int a : list) {
				for(int i = 2; a*i < max+1; i++) {
					dp[a*i] = false;
				}
			}

			int count = 0;
			for(int a: list) {
				if(numCount[a] == 1 && dp[a]) {
					count++;
				}
			}
			System.out.println(count);

		} catch (Exception e) {
			e.printStackTrace();

		}
	}

	static class Prime {
		public ArrayList<Long> primes = new ArrayList<>();
		public long max;

		public Prime(long max) {
			this.max = max;
			primes.add(2l);
			for (long i = 3; i <= max; i += 2) {
				if (isPrime(i))
					primes.add(i);
			}
		}

		public boolean isPrime(long value) {
			if (value <= 1l) {
				return false;
			} else if (value == 2l) {
				return true;
			}

			if(value % 2 == 0) return false;

			boolean flag = true;
			for (long i = 3l; i * i <= value; i += 2l) {
				if (value % i == 0) {
					flag = false;
					break;
				}
			}

			return flag;
		}

		public HashMap<Long,Integer> primeFact(long value){
			HashMap<Long,Integer> returns = new HashMap<>();
			int i = 0;
			int count = 0;
			if(primes.contains(value)) {
				returns.put(value, 1);
				return returns;
			}

			while(true) {
				if(value % primes.get(i) == 0) {
					count++;
					value /= primes.get(i);
				}else {
					if(count !=0) {
						returns.put(primes.get(i), count);
					}

					i++;
					count = 0;
				}

				if(value == 1) {
					returns.put(primes.get(i), count);
					break;
				}
			}


			return returns;
		}
	}

}



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

int main(void)
{
    int a[9];
    for (int i = 0; i < 9; i++) {
        cin >> a[i];
    }

    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if (a[j] == b) {
                a[j] = -1;
            }
        }
    }

    if ((a[0] == -1 && a[1] == -1 && a[2] == -1)
    || (a[3] == -1 && a[4] == -1 && a[5] == -1)
    || (a[6] == -1 && a[7] == -1 && a[8] == -1)) {
        cout << "Yes" << endl;
        return 0;
    }
    if ((a[0] == -1 && a[3] == -1 && a[6] == -1)
    || (a[1] == -1 && a[4] == -1 && a[7] == -1)
    || (a[2] == -1 && a[5] == -1 && a[8] == -1)) {
        cout << "Yes" << endl;
        return 0;
    }
    if ((a[0] == -1 && a[4] == -1 && a[8] == -1)
    || (a[2] == -1 && a[4] == -1 && a[6] == -1)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int A, B, C;

int main() {
    cin >> A >> B >> C;
    bool flag = A == B && B == C;
    cout << (flag? "Yes": "No") << endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

int check(llong p){
  int i = 0;
  for(int j = 0; j < k; j++){
    llong s = 0;
    while(s + T[i] <= p){
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

int solve(){
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left > 1){
    mid = (left + right) / 2;
    int v = check(mid);
    if(v >= n) right = mid;
    else left = mid;
  }
  return right;
}

main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> T[i];
  llong ans = solve();
  cout << ans << endl; 
}

Measured memory_bytes: 1944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int main() {
    int n; 
    ll power = 1;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        power = power * i % mod;
    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define int long long
#define N1097 1000000007
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
#define REP(val, count) for(int (val)=0; (val)<(count); ++(val))

using namespace std;

signed main()
{
	int n;
	cin >> n;
	int sum = 0;
	int d[1001] = { 0 };
	for (int i = 1; i <= n; i++)
	{
		int a = i;
		int b = 2;
		while(a > 1)
		{
			if (a % b == 0)
			{
				d[b]++;
				a /= b;
			}
			else
			{
				b++;
			}
		}
	}
	int s = 1;
	for (int j = 2; j <= n; j++)
	{
		s *= (d[j] + 1);
		s %= N1097;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int dir[4][2] = { {0,1},{-1,0},{0,-1},{1,0} };
int main() {
	int height, width;
	cin >> height >> width;
	vector<string> map(height);
	for (int i = 0; i < height; ++i) {
		cin >> map[i];
	}
	vector<vector<int>> fmap(height, vector<int>(width, 2501));
	int walkable = 0;
	for (int h = 0; h < height; ++h) {
		for (int w = 0; w < width; ++w) {
			if (map[h][w] == '.') {
				walkable++;
			}
		}
	}
	fmap[0][0] = 1;
	int change = 1;
	while (change == 1) {
		change = 0;
		for (int h = 0; h < height; ++h) {
			for (int w = 0; w < width; ++w) {
				if (map[h][w] == '.') {
					for (int d = 0; d < 4; ++d) {
						int to_h = h + dir[d][0], to_w = w + dir[d][1];
						if (to_h >= 0 && to_h < height && to_w >= 0 && to_w < width) {
							if (map[to_h][to_w] == '.') {
								if (fmap[to_h][to_w] > fmap[h][w] + 1) {
									fmap[to_h][to_w] = fmap[h][w] + 1;
									change = 1;
								}
							}
						}
					}
				}
			}
		}
	}
	if (fmap[height - 1][width - 1] == 2501) {
		cout << -1 << endl;
	}
	else {
		cout << walkable - fmap[height - 1][width - 1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 28;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n, m;
    cin >> n >> m;
    VVI cost(n, VI(n, IINF));
    vector<pair<PII, int>> g;
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        cost[a][b] = c;
        cost[b][a] = c;

        g.push_back({{a, b}, c});
    }

    rep(k, n) rep(i, n) rep(j, n)
    {
        chmin(cost[i][j], cost[i][k] + cost[k][j]);
    }
    int ans = 0;
    rep(i, m)
    {
        int a = g[i].first.first;
        int b = g[i].first.second;
        int c = g[i].second;
        if (c > cost[a][b])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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



Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int d,n,t;
int main(){
	ios::sync_with_stdio(0);
	cin>>d>>n>>t;
	if(n*t<d)
	cout<<"No";
	else
	cout<<"Yes";
	re 0;
}


Measured memory_bytes: 3612
while True:
    try:
        cnt =0
        a = int(input())
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if i+j+k+l == a:
                            cnt += 1
        print(cnt)
    except:
        break


Measured memory_bytes: 5596
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n; cin>>n;
  int h[n]; for(int i=0;i<n;i++) cin>>h[i];
  int dp[n]; fill(dp,dp+n,1e9); dp[0]=0;
  for(int i=0;i<n;i++) {
    if (i+2<n) chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    if (i+1<n) chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
  }
  cout<<dp[n-1]<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 4280
#!/usr/local/bin/ruby
a = Array.new
N = gets.to_i
N.times do
 a << gets.split(" ").map(&:to_f)
end
a.each do |xa,ya,ra,xb,yb,rb|
 l = Math::sqrt( (xb-xa)**2 + (yb-ya)**2 )
 if l+rb < ra
  puts 2
 elsif l+ra < rb
  puts -2
 elsif l <= ra+rb
  puts 1
 elsif l > ra+rb
  puts 0
 end
end

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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
    //freopen("search.in", "r", stdin);
   // freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}

#define int long long

void test_case() {
    int x, k, d, ans = 0;
    cin >> x >> k >> d;
    x = abs(x);
    int c = x / d;
    if (c > k) {
        cout << abs(x - k * d);
    } else {
        k -= c;
        x -= c * d;
        if(k%2)
            x-=d;
        cout << abs(x);
    }
}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;
    while (Q--) {
        test_case();
    }
}





Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (isPrime(sc.nextInt())) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static boolean isPrime(int n) {
		int max = (int) Math.sqrt(n)+1;
		for (int i = 2; i < max; i++) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}



Measured memory_bytes: 44552
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0; i < 3; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = a[2]*10 + a[1] + a[0];
        System.out.println(ans);
    }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int H, W;
    cin >> H >> W;
    char maze[H][W];
    rep(i, 0, H) rep(j, 0, W) cin >> maze[i][j];
    vector<int> v(26);
    rep(i, 0, H) rep(j, 0, W) {
        v[maze[i][j] - 'a'] += 1;
    }

    vsort(v);
    reverse(v.begin(), v.end());
    if(H % 2 == 0 and W % 2 == 0) {
        H /= 2;
        W /= 2;
        rep(i, 0, H * W) {
            if(v[0] < 4) {
                cout << "No" << endl;
                return 0;
            }
            v[0] -= 4;
            vsort(v);
            reverse(v.begin(), v.end());
        }
        cout << "Yes" << endl;
        return 0;
    } else if(H % 2 != 0 and W % 2 != 0) {
        H /= 2;
        W /= 2;
        rep(i, 0, H * W) {
            if(v[0] < 4) {
                cout << "No" << endl;
                return 0;
            }
            v[0] -= 4;
            vsort(v);
            reverse(v.begin(), v.end());
        }
        rep(i, 0, H + W) {
            if(v[0] < 2) {
                cout << "No" << endl;
                return 0;
            }
            v[0] -= 2;
            vsort(v);
            reverse(v.begin(), v.end());
        }
        if(v[0] < 1) {
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
        return 0;
    } else {
        if(W % 2 == 0) swap(H, W);
        H /= 2;
        W /= 2;
        rep(i, 0, H * W) {
            if(v[0] < 4) {
                cout << "No" << endl;
                return 0;
            }
            v[0] -= 4;
            vsort(v);
            reverse(v.begin(), v.end());
        }
        rep(i, 0, H) {
            if(v[0] < 2) {
                cout << "No" << endl;
                return 0;
            }
            v[0] -= 2;
            vsort(v);
            reverse(v.begin(), v.end());
        }
        cout << "Yes" << endl;
        return 0;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll b=0,r=0;
    forn(i,n){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout << "Yes" << ln;
    else cout << "No" << ln;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
S = [0]*(M-1)
for i in range(M-1):
    S[i] = X[i+1] - X[i]
S.sort()
S.reverse()
print(X[-1]-X[0]-sum(S[:N-1]))

Measured memory_bytes: 13968
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,k,a[100010];
    ll sum[100010]={};
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll dp1[100010]={},dp2[100010]={};
    rep(i,n){
        if(a[i]>0) dp1[i+1]=dp1[i]+a[i];
        else dp1[i+1]=dp1[i];
    }
    repr(i,n){
        if(a[i]>0) dp2[i]=dp2[i+1]+a[i];
        else dp2[i]=dp2[i+1];
    }
    ll ans=0;
    /*
    rep(i,n+1) cout<<sum[i]<<" ";
    cout<<endl;
    rep(i,n+1) cout<<dp1[i]<<" ";
    cout<<endl;
    rep(i,n+1) cout<<dp2[i]<<" ";
    cout<<endl;
    */
    rep(i,n-k+1){
        ll cnt=0;
        ll s=sum[i+k]-sum[i];
        cnt+=dp1[i]+dp2[i+k];
        // cout<<cnt<<endl;
        ans=max(ans,cnt+s);
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
from collections import deque
S=deque(input())
Q=int(input())
r='1'
for _ in range(Q):
    target = input()
    if target == '1':
        if r=='1':
            r='2'
        else:
            r='1'
    else:
        a,b,c=target.split()
        if b=='1' and r=='1':
            S.appendleft(c)
        elif b=='2' and r=='1':
            S.append(c)
        elif b=='1' and r=='2':
            S.append(c)
        else:
            S.appendleft(c)
if r=='2':
    S.reverse()
print(''.join(list(S)))

Measured memory_bytes: 8436
// Author: pankaj_m05 
// Problem: c 
// Created: 21.06.2020 17:36:08

#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;

void testcase() {
    ll n;
    cin >> n;
    string s;
    map<int, char> hash;
    for(int i = 1; i <= 26; ++i) hash[i] = char(i - 1 + 97);
        hash[0] = 'z';
    while(n) {
        ll rem = n % 26;
        if(rem == 0) n--;
        char temp = hash[rem];
        n /= 26;
        s += temp;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

int main(void) { 
    fast
    int t = 1; 
    // cin >> t;
    while (t--) {
        testcase();
    }
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  char s[3];
  cin >> s;
  if(!strcmp(s, "SUN")) cout << 7;
  else if(!strcmp(s, "MON")) cout << 6;
  else if(!strcmp(s, "TUE")) cout << 5;
  else if(!strcmp(s, "WED")) cout << 4;
  else if(!strcmp(s, "THU")) cout << 3;
  else if(!strcmp(s, "FRI")) cout << 2;
  else cout << 1;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n, m = inl()
    if n * 2 >= m:
        return m // 2

    def check(x):
        y = x - n
        mm = m - y * 2
        return mm >= x * 2

    ok = n
    ng = n + m
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(solve())


Measured memory_bytes: 9076
n = gets.to_i
numbers = gets.split.map(&:to_i)
for i in 0..(n-1) do
  target = numbers[i]
  c = i - 1
  while c >= 0 && target < numbers[c]
    numbers[c+1] = numbers[c]
    c -= 1
  end
  numbers[c+1] = target
  puts numbers.join(" ")
end


Measured memory_bytes: 6884
n = int(input())
ss = "abcdefghijklmnopqrstuvwxyz"
dmin = {}
for s in ss:
  dmin[s] = 51
for i in range(n):
  S = input()
  for s in ss:
    dmin[s] = min(dmin[s], S.count(s))
ans = ""
for s in ss:
  ans += s*dmin[s]
print(ans)

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int k=0 ;
  
  for (int i=A ; i<=B; i++){
    if (i%10 == i/10000 && (i/1000)%10 == (i%100)/10 )
      k += 1;
  }    
  cout << k << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    char c = s[len(s) - 1];
    if ((c == '2') || (c == '4') || (c == '5') || (c == '7') || (c == '9')) cout << "hon" << endl;
    else if ((c == '0') || (c == '1') || (c == '6') || (c == '8')) cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, x, y, z; 
    cin >> n >> x >> y >> z;
    int ng = (1 << (z - 1)) | (1 << (y + z - 1)) | (1 << (x + y + z - 1));
    int mask = (1 << (x + y + z)) - 1;
    vector<vector<ll>> dp(n + 1, vector<ll>(mask + 1));
    ll ans = 1;
    for(int i = 0; i < n; i++){
        ans *= 10;
        ans %= MOD;
    }
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= mask; j++){
            if(dp[i][j] == 0) continue;
            for(int k = 1; k <= 10; k++){
                int t = (((j << k)) | (1 << (k - 1)));
                if((t & ng) == ng) continue;
                t &= mask;
                dp[i + 1][t] += dp[i][j];
                dp[i + 1][t] %= MOD;
            }
        }
    }
    for(int i = 0; i <= mask; i++){
        ans += MOD - dp[n][i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 43392