akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ

int main(){
    string s;
    cin>>s;
    int n = s.length();
    int i=n-1;
    while(i>0){
        if(s[i]=='m'&&s[i-1]=='a'&&s[i-2]=='e'&&s[i-3]=='r'&&s[i-4]=='d'){
            i -= 5;
        }
        else if(s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='m'&&s[i-3]=='a'
        &&s[i-4]=='e'&&s[i-5]=='r'&&s[i-6]=='d'){
            i -= 7;
        }
        else if(s.substr(i-4,5)=="erase"){
            i -= 5;
        }
        else if(s.substr(i-5,6)=="eraser"){
            i -= 6;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
fn main() {
    let n: i64 = read();
    let blue: i64 = read();
    let red: i64 = read();

    let repeat_cnt = n / (blue + red);
    let mut sum = repeat_cnt * blue;
    let diff = n % (blue + red);
    if diff > blue {
        sum += blue;
    } else {
        sum += diff;
    }
    println!("{}", sum);
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int n,d,c=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d);
    if(i%2==0&&d%2==1)c++;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 1720
def resolve():
    A,B,C = map(int,input().split())
    K = int(input())
    for i in range(K+1):
        for j in range(K-i+1):
            for k in range(K+1-i-j):
                a = A*(2**i)
                b = B*(2**j)
                c= C*(2**k)
                #print(i,j,k)
                if b>a and c>b:
                    print("Yes")
                    return
    print('No')

resolve()

Measured memory_bytes: 61740
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *a = ALLOC (n * n, i32);
  for (i32 i = 0; i < n * n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i64 *dp = ALLOC (1 << n, i64);
  for (i32 i = 1; i < (1 << n); ++i) {
    i64 sum = 0;
    for (i32 j = 0; j < n; ++j) {
      if (((i >> j) & 1) == 0) continue;
      for (i32 k = j + 1; k < n; ++k) {
        if (((i >> k) & 1) == 0) continue;
        sum += a[j * n + k];
      }
    }
    i64 max = MAX (0, sum);
    for (i32 j = (i - 1) & i; j > (i ^ j); j = (j - 1) & i) {
      i64 x = dp[j] + dp[i ^ j];
      max = MAX (max, x);
    }
    dp[i] = max;
  }
  printf ("%" PRIi64 "\n", dp[(1 << n) - 1]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
	int a = 0, b = 0;
	int length = 0, sheeld = 0;
	
	cin >> a >> b;
	
	length = (a + b) * 2;
	sheeld = a * b;
	
	cout << sheeld << " " << length << endl;
	
	return 0;
}

Measured memory_bytes: 1164
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    n,k = readline() |> split |> parseMap
    if n<2*k-1
        println(-1)
    else
        for i in 0:(n-1)>>1
            println(k+n-1-2*i, " ", k+n+n>>1+i, " ",k+3*n-1-i)
        end
        for i in 0:(n-2)>>1
            println(k+n-2-2*i, " ", k+n+i, " ", k+3*n-1-(n+1)>>1-i)
        end
    end
end

main()

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vector<double> x(n),y(n),a(n);
    rep(i,n) cin >> x[i] >> y[i];
    rep(i,n) a[i] = i;
    double res = 0.0;
    ll count = 0;
    do{
        double ans =0.0;
        rep(i,n-1){
        ans+=hypot(x[a[i]]-x[a[i+1]],y[a[i]]-y[a[i+1]]);
        }
        count++;
        res+=ans;
    }while(next_permutation(all(a)));
    cout << fixed << setprecision(10) << res/count << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAX 10000
#define NIL -1

struct Node{int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setDepth(int u,int d){
	if(u==NIL)return;
	D[u]=d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}
int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].left!=NIL)
		h1=setHeight(T[u].left)+1;
	if(T[u].right!=NIL)
		h2=setHeight(T[u].right)+1;
	return H[u]=(h1>h2?h1:h2);
}
int getSibling(int u){
	if(T[u].parent==NIL)return NIL;
	if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
		return T[T[u].parent].right;
	return NIL;
}
void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg=0;
	if(T[u].left!=NIL)deg++;
	if(T[u].right!=NIL)deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);

	if(T[u].parent==NIL){
		printf("root\n");
	}else if(T[u].left==NIL&& T[u].right==NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}

int main(){
	int v,l,r,root=0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i) {T[i].parent=NIL;}
	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL)T[l].parent=v;
		if(r!=NIL)T[r].parent=v;
	}
	for (int i = 0; i < n; ++i) {if(T[i].parent==NIL)root=i;}
	setDepth(root,0);
	setHeight(root);
	for (int i = 0; i < n; ++i) {print(i);}
	return 0;
}

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

