akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

int main(){
	ll n,cnt=0,sum=0;
	cin>>n;
	cnt=n/11*2;
	n-=cnt/2*11;
	if(n>6)cnt+=2;
	else if(n>0)cnt++;
	cout<<cnt<<endl;
	return 0;
}

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

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

using ll = long long;
using namespace std;

void
fumi (
    queue<string> & q,
    string          s, // copy
    char            c)
{
    s.push_back(c);
    q.push(s);
}

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

    queue<string> q;
    rep(9, i) {
      q.push(to_string(i + 1));
    }

    int counter = 0;
    for (;;) {
      auto e = q.front();
      q.pop();
      if (++counter == k) {
        cout << e << endl;
        return 0;
      }
      auto last = *e.crbegin();
      if (last != '0')
        fumi(q, e, last - 1);
      if (true)
        fumi(q, e, last);
      if (last != '9')
        fumi(q, e, last + 1);
    }
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables **************/
int a, b, c, d;
/**********************************************/

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

    cin >> a >> b >> c >> d;
    if(abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
    else if(abs(a-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# solution
import io

data = int(input())
if data<105:
  print(0)
elif 104<data<135:
  print(1)
elif 134<data<165:
  print(2)
elif 164<data<189:
  print(3)
elif 188<data<195:
  print(4)
else:
  print(5)

Measured memory_bytes: 3060
{-# LANGUAGE FlexibleContexts, RankNTypes #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import Data.Ord
import Data.Foldable
import Data.Function
import Debug.Trace
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Control.Monad.ST

main :: IO ()
main = readLn >>= readContents . pred >>= printRes . solve 
    where
        printRes = mapM_ print

solve :: [[Int]] -> [Int]
solve uvws = V.toList $ V.create (VM.replicate n (0 :: Int) >>= search)
    where
        n = 1 + length uvws

        g = M.fromList . map (\g -> (fst $ head g, map snd g)) . groupBy ((==) `on` fst) . sortOn fst $ concatMap mf uvws
            where
                mf [u, v, w] = [(u - 1, (v - 1, even w)), (v - 1, (u - 1, even w))]

        search vs = vs <$ loop 0 0 0
            where
                loop p i v = mapM_ (\(j, w) -> VM.unsafeWrite vs j w >> loop i j w) cs
                    where
                        cs = map mf . filter (\(j, _) -> j /= p) $ g M.! i
                        mf (j, b)
                            | b = (j, v)
                            | otherwise = (j, 1 - v)
 

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 124284
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll p){
    ll ans = 1;
    a %= p;
    while (b){
        if (b & 1) ans = (ans * a) % p;
        a = (a * a) % p;
        b >>= 1;
    }
    return (ans % p);
}

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

ll gcd__(ll a, ll b){
    while (b){
        ll c = a;
        a = b;
        b = c % b;
    }
    return a;
}

ll a, b, gcd_, ans;

int main(){
    scanf("%lld%lld", &a, &b);
    ans = 1;
    gcd_ = gcd__(a, b);
    for (ll i = 2; i * i <= gcd_; i ++ ){
        if (gcd_ % i == 0){
            while (gcd_ % i == 0)
                gcd_ /= i;
            ans ++ ;
        }
    }
    if (gcd_ > 1)
        ans ++ ;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
struct xyz{string x;int y;int z;};
bool cmp1(xyz a,xyz b){return a.x<b.x;}

void solve(){
     int n;cin >> n;
     vector<xyz>v;
     for(int i = 0;i<n;i++){
        string s;int c;
        cin >> s >> c;
        v.push_back({s,c,i+1});
     }
     sort(v.begin(),v.end(),cmp1);
     vector< pair<int,int> >ans;
     ans.push_back({v[0].y,v[0].z});
     for(int i = 1;i<n;i++){
        if(v[i].x==v[i-1].x) ans.push_back({v[i].y,v[i].z});
        if(v[i].x!=v[i-1].x){
           sort(ans.rbegin(),ans.rend());
          for(int j = 0;j<ans.size();j++){
            cout << ans[j].second <<endl;
          }
          ans.clear();
          ans.push_back({v[i].y,v[i].z});
        }
     }
     sort(ans.rbegin(),ans.rend());
      for(int j = 0;j<ans.size();j++){
            cout << ans[j].second <<endl;
        }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201402L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, m;
	scanf("%d%d", &n, &m);
	if(n & 1){
		for(int i = 1; i <= m; ++i){
			printf("%d %d\n", i, n - i);
		}
	}
	else{
		for(int i = 0; i < m; ++i){
			printf("%d %d\n", i + 1, i * 4 < n - 2 ? n - i : n - i - 1);
		}
	}
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3788
#include<stdio.h>

int main(){
  int n,q,left,right,mid,count=0,i;
  scanf("%d",&n);
  int S[100000];

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  int T[50000];

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  
  for(i=0;i<q;i++){
    
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right) /2;
    if(S[mid] == T[i]){
      count++;
      break;
    }else if(T[i] < S[mid]){
      right = mid;
    }else{
      left = mid + 1;
    }
  }
  
  }

  printf("%d\n",count);

  return 0;
}



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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    int n;
    cin >> n;

    int arr[n], dp[n];

    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    
    for (int i = 2; i < n; ++i)
        dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);

    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
using namespace std;
using ll = long long;

int main (){
    int N;
    cin >> N;
    vector<int> W;
    int w;
    for (int i=0;i<N;i++){
        cin >> w;
        W.push_back(w);
    }
    vector<int> dif;
    int s1,s2;
    for(int i=1;i<=N;i++){
        s1 = accumulate(W.begin(), W.begin()+i, 0);
        s2 = accumulate(W.begin()+i, W.end(), 0);
        dif.push_back(abs(s1-s2));
    }
    sort(dif.begin(),dif.end());
    cout << dif[0];
}

Measured memory_bytes: 256
X = int(input())

if X < 100:
    print(0)
else:
    y = X - X // 100 * 100

    if y // (X // 100) < 5:
        print(1)
    elif y // (X // 100) == 5 and y % (X // 100) == 0:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, a, b;
        n = Integer.parseInt(sc.next());
        a = Integer.parseInt(sc.next());
        b = Integer.parseInt(sc.next());
        
        int num = n * a;
        System.out.println(Math.min(num, b));

        sc.close();
    }
}

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

