akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void solve1()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> w, r;
    for (int i = 0; i < n; ++i)
        if (s[i] == 'W')
            w.push_back(i);
    for (int i = n - 1; i >= 0; --i)
        if (s[i] == 'R')
            r.push_back(i);
    int ans = 0;
    for (int i = 0; i < min(w.size(), r.size()); ++i)
        if (w[i] < r[i])
            ans++;
    cout << ans << endl;
}
void solve2()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, ans = 0;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] == 'R')
            r++;
    for (int i = 0; i < r; ++i)
        if (s[i] == 'W')
            ans++;
    cout << ans << endl;
}
int main()
{
    //solve1();
    solve2();
    return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int k, n, d=0,d0;
    int a[10000000];
    cin>>k>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        d=max(d,a[i+1]-a[i]);
    }
    d0=a[0]+k-a[n-1];
    d=max(d,d0);
    cout<<k-d<<endl;
}

Measured memory_bytes: 3072
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    string s;
    cin>>s;
    ll k;cin>>k;
    ll m=s.size();
    for(ll i=0;i<m;i++){
        if(s[i]=='a') continue;
        ll u=s[i]-'a';
        u=26-u;
        if(u<=k){
            s[i]='a';
            k-=u;
        }
    }
    if(k>0){
        if(s[m-1]=='a'){
            k%=26;
            s[m-1]+=k;
        }else{
            s[m-1]+=k;
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

int compare_ascending(const void* a, const void* b){
    return *(int*)a - *(int*)b;
}

int main()
{
    int n;
    scanf("%d", &n);
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &c[i]);
    }
    qsort(a, n, sizeof(int), compare_ascending);
    qsort(b, n, sizeof(int), compare_ascending);
    qsort(c, n, sizeof(int), compare_ascending);
    long long int ans = 0;
	long long int x, y;
	long long int min, mid, max;
	for (int  i = 0; i < n; i++)
	{
		if (b[i] <= a[0])
			continue;
		min = 0;
		max = n;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[mid] < b[i])
				min = mid;
			else
				max = mid;
		}
		x = min + 1;
		if (b[i] >= c[n - 1])
			break;
		min = 0;
		max = n;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (c[mid] <= b[i])
				min = mid;
			else
				max = mid;
		}
		if (b[i] < c[0])
			y = n;
		else
			y = n - max;
		ans += x * y;
	}
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin, s)){
		for(int i = 0; i < 26; i++){
			for(int i = 0; s[i] != '\0'; i++){
				if(s[i] >= 97 && s[i] <= 122) s[i] = (s[i] - 97 + 1) % 26 + 97;
			}
			if(s.find("th", 0) != string::npos){
				cout << s << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1172
// 2020-09-06 22:22:41
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
namespace prime {
  bool is_prime(ll n) {
    if(n < 2) return false;
    for(ll i = 2; i * i <= n; i++) {
      if(n % i == 0) return false;
    }
    return true;
  }
  vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++) {
      if(n % i == 0) {
        res.push_back(i);
        if(i != n / i) res.push_back(n / i);
      }
    }
    return res;
  }
  map<ll, int> prime_factors(ll n) {
    map<ll, int> res;
    if(n < 2) return res;
    for(ll i = 2; i * i <= n; i++) {
      while(n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
    if(n > 1) res[n] = 1;
    return res;
  }
};

// clang-format on
void answer() {
  ll n;
  cin >> n;
  auto ds = prime::divisors(n);
  sort(ALL(ds));
  ll ans = 0;
  for (auto d : ds) {
    ll m = d - 1;
    if (m > 0 && n / m == n % m) ans += m;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3744
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)				memset(a,b,sizeof a)
#define pb				push_back

int n,m;
string s[10];

int main(){	
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif

	cin>>n>>m;
	REP(i,n)cin>>s[i];
	vector<pii> v;
	REP(i,n)REP(j,m)if(s[i][j]=='#')v.pb(pii(i+j,i*10+j));
	SORT(v);
	if(v.empty() || v[0].first)puts("Impossible");
	else{
		FOR(i,1,v.size()){
			if(v[i].first!=v[i-1].first+1){puts("Impossible");return 0;}
			if(v[i].second!=v[i-1].second+1 && v[i].second!=v[i-1].second+10){puts("Impossible");return 0;}
		}
		puts("Possible");
	}

#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a,b,c; cin >>a >> b >> c;
    if(a==b&&b==c)
        cout << "1\n";
        else if(a==b||b==c||a==c)
        cout<< "2\n";
        else
    cout << "3" << endl;
    return 0;
}


Measured memory_bytes: 764
class Dice
  V={N:0,E:1,S:2,W:3}
  def initialize(label)
    @label=label # Top down Rignt Left up Bottom
    @top=1
    @around=[5,3,2,4] # U R D L
    # 右に転がす場合
    # 対角値(レフト,idx3)が上面(top)になる
    # 右(idx1)にもともと上面だった値（top）が入る
    # その対角面(右,idx1)には対角値（合計7になる値）が入る
    # 1 => [5,3,2,4]
    # 4 => [5,1,2,6]
    # 下に転がす場合
    # 1 => [5,3,2,4]
    # 5 => [6,3,1,4]
  end
  def set_position(top_value,front_value)
    set_uniq_top(top_value)
    set_front(front_value)
  end
  def set_uniq_top(top_value)
    # 与えられた値（ラベル値）になるようにダイスを回転させる
    # 縦横の回転数を計算して実際に動かす
    top_num=@label.index(top_value)+1
    # TOP面をあわせる
    if top_num==@top then
    elsif idx=@around.index(top_num)
      rn=self.reverse_vector(idx)
      v=V.key(rn)
      self.move(v)
    elsif
      2.times{self.move("S")}
    end
  end
  def set_front(front_value)
    # 与えられた値（ラベル値）になるようにダイスを回転させる
    # 縦横の回転数を計算して実際に動かす
    front_num=@label.index(front_value)+1
    # FRONT面を合わせる
    if idx=@around.index(front_num)
      n=reverse_vector(idx)
      self.turn(n) unless n==0
    else
      puts "i can not"
    end
  end
  def turn(n)
    # n回右に回転する（TOPは変わらず）
    # n = turn_right * n
    @around.push(@around.shift(n)).flatten!
  end
  def move(v)
    # v = U,R,D,L
    #     N,E,S,W
    #     0,1,2,3
    vn=V[v.to_sym] # 移動方向のインデックス数値
    rn=reverse_vector(vn) # 対角のインデックス数値（2を足す。4を超えていた場合は剰余）
    @top,@around[vn]=@around[rn],@top
    @around[rn]=7-@around[vn]
  end
  def state
    arr=[]
    arr<<@label[@top-1]
    @around.each do |n|
      arr<<@label[n-1]
    end
    return arr
  end
  def reverse_vector(vn)
    return (vn+2)%4
  end
end

def uniq_value(label)
  label.each do |i|
    return i if label.count{|j|i==j} == 1
  end
  puts "uniq none"
end
def code_run3
  label1=$stdin.gets.split.map(&:to_i)
  d1=Dice.new(label1)
  label2=$stdin.gets.split.map(&:to_i)
  d2=Dice.new(label2)

  t=uniq_value(label1)
  d1.set_uniq_top(t)
  f=d1.state[3] #down(front)
  d2.set_position(t,f)
  puts d1.state==d2.state ? "Yes" : "No"
end


  code_run3



Measured memory_bytes: 6876
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        d = list(map(int, input().split()))

        d.sort()
        print(d[N // 2] - d[N // 2 - 1])


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 52764
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q, i, r, l;
    cin >> n >> q;
    vector<ll> data;
    vector<ll> x;
    ll tmp;
    for (int i=0; i < n; i++){
        cin >> tmp;
        data.push_back(tmp); 
    }
    rep(i, q){
        cin >> tmp;
        x.push_back(tmp);
    }
    //sort(data.begin(), data.end());
    
    ll boarder;
    ll sums;
    ll ans;
    rep(i, q){
        boarder = x[i];
        sums = 0;
        ans = 0;
        r = 0;
        rep(l, n){
             if (r == n){
                 ans += r - l;
                 //cout << l << r << endl;
                 continue;
             }else if (r <= l){
                 r = l;
             }
             while (r < n){
                 if (sums + data[r] > boarder){
                     //cout << l << r << endl;
                     break;
                  }
                  sums += data[r];
                  r++;
                  
             }
             if (sums > 0){
                sums -= data[l];
             }
             ans += r - l;
        }
        cout << ans << endl;
    }    

    return 0;
}



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

using namespace std;
using lint = long long;

lint MOD[3] = {1000000007, 1000000009, 998244353};
mt19937 mt((int)time(nullptr));
int R[10000];

lint myhash(vector<vector<int>>& graph, int v, int d, int i) {
	lint ret = 8951 * (graph[v].size() + 1);
	for(int sv : graph[v]) {
		ret *= (myhash(graph, sv, d + 1, i) + R[d]) % MOD[i];
		ret %= MOD[i];
	}
	return ret;
}

bool solve() {
	int H[2], W[2];
	vector<string> S[2];

	for(int i = 0; i < 2; ++i) {
		cin >> H[i] >> W[i];
		if (i == 0 && H[i] == 0) return false;

		S[i].resize(H[i] + 2);

		for(int x = 0; x < H[i] + 2; ++x) {
			if (x == 0 || x == H[i] + 1) {
				S[i][x] = string(W[i] + 2, '.');
			} else {
				cin >> S[i][x];
				S[i][x] = '.' + S[i][x] + '.';
			}
		}
	}

	vector<vector<int>> graph[2];

	for(int i = 0; i < 2; ++i) {
		vector<vector<int>> id(H[i] + 2, vector<int>(W[i] + 2, -1));
		int curid = 0;

		deque<pair<pair<int, int>, pair<int, int>>> que;
		que.emplace_front(make_pair(0, 0), make_pair(-1, -1));

		while (!que.empty()) {
			pair<int, int> p, sp;
			tie(p, sp) = que.front();
			que.pop_front();

			int x, y, sx, sy;
			tie(x, y) = p;
			tie(sx, sy) = sp;

			if (id[x][y] >= 0) continue;

			if (sx < 0 || S[i][sx][sy] != S[i][x][y]) {
				id[x][y] = curid++;
				graph[i].push_back(vector<int>());
				if (id[x][y] > 0) graph[i][id[sx][sy]].push_back(id[x][y]);
			} else {
				id[x][y] = id[sx][sy];
			}

			for(int dx = -1; dx <= 1; ++dx) {
				for(int dy = -1; dy <= 1; ++dy) {
					if ((dx == 0 && dy == 0) ||
						(S[i][x][y] == '.' && abs(dx) + abs(dy) == 2)) continue;

					int nx = x + dx, ny = y + dy;
					if (nx < 0 || H[i] + 2 <= nx || ny < 0 || W[i] + 2 <= ny ||
						id[nx][ny] >= 0) continue;

					if (S[i][nx][ny] == S[i][x][y]) {
						que.emplace_front(make_pair(nx, ny), make_pair(x, y));
					} else {
						que.emplace_back(make_pair(nx, ny), make_pair(x, y));
					}
				}
			}
		}
	}

	if (graph[0].size() != graph[1].size()) {
		cout << "no" << endl;
		return true;
	}

	for(int j = 0; j < 3; ++j) {
		lint val[2];
		for(int i = 0; i < 2; ++i) {
			val[i] = myhash(graph[i], 0, 0, j);
		}
		if (val[0] != val[1]) {
			cout << "no" << endl;
			return true;
		}
	}

	cout << "yes" << endl;
	return true;
}

int main() {
	for(int i = 0; i < 10000; ++i) R[i] = mt();
	while (solve());
	return 0;
}


Measured memory_bytes: 3420
package main

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

func main() {
	N, W := ReadInt(), ReadInt()
	ws := make([]int, N)
	vs := make([]int, N)
	for i := 0; i < N; i++ {
		ws[i] = ReadInt()
		vs[i] = ReadInt()
	}

	maxSumV := Sum(vs...)
	dp := make([][]int, N)
	for i := 0; i < N; i++ {
		dp[i] = make([]int, maxSumV+1)
		for sumV := 0; sumV <= maxSumV; sumV++ {
			dp[i][sumV] = W + 1
		}
	}

	dp[0][0] = 0
	dp[0][vs[0]] = ws[0]

	for i := 1; i < N; i++ {
		for sumV := 0; sumV <= maxSumV; sumV++ {
			dp[i][sumV] = dp[i-1][sumV]
			if sumV-vs[i] >= 0 {
				dp[i][sumV] = Min(dp[i][sumV], dp[i-1][sumV-vs[i]]+ws[i])
			}
		}
	}

	for sumV := maxSumV; sumV >= 0; sumV-- {
		w := dp[N-1][sumV]
		if w <= W {
			fmt.Println(sumV)
			return
		}
	}
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 82968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if (x > y)
    {
        swap(x, y);
        swap(a, b);
    }
    ans = max(x, y) * min(a + b, 2 * c);
    ans = min(ans, x * min(a + b, 2 * c) + (y - x) * b);
    cout << ans << endl;
}


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

int main(){
    int x;
    cin >> x;
    ll r;
    for(int a = 0;a <= 1000;a++){
        for(int b = -1000;b <= 1000;b++){
            r = a*a*a*a*a-b*b*b*b*b;
            if(r == x){
                cout << a <<" "<< b << "\n";
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 3648
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
    var expressions = inputs.split('\n');

    for (var i = 0; i < expressions.length; i++) {
        if (expressions[i] === '0 ? 0') {
            break;
        }
        var expression = expressions[i].split(' ');
        var left = parseFloat(expression[0]);
        var right = parseFloat(expression[2]);
        var op = expression[1];

        switch (op) {
            case '+':
                console.log(left + right);
                break;
            case '-':
                console.log(left - right);
                break;
            case '*':
                console.log(left * right);
                break;
            case '/':
                console.log(Math.floor(left / right));
                break;
        }

    }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

// N は6で割ってあまりが1か5(奇数)
int checker(ll N){
    ll n_max = ll(pow(N,0.5));
    for(int i=3;i<=n_max;i+=2){
        if(N%i==0){
            return 0;
        }
    }
    return 1;
}


int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll X;
	// 出入力
	cin >> X;

    if (X<6){
        if(X == 4){
            cout << 5 << "\n";
            return 0;
        }
        cout << X << "\n";
        return 0;
    }
    if(X%6 != 1 && X%6!= 5){
        if(X%6 ==0){
            X+=1;
        }
        else{
            X+= (5-X%6);
        }
    }

    while (checker(X)==0){
        if(X%6 == 1){
            X += 4;
        }else{
            X += 2;
        }
    }

    cout << X << "\n";


}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll X,t; cin>>X>>t;
    if(X-t>=0)cout<<X-t<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	h, w, k := io.NextInt(), io.NextInt(), io.NextInt()
	c := make([]string, h)
	for i := 0; i < h; i++ {
		c[i] = io.Next()
	}
	ans := solve(h, w, k, c)
	io.Println(ans)
}

func solve(h, w, k int, c []string) (ans int) {
	for i := 0; i < 1<<h; i++ {
		for j := 0; j < 1<<w; j++ {
			count := 0
			for is := 0; is < h; is++ {
				if i>>is&1 == 1 {
					continue
				}
				for js := 0; js < w; js++ {
					if j>>js&1 == 1 {
						continue
					}
					if c[is][js] == '#' {
						count++
					}
				}
			}
			if count == k {
				ans++
			}
		}
	}
	return ans
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
#include<iostream>
#include<vector>
using namespace std;
int main(void) {
	int N; cin >> N;
	long long int D; cin >> D;
	long long int DD = D * D;
	vector<long long int>X(N);
	vector<long long int>Y(N);
	for (int i = 0; i < N; i++){
		cin >> X[i];
		cin >> Y[i];
	}
	vector<long long int>XX(N);
	vector<long long int>YY(N);
	for (int i = 0; i < N; i++) {
		XX[i] = X[i] * X[i];
		YY[i] = Y[i] * Y[i];
	}
	vector<long long int>Distance(N);
	for (int i = 0; i < N; i++) {
		Distance[i] = XX[i] + YY[i];
	}
	int Ans = 0;
	for (int i = 0; i < N; i++) {
		if (DD >= Distance[i]) {
			Ans += 1;
		}
	}
	cout << Ans << endl;
}

Measured memory_bytes: 11164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

string s[2020];
int v[2020][2020],ex[2020][2020],ey[2020][2020];

int main(void){
	int n,m,q,i,j,sx,sy,gx,gy,vc,ec;
	fill(v[0],v[2020],0);
	fill(ex[0],ex[2020],0);
	fill(ey[0],ey[2020],0);
	cin >> n >> m >> q;
	for(i=0; i<n; ++i){
		cin >> s[i];
		for(j=0; j<m; ++j){
			v[i+1][j+1] = s[i][j]-'0';
		}
	}
	for(i=0; i<=n; ++i){
		for(j=0; j<m; ++j){
			ex[i][j+1] += ex[i][j];
			if(v[i][j]&v[i][j+1]){
				++ex[i][j+1];
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<=m; ++j){
			ex[i+1][j] += ex[i][j];
			ey[i+1][j] += ey[i][j];
			if(v[i][j]&v[i+1][j]){
				++ey[i+1][j];
			}
		}
	}
	for(i=0; i<=n; ++i){
		for(j=0; j<m; ++j){
			ey[i][j+1] += ey[i][j];
			v[i][j+1] += v[i][j];
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<=m; ++j){
			v[i+1][j] += v[i][j];
		}
	}
	for(i=0; i<q; ++i){
		vc = 0; ec = 0;
		cin >> sx >> sy >> gx >> gy;
		--sx; --sy; --gx; --gy;
		vc = v[gx+1][gy+1] - v[sx][gy+1] - v[gx+1][sy] + v[sx][sy];
		ec = ex[gx+1][gy+1] - ex[sx][gy+1] - ex[gx+1][sy+1] + ex[sx][sy+1];
		ec += ey[gx+1][gy+1] - ey[sx+1][gy+1] - ey[gx+1][sy] + ey[sx+1][sy];
		cout << (vc-ec) << endl;
	}
	return 0;
}


Measured memory_bytes: 53760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, H, W;
    cin >> N >> H >> W;
    cout << (W - N - 1) * (H - N - 1) << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]-=1
flag=format(k,'b')
flag=flag[::-1]
pos=0
for i in range(len(flag)):
  if flag[i]=='1':
    pos=arr[pos]
  tmp=[]
  for j in range(n):
    tmp.append(arr[arr[j]])
  arr=tmp
print(pos+1)

Measured memory_bytes: 169784
let house = Array.init 4 (fun x-> Array.init 3 (fun y -> Array.init 10 (fun z->0) )) and
    s = "####################";;
let n = read_int ();;

let rec read i = match i with
    0 -> ()
  | i -> Scanf.scanf "%d %d %d %d\n" (fun b f r v -> house.(b-1).(f-1).(r-1)<- (house.(b-1).(f-1).(r-1)+v));
         read (i-1) in
    read n;;

let () =
  for i=0 to 3 do
    Array.iter (fun f -> Array.iter (fun r-> Printf.printf " %d" r) f;print_newline ()) house.(i);
    if i < 3 then print_endline s;
  done;

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
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 num_divisor(int n) {
    map<int, int> a;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            if (a.count(i)) a[i]++;
            else a[i] = 1;
        }
    }
    return a.size();
}

int main(){
    int N; cin >> N;
    int count = 0;
    for (int i = 1; i <= N; i += 2) {
        if (num_divisor(i) == 8) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
     int main()
    {
         int a = 0;
         char s[3];
                              
          scanf("%s", s);
          
          if(s[0] == '1'){
            a++;
           }
          if(s[1] == '1'){
          a++;
          }
         if(s[2] == '1'){
         a++;
         }
         printf("%d", a);
         
       return 0;
     }

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

int main()
{
    int x;
    cin >> x;
    int answer = 1;
    for (int b = 2; b <= x; b++)
    {
        int bp = b * b;
        for (int p = 2;; p++)
        {
            if (bp > x)
                break;
            answer = max(answer, bp);
            bp *= b;
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


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

	int N, M, K;

	int P;
	int A[50];

	ll a = 0, b = 0;
	cin >> N >> P;
	rep(i, 0, N) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			a++;
		}
		else {
			b++;
		}
	}
	ll tmp = 1;
	ll ans = 0;
	if (P == 0) {
		j = 0;
	}
	else {
		j = 1;
	}
		
	while (j <= b) {
	
		if (j != 0)
			tmp *= max((ll)1, (b - j +1));
		tmp /= max(1, j);
		ans += tmp;
		j++;
		tmp *= max((ll)1,(b - j+1));
		tmp /= j;
		j++;
	}

	ans *= pow(2, a);
	cout << ans;



	return 0;
}

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

long long n, m, k;
vector<long long> a, b;

long long solve();

int main() {
  cin >> n >> m >> k;
  a.resize(n);
  b.resize(m + 1);
  for (auto& p : a) cin >> p;
  for (int i = 0; i < m; ++i) cin >> b[i + 1];
  for (int i = 1; i <= m; ++i) b[i] += b[i - 1];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, sum = 0, id = m;
  for (int i = 0; i <= n; ++i)
    if (sum <= k) {
      while (b[id] + sum > k) --id;
      res = max(res, id + i);
      if (i != n) sum += a[i];
    }
  return res;
}

Measured memory_bytes: 6436
N, M = (int(i) for i in input().split())
xys = [[int(i)-1 for i in input().split()] for j in range(M)]
boxes = [[False,1] for _ in range(N)]
boxes[0][0] = True #Red
for x,y in xys:
    if boxes[x][0] == True:
        if boxes[x][1] == 1:
            boxes[x] = [False,0]
        else:
            boxes[x][1] -= 1
        boxes[y] = [True,boxes[y][1] + 1]
    elif boxes[x][0] == False:
        boxes[x][1] -= 1
        boxes[y][1] += 1
ans = 0
for tf,c in boxes:
    if tf:
        ans += 1
print(ans)

Measured memory_bytes: 79576
#include <iostream>
using namespace std;
int main(void){
    int x,y,i,j;
    cin >> x >> y;
    for(i=0;i<=x;i++){
        j = x-i;
        if(i*2+j*4==y){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3604
N, _, c = map(int, input().split())
b = [int(x) for x in input().split()]

ans = 0

for _ in range(N):
    a = [int(x) for x in input().split()]
    sm = 0
    for ai, bi in zip(a, b):
        sm += ai*bi
    if sm + c > 0:
        ans += 1

print(ans)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	long long n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	long long dif = b - a;
	for(long long i = 0; i < n; i++) {
		if(c * (n - 1 - i) - i * d <= dif && dif <= d * (n - 1 - i) - i * c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    print(min(A, B), max(0, A + B - N))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    int n = s.length();

    if(n%2!=0)
    {
        cout << "No";
    }
    else
    {
        for(int i=0; i<n ; i=i+2)
        {
            if(s[i]=='h' && s[i+1]=='i')
                continue;
            else
            {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }


    return 0;
}


Measured memory_bytes: 768
BINGO = [list(map(int,input().split())) for _ in range(3)]

N=int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
    for r in range(3):
        for c in range(3):
            if BINGO[r][c] == b[i]:
                BINGO[r][c] = 0

if sum(BINGO[0])==0:
    print('Yes')
elif sum(BINGO[1])==0:
    print('Yes')
elif sum(BINGO[2])==0:
    print('Yes')
elif BINGO[0][0]+BINGO[1][0]+BINGO[2][0]==0:
    print('Yes')
elif BINGO[0][1]+BINGO[1][1]+BINGO[2][1]==0:
    print('Yes')
elif BINGO[0][2]+BINGO[1][2]+BINGO[2][2]==0:
    print('Yes')
elif BINGO[0][0]+BINGO[1][1]+BINGO[2][2]==0:
    print('Yes')
elif BINGO[0][2]+BINGO[1][1]+BINGO[2][0]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int H,W;
  scanf("%d%d",&H,&W);

  char S[H][W+1];
  for (int i = 0; i < H; i++) {
    scanf("%s",S[i]);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int flag = 0;
      if(S[i][j] == '.') continue;
      if(j != 0) if(S[i][j-1] == '#') flag = 1;
      if(i != 0) if(S[i-1][j] == '#') flag = 1;
      if(j != W-1) if(S[i][j+1] =='#') flag = 1;
      if(i != W-1) if(S[i+1][j] =='#') flag = 1;
      if(flag == 0){
        printf("No\n");
        return 0;
      }
    }
  }

  printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
A = list(zip(*a))
skip_h = [] 
skip_w = []
for i in range(h):
  if a[i] == ["."] * w: skip_h.append(i)
for i in range(w):
  if A[i] == tuple(".") * h: skip_w.append(i)

for i in range(h):
  if i in skip_h: continue
  ans = ""
  for j in range(w):
    if j in skip_w: continue
    ans += a[i][j]
  print(ans)

Measured memory_bytes: 3188
li=list(map(int,input().split()))

A=li[0]
B=li[1]
C=li[2]
D=li[3]

while ((A>0) and (C>0)) :
  C=C-B
  if C<=0:
    print('Yes')
    break
  A=A-D
  if A<=0:
    print('No')
    break


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
double PI=acos(-1);
double alphaZ;
double kq;

double Calc(double alpha){
  double res;
  if (alpha==alphaZ) res=1.0*a*b/2;
  if (alpha<alphaZ){
    double bb=a*sin(alpha)/cos(alpha);
//    cout<<sin(alpha)<<" "<<cos(alpha)<<" BB= "<<bb<<endl;
    res=a*b-0.5*a*bb;
  }
  if (alpha>alphaZ){
    double aa=b*cos(alpha)/sin(alpha);
//    cout<<sin(alpha)<<" "<<cos(alpha)<<" AA= "<<aa<<endl;
    res=0.5*aa*b;
  }
  return res;
}

int main(){
  cin>>a>>b>>c;
  if (c==a*a*b){
    cout<<"0.0000000000";
    return 0;
  }
  double inf=0,sup=PI/2;
  double cc=1.0*c/a;
  alphaZ=acos(a/sqrt(a*a+b*b));
//  cout<<alphaZ<<endl;
  for(int i=1;i<=100;i++){
    double mid=(inf+sup)/2;
    double tmp=Calc(mid);
//    cout<<"Calc("<<mid<<")= "<<tmp<<endl;
    if (tmp>=cc){
      kq=mid;inf=mid;
    }
    else sup=mid;
  }
  kq=kq*180/(PI);
  cout<<fixed<<setprecision(10)<<kq;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String S=stdIn.next();
		int K=stdIn.nextInt();
		int z=0;
		String a="";
		char s=S.charAt(K-1);
		while(z<N){
			if(S.charAt(z)!=s)
				a+="*";
			else
				a+=s;
			z++;
		}
		System.out.println(a);
	}
}

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

int main(){
	ll r,d,x;
	cin >> r >> d >> x;
	
	rep(i,10){
		x = r*x - d;
		cout << x << endl;
	}
	
    return 0;
}

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

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    int sum = 0;

    for (int i = 0; i <= N; i++) {
        sum = findSumDigits(i);
        if (A <= sum && sum <= B) {
            total += i;
        }
    }

    cout << total << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*n
for i in range(m):
    x,y = map(int,input().split())
    if h[x-1]>=h[y-1]: a[y-1]=1
    if h[x-1]<=h[y-1]: a[x-1]=1
print(a.count(0))

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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> s;

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    s.emplace_back(a, i);
  }
  sort(s.begin(), s.end());

  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    cout << s[i].second + 1;
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vvbool vector<vector<bool>>
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

int n,m;
const int limit = 50;
int a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];

void search(int a){
  visited[a] = true;
  rep(v2,n){
    if(graph[a][v2] == false) continue;
    if(visited[v2] == true) continue;
    search(v2); 
  }
}
signed main(){
  cin >> n >> m;
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  int ans = 0;
  rep(i,m){
    rep(j,n) visited[j] = false;
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;
    search(0);
    bool judge = false;
    rep(j,n) if(visited[j] == false) judge = true;
    if(judge) ans++; 
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
int n, D[1 << 21], Mod = 1000000007, w[21][21];
int main() {
	int i, j, k;
	scanf("%d", &n);
	D[0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			scanf("%d", &w[i][j]);
		}
	}
	for (i = 0; i < (1<<n); i++) {
		int c = 0;
		for (j = 0; j < n; j++)if ((i >> j) & 1)c++;
		for (j = 0; j < n; j++) {
			if (!((i >> j) & 1)) {
				if (w[c][j])D[i | (1 << j)] = (D[i | (1 << j)] + D[i]) % Mod;
			}
		}

	}
	printf("%d\n", D[(1 << n) - 1]);
}

Measured memory_bytes: 8320
from collections import defaultdict


def main():
    N = int(input())
    A = list(map(int, input().split()))
    counter = defaultdict(int)
    counter[0] = 1
    cumsum = 0
    ans = 0
    for a in A:
        cumsum += a
        ans += counter[cumsum]
        counter[cumsum] += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 42112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int c=100;
  int d=0;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    while(a%2==0){
      a/=2;
      d++;
    }
    if(d<c){
      c=d;
    }
    d=0;
  }
  cout << c <<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	map<pair<string, string>, int> mp;
	int N; cin >> N;
	string S; cin >> S;
	rep(bit, 1 << N) {
		string s1, s2;
		rep(i, N) {
			if (bit & (1 << i)) s1 += S[i];
			else s2 += S[i];
		}
		mp[make_pair(s1, s2)]++;
	}
	int sum = 0;
	rep(bit, 1 << N) {
		string s1, s2;
		for (int i = N - 1; i >= 0; i--) {
			if (bit & (1 << i)) s1 += S[N + i];
			else s2 += S[N + i];
		}
		sum += mp[make_pair(s1, s2)];
	}
	cout << sum << endl;

    return 0;
}


Measured memory_bytes: 91904
from collections import defaultdict

def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    d = defaultdict(lambda: 0)
    h, w, n = reads()
    for _ in range(n):
        a, b = reads()
        for i in range(3):
            for j in range(3):
                d[(a+i-1,b+j-1)] += 1
    r = [0] * 10
    for k in d:
        y, x = k
        if y < 2 or x < 2 or h-1 < y or w-1 < x:
            continue
        if d[k] < 10:
            r[d[k]] += 1
    r[0] = (h - 2)*(w - 2) - sum(r)
    for l in r:
        print(l)

main()

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

int main(){
  int n[3],k;
  cin >> n[0] >> n[1] >> n[2] >> k;
  sort(n,n+3);
  int ans = n[0]+n[1];
  for(int i=0; i<k; i++){
    n[2] *= 2;
  }
  ans += n[2];
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    double a,b;
    scanf("%lf%lf",&a,&b);
    if(a>0&&b>0)
    {


    if(a>b)
    {
        printf("GREATER");
    }
    else if(a<b)
    {
        printf("LESS");
    }
    else if(a==b)
    {
        printf("EQUAL");
    }
    }

}


Measured memory_bytes: 384
# -*- coding:utf-8 -*-

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

manpuku = 0

for i in range(n):
    manpuku += b[a[i]-1]
    try:
        if i == 0:
            pass
        else:
            if (a[i] - a[i-1]) == 1:
                manpuku += c[a[i-1]-1]
    except:
        pass

print(manpuku)


Measured memory_bytes: 3064
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	dipi2(n, d);
	int count = 0;
	fo(i, n) {
		int x, y;
		cin >> x >> y;
		if ((x * x + y * y) <= (d * d))
			count++;
	}
	cout << count << endl;
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}


Measured memory_bytes: 3760
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.chars();
    let xs: Vec<usize> = s.iter().rev().map(|&c|
        ((c as u8) - ('0' as u8)) as usize
    ).collect();

    let mut dp = vec![vec![0; 2]; xs.len()];
    dp[0][0] = xs[0];
    dp[0][1] = 10 - xs[0];
    for i in 1..xs.len() {
        let x = xs[i];
        dp[i][0] = min!(
            x + dp[i-1][0],
            x + dp[i-1][1] + 1
        );
        dp[i][1] = min!(
            dp[i-1][0] + (10 - x),
            dp[i-1][1] + (10 - x - 1)
        );
    }

    put!( min!(dp[xs.len()-1][0], dp[xs.len()-1][1] + 1));

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 55452
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

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

  ll N,K; cin >> N>>K;
  vl A(N); REP(i,N) cin>>A[i];
  vl F(N); REP(i,N) cin>>F[i];

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());

  ll l = 0, r = 1e12+1;
  while (l < r) {
      ll m = (l + r) / 2;
      
      ll sum = 0;      
      REP(i,N) sum += max(A[i]-m/F[i], 0LL);
      
      if (sum <= K) r = m;
      else l = m + 1;
  }
  
  ll ans = l;  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3456