#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'

#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

#ifndef __LOCAL
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout); FAST;
#else
#define FILES(namein, nameout) FAST;
#endif //__LOCAL

using namespace std;
using namespace __gnu_pbds;
using python = void;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned short uss;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type> ordered_set;

const ll M = 1e9+7;
const ll N = 1e5+228;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
ll a[N], dp[N];
python solve(){
	FAST;
	ll n;
	cin >> n;
	for(ll i = 0;i<n;i++){
		cin >> a[i];
		dp[i] = min((i>0 ? dp[i-1] + abs(a[i]-a[i-1]) : inf), (i>1 ? dp[i-2] + abs(a[i]-a[i-2]) : inf));
		if(!i) dp[i] = 0;
	}
	cout << dp[n-1] << '\n';
}

signed main(){
	FAST;
	ll q = 1;
	//cin >> q;
	while(q--){
		solve();
	}
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;

int n;

bool equal(const std::vector<ll>& a, const std::vector<ll>& b) {
	rep(i, n) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

int main(void)
{
	cin >> n;
	vector<ll> ps(n);
	vector<ll> qs(n);
	rep(i, n)cin >> ps[i];
	rep(i, n)cin >> qs[i];
	vector<ll> v(n);
	rep(i, n) {
		v[i] = i + 1;
	}

	ll a = -1;
	ll b = -1;

	ll index = 0;
	do {
		index++;
		if (equal(v, ps)) {
			a = index;
		}
		if (equal(v, qs)) {
			b = index;
		}
		if (a >= 0 && b >= 0) break;
	} while (std::next_permutation(v.begin(), v.end()));
	cout << abs(a-b) << endl;
	return 0;
}


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

typedef long long int ll;
typedef long double ld;


int main(){
    ll n,k,x,y,ans;
    cin >> n >> k >> x >> y;
    for(ll i=0;i<n;++i){
        if(i>=k){
            ans+=y;
            continue;
        }
        ans+=x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[3][100100];
ll num[3][100100];

ll solve() {
    for (int i = 0; i < 3; i++) {
        sort(a[i], a[i]+n);
        a[i][n] = inf;
    }
    for (int i = 0; i < n; i++) num[2][i] = n - i;
    for (int i = 1; i >= 0; i--) {
        int k = n;
        for (int j = n-1; j >= 0; j--) {
            while (k > 0 && a[i][j] < a[i+1][k-1]) k--;
            num[i][j] = num[i][j+1] + num[i+1][k];
        }
    }
    return num[0][0];
}

void input() {
    cin >> n;
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;

double D(P a,P b) {
  int x1=floor(a.F/10)*10,x2=floor(b.F/10)*10,y1=floor(a.S/10)*10,y2=floor(b.S/10)*10;
  if(x1!=a.F&&x2!=b.F&&x1==x2&&y1!=y2) {
    double d1=fabs(a.F-x1),d2=fabs(b.F-x2);
    return fabs(a.S-b.S)+min(d1+d2,20-d1-d2);
  } else if(y1!=a.S&&y2!=b.S&&y1==y2&&x1!=x2) {
    double d1=fabs(a.S-y1),d2=fabs(b.S-y2);
    return fabs(a.F-b.F)+min(d1+d2,20-d1-d2);
  }
  return fabs(a.F-b.F)+fabs(a.S-b.S);
}

int n,M=1<<29;
P a[11111];
double solve(int x,int y,double s,double t) {
  double ans=M;
  for(double l=x-30; l<=x+30; l+=s) {
    for(double r=y-30; r<=y+30; r+=t) {
      double d=0;
      for(int i=0; i<n; i++) d=max(d,D(a[i],P(l,r)));
      ans=min(ans,d);
    }
  }
  return ans;
}

int main() {
  cin >> n;
  double Max=-M,Mix=M,May=-M,Miy=M;
  for(int i=0; i<n; i++) {
    cin >> a[i].F >> a[i].S;
    Max=max(Max,a[i].F+a[i].S);
    Mix=min(Mix,a[i].F+a[i].S);
    May=max(May,a[i].F-a[i].S);
    Miy=min(Miy,a[i].F-a[i].S);
  }
  int xx=(Max+Mix)/2,yy=(May+Miy)/2;
  int x=floor((double)(xx+yy)/20)*10,y=floor((double)(xx-yy)/20)*10;
  printf("%.10f\n",min(solve(x,y,10,0.5),solve(x,y,0.5,10)));
  return 0;
}

Measured memory_bytes: 3460
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(10));
    vector<vector<int>> c(n,vector<int>(11));
    rep(i,n){
        rep(j,10){
            cin >> a[i][j];
        }
    }

    rep(i,n){
        rep(j,11){
            cin >> c[i][j];
        }
    }
    int res = -1000000000;
    for(int i=1;i<(1<<10);i++){
        int ans=0;
        rep(j,n){
            int cnt=0;
            rep(l,10){
                if((i>>l&1)&&a[j][l]){
                    cnt+=1;
                }
            }
            ans+=c[j][cnt];
        }
        if(res<ans){
            res = ans;
        }
    }
    cout << res << endl;

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000003
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, m, sum = 0, res = 0;
    cin>>n;
    m = n%10;
    if(m == 3)
        cout<<"bon";
    else if(m == 0 || m == 1 || m == 6 || m == 8)
        cout<<"pon";
    else
        cout<<"hon";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }



int main() {
  int N;
  scanf("%d", &N);
  deque<int> a;
  int input;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &input);
    if(N%2==i%2){
      a.push_front(input);
    }
    else{
      a.push_back(input);
    }
  }

  FOR(i,0,N-1){
    cout << a[i] << " " ;
  }

}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	for(int i = n; i > 0; i--) {
		for(int j = i+i; j <= n; j += i) {
			a[i-1] ^= a[j-1];
		}
	}
	int m = 0;
	rep(i, n) {
		if(a[i]) m++;
	}
	cout << m << endl;
	rep(i, n) {
		if(a[i]) cout << i+1;
		printf("%c", (i == n-1) ? '\n' : ' ');
	}
	
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int n,k,x,y;
		
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k)
	printf("%d\n",(k*x)+(n-k)*y);
	else
	printf("%d\n",n*x);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){

    int a,b,c;

    scanf("%d%d%d",&a,&b,&c);

    if(a<=b&&b<=c){
        printf("%d %d %d\n",a,b,c);
    }

    else if(a<=b&&b>=c){
        if(a<=c)printf("%d %d %d\n",a,c,b);

        else if(a>=c)printf("%d %d %d\n",c,a,b);
    }

    else if(b<=a&&a>=c){
        if(b<=c)printf("%d %d %d\n",b,c,a);

        else if(c<=b)printf("%d %d %d\n",c,b,a);


    }

    else if(b<=a&&a<=c)printf("%d %d %d\n",b,a,c);



    return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
const int  MOD = 1e9 + 7;
const int  N = 1e5 + 7;
int dp[N];



//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    int n , k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    dp[0] = 0;
    for(int i = 1 ; i <= k ; i++){
        for(int j = 0 ; j < n ; j++){
            if(a[j] > i) break;
            if(dp[i-a[j]] == 0) {
                dp[i] = 1;
                continue;
            }
        }
    }
    if(dp[k]){
        cout<<"First"<<endl;
    }else cout<<"Second"<<endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  int n;
  cin >> n;
  int m = n * 3;

  vector<ll> v(m);
  rep(i, m) { cin >> v[i]; }

  sort(all(v), greater<ll>());
  ll sum = 0;
  rep(i, n) {
    sum += v[1 + 2 * i];
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 2560
// Written By NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 65537, mod = 1e9 + 7;
int bin[121], ed[maxN], dp[2][maxN];

int main() {
    int n = read(), m = read(), lim = (1 << n), i, j, k, ans = 0;
    bin[0] = 1;
    for (i = 1; i <= m; ++i) {
        bin[i] = (bin[i - 1] << 1) % mod;
        ++ed[(1 << (read() - 1)) | (1 << (read() - 1))];
    }
    for (i = 0; i < n; ++i)
        for (j = 0; j < lim; ++j)
            if (j >> i & 1)
                ed[j] += ed[j ^ (1 << i)];
    
    for (i = 0; i < lim; ++i) {
        if (i & 1) {
            for (j = (i - 1) & i; j; j = (j - 1) & i)
                if (j & 1)
                    dp[0][i] = (1ll * dp[0][j] * bin[ed[i ^ j]] + dp[0][i]) % mod;
            dp[0][i] = (bin[ed[i]] - dp[0][i]) % mod;
        }
        if (i & 2) {
            for (j = (i - 1) & i; j; j = (j - 1) & i)
                if (j & 2)
                    dp[1][i] = (1ll * dp[1][j] * bin[ed[i ^ j]] + dp[1][i]) % mod;
            dp[1][i] = (bin[ed[i]] - dp[1][i]) % mod;
        }
    }
    
    for (i = 0; i < lim; ++i)
        if ((i & 1) && (~i & 2))
            for (j = k = (lim - 1) ^ i; j; j = (j - 1) & k)
                if ((j & 2) && ed[i | j] == ed[i] + ed[j])
                    ans = (1ll * dp[0][i] * dp[1][j] % mod * bin[ed[(lim - 1) ^ i ^ j]] + ans) % mod;

    printf("%d\n", ((bin[m] - ans) % mod + mod) % mod);
    return 0;
}


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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+100000000
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
            
           ll n;
           cin >> n;
           ll ma = 0LL;
           
           ll ans[n + 1] = {0};
           
           for(ll i = 1; i <= n; i++) {
                ll a, b;
                cin >> a >> b;
                if(a == b) {
                        ans[i]++;
                        ans[i] += ans[i - 1];
                }
               
                ma = max(ma, ans[i]);
           }
           
           if(ma >= 3) {
                cout << "Yes" << endl;
           } else {
                cout << "No" << endl;
           }
            
            
}


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

    int t=1;
   // cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define PMAX_A 110
#define PMAX_B 110

#define NN (PMAX_A+PMAX_B+2)

int vv[NN][NN];
int flag[NN];

int flow(int s, int e, int f){
  if(s == e)return f;

  flag[s] = 1;

  for(int i = 0; i < NN; i++){
    if(vv[s][i] > 0 && flag[i] == 0){
      int d = flow(i, e, min(f, vv[s][i]));
      if(d > 0){
        vv[s][i] -= d;
        vv[i][s] += d;
        return d;
      }
    }
  }
  return 0;
}

void ae(int from, int to, int cost){
  vv[from][to] = cost;
  vv[to][from] = 0;
}

int pmatch(int pa[PMAX_A][PMAX_B]){
  memset(vv,-1,sizeof(vv));

  for(int i = 1; i <= PMAX_A; i++){
    ae(0,i,1);
  }

  for(int i = 0; i < PMAX_A; i++){
    for(int j = 0; j < PMAX_B; j++){
      if(pa[i][j] == 1){
        ae(i+1,j+PMAX_A+1,1);
      }
    }
  }

  for(int i = PMAX_A+1; i <= PMAX_A+PMAX_B; i++){
    ae(i,PMAX_A+PMAX_B+1,1);
  }

  int ans = 0;

  for(;;){
    memset(flag,0,sizeof(flag));
    int f = flow(0, PMAX_A+PMAX_B+1, 1000000000);
    if(f == 0)break;
    ans += f;
  }

  return ans;
}

int main() {
  int pa[PMAX_A][PMAX_B];

  memset(pa,0,sizeof(pa));

  ll n;
  cin>>n;
  vector<ll> va1;
  vector<ll> va2;
  rep(i,0,n){
  	ll a,b;
  	cin>>a>>b;
  	va1.pb(a);
  	va2.pb(b);
  }
  vector<ll> vb1;
  vector<ll> vb2;
  rep(i,0,n){
  	ll a,b;
  	cin>>a>>b;
  	vb1.pb(a);
  	vb2.pb(b);
  }
  rep(i,0,va1.sz){
  	rep(j,0,vb1.sz){
  		if(va1[i]<vb1[j]&&va2[i]<vb2[j]){
  			pa[i][j] = 1;
  		}
  	}
  }
  cout << pmatch(pa) << endl;
	return 0;
}





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

using namespace std;

int main() {
	int R[200000];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}
	int maxv, minv;
	maxv = -2000000000;
	minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(R[i] - minv,maxv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3872
N, K = map(int, input().split())

count = 0

for b in range(K+1, N+1):
    q_max = N // b
    count += q_max * (b - K)
    
    rem = N % b - K + 1
    if rem > 0:
        count += rem
    if K == 0:
        count -= 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int a[100];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int max = 0;
	int min = 0;
	for (int i = 0; i < N; i++) {
		int d = a[i] - a[0];
		if (d > max) {
			max = d;
		}
		if (d < min) {
			min = d;
		}
	}
	int dif = max - min;
	cout << dif << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define N 300012
#define ll long long
#define ld long double
#define lli long long 
#define pb push_back
#define pf push_front
#define INF 1e18
// #define INF 10000000000
#define mod 1000000007
#define MOD 1000000007
#define mp make_pair
#define loop(n) for (lli i = 0; i < n; i++)
#define FOR(a,b) for (lli i = a; i < b; i+=1)
#define st(v) v.begin(),v.end()
#define F first
#define S second
#define mp make_pair
#define pii pair<lli,lli>
#define itr :: iterator it
#define w(t) cin>>t; while(t --)
#define inputarr(a,n) for(lli i=1;i<=n;i++)cin>>a[i];
#define input(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.push_back(x);}
#define printarr(a,n) for(lli i=0;i<n;i++)cout<<a[i]; cout<<endl;
#define print(vec) for(auto xt : vec)cout<<xt; cout<<endl;
#define printset(st) for(auto xt : st) cout<<xt<<" ";    cout<<endl;
struct Edge;
typedef list<Edge>::iterator iter;
// const int N=(int)(1 * 1e5 + 10);
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// // typedef tree<int,null_type,less<int>,rb_tree_tag,
// // tree_order_statistics_node_update> indexed_set;
// typedef tree<int, null_type, less_equal<int>, 
//              rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     ordered_set; 

std::vector<lli> v1;
// std::vector<lli> dp(N,-1);
std::vector<std::vector<lli> > dp(3002,std::vector<lli> (3002,-1));
std::vector<std::vector<lli> > vis(3002,std::vector<lli> (3002,0));
lli solve(lli i,lli j){

	if(vis[i][j])return dp[i][j];
	
	vis[i][j]=1;

	if(i == j)return dp[i][j]=v1[i];
	
	return dp[i][j]=max(v1[i]-solve(i+1,j), v1[j]-solve(i,j-1));

}

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

	lli n,k;

	
	cin>>n;
	// std::vector<lli> v1;
	input(v1,n);

	cout<<solve(0,n-1);

}

Measured memory_bytes: 144760
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
s = list(ins())
n = s.count("R")
ans = 0
for i in range(n):
    if s[i] != "R":
        ans += 1
print(ans)

Measured memory_bytes: 10792
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  int N; cin>>N;
  vector<int> a(N);
  rep(i,N) {
    cin>>a[i];
    --a[i];
  }

  bool can = false;
  int now = 0;    // start: 0, goal: 1
  int res = 0;
  rep(i,N-1) {
    now = a[now];
    ++res;
    if(now==1) {
      can = true;
      break;
    }
  }

  if(can) cout<<res<<endl;
  else cout<<-1<<endl;

  return 0;
}


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

