akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 高橋君の夏休みは
 * N
 *  日間です。
 *
 * 夏休みの宿題が
 * M
 *  個出されており、
 * i
 *  番目の宿題をやるには
 * A
 * i
 *  日間かかります。
 *
 * 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
 * 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
 * ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
 */
public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String tmp[] = br.readLine().split(" ");
        int N = Integer.valueOf(tmp[0]);
        int M = Integer.valueOf(tmp[1]);

        int sum = 0;
        for (String A: br.readLine().split(" ")) {
            sum += Integer.valueOf(A);
        }

        if (N - sum >= 0) {
            System.out.println(N - sum);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 34576
import numpy as np

N, X = map(int, input().split())
L = list(map(int, input().split()))

L = np.array(L)
D = np.zeros(N+1)

count = 1
for i in range(1, N+1):
  D[i] = D[i-1] + L[i-1]
  if D[i] <= X:
    count += 1
  else:
    pass

print(count)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> L(M);
  vector<int> R(M);
  
  for( int i = 0; i < M; i++ ){
    cin >> L.at(i) >> R.at(i);
  }
  
  int mostL = 0;
  int mostR = N;
  for( int i = 0; i < M; i++ ){
    if( mostL < L.at(i) ) mostL = L.at(i);
    if( mostR > R.at(i) ) mostR = R.at(i);
    if( mostL > mostR ){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << mostR - mostL + 1 << endl;
      
}

Measured memory_bytes: 1024
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (n, k) = (sc.nextInt(), sc.nextInt())
    val values = Vector.fill(n)(sc.nextLong())
    debug(n, k, values)

    getTakePatterns(k).foldLeft(ArrayBuffer.empty[Long]) { case (acc, (l, r, d)) =>
      val fromLeft = if (l > 0) values.slice(0, l) else Vector.empty[Long]
      val fromRight = if (r > 0) values.slice(l, values.size).reverse.slice(0, r) else Vector.empty[Long]
      val takes = fromLeft ++ fromRight
      val value =
        if (d > 0) {
          val dropValue = takes.sorted.take(d).foldLeft(0L) { (acc, v) =>
            if (v < 0) {
              acc + v
            } else acc
          }
          takes.sum + dropValue * -1
        } else {
          takes.sum
        }
      acc += (if (value > 0) value else 0)
    }.max.toString
  }

  def getTakePatterns(k: Int): ArrayBuffer[(Int, Int, Int)] = {
    @tailrec
    def dfs(buf: ArrayBuffer[(Int, Int, Int)], i: Int): ArrayBuffer[(Int, Int, Int)] = {
      (0 to k - i).foreach { j =>
        val x = if (k - i - j > 0) k - i - j else 0
        if (i + j >= x) {
          buf += ((i, j, x))
        }
      }
      if (i < k) {
        dfs(buf, i + 1)
      } else buf
    }

    val initialBuf = ArrayBuffer.empty[(Int, Int, Int)]
    dfs(initialBuf, 0)
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 41008
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n,a=0,c=0,w,ans=0;
    cin>>n>>w;
    ll v1[n+1],v2[n+1];
    ra(i,1,n)
    {
        cin>>v1[i]>>v2[i];
        //c+=l;
    }
    ll b=n*1000;
    ll dp[n+1][b+1];
    for(i=0;i<=b;i++)
    dp[1][i]=100000000000;
    dp[1][0]=0;
    dp[1][v2[1]]=v1[1];
    for(i=2;i<=n;i++)
    {   
        for(j=0;j<=b;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(v2[i]<=j){
            if(dp[i-1][j-v2[i]]+v1[i]<=w)
            dp[i][j]=min(dp[i][j],(dp[i-1][j-v2[i]]+v1[i]));}
        }
    }
    for(i=0;i<=b;i++)
    {
        if(dp[n][i]<=w)
        ans=i;
    }
    cout<<ans;
}

Measured memory_bytes: 78336
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()


int main(){
    double t, x; cin>>t>>x; cout<<(t/x)<<endl;
}

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

int main() {
  int n,m; cin >> n >> m;
  int a,b;
  int count[n];
  
  for (int i=0; i<n; i++){
    count[i] = 0;
  }
  for (int i=0; i<m; i++){
    cin >> a >> b;
    count[a-1] += 1;
    count[b-1] += 1;
  }
  for (int i=0; i<n; i++){
    cout << count[i] << endl;
  }

}


Measured memory_bytes: 256
N = gets.to_i
As = gets.split.map(&:to_i)

cnt = 0
As.each do |a|
  cnt += 1 if a < 0
end

bs = As.map{|a| a > 0 ? a : -a}
res = bs.reduce(:+)
res = res - bs.min * 2 if cnt % 2 == 1

puts res

Measured memory_bytes: 9476
def slove():
    import sys
    input = sys.stdin.readline
    o = str(input().rstrip('\n'))
    e = str(input().rstrip('\n'))
    ans = []
    for i in range(51):
        if i < len(o):
            ans.append(o[i])
        if i < len(e):
            ans.append(e[i])
    print("".join(ans))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
from math import tan,pi,radians
a,b,x = map(int,input().split())
ok = 0
ng = 90
if 2*x >= a**2*b:
    while ng-ok > 10**(-7):
        mid = (ok+ng)/2
        if a*a*b-a**3*tan(radians(mid))/2 >=x:
            ok = mid
        else:
            ng = mid
else:
    while ng-ok > 10**(-7):
        mid = (ok+ng)/2
        if a*b**2 > 2*x*tan(radians(mid)):
            ok = mid
        else:
            ng = mid

print(ok)

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

#define llong long long 
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define ii pair<int, int>

#define maxn 101010
int n, c;
int a[maxn * 2];
int cnt[40];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> c;
  rep(i, n) {
    int u, v, t; cin >> u >> v >> t;
    a[i * 2] = (u * 2 - 1) * 40 + t;
    a[i * 2 + 1] = v * 2 * 40 + t;
  }

  sort(a, a + 2 * n);
  int ans = 0;
  int cur = 0;
  rep(i, 2 * n) {
    int ch = a[i] % 40;
    a[i] /= 40;
    if (a[i] & 1) {
      if (cnt[ch]++ == 0) ++cur;
    }
    else if (--cnt[ch] == 0) --cur;
    ans = max(ans, cur);
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
    
    int H,W;
    
    while(1){
    std::cin >> H >> W;
    
    if(H == 0 && W == 0)return 0;
    
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            
            switch (i % 2) {
                case 0:
                    if(j % 2 == 0 ){
                        std::cout << "#";
                    } else {std::cout << ".";}
                    break;
                case 1:
                    if(j % 2 == 1 ){
                        std::cout << "#";
                    } else {std::cout << ".";}
                    break;
            }
            
            
        }
        std::cout << "\n";
    }
    
    std::cout << "\n";
}
    
    return 0;
}