using namespace std;



int main(){
int n,m;
    cin>>n>>m;
    char arr[n][m];
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++) cin>>arr[i][j];
    }
    long long dp[n][m];
    memset(dp,0,sizeof(dp));
    //dp[0][0]=1;
    int mod=pow(10,9)+7;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(arr[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            if(i==0 && j==0) dp[i][j]=1;
            else if(i==0) dp[i][j]=((dp[i][j-1]))%mod;
            else if(j==0) dp[i][j]=dp[i-1][j]%mod;
            else{
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[n-1][m-1]%mod<<endl;
   

	return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};



int main(void){
   ll N, A, B;
   cin >> N >> A >> B;
   vector<ll> p(N);
   rep(i, N) cin >> p[i];
   ll dp[N+1][N+1];
   rep(i, N+1)rep(j, N+1) dp[i][j] = INFL;
   dp[0][0] = 0;
   for(int i = 1; i <= N; i++){
     ll x = p[i-1];
     for(int j = 0; j <= N; j++){
       if(x > j){
         dp[i][x] = min(dp[i][x], dp[i-1][j]);
         dp[i][j] = min(dp[i][j], dp[i-1][j] + A);
       }
       if(x < j){
         dp[i][j] = min(dp[i][j], dp[i-1][j] + B);
       }
     }
   }
   ll ans = INFL;
   for(int i = 1; i <= N; i++) ans = min(ans, dp[N][i]);
   cout << ans << endl;
}


Measured memory_bytes: 195712
s = str(input())
L = len(s)
dict = [0] * 2019
dict[0] += 1
num = 0
for i in range(L-1, (-1), (-1)):
    num += (int(s[i]) * pow(10,(L-i-1), 2019))%2019
    amari = num % 2019
    dict[amari] += 1
ans = 0
for j in range(2019):
    ans += (dict[j]*(dict[j]-1))/2
print(int(ans))

Measured memory_bytes: 9276
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=list(map(int,input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  for k in range(0,n-i+1):
    if (n-i) % 2 == 0:
      dp[k][k+i] = max(A[k] + dp[k+1][k+i], dp[k][k+i-1] + A[k+i-1])
    else:
      dp[k][k+i] = min(-A[k] + dp[k+1][k+i], dp[k][k+i-1] - A[k+i-1])
print(dp[0][n])
# print(dp)

Measured memory_bytes: 113244
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left + 1 < right ) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int n, A[MAX];
  cnt = 0;

  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  mergeSort(A, n, 0, n);

  for ( int i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 6616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[10];
int main()
{
	int N;
	cin >> N;
	int ans = 0;
	int free = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A / 400 < 8) {
			if (cnt[A / 400] == 0) {
				ans++;
				cnt[A / 400]++;
			}
		}
		else free++;
	}
	cout << max(ans, 1) << " " << ans + free << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[100010]={0},h[100010]={0},n;
int main(){
	scanf("%d",&n);
	f[100004]=10007;
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	f[1]=0;
	for(int i=2;i<=n;i++){
		f[i]=2000000000;
		for(int j=max(1,i-2);j<i;j++){
			f[i]=min(f[i],abs(h[i]-h[j])+f[j]);
		}
	}
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#define M_PI 3.14159265358979323846
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll lcm(int a, int b) {
	return (ll)a * b / gcd(a, b);
}
int main() {
	int n;
	cin >> n;
	int m = n % 10;
	if (m == 2 || m == 4 || m == 5 || m == 7 || m == 9) cout << "hon" << endl;
	else if (m == 0 || m == 1 || m == 6 || m == 8) cout << "pon" << endl;
	else if (m == 3) cout << "bon" << endl;

	return 0;
}

Measured memory_bytes: 3104
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 10101;
const long long mod = 1e9 + 7;

long long dp[MSIZE][101];

void  Precalc(int d) {
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 1; i < MSIZE; i++) {
        for (int c = 0; c < 10; c++) {
            for (int p = 0; p < d; p++) {
                int n = (c + p) % d;
                dp[i][n] += dp[i - 1][p];
                dp[i][n] %= mod;
            }
        }
    }

}

long long Get(int len, int cur, int d) {
    return dp[len][(d - (cur % d)) % d];
}

long long Get(string& arr, int d, int i, int n, int cur) {
    if (i == n) return (cur % d == 0);
    long long ans = 0;
    for (int dig = 0; dig < arr[i]; dig++) {
        ans += Get(n - 1 - i, cur + dig, d);
        ans %= mod;
    }
    ans += Get(arr, d, i + 1, n, cur + arr[i]);
    ans %= mod;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    string k;
    cin >> k;
    int d;
    cin >> d;
    Precalc(d);
    for (char& ch : k) ch -= '0';
    cout << (mod - 1 + Get(k, d, 0, k.size(), 0)) % mod << endl;
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll d, n;
  cin >> d >> n;
  if(n == 100) n++;
  ll ans = pow(100, d) * n;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
    int N= sc.nextInt();
    String C=sc.next();
    String c[]= C.split("",0);
    int last_R =(int)C.chars().filter(ch -> ch =='R').count();
    String C2= C.substring(0,last_R);
    long ans = C2.chars().filter(ch -> ch =='W').count();
    System.out.println(ans);  
    }
}

Measured memory_bytes: 65908
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,b,c,d,e,g,i,j,k,f,t;
long long A,B,C,X,Y,Z;
long long MIN ,ans,mid;
char str[3];

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	c=a+b;
	d=n%c;
	n=n-d;
	if(d>a) d=a;
	ans=a*(n/c)+d;
	printf("%lld\n",ans);
    return 0;
}

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

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    string s;
    cin >> s;
    ll n = s.length();
    bool ok = false;
    while(!ok){
        n -= 2;
        ll n1 = n / 2;
        bool ok1 = true;
        for(int i = 0; i < n1; i++){
            if(s[i] != s[i + n1]) ok1 = false;
        }
        ok = ok1;
    }
    cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if (a < b) {
		rep(i, b) {
			cout << a;
		}
		cout << endl;
	}
	else {
		rep(i, a) {
			cout << b;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n;
	string a = "", b = "", str;
	
	cin >> n;
	cin >> str;
	
	int i;
	for(i = 0; i < n / 2; i++){
		a += str[i];
	}
	for(; i < n; i++){
		b += str[i];
	}
	
	if(a == b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll f[N],g[N],c;int n,h,t,hi[N],q[N];
inline double sl(R int i,R int j){return 1.0*(g[i]-g[j])/(hi[i]-hi[j]);}
int main(){
	scanf("%d%lld",&n,&c);
	fp(i,1,n)scanf("%d",&hi[i]);
	f[1]=0,g[1]=1ll*hi[1]*hi[1],q[h=t=1]=1;
	fp(i,2,n){
		while(h<t&&sl(q[h],q[h+1])<=2*hi[i])++h;
		f[i]=1ll*(hi[i]-hi[q[h]])*(hi[i]-hi[q[h]])+c+f[q[h]],
		g[i]=1ll*hi[i]*hi[i]+f[i];
		while(h<t&&sl(q[t-1],q[t])>sl(q[t-1],i))--t;
		q[++t]=i;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

long double calc(int p) {
    return (1.0 * p * (p + 1) / 2) / p;
}

int main(void) {
    int N, K;
    cin >> N >> K;
    VI p(N);
    REP(i, N) {
        cin >> p[i];
    }

    long double ans = 0;
    long double cur = 0;
    set<int> se;
    REP(i, K - 1) {
        cur += calc(p[i]);
    }
    REP(i, N - K + 1) {
        cur += calc(p[K + i - 1]);
        chmax(ans, cur);
        se.erase(i);
        cur -= calc(p[i]);
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B > D+C)
  {
    cout<<"Left\n";
  }
  else if(A+B < C+D)
  {
    cout<<"Right\n";
  }
  else
  {
    cout<<"Balanced\n";
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    if (k == n) {
        cout << 1 << endl;
        return 0;
    }
    cout << 1 + (n - k + k - 2) / (k - 1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#define  ll long long
using namespace std ;
int main()
{
    ll k,x ;
    cin >> k >> x ;
    k= (ll)k*500;
    if(k>=x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[100000], b[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A = gi();
    int B = gi();
    int M = gi();
    int mna = 100000, mnb = 100000;
    for (int i = 0; i < A; i++) {
        a[i] = gi();
        mna = MIN(a[i], mna);
    }
    for (int i = 0; i < B; i++) {
        b[i] = gi();
        mnb = MIN(b[i], mnb);
    }
    int mn = mna + mnb;
    for (int i = 0; i < M; i++) {
        int x = gi()-1;
        int y = gi()-1;
        int c = gi();
        int alt = a[x] + b[y] - c;
        mn = MIN(alt, mn);
    }

    printf("%d\n", mn);

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
for i in range(n):
    x, y = map(int, input().split())
    t = [[0 for i in range(x + 1)] for j in range(y + 1)]
    p = int(input())
    if p>0:
        for j in range(p):
            x1, y1, x2, y2 = map(int, input().split())
            if x1 == x2:
                for k in range(min(y1, y2)+1, max(y1, y2)+1):
                    if t[k][x1] == 'x':
                        t[k][x1] = 'xy'
                    else:
                        t[k][x1] = 'y'
            if y1 == y2:
                for k in range(min(x1, x2)+1, max(x1, x2)+1):
                    if t[y1][k] == 'y':
                        t[y1][k] = 'xy'
                    else:
                        t[y1][k] = 'x'
    for i in range(x + 1):
        for j in range(y + 1):
            if i == 0 and j ==0:
                t[j][i] = 1
            elif t[j][i] == 'xy':
                t[j][i] = 0
            elif t[j][i] == 'x':
                if j == 0:
                    t[j][i] =0
                else:
                    t[j][i] = t[j-1][i]
            elif t[j][i] == 'y':
                if i == 0:
                    t[j][i] = 0
                else:
                    t[j][i] = t[j][i-1]
            else:
                #print(i,j)
                if i != 0 and j != 0:
                    t[j][i] =  t[j][i-1] + t[j-1][i]
                if i == 0:
                    t[j][i] = t[j-1][i]
                if j == 0:
                    t[j][i] = t[j][i-1]
                #print(t)
    # print(t)
    if t[y][x] == 0:
        print('Miserable Hokusai!')
    else:
        print(t[y][x])
                

Measured memory_bytes: 7840
N,M = gets.split.map &:to_i
favs = (0...N).map{ (gets.split.map &:to_i).reverse }
vmax = N
rejected = {}

M.times {
  cs = Array.new(M+1, 0)
  (0...N).each{ |i|
    fv = favs[i]
    while rejected[fv[-1]] do
	  fv.pop      
    end
    cs[fv[-1]] += 1
  }
  v = cs.max
  vmax = [vmax, v].min
  k = (1..M).find{ |i| cs[i] >= vmax }
  rejected[k] = 1
}

p vmax


Measured memory_bytes: 3836
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)1e5+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cout << #x << " = " << x << endl;
#define pb push_back
#define MP make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vii vector<pi>
#define all(x) x.begin(), x.end()

int n,m,t,k;

queue <int> q;
vector <int> v[MAXN];
int ind[MAXN];
int dist[MAXN];

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

	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin >> a >> b;
		v[a].pb(b);
		ind[b]++;
	}

	for (int i = 1; i <= n; ++i)
	{
		if(ind[i] == 0)
			q.push(i);
	}


	while(!q.empty())
	{
		int tmp = q.front();
		q.pop();

		// cout << tmp << endl;
		for (int i = 0; i < (int)v[tmp].size(); ++i)
		{
			dist[v[tmp][i]] = max(dist[v[tmp][i]] , dist[tmp] + 1);
			ind[v[tmp][i]]--;
			if(ind[v[tmp][i]] == 0)
				q.push(v[tmp][i]);
		}
	}

	int maxx = 0;
	for (int i = 1; i <= n; ++i)
	{
		maxx = max(maxx , dist[i]);
	}

	cout << maxx << endl;
	return 0;
}


Measured memory_bytes: 6528
#include<iostream>

using namespace std;
int main(){
  int H,W;
  double a,b;
 

  
  while(1){
    cin >> H >> W;
    
    if(H==0 && W==0)break;
    
    for(  int i=0; i<H ;i++){ 	
	  for( int j=0; j<W;j++){
	    a=i%2;
	    b=j%2;
	    if((a==0 && b==0) || (a==1 && b==1)){
	      cout <<"#";}
	    else  {
	      cout << ".";}
	  
	  }
	  cout << endl;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a[6];
int main(){FAST;
ll n;cin>>n;
for(ll i=0;i<5;i++){
	cin>>a[i];
}
ll tot=0,cur=n;
for(ll i=1;i<=5;i++){
	// time for the last person to come to this point is
	ll lp = (cur+a[i-1]-1)/a[i-1];
//	cout<<cur<<' '<<lp<<'\n';
	tot+=lp;
	if(i==5)break;
	cur = n - a[i]*(tot-i);
	if(cur<=0){
		cur=1;
	}
}	
cout<<tot;
return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(string S) {
    return min(
        S.zip("01".cycle.take(S.length)).count!"a[0] != a[1]",
        S.zip("10".cycle.take(S.length)).count!"a[0] != a[1]"
    );
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(S);
    else
        solve(S).writeln;
}


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

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

  int ans = n*l + n*(n-1)/2;
  if(l>0) ans -=l;
  else if(l<=-n) ans -= (l+n-1);

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n, h;
	cin >> n >> h;
	vector<ll>a(n), b(n), c, cnt;
	rep(i, n)cin >> a[i] >> b[i];
	sort(b.begin(), b.end());
	reverse(b.begin(),b.end());
	rep(i, n) {
		//O(N^2)c.push_back(max(h-accumulate(b.begin(), b.begin() + (i+1), 0LL),0LL));となりTLE？
		h -= b[i];
		c.push_back(max(h, 0LL));
	}
	ll ma = *max_element(a.begin(),a.end());
	rep(i, n) {
		cnt.push_back((i + 1) + ceil((double)c[i] / (double)ma));
	}
	cout << *min_element(cnt.begin(),cnt.end()) << endl;
}



Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx =1e6;
bool vis[mx];
int n,a[mx],dp[mx];
int solve(int i,int k)
{
    //cout<<"now in "<<a[i]<<endl;
    if(i>=n-1)
        return 0;
   // if(i==n-2)
     //   return abs(a[n-1]-a[n-2]);
    if(vis[i])
        return dp[i];
    int ans=1e9;
    for(int j=1;j<=k;j++)
    {
      if(i+j<n)
        ans=min (ans,abs(a[i]-a[i+j]) + solve(i+j,k));
    }

    vis[i]=1;
    return dp[i]=ans;
}
int main()
{
    memset(dp,0,sizeof dp);
    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<solve(0,k)<<endl;
    return 0;

}



Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    string s[h];
    rep(i, h) cin >> s[i];
    vvec<int> summ(h+1, vec<int>(w+1, 0));
    rep(i, h) rep(j, w) {
        summ[i][j+1] = summ[i][j] + (s[i][j] - '0');
    }
    int final_ans = 1000000;
    for (int bit = 0; bit < (1<<(h-1)); ++bit) {
        //cout << "here, bit:" << bit << endl;
        int num_yoko = 0;
        for (int i = 0; i < h-1; ++i) {
            if (bit & (1<<i)) num_yoko++;
        }       

        vec<int> tmp(num_yoko+1, 0);
        vec<int> cutting_point;
        int ans = num_yoko;
        rep(j, w) {
            int grp = 0;
            rep(i, h) {
                if (i!=0) if (bit & (1<<(i-1))) grp++;
                if ((s[i][j] - '0')==1) tmp[grp]++;
            } 
            bool cut = false;
            rep(kk, num_yoko+1) if (tmp[kk]>k) cut = true;
            if (cut==true) {
                ans++;
                rep(kk, num_yoko+1) tmp[kk] = 0;
                int grp = 0;
                rep(i, h) {
                    if (i!=0) if (bit & (1<<(i-1))) grp++;
                    if ((s[i][j] - '0')==1) tmp[grp]++;                    
                }
                bool valid = true;
                rep(kk, num_yoko+1) if (tmp[kk]>k) valid = false;
                if (valid==false) ans = 1000000;
                cutting_point.push_back(j-1);
            }
        }
        // cout << "here ans:" << ans << endl;
        // if (ans < final_ans) {
        //     cout << bit << endl;
        //     rep(kkk, cutting_point.size()) cout << cutting_point[kkk] << " ";
        //     cout << endl;
        // }
        final_ans = min(ans, final_ans);
    }
    cout << final_ans << endl;
}

Measured memory_bytes: 256
program name

    implicit none
    character(len=1) a,b
    logical c,d,ans
    READ*, a,b
    if ( a=="H" ) then
        c = .true.
    else
        c = .false.
    end if
    if ( b=="H" ) then
        d = .true.
    else
        d = .false.
    end if

    if (c .eqv. d) then
        print*, "H"
    else
        print*, "D"
    end if

end program

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using v1 = vector<int>;
using v2 = vector<vector<int>>;

int main(){
	v2 c(3, vector<int>(3));
	for(int i = 0; i<3; i++){
		for(int j = 0; j<3; j++){
			cin >> c.at(i).at(j);
		}
	}
	bool judge = true;
	int sum1_1 = c.at(0).at(0) + c.at(1).at(1);
	int sum1_2 = c.at(0).at(1) + c.at(1).at(0);
	if(sum1_1 != sum1_2){
		judge = false;
	}else{
		int sum2_1 = c.at(2).at(2) + sum1_1;
		double sum2_2 = c.at(1).at(2) + c.at(0).at(2) + c.at(2).at(0) +c.at(2).at(1) +sum1_2;
		 if(sum2_1 != (sum2_2/2.0)) judge = false;
		}
		if(judge) cout << "Yes" << endl;
		if(!judge) cout << "No" << endl;
}


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


using namespace std;


using ull = unsigned long long;


int main()
{
    ull N, T;
    cin >> N >> T;

    ull prev, ans, stop;
    ans = 0;
    cin >> prev;
    stop = prev + T;
    for (ull i = 0; i < N - 1; i++) {
        ull now;
        cin >> now;

        if (stop > now) {
            ans += (now - prev);
        } else {
            ans += T;
        }
        prev = now;
        stop = now + T;
    }
    cout << ans + T << endl;
}


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

using namespace std;

int main() {
    string S, t("2019/04/30");
    cin >> S;
    int index = 0;
    for(auto &s:S) {
        if(s > t[index]){
            cout << "TBD" << endl;
            return 0;
        } else if(s < t[index]){
            cout << "Heisei" << endl;
            return 0;
        }
        index++;
    }
    cout << "Heisei" << endl;
    return 0;
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc132/tasks/abc132_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  auto d = make_v<int>(N);
  REP(i,N) {
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[N/2] - d[N/2-1] << endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
s = input()
w = [0] * n
e = [0] * n
ans = 10**9

if s[0] == 'W':
    w[0] = 1
if s[-1] == 'E':
    e[-1] = 1

for i in range(1,n):
    if s[i] == 'W':
        w[i] = w[i-1] + 1
    else:
        w[i] = w[i-1]
for i in range(n-1)[::-1]:
    if s[i] == 'E':
        e[i] += e[i+1] + 1
    else:
        e[i] += e[i+1]


for i in range(1,n-1):
    ans = min(ans,w[i-1]+e[i+1])
ans = min(ans,e[0])
ans = min(ans,w[n-1])
print(ans)

Measured memory_bytes: 26272
import sys
from heapq import heappush, heappop
input = sys.stdin.readline

num, person = map(int, input().split())
arr = []

for i in range(num):
    s, t, x = map(int, input().split())
    arr.append((s - x - 0.5, 1, x, i))
    arr.append((t - x - 0.5, 0, x, i))

for i in range(person):
    d = int(input())
    arr.append((d,))

arr.sort()

heap = []
done = set()

for elem in arr:
    if len(elem) == 1:
        while heap and heap[0][1] in done:
            heappop(heap)
        if heap:
            print(heap[0][0])
        else:
            print(-1)
        continue

    time, kind, x, i = elem
    if kind:
        heappush(heap, (x, i))
    else:
        done.add(i)


Measured memory_bytes: 107832
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <vector>
using namespace std;

#define Nmax 200002

vector<int> A;
unordered_map<int, int> total;

int main() {
    int N, a;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        A.push_back(a);
        total[a]++;
    }
    vector<int> B = A;
    sort(A.begin(), A.end());
    auto last = unique(A.begin(), A.end());
    long long nr = 0;
    for (auto it = A.begin(); it != last; ++it) {
        nr += (long long)total[*it] * (total[*it] - 1) / 2;
    }
    for (auto it = B.begin(); it != B.end(); ++it) {
        cout << nr - total[*it] + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 9148