int main() {
  long long n, a, b;
  cin>>n>>a>>b;
  int x[n];
  for (int i=0; i<n; i++) cin>>x[i];

  long long ans = 0;
  for (int i=0; i<n-1; i++) {
    long long h = (x[i+1] - x[i]) * a;
    ans += min(h, b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  M amap;
  REP(i,n){
    int tmp;
    IN(tmp);
    amap[tmp]++;
  }
  for(auto p: amap){
    if(p.second < p.first) z += p.second;
    else z += p.second - p.first;
  }
  OUT(z);
}

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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    IOS;
    CIN(N);
    SCIN(s);
    int ans=0;
    Rep(i,1,N){
        vi alpha(26);
        int cnt=0;
        rep(j,i) alpha[s[j]-'a']++;
        Rep(j,i,N){
            if(alpha[s[j]-'a']>0){
                cnt++;
                alpha[s[j]-'a']=0;
            }
        }
        ans=max(ans,cnt);
    }
    printf("%d\n",ans);
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
const int N = 1e6+6;
ll a[N][3];
ll val(int id,int msk){
    ll ret = 0;
    for(int i=0;i<3;i++){
        if(msk&(1<<i))ret+=a[id][i];
        else ret-=a[id][i];
    }
    return ret;
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll ans = 0;
    for(int j=0;j<8;j++){
        vector<ll>v;
        for(int i=0;i<n;i++){
            v.pb(val(i,j));
        }
        sort(v.rbegin(),v.rend());
        ll trt = 0;
        for(int i=0;i<m;i++)trt+=v[i];
        ans = max(ans,trt);
    }
    cout<<ans<<endl;
}


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

using namespace std;

int n, tot, ans;

string s, s1, s2;

bool check(string str) {
	int l = 0, r = str.size() - 1, f = 1;
	while (l < r) {
		if (s[l] != s[r]) f = 0;
		l++; r--;
	}
	return f;
}

int main() {
	int t;
	cin >> s;
	n = s.size();
	s1 = s.substr(0, ((n - 1) / 2));
	s2 = s.substr((n + 3) / 2 - 1, n - 1);
	if (check(s) && check(s1) && check(s2)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
   int n,k,x,y;
   cin>>n>>k>>x>>y;
   cout<<min((k*x),n*x)+max(0,(n-k)*y)<<"\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		String regex = "(.)\\1{1}";
		
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(str);

		System.out.println(m.find() ? "Bad" : "Good");
	}
}

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

using namespace std;



int main(){

long int n,k;
long int r,s,p;
string T;

cin >> n>>k;
cin >> r>>s>>p;
cin >> T;
long int score=0;
for (long int i = 0; i < n; i++)
{
 if (i<k)
 {
  if (T[i] =='r')
  {
    score +=p;
  }
  else if (T[i] =='s')
  {
    score +=r;
  }
  else if(T[i] =='p')
  {
    score +=s;
  }
 }
 else{
  if (T[i]==T[i-k])
  {
    T[i]='Z';
  }
  else{
  if (T[i] =='r')
  {
    score +=p;
  }
  else if (T[i] =='s')
  {
    score +=r;
  }
  else if (T[i] =='p')
  {
    score +=s;
  }
}
 }
}

cout << score;
return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    getline(cin, s);
    // cout << s << "\n";
    int x = atoi(s.substr(0).c_str());
    int y = atoi(s.substr(2).c_str());

    cout << x * y << " " << (x + y) * 2 << "\n";
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>

std::string& replace_all(std::string& str, const std::string& from, const std::string& to) {
    std::size_t start_pos = 0;
    while( (start_pos = str.find(from, start_pos)) != std::string::npos ) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length();
    }
    return str;
}

int main(void) {
    u_int n;
    std::string str;
    const std::string from  = "Hoshino";
    const std::string to    = "Hoshina";

    std::cin >> n;
    std::cin.ignore(); // ignore next newline character
    for (u_int i = 0; i < n; ++i) {
        std::getline(std::cin, str);
        std::cout << replace_all(str, from, to) << std::endl;
    }

    return 0;
}

/* requre clang or gcc 4.9 or later */
/*
#include <iostream>
#include <string>
#include <regex>

int main(void) {
    int n;
    std::string str;
    std::regex regexp("Hoshino");

    std::cin >> n;
    std::cin.ignore();
    for (int i = 0; i < n; ++i) {
        std::getline(std::cin, str);
        std::cout << std::regex_replace(str, regexp, "Hosina") << std::endl;
    }

    return 0;
}
*/

Measured memory_bytes: 1212
#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>

using namespace std;
#define next __next
#define prev __prev
#define right __right
#define left __left
#define index __index

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<int, int> ipair;
#define szof(x) ((int)(x).size())
#define ff first
#define ss second
#define puba push_back
#define bend(x) (x).begin(), (x).end()

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
mt19937 tw(960172);

bool is_prime(ll x) { for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return x > 1; }
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }
ll sqr(int a) { return (ll) a * a; } template<class T> T sqr(T const& a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }

int const N = 500100;
int const C = 333;

int ans[N];
int add[N];

void solve() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int it = 0; it < n; ++it) {
        int l, r;
        scanf("%d%d", &l, &r);
        int len = r - l + 1;
        for (int d = 1; d <= m && d <= C; ++d)
            if (len >= d || r % d < l % d || l % d == 0)
                ++ans[d];
        --l;
        for (int x = 1; x <= C; ++x) {
            int mind = r / (x + 1) + 1;
            mind = max(mind, C + 1);
            mind = max(mind, l / x + 1);
            int maxd = r / x;
            maxd = min(maxd, m);
            if (mind > maxd)
                continue;
            ++add[mind];
            --add[maxd + 1];
        }
    }
    for (int i = 1; i <= m; ++i) {
        add[i] += add[i - 1];
        ans[i] += add[i];
        cout << ans[i] << '\n';
    }
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    cout << setprecision(15) << fixed;
#ifdef LOCAL
    cerr << setprecision(6) << fixed;
