akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

ll ans(ll a){
	ll ret=0;
	for(int i=57;i>=0;i--){
		ll pos=(1ll<<i);
		if(i==0){
			if(a%4<=2&&a%4>=1) ret++; 
		}
		else if(a/pos&&((a&1)==0)){
			ret^=pos;
		}
		if(i>1)a%=pos;
		//cout<<a<<endl;
	}
	return ret;
}

int main(){
	ll n,m;
	cin>>n>>m;
	P p[n];
	rep0(i,n){
		ll a,b;
		cin>>a>>b;
		p[i]={a,b};
	}
	sort(p,p+n);
	ll i=0;
	ll ans=0;
	while(m>0){
		if(p[i].second<m){
			m-=p[i].second;
			ans+=p[i].first*p[i].second;
		}
		else{
			ans+=p[i].first*m;
			break;
		}
		i++;
	}
	cout<<ans<<endl;
      return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int b, bb, s;
    cin >> bb;
    s = bb;

    for (int i=1; i < n-1; i++) {
        cin >> b;
        s+= min(b, bb);
        bb=b;
    }
    s+=bb;
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int t = 0;
	int len;
	char a[128];
	char takahashi;

	//入力
	scanf("%s",a);
	
	len = strlen(a);
	//printf("len: %d\n", len);

	//計算
	for(int j=0; j<len; j++){
	takahashi = a[j];
	 	if(takahashi == '+')
		{
			t++;
		} else {
			t--;
		}
	}


	printf("%d\n", t);
}

Measured memory_bytes: 128
//  Created by conan1024hao on 2019/11/18.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
     
    int N, T;
     
    int dp[3000 + 10][3000 + 10][2];//dp[i][j][k] := i品目まで食べるかを選んで、jの時間がかかったときのおいしさの最大値
    //kが0の時は、最後に食べるものをまだ選んでない 1の時は最後に食べるものをもう選んでる状態
    vector<int> A, B;
        cin >> N >> T;
        for (int i = 0; i < N; i++) {
            int a, b;
            cin >> a >> b;
            A.push_back(a);B.push_back(b);
        }
        dp[0][0][0] = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= T - 1; j++) {
                for (int k = 0; k < 2; k++) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k]);
                    if (j - A[i - 1] >= 0)
                        dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - A[i - 1]][k] + B[i - 1]);
                    //最後に食べるとする
                    if (k == 0) {
                        dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][k] + B[i - 1]);
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i <= T - 1; i++)for (int j = 0; j < 2; j++)
            ans = max(ans, dp[N][i][j]);
        cout << ans << endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 71040
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    vector<bool> mod(b, false);
    for (int i = 1; !mod[i * a % b]; i++) {
        mod[i * a % b] = true;
    }

    cout << (mod[c] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    a, b, c, d = map(int, input().split())
    while True:
        c -= b
        if c <= 0:
            print("Yes")
            break
        a -= d
        if a <= 0:
            print("No")
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 62088
import sys
import collections

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    n = I()
    ans = 0
    for c in range(1, n):
        t = list(collections.Counter(prime_factorize(n-c)).values())
        s = 1
        for key in t:
            s *= key+1
        ans += s
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 76720
#include <iostream>
#include <stack>
#include <sstream>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cfloat>
#include <cmath>
using namespace std;

int main() {
  string str;
  double a, b;

  while( getline(cin, str) ) {
    stack<double> st;
    stringstream ss(str);
    string s;

    while( ss >> s ) {
      if( s.size() > 1 || isdigit( s[0] ) ) {
	a = atof( s.c_str() );
	st.push( a );
      }
      else if( s == "+" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b+a );
      }
      else if( s == "-") {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b-a );
      }
      else if( s == "*" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	st.push( b*a );
      }
      else if( s == "/" ) {
	a = st.top(); st.pop();
	b = st.top(); st.pop();
	if( a == 0 ) exit(EXIT_FAILURE);
	st.push( b/a );
      }
    }
    printf("%.6lf\n", st.top());
  }
  
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main() {

    simplify
    int n,k;
    cin>>n>>k;
    vector<int>arr(n);

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=arr[i];
    }
    cout<<ans;



    return 0;
}


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

