akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


int main(){
    int n, m;   cin >> n >> m;
    priority_queue<ll> q;
    for(int i = 0; i < n; i++){
        int a;  cin >> a;
        q.push(a);
    }

    for(int i = 0; i < m; i++){
        int x = q.top();    q.pop();
        x = x / 2;
        q.push(x);
    }

    ll res = 0;
    while(!q.empty()){
        res += q.top();
        q.pop();
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 4276
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<vector<int>> s(M);
	int k, tmp;

	for (int i = 0; i < M; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {

			cin >> tmp;
			s[i].emplace_back(tmp);

		}

	}

	vector<int> p(M);
	for (int i = 0; i < M; i++) cin >> p[i];
	
	int ans = 0;
	for (int bit = 0b0; bit < (1<<N); bit++) {

		bool flag = true;
		for (int i = 0; i < M; i++) {

			int on = 0;
			for (const auto &elem : s[i]) {
				if (bit & (1 << (elem - 1))) on++;
			}
			if (on % 2 != p[i]) {
				flag = false;
				break;
			}

		}
		if (flag) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
V=list(map(int,input().split()))

valu=[]
for a in range(min(N,K)+1):
  for b in range(min(N,K)-a+1):
    val=sorted(V[:a]+V[N-b:])
    n=K-(a+b)
    for i in range(n):
      if len(val)>0:
        if val[0]<0:
          val.pop(0)
        else:
          break
    valu.append(sum(val))
    
print(max(valu))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
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<P,int> 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=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m,x;

int main(){
	cin>>n>>m>>x;
	int A=0,B=0;
	for(int i=0;i<m;i++){
		int y;
		cin>>y;
		if(y<x) A++;
		else B++;
	}
	cout<<min(A,B)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	LLI n, x;
	cin >> n >> x;
	
	LLI tmp, min;
	
	cin >> tmp;
	x -= tmp;
	min = tmp;
	
	for(int i = 1; i < n; i++)
	{
		cin >> tmp;
		if( min > tmp )
			min = tmp;
		x -= tmp;
	}
	cout << n + x/min;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), d(m - 1);

  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());
  rep(i, m - 1) d[i] = x[i + 1] - x[i];
  sort(d.begin(), d.end());

  int ans = 0;
  for (int i = 0; i < m - 1 - (n - 1); ++i) ans += d[i];

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


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

int n, kk;
int dst[100][100];
int M = 1001001001;

void wf(){
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(dst[i][k]+dst[k][j] < dst[i][j]){
					dst[i][j] = dst[i][k]+dst[k][j];
				}
			}

		}
	}
}

void addEdge(int a, int b, int c){
	dst[a][b] = min(dst[a][b], c);
	dst[b][a] = min(dst[b][a], c);

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(dst[i][a]+c+dst[b][j] < dst[i][j]){
				dst[i][j] = dst[i][a]+c+dst[b][j];
			}
			if(dst[i][b]+c+dst[a][j] < dst[i][j]){
				dst[i][j] = dst[i][b]+c+dst[a][j];
			}
		}
	}

}


int main(){

	for(;;){
		cin >> n >> kk;
		if(n==0&&kk==0) break;

		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				dst[i][j] = M;
				if(i==j) dst[i][j] = 0;
			}
		}

		int f,a, b, c, d, e;
		for(int i=0; i<kk; i++){
			cin >> f;
			if(f==0){
				cin >> a >> b;
				a--;
				b--;
				if(dst[a][b]==M){
					cout << "-1" << endl;
				}else{
					cout << dst[a][b] << endl;
				}


			}else{
				cin >> c >> d >> e;
				c--;
				d--;
				addEdge(c, d, e);
//				dst[c][d] = e;
//				dst[d][c] = e;
//				wf();
			}
		}


	}

}

Measured memory_bytes: 1204
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x == cnt + 1)
            ++cnt;
    }

    if (cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << n - cnt << endl;
    }

}