Measured memory_bytes: 3036
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


//	scanf("%d",&n);
//	scanf_s("%d",&n);

	scanf("%s",&s);
//	scanf_s("%s",&s,20);


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


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],10);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<3;i++){
		if(s[i]=='1'){
			ans++;
		}
	}

	printf("%d",ans);

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	//printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;

	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}

	return elems;
}


vector<string> results;

string run_command(string& str, vector<string>& commands) {
	auto _str = str;
	int a = stoi(commands[1]);
	int b = stoi(commands[2]);
	int print_num = b - a + 1;
	
	if (commands[0] == "print") {
		results.emplace_back(_str.substr(a, print_num));
	}
	else if (commands[0] == "reverse") {
		reverse(_str.begin() + a, _str.begin() + b + 1);
	}
	else if (commands[0] == "replace") {
		_str.replace(_str.begin() + a, _str.begin() + b + 1, commands[3]);
	}

	return _str;
}


int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	auto ans = sqrt(pow(x2 - x1, 2.0) + pow(y2 - y1, 2.0));

	printf("%lf\n", ans);
	return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define int long long

struct node{
  //親、左の子、左の子の兄弟
  int p,l,r;
};
node T[100010];

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = -1;
  for(int i = 0; i < n; i++){
    int v,d;
    cin >> v >> d;
    for(int j = 0; j < d; j++){
      int c,l;
      cin >> c;
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(int i = 0; i < n; i++){
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].p << ", ";
    int depth = 0,t = i;
    while(T[t].p != -1){
      t = T[t].p;
      depth++;
    }
    cout << "depth = " << depth << ", ";
    if(T[i].p == -1){
      cout << "root, [";
      for(int m = 0,k = T[i].l; k != -1; m++){
        if(m) cout << ", ";
        cout << k;
        k = T[k].r;
      }
      cout << "]";
    }
    else if(T[i].l == -1){
      cout << "leaf, []";
    }
    else {
      cout << "internal node, [";
      for(int m = 0,k = T[i].l; k != -1; m++){
        if(m) cout << ", ";
        cout << k;
        k = T[k].r;
      }
      cout << "]";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 5460
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	


	return 0;
}



Measured memory_bytes: 256
coinA = int(input())
coinB = int(input())
coinC = int(input())
want = int(input())
ways = 0
i = 0
while i <= coinA:
    j = 0
    while j <= coinB:
        k = 0
        while k <= coinC:
            if i*500 + j*100 + k*50 == want:
                ways = ways + 1
            k = k + 1
        j = j + 1
    i = i + 1
print(ways)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; ll K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  vector<int> v;
  vector<int> step(N, 0);
  int cnt = 2;
  step[0] = 1;
  v.push_back(1);
  int cur = 1, ans = 1, loop = 0;
  while(K > 0) {
    ans = A[cur-1];
    cur = ans;
    --K;
    if(K==0) break;
    v.push_back(cur);
    if(step[cur-1] == 0) {
      step[cur-1] = cnt;
      ++cnt;
    } else {
      loop = cnt-step[cur-1];
      K %= loop;
      ans = v[K+step[cur-1]-1];
      break;
    }
  }
  cout << ans << endl;
}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n - 1) {
        int s;
        cin >> s;
        s--;
        a[s]++;
    }
    rep(i, n) {
        cout << a[i] << endl;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 4052
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Converter(Console.ReadLine());
            Console.WriteLine(Calc(array));
            Console.ReadLine();
        }

        static int[] Converter(string str)
        {
            var array = str.Split(' ');
            return Array.ConvertAll(array, int.Parse);
        }

        static string Calc(int[] array)
        {
            var result = "No";
            int W = array[0]; int H = array[1]; int x = array[2]; int y = array[3]; int r = array[4];
            if ((x - r) >= 0)
                if ((x + r) <= W)
                    if ((y - r) >= 0)
                        if ((y + r) <= H)
                            result = "Yes";
            return result;
        }
    }
}