int main(void){
  
  string s;
  cin >> s;

  int len = s.length();
  int a_str;
  int z_str;
  for (int i = 0; i < len; i++) {
	if (s[i] == 'A') {
      a_str = i;
      break;
    }
  }
  for (int i = len-1; i > 0; i--) {
	if (s[i] == 'Z') {
      z_str = i;
      break;
    }
  }
  cout << (z_str - a_str + 1);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  string str;
  cin >> str;
  ll sum;
  sum = 0;
  ll ans = 0;
  ll piv1 = 0;
  ll piv2 = n-1;
  while(1){
    while(piv1 < n && str[piv1] == 'R'){
      piv1++;
    }
    while(piv2 >= 0 && str[piv2] == 'W'){
      piv2--;
    }
    if(piv1 < piv2){
      ans++;
      piv1++;
      piv2--;
    }else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3720
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int x;
	cin >> x;
	if (x <= 599) {
		cout << 8;
	}
	else if (x <= 799) {
		cout << 7;
	}
	else if (x <= 999) {
		cout << 6;
	}
	else if (x <= 1199) {
		cout << 5;
	}
	else if (x <= 1399) {
		cout << 4;
	}
	else if (x <= 1599) {
		cout << 3;

	}
	else if (x <= 1799) {
		cout << 2;
	}
	else {
		cout << 1;
	}
	return 0;
	return 0;
}

Measured memory_bytes: 3636
// In the Name of God

#include <bits/stdc++.h>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const int pw = 257;

int n, a[N], cnt[2];

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif

	ios_base :: sync_with_stdio(false); cin.tie(NULL);

	cin >> n;
	rep(i, 1, n)
		cin >> a[i];
		        
 	rep(i, 1, n)
 		++cnt[a[i] % 2];

	if (cnt[1] % 2 == 1)
		cout << "NO";
	else
		cout << "YES";
	return 0;
}

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

typedef int32_t i32;

void run (void) {
  i32 n, sum;
  scanf ("%" SCNi32 "%" SCNi32, &n, &sum);
  for (i32 x = 0, sx = 0; x <= n; ++x, sx += 10000) {
    for (i32 y = 0, sy = sx; y <= n - x; ++y, sy += 5000) {
      for (i32 z = 0, sz = sy; z <= n - x - y; ++z, sz += 1000) {
        if (sz == sum && z == n - x - y) {
          printf ("%" PRIi32 " %" PRIi32 " %" PRIi32 "\n", x, y, z);
          return;
        }
      }
    }
  }
  puts ("-1 -1 -1");
}

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

Measured memory_bytes: 128
import java.util.Scanner;
class Main{