#endif
    int tcnt = 1;
    for (int test = 1; test <= tcnt; ++test)
        solve();
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}


Measured memory_bytes: 1664
import sys

n, *inp = map(int, sys.stdin.buffer.read().split())
vvv = [0] + inp[0:n * 2:2]
www = [0] + inp[1:n * 2:2]

weight_limit = 10 ** 5
precalc_limit = min(1 << 10, n + 1)
precalc = [[0] * (weight_limit + 1)]

for u in range(1, precalc_limit):
    v = vvv[u]
    w = www[u]
    dp = precalc[u >> 1][:]
    for x in range(weight_limit, w - 1, -1):
        nv = dp[x - w] + v
        if dp[x] < nv:
            dp[x] = nv
    precalc.append(dp)

buf = []
mp = iter(inp[n * 2 + 1:])
for u, l in zip(mp, mp):
    if u < precalc_limit:
        buf.append(precalc[u][l])
        continue
    dp_w = [0]
    dp_v = [0]
    while u >= precalc_limit:
        v = vvv[u]
        w = www[u]
        for i in range(len(dp_w)):
            nw = dp_w[i] + w
            if nw > l:
                continue
            nv = dp_v[i] + v
            dp_w.append(nw)
            dp_v.append(nv)
        u >>= 1
    ans = 0
    for w, v in zip(dp_w, dp_v):
        nv = v + precalc[u][l - w]
        if ans < nv:
            ans = nv
    buf.append(ans)