Measured memory_bytes: 256
from math import gcd
import random
n = int(input())
mod = 10**9 + 7
d1 = dict()
a_zero,b_zero = 0,0
ab = 0
for i in range(n):
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        ab += 1
        continue
    if a == 0:
        a_zero += 1
        continue
    if b == 0:
        b_zero += 1
        continue
    a,b = a//gcd(a,b),b//gcd(a,b)
    if a < 0:
        a *= -1
        b *= -1

    if (a,b) in d1:
        d1[(a,b)] += 1
    else:
        d1[(a,b)] = 1

ans =  1
ans *= pow(2,a_zero,mod)+pow(2,b_zero,mod)-1
ans %= mod
for a,b in d1:
    if b > 0 and (b,-a) in d1:
        ans *= pow(2,d1[(a,b)],mod)+pow(2,d1[(b,-a)],mod)-1
        d1[(a,b)] = 0
        d1[(b,-a)] = 0
    elif b < 0 and (-b,a) in d1:
        ans *= pow(2,d1[(a,b)],mod)+pow(2,d1[(-b,a)],mod)-1
        d1[(a,b)] = 0
        d1[(-b,a)] = 0
    else:
        ans *= pow(2,d1[(a,b)],mod)
        d1[(a,b)] = 0
    ans %= mod
    #print(a,b,d1)
print((ans-1 + ab)%mod)

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

const int N = (int) 1e5 + 5;

int n;
int a[N];
int fw[N];

void maximize(int &a, int b) { 
	if (a < b) a = b;
}

void upd(int i, int v) {
	for (; i >= 1; i -= i & -i) maximize(fw[i], v);
}

int get(int i) {
	int r = 0;
	for (; i <= n; i += i & -i) maximize(r, fw[i]);
	return r;
}

void compress() {
	vector <int> zip; zip.push_back(-1);
	for (int i = 1; i <= n; i++) zip.push_back(a[i]);
	sort(zip.begin(), zip.end());
	zip.resize(distance(zip.begin(), unique(zip.begin(), zip.end())));
	for (int i = 1; i <= n; i++) a[i] = lower_bound(zip.begin(), zip.end(), a[i]) - zip.begin();
}

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	compress();
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int temp = get(a[i]);
		maximize(ans, temp + 1);
		upd(a[i], temp + 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
using namespace std;
using ll=long long;
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; }
const ll N=1e5, M = 1e5;
ll dp[100000];
ll a[100000];
const ll AA = 1000000007;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N+1, 1);
	int A;
	in(0, M) {
		cin >> A;
		a.at(A) = 0;
	}
	dp[0] = 1;
	if (a.at(1)) dp[1] = 1;
	else dp[1] = 0;

	in(2, N+1) {
		if (a.at(i)) dp[i] = dp[i - 1] + dp[i - 2];
		else dp[i] = 0;
		dp[i] %= AA;
	}
	cout << dp[N] % AA << endl;
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	llong ans=0;
	REP(i,n) ans+=a[i]-1;
	
	cout<<ans<<endl;
	return 0;
}//解説参考.

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string a, b;
	cin >> a >> b;
	if (a == b)
	{
		print("EQUAL");
		return 0;
	}
	if (SIZE(a) > SIZE(b))
	{
		print("GREATER");
		return 0;
	}
	else if (SIZE(a) < SIZE(b))
	{
		print("LESS");
		return 0;
	}

	REP(i, SIZE(a))
	{
		if (a[i] > b[i])
		{
			print("GREATER");
			return 0;
		}
		else if (a[i] < b[i])
		{
			print("LESS");
			return 0;
		}
	}

	print("EQUAL");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int N;
int x[10], y[10];