	static char[][] map;
	static final int MOD = 1000000007;


	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			h[i] = sc.nextInt();
		}
		for(int i = n-1;i >= 1;i--){
			if(h[i-1] > h[i]){
				h[i-1]--;
				if(h[i-1] > h[i]){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");





	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 49840
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stdlib.h>  
using namespace std;

int main(){
	vector <unsigned long long int> A;
	int N, temp, max;
	unsigned long long int res;
	cin>> N;
	max = N;
	while(N--){
		cin>>temp;
		A.push_back(temp);
	}
	sort(A.begin(), A.end());
	
	res = (A[max-1] - A[0]);
	
	if( res < 0){
		cout<< -res<<endl;
	}
	else
	cout << res<<endl;
	
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a;
  int oddc=0;
  REP(i, n){
    cin>>a;
    if(a%2>0) ++oddc;
  }
  if(oddc%2==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

  return 0;
}


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

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	long long ans = 0;
	priority_queue<int> best;
	for (int i = 1, ptr = 0; i <= m; ++i) {
		while (ptr < n and v[ptr].first == i) {
			best.push(v[ptr++].second);
		}
		if (best.size()) {
			ans += best.top();
			best.pop();
		}
	}
	cout << ans;

	return 0;
}


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

int main () {
  int a,b,c,d = 3;
  cin >> a >> b >> c;
  if(a==b && a==c){
    cout << 1 << endl;
  }
  else if(a!=b && b!=c && a!=c){
    cout << 3 << endl;
  }
  else{
    cout << 2 << endl;
  }
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof(a))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
typedef long long ll;
const ll maxn=1e4+200;
const int inf=0x3f3f3f3f;
const double EPS=1e-10;
//typedef pair<int,int> PA;
double add(double a,double b){//考虑误差的加法运算
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return  0;
    return a+b;
}
class Point{
public:

    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){
    }
    Point operator+ (Point p){
        return Point(add(x,p.x),add(y,p.y));
    }
    Point operator -(Point p){
        return Point(add(x,-p.x),add(y,-p.y));
    }
    Point operator *(double d){
        return Point(x*d,y*d);
    }
    double dot(Point p){//外积 p1.p2  outside
        return add(x*p.x,y*p.y);
    }
    double det(Point p){//内积 p1*p2    inner
        return add(x*p.y,-y*p.x);
    }
    double len(){
        return sqrt(add(x*x,y*y));
    }
};
Point operator *(double d,Point p){
    return Point(p.x*d,p.y*d);
}
Point getProjection(Point p1,Point p2,Point p){//p 在线段p1,p2上的投影坐标
    double d1=1.0/(p2-p1).len();
    Point ans=(p-p1).dot((p2-p1))*(p2-p1)*d1*d1;
    return ans+p1;
}
Point getReflection(Point p1,Point p2,Point p){//p 关于线段p1 p2的 反射坐标
    return 2.0*getProjection(p1,p2,p)-p;
}
double getDistance(Point a,Point b){
    return (b-a).len();
}
int seg(double x){
    if(abs(x)<EPS)  return 0;
    if(x<0) return -1;
    else return 1;
}
int getDir(Point p,Point p1,Point p2){//返回 p2 关于p 在p1的什么方向
        int a=seg((p1-p).det(p2-p));
        int b=seg((p1-p).dot(p2-p));
        if(a>0){
            puts("COUNTER_CLOCKWISE");
        }
        else if(a<0){
            puts("CLOCKWISE");
        }
        else if(b<0){
            puts("ONLINE_BACK");
        }
        else if(b>0&&seg((p1-p).dot(p2-p1))>0){
            puts("ONLINE_FRONT");
        }
        else{
            puts("ON_SEGMENT");
        }
        return 0;

}
typedef Point P;
int main(){
    P p,p1;
    scanf("%lf%lf%lf%lf",&p.x,&p.y,&p1.x,&p1.y);
    int q;
    scanf("%d",&q);
    while(q--){
        P p2;
        scanf("%lf%lf",&p2.x,&p2.y);
        getDir(p,p1,p2);
    }
    return 0;
}



Measured memory_bytes: 3252
import heapq

inf = 10000000000

n,m,r = map(int,input().split())
e = [[] for _ in range(n)]

for _ in range(m):
    a,b,c = map(int,input().split())
    e[a].append([b,c])

d = [inf]*n

d[r] = 0
pq = [[0,r]]
heapq.heapify(pq)
while len(pq):
    pre = heapq.heappop(pq)
    a,b = pre[0],pre[1]

    if d[b]<a:continue

    for i in range(len(e[b])):
        next_index = e[b][i][0]
        next_cost = d[b]+e[b][i][1]
        if next_cost<d[next_index]:
            d[next_index] = next_cost
            heapq.heappush(pq,[next_cost,next_index])

for i in range(n):
    if d[i]==inf:print ('INF')
    else        :print (d[i])




Measured memory_bytes: 97992
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>


namespace n91 {

void main_() {
  std::string s;
  std::cin >> s;
  const usize n = s.size();
  std::vector<usize> ans(n);
  {
    usize e_cnt = 0_z, o_cnt = 0_z;
    for (const auto i : rep(0_z, n)) {
      if (s[i] == 'R') {
        ++o_cnt;
      } else {
        ans[i] += o_cnt;
        ans[i - 1_z] += e_cnt;
        o_cnt = 0_z;
        e_cnt = 0_z;
      }
      std::swap(o_cnt, e_cnt);
    }
  }
  {
    usize e_cnt = 0_z, o_cnt = 0_z;
    for (const auto i : revrep(0_z, n)) {
      if (s[i] == 'L') {
        ++o_cnt;
      } else {
        ans[i] += o_cnt;
        ans[i + 1_z] += e_cnt;
        o_cnt = 0_z;
        e_cnt = 0_z;
      }
      std::swap(o_cnt, e_cnt);
    }
  }
  for (const auto e : ans) {
    std::cout << e << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, ans;
map<P, ll> m;
int main() {
	cin >> n;
	REPO(i, n) {
		string s = to_string(i).c_str();
		m[P(s[0] - '0', s[s.size() - 1] - '0')]++;
	}
	REP(i, 10) {
		REP(j, 10) {
			ans += m[P(i, j)] * m[P(j, i)];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;
 

int main(){
  
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double x = pow(x1-x2, 2);
  double y = pow(y1-y2, 2);
  double distance = sqrt(x+y);
  cout.precision(8);
  cout << fixed;
  cout << distance << endl;
  


  
  return 0;

  
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

#define MAX_N 2010

int N, K;
vector<int> e[MAX_N];

int dfs(int from, int t, int d) {
    if (d < 0) return 0;
    //cout << d << endl;
    int res=1;
    for(auto x: e[t]) if(from!=x) {
        res+=dfs(t,x,d-1);
    }
    return res;
}


int main(){
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i,N-1) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        e[a].pb(b);
        e[b].pb(a);
    }
    
    int ans = INF;
    
    if(K%2) {
        REP(i,N) {
            for(auto x: e[i]){
                ans = min(ans, N-dfs(i,x,(K-1)/2)-dfs(x,i,(K-1)/2));
            }
        }
    } else {
        REP(i,N) {
            ans = min(ans,N-dfs(-1,i,K/2));
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline


def main():
    H = int(input().strip())
    A = [int(i) for i in input().strip().split()]

    for i in range(H):
        print("node {}: key = {}, ".format(i + 1, A[i]), end="")
        if i > 0:
            print("parent key = {}, ".format(A[(i - 1) // 2]), end="")
        if (i * 2) + 1 < H:
            print("left key = {}, ".format(A[(i * 2) + 1]), end="")
        if (i * 2) + 2 < H:
            print("right key = {}, ".format(A[(i * 2) + 2]), end="")
        print()

    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const ll inf = 1LL<<60;
int n;
vector<vector<ll>> d(330, vector<ll>(330, inf)), a(330, vector<ll>(330, 0));

void floyd(){
    rep(k, 0, n){
        rep(i, 0, n){
            if(d[i][k]==inf) continue;
            rep(j, 0, n){
                if(d[k][j]==inf) continue;
                chmin(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

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

    cin >> n;
    rep(i, 0, n) rep(j, 0, n) { cin >> d[i][j]; a[i][j]=d[i][j]; }

    floyd();
    ll ans=0;
    rep(i, 0, n) rep(j, i+1, n) ans+=a[i][j];

    rep(i, 0, n) rep(j, 0, n){
        if(a[i][j]>d[i][j]){
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, 0, n) rep(j, i+1, n){
        bool flg=false;
        rep(k, 0, n){
            if(k==i || k==j) continue;
            if(d[i][k]+d[k][j]==d[i][j]) flg=true;
        }
        if(flg) ans-=a[i][j];
    }
    cout << ans << endl;

    return 0;
}

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

int n,y;

int main()
{
	cin>>n>>y;
	for(int i=0;i<=n;i++) for(int j=0;j<=n-i;j++)
	{
		int r=y-i*10000-j*5000;
		if(r>=0&&r%1000==0&&i+j+r/1000==n) {cout<<i<<' '<<j<<' '<<n-i-j;return 0;}
	}
	cout<<-1<<' '<<-1<<' '<<-1;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  ll n = s.length();
  ll cnt[26]; CLR(cnt);
  FOR(i,0,n) {
    cnt[s[i]-'a']++;
  }
  ll mx = n * (n - 1) / 2;
  FOR(i,0,26) {
    mx -= cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << mx + 1 << endl;
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int h, w;
    cin >> h >> w;
    rep(i, h){
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

ll modbeki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1){
      res *= x % MOD;
      res %= MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(N), B(N);
  ll zero = 0;
  map<Pll, ll> mp;
  set<Pll> st;
  for(int i = 0; i < N; i++){
    cin >> A.at(i) >> B.at(i);
    if(A.at(i) == 0 && B.at(i) == 0){
      zero++;
      continue;
    }
    ll gg = __gcd(A.at(i), B.at(i));
    A.at(i) /= gg;
    B.at(i) /= gg;
    if(A.at(i) < 0 || (A.at(i) == 0 && B.at(i) < 0)){
      A.at(i) *= -1LL; B.at(i) *= -1LL;
    }
    mp[Pll(A.at(i), B.at(i))]++;
    st.insert(Pll(A.at(i), B.at(i)));
  }
  ll ans = 1LL;
  for(auto ite = st.begin(); ite != st.end(); ite++){
    Pll p = *ite;
    if(!mp.count(p)) continue;
    ll nn = mp.at(p);
    Pll q;
    if(p.second > 0) q = Pll(p.second, -p.first);
    else q = Pll(-p.second, p.first);
    ll mm = (mp.count(q)? mp.at(q): 0LL);
    if(mm != 0) ans *= (modbeki(2LL, nn) + modbeki(2LL, mm) - 1) % MOD;
    else ans *= modbeki(2LL, nn);
    ans %= MOD;
    mp.erase(p);
    if(mm != 0) mp.erase(q);
  }
  ans += MOD - 1;
  ans %= MOD;
  ans += zero;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 31276
// 橋渡し問題
// 結局は律速がどこにあるのかを考える必要がある

#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  long N, capacity[5];
  cin >> N;
  for (int i=0; i<5; i++){
    cin >> capacity[i];
  }
  // 最小値
  int min_capa_id = -1;
  long min_capa = LONG_MAX;
  for (int i=0; i<5; i++){
    if (capacity[i] < min_capa){
      min_capa = capacity[i];
      min_capa_id = i;
    }
  }

  long output = 5;
  // 律速のキャパで割る
  if (N % capacity[min_capa_id] == 0){
    output += N /capacity[min_capa_id] - 1;
  } else{
    output += N / capacity[min_capa_id];
  }
  cout << output << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

typedef long long lint;

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
lint* array(lint x) {
	lint *array = new lint[x];
	return array;
};
lint** array2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
int main() {
	int n,m,l;
	cin >> n >> m>>l;
	lint** arr = array2(n,m);
	lint** arr2 = array2(m, l);
	lint** output = array2(n,l);
	rep(i, n)rep(j, m)cin >> arr[i][j];
	rep(i, m)rep(j, l)cin >> arr2[i][j];
	rep(i, n)rep(j, l)rep(k, m)output[i][j] += arr[i][k] * arr2[k][j];
	rep(i, n) {
		rep(j, l) {
			cout << (j ? " " : "") << output[i][j];
		}
		cout << "\n";
	}
}


Measured memory_bytes: 3256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int dp[510][510];
string in;
bool rec(int s, int t){
	int &res = dp[s][t];
	if(res >= 0) return res;
	if(s == t) return res = 1;
	
	res = 0;
	if(in[s] != 'm' || in[t - 1] != 'w') return res;
	for(int i = s + 1; i < t - 1; i++) if(in[i] == 'e'
		&& rec(s + 1, i) && rec(i + 1, t - 1)) return res = 1;
	return res;
}

int main(){
	cin >> in;
	memset(dp, -1, sizeof(dp));
	cout << (rec(0, in.size()) ? "Cat" : "Rabbit") << endl;
	return 0;
}

Measured memory_bytes: 2212
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    multiset<int>s;
    V a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    s.insert(-INF);
    for (int i = 0; i < n; ++i) {
        auto it=s.lower_bound(a[i]);
        it--;
        if(*it==-INF)s.insert(a[i]);
        else {
            s.insert(a[i]);
            s.erase(it);
        }
    }
    cout <<s.size()-1<<endl;
}


Measured memory_bytes: 8260
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int n,a,b,c,x;
    in(n);
    vector<vector<int>> graph(n);
    vector<pair<int,int>> time(n);
    rep(i,n){
        in(a,b);
        time[i].first=-1;
        rep(j,b){
            in(c);
            graph[a-1].push_back(c-1);
        }
    }
    stack<int> next;
    int time1=0;
    rep(j,n){
    if(time[j].first==-1){
        time1++;
        next.push(j);
        time[j].first=time1;
        while(!next.empty()){
            x=next.top();
            time1++;
            rep(i,graph[x].size()){
                if(time[graph[x][i]].first==-1){
                    time[graph[x][i]].first=time1;
                    next.push(graph[x][i]);
                    goto skip;
                }
            }
            next.pop();
            time[x].second=time1;
            skip: ;
        }
    }
    }
    rep(i,n){
        out(i+1,time[i].first,time[i].second);
    }
}


Measured memory_bytes: 3236
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int top=0,S[1000];
void push(int x){S[++top]=x;}
int pop(){return S[top--];}
int main(){
	char s[100];
	int a,b;
	while(scanf("%s",s)!=EOF){
		if (s[0]=='+'){
			a=pop();b=pop();
			push(a+b);
		}
		else if (s[0]=='-'){
			a=pop();b=pop();
			push(b-a);
		} 
		else if	(s[0]=='*'){
			a=pop();b=pop();
			push(a*b);
		}
		else push(atoi(s));
	}
	printf("%d\n",pop());
} 


Measured memory_bytes: 3228
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#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());
#define dump(x) cerr << #x << " = " << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
    int N; cin >> N;
	int A;
	repi(i, 1, (int)(sqrt(N)) + 1) {
		if (N % i == 0) A = N / i;
	}
	cout << (int)(log10(A) + 1) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
signed main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13)cout << b << endl;
  else if(a >= 6)cout << b/2 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
const int MOD = 1000000007;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   int n;cin>>n;
   VI a(n),b(n);
   rep(i,n)cin>>a[i];
   rep(i,n)cin>>b[i];
   ll biggerA=0,biggerB=0;
   rep(i,n){
      if(a[i]>b[i])biggerA+=a[i]-b[i];
      if(b[i]>a[i])biggerB+=(b[i]-a[i])/2;
   }
   if(biggerB>=biggerA)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

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

int n,a[100001],b[100001],c[100001];
int sum1[4000010],sum2[4000010];
long long up;
void Insert(int k,int l,int r,int x,int id){
	if(id&1)sum1[k]++;
	else sum2[k]++;
	if(l==r)return;
	int mid=(l+r)>>1;
	if(x<=mid)Insert(k<<1,l,mid,x,id);
	else Insert(k<<1|1,mid+1,r,x,id);
}
int Query(int k,int l,int r,int L,int R,int id){
	if(l==L&&r==R){
		if(id&1)return sum1[k];
		else return sum2[k];
	}
	int mid=(l+r)>>1;
	if(R<=mid)return Query(k<<1,l,mid,L,R,id);
	else if(mid<L)return Query(k<<1|1,mid+1,r,L,R,id);
	else return Query(k<<1,l,mid,L,mid,id)+Query(k<<1|1,mid+1,r,mid+1,R,id);
}
bool check(int mid)
{
	memset(sum1,0,sizeof(sum1));
	memset(sum2,0,sizeof(sum2));
	for(int i=1;i<=n;++i)
		c[i]=(a[i]<=mid);
	int x=0;
	Insert(1,0,3*n,n,0);
	long long Ans=0;
	for(int i=1;i<=n;++i){
		x+=c[i];
		int now=2*x-i+n;
		int ans=0;
		if(now>=2)ans+=Query(1,0,3*n,0,now-2,i);
		if(now>=1)ans+=Query(1,0,3*n,0,now-1,i^1);
		Insert(1,0,3*n,now,i);
		Ans=Ans+ans;
	}
	return Ans>=up;
}

int main()
{
	scanf("%d",&n);
	up=(1ll*n*(n-1)/2+n)/2+1;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	int l=0,r=1e9,ans=n;
	while(l<r){
		int mid=(l+r)>>1;
	    if(check(mid))r=mid;
	    else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 32768
module Program =
  open System

  [<EntryPoint>]
  let main argv = 
    let n = Console.ReadLine() |> int
    let xs = Console.ReadLine().Split([|' '|]) |> Array.map int

    let m =
      xs
      |> Seq.sort
      |> Seq.pairwise
      |> Seq.indexed
      |> Seq.filter (fun (i, p) -> i % 2 = 0)
      |> Seq.map (fun (i, (l, r)) -> min l r)
      |> Seq.sum

    printfn "%d" m

    // exit code
    0


Measured memory_bytes: 5200
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 998244353;

long long big_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) {
			res *= a;
			res %= mod;
		}

		b >>= 1;
		a = (a * a) % mod;
	}

	return res % mod;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> d(n);
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}

	if (d[0] != 0) {
		cout << "0\n";
		return 0;
	}

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

 	int i = 1;
 	int curr_level = 1, prev_level_nodes = 1;
 	long long ans = 1;
 	while (i < n) {
 		int curr_nodes = 0;
 		while (i < n && d[i] == curr_level) {
 			++curr_nodes;
 			++i;
 		}

 		if (!curr_nodes) {
 			cout << "0\n";
 			return 0;
 		}

 		ans *= big_pow(prev_level_nodes, curr_nodes);
 		ans %= mod;
 		prev_level_nodes = curr_nodes;
 		++curr_level;
 	}

 	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 640
from collections import deque

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())), reverse = True)

s = []

for i in range(x):
    p_e = p.pop()
    s.append(p_e)

for i in range(y):
    q_e = q.pop()
    s.append(q_e)

S = sum(s)
s.sort(reverse = True)

lim = c
if x + y < c:
    lim = x + y


k = x+y-1

for i in range(lim):
    if r[i] > s[k]:
        S += r[i]
        S -= s[k]        
        k -= 1
    if r[i] <= s[k]:
        break

print(S)

Measured memory_bytes: 23608
import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }


    void run() {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int K = cin.nextInt();
        System.out.println(dfs(N, K, 1));
    }

    // 残り回数、K、今の値を引数に持ち、この状態からの最小値を返す。
    int dfs(int remain, int K, int now){
        if(remain == 0) return now; //残り回数が0であれば、nowをそのまま返す。
        //残り回数が残っていれば、残り回数を1減らし、2倍したパターンと、Kを足したパターンの最小値を返す
        return Math.min(dfs(remain-1, K, now*2), dfs(remain-1, K, now + K));
    }
}


Measured memory_bytes: 21972
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    double r;
    double circumference, area;

    cin >> r;

    circumference = r * r * M_PI;
    area = 2 * M_PI * r;

    printf("%lf %lf\n", circumference, area);
}



Measured memory_bytes: 3116
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next().replaceAll("\\?",".");
        String t = sc.next();
        if(s.length() < t.length()){
            System.out.println("UNRESTORABLE");
            return;
        }
        for(int i = s.length() - t.length(); i>=0; i--){
            String x = s.substring(i, i + t.length());
            if(t.matches(x)){
                System.out.println(s.replaceFirst(
                    s.substring(0,i)+x,s.substring(0,i) + t)
                    .replaceAll("\\.", "a"));
                    return;
            }
        }
        System.out.println("UNRESTORABLE");
    }
}

Measured memory_bytes: 21844