akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ab = sorted([[a[i], b[i]] for i in range(n)],key=lambda x:x[1])
    num=131071

    m=num+n
    segtree=[10**9+1]*m
    for i in range(num,m):
        segtree[i] = ab[i - num][0]
    for i in range(num-1,-1,-1):
        j=2*i+1
        if j>=m:
            segtree[i]=10**9+1
        elif j+1>=m:
            segtree[i]=segtree[j]
        else:
            segtree[i] = min(segtree[j], segtree[j + 1])

    #探す
    def search(i, s):
        if i >= num:
            return i - num
        k = 2 * i + 1
        if k+2<=m:
            if segtree[k+1] <= s:
                return search(k+1, s)
        if 2*i+2<=m:
            if segtree[k] <= s:
                return search(k, s)
        return -1
    
    #更新
    def update_good(i, s):
        if segtree[i] > s:
            segtree[i] = s
            update_good((i - 1) // 2, s)
    
    def update_bad(i):
        k=(i - 1) // 2
        if i % 2 == 1:
            if m > i + 1:
                temp=min(segtree[i+1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    update_bad(k)
            else:
                segtree[k] = segtree[i]
                update_bad(k)
        else:
            if i != 0:
                temp=min(segtree[i-1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    update_bad(k)

    cnt = 0
    for i in range(n):
        a,b=ab[i][0],ab[i][1]
        if a > b:
            t = search(0, b)
            if t <= i:
                print("No")
                return 0
            update_good(num + i, a)
            segtree[num + t] = a
            update_bad(num + t)
            ab[i][0], ab[t][0] = ab[t][0], a
            cnt+=1
    if cnt <= n - 2:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, K; cin >> N >> K;
    vector <ll> A(N+1);
    loop(i,1,N+1) cin >> A[i];
    // dp[i][j] - Number of ways to distribute i candies in j children
    vector < vector <ll> > dp(K+1, vector <ll> (N+1));
    vector < vector <ll> > prefixsums(K+1, vector <ll> (N+1, 0));
    loop(j,1,N+1) {
        dp[0][j]=1;
        prefixsums[0][j]=1;
    }
    loop(i,0,K+1) dp[i][0]=0;
    ll mod=1e9+7;
    dp[0][0]=1;
    prefixsums[0][0]=1;
    loop(i,0,K+1) prefixsums[i][0]=1;
    for (int i=1; i<=K; ++i) {
        for (int j=1; j<=N; ++j) {
            dp[i][j]=(prefixsums[max(i, 0)][j-1])%mod;
            if (i-A[j]>0) dp[i][j] = (mod+ dp[i][j] - prefixsums[i-A[j]-1][j-1])%mod;
            prefixsums[i][j] = (prefixsums[i-1][j] + dp[i][j])%mod;
            // cout << i << " " << j << " " << dp[i][j] << " " << prefixsums[i][j] << "\n";
            // If person j receives 0 candies, then i candies are distributed among j-1 people
            // If person j receives 1 candies, then i-1 candies are distributed among j-1 people
            // ...
            // If person j receives A[j] candies, then i-A[j] candies are distributed among j-1 people
            // Let's add all these ways together using prefix sums.
        }
    }
    cout << dp[K][N] << "\n";
    return 0;
}

Measured memory_bytes: 164352
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
    bool is_palindrome(string s)
    {
        string s_copy(s);
        reverse(s.begin(), s.end());

        bool is_palindrome = false;
        if (s == s_copy)
        {
            is_palindrome = true;
        }

        s = s_copy;

        return is_palindrome;
    }

    void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;

        int len_s = s.length();

        bool is_palindrome_full = is_palindrome(s);

        if (!is_palindrome_full)
        {
            out << "No";
        }
        else
        {
            bool is_palindrome_left = is_palindrome(s.substr(0, (len_s - 1) / 2));

            if (!is_palindrome_left)
            {
                out << "No";
            }
            else
            {
                int start_i = (((len_s + 3) / 2) - 1);
                int len_sub = len_s - start_i;
                bool is_palindrome_right = is_palindrome(s.substr(start_i, len_s));

                if (!is_palindrome_right)
                {
                    out << "No";
                }
                else
                {
                    out << "Yes";
                }
            }
        }
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> problems;
vector<int> bonus;

int solve(const int bits, const int D, const ll G) {
    ll score = 0;
    int ans = 0;
    priority_queue<int> que;
    for (int i = 0; i < D; i++) {
        if (bits & (1 << i)) {
            score += (i + 1) * 100 * problems[i];
            score += bonus[i];
            ans += problems[i];
        } else {
            for (int j = 0; j < max(0, problems[i] - 1); j++) {
                que.push((i + 1) * 100);
            }
        }
    }

    while (!que.empty() && score < G) {
        auto v = que.top();
        que.pop();
        score += v;
        ans++;
    }

    if (score < G) {
        return -1;
    } else {
        return ans;
    }
}

int main(void) {
    int D;
    ll G;
    cin >> D >> G;

    problems.resize(D);
    bonus.resize(D);
    for (int i = 0; i < D; i++) {
        cin >> problems[i] >> bonus[i];
    }

    int ans = INT_MAX / 2;

    for (int bits = 0; bits < (1 << D); bits++) {
        int cand = solve(bits, D, G);
        if (cand >= 0) {
            // printf("bits: %x, required: %d\n", bits, cand);
            chmin(ans, cand);
        }
    }

    cout << ans << endl;

    return 0;
}


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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 0.8e5);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M;
	cin >> N;

	map<int, int> m;
	for(int i = 0; i < N; i++){
		int D;
		cin >> D;
		m[D]++;
	}

	cin >> M;
	for(int i = 0; i < M; i++){
		int T;
		cin >> T;
		if(!m.count(T) || m[T] == 0){
			cout << "NO" << endl;
			return 0;
		}
		m[T]--;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 9600
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {

	var A = sc.nextInt();
	var B = sc.nextInt();
	var C = sc.nextInt();
	var D = sc.nextInt();
	
	var plrs = [{ pw : A , atk : B}, { pw : C , atk : D }];
	var is0Win = false;
	
	for (var i = 0; i < 1000000; i++) {
		var akter = i % 2;
		var dfer = (akter == 0) ? 1 : 0;
		plrs[dfer].pw -= plrs[akter].atk;
		if (plrs[dfer].pw <= 0) {
			is0Win = (dfer == 1) ? true : false;
			break;
		}
	}
	 
	console.log((is0Win) ? "Yes" : "No");
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


Measured memory_bytes: 29540
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;

int main() {
	
	int n,k;
	cin >> n >> k;
	vi h(n + 1000);
	vl dp(n + 1000, LINF);
	rep(n) { cin >> h[i]; }
	dp[0] = 0;
	rep(n) {
		for(int j=0;j<=k;j++)
		chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
		

	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)))
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int n,m,cnt;
int w[100000];
int r[100000];
vi c[100000];
ll ans;
vi remain;
/*---main code---*/

int root(int x)
{
	if(r[x]!=x)
	{
		r[x]=root(r[x]);
	}
	return r[x];
}

bool unite(int x,int y)
{
	x=root(x),y=root(y);
	if(x!=y)
	{
		r[y]=x;
		return 1;
	}
	return 0;
}

int main()
{
	FIO;
	cin>>n>>m;
	cnt=n;
	for(int i=0;i<n;i++)
	{
		r[i]=i;
		cin>>w[i];
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		if(unite(x,y))
		{
			cnt--;
		}
	}
	if(cnt==1)
	{
		cout<<"0\n";
		exit(0);
	}
	for(int i=0;i<n;i++)
	{
		c[root(i)].push_back(w[i]);
	}
	int use=(cnt-1)*2;
	for(int i=0;i<n;i++)
	{
		if(c[i].empty())
		{
			continue;
		}
		sort(ALL(c[i]));
		ans+=c[i][0];
		use--;
		for(int j=1;j<c[i].size();j++)
		{
			remain.push_back(c[i][j]);
		}
	}
	if(use>remain.size())
	{
		cout<<"Impossible\n";
		exit(0);
	}
	sort(ALL(remain));
	for(int i=0;i<use;i++)
	{
		ans+=remain[i];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
    int n;
    while(cin>>n&&n){
        int ans = INF;
        vector<int> a(n);
        rep(i,n)cin>>a[i];
        rep(i,a.size()){
            rep(j,a.size()){
                if(i==j)continue;
                ans = min(ans,abs(a[i]-a[j]));
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  int ans = n / 2;
  if (n % 2) {
    ans++;
  }

  cout << ans << ln;

  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 1e5 + 3; 
int N;
LL A[MC],B[MC];
LL C[2*MC];
int r[2*MC];
bool f[MC];

int main(){
	cin >> N;
	repp(i,0,N){
		cin >> A[i] >> B[i];
		C[i*2] = A[i];
		C[i*2+1] = B[i];
		r[i*2] = i*2;
		r[i*2+1] = i*2+1;
	}
	sort(r,r+2*N,[&](const int &x, const int &y){return C[x] < C[y];});
	bool p = 0;
	int q[2] = {0,0};
	LL ans = 0;
	repp(i,0,N){
		ans += C[r[i]];
		if(f[r[i]/2]) p = 1;
		f[r[i]/2] = 1;
		++q[r[i]%2];
	}
	if(!p && q[0] && q[1]){
		if(r[N]/2 == r[N-1]/2 && q[r[N-1]%2] != 1){
			ans += min(C[r[N+1]] - C[r[N-1]], C[r[N]] - C[r[N-2]]);
		}
		else ans += C[r[N]] - C[r[N-1]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    string s; cin >> s;

    vector<int> ans;

    int i = n;
    while(i > 0) {
        if (i <= m) {
            ans.push_back(i);
            i = 0;
            break;
        }
        int j = m;
        while(j > 0) {
            if (s[i-j] == '0') {
                ans.push_back(j);
                i -= j;
                break;
            }
            j--;
        }
        if (j == 0) {
            OUT(-1)
            return 0;
        }
    }

    reverse(ALL(ans));

    REP(i,ans.size()) cout << ans[i] << " ";

    return 0;
}

Measured memory_bytes: 1096
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;

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

int main() { 
	ios::sync_with_stdio(false); cin.tie(0); 
	string s; cin >> s; 
	cout << s.substr( 0 , 4 ) << " " << s.substr( 4 , 8 ) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  int i=0;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    if(i%2==0)  c-=b;
    else        a-=d;
    i++;
  }
  if(a<=0) cout<<"No"<<endl;
  else     cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int a,b;
    string s;
    cin>>a>>s>>b;
    if(s=="+") cout<<a+b<<endl;
    else cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
//==================================================================//

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
//=================================================================//

	int n;
	cin >> n;
	string s; cin >> s;
	int cnt = 0;
	for1(i, 0, n - 2) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			cnt++;
		}
	}
	cout << cnt << endl;
}








Measured memory_bytes: 3648
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f k p = (k-1) `mod` p + 1

main = getInt >>= flip replicateM getInts >>= mapM_ (print . apply2 f)


Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	if(s[1]=='B') s[1]='R';
	else s[1]='B';
	cout<<s<<endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <string>
using namespace std;

string s;
char t[1000000];
int l;

int main(){
	scanf("%s", t);
	s = t;
	l = 1;
	for(int i=1; i<s.size(); i++){
		if(s[i] != s[i-1]) l++;
	}
	printf("%d\n", l-1);
	return 0;
}

Measured memory_bytes: 384
n,m = map(int, input().split())
a = list(map(lambda x:int(x)*(-1), input().split()))
import heapq
heapq.heapify(a)
for _ in range(m):
    num = heapq.heappop(a)
    heapq.heappush(a,(-num//2)*(-1))
print(-sum(a))

Measured memory_bytes: 20376
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    int n; scanf("%d", &n);
    int cur=1;
    LL ans=0;
    repn(i, n) {
        int x; scanf("%d", &x);
        if(x==cur) {
            ++cur; continue;
        }
        ans+=(x-1)/cur;
        if(cur==1) ++cur;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    long ans = 0;
    for (int i = 0; i < pow(2, S.length() - 1); i++)
    {
        vector<int> plus;
        plus.push_back(0);
        for (int j = 0; j < S.length() - 1; j++)
        {
            if ((i >> j) & 1)
            {
                plus.push_back(j + 1);
            }
        }
        for (int j = 0; j < plus.size() - 1; j++)
        {
            ans += stol(S.substr(plus[j], plus[j + 1] - plus[j]));
        }
        ans += stol(S.substr(plus[plus.size()-1], S.length()-plus[plus.size()-1]));
    }
    cout << ans << endl;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll L, R;
ll ret = 0;
vector<ll> que;
priority_queue<ll, vector<ll>, greater<ll>> rem;

void input() {
  IN(L);
  IN(R);
}

void solve() {
  if (R-L >= 2019) {
    ret = 0;
  } else {
    ll r;
    FOR(i, L, R+1) {
      r = i % 2019;
      que.pb(r);
    }

    for(auto itr1 = que.begin(); itr1 != que.end(); itr1++) {
      for(auto itr2 = next(itr1); itr2 != que.end(); itr2++) {
        r = ((*itr1)*(*itr2))%2019;
        // DEBUG(*itr1);
        // DEBUG(*itr2);
        // DEBUG(r);
        // LN();
        rem.push(r);
      }
    }
    ret = rem.top();
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 17276
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import Text.Printf

readInt = ( readLn :: IO Int )
getInts = map ( read :: String -> Int ) . words <$> getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, a, b ] <- getInts
	print $ min ( n * a ) b


Measured memory_bytes: 508
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;  scanf("%d %d", &a,&b);
  if (a<b)
    printf ("a < b\n");
else if (a>b)
    printf ("a > b\n");
else if (a==b)
    printf ("a == b\n");
else
    printf ("none\n");
return 0;
  }


Measured memory_bytes: 2048
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9 + 7;
char judge[2];
int main(void) {
	cin >> judge[0] >> judge[1];
	if (judge[0] == judge[1])ct("H");
	else ct("D");
	return 0;
}

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

int main() {
    vector<string> row(3);
    for (int i = 0; i < 3; i++) {
        cin >> row[i];
    }

    cout << row[0][0];
    cout << row[1][1];
    cout << row[2][2];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<tuple>
#include<vector>
#include<algorithm>
using namespace std;
// ------ Class ------ //
class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
//-----------------Code--------------------
vector<tuple<int, int, int>>tup;
int n, m;
int main() {
	while (true) {
		tup.clear();
		cin >> n >> m; if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int a; cin >> a; if (a >= 1)tup.push_back(make_tuple(a, i, n + j));
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				int a; cin >> a; if (a >= 1) tup.push_back(make_tuple(a, n + i, n + j));
			}
		}
		sort(tup.begin(), tup.end()); UnionFind UF(n + m);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				UF.unite(i, j);
			}
		}
		int cnt = 0, G = 0;
		for (int i = 0; i < tup.size(); i++) {
			int a1 = get<1>(tup[i]), a2 = get<2>(tup[i]);
			if (UF.same(a1, a2) == false) {
				UF.unite(a1, a2); cnt += get<0>(tup[i]); G++;
			}
			if (G == m)break;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            int[] time = new int[5];
            int last = 10;
            int last_number = -1;
            for(int i=0; i<5; i++)
            {
                time[i] = int.Parse(Console.ReadLine());
                if((time[i] % 10) < last && (time[i] % 10) != 0)
                {
                    last = time[i] % 10;
                    last_number = i;
                }
            }
            int res = 0;
            for(int i=0; i<5; i++)
            {
                if(i != last_number)
                {
                    if(time[i] % 10 == 0)
                    {
                        res = res + time[i];
                    }
                    else
                    {
                        res = res + time[i] + (10 - time[i] % 10);
                    }

                }
                else
                {
                    res = res + time[i];
                }
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
typedef long long ll;  

using namespace std;

int main()
{
    long long n;
    cin>>n; 
    ll minval = LONG_MAX; 
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(n/i + i -2 <minval)
            {
                minval= n/i +i -2; 
            }
        }
    }
    cout<<minval<<endl; 

    return 0; 
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

int main(){
	int N, D;
	cin>>N>>D;
	int NUM[N][D];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin>>NUM[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
          if(i != j){
			double sum = 0.0;
			for(int k = 0; k < D; k++){
				sum += ((double)NUM[i][k] - (double)NUM[j][k])*((double)NUM[i][k] - (double)NUM[j][k])* 1.0;
				//cout<<sum<<endl;
			}
			sum = sqrt(sum);
			if(sum == (int)sum)ans++;
		}
	}
    }
	cout<<ans/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;
 
 
int main() {
    int n; cin >> n;
    V<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
 
    V<int> dp(n + 1, INT_INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i]);
        if(1 < i){
            dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i]);
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
NMX = list(int(i) for i in input().split())
A = list(int(i) for i in input().split())
ans0 = 0
ansN = 0
for j in range(0, NMX[2]):
    if j in A:
        ans0 += 1
for j in range(NMX[2], NMX[0]):
    if j in A:
        ansN += 1
anslist = [ans0, ansN]
ans = min(anslist)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n, m := nextInt(), nextInt()
	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		sum += a[i]
	}

	line := sum / (4 * m)
	if sum%(4*m) != 0 {
		line += 1
	}
	x := 0
	for i := 0; i < n; i++ {
		if a[i] >= line {
			x++
		}

		if x >= m {
			fmt.Fprint(out, "Yes")
			return
		}
	}
	fmt.Fprint(out, "No")
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

using ll = long long;

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    //for_each(a.begin(), a.end(), [](int v){cout << v << " ";}); cout << endl;
    
    vector<ll> a_of(n);
    for (int i = 0; i < n; i++) {
        a_of.at(i) = a.at(i);
    }
    
    auto is_ok = [&](int idx){
        ll sum = m * v;
        vector<pair<ll, int>> b(n);
        for (int i = 0; i < n; i++) {
            b.at(i) = make_pair(a.at(i), i);
        }
        b.at(idx).first += m;
        sum -= m;

        sort(b.begin(), b.end());

        int next_idx = -1;
        for (int i = n - 1; i >= 0; i--) {
            if (b.at(i).first == a.at(idx) + m) {
                next_idx = i;
                break;
            }
        }

        for (int i = next_idx + 1; i < n; i++) {
            ll d = min(m, sum);
            b.at(i).first += d;
            sum -= d;
        }
        
        for (int i = 0; i < next_idx; i++) {
            ll d = min(sum, min(m, b.at(next_idx).first - b.at(i).first));
            b.at(i).first += d;
            sum -= d;
        }
        
        for (int i = next_idx - 1; i >= 0; i--) {
            ll d = min(m - (b.at(i).first - a_of.at(b.at(i).second)), sum);
            b.at(i).first += d;
            sum -= d;
        }

        sort(b.begin(), b.end());
        //for_each(b.begin(), b.end(), [](int v){cout << v << " ";}); cout << endl;
        
        int cnt = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (b.at(i).first == a.at(idx) + m) break;
            cnt++;
        }
        
        return cnt + 1 <= p;
    };

    int ng = -1;
    int ok = (int)a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (is_ok(mid)) {
            ok = mid;
            //cout << "true: " << mid << endl;
        }
        else {
            ng = mid;
            //cout << "false: " << mid << endl;
        }
    }
    cout << n - ok << endl;
}

Measured memory_bytes: 3428
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;
int n, k, q;
int a[N];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k >> q;
	for(int i = 1 ; i <= q ; i ++){
		int x;
		cin >> x;
		a[x] ++;
		
	}
	for(int i = 1 ; i <= n ; i ++){
		//cin >> a[i];
		cout << (k - (q - a[i]) <= 0 ? "No" : "Yes") << endl;
	}
}


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

const int MOD = 1000000007;
int dp[1010][1010];

int main() {
  string s, t; cin >> s >> t;
  int N = s.length(), M = t.length();

  dp[0][0] = 1;
  for(int i=0; i<N; i++) {
    for(int j=0; j<M; j++) {
      (dp[i+1][j] += dp[i][j]) %= MOD;
      if(s[i] == t[j]) {
        (dp[i+1][j+1] += dp[i][j]) %= MOD;
      }
    }
  }

  int ans = 0;
  for(int i=0; i<=N; i++) {
    (ans += dp[i][M]) %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 7100
student = [0 for i in range(31)]

for i in range(28):
    a = int(input())
    student[a] += 1

absent = []

for i in range(1, 31):
    if student[i] == 0:
        absent.append(i)

sort_absent = sorted(absent)

print("{}\n{}".format(sort_absent[0], sort_absent[1]))

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    string s;
    cin1(s);
    lli len = s.length();
    if (len == 2) {
        cout << "1 1" << endl;
        return 0;
    }
    lli ans[len] = {0};

    vector<lli> rl_inds_r;
    vector<lli> rl_inds_l;
    REP(i, 0, len-1) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            rl_inds_r.push_back(i);
            rl_inds_l.push_back(-(i+1));
        }
    }
    sort(rl_inds_l.begin(), rl_inds_l.end());

    REP(i, 0, len) {
        if (s[i] == 'R') {
            // rl のやつか？
            if (binary_search(rl_inds_r.begin(), rl_inds_r.end(), i)) {
                ans[i]++;
            }
            else {
                auto it = upper_bound(rl_inds_r.begin(), rl_inds_r.end(), i);
                lli ind = *it;
                if ((ind - i) % 2 == 0) {
                    ans[ind]++;
                }
                else {
                    ans[ind+1]++;
                }
            }


        }
        else {
            if (binary_search(rl_inds_l.begin(), rl_inds_l.end(), -i)) {
                ans[i]++;
            }
            else {
                auto it = upper_bound(rl_inds_l.begin(), rl_inds_l.end(), -i);
                lli ind = -(*it);
                if ((i - ind) % 2 == 0) {
                    ans[ind]++;
                }
                else {
                    ans[ind-1]++;
                }
            }
        }
    }
    REP(i, 0, len) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2420
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN = 110;
#define _clr(x) memset(x, 0xff, sizeof(int) * MAXN)
int ax[MAXN],ay[MAXN],bx[MAXN],by[MAXN],m1[MAXN],m2[MAXN],n;
bool mp[MAXN][MAXN];
int hungary(int n, int m, const bool mat[][MAXN], int * match1, int * match2) {
    int s[MAXN + 1], t[MAXN], p, q, ret = 0, i, j, k;
    _clr(match1);
    _clr(match2);
    for (i = 0; i < n; ret += (match1[i++] >= 0)) {
        _clr(t);
        for (s[p = q = 0] = i; p <= q && match1[i] < 0; p++) {
            k = s[p];
            for (j = 0; j < m && match1[i] < 0; j++) {
                if (mat[k][j] && t[j] < 0) {
                    s[++q] = match2[j];
                    t[j] = k;
                    if (s[q] < 0) {
                        for (p = j; p >= 0; j = p) {
                            match2[j] = k = t[j];
                            p = match1[k];
                            match1[k] = j;
                        }
                    }
                }
            }
        }
    }
    return ret;
}
 
int main () {
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d%d",&ax[i],&ay[i]);
    for (int i=1;i<=n;i++) scanf("%d%d",&bx[i],&by[i]);
    for (int i=1;i<=n;i++) 
        for (int j=1;j<=n;j++) if (ax[i]<bx[j]&&ay[i]<by[j]) mp[i-1][j-1]=1;
    printf("%d\n",hungary(n,n,mp,m1,m2));
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = long double;
using Point = complex<ld>;
using Set = vector<Point>;
const ld pi = acos(-1);
constexpr ld eps = 1e-10;
constexpr ld inf = 1e12;

ld cross(const Point& a, const Point& b){
    return a.real() * b.imag() - a.imag() * b.real();
}

ld dot(const Point& a, const Point& b){
    return a.real() * b.real() + a.imag() * b.imag();
}

// 象限を返す (推移率を成立させるために、原点は 0 象限とする)
int get_orthant(const Point& p){
    if(abs(p.real()) < eps && abs(p.imag()) < eps)  return 0;
    if(p.imag() > 0)    return p.real() > 0 ? 1 : 2;
    return p.real() > 0 ? 4 : 3;
}

// 偏角ソート用比較関数 (arg や atan2 での誤差が怖い場合に用いる)
// 第 1 象限から第 4 象限にかけて、偏角の小さい順にソートする。
bool arg_comp(const Point& p1, const Point& p2){
    int ort1 = get_orthant(p1), ort2 = get_orthant(p2);
    if(ort1 != ort2)    return ort1 < ort2;
    return cross(p1, p2) > 0;
}

istream& operator>>(istream& is, Point& p){
    ld x, y;
    is >> x >> y;
    p = Point(x, y);
    return is;
}
ostream& operator<<(ostream& os, const Point& p){
    return os << p.real() << ' ' << p.imag() << '\n';
}

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

    int n;
    cin >> n;
    Set ps(n);
    for(int i = 0; i < n; ++i)  cin >> ps[i];
    sort(ps.begin(), ps.end(), arg_comp);
    ld ans = 0.0;
    for(int k = 1; k <= n; ++k){
        for(int i = 0; i < n; ++i){
            Point p = ps[i];
            for(int j = 1; j < k; ++j){
                p += ps[(i + j) % n];
            }
            chmax(ans, abs(p));
        }
    }
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
	int n;
	string s;
	int rc=0,bc=0;

	cin>>n;
	cin>>s;

	for(int i=0;i<n;i++){
		if(s[i]=='R') rc++;
		if(s[i]=='B') bc++;
	}

	if(rc>bc) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;

class C{
  public static void Main(){
	int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int A = Ar[0], B = Ar[1], H = Ar[2], M = Ar[3];
    double shortr = 30 * H;
    shortr += M * 0.5;
    double longr = 6 * M;
    double abs = Math.Abs(longr - shortr);
    double min = Math.Min(abs, 360 - abs);
    double aji = (A * A) + (B * B);
    decimal minus = ((decimal)Math.Cos(min * (Math.PI / 180))* 2 * B * A);
    double ans = Math.Sqrt(aji - (double)minus);
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 27856
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  char c;

  std::cin >> c;

  std::cout << ('A' <= c && c <= 'Z' ? 'A' : 'a') << std::endl;

  return 0;
}


Measured memory_bytes: 3644
def main():
    N = int(input())
    d = [0 for _ in range(N)]
    r = 100
    ii = 0
    for i in range(1, r):
        ii += 2* i - 1
        for j in range(1, i + 1):
            s = i + j
            c = ii + s * j
            l = 6
            if i == j:
                l = 3
            if c + 1 + s > N:
                break
            for k in range(1, j + 1):
                c += 2* k - 1 + s
                if c <= N:
                    if j == k:
                        l = 3
                        if i == k:
                            l = 1
                    d[c - 1] += l
                else:
                    break
                    
    print("\n".join(map(str,d)))


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<double> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  vector<double> CS(N + 1, 0);
  for (int i = 0; i < N; i++) {
    CS[i + 1] = CS[i] + (1 + P[i]) / 2;
  }
  double res = 0;
  for (int i = 0; i + K < N + 1; i++) {
    res = max(res, CS[i + K] - CS[i]);
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


Measured memory_bytes: 3328