Measured memory_bytes: 9000
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int n,ans[maxn];
string s;
bool valid()
{
	for(int i=0;i<n;i++)
	{
		int a=i,b=(i+1)%n,c=(i+2)%n;
		if(((s[b]=='x')^ans[b]^ans[a])!=ans[c])
			return false;
	}
	return true;
}
int main()
{
	cin>>n>>s;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
		{
			ans[0]=i,ans[1]=j;
			for(int i=2;i<n;i++)
				ans[i]=(s[i-1]=='x')^ans[i-1]^ans[i-2];
			if(valid())
			{
				for(int i=0;i<n;i++)
					cout<<(ans[i]?'W':'S');
				return 0;
			}
		}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 896
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[55],tot;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		if(a[i]!=i)
			tot++;
	if(tot>2)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
LR = TIR(m)

l = -INF
r = INF

for l_, r_ in LR:
    l = max(l, l_)
    r = min(r, r_)

print(max(r-l+1, 0))


Measured memory_bytes: 83540
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c = nm()
    k = ni()

    arr = [a, b, c]
    arr.sort()

    print(arr.pop()*2**k + sum(arr))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3952
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

char s[100000];

int main() {
//	freopen("a.in", "r", stdin);
	int n= read();
	scanf("%s",s + 1);
	int r = 0, b= 0;
	for (int i = 1;i <= n; ++i) {
		r += (s[i] == 'R');
		b += (s[i] == 'B');
	}
	puts(r > b ? "Yes" : "No");


	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt)).head
  val A = ls(0)
  val B = ls(1)
  val max = Math.max(A,B)
  val ret = if(A==B) max + max else max + max - 1
  println(ret)
}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int ans = 0;
    for(int i = 0; i < v.size(); ++i) {
        while(v[i] % 2 == 0) {
            v[i] = v[i] / 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b, s int
	fmt.Scan(&a, &b)
	for i := 0; i < 2; i++ {
		if a > b {
			s += a
			a--
		} else {
			s += b
			b--
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    string a, b;

    cin >> a >> b;
    cout << (b.substr(0, b.size() - 1) == a ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/20/20
 */
public class Main {
    public int N;
    public int[][] G;

    public Main(Scanner sc) {
        N = sc.nextInt();
        G = new int[N][];
        for (int i = 0; i < N; i++) {
            G[i] = new int[N];
        }

        for (int i = 0; i < N; i++) {
            int u = sc.nextInt()-1;
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt()-1;
                G[u][v] = 1;
            }
        }
    }

    public void printAdjMat() {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N-1; j++) {
                System.out.print(G[i][j] + " ");
            }
            System.out.println(G[i][N-1]);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.printAdjMat();
    }
}


Measured memory_bytes: 32312
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n; cin >> n; int a[n], b[n], c[n];
	for(int i=0; i<n; i++) cin >> a[i];
	fill(b, b+n, 0); fill(c, c+n, 0);
	for(int i=0; i<n; i++) b[a[i]-1]++; // xの個数
	for(int i=0; i<n; i++) {
		for(int j=0; j<b[i]; j++) c[j]++;
	}
	for(int i=1; i<n; i++) {
		c[i] += c[i-1];
	}
    //for(int x:c) cout << x << " "; cout << endl;
	for(int i=1; i<=n; i++) {
		int le=-1, ri=n;
		while(ri - le > 1) {
	      int md = (le + ri) / 2;
		  if (c[md] >= (ll)(md+1)*i) le = md; else ri = md;
          //cout << "(" << le <<" " << ri << ")" << endl;
		}
		cout << le+1 << endl;
	}
}

Measured memory_bytes: 4352
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

T=X=Y=0
ok = True
for t,x,y in txy:
  if abs(X-x)+abs(Y-y) <= t-T:
    if (t-T)%2 == 0:
      if (abs(X-x)+abs(Y-y))%2!=0:
        ok = False
        break
    else:
      if (abs(X-x)+abs(Y-y))%2==0:
        ok = False
        break
  else:
    ok = False
    break
  T,X,Y = t,x,y
print("Yes" if ok else "No")

Measured memory_bytes: 27300
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<stack>
typedef long long ll;
using namespace std;
int main(){
  vector<int> a(5);
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int ans,i=0,min=10;
  for(;i<5;i++){
    if(a[i]%10==0) ans+=a[i];
    else {
      ans+= a[i]/10*10+10;
      if(a[i]%10<min) min=a[i]%10;
    }
  }
  cout << ans + min -10 << endl;
}

Measured memory_bytes: 256
import sys
#import numpy as np
stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, x = rl()
if x == 1 or x == 2 * N - 1:
    print('No')
    exit()
answer = [0] * (2*N-1)
mid = N-1
if x <= N:
    answer[mid] = x
    answer[mid-1] = x - 1
    cur = 0
    for y in range(2*N-1, 0, -1):
        while cur == mid or cur == mid-1:
            cur += 1
        if y == x or y == x-1:
            continue
        answer[cur] = y
        cur += 1
else:
    answer[mid] = x
    answer[mid-1] = x + 1
    cur = 0
    for y in range(1, 2*N):
        while cur == mid or cur == mid-1:
            cur += 1
        if y == x or y == x+1:
            continue
        answer[cur] = y
        cur += 1

print('Yes')
print(*answer)
#44


Measured memory_bytes: 15644
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007
S = 0
_sum = 0
for i in range(N):
    S += A[i]
    S %= mod
for i in range(N):
    S -= A[i]
    if S<0:
        S += mod
    _sum += A[i]*S
    _sum %= mod

print(_sum)

Measured memory_bytes: 94292
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
void dfs(vector<ll>v[],ll vis[],vector<ll>arr,ll node,ll &k,ll ans[])
{
    ans[node]=arr[k];
    vis[node]=1;
    k++;
    for(auto u:v[node])
    {
        if(!vis[u])
        {
            dfs(v,vis,arr,u,k,ans);
        }
    }
}
int main()
{
ll n,i,x,y,k,m,a,b,s=0;
cin>>n;
vector<ll>v[n+1],arr;
ll vis[n+1]={0};
for(i=1;i<n;i++)
{
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
}
for(i=0;i<n;i++)
{
    cin>>m;
    arr.pb(m);
    s=s+m;
}
sort(arr.begin(),arr.end(),greater<ll>());
s=s-arr[0];
cout<<s<<endl;
ll ans[n+1];
k=0;
dfs(v,vis,arr,1,k,ans);
for(i=1;i<=n;i++)
cout<<ans[i]<<" ";
cout<<endl;
}


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

void solve(long long N, long long K, std::vector<long long> p) {
    vector<double> sum(N + 1);
    sum[0] = 0;

    for (int i = 1; i <= N; i++) {
        double prob = (p[i - 1] + 1.0) / 2.0;
        sum[i] = sum[i - 1] + prob;
    }

    double ans = 0;
    for (int i = K; i <= N; i++) {
        double tmp = sum[i] - sum[i - K];
        if (tmp > ans) {
            ans = tmp;
        }
    }

    printf("%.12lf\n", ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

#define N 501

static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  tt++;
  d[u] = tt;
  for ( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}



void dfs(){
  int i, u;
  for ( i = 0; i < n; i++ ) color[i] = WHITE;
  tt = 0;
  for ( u = 0; u < n; u++ ){
    if ( color[u] == WHITE ) dfs_visit(u);
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}


int main(){
  int u, k, v;
  int i, j;

  scanf("%d", &n);

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

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2112
# ABC145 A
import itertools
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n = ni()
L = [[] for i in range(n)]
D = []
for i in range(n):
    x,y = nm()
    L[i].append(x)
    L[i].append(y)

L = list(itertools.permutations(L))

for l in L:
    d = 0.0
    for i in range(len(l)-1):
        d += float(((l[i][0]-l[i+1][0])**2 + (l[i][1]-l[i+1][1])**2)**0.5)
    D.append(d)

ans = float(sum(D)/len(D))
print(ans)

Measured memory_bytes: 9460
#include<iostream>

using namespace std;

int main(){

  string in;
  while(cin >> in){

    for(int i = 0; i < in.length(); i++){

      if(in[i] == '@'){

	for(int j = 0; j < in[i+1]-48; j++) cout << in[i+2];
	i += 2;
    
      }else{
	cout << in[i];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3648
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] data = new int[N];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			data[i] = a;
		}
		for (int i = 0; i < (N - 1); i++) {
			for (int k = 0; k < (N - 1); k++) {
				if (data[k] > data[k + 1]) {
					int x = data[k];
					data[k] = data[k + 1];
					data[k + 1] = x;
				}
			}
		}
		/*for(int i = 0; i < N; i++) { //デバッグ用
			System.out.println(i + " " + data[i]);
		}*/
		int cnt = 1;
		for(int i = 0; i < (N - 1); i++) {
			if(data[i] != data[i + 1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
		sc.close();
	}

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    int m, k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            int black = i * m;
            black -= (j * i);
            black += (j * (n - i));
            if(black == k)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    //int mizu = min(a, b+c)
    cout << c - min(a-b, c) << endl;
    return 0;
}


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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl; 
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=1e5;

int N,H;
int a,b[MAXN];

int main(){
  cin>>N>>H;
  int ma=0;
  for(int i=0;i<N;i++){
    cin>>a>>b[i];
    if(ma<a) ma=a;
  }
  sort(b,b+N,greater<int>());
  int cnt=0;
  for(int i=0;i<N;i++){
    if(b[i]<ma) break;
    if(H<=0) break;
    H-=b[i];
    cnt++;
  }
  if(H>0) cnt+=(H+ma-1)/ma;
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	r := nextFloat()
	fmt.Printf("%f %f\n", math.Pi*r*r, 2*math.Pi*r)
}

func nextFloat() float64 {
	scanner.Scan()
	num, err := strconv.ParseFloat(scanner.Text(), 10)
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007

lli x,y,n;
lli arr[200005];
vector<lli> adj[200005];
lli min(lli a,lli b)
{
    if(a<b)
    {
        return a;
    }
    return b;
}
void bfs(int root,int dist[])
{
    dist[root]=0;
    queue<int> q;
    q.push(root);
    while(!q.empty())
    {
        int p=q.front();
        q.pop();
        for(int i=0;i<adj[p].size();i++)
        {
            if(dist[adj[p][i]]==-1)
            {
                dist[adj[p][i]]=dist[p]+1;
                q.push(adj[p][i]);
            }
        }
    }
}

int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    map<int ,set<pair<int,int> > > m;
    for(int i=1;i<=n;i++)
    {
        int dist[n+1];
        //cout<<"for root :"<<i<<"\n";
        memset(dist,-1,sizeof(dist));
        bfs(i,dist);
        for(int j=1;j<=n;j++)
        {
            //cout<<dist[j]<<"\n";
            m[dist[j]].insert(make_pair(min(i,j) , max(i,j)));
        }
        //cout<<"\n";
    }
    for(int i=1;i<=n-1;i++)
    {
        cout<<m[i].size()<<"\n";
    }
    cout<<"\n";

    return 0;
}


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

void main(){
  char str[256];
  int i,len,array[10],ind;
  ind=0;
  scanf("%s",str);
  len=strlen(str);
  
  // 入力
  for(i=0;i<len;i++){
    if(str[i]==48){
      array[ind++]=0;
    }else if(str[i]==49){
      array[ind++]=1;
    }else{
      if(ind>0) ind--;
    }
  }
  
  //出力
  for(i=0;i<ind;i++){
    printf("%d",array[i]);
  }
}

Measured memory_bytes: 128
import sys
import numpy as np
from numba import njit
 
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
  N = len(A)
  B = np.zeros_like(A)
  for i,x in enumerate(A):
    l = max(0, i-x)
    r = min(N-1, i+x)
    B[l] += 1
    if r + 1 < N:
      B[r+1] -= 1
  B = np.cumsum(B)
  return B
    
    
N,K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
K = min(K, 100)
for _ in range(K):
  A = update(A)
print(' '.join(A.astype(str)))

Measured memory_bytes: 147312
import bisect
from operator import itemgetter

Q = int(input())
lr = [list(map(int, input().split())) for _ in range(Q)]

rmax = max(lr, key=itemgetter(1))[1]
primes = list(range(rmax+1))
primes [1] = 0

for i in range(2, int(rmax**0.5)+ 2):
    for j in range(2 * i, rmax+1, i):
        primes[j] = 0
primess = [prime for prime in primes[:] if prime!=0]
lst2017 = [x for x in primess if primes[(x+1)//2] != 0]

for l, r in lr:
    nr = bisect.bisect_right(lst2017, r)
    nl = bisect.bisect_left(lst2017, l)
    print(nr - nl)

Measured memory_bytes: 32280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, a;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> a;
	n %= 500;
	cout << (n <= a ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
	int h,n;
	cin >> h >> n;
	ll sum = 0;
	while(n--)
	{
		int x;
		cin >> x;
		sum += x;
	}
	if(sum>=h)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
int a[3001];
int d[3001][3001];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	
	int l; cin >> l;
	double a = l / (double)3;

	cout << fixed;
	cout.precision(10);

	cout << a * a * a << '\n';

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') {
            a++;
        }
    }

    if ((a == 0) || (a == 3)) {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    string s ;
    cin >> s ;
    int ans = 0 ;
    for(char &c : s){
        ans += c - '0' ; 
    }
    puts(ans % 9 == 0 ? "Yes" : "No") ;
    return 0; 
}

Measured memory_bytes: 3692
#include <stdio.h>
int main(void){
    int n;
    int gap_n;
    int gap;
    int cnt;
    scanf("%d", &n);
    
    int gaps[40];
    int n_ = n;
    gap_n = 0;
    while (n_ > 3) {
        gaps[gap_n] = n_ - 2;
        n_ /= 2;
        gap_n++;
    }
    gaps[gap_n++] = 1;
    
    int arr[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &arr[i]);
    }

    printf("%d\n", gap_n);
    for (int g=0; g<gap_n; g++) {
        if (g!=0) printf(" ");
        printf("%d", gaps[g]);
    }
    printf("\n");
        
    cnt = 0;
    for (int g=0; g<gap_n;g++) {
        gap = gaps[g];
        for (int i=0; i<n; i++) {
            int j=i;
            int value = arr[i];
            while ((j>=gap) && (arr[j-gap]>value)) {
                arr[j] = arr[j-gap];
                j -= gap;
                cnt++;
            }
            arr[j] = value;
        }
    }
    
    printf("%d\n", cnt);
    
    for (int i=0; i<n; i++) {
        if (i!=0) printf("\n");
        printf("%d", arr[i]);
    }
}



Measured memory_bytes: 6592
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    n=length(s)
    b=count(x->x=='B',s)
    w=count(x->x=='W',s)
    ans=0
    for i in 1:n
        if s[i]=='B'
            ans+=max(0,n-b-i)
        else
            ans+=max(0,i-w)
        end
    end
    println(ans)
end
main()

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

#define MorsheD ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;

int nod[10000005];
void NOD() {
    for(int i=1; i<=10000000; i++) {
        for(int j=i; j<=10000000; j+=i) {
            nod[j]++;
        }
    }
}


int main(){
    // ===================
    MorsheD;
    NOD();
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // ===================

    int n;
    cin >> n;

    ll sum = 0;

    for (int i = 1; i <= n; i++) {
        sum += (ll)i * nod[i];
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 42708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int main() {
    int N, Q, l, r;
    string s;
    int cnt = 0;
    cin >> N >> Q >> s;
    vector<int> t(N, 0);
    for(int i = 1; i < N; i++) {
        t[i] = t[i - 1];
        if(s[i] == 'C' && s[i - 1] == 'A') {
            t[i] += 1;
        }
        // cout << t[i] << endl;
    }
    for(int i = 0; i < Q; i++) {
        cin >> l >> r;
        cout << t[r - 1] - t[l - 1] << endl;
    }
    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



ll n, m;
vector<ll> k(10);
vector<vector<ll>> s(10, vector<ll>(10));
vector<ll> p(10);


bool isOn(vector<bool>& v){
  rep(i, m){
    ll sum = 0;
    rep(j, k[i]){
      if(v[s[i][j]]) sum++;
    }
    if(sum%2 != p[i]) return false;
  }
  return true;
}

int main(){
  cin >> n >> m;
  
  rep(i, m){
    cin >> k[i];
    rep(j, k[i]) cin >> s[i][j];
  }
  rep(i, m){
    rep(j, k[i]) s[i][j]--;
  }
  
  rep(i, m) cin >> p[i];

  queue<vector<bool>> que;
  que.push({});

  ll res = 0;
  while(!que.empty()){
    vector<bool> v = que.front(); que.pop();

    if(v.size() == n){
      if(isOn(v)) res++;
      continue;
    }

    vector<bool> w = v;
    v.push_back(true);
    que.push(v);
    w.push_back(false);
    que.push(w);
  }

  cout << res << endl;



  return 0;
}


Measured memory_bytes: 384
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfDouble()
    var sum = 0.0
    for (a in A) sum += 1.0 / a
    println(1 / sum)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfDouble() = listOfString().map { java.lang.Double.parseDouble(it) } //{ it.toDouble() }


Measured memory_bytes: 37584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

unordered_map<int, int> prime_factorize(int n) {
    unordered_map<int, int> res;
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res[p] = num;
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

    int n; cin >> n;
    vector<unordered_map<int, int> > p;
    unordered_map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int a; cin >> a;
        p.emplace_back(prime_factorize(a));
    }
    for(auto& pi : p){
        for(auto& it : pi){
            if(mp.count(it.first) != 0){
                mp[it.first] = max(mp[it.first], it.second);
            }
            else{
                mp[it.first] = it.second;
            }
        }
    }

    ll ans = 0;
    for(auto& pi : p){
        ll tmp = 1;
        for (auto& it : mp) {
            if(pi.count(it.first) != 0){
                tmp *= modpow(it.first, it.second - pi[ it.first ], MOD);
            }
            else{
                tmp *= modpow(it.first, it.second, MOD);
            }
            tmp %= MOD;
        }
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>

int main(void)
{
	int		i;
    
    scanf("%d", &i);
    if (i < 600)
    	printf("8");
    else if (i < 800)
    	printf("7");
    else if (i < 1000)
    	printf("6");
    else if (i < 1200)
    	printf("5");
    else if (i < 1400)
    	printf("4");
    else if (i < 1600)
    	printf("3");
    else if (i < 1800)
    	printf("2");
    else if (i < 2000)
    	printf("1");
    return (0);
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    string s; cin >> s;
    int n = s.size();
    vector<int> ar;
    rep(i,n-1){
        if (s.substr(i,2) == "BC"){
            ar.emplace_back(i);
        }
    }
    rep(i,ar.size()){
        s.replace(s.begin()+ar[ar.size()-1-i],s.begin()+ar[ar.size()-1-i]+2,"S");
    }
    s += 'B';
    n = s.size();
    vector<string> pq;
    string ps = "";
    rep(i,n){
        if ((s[i] == 'B' || s[i] == 'C') && !ps.empty()){
            pq.emplace_back(ps);
            ps = "";
        }
        else if (s[i] == 'S'|| s[i] == 'A'){
            ps += s[i];
        }
        //cout << ps << endl;
    }
    //printvec(pq);
    ll ans = 0;
    rep(i,pq.size()){
        int d = pq[i].size();
        string g = pq[i];
        //cout << g << endl;
        int cnt = 0;
        rep(j,d){
            if (g[j] == 'S'){
                ans += j - cnt;
                //cout << ans << "#" << endl;
                cnt ++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196