double root(int i, int j) {
    int dx = x[i - 1] - x[j - 1];
    int dy = y[i - 1] - y[j - 1];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    double sum = 0.0;

    vector<int> v(N);

    for (int i = 0; i < N; ++i) {
        v[i] = i + 1;
    }

    do {
        for (int i = 1; i < N; ++i) {
            sum += root(v[i-1], v[i]);
        }
    } while (next_permutation(v.begin(), v.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;

    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return 0;
}

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

#define ll long long
#define inf 1e18

ll dp[401][401];
ll n, k, arr[401], pre[401], sum[401][401];


int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	pre[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		pre[i] = arr[i] + (i == 0 ? 0 : pre[i - 1]);
	}

	sum[0][0] = arr[0];

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (i == 0) {
				sum[i][j] = pre[j];
			}
			sum[i][j] = pre[j] - pre[i - 1];
		}
	}


	for (int len = 0; len < n; len++) {
		for (int i = 0; i + len < n; i++) {
			if (len == 0) {
				dp[i][i] = 0;
				continue;
			}
			dp[i][i + len] = inf;
			for (int k = 1; k <= len; k++) {
				dp[i][i + len] = min(dp[i][i + len], dp[i][i + len - k] + dp[i + len - k + 1][i + len] + sum[i][i + len - k] + sum[i + len - k + 1][i + len]);
			}
		}
	}

	/*for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
	cout << dp[0][n - 1];
	return 0;
}


Measured memory_bytes: 2816
using System;

namespace abc052_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int x = 0;
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'I')
                {
                    x++;
                    if (max < x)
                    {
                        max = x;
                    }
                }
                else
                {
                    x--;
                }
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e15;

int arr[N];
int n, k;
int query = 1;
void print(int ret)
{
    cout << "Case #" << query++ << ": " << ret << endl;
}

long double maxvolume(long double s) 
{ 
    long double length = s / 3.0; 
    s -= length; 
    long double breadth = s / 2.0; 
    long double height = s - breadth; 
    return length * breadth * height; 
} 

void solve()
{
	long double n;
	cin >> n;
	std::cout << std::fixed;
  	std::cout << std::setprecision(10) << maxvolume(n) << '\n';
}

 
int32_t main()
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 5005
#define MOD 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int power(int x, int n) {
    if (n == 0) return 1;
    if (n&1) return (1LL*x*power(x, n-1))%MOD;
    int p = power(x, n/2);
    return (1LL*p*p)%MOD;
}

void add(int &a, int b) {a = (a+b)%MOD;}

int n, k, dp[maxN][maxN];
string s;

int main () {
    scanf("%d", &n);
    cin >> s; k = s.length();

    dp[0][0] = 1;
    fto(i, 0, n-1) {
        fto(j, 0, n-1) {
            add(dp[i+1][j+1], dp[i][j]*2);
            add(dp[i+1][max(0, j-1)], dp[i][j]);
        }
    }

    int ans = (1LL*dp[n][k]*power(power(2, MOD-2), k))%MOD;
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 98048
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
int g[100001];
int di[100000];
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
int dfs(int i) {
	if (g[i] != i) {
		int r = dfs(g[i]);
		di[i] += di[g[i]];
		//printf("di[%d]=%d\n",i,di[i]);
		return g[i] = r;
	}
	else {
		return i;
	}
}

int main() {
	int n, m;
	scanf("%d%d", &n,&m);
	REP(i,n) g[i] = i;
	REP(i,m) {
		int l, r, d;
		scanf("%d %d %d", &l, &r, &d);
		l--; r--;
		int g1 = dfs(l);
		int g2 = dfs(r);
		if (g1 != g2) {
			g[g2] = l;
			di[g2] = d;
		}
	}

	int ans = 0;
	REP(i, n) {
		dfs(i);
		if (g[i] == i)ans++;
	}
	PRINTD(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,ans = 0,Max = 0;
    scanf("%d",&n);
    for (int i = 1,x;i <= n;i++) {
        scanf("%d",&x);
        ans += x;
        Max = max(x,Max);
    }
    printf("%d",ans-Max/2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    string s;
    cin >> s;
    int n = s.size();
    static int mn[1 << 26];
    fill(mn, mn + (1 << 26), mod);
    mn[0] = 0;
    int x = 0;
    rep(i, n) {
        x ^= 1 << s[i] - 'a';
        rep(j, 26) chmin(mn[x], mn[x ^ 1 << j] + 1);
    }
    cout << max(1, mn[x]) << endl;

    return 0;
}

Measured memory_bytes: 262864
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
int main(){
  ll n,m;cin >>n>>m;int a[n+1],c;fill(a,a+n+1,1);
  for(int i=0;i<m;i++){
    cin >> c; a[c]=0;
  }
  ll b[n+1];fill(b,b+n+1,0);
  for(int i=0;i<n+1;i++){
    if(a[i]==0){
      b[i]=0;
      if(b[i-1]==0){b[n]=0;break;}
    }else{
      if(i<2){
        b[i]=1;
      }else{
      b[i]=(b[i-1]+b[i-2])%1000000007;
    }}
  }
  cout << b[n] << endl;
}

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

using namespace std;

using ll = long long;

int main(void) {
    int n, k;
    scanf("%d %d", &n, &k);
    set<int> check;
    for (int i = 0; i < k; i++) {
        int d;
        scanf("%d", &d);
        for (int i = 0; i < d; i++) {
            int snuke;
            scanf("%d", &snuke);
            check.insert(snuke);
        }
    }
    printf("%d\n", n - (int) check.size());
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int a = (s[0]-'0')*10 + (s[1]-'0');
    int b = (s[2]-'0')*10 + (s[3]-'0');
    bool mm = false, yy = false;
    if (a >= 1 && a <= 12) mm = true;
    if (b >= 1 && b <= 12) yy = true;
    string ans;
    if (mm && yy) ans = "AMBIGUOUS";
    else if (mm) ans = "MMYY";
    else if (yy) ans = "YYMM";
    else ans = "NA";
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3604
from collections import Counter

n = int(input())
s = []
for _ in range(n):
   s.append(input())

c = Counter(s)
cmax = c.most_common()[0][1]

ans = []
for k, v in c.items():
   if v == cmax:
      ans.append(k)

ans.sort()
for x in ans:
   print(x)


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
    ll N;
    cin>>N;
    vector<ll> f(N+1,2);
    f[1]=1;
    ll max_num = (ll)sqrt(N+1);
    ll n;
    ll d;
    rep(i,max_num-1){
        n=i+2;
        if(N/n<n) break;
        rep(j,N/n-1){
            if(n>j+2) continue;
            ++f[n*(j+2)];
            if(j+2!=n) ++f[n*(j+2)];
        }
    }

    ll ans = 0;
    rep(i,N){
        ans += (i+1)*f[i+1]; // 素数の処理
        // cout<<f[i+1]<<"\n";
    }
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 81336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll N; cin >> N;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll a; cin >> a;
    ans += a-1;
  }
  cout << ans << endl;  
}

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

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

    string s;
    cin >> s;
    if(s.size() < 4){
        cout << "No" << endl;
        return 0;
    }
    if(s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I'){
        cout << "Yes" << endl;
    }else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;
const long long MOD = 1000000007;

typedef long long ll;

int
main(int argc, const char *argv[])
{
  vector<int> g[100010];
  int n;
  scanf("%d", &n);
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &a, &b);
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  queue<int> p, q;

  p.push(0); p.push(-1);
  q.push(n - 1); q.push(-1);
  int color[100010] = {}, x, y;
  color[0] = 1; color[n - 1] = 2;
  while (!p.empty() || !q.empty()) {
    if (!p.empty()) {
      while (1) {
	x = p.front(); p.pop();
	if (x == -1) break;
	for (int i = 0; i < g[x].size(); i++) {
	  if (color[g[x][i]] == 0) {
	    color[g[x][i]] = 1;
	    p.push(g[x][i]);
	  }
	}
      }
      if (!p.empty()) p.push(-1);
    } 
    if (!q.empty()) {
      while (1) {
	y = q.front(); q.pop();
	if (y == -1) break;
	for (int i = 0; i < g[y].size(); i++) {
	  if (color[g[y][i]] == 0) {
	    color[g[y][i]] = 2;
	    q.push(g[y][i]);
	  }
	}
      }
      if (!q.empty()) q.push(-1);
    } 
  }

  int f = 0, s = 0;
  for (int i = 0; i < n; i++) {
    if (color[i] == 1) f++;
    else s++;
  }

  if (f <= s)printf("Snuke\n");
  else printf("Fennec\n");

  return 0;
}
	   
	   

  


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int dp[22'222];
void solve()
{
    int h, n;
    vector<pair<int, int>> v;
    cin>>h>>n;
    v.resize(n);
    forn(i, n) cin>>v[i].f>>v[i].s;
    //
    memset(dp, 0x3F, sizeof dp);
    dp[0]=0;
    forn(i, h)
    {
        for(auto& it: v)
        {
            dp[i + it.f] = min(dp[i+it.f], dp[i] + it.s);
        }
    }
    int ans = 1e9;
    for(int i = h; i < 22'222; ++i)
    {
        ans = min(ans, dp[i]);
    }
    cout << ans << '\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3836
arr = gets.split.map &:to_i
m = arr[0]
d = arr[1]
count = 0
1.upto(m) do |i|
  22.upto(d) do |j|
    d1 = j % 10
    d10 = j / 10
    if d1 >= 2
      if d1 * d10 == i
        count += 1
      end
    end
  end
end
puts count


Measured memory_bytes: 1788
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
    int x, y;
    cin >> x >> y;

    int c = 0;
    while (c <= x) {
        int t = x - c;
        if (2 * c + 4 * t == y) {
            col("Yes");
            return 0;
        }
        c++;
    }
    col("No");
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
struct apple
{
	int x,y;
}edge[100010];
int k,f[100010];
long long cnt;
void push_back(int x,int y)
{
	edge[++k].x=x;
	edge[k].y=y;
 } 
int find(int x)
{
	if(f[x]==x)
		return x;
	f[x]=find(f[x]);
	return f[x];
}
void unioned(int x,int y)
{
	int fx,fy;
	fx=find(x);
	fy=find(y);
	if(fx!=fy)
	{
		f[fx]=fy;
		cnt--;
	} 
}
int judge(int x,int y)
{
	int fx,fy;
	fx=find(x);
	fy=find(y);
	if(fx==fy)
		return 0;
	return 1;
}
int main()
{
	int fla,q,i,x,y,z;
	long long n,m;
	fla=1;
	k=0;
	scanf("%lld%lld%d",&n,&m,&q);
	cnt=n;
	for(i=1;i<=n;i++)
		f[i]=i;
	for(i=1;i<=q;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		x++;
		y++;
		if(z==0)
			unioned(x,y);
		else
			push_back(x,y);
	}
	if(m==n-1)
	{
		if(k>0)
			printf("No");
		else
			printf("Yes");
		return 0;
	}
	for(i=1;i<=k;i++)
		if(!judge(edge[i].x,edge[i].y))
			fla=0;
	if(m>n-cnt+cnt*(cnt-1)/2)
		fla=0;
	if(fla)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 1280
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const W = parseInt(arg[0].split(" ")[1]);
 
    const wv = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));

    let dp = [];
    
    for(let i=0;i<N+1;i++){
        dp.push(Array(W+1).fill(0));
    }
    
    for(let i=1; i<N+1; i++) {
        const w = wv[i-1][0];
        const v = wv[i-1][1];
        
        for(let j=0; j<W+1; j++) {
            if(w > j) {
                // 単体で重さオーバーなら前回のを引き継ぐ
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = Math.max(dp[i-1][j], v + dp[i-1][j - w]);
            }
        }
    }
    
    console.log(dp[N][W]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 187564
import numpy as np
from copy import deepcopy
from heapq import heappop, heappush
from bisect import bisect_left, bisect
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations

D, T, S = map(int, input().split())

if D / S > T:
    print("No")
else:
    print("Yes")

exit()


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

int main(void) {
  int n;
  cin >> n;
  int a = n/15;
  cout << 800*n-a*200 << endl;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	//sc = bufio.NewScanner(os.Stdin)
	//sc.Split(bufio.ScanWords)
	var s string
	fmt.Scan(&s)
	n := len(s)
	for n > 0 {
		switch {
		case n >= 5 && s[n-5:n] == "dream":
			n -= 5
		case n >= 7 && s[n-7:n] == "dreamer":
			n -= 7
		case n >= 5 && s[n-5:n] == "erase":
			n -= 5
		case n >= 6 && s[n-6:n] == "eraser":
			n -= 6
		default:
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
typedef long long ll;
bool check(ll x, ll y,char c,string s[100]){
  for(ll i=-1;i<=1;i++){
    for(ll j=-1;j<=1;j++){
      if(i==0&&j==0) continue;
      if(x+i<0||y+j<0||x+i>=100||y+j>=100) continue;
      if(s[x+i][y+j]==c) return false;
    }
  }
  return true;
}
signed main(){
  ll a,b,tmp=0;
  string s[100];
  cin >> a >> b;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      tmp++;
      if(i<50){
        s[i]+='.';
      }else{
        s[i]+="#";
      }
    }
  }
  cout <<"100 100\n";
  for(int i=0;i<49;i++){
    for(int j=0;j<100;j++){
      if(b-1>0&&check(i,j,'#',s)){
        b--;
        s[i][j]='#';
      }
    }
  }
  for(int i=51;i<100;i++){
    for(int j=0;j<100;j++){
      if(a-1>0&&check(i,j,'.',s)){
        s[i][j]='.';
        a--;
      }
    }
  }
  for(int i=0;i<100;i++){
    cout << s[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <tuple>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int> > p;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        p.push_back(make_tuple(a, b, i));
    }
    SORT(p);

    vector<pair<int, string>> ans;
    vector<int> pref(n);
    fill(ALL(pref), 1);
    REP(i, m) {
        ostringstream id;
        id << setfill('0') << setw(6) << get<0>(p[i]) << setfill('0') << setw(6) << pref[get<0>(p[i])-1];
        pref[get<0>(p[i])-1]++;
        ans.push_back(make_pair(get<2>(p[i]), id.str()));
    }

    SORT(ans);
    EACH(x, ans) {
        P(x.second);
    }



    return 0;
}


Measured memory_bytes: 10096
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

const int M=1e5+5;
char s[M];
int ans[M];
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	int i=0;
	while(i<n)
	{
		int cntl=0,cntr=0;
		while(i<n&&s[i]=='R')
			cntr++,i++;
		// ..RRR LLLL..
		//    rp lp
		int lp=i;
		while(i<n&&s[i]=='L')
			cntl++,i++;
		ans[lp]=(cntl+1)/2+cntr/2;
		ans[lp-1]=cntl/2+(cntr+1)/2;
	}
	for(int i=0;i<n;i++)
		printf("%d%c",ans[i],i==n-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

//#define int long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF int(1e9)

int main(void) {
    int h, w;
    string s[102];

    cin >> h >> w;
    rep(i,h) {
        cin >> s[i];
    }

    rep(i,h) {
        cout << s[i] << "\n" << s[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <cmath>

using namespace std;



int  main(){
    int N;
    cin >> N;
    int dp[N][3], p[N][3];
    for (int i = 0; i<N; i++){
        cin >> p[i][0] >> p[i][1] >> p[i][2];
    }
    dp[0][0] = p[0][0];
    dp[0][1] = p[0][1];
    dp[0][2] = p[0][2];

    for (int i = 1; i < N; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + p[i][0];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + p[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + p[i][2];
    }
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
}

Measured memory_bytes: 2560
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pli pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;
map<int, bool> mp;
int main(){
	FASTIO
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0, w = 0;
	rep(i, 0, n){
		s[i] == 'R' ? r++ : w++;
	}
	int ans = min(w, r), c = 0;
	rep(i, 0, r){
		if(s[i] == 'W')
			c++;
	}
	ans = min(ans, c);
	c = 0;
	for(int j = n - 1; j >= n - w; j--){
		if(s[j] == 'R')
			c++;
	}
	ans = min(ans, c);
	cout << ans;
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,x,m[1005]={},num=0,ans=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>m[i];
        num+=m[i];
    }
    x-=num;
    ans+=n;
    sort(m,m+n);
    ans+=(x/m[0]);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n)
    {
        cin >> a[i];
        b[i] = a[i] - i;
    }
    sort(b.begin(), b.end());
    ll mean;
    mean = b[n / 2];
    ll ans = 0;
    rep(i, n)
    {
        ans += abs(b[i] - mean);
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;


//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
// vector<int> v(1000);

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N;
  cin>>N;
  cout << 3*N*N << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
int dx[] = {1,1,1,-1,-1,-1,0,0,0};
int dy[] = {0,1,-1,0,1,-1,0,1,-1};

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int> > map(h+2,vector<int>(w+2,0) );
	vector<vector<int> > cnt(h+2,vector<int>(h+2,0) );
	queue<mp> q;
	for(int i=1;i<=h;i++)
	    for(int j=1;j<=w;j++){
		char tmp ;
		cin>>tmp;
		if(tmp=='.'){
			q.push( mp(i,j) );	
		}else{
			map[i][j] = tmp-'0';
		}
	    }

	int res = 0;
	if(q.empty()){
		cout<<res<<endl;
		return 0;
	}
	while(!q.empty() ){
		queue<mp> tt;
		while(!q.empty() ){
			mp now = q.front();
			q.pop();
			int x = now.first;
			int y = now.second;
			for(int i=0;i<9;i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				cnt[nx][ny]++;
				if(cnt[nx][ny] == map[nx][ny]){
					tt.push( mp(nx,ny) );
				}
	
			}
		}
		res++;
		q = tt;
	}
	cout<<res-1<<endl;

	return 0;
}



Measured memory_bytes: 11164
n,k=map(int,input().split())
s=[int(i) for i in input()]
l1,l0=[],[]
b,c=1,0
for i in s:
  if b==i: c+=1
  else:
    if b: l1+=[c]
    else: l0+=[c]
    c=1
  b=i
if b:
  l1+=[c]
  l0+=[0]
else:
  l0+=[c]
S=[0]
for i,j in zip(l1,l0):
  S+=[S[-1]+i+j]
l1+=[0]
m=len(S)
if m<=k:
  print(n)
  exit()
a=0
for i in range(k,m):
  a=max(a,S[i]-S[i-k]+l1[i])
print(a)

Measured memory_bytes: 12700
S = input()

left = int(S[:2])
right = int(S[2:])

if 1 <= left <= 12 and 1 <= right <= 12:
    print('AMBIGUOUS')
elif 1 <= left <= 12:
    print('MMYY')
elif 1 <= right <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(list(input()))
for _ in range(m):
    b.append(list(input()))

c = n - m + 1
ans = "No"
for i in range(c):
    for j in range(c):
        flag = True
        for p in range(m):
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    flag = False
                    break
        if flag == True:
            ans = "Yes"
            break
print(ans)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int sum(int n) {
    int res = 0;
    while(n > 0){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int ans = 9999999;
    inc(i, 1, n){
        ans = min(ans, sum(i)+sum(n-i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# E - Simple String Queries
from operator import or_


class SegmentTree:
    __slots__ = ["_default_value", "_seg_func", "_modifying_func", "_size", "_tree"]

    def __init__(self, initial_values: "Sequence", default_value: "Union[int, str]", seg_func: "Callable",
                 modifying_func: "Optional[Callable]" = None) -> None:
        self._default_value = default_value
        self._seg_func = seg_func
        self._modifying_func = modifying_func
        self._size = 1 << (len(initial_values) - 1).bit_length()
        self._tree = self._build(initial_values)

    def _build(self, initial_values: "Sequence") -> "List":
        """Build a segment tree with initial values."""
        tree = [self._default_value] * (2 * self._size)

        if self._modifying_func:
            initial_values = map(self._modifying_func, initial_values)

        for idx, val in enumerate(initial_values):  # set a tree
            tree[idx + self._size - 1] = val

        for idx in range(self._size - 2, -1, -1):  # build
            tree[idx] = self._seg_func(tree[2 * idx + 1], tree[2 * idx + 2])

        return tree

    def update(self, index: int, value: int) -> None:
        """Update index to value."""
        index += self._size - 1
        if self._modifying_func:
            value = self._modifying_func(value)
        self._tree[index] = value
        while index:
            index = (index - 1) // 2
            self._tree[index] = self._seg_func(self._tree[2 * index + 1], self._tree[2 * index + 2])

    def query(self, left: int, right: int) -> "Union[int, str]":
        """Respond to query in [left, right]."""
        left += self._size
        right += self._size
        result = self._default_value
        while left < right:
            if left & 1:
                result = self._seg_func(result, self._tree[left - 1])
                left += 1
            if right & 1:
                right -= 1
                result = self._seg_func(result, self._tree[right - 1])
            left >>= 1
            right >>= 1
        return result


def main():
    _, S, _, *queries = open(0).read().split()
    tree = SegmentTree(S, 0, or_, lambda c: 1 << (ord(c) - 97))
    ans = []
    popcount = lambda x: bin(x).count("1")
    for com, a, b in zip(*[iter(queries)] * 3):
        if com == "1":
            tree.update(int(a) - 1, b)
        else:
            ans.append(popcount(tree.query(int(a) - 1, int(b))))
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 46644
small = []
large = []

while True:
	input_a, input_b = map(int, raw_input().split())
	if input_a == 0 and input_b == 0:
		break
	else:
		if input_a < input_b:
			small.append(input_a)
			large.append(input_b)
		else:
			small.append(input_b)
			large.append(input_a)

for (n, m) in zip(small, large):
		print n, m

Measured memory_bytes: 6412
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

int n;
const int N = 110000;
VI edges[N];
int p[N];
ll s[N];
int size[N];
ll wei[N];
int sa, sb;

int dfs(int v, int par) {
  p[v] = par;
  int sz = 1;
  for (int w: edges[v]) {
    if (w == par) continue;
    int sub = dfs(w, v);
    if (2 * sub != n) {
      wei[w] = (s[v] - s[w]) / (2 * sub - n);
      cerr << w << " " << wei[w] << endl;
    } else {
      sa = v;
      sb = w;
    }
    sz += sub;
  }
  return size[v] = sz;
}

ll dfs2(int v, int par) {
  ll sum = 0;
  for (int w: edges[v]) {
    if (w == par) continue;
    ll sub = dfs2(w, v);
    sum += sub + size[w] * wei[w];
  }
  return sum;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  sa = -1, sb = -1;
  vector<PI> e(n - 1);
  REP(i, 0, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    e[i] = PI(a, b);
  }
  REP(i, 0, n) {
    cin >> s[i];
  }
  VL r(n - 1);
  dfs(0, -1);
  if (sa != -1 || sb != -1) {
    ll sum = dfs2(0, -1);
    wei[sb] = (s[0] - sum) / (n / 2);
  }
  REP(i, 0, n - 1) {
    int a = e[i].first, b = e[i].second;
    if (p[a] == b) {
      r[i] = wei[a];
    } else {
      r[i] = wei[b];
    }
  }
  REP(i, 0, n - 1) {
    cout << r[i] << endl;
  }
}


Measured memory_bytes: 18432
#include<bits/stdc++.h>
#define N 100010
typedef long long ll;
using namespace std;
int main(){
  ll n,k,sum=0;
  scanf("%lld%lld",&n,&k);
  if (!k)  sum=n*n;
  else {
      for (int i=k+1;i<=n;i++)
         sum+=(n/i)*(i-k)+max(0LL,n%i-k+1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256