akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//18:08~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	llint n;cin>>n;
	cout<<n*(n-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
mod = 10**9 + 7
ans = 1
if N % 2 == 0:
	for i in range(N):
		if A[i] == (i//2) * 2 + 1:
			if i % 2 == 1:
				ans *= 2
				ans %= mod
		else:
			ans = 0
			break
else:
	if A[0] != 0:
		ans = 0
	else:
		for i in range(1,N):
			if A[i] == ((i+1)//2) * 2:
				if i % 2 == 0:
					ans *= 2
					ans %= mod
			else:
				ans = 0
				break

print(ans)

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

const int INF = 1e+9;

int main(){
    ll n;
    cin >> n;
    int ans = INF;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ans = min(ans, (int)to_string(n / i).size());
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, M; cin >> N >> M;
    int ans = 0;
    graph r(N+1);
    vector<int>H(N+1);
    REP(i, N) {
        cin >> H[i];
    }
    REP(i, M) {
        int a, b; cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    REP(i, N) {
        if (r[i].empty()) { ans++; }
        else {
            bool g = true;
            for (int& element : r[i]) {
                if (H[i] <= H[element]) { g = false; break; }
            }
            if (g == true) {  ans++; }
        }
    }
    cout << ans << endl;
}























































































































































































































































































































































































































































































































































































































































































    
   
   













































































































































































































































































































































   



    






    


   









    


















































































































































































































































































































Measured memory_bytes: 8716
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char S[250005];
const ll P = 998244353;
const ll Q = 400009;
const ll P2 = 1000000007;
const ll Q2 = 400033;
ll modex(ll a, ll p, ll m) {
	if (!p) return 1;
	if (p & 1) return a * modex(a, p - 1, m) % m;
	ll v = modex(a, p >> 1, m);
	return v * v % m;
}
int main() {
	int n;
	scanf("%d%s", &n, S);
	ll Qinv = modex(Q, P - 2, P);
	ll Qinv2 = modex(Q2, P2 - 2, P2);
	ll v = 0, v2 = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (S[i] == '+') v = (v + 1) % P;
		else if (S[i] == '-') v = (v - 1) % P;
		else if (S[i] == '>') v = v * Q % P;
		else if (S[i] == '<') v = v * Qinv % P;
		if (S[i] == '+') v2 = (v2 + 1) % P2;
		else if (S[i] == '-') v2 = (v2 - 1) % P2;
		else if (S[i] == '>') v2 = v2 * Q2 % P2;
		else if (S[i] == '<') v2 = v2 * Qinv2 % P2;
	}
	if (v < 0) v += P;
	if (v2 < 0) v2 += P2;
	map<pair<ll, ll>, int> cnt;
	ll mult = 1, add = 0, multinv = 1;
	ll mult2 = 1, add2 = 0, multinv2 = 1;
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		// add 0
		// x * mult + add = 0
		ll zero = -add * multinv % P;
		if (zero < 0) zero += P;
		ll zero2 = -add2 * multinv2 % P2;
		if (zero2 < 0) zero2 += P2;
		++cnt[{zero, zero2}];
		if (S[i] == '+') add = (add + 1) % P;
		else if (S[i] == '-') add = (add - 1) % P;
		else if (S[i] == '>') {
			mult = mult * Q % P;
			multinv = multinv * Qinv % P;
			add = add * Q % P;
		} else if (S[i] == '<') {
			mult = mult * Qinv % P;
			multinv = multinv * Q % P;
			add = add * Qinv % P;	
		}
		if (S[i] == '+') add2 = (add2 + 1) % P2;
		else if (S[i] == '-') add2 = (add2 - 1) % P2;
		else if (S[i] == '>') {
			mult2 = mult2 * Q2 % P2;
			multinv2 = multinv2 * Qinv2 % P2;
			add2 = add2 * Q2 % P2;
		} else if (S[i] == '<') {
			mult2 = mult2 * Qinv2 % P2;
			multinv2 = multinv2 * Q2 % P2;
			add2 = add2 * Qinv2 % P2;	
		}
		// query how many is equal to v
		ll w = (v - add) * multinv % P;
		if (w < 0) w += P;
		ll w2 = (v2 - add2) * multinv2 % P2;
		if (w2 < 0) w2 += P2;
		auto it = cnt.find(make_pair(w, w2));
		if (it != cnt.end()) ans += it->second;
	}
	printf("%lld\n", ans);
}


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

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

using namespace std;

#define MAX_N 2016

typedef long long ll;

const bool debug = 0;

int N,x;
ll a[MAX_N];
ll mini[MAX_N];
bool fin[MAX_N];

const int IINF = INT_MAX;

class RMQ{
private:
  int limit,N;
  vector<int> dat;
public:
  void init(int n_){
    N = n_;
    limit = 1;
    while(limit<n_)limit*=2;
    dat.clear();
    dat.resize(2*limit,IINF);
  }
  
  int _build(int cur,int L,int R,const vector<int> &buf){
    if( !( 0 <= cur && cur < 2*limit ) ) return IINF;
    if( L == R-1 ) {
      if( L >= N ) return IINF;
      dat[cur] = buf[L];
    } else {
      int vl = _build(cur*2+1,L,(L+R)/2,buf);
      int vr = _build(cur*2+2,(L+R)/2,R,buf);
      dat[cur] = min(vl,vr);
    }
    return dat[cur];
  }

  void build(const vector<int> &buf){ _build(0,0,limit,buf); };

  void update(int k,int a){
    k += limit-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
  }
 
  int _query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return IINF;
    else if(a<=l && r<=b)return dat[k];
    int vl = _query(a,b,k*2+1,l,(l+r)/2);
    int vr = _query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }

  int query(int a,int b){ return _query(a,b,0,0,limit); }
};


RMQ rmq;
ll compute(ll cnt) {
  memset(fin,false,sizeof fin);
  ll answer = x * cnt;
  rep(i,N) {
    int L,R;
    L = i + N;
    R = i - cnt + N;
    if( L > R ) swap(L,R);
    mini[i] = rmq.query(L,R+1);
    answer += mini[i];
  }
  return answer;
  /*
  deque<int> sp;
  rep(i,N) {
    if( mini[i] == a[i] ) {
      fin[i] = true;
      answer += a[i];
      sp.push_back(i);
    }
  }

  rep(i,(int)sp.size()) {
    ll step = 0;
    int cur = (sp[i]+1)%N;
    while( !fin[cur] ) {
      ( cur += 1 ) %= N;
      ++step;
      if( step > cnt ) {
	answer += a[cur];
      } else {
	answer += a[sp[i]];
      }
    }
  }
  return answer;
  */
}


int main() {
  cin >> N >> x;
  rep(i,N) cin >> a[i];
  rmq.init(N*3);
  {
    vector<int> vec;
    rep(i,2) rep(j,N) vec.push_back(a[j]);
    rmq.build(vec);
  }
  ll mini = LLONG_MAX;
  rep(i,N+1) {
    mini = min(compute(i),mini);
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
ans = [0] * 10050
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      v = i*i+j*j+k*k+i*j+j*k+k*i
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

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

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

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

vector < int > G[200000];
int visited[200000], N, M, ct = 0;

void dfs(int u){
	ct += 1;
	visited[u] = true;
	for (int v : G[u]){
		if (!visited[v]){
			dfs(v);
		}
	}
}

int main(){
	cin >> N >> M;
	for (int i = 0; i < M; i ++){
		int A, B;
		cin >> A >> B;
		A -= 1; B -= 1;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	int result = 0;
	for (int i = 0; i < N; i ++){
		if (!visited[i]){
			ct = 0;
			dfs(i);
			result = max(ct, result);
		}
	}

	cout << result << "\n";

}

Measured memory_bytes: 21496
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
const int MOD = 1e9 + 7;
int popcount(int num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
int powerOfTwo(int n){
    return 1 << n;
}

int arr[1000001];
bool temet = false;




void codeChef(){
    int x[5] , flag;
    for(int i=0; i<5; i++){
        cin>>x[i];
        if(x[i]==0){
            flag = i;
        }
    }
    cout << flag + 1;
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    codeChef();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define FI first
#define SE second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz size

#define MAXN 100009

bool p[MAXN];

void sieve()
{
    int i,j;
    for(i=0;i<=MAXN;i++)
    {
        p[i]=true;
    }
    p[0]=false;
    p[1]=false;
    for(i=2;i*i<=MAXN;i++)
    {
        if(p[i]==true)
        {
            for(j=i*i;j<=MAXN;j+=i)
            {
                p[j]=false;
            }
        }
    }
}

void fsscan()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void scan(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    //Write Your Code Here
    fsscan();
    sieve();
    int a[MAXN];
    a[0]=0;
    a[1]=0;
    for(int i=2;i<=MAXN;i++)
    {
        if(p[i]==true&&p[(i+1)/2]==true)
        {
            a[i]=a[i-1]+1;
        }
        else
        a[i]=a[i-1];
    }
    int t;
    cin>>t;
    while(t--)
    {
        //int c=0;
        int l,r;
        cin>>l>>r;
        cout<<a[r]-a[l-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 1152
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
# n, k = 5, 3
# nums = [-30, -10, 10, 20, 50]

m = 10 ** 10
# 左から
for i in range(n-k+1):
    m = min(m, abs(nums[i]) + nums[i+k-1] - nums[i])

# 逆で考えるのindex的に大変なので-1をかけて反転する
nums = nums[::-1]
nums = [num * -1 for num in nums]

# 本当は関数化すべき
for i in range(n-k+1):
    m = min(m, abs(nums[i]) + nums[i+k-1] - nums[i])
print(m)


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

int main() {
  int N;
  cin>>N;
  vector<int>A(N-1);
  vector<int>B(N);
  for(int i=0;i<N-1;i++){
    cin>>A.at(i);
  }
  for(int x:A){
    x--;
    B.at(x)++;
  }
  for(int x:B){
    cout<<x<<endl;
  }
}

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

int main() {
	lint n=0;
	int flag=0;
	int a=0;
	vector<lint> v(3);
	cin>>n;
	v[0]=n%10;
	v[1]=n/100;
	a=n/10;
	v[2]=a%10;
	for(int i=0;i<3;i++)
	{
		if(v[i]==7)
		{
			flag=1;
		}
	}
    if(flag==1)
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3628
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){

int N,K;
cin>>N>>K;
string S;
cin>>S;

int ans=0;
rep(i,N){
    if(S[i]==S[i+1]){
        ans++;
    }
}
cout<<min(ans+2*K,N-1)<<endl;


return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <set>
#include <cstdio>
#include <queue>
using namespace std;

#define EPS (1e-10)
#define EQ(a,b) ((abs((a)-(b)))<EPS)

typedef complex<double> P;

struct edge{
	int to;
	double cost;
};

int n,m;
vector<edge> G[10001];
vector<edge> G2[10001];
P points[10001];
const double INF=1000000000;
double mincost[10001];
bool used[10001];

// _s©çÅ¬SæØðì¬
double prim(int s,int V){
	for(int i=0;i<V;i++)mincost[i]=INF;
	mincost[s]=0;
	double res=0;
	priority_queue<pair<double,int> ,vector<pair<double,int> >,greater<pair<double,int> > > pq;
	pq.push(make_pair(0,s));
	while(pq.size()){
		// xÉ®³È¢¸_Ì¤¿,x©çÌÓÌRXgªÅ¬ÆÈé_ð³ª·
		double mc=pq.top().first;
		int v=pq.top().second;
		pq.pop();
		if(used[v])continue;
		// xÉvðÇÁ
		used[v]=true;
		// vÖÌRXgðÁ¦é
		res+=mc;
		// »ê¼êÌÓÖÌÅ¬RXgðXV
		for(int i=0;i<(int)G[v].size();i++){
			int u=G[v][i].to;
			if(!used[u])pq.push(make_pair(G[v][i].cost,u));
		}
	}
	return res;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		points[i]=P(x,y);
	}
	double sum=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		b--;a--;
		edge e;
		e.to=b;
		e.cost=-abs(points[a]-points[b]);
		sum+=-e.cost;
		G[a].push_back(e);
		e.to=a;
		G[b].push_back(e);
	}
	double res=0;
	for(int i=0;i<n;i++){
		if(used[i])continue;
		res+=prim(i,n);
	}
	printf("%.10f\n",sum+res);
	return 0;
}

Measured memory_bytes: 2340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>dp(100002,-1);
ll n;
ll solve(vector<ll>&v,ll i,ll &k)
{
    if(i==n-1) return 0;
    if(dp[i]!=-1) return dp[i];
    ll ans=abs(v[i]-v[i+1])+solve(v,i+1,k);
    for(ll j=2;j<=k;j++)
   {
     if(i+j<n)
    {
        ans=min(ans,abs(v[i]-v[i+j])+solve(v,i+j,k));
    }
   }
   return dp[i]=ans;

}
int main()
{
    ll k;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(v,0,k);
}


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

int main(){
    int N;
    cin >> N;
    if (N % 2 == 0){
        cout << 0.5 << endl;
    }
    else{
        double n = N;
        cout << setprecision(10)<< (n + 1)/(2 * n) << endl;
    }
}



Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		for(int i = 1; i < 10; i++) {
			for(int j = 1; j < 10; j++) {
				int product = i*j;
				System.out.println(i + "x" + j + "=" + product);
			}
		}
	}
}

Measured memory_bytes: 9360
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if(a%2 && b%2 && c%2) {
        if(a>=b && a>=c) cout << b*c << endl;
        else if(b>=a && b>=c) cout << a*c << endl;
        else if(c>=a && c>=b) cout << a*b << endl;
    } else {
        cout << '0' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
    int res = a + b;
    return res % MOD;
}

int sub(int a, int b) {
    int res = a - b;
    res %= MOD;
    res += MOD;
    return res % MOD;
}

int mul(int a, int b) {
    int res = a * b;
    return res % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return res;
}

int divv(int a, int b) {
    return mul(a, binpow(b, MOD - 2));
}

int n;

int solve(vector<int> soski) {
    if (soski.size() < 2) {
        return 0;
    }
    int none = 1;
    int one = 0;
    for (auto t : soski) {
        int other = 1;
        int we = sub(binpow(2, t), 1);
        one = add(one, mul(we, other));
    }
    return sub(binpow(2, n - 1), add(one, none));
}

vector<int> sz;
vector<int> used;
vector<vector<int>> g;

void dfs(int cur) {
    used[cur] = 1;
    sz[cur] = 1;
    for (auto t : g[cur]) {
        if (!used[t]) {
            dfs(t);
            sz[cur] += sz[t];
        }
    }
}

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

    cin >> n;
    sz.resize(n);
    used.resize(n);
    g.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector<int> soski;
        for (auto t : g[i]) {
            int rsz = sz[t];
            if (sz[t] > sz[i]) {
                rsz = n - sz[i];
            }
            soski.push_back(rsz);
        }
        int cur = solve(soski);
        ans = add(ans, cur);
    }
    cerr << ans << endl;
    cout << divv(ans, binpow(2, n)) << endl;
}   


Measured memory_bytes: 21376
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

int main(int args, char *argc[]){
  char a;
  while(cin>>a&&a!='\n')
    if(a<='C')
      printf("%c",('Z'+a-'A'-2));
    else
      printf("%c",a-3);
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main() {
    int n, wmax;
    std::cin >> n >> wmax;

    std::vector<int> w(n);
    std::vector<size_t> v(n);
    for (int i = 0; i < n; ++i) std::cin >> w[i] >> v[i];

    std::vector<size_t> vsum1(wmax + 1, 0);
    std::vector<size_t> vsum2(wmax + 1, 0);
    
    for (int j = 0; j < n; ++j) {
        for (int i = 1; i <= wmax; ++i)
            vsum2[i] = (i < w[j]) ? vsum1[i] : std::max(vsum1[i-w[j]] + v[j], vsum1[i]);
        std::copy(vsum2.begin(), vsum2.end(), vsum1.begin());
    }

    const auto it = std::max_element(vsum1.begin(), vsum1.end());
    std::cout << *it << std::endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b);
}

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

int main(){
    int h,w; cin>>h>>w;
    vector<string> grid(h);
    for(int i=0; i<h; i++) cin>>grid.at(i);
    vector<bool> blackH(h,false);
    vector<bool> blackW(w,false);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(grid.at(i).at(j) == '#'){
                blackH.at(i) = true;
                blackW.at(j) = true;
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(blackH.at(i) and blackW.at(j))
                cout<<grid.at(i).at(j);
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 256
import math
d, g = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(d)]
for i in range(d):
    lst[i].append((i+1) * 100)
    lst[i].append((i+1) * 100 * lst[i][0] + lst[i][1])

def make_bit(n, d):
    bit = [0] * d
    for i in range(d):
        bit[i] += n % 2
        n //= 2
    return bit

min_count = 10 ** 9 + 7
for n in range(2 ** d):
    bit = make_bit(n, d)
    #print(bit)
    now = 0
    count = 0
    for i in range(d):
        if bit[i] == 1:
            now += lst[i][3]
            count += lst[i][0]
    if now >= g:
        min_count = min(min_count, count)
    else:
        for i in range(d-1, -1, -1):
            if bit[i] == 0:
                c = math.ceil((g - now) / lst[i][2])
                if c < lst[i][0]:
                    count += c
                    min_count = min(min_count, count)
                break
print(min_count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <istream>
#include <vector>
#define rep(I,N) for(int I=0;I<N;I++)
using ll=long long int;
using namespace std;

int main(){
	ll N=0;
	char s[2000000],t[2000000];

	cin>>s;
	cin>>t;
	string S=s;
	rep(i,S.size()){
		if(!(s[i]==t[i]))N++;
	}
	cout<<N;
}


Measured memory_bytes: 4012
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

int32_t main(){
   boost;
   IO();

   int N; cin>>N;
   if(N>=30) cout << "Yes" << endl;
   else cout << "No" << endl;
	

   return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

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

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

const ll MAX_N = 50;

int main(void){
    string S, T;
    string answer = "UNRESTORABLE";

    cin >> S >> T;

    ll nt = T.length();
    ll ns = S.length();
    vector<string> answers;
    bool good = true;

    if (ns - nt < 0) {cout << answer << endl; return 0;}

    rep(i, ns - nt + 1){
        good = true;
        string s = S;
        rep(j, nt) if (T[j] == S[i + j] || S[i + j] == '?') s[i + j] = T[j]; else {good = false; break;}
        if (good) {
            rep(i, ns) if (s[i] == '?') s[i] = 'a';
            answers.push_back(s);
            }
    }

    if (!answers.empty()){
        sort(all(answers));
        cout << answers[0] << endl;
    }else{
        cout << answer << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def f(n):
    return n // 2 if n % 2 == 0 else 3*n + 1

a_n = int(input())
appeared = {a_n}

i = 1
while True:
    i += 1
    a_n = f(a_n)
    if a_n in appeared:
        print(i)
        break
    appeared.add(a_n)

Measured memory_bytes: 2940
n = int(input())
h_ls = list(map(int, input().split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h_ls[i+1] - h_ls[i]))
    if i < n - 2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h_ls[i+2] - h_ls[i]))
print(dp[-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
#define deb(x) each(x.begin(),x.end(),(int& y){cout << y <<" ";})
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

struct UnionFind{
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n) { //初期化
    par.resize(n); rank.resize(n);
    rep(i,n) {par[i] = i, rank[i] = 0;}
  }

  int root(int x) { //ノードの根を返す
    if (par[x] == x) return x; //親が自分なら自分を返す
    else {
      int r = root(par[x]); //根まで遡りながら経路圧縮
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x; //ランクの小さい方に接続
    return true;
  }
};

ll xx[200000],yy[200000]; //parent

void Main(){

  int N; cin>>N;

  UnionFind uf(200000);

  rep(i,N){
    int x,y; cin>>x>>y;
    uf.merge(x-1,100000+y-1);
  }

  rep(i,200000){
    if(i<100000) ++xx[uf.root(i)];
    else ++yy[uf.root(i)];
  }

  ll ans=0;

  rep(i,200000){
    if(xx[i]>=2 and yy[i]>=2) ans+=xx[i]*yy[i];
    else ans+=max(0LL,xx[i]+yy[i]-1);
  }

  ans-=N;

  cout<< ans<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 3968
from collections import deque
f_inf = float('inf')
H, W = map(int, input().split())
sh, sw = map(int, input().split())
sh, sw = sh-1, sw-1
eh, ew = map(int, input().split())
eh, ew = eh-1, ew-1
S = [list(input()) for _ in range(H)]
m = [[f_inf]*W for _ in range(H)]
m[sh][sw] = 0
que = deque([])
que.appendleft([sh,sw])
while que:
  h, w = que.popleft()
  for dh, dw in ((1,0), (-1,0), (0, 1), (0, -1)):
    next_h, next_w = h + dh, w + dw
    if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w]:
          m[next_h][next_w] = m[h][w] # 移動Aで行けるところにmの値を合わせる
          que.appendleft([next_h,next_w])
  for dh in range(-2, 3):
    for dw in range(-2, 3): # 移動Bで行ける範囲
      next_h, next_w = h + dh, w + dw
      if 0 <= next_h < H and 0 <= next_w < W and S[next_h][next_w] == ".":
        if m[next_h][next_w] > m[h][w] + 1: # h,wから移動Aですでに行けているところは更新されない
          m[next_h][next_w] = m[h][w] + 1 
          que.append([next_h, next_w]) # appendleftではなくappend 優先順位が後
print(m[eh][ew] if m[eh][ew] != f_inf else -1)

Measured memory_bytes: 148880
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=c-a;
  int y=d-b;
  cout<<c-y<<' '<<d+x<<' '<<a-y<<' '<<b+x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = n-1; i >= 0; i-=2) {
        cout << a[i] << " ";
    }
    for(int i = 0; i < n; i+=2) {
        if(n%2 == 1 && i == 0) {
            i--;;
            continue;
        }
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
		    String x = in.next();
		    if (x.equals("0")) {
		    	break;
		    }
		    char[] chars = x.toCharArray();
		    int sum = 0;
		    for (char c : chars) {
			    sum += Character.getNumericValue(c);
		    }
		    System.out.println(sum);
		}
	}
}	


Measured memory_bytes: 26260
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f[1000001];

void run(){
  int n,m;
  cin>>n>>m;
  priority_queue<pi> q;
  while(m--){
    int a,v;
    cin>>a>>v;
    f[a]+=v;
    q.push(mp(f[a],-a));
    while(true){
      pi t=q.top();
      if(t.fi==f[-t.se]){
	cout<<-t.se<<" "<<t.fi<<endl;
	break;
      }
      q.pop();
    }
  }
}



Measured memory_bytes: 12728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vector<map<int,int>> M(2);
  rep(i,0,N) M[i%2][A[i]]++;
  sort(ALL(A));
  int ans=0;
  rep(i,0,N){
    if(M[i%2][A[i]]>0){
      M[i%2][A[i]]--;
    }
    else{
      ans++;
      M[1-i%2][A[i]]--;
    }
  }
  cout<<ans/2<<endl;
  }



Measured memory_bytes: 13568
s = str(input())

for i in range(len(s)):
    #print(s[i])
    if i%2 == 0:        #偶数
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            print('No')
            exit()
    elif i%2 == 1:       #奇数
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            print('No')
            exit()
    

print('Yes')

Measured memory_bytes: 9056
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
    int n; cin>>n;
    vector<int> ans(2*n,inf),lst={1};
    ans[0]=0;
    int a=6,b=9;
    while(a<=n){
        lst.push_back(a); a*=6;
    }
    while(b<=n){
        lst.push_back(b); b*=9;
    }
    rep(i,n){
        for(auto p : lst){
            if(ans[i+p]>ans[i]+1) ans[i+p]=ans[i]+1;
        }
    }
    cout<<ans[n]<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

string s;
ll ans;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> s;
    if(s[0] == '>') s = "<" + s;
    if(s[s.size()-1] == '<') s.pb('>');

    int l = 0;
    int r = 0;
    forn(i, s.size())
    {
        if(s[i] == '<') l++;
        else r++;
        if(i == s.size()-1 || (s[i] == '>' && s[i+1] == '<'))
        {
            if(l<r) swap(l, r);
            ans += ((ll) l * (ll) (l+1) / 2);
            ans += ((ll) (r-1) * (ll) (r) / 2);
            //cout << "add " << l << " " << r << endl;
            l = r = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1308
#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=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, K;
vv<int> B, W, Bcnt, Wcnt;

int main() {
	cin >> N >> K;
	B = W = Bcnt = Wcnt = vvec(K + 1, K + 1, 0);
	rep(i, N) {
		int x, y; char c;
		cin >> x >> y >> c;
		bool isBlack = c == 'B';

		if (x % (2 * K) >= K) {
			isBlack = !isBlack;
		}
		if (y % (2 * K) >= K) {
			isBlack = !isBlack;
		}
		if (isBlack) {
			B[x % K][y % K]++;
		}
		else {
			W[x % K][y % K]++;
		}
    }

	rep(i, 1, K + 1) {
		rep(j, 1, K + 1) {
			Bcnt[i][j] = Bcnt[i - 1][j] + Bcnt[i][j - 1] - Bcnt[i - 1][j - 1] + B[i - 1][j - 1];
			Wcnt[i][j] = Wcnt[i - 1][j] + Wcnt[i][j - 1] - Wcnt[i - 1][j - 1] + W[i - 1][j - 1];
		}
	}

	int ans = -INF;
	rep(i, K + 1) {
		rep(j, K + 1) {
			chmax(ans, (Bcnt[K][K] - Bcnt[i][K] - Bcnt[K][j] + 2 * Bcnt[i][j]) + (Wcnt[i][K] + Wcnt[K][j] - 2 * Wcnt[i][j]));
			chmax(ans, (Wcnt[K][K] - Wcnt[i][K] - Wcnt[K][j] + 2 * Wcnt[i][j]) + (Bcnt[i][K] + Bcnt[K][j] - 2 * Bcnt[i][j]));
		}
	}
	write(ans);
}

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

int main(){
    int N, K;
    cin >> N >> K;
    long long Vq[50] = {0};
    for(int i=0; i<N; i++){
        cin >> Vq[i];
    }
    long long max = 0;
    for(int l=0; l<N+1; l++){
        for(int r=l-1; r<N; r++){
            if((l-1)+(N-1-r) >= K){
                continue;
            }
            int i=0;
            long long lst[50] = {0};
            for(int n=0; n<l; n++){
                lst[i] = Vq[n];
                i++;
            }
            for(int n=r+1; n<N; n++){
                lst[i] = Vq[n];
                i++;
            }
            sort(lst, lst+i);
            long long sum = 0;
            for(int n=0; n<i; n++){
                if(lst[n] <= 0 && n < K-i){
                    continue;
                }else{
                    sum += lst[n];
                }
            }
            if(sum >= max){
                max = sum;
            }
        }

    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

l = [0 for i in range(n)]
r = [0 for i in range(n)]
for i in range(1,n):
  rev = -(i+1)
  l[i] = l[i-1] + 1 if s[i-1] == "#" else l[i-1]
  r[rev] = r[rev+1] + 1 if s[rev+1] == "." else r[rev+1]

ans = 1e+9
for i in range(n):
  ans = min(ans, l[i] + r[i])
print(ans)

Measured memory_bytes: 13032
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int num[MAXN],cnt[MAXN];
int ans;
inline void add(int x)
{
	if(x-cnt[x]<=0)
	{
		cnt[x]++;
		return;	
	}
	if(!num[x-cnt[x]])
	{
		num[x-cnt[x]]++;
		ans--;
		cnt[x]++;
	}
	else
	{
		num[x-cnt[x]]++;
		cnt[x]++;
	}
}
inline void sub(int x)
{
	//cout<<x<<" x\n";
	if(x-cnt[x]+1<=0)
	{
		cnt[x]--;
		return;
	}
	num[x-cnt[x]+1]--;
	//cout<<num[x-cnt[x]+1]<<" num\n";
	if(!num[x-cnt[x]+1])
	{
		ans++;
		cnt[x]--;
	}
	else
	{
		cnt[x]--;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	ans=n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		add(x);
		a[i]=x;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		add(y);
		sub(a[x]);
		a[x]=y;
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3840
N = gets.to_i
X = gets.chomp.chars

def cnt(n, d)
  return d if n == 0
  wk = (0...n.bit_length).count{|i| n[i] == 1}
  cnt(n % wk, d+1)
end

c = X.count('1')
h, l = c+1, c-1
l = 1 if l == 0
t = Array.new(2).map{Array.new(N)}
t[0][N-1] = 1 % h
t[1][N-1] = 1 % l
m_h = (X[N-1] == '1' ? 1 : 0)
m_l = (X[N-1] == '1' ? 1 : 0)
(0..(N-2)).reverse_each{|n|
  t[0][n] = (t[0][n+1] << 1) % h
  t[1][n] = (t[1][n+1] << 1) % l
  if X[n] == '1' then
    m_h = (m_h + t[0][n]) % h
    m_l = (m_l + t[1][n]) % l
  end
}
m_l += l

(0...N).each{|n|
  if X[n] == '1' then
    if c == 1 then
      puts 0
    else
      puts cnt((m_l - t[1][n]) % l, 1)
    end
  else
    puts cnt((m_h + t[0][n]) % h, 1)
  end
}


Measured memory_bytes: 35240
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int ans;

        if (x >= y) {
            System.out.println(10);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a = N / 1000;
  int b = (N % 1000) / 100;
  int c = ((N % 1000) % 100) / 10;
  int d = (((N % 1000) % 100) % 10);
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

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

  if (k == 1) {
    outl(0);
  } else {
    outl(n - k);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int n, m, ans, f[2][188][188][188], g[188][188][188];
char s[188][188];

void gaotra(int f[188][188][188],int ff[188][188][188]){
    for (int l=0;l<=n;++l)
        for (int i=1;i+l<=n;++i){
            int j=i+l;
            for (int k=m;k>=1;--k){
                int t1=0, t2=0;
                {
                    int to=f[i][j][k];
                    t1= to==m+1? m+1: f[i][j][to];
                }
                if (j-i+1>=2){
                    if (j-i+1==2){
                        g[i][j][k]=i;
                        t2= min(f[i][i][k],f[i+1][j][k]);
                    }else{
                        for (int s=g[i][j-1][k];s<=g[i+1][j][k];++s){
                            int tmp=min(f[i][s][k],f[s+1][j][k]);
                            if (tmp>t2) t2=tmp, g[i][j][k]=s;
                        }
                    }
                }
                ff[i][j][k]=max(max(t1,t2),f[i][j][k]);
            }
        }
}

void gaofir(int f[188][188][188]){
    for (int l=0;l<=n;++l)
        for (int i=1;i+l<=n;++i){
            int j=i+l;
            for (int k=m;k>=1;--k){
                if (j-i+1==1){
                    f[i][j][k]= s[i][k]==s[i][k+1]? f[i][j][k+1]: k+1;
                }else{
                    f[i][j][k]= s[i][k]==s[j][k]? min(f[i][j-1][k],f[i+1][j][k]): k;
                }
            }
        }
}

int main(){
    cin>>n>>m;
    for (int i=1;i<=n;++i)
        cin>>s[i]+1;
    gaofir(f[0]);
    while (1){
        int now=ans%2, nex=(ans+1)%2;
        if (f[now][1][n][1]==m+1){
            cout<<ans<<endl; exit(0);
        }
        ++ans;
        gaotra(f[now],f[nex]);
    }
}

Measured memory_bytes: 77824