akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto X = ri;
	int[] arr = [1];
	foreach(i; 2..33) {
		int k = 2;
		while(i^^k <= X) {
			arr ~= i^^k;
			k++;
		}
	}
	arr.sort();
	debug arr.writeln;
	arr.back.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n, a[3][101];
    std::cin >> n;
    for (int i = 1; (i <= n); ++i) {
        std::cin >> a[1][i];
    }
    for (int i = 1; (i <= n); ++i) {
        std::cin >> a[2][i];
    }
    int max = 0;
    for (int i = 1; (i <= n); ++i) {
        int sum = a[1][1];
        for (int j = 1; (j <= n); ++j) {
            if (i <= j) sum += a[2][j];
            else sum += a[1][j + 1];
        }
        max = std::max(max, sum);
    }
    std::cout << max << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char data[4];
  
  scanf("%s", data);
  char d = data[0];
  int ret = 0;
  if(data[0] == 'S') {
    if(data[1] == 'S') {
        if(data[2] == 'S') {
            ret = 0;
        } else {
            ret = 1;
        }
    } else {
        if(data[2] == 'S') { ret = 1; }
        else { ret = 2;}
    }
  } else {
      if(data[1] == 'S') {
        if(data[2] == 'S') { ret = 1;}
        else { ret = 1; }
      } else {
        if(data[2] == 'S') { ret = 2; }
        else { ret = 3; }
      }
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
ll a[300010];
int main(){ _;
  int n;cin>>n;
  int n3=n*3;
  REP(i,n3) cin>>a[i];
  sort(a,a+n3,greater<int>());
  ll sm=0;
  for(int i=1;i<n*2;i+=2)
    sm+=a[i];
  cout<<sm<<endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double r; cin >> r;
    printf("%.4lf\n", r*2*3.141592);
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N, Q;
string S;

ll solve(ll k)
{
    ll s = 0;
    ll sum = 0;
    ll D = 0, M = 0, C = 0;
    REP(i, N)
    {
        if (i - s >= k)
        {
            if (S[s] == 'D')
            {
                D--;
                C -= M;
            }
            else if (S[s] == 'M')
                M--;
            s++;
        }

        if (S[i] == 'D')
            D++;
        else if (S[i] == 'M')
        {
            M++;
            C += D;
        }
        else if (S[i] == 'C')
            sum += C;
    }
    return sum;
}

int main()
{
    cin >> N >> S >> Q;
    REP(i, Q)
    {
        ll k;
        cin >> k;
        cout << solve(k) << endl;
    }
    return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod



struct edge{
    ll place;
    ll cost;
    ll time;
    bool operator>(const edge & a) const{
        if(time!=a.time) return time>a.time;
        return cost!=a.cost ? cost>a.cost : place>a.place;
    }
    bool operator<(const edge &a) const{
        if(time!=a.time) return time<a.time;
        return cost!=a.cost ? cost<a.cost : place<a.place;
    }
    void f(ll a, ll b, ll c){
        place=a;
        cost=b;
        time=c;
        return;
    }
    void Print(){
        cout<<place<<' '<<cost<<' '<<time<<endl;
        return;
    }
};
typedef priority_queue<edge,vector<edge>,greater<edge> > E_queue;

ll dp[51][5001];
vector<edge> d[51];
int main(){
    ll N,M,S; cin>>N>>M>>S;
    if(S>5000) S=5000;
    rep(i,M){
        ll u,v,a,b; cin>>u>>v>>a>>b;
        u--; v--;
        edge eu={v,a,b}, ev={u,a,b};
        d[u].pb(eu); d[v].pb(ev);
    }
    rep(i,N){
        ll c,k; cin>>c>>k;
        edge ec={i,-c,k};
        d[i].pb(ec);
    }
    rep(i,51) rep(j,5001) dp[i][j]=INF;
    E_queue Q;
    edge E={0,S,0};
    Q.push(E);
    vec ans(N,INF);
    ll Count=0;
    while(Count<N){
        E=Q.top();
        Q.pop();
        if(E.time<dp[E.place][E.cost]){
            dp[E.place][E.cost]=E.time;
            if(ans[E.place]>E.time){
                ans[E.place]=E.time;
                Count++;
            }
            rep(j,d[E.place].size()){
                edge F=d[E.place][j];
                if(E.cost-F.cost>=0 && E.cost-F.cost<=5000) if(dp[F.place][E.cost-F.cost]>E.time+F.time){
                    edge G={F.place,E.cost-F.cost, E.time+F.time};
                    Q.push(G);
                }
            }
        }
    }
    REP(i,1,N) cout<<ans[i]<<endl;


}

Measured memory_bytes: 17512
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    S = [input() for i in range(N)]

    a = b = ab = 0
    ans = 0
    for s in S:
        n = len(s)
        for j in range(n-1):
            if s[j] == "A" and s[j+1] == "B":
                ans += 1
        if s[0] == "B" and s[-1] == "A":
            ab += 1
        elif s[0] == "B":
            b += 1
        elif s[-1] == "A":
            a += 1

    if ab == 0:
        print(ans+min(a, b))
    elif a == 0 and b == 0:
        print(ans+ab-1)
    else:
        print(ans+ab+min(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 46808
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>



typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;
const ll INF = 1e16;

using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}


class Main{
public:
    Main(){
        
    }
    
    
    void run(){
        ll N,A,B;cin>>N>>A>>B;
        cout<<max((N-2) * (B-A) + 1, 0LL)<<endl;
    }
};

int main(){
    omajinai();
    Main().run();
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
int main(){
	int n;
	cin>>n;
	while(n--){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a<b||b>d)cout<<"No"<<endl;
		else{
			ll e=gcd(b,d);
			a%=e;
			if(c-a<0){
				cout<<"No"<<endl;
				continue;
			}
			a+=(c-a)/e*e;
			while(c>=a)a+=e;
			if(a-b>=0)cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
}







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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a, b; cin >> a >> b;
    string x; cin >> x;
    x[b - 1] = tolower(x[b - 1]);

    cout << x << '\n'; 
   
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1<<30)
d = 'ABC'
N, *v = map(int, input().split())
e = [tuple(map(d.index, input())) for _ in range(N)]
p = []
def f(i):
	if i == len(e):
		print('Yes')
		print('\n'.join(p))
		raise SystemExit
	k, j = e[i]
	for a, s in ((k, j), (j, k)):
		if v[s] == 0: continue
		v[a] += 1
		v[s] -= 1
		p.append(d[a])
		f(i+1)
		v[a] -= 1
		v[s] += 1
		p.pop()
f(0)
print('No')

Measured memory_bytes: 540492
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string a;
  cin >> a;
  cout << count(all(a),'+')*2-4 << endl;
}

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

int main() {
  int a, b;
  cin>>a>>b;
  int c;
  if (b < 10) {
    c = 10 * a + b;
  } else if (b < 100) {
    c = 100 * a + b;
  } else {
    c = 1000 * a + b;
  }
  int d = sqrt(c);
  if (d * d == c) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	
	long long a, b, c, d, x,y;
	cin >> a >> b >> c >> d;

	x = max(a * c, b * d);
	y = max(a * d, c * b);

	cout << max(x,y) << endl;
	
	
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll dp[n+1];
    fill(dp,dp+n+1,-inf);
    dp[0]=1000;
    ll ans=1000;
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n+1){
                ll y=dp[i]/a[j-1]*a[k-1];
                y+=dp[i]%a[j-1];
                Max(ans,y);
                Max(dp[k],y);
            }
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

const ll mod = 1e9+7;
const ll m = 1e9+7;

ll expo_mod(ll x, ll n) //Exponenciação rápida com módulo
{
    if (n == 0)
        return 1;

    ll t = expo_mod(x, n/2); //O resultado já é em módulo

    ll result = (t * t)%mod;

    if (n%2 == 1) //Se n é ímpar
        return (result * (x%mod))%mod; //(a * b) mod m = (a mod m * b mod m) mod m

    return result;
}

int main ()
{
    int n, x; cin >> n >> x;
    int contador = 0;
    for (int i = 0; i < n; i++)
    {
        int z; cin >> z;
        if (z >= x)
            contador++;
    }

    cout << contador << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;

  // Nは1〜100の間なのでベタ書き
  if( N <= 100 && N >= 64 ){
    ans = 64;
  } else if ( N < 64 && N >= 32 ){
    ans = 32;
  } else if ( N < 32 && N >= 16 ){
    ans = 16;
  } else if ( N < 16 && N >= 8 ){
    ans = 8;
  } else if ( N < 8 && N >= 4 ){
    ans = 4;
  } else if ( N < 4 && N >= 2 ){
    ans = 2;
  } else if ( N == 1 ){
    ans = 1;
  } 

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




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val p0 = s.count { it == '0' }
    val p1 = s.count { it == '1' }
    if (p0 > p1) {
        println(p1 * 2)
    } else {
        println(p0 * 2)
    }
}

Measured memory_bytes: 34368
//#pragma GCC optimize("O2")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;
using ld = long double;
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
//using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<20, mod = (119<<23)+1, lg = 19;
namespace bruh {
int h[maxn], p[maxn][lg], n;
vi g[maxn];
struct lcatree {
	lcatree() {
		h[1] = 1;
		dfs(1);
	}
	void dfs(int v) {
		for(int i = 1; i < lg; i++) p[v][i] = p[p[v][i-1]][i-1];
		for(auto i : g[v]) {
			if(h[i]) continue;
			p[i][0] = v, h[i] = h[v] + 1;
			dfs(i);
		}
	}
	int lca(int u, int v) {
		if(h[u] < h[v]) swap(u, v);
		for(int i = 0; i < lg; i++) if(((h[u]-h[v])>>i)&1) u = p[u][i];
		if(u == v) return u;
		for(int i = lg; i--;) if(p[u][i]!=p[v][i]) u = p[u][i], v = p[v][i];
		return p[u][0];
	}
	
};
};
struct node {
	ll sum = 0;
	node *l, *r;
	node(int x = 0) : sum(x), l(0), r(0) {}
};
deque<node> buffer;
using pnode = node*;
pnode newnode(int x) {
	buffer.emplace_back(x);
	return &buffer.back();
}
pnode merge(pnode l, pnode r) {
	pnode t = newnode(0);
	t->sum = l->sum + r->sum;
	t->l = l;
	t->r = r;
	return t;
}
pnode build(int l, int r) {
	if(l == r) return newnode(0);
	int mid = (l+r)>>1;
	return merge(build(l, mid), build(mid+1, r));
}
pnode upd(int l, int r, int i, int x, pnode rt) {
	if(i < l || i > r) return rt;
	if(l == r) return newnode(rt->sum + x);
	int mid = (l+r)>>1;
	return merge(upd(l, mid, i, x, rt->l), upd(mid+1, r, i, x, rt->r));
}
ll get(int l, int r, int ql, int qr, pnode rt) {
	if(qr < l || ql > r) return 0;
	if(ql <= l && r <= qr) return rt->sum;
	int mid = (l+r)>>1;
	return get(l, mid, ql, qr, rt->l) + get(mid+1, r, ql, qr, rt->r);
}
pnode rt[maxn];
int n, m;
vi h[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int l, r, i = 0; i < n; i++) {
		cin >> l >> r;
		h[l].pb(r);
	}
	for(int i = 0; i <= m; i++) {
		if(i)
			rt[i] = rt[i-1];
		else
			rt[i] = build(0, m);
		for(auto j : h[i]) rt[i] = upd(0, m, j, 1, rt[i]);
		//cout << i << ":\n";
		//for(int j = 0; j <= m; j++) cout << get(0, m, j, j, rt[i]) << ' '; cout << '\n';
	}
	for(int i = 1; i <= m; i++) {
		int ans = 0;
		for(int j = 0; j <= m; j += i) {
			ans += get(0, m, j, min(m, j+i-1), rt[j]);
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 191992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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

int main() {

	int n, k;
	std::cin >> n >> k;
	std::vector<int> h(n);
	rep(i, n) std::cin >> h[i];

	int ans = 0;
	rep(i, n) {
		if (h[i] >= k) ans++;
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 640
// 解説pdf通りに実装

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

const int MAX = 1e9;
int main(void)
{
    cin.sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> cells_ini(H);
    REP(h, H) cin >> cells_ini[h];

    // 縦横入れ替え
    vector<string> cells(W);
    REP(h, H) REP(w, W) {
        cells[w] += cells_ini[h][w];
    }

    int ret = 0;

    // i列目とi+1(=j)列目との間での処理を考える
    REP(i, W - 1) {
        auto j = i + 1;

        // 初期状態から、i列目をx段、2列目をy段沈めるまでのコスト
        vector<vector<int>> dp(H + 1, vector<int>(H + 1, MAX));

        // i列目がx, j列目がy沈んでいるときのコストを前計算しておく
        vector<vector<int>> cost(H + 1, vector<int>(H + 1));

        // 愚直にやるとH^3で間に合わない　以下はそのコード
        //REP(x,H+1) {
        //    REP(y,H+1) {
        //        REP(h, H) {
        //            if (h >= x && h >= y) {
        //                cost[x][y] += (cells[i][h-x] == cells[j][h-y]);
        //            }
        //        }
        //    }
        //}

        // 改善版
        for (int y = H - 1; y >= 0; --y) {
            for (int x = H - 1; x >= 0; --x) {
                cost[x][y]
                    = cost[x + 1][y + 1]
                    + (cells[i][H - x - 1] == cells[j][H - y - 1]);
            }
        }

        dp[0][0] = 0;
        FOR(sum, 1, 2*H+1) {
            REP(x, sum+1) {
                auto y = sum - x;
                if (x > H || y > H) continue;
                if (x-1 >= 0) dp[x][y] = min(dp[x][y], dp[x - 1][y] + cost[x - 1][y]);
                if (y-1 >= 0) dp[x][y] = min(dp[x][y], dp[x][y - 1] + cost[x][y - 1]);
            }
        }
        ret += dp[H][H];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1320
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N, M;
vector<long long> A,dev;

int main() {
	cin >> N >> M;
	A.resize(N+1);
	for (int n = 1; n <= N; n++)cin >> A[n];
	dev.resize(N + 1);
	dev[0] = 0;
	for (int n = 1; n <= N; n++) {
		dev[n] = (dev[n - 1] + A[n]) % M;
	}
	sort(dev.begin(), dev.end(), [](long long a, long long b) {
		return a < b;
	});
	dev.push_back(INT_MAX);
	long long ans = 0;
	long long counter = 1;
	for (int n = 1; n <= N+1; n++) {
		if (dev[n] == dev[n - 1])counter++;
		else {
			ans += counter * (counter - 1) / 2;
			counter = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
N,K,*as = `dd`.split.map &:to_i
as.sort!
$stderr.puts N,K,as*" "
ndd = K
nndd = 0
p (0...N).bsearch{ |i|  
  a = as[i]
  next true if ndd <= a
  next false if a <= nndd
  h = { 0 => 1 }
  q = [0]
  ka = K - a
  needed = ka <= 0 && 0 < K
  (0...N).each{ |j|
    b = as[j]
    next if i == j || K <= b
    (0...q.size).each{ |l|
      x = b+q[l]
      next if h[x]
      next if K <= x
      #p [q.size,q[-1]]
      h[x] = 1
      q << x
      if ka <= x
        needed = true; break
      end
    }
    break if needed
  }
  #p [i,a,K-a,K,h.keys.size,needed]
  ndd = a if needed && a < ndd
  nndd = a if !needed && nndd < a
  needed
} || N

#$stderr.puts [ndd,nndd]

Measured memory_bytes: 6652
#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<long long>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;

const ll N=2e5+5;
ll dp[N][2];
ll back[N][2];

void func()
{ 
  string s;
  cin>>s;
  
  dp[0][0]=dp[0][1]=0;

  f(i,1,s.length()+1)
  {
    if(s[i-1]=='P') dp[i][0]=0,back[i][0]=-1;
    else
    {
        ll op1=dp[i-1][0];
        ll op2=0;
        if(dp[i-1][1]!=0) op2=1+dp[i-1][1];
        if(op1>op2) 
        {
            back[i][0]=0;
            dp[i][0]=1+op1;
        }

        else
        {
            back[i][0]=1;
            dp[i][0]=1+op2;
        }
    }

    if(s[i-1]=='D') dp[i][1]=0,back[i][1]=-1;
    else
    {
      if(dp[i-1][0]>dp[i-1][1])
      {
        dp[i][1]=dp[i-1][0];
        back[i][1]=0;
      }

      else
      {
        dp[i][1]=dp[i-1][1];
        back[i][1]=1;
      }
    }
  }

  ll n=s.length();
  if(dp[n][0]>dp[n][1])
  {
    stack<char>ans;
    ll i=n,j=0;
    while(i>0)
    {
        if(j==0) ans.push('D');
        else ans.push('P');
        j=back[i][j];
        i--;
    }
    while(!ans.empty())
    {
        cout<<ans.top();
        ans.pop();
    }
    nl
  }

  else
  {
    stack<char>ans;
    ll i=n,j=1;
    while(i>0)
    {
        if(j==0) ans.push('D');
        else ans.push('P');
        j=back[i][j];
        i--;
    }
    while(!ans.empty())
    {
        cout<<ans.top();
        ans.pop();
    }
    nl
  }
}   
     
     
int main() 
{
    //fast
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }     
    return 0;
}

Measured memory_bytes: 10092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Elementary Number Theory - Prime Factorize
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);

			StringBuilder sb = new StringBuilder();
			sb.append(n + ":");

			int d = 2;
			while (n != 1) {
				if (n % d == 0) {
					sb.append(" " + d);
					n /= d;
				} else {
					if (d == 2) d = 3;
					else d += 2;
				}
			}
			System.out.println(sb.toString());

		}//end while
	}//end main
}

Measured memory_bytes: 24852
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] vs = str.Split(new char[] { ' ' });
            int W = int.Parse(vs[0]);
            int H = int.Parse(vs[1]);
            int x = int.Parse(vs[2]);
            int y = int.Parse(vs[3]);
            int r = int.Parse(vs[4]);
            if (y + r > H | x + r > W)
            {
                Console.WriteLine("No");
            }
            else if (x < r | y < r)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}



Measured memory_bytes: 17932
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
 
int n;
int v[100000];
int cnt[2][100000];
vector<P> vec1, vec2;
 
int main() {
	int i, j;
	
	cin >> n;
	rep(i, n) {
		cin >> v[i];
		v[i]--;
		cnt[i % 2][v[i]]++;
	}
	
	rep(i, 100000) {
		vec1.push_back(P(n/2 - cnt[0][i], i));
		vec2.push_back(P(n/2 - cnt[1][i], i));
	}
	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());
	
	int ans = 114514;
	rep(i, 2) {
		rep(j, 2) {
			if (vec1[i].second == vec2[j].second) continue;
			ans = min(ans, vec1[i].first + vec2[j].first);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; };
}
void solve() {
  map<int, int> mp;
  //  sort(all(A));
  for (auto x : A) {
    mp[x]++;
  }
  int ans = 0;
  for (auto x : mp) {
    if (x.second % 2) ans++;
  }
  cout << ans << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

namespace AtCoder
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var words = Enumerable.Range(0, n).Select(_ => Console.ReadLine()).ToArray();

			for (var i = 1; i < words.Length; i++)
			{
				var current = words[i];
				var previous = words[i - 1];

				if (words.Take(i).Contains(current) ||
					current.First() != previous.Last())
				{
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}


Measured memory_bytes: 11476
N,a,b = map(int,input().split(" "))
total= 0
ans = 0
for i in range(1,N+1):
    st_i = str(i)
    for j in range(4):
        try:
            total += int(st_i[j])
        except:
            pass


    if a <= total <= b:
        ans += i
    total = 0

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int x, y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

int main(void)
{
  string S;
  cin >> S;
  int ret;
  if(S=="SUN")
  {
      ret = 7;
  }
  else if(S=="MON")
  {
    ret = 6;
  }
   else if(S=="TUE")
  {
    ret = 5;
  }
   else if(S=="WED")
  {
    ret = 4;
  }
   else if(S=="THU")
  {
    ret = 3;
  }
   else if(S=="FRI")
  {
    ret = 2;
  }
  else
  {
    ret = 1;
  }
      
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(A + B == C) {
			System.out.println(A + 2 *B);
		}else if(A + B < C) {
			System.out.println(A + 2 * B + 1);
		}else {
			System.out.println(B + C);
		}
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline int kazu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}

int N, K, A[2005], ans = 0;

int main(){
	getint(N), getint(K);
	for(register int i = 1; i <= N; i++) getint(A[i]);
	for(register int i = 1; i <= N; i++){
		register int cnt = 0, cntr = 0;
		for(register int j = 1; j < i; j++) if(A[j] < A[i]) cnt++;
		for(register int j = i + 1; j <= N; j++) if(A[j] < A[i]) cntr++;
		cnt += cntr, ans = kazu(ans, kazu(cntr * (ll)K % MOD, ((K - 1LL) * K >> 1) % MOD * cnt % MOD));
	}
	return printf("%d\n", ans), 0;
}

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

int main(){
long long N,ans;
  cin>>N;
ans=1;
  string c;
  cin>>c;
  vector<int>b(26);
    for(int i=0;i<N;i++){
   b[c[i]-'a']++;
  }
  for(int i=0;i<26;i++){
  ans*=(b[i]+1);
ans%=1000000007;
  }
  cout<<ans-1<<endl;
}


Measured memory_bytes: 512
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long STACK_SIZE=8*1024*1024;
		new Thread(null, new B(), "RUN", STACK_SIZE).start();
	}
	
	class B implements Runnable{
		B(){}
		@Override public void run(){
			while(sc.hasNext()){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		
		int N;
		
		void solve(){
			String[] a=new String[N],b=new String[N];
			for(int i=0; i<N; ++i){
				a[i]=sc.next();
				b[i]=sc.next();
			}
			
			String g=sc.next(),s=sc.next();
			
			PriorityQueue<State> open=new PriorityQueue<State>();
			open.add(new State(g,0));
			
			ArrayList<HashSet<String>> closed=new ArrayList<HashSet<String>>();
			closed.add(new HashSet<String>());
			closed.get(0).add(g);
			
			int ans=-1;
			while(!open.isEmpty()){
				
				State now=open.poll();
				
				//System.out.println("now = " + now);
				
				if(now.s.equals(s)){
					//System.out.println("ANS:"+now.s);
					ans=now.step;
					break;
				}
				
				for(int i=0; i<N; ++i){
					
					if(!now.s.matches(".*?"+a[i]+".*?"))	continue;
					
					String tmp=now.s.replaceAll(a[i], b[i]);
					
					if(tmp.length()>s.length())	continue;
					
					//System.out.println("temp = " + tmp+" "+(now.step+1));
					
					if(now.step+1 >= closed.size()){
						closed.add(new HashSet<String>());
					}else if(closed.get(now.step+1).contains(tmp)){
						continue;
					}
					
					for(int j=1; j<=now.step+1; ++j)	closed.get(j).add(tmp);
					open.add(new State(tmp, now.step+1));
					
					
				}
				
			}
			
			System.out.println(ans);
			
		}
		
		class State implements Comparable<State>{
			String s;
			int step;
			State(String s,int step){
				this.s=s;
				this.step=step;
			}
			@Override public int compareTo(State s){
				return this.step-s.step;
			}
			@Override public String toString(){
				return s+" "+step;
			}
		}
		
	}
}

Measured memory_bytes: 14000
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <cmath>
//#include <vector>
//#include <time.h>
#include <queue>
//#include <stack>
//#include <map>
//#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
int a[10000];
int main()
{
    char ch[1000];
    char c;
    int l=500,r=500;
    while(~scanf("%c",&c))
    {
        if(c=='0')
            ch[r++]='0';
        if(c=='1')
            ch[r++]='1';
        if(c=='B'&&l!=r)
            r-=1;
    }
    for(int i=l;i<r;i++)
    {
        cout<<ch[i];
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A%3==0 || B%3==0 || (A+B)%3==0){
			System.out.println("Possible");
		} else{
			System.out.println("Impossible");
		}
	}
}

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

int main() {

  int input[3];
  cin >> input[0] >> input[1] >> input[2];

  sort(input, input+3);

  int l, m, s;
  l = input[2];
  m = input[1];
  s = input[0];

 // (l-m)回mとsに１を足す
 //  l-(s+l-m)/2回sに2を足す。

  int ans = ((m-s)%2 == 0) ?  (l-m)+(m-s)/2 : 2+(l-m)+(m-s)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
    string ret = "<";
    for (auto it : v) {
        ret += to_string(it) + ", ";
    }
    ret.pop_back(); ret.pop_back();
    ret += ">";
    return ret;
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
    cerr << " " << to_string(t);
    debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

ll bfs(ll k) {
    queue<ll> q;
    for (ll i = 1; i < 10; i++)
        q.push(i);
    while (k) {
        k--;
        ll now = q.front();
        q.pop();
        if (k == 0)
            return now;
        for (ll i = -1; i < 2; i++) {
            ll cur = (now % 10) + i;
            if (0 <= cur && cur <= 9) {
                q.push(10 * now + cur);
            }
        }
    }
    return q.front();
}

int main() {
    ll a;
    cin >> a;
    cout << bfs(a) << endl;
    return 0;
}

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

int main(void){
  int k,a,b; cin >> k >> a >> b;
  for(int i = 1; i < 1001; i++){
    if(i % k == 0 && a <= i  && i <= b){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3620
def resolve():
    weather = input()
    if weather[0] == 'R':
        if weather[1] == 'R':
            if weather[2] == 'R':
                print(3)
            else:
                print(2)
        else:
            print(1)
    else:
        if weather[1] == 'R':
            if weather[2] == 'R':
                print(2)
            else:
                print(1)
        else:
            if weather[2] == 'R':
                print(1)
            else:
                print(0)
resolve()

Measured memory_bytes: 61852
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  rep(i,N) cin>>a[i];
  rep(i,N) cin>>b[i];
  rep(i,N) c[i]=i+1; 
  map<vector<int>, int> mp;
  do{
    mp[c]=mp.size();
  } while (next_permutation(c.begin(),c.end()));
  int ans=abs(mp[a]-mp[b]);
  cout<<ans<<endl;
}

Measured memory_bytes: 8680
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

bool isA(const string &str){
  int n = str.size();
  int m = 0;
  int pos = 2;
  if(n == 0 || n==1) return false;
  if(str[0] != '>') return false;
  if(str[1] != '\'') return false;
  while(pos < n && str[pos] == '=') {m++; pos++;}
  if(pos == n || m == 0) return false;
  if(str[pos++] != '#') return false;
  while(pos < n && str[pos] == '=') {m--; pos++;}
  if(pos == n) return false;
  if(str[pos++] != '~') return false;
  if(m == 0 && pos == n) return true;
  return false;
}

bool isB(const string &str){
  int n = str.size();
  int pos = 2;
  int m = 0;
  if(n == 0 || n == 1) return false;
  if(str[0] != '>') return false;
  if(str[1] != '^') return false;
  while(pos+1 < n && str[pos] == 'Q' && str[pos+1] == '=') {m++; pos+=2;}
  if(m == 0) return false;
  if(pos+2 != n) return false;
  if(str[pos] == '~' && str[pos+1] == '~') return true;
  return false;
}

int main(){
  int n;
  string str;
  getline(cin,str); sscanf(str.c_str(),"%d",&n);
  while(n --> 0){
    getline(cin,str);
    if(isA(str)) puts("A");
    else if(isB(str)) puts("B");
    else puts("NA");
  }
  return 0;
}

Measured memory_bytes: 0
use std::io;


fn main() {
    let _ = read_one::<usize>();
    let an = read::<usize>()
        .iter().sum::<usize>();

    if an % 2 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 6396
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;

int main() {

  cin >> N;

  if (N%2 == 0) {
    printf("%.10f\n", (double(N/2))/N);
  } else {
    printf("%.10f\n", (double(N/2 + 1))/N);
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int N=205;
const int MOD=998244353;
int n;
int x[N],y[N];
int Pow[N];
int mul (int a,int b,int c)
{
	int x_1=x[a]-x[c],y_1=y[a]-y[c];
	int x_2=x[b]-x[c],y_2=y[b]-y[c];
	return x_1*y_2-x_2*y_1;
}
bool check (int x,int y)
{
	for (int u=1;u<y;u++)
	{
		if (u==x) continue;
		if (mul(x,y,u)==0)	
		{
		//	printf("NO:%d %d %d\n",x,y,u);
			return false;
		}
	}
	return true;
}
int dec (int x,int y)	{x=x-y;return x<0?x+MOD:x;}
int main()
{
	scanf("%d",&n);
	Pow[0]=1;for (int u=1;u<=n;u++) Pow[u]=Pow[u-1]*2%MOD;
	for (int u=1;u<=n;u++) scanf("%d%d",&x[u],&y[u]);
	int ans=dec(Pow[n],n+1);
	for (int u=1;u<=n;u++)
		for (int i=u+1;i<=n;i++)
			if (check(u,i))//这条线有没有枚举过
			{
			//	printf("YES:%d %d\n",u,i);
				int cnt=2;
				for (int j=i+1;j<=n;j++) cnt=cnt+(mul(u,i,j)==0);
				ans=dec(ans,dec(Pow[cnt],cnt+1));
			}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: i64,
        k: u64,
        d: u64
    }
    let x = x.abs() as u64;
    if k <= x / d {
        println!("{}", x - k * d);
    } else {
        let kk = k - x / d;
        if kk % 2 == 0 {
            println!("{}", x % d);
        } else {
            println!("{}", d - x % d);
        }
    }
}


Measured memory_bytes: 2200
#include<iostream>
using namespace std;
       
struct Card{ char suit,value; };
       
void bubbleSort(struct Card A[],int N){
   for(int i=0;i<N;i++){
     for(int j=N-1;j>=i;j--){
       if(A[j].value<A[j-1].value){
         Card t = A[j];A[j] = A[j-1];A[j-1] = t;
       }
     }
   }
}
       
void selectionSort(struct Card A[],int N){
   for(int i=0;i<N;i++){
     int minj = i;
     for(int j=i;j<N;j++){
       if(A[j].value<A[minj].value)minj = j;
     }
     Card t = A[i];A[i] = A[minj];A[minj] = t;
   }
}
       
       
void print(struct Card A[],int N){
   for(int i=0;i<N;i++){
     if(i>0)cout << " ";
     cout << A[i].suit << A[i].value;
   }
   cout << endl;
}
       
bool isStable(struct Card C1[],struct Card C2[],int N){
   for(int i=0;i<N;i++){
     if(C1[i].suit != C2[i].suit)return false;
   }
   return true;
}
       
int main(){
   Card C1[100],C2[100];
   int N;
   char ch;
       
   cin >> N;
   for(int i=0;i<N;i++){
     cin >> C1[i].suit >> C1[i].value;
   }
       
   for(int i=0;i<N;i++)C2[i] = C1[i];
       
   bubbleSort(C1,N);
   selectionSort(C2,N);
          
   print(C1,N);
   cout << "Stable" << endl;
   print(C2,N);
   if(isStable(C1,C2,N)){
   cout << "Stable" << endl;
   }else{
   cout <<"Not stable" << endl;
   }
       
   return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

int n;
int k;
int xy[2005][2005];
int s[4005][4005];

int get(int x, int y) {
	return s[x + k - 1][y + k - 1] + s[x - 1][y - 1] - s[x - 1][y + k - 1] - s[x + k - 1][y - 1];
}

int main() {
	std::cin >> n >> k;

	int k2 = 2 * k;
	int k4 = 4 * k;
	for (int i = 0; i < n; ++i) {
		int x, y; char c;
		std::cin >> x >> y >> c;
		if (c == 'W') {
			x += k;
		}
		++xy[x % k2 + 1][y % k2 + 1];
	}

	for (int i = 1; i <= k4; ++i) {
		for (int j = 1; j <= k4; ++j) {
			s[i][j] = s[i][j - 1] + xy[(i - 1) % k2 + 1][(j - 1) % k2 + 1];
		}
	}
	for (int j = 1; j <= k4; ++j) {
		for (int i = 1; i <= k4; ++i) {
			s[i][j] += s[i - 1][j];
		}
	}

	int ans = 0;
	for (int i = 1; i <= k2; ++i) {
		for (int j = 1; j <= k2; ++j) {
			ans = std::max(ans, get(i, j) + get(i + k, j + k));
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 78592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		String[] inputSplit = input.split("");
		int num0 = 0;
		for (int i = 0; i < inputSplit.length; i++) {
			if (inputSplit[i].equals("0")) {
				num0++;
			}
		}
		System.out.print(Math.min(num0, inputSplit.length - num0) * 2);
	}
}

Measured memory_bytes: 33144
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    to = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a] = max(to[a], h[b])
        to[b] = max(to[b], h[a])
    ans = 0
    for hi, ti in zip(h, to):
        if hi > ti:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19868