akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 1e5;
int n, k, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    int h;
    cin >> h;
    c += h >= k;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

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

int main(){
    int n, player[10], field;

    while(std::cin >> n, n){
        std::string cards;
        std::cin >> cards;
    
        std::fill(player, player+n, 0);
        field = 0;

        REP(i, 100){
            int turn = i % n;
            char card = cards[i];
            if(card == 'M'){
                player[turn]++;
            }else if(card == 'S'){
                field += player[turn] + 1;
                player[turn] = 0;
            }else{
                player[turn] += field + 1;
                field = 0;
            }
        }

        std::sort(player, player+n);

        REP(i, n){
            std::cout << player[i] << " ";
        }
        std::cout << field << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
	
ll mod = 1e9 + 7;
 
int main(){
	ll n; cin >> n;
    ll dp[n + 1] = {0};
    dp[0] = 1;
    for(ll i = 3; i <= n; ++i){
        for(ll j = 3; j <= n; ++j){
            if(i - j >= 0){
                dp[i] += dp[i - j];
                dp[i] %= mod;
            }
        }
    } 
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

int dp[101][4][4][4];

int main() {
    int n;
    cin >> n;
    int mod = 1e9+7;

    dp[0][3][3][3] = 1;
    //   0 1 2 = A G C
    //   1 0 2
    //   0 2 1
    // 0 1 ? 2
    // 0 ? 1 2
    // j k l m
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    if (dp[i][j][k][l] == 0) continue;
                    for (int m = 0; m < 4; m++) {
                        if (k == 0 && l == 1 && m == 2) continue;
                        if (k == 1 && l == 0 && m == 2) continue;
                        if (k == 0 && l == 2 && m == 1) continue;
                        if (j == 0 && k == 1 && m == 2) continue;
                        if (j == 0 && l == 1 && m == 2) continue;
                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                ans += dp[n][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
Ns = input()
N = int(Ns)
Nl = len(Ns)
ret = []
def doit(t, f , s, now):
    if t + f + s == 0:
        if int(now) <= N:
            ret.append(now)
        return
    if t > 0:
        doit(t - 1, f, s, now + str(3)) 
    if f > 0:
        doit(t, f - 1, s, now + str(5)) 
    if s > 0:
        doit(t, f, s - 1, now + str(7)) 
    
for seven in range(1, Nl - 1):
    for five in range(1, Nl - seven):
        least = Nl - seven - five
        for three in range(1, least + 1):
            doit(three, five, seven, '')

print(len(ret))


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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 2e5 + 100;
const ll mod = 1e9;
signed main(){
	int c;
	cin >> c;
	cout << (c+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    vector<ll> a(n),c(60);
    for(int i=0;i<n;i++){
        cin >> a[i];
        for(int j=0;j<60;j++){
            if(a[i]&(1LL<<j)){
                c[j]++;
            }
        }
    }
    ll ans=0;
    for(int j=0;j<60;j++){
        ll t=(1LL<<j)%mod;
        (ans+=t*c[j]%mod*(n-c[j])%mod)%=mod;
    }
    cout << ans << endl;
}

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

int main()
{
	int N, D, X;
	scanf("%d", &N);
	scanf("%d%d", &D, &X);
	int A[N];
	int i, j, k;
	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	int num = 0;
	for (i = 0; i < N; i++) {
		for (j = 0; j < D; j += A[i])
			num += 1;
//		printf("i: %d, num: %d\n", i, num);
	}

	printf("%d\n", num + X);

	return 0;
}


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

int main(){
	const int INF = 10000;
	ll l,r;
	cin >> l >> r;
	
	if(r-l >= 2018){
		l = 0;
		r = 2018;
	} else{
		l %= 2019;
		r %= 2019;
		if(l > r) swap(l,r);
	}

	
	int min = INF;
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			if( min > (i*j)%2019 ) min = (i*j)%2019;
		}
	}
	
	cout << min << endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b, q;
	cin >>a >>b >>q;
	VL s(a+2), t(b+2), x(q);
	rep(i, a) cin >>s[i+1];
	rep(i, b) cin >>t[i+1];
	rep(i, q) cin >>x[i];
	s[0] = t[0] = -1LL<<55;
	s[a+1] = t[b+1] = 1LL<<55;

	auto zfc=[&](int i, VL& s, VL& t) ->ll{
		ll ans = 1LL<<60;
		int p1 = lower_bound(all(s), x[i]) - s.begin();
		int p2 = lower_bound(all(t), s[p1]) - t.begin();
		ll ds = abs(s[p1] - x[i]) + abs(t[p2]-s[p1]);
		ans = min(ans, ds);
		if(p2 > 0) ans = min(ans, abs(s[p1] - x[i]) + abs(t[p2-1]-s[p1]));
		if(p1 > 0){
			p1--;
			p2 = lower_bound(all(t), s[p1]) - t.begin();
			ans = min(ans, abs(s[p1] - x[i]) + abs(t[p2]-s[p1]));
			if(p2 > 0) ans = min(ans, abs(s[p1] - x[i]) + abs(t[p2-1]-s[p1]));
		}
		return ans;
	};


	rep(i, q){
		ll ans = min(zfc(i, s, t), zfc(i, t, s));
		cout << ans <<"\n";
	}
	return 0;
}


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

using namespace std;
int main(){
    char s[3];
    char t[3];
    int count = 0;
    for(int i = 0; i < 3; i++){
        cin >> s[i];
    }
    for(int i = 0; i < 3; i++){
        cin >> t[i];
    }
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) count++;
    }
    cout << count;
    
}

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


int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (A > 0 && C > 0) {
        C -= B;
        if (C <= 0) break;
        A -= D;
    }

    if (A <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

const int INF = 10000000;
int n, ma, mb;
int a[45], b[45], c[45];
int dp[45][405][405];

int rec(int i, int  A, int B){
    if (dp[i][A][B] > 0){
        return dp[i][A][B];
    }

    if (A > 0 && B > 0 && ma*B == mb*A){
        return dp[i][A][B] = 0;
    }

    if (i == n){
        return INF;
    }

    int ret = INF;
    ret = min(ret, rec(i + 1, A, B));

    ret = min(ret, c[i] + rec(i + 1, A + a[i], B + b[i]));
    

    return dp[i][A][B] = ret;
    
}

int main(void){
   
    cin >> n >> ma >> mb;

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

    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                dp[i][j][k] = -1;
            }
        }
    }

    int ans = rec(0, 0, 0);
    
    if (ans >= INF){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
    
}

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

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = input[0];
            var m = input[1];
            var list1 = Enumerable.Repeat(0, m).ToArray();

            for(int i = 0; i < n; i++) {
                var list2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Skip(1).ToArray();
                foreach(var j in list2) {
                    list1[j - 1]++;
                }
            }

            var count = 0;
            foreach(var foodNum in list1) {
                if(foodNum == n) {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13396
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X=gets.to_i
if X>=30
    puts "Yes"
else
    puts "No"
end

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

int main(){
    int a[5];
    rep(i,5){
        cin >> a[i];
    }
    int k; cin >> k;
    rep(i,5){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll x;
    cin >> N >> x;
    vll A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;

    vll B(N - 1);
    rep(i, N - 1) {
        B[i] = A[i] +A[i + 1];
    }


    rep(i, N - 2) {
        ll sub = max(0LL, B[i] - x);
        ans += sub;
        B[i + 1] -= min(A[i + 1], sub);

    }
    ans += max(0LL, B[N - 2] - x);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

int main()
{
    fastio;

    char a;
    cin >> a;

    if(a=='A')
    {
        cout << "T\n";
    }
    else if(a=='T')
    {
        cout << "A\n";
    }
    if(a=='G')
    {
        cout << "C\n";
    }
    if(a=='C')
    {
        cout << "G\n";
    }

    return 0;
}




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

using namespace std;

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

int main() {
  int H, W;
  cin >> H >> W;
  
  rep(i, W+2){
    cout << '#';
  }
  cout << endl;
  rep(i, H){
    cout << '#';
    rep(j, W){
      char c;
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }
  rep(i, W+2){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
    static void Main() {
        int a = 0, b = 0;
        int n = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++) {
            string[] stdin = Console.ReadLine().Split();
            if(stdin[0].CompareTo(stdin[1]) < 0) b += 3;
            else if(stdin[0].CompareTo(stdin[1]) > 0) a += 3;
            else {
                a++;
                b++;
            }
        }
        Console.WriteLine("{0} {1}", a, b);
    }
}


Measured memory_bytes: 16756
#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>;
const int INF = numeric_limits<int>::max();

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind(int n) {
        par.assign(n, 0);
        iota(par.begin(), par.end(), 0);
        rank.assign(n, 0);
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
};

int main()
{
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind road(n);
    UnionFind rail(n);
    rep(i, k) {
        int p, q;
        cin >> p >> q;
        road.unite(p - 1, q - 1);
    }
    rep(i, l) {
        int r, s;
        cin >> r >> s;
        rail.unite(r - 1, s - 1);
    }
    map<P, int> count;
    for (int i = 0; i < n; i++) {
        count[P(road.find(i), rail.find(i))]++;
    }
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << count[P(road.find(i), rail.find(i))];
    }
    cout << endl;
}

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

using namespace std;
int main(){
  double A, B, H, M, X, Y;
  cin >> A >> B >> H >> M;
  Y = (M/360) * 11;
  Y = Y - H/6;
  X = A*A + B*B - 2*A*B*cos(M_PI*Y);
  X = pow(X, 0.5);

  cout << fixed << setprecision(10) << X <<endl;
}


Measured memory_bytes: 4344
#include <iostream>

using namespace std;

int main(){
    long N, K;
    cin >> N >> K;

    long mod0Count = 0, bar2Count = 0;
    for(int a = 1; a <= N; a++){
        if(a % K == 0) mod0Count ++;
        if(K % 2 == 0 && a % K == K / 2) bar2Count ++;
    }

    cout << mod0Count*mod0Count*mod0Count + bar2Count*bar2Count*bar2Count << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int N, d, result = 0, sum = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> d;
        if (i > 0) {
            result += sum * d;
        }
        sum += d;
    }
    cout << result;
}

Measured memory_bytes: 256
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
#  Coin Changing Problem : python3
#  2018.12.11 yonezawa

#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile
#from math import cos,sin,radians,sqrt

def Reflection(p1,p2):
    (x,y) = p2
    (tx,ty) = Projection(p1,(x,y))
    rx = (tx - x) * 2 + x 
    ry = (ty - y) * 2 + y
    return (rx,ry)


def solve(cn:int,l:list):
    calc = [[0 for i in range(len(l))] for j in range(cn+1)]
    calc[0][0] = 0

    for i in range(cn+1):
        calc[i][0] = i // l[0] if i % l[0] == 0 else (i // l[0]) + 1

    for j in range(1,len(l)):
        for i in range(cn+1):
            if i-l[j] >= 0:
                calc[i][j] = min(calc[i][j-1],calc[i-l[j]][j]+1)
            else:
                calc[i][j] = calc[i][j-1]
    print (calc[cn][j])
    return 0

def main():
    (cn,n) = map(int,input().split())
    l = list(map(int,input().split()))

    solve(cn,l)
    
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
// #define MOD 998244353
#define VL vector<ll>

vector<ll> dx = {-1, 1, 0,  0, -1, -1,  1, 1};
vector<ll> dy = { 0, 0, 1, -1, -1,  1, -1, 1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }



template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
/*
WeightedGraph<ll> g(V);
g[a].emplace_back(b, c);
*/
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	ll K;
	string S;
	cin >> K >> S;
	if (S.size() <= K) {
		PRINT(S);
	} else {
		PRINT(S.substr(0, K) + "...");
	}
	return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
output = 0
prev = -1
for i in a:
    output += b[i - 1]
    if prev + 1 == i:
        output += c[prev - 1]
    prev = i
print(output)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),cnt(60);
    ll x = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        x ^= A[i];
    }
    for(int i=0;i<N;i++) A[i] &= ~x;
    int r = 0;
    for(int j=59;j>=0;j--){
        bool ok = false;
        for(int i=r;i<N;i++){
            if(A[i]&(1LL<<j)){
                swap(A[i],A[r]);
                ok = true;
                break;
            }
        }
        if(ok){
            for(int i=0;i<N;i++){
                if((i!=r) && (A[i]&(1LL<<j))) A[i] ^= A[r];
            }
            r++;
        }
    }
    ll ans = 0;
    for(int i=0;i<N;i++) ans = max(ans,ans^A[i]);
    cout << 2*ans+x << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]
    b_list = [int(x) for x in sys.stdin.readline().split()]

    count = 0
    for i in range(N)[::-1]:
        a = a_list[i+1]
        b = b_list[i]
        if a >= b:
            count += b
            continue
        else:
            count += a
            b -= a

            if a_list[i] >= b:
                a_list[i] -= b
                count += b
            else:
                count += a_list[i]
                a_list[i] = 0


    print(count)
            





if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
3 5 2
4 5"""
        output = """9"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3
5 6 3 8
5 100 8"""
        output = """22"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
100 1 1
1 100"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1
1 1
1"""
        output = """1"""
        self.assertIO(input, output)


Measured memory_bytes: 89056
#include <iostream>
#include <queue>
#include <vector>

#define MOD 1000000007
using namespace std;
using Graph = vector<vector<int>>;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N,M;
const int MAXN = 100000;
const int MAXM = 200000;


int main(){

    Graph G(MAXN);
    int N,M;cin >> N >> M;
    vector<int> dist(N+1,-1);
    queue<int> que;
    rep(i,M) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dist[1] = 0;
    que.push(1);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for(int nv: G[v]) {
            if(dist[nv] != -1)continue;
            
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    int ans[MAXN];

    for(int i=2;i<=N;i++) {
        for(int nv: G[i]){
            if(dist[nv] == dist[i] - 1) {
                ans[i] = nv;
            }
        }
    }

    cout << "Yes" << endl;
    for(int i=2;i<=N;i++) {
        cout << ans[i] << endl;
    }

    
    
}

Measured memory_bytes: 10500
n = gets.to_i
s = gets.chomp
need = 0
right = 0
s.chars{|c|
  if c == '('
    right -= 1
  else
    right += 1
  end
  need = [need, right].max
}
need.times {
  s = '(' + s
}
left = 0
right = 0
s.chars{|c|
  if c == '('
    left += 1
  else
    right += 1
  end
}
(left - right).times{
  s = s + ')'
}
puts s



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define MAX 333
#define endl '\n'
#define boost ios_base::sync_with_stdio(0);cin.tie(0)
const int inf=1e15;

int32_t main()
{
    boost;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif // ONLINE_JUDGE

    map<string,int>mp;
    mp["MON"]=1;
    mp["TUE"]=2;
    mp["WED"]=3;
    mp["THU"]=4;
    mp["FRI"]=5;
    mp["SAT"]=6;
    mp["SUN"]=0;

    string s;
    cin>>s;
    cout<<7-mp[s]<<endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int x;
	cin >> x;
	cout << (x == 3 || x == 5 || x == 7 ? "YES" : "NO") << endl;
	return 0;
}
 

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	if((B-A)%2==0) cout<<"Alice"<<endl;
	else cout<<"Borys"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 892
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N, K = map(int,input().split())
P = list(map(int,input().split()))
Q = [(1.0+P[i])/2.0 for i in range(N)]

lst = []
Q.insert(0, 0)
P_cumsum = np.cumsum(Q)

for i in range(N-K+1):
  var = P_cumsum[K+i] - P_cumsum[i]
  lst.append(var)
  
ans = max(lst) * 1.0

print(ans)




Measured memory_bytes: 35788
#include<bits/stdc++.h>
using namespace std;
int dp[1005][1005];
const int MOD = 1000000007;
int main()
{
  int h,w;
  char streat[1005][1005];

  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>streat[i][j];
    }
  }

  dp[1][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(streat[i][j]!='#'){
	dp[i][j]+=dp[i-1][j]%MOD+dp[i][j-1]%MOD;
      }
    }
  }

  cout<<dp[h][w]%MOD<<endl;
  return 0;
}


Measured memory_bytes: 5120
n = gets.to_i
k = gets.to_i

queue = [[1, 0]]
answers = []

until queue.empty?
  sum, count = queue.shift
  if count < n
    queue.push([sum * 2, count + 1])
    queue.push([sum + k, count + 1])
  else
    answers.push(sum)
  end
end

puts answers.min


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

static const int MAX = 90001;
pair<int, int> mat[MAX];

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a;
            cin >> a;
            mat[a] = make_pair(i, j);
        }
    }
    vector<ll> sum(h * w + 1, 0);
    for(int i = 1; i <= d; i++){
        int t = i;
        int prex, prey;
        tie(prex, prey) = mat[i];
        while(t <= h * w){
            int x, y;
            tie(x, y) = mat[t];
            if(t != i) sum[t] = sum[t - d] + abs(x - prex) + abs(y - prey);
            prex = x;
            prey = y;
            t += d;
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
 int K,A,B;
 int ON = 100;
 cin >> K;
 cin >> A >> B;
 for(int i = 0; i < B-A+1; i++){
     if((A+i) % K == 0) {
         ON = 10;
         break;
     }
 }

 if(ON == 10) cout << "OK" << endl;
 if(ON == 100) cout << "NG" << endl;

 return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
ll n,k;
int main(){
    cin>>n>>k;
    vl a(n),s,t;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=0)s.pb(a[i]);
        else t.pb(a[i]);
    }
    ll S=sz(s),T=sz(t);
    bool ok=false;
    if(S>0){
        if(n==k)ok=(T%2==0);
        else ok=true;
    }else{
        ok=(k%2==0);
    }
    mint ans=1;
    if(!ok){
        sort(a.begin(),a.end(),[](int x,int y){
            return abs(x)<abs(y);
        });
        rep(i,k)ans*=a[i];
    }else{
        sort(s.begin(),s.end());
        sort(t.rbegin(),t.rend());
        if(k%2==1){
            ans*=s.back();s.pop_back();
        }
        vl p;
        while(sz(s)>=2){
            ll x=s.back();s.pop_back();
            x*=s.back();s.pop_back();
            p.pb(x);
        }
        while(sz(t)>=2){
            ll x=t.back();t.pop_back();
            x*=t.back();t.pop_back();
            p.pb(x);
        }
        sort(p.rbegin(),p.rend());
        rep(i,k/2)ans*=p[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long K=0;
  map<string,long long>mp;
  cin>>N;
  vector<string>v(N);
  for(int X=0;X<N;X++){
    cin>>v[X];
    sort(v[X].begin(),v[X].end());
    mp[v[X]]++;
  }
  for(auto p:mp){
    auto V=p.second;
    K+=V*(V-1)/2;
  }
  cout<<K<<endl;
}

Measured memory_bytes: 14084
using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()



// vector<bool> visited;
// vector<vl> v;
// ll cnt[2];

// void dfs(ll pnt, ll col) {
// 	visited[pnt] = true;
// 	cnt[col]++;
// 	fr(i, 0, v[pnt].size()) {
// 		if (!visited[v[pnt][i]])dfs(v[pnt][i], !col);
// 	}
// }



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

void solve() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d)));
}






int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	//precompute();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {

		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans =0;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        if(tmp >= k) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int f(int n){ return n%2==0 ? n/2 : 3*n+1; }
int main() {
  int n;
  cin >> n;
  vector<bool> u(100005, false);
  u[n] = true;
  int ans = 2;
  for(n = f(n); !u[n]; n = f(n)) {
    u[n] = true;
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vi dp(1000000,INF);
    dp[0] = 0;
    for(int i=1;i<=100000;i++){
        int power = 1;
        while(i>=power){
            dp[i] = min(dp[i],dp[i-power] + 1);
            power *= 6;
        }
        power = 1;
        while(power<=i){
            dp[i] = min(dp[i],dp[i-power] + 1);
            power *= 9;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4096
/* Author : tushar3105 */

#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;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int t; cin>>t;while(t--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli n, ans=0, r=0;
	char str[210000];
	
	cin>>n;
	cin>>str;
	
	ref(i,0,n-1)
		if (str[i]=='R')
			r++;
	
	ref(i,0,r-1)
		if (str[i]=='W')
			ans++;
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3852
//Sameer's Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define pb push_back
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	int doublet = 0;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		if (x == y)
		{
			doublet++;
		}
		else {
			doublet = 0;
		}
		if (doublet == 3)
		{
			break;
		}
	}
	if (doublet == 3)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    string S;
    cin>>S;
    ll Sz=S.size();
    vector<ll> T(Sz);
    rep(i, Sz){
        T[i]=S.at(i)-'0';
      	//cout<<T[i]<<endl;
    }
    ll Num=pow(2, Sz-1);
  	//cout<<"Num="<<Num<<endl;
    ll Sum=0;
    rep(i, Num){
      	ll Now=i;
        ll Cou=0;
        Sum+=T[Sz-1];
      	//cout<<T[Sz-1]<<endl;
        rep(j, Sz-1){
            if(Now%2==0){
                Cou++;
            }else{
                Cou=0;
            }
            Sum+=T[Sz-2-j]*pow(10, Cou);
          	Now/=2;
          	//cout<<T[Sz-2-j]*pow(10, Cou)<<endl;
        }
      	
    }
    cout<<Sum<<endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
ll tot=0,n,k,num[500005],ok[500005];
const int mod=1000000007;
int f[105][500005];
int main()
{
	ll last;n=read();k=read();
	for(int i=1;i<=n;i=last+1)
	{
		last=n/(n/i);//tot++;
		num[++tot]=last;
	}
	//cout<<tot<<" ";
	//for(int i=1;i<=tot;i++) cout<<num[i]<<" ";
	//f[0][0]=1;
	for(ll j=1;j<=tot;j++) f[1][j]=num[j];
	for(ll i=1;i<=tot;i++)
	{
		ll l=1,r=tot,ans=0;
		while(l<=r)
		{
			ll mid=l+r>>1LL;
			if(1LL*num[mid]*num[i]<=1LL*n)
			{
				ans=mid;
				l=mid+1;
			}
			else r=mid-1;
		}
		ok[i]=ans;
	}
	for(ll i=2;i<=k;i++)
	{
		for(ll j=1;j<=tot;j++)
		{
			f[i][j]+=1LL*f[i-1][ok[j]]*(num[j]-num[j-1])%mod;
			//cout<<f[i][j]<<" ";
		}
		//cout<<endl;
		for(ll j=1;j<=tot;j++)
		{
			f[i][j]+=f[i][j-1];
			if(f[i][j]>=mod) f[i][j]-=mod;
		}
	}
	cout<<f[k][tot];
}


Measured memory_bytes: 199040
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    M, D = mi()
    cnt = 0

    for m in range(1, M+1):
        for d in range(1, D+1):
            if d > 9:
                d1 = int(str(d)[1])
                d10 = int(str(d)[0])

                if d1 >= 2 and d10 >= 2 and d1*d10 == m:
                    cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9516
import java.util.Scanner;

public class Main {

	static int n;
	static int money;
	static int sub[];
	static int total;
	static int dfs[] = new int[1000];
	static int k = 0;
	public static void main(String[] args) {

		Scanner sr = new Scanner(System.in);

		while(true) {
			n = sr.nextInt();
			money = sr.nextInt();
			//System.out.println(money);
			if(n == 0) break;
			sub = new int[n];

			for (int i = 0; i < n; i++) {

				sub[i] = sr.nextInt();
			}
			int max = 0;
			for(int i = 0; i < n; i++) {

				for(int j = i+1; j < n; j++) {
					total = sub[i] + sub[j];
					//System.out.println(total);
					if(max < total) {
						if(total <= money) {
							//System.out.println(total);
							max = total;
						}


					}
				}
			}
			if(max ==0) System.out.println("NONE");
			else System.out.println(max);

		}
	}


}



Measured memory_bytes: 50796
//Name: Thanksgiving
//Level: 2
//Category: 貪欲,Greedy
//Note:

/*
 * 野菜を価格の順に並べたとき、取り除ける個数は floor(n/m) 個で固定であることから、
 * 安いほうから n%m 個までの野菜は取り除いても効率が悪い。
 * したがって、残った n - n%m 個の野菜から floor(n/m) 個を取り除くことになるが、
 * このときもっとも安い野菜は必ず取り除かれることになる。
 * この野菜と一緒に袋に詰められる野菜は可能な限り安いものを使ったほうがよい（なるべく高い野菜を次で消せるようにする）から、
 * 結局貪欲に詰めていけばよい。
 *
 * 高い野菜からm個ずつ選んでいくようにすると楽に書ける。
 *
 * オーダーは O(N log N)。
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool solve() {
    int N, M;
    if(!(cin >> N >> M)) return false;
    if(!N && !M) return false;

    vector<int> ps(N);
    for(int i = 0; i < N; ++i) {
        cin >> ps[i];
    }
    sort(begin(ps), end(ps), greater<int>());

    int ans = 0;
    for(int i = 0; i < N; ++i) {
        if(i % M == M-1) continue;
        ans += ps[i];
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;

    return 0;
}

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


int main()
{
	int n;
	cin >> n;
	map<string, long long> mp;

	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		sort(str.begin(), str.end());

		if(mp.find(str) == mp.end()){
			mp[str] = 1;
		}else{
			mp[str]++;
		}
	}

	long long ans = 0;
	for(auto x: mp){
		ans += (x.second-1)*x.second/2;
	}
	cout << ans << endl;

	return 0;
}

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

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


int nextInt() { int x; scanf("%d", &x); return x;}

const int SIZE = 100000 + 10;
int bin[SIZE];

int main2() {
  int N = nextInt();
  memset(bin, 0, sizeof(bin));
  REP(i, N) {
    int a = nextInt() + 1;
    bin[a-1]++;
    bin[a]++;
    bin[a+1]++;
  }

  int ans = *max_element(bin, bin + SIZE);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 640