print('\n'.join(map(str, buf)))


Measured memory_bytes: 906224
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: u64 = input();
    let mut set: HashSet<String> = HashSet::new();
    for _ in 0..n {
        let s: String = input();
        set.insert(s);
    }
    println!("{}", set.len());
}


Measured memory_bytes: 15276
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();
		
		List<Integer> xmv = new ArrayList<Integer>();
		List<Integer> ymv = new ArrayList<Integer>();
		
		int cnt = 0;
		boolean goX = true;
		for(int i=0;i<s.length()+1;i++) {
			if(i!=s.length()&&s.charAt(i)=='F')cnt++;
			else {
				if(goX) {
					xmv.add(cnt);
					goX = false;
				}else {
					ymv.add(cnt);
					goX = true;
				}
				cnt = 0;
			}
		}
		
		int xmax = 0;
		for(int i=0;i<xmv.size();i++)xmax+=xmv.get(i);
		
		//xについて
		boolean dp[][] = new boolean[xmv.size()][35000];
		dp[0][xmv.get(0)+16005]=true;
		for(int i=1;i<xmv.size();i++) {
			int dist = xmv.get(i);
			for(int j=-xmax;j<=xmax;j++) {
				dp[i][j+16005] = dp[i-1][j-dist+16005]||dp[i-1][j+dist+16005];
			}
		}
		
		//yについてコピー
		int ymax = 0;
		if(ymv.size()==0)ymv.add(0);
		for(int i=0;i<ymv.size();i++)ymax+=ymv.get(i);
		
		//yについて
		boolean dpy[][] = new boolean[ymv.size()][30000];

		dpy[0][ymv.get(0)+16005]=true;
		dpy[0][-ymv.get(0)+16005]=true;
		for(int i=1;i<ymv.size();i++) {
			int dist = ymv.get(i);
			for(int j=-ymax;j<=ymax;j++) {
				dpy[i][j+16005] = dpy[i-1][j-dist+16005]||dpy[i-1][j+dist+16005];
			}
		}
		
		String ans = "No";
		if(dp[xmv.size()-1][x+16005]&&dpy[ymv.size()-1][y+16005]) ans = "Yes";
		System.out.println(ans);
		
	}
}


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

int main() {
    int x,y,z,N,end;
    long long Y;
    cin >> N >> Y;
    x = -1;
    y = -1;
    z = -1;
    end = 0;
    rep(i,(Y/10000)+1)
    {
        rep(j,(Y-i*10000)/4999+1)
        {
        if((i*10000 + j*5000 + (N-i-j)*1000) == Y)
        {
            x =i;
            y =j;
            z = N-i-j;
            end = 1;
            break;
        }
        }
    if(end == 1)
    break;
    }
cout << x << ' ' << y << ' ' << z << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, M int
	var ans int
	fmt.Scan(&N, &M)
	if N == 1 && M == 1 {
		ans += 1
	} else if 1 < N && 1 < M {
		ans += (N - 2) * (M - 2)
	} else {
		ans += (N * M) - 2
	}

	fmt.Println(ans)
}

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

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 1;
    }
  }
  for (int j = 0; j < y; j++) {
    for (int i = 0; i < n; i++) {
      a[i][j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ans += !a[i][j];
    }
  }
  cout << ans << '\n';
  return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    cout << n/3 << endl;
    return 0;
}


Measured memory_bytes: 256