akhauriyash/Code-Regression huggingface dataset:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

t = read()
count = 0
l = 0
for i in list(t):
    if i == 'o':
        count += 1
    l += 1
for i in range(15 - l - 1):
    count += 1
if count >= 7:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 7748
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int n=000;
    string A;
    cin>>n;
    if(n>999){
        A="ABD";
        n=n-1000;
    }
    else{
        A="ABC";
    }
    cout<<A<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int n,a,out[210000];
vector<pair<int,int>> s;

int main() {
	cin >> n;
	REP(i, n) {
		cin >> a;
		s.push_back(make_pair(a, i + 1));
	}
	sort(ALL(s));
	REP(i, n) {
		if (i + 1 <= n / 2) out[s[i].second - 1] = s[n / 2].first;
		else out[s[i].second - 1] = s[n / 2 - 1].first;
	}
	REP(i, n) cout << out[i] << endl;
}
	


Measured memory_bytes: 4720
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;

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

    vector<pair<ll,ll>> s;
    for(int i = 0; i < n; i++){
        s.push_back(make_pair(a[i],i+1));
    }

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

    vector<pair<ll,ll>> t;

    for(int i = 1; i < n; i++){
        t.push_back(s[i]);
    }

    t.push_back(s[0]);

    vector<ll> ans;

    bool front = true;
    bool first = true;

    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>> pq1,pq2;

    pq2.push(make_pair(t[0].first-1,t[0].second));
    ans.push_back(t[0].second);

    for(int i = 1; i < n; i++){
        pq1.push(t[i]);
    }

    while(k >= 0){
        if(front){
            while(pq1.size() > 1){
                auto tmp = pq1.top();
                pq1.pop();
                if(tmp.first == 0){
                    cout << -1 << endl;
                    return 0;
                }
                tmp.first--;
                ans.push_back(tmp.second);
                pq2.push(tmp);
            }
            auto z = pq1.top();
            pq1.pop();
            if(z.first == 0){
                cout << -1 << endl;
                return 0;
            }
            z.first--;
            ans.push_back(z.second);
            pq1.push(z);
        }else{
            while(pq2.size() > 1){
                auto tmp = pq2.top();
                pq2.pop();
                if(tmp.first == 0){
                    cout << -1 << endl;
                    return 0;
                }
                tmp.first--;
                ans.push_back(tmp.second);
                pq1.push(tmp);
            }
            auto z = pq2.top();
            pq2.pop();
            if(z.first == 0){
                cout << -1 << endl;
                return 0;
            }
            z.first--;
            ans.push_back(z.second);
            pq2.push(z);
        }
        k--;
        front = !front;
    }

    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        if(i > 0)cout << " ";
        cout << ans[i];
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 384
x1,y1,x2,y2 = map(int,input().split())
diffx = x2-x1
diffy = y2-y1

x3 = x2-diffy
y3 = y2+diffx
x4 = x3-diffx
y4 = y3-diffy
print(x3,y3,x4,y4)

Measured memory_bytes: 61620
#include <stdio.h>
int main(){
  int i, j, tmp, num[100], k, minj, x=0;

  scanf("%d", &k);
  for(i=0; i < k; i++)
    {
      scanf("%d", &num[i]);
    }

  for(i=0; i<k; i++){
    minj = i;
    for(j=i; j<k; j++){
      if(num[j] < num[minj]){
	minj = j;
      }
    }
    tmp = num[i];
    num[i] = num[minj];
    num[minj] = tmp;
    
    if(minj != i){
      x++;
    }
  }
  
  for(i=0; i<k; ++i)
    {
      printf("%d", num[i]);
      if(i+1>=k) break;
      printf(" ");
    }
  printf("\n%d\n", x);
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split(" ");
    const hitPoint = Math.floor(input[0], 10);
    const atcPoint = Math.floor(input[1], 10);

    console.log(Math.ceil(hitPoint / atcPoint, 10));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 9420
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
for i in range(1,n+1):
    param,value = input().split()
    cards[pattern.index(param)][int(value)-1]  = True

for i in pattern:

    for indexj,j in enumerate(cards[pattern.index(i)]):

        if j== False:
            print("%s %d" % (i,indexj+1))


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

struct activity{
    int a,b,c;
};

int vacation(vector<activity> &v, int n){

    int dp[n+1][3];
    dp[1][0] = v[1].a;
    dp[1][1] = v[1].b;
    dp[1][2] = v[1].c;

    for(int i=2;i<=n;i++){
        dp[i][0] = v[i].a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i].b + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = v[i].c + max(dp[i-1][0],dp[i-1][1]);
    }

    return max(dp[n][0],max(dp[n][1],dp[n][2]));

}

int main() {
    
    int n;
    cin>>n;    

    vector<activity> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i].a>>v[i].b>>v[i].c;
    }

    cout<<vacation(v,n);

    return 0;
}


Measured memory_bytes: 5648
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i).first;
        a.at(i).second = i;
    }

    sort(a.begin(), a.end());
    vector<int> pla(n);
    for (int i=0; i<n; i++) {
        pla.at(a.at(i).second) = i;
    }
    int res = 0;
    for (int i=0; i<n; i+=2) {
        if (i%2 != pla.at(i)%2) res++;
    }

    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
    string s;
    cin>>s;
    int sum=0,a=0;
    r(i,(int)s.size()){
        int r=1;
        while(i<s.size()){
            sum=0;
            if(s[i]=='A')sum++;
            if(s[i]=='T')sum++;
            if(s[i]=='G')sum++;
            if(s[i]=='C')sum++;
            if(sum)a=max(a,r);
            else break;
            r++;
            i++;
            //cout<<i<<endl;
        }
    }
    cout<<a<<endl;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, k, ans;

vector<int> v[2005];

int dis[2005];

void go(int id, int prev, int ht){
	dis[ht]++;
	for(auto to: v[id]) if(to != prev){
		go(to, id, ht + 1);
	}
}

void attempt(int id){
	//keep node id, how many more can take?
	int dif = 0, sum = 0;
	for(auto to: v[id]){ //O(n) times
		memset(dis, 0, sizeof(dis));
		go(to, id, 1);
		FI(j, 1, n) dis[j] += dis[j - 1];
		sum += dis[k / 2];
		if(k & 1) dif = max(dif, dis[k / 2 + 1] - dis[k / 2]);
	}
	ans = max(ans, sum + dif + 1);
}

int main(){
	scanf("%d %d", &n, &k);
	FI(i, 2, n){
		int a, b;
		scanf("%d %d", &a, &b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	FI(i, 1, n) attempt(i);
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 512
local t = {
  {A=2,K=3},
  {K=3},
  {I=4},
  {H=5},
  {A=6,B=7},
  {B=7},
  {A=8,R=9},
  {R=9},
  {A=10,["\n"]=0},
  {["\n"]=0}
}
local s = 1
while s do
  local c = io.read(1)
  s = t[s][c]
  if not s then
    print("NO")
  elseif s == 0 then
    print("YES")
    s = nil
  end
end

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

int main()
{
    string s;
    cin >> s;
    string ans;
    if (s == "Sunny")
        ans = "Cloudy";
    if (s == "Cloudy")
        ans = "Rainy";
    if (s == "Rainy")
        ans = "Sunny";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <numeric>
#include <tuple>
#include <cmath>
#include <random>

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

typedef int64_t lint;

using namespace std;

int main(){
//////////////////////////////////////////////////////
    lint n;
    cin >> n;
    vector<string> s(n);

    rep(i, n)
    {
        cin >> s[i];
        sort(all(s[i])); 
    }

    // rep(i,10)
    // {
    //     sort(all(s),[&i](const string &a , const string &b ){return a[i] < b[i];});
    // }
    sort(all(s));

    string nows;
    lint ans = 0;
    lint add = 0;
    lint same = 0;
    for(lint i = 1 ; i < n ; i ++)
    {
        nows = s[i-1];
        bool sameflag = true;

        rep(j,10)
        {
            if(nows[j] != s[i][j])
            {
                sameflag = false;
                break;
            }
        }
        if(sameflag == true)
        {
            same ++;
            ans += same;
        }
        else 
        {
            add = 0;
            same = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  map<int, int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  multiset<int> list;
  for (auto i = a.begin(); i != a.end(); i++) {
    int p = (*i).second;
    if (p >= 2) list.insert((*i).first);
    if (p >= 4) list.insert((*i).first);
  }
  if (list.size() < 2) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  int cnt = 0;
  for (auto i = list.rbegin(); i != list.rend() && cnt < 2; i++, cnt++) {
    ans *= (*i);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> H(N), v(N);
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }

    while(M--) {
        int A, B;
        cin >> A >> B;
        --A; --B;
        if(H[A] >= H[B]) v[B]++;
        if(H[B] >= H[A]) v[A]++;
    }

    int ans = 0;
    for(auto e: v) {
        if(!e) ++ans;
    }

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


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

// ----------- define ---------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(), (x).end()
// ----------------------------------

void MAIN() {
  int n, q;
  cin >> n >> q;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    m[-t]++;
  }
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    m[-v] += u;
  }
  int ans = 0;
  for (auto &i : m) {
    int t = min(i.sc, n);
    ans += -i.fi * t;
    n -= t;
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 16104
n = input()

onaji = 0

flag = False

for i in range(3):
    if n[i] == n[i+1]:
        onaji += 1
        if onaji >= 2:
            flag = True
    else:
        onaji = 0
        
if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include<iostream>
#include <stdlib.h>
#include <algorithm> 
using namespace std;
struct store {
	
   long long int price,cans;
   
};

bool cmp(store i1,store i2) 
{ 
    return (i1.price < i2.price); 
} 

int main()
{
	long long int n,x,y,z,c,i,j,k,qq,s;
	while(cin>>x){
		qq=0;
		cin>>y;
		struct store a[x];
		for(i=0;i<x;i++){
			cin>>a[i].price>>a[i].cans;
		}
		sort(a, a+x, cmp);
		for(i=0;i<x;i++){
			if(y>a[i].cans){
				qq=qq+a[i].cans*a[i].price; 
				y-= a[i].cans;
			}
			else{
				qq=qq+y*a[i].price;
				break;
			}
			
		}
		cout<<qq<<"\n";
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;

  int debt = 100000;
  for(int i=0; i<n; i++){
    debt = debt * 105 / 100;
    if(debt % 1000 != 0) debt = (debt/1000+1)*1000;
  }

  cout << debt << endl;
}
  


Measured memory_bytes: 3004
n, m = map(int, input().split())
ret = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    ret[a] += [b]
    ret[b] += [a]
for i in range(1, n + 1):
    print(len(ret[i]))


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int a[5];
  pair<int,int> comb[5];
  for(int i=0;i<5;i++){
    cin>>a[i];
    comb[i]=make_pair(a[i]%10,a[i]);
  }
  sort(comb,comb+5);
  int t=0;
  int pass=0;
  for(int i=0;i<5;i++){
    if(comb[i].first==0) {
      pass++;
      continue;
    }
  }
  for(int i=0;i<5;i++){
    if(pass!=5 and i==pass) continue;
    t+=comb[i].second;
    if(i!=4) t=(t+9)/10*10;
  }
  if(pass!=5){
    t=(t+9)/10*10;
    t+=comb[pass].second;
  }
  cout<<t<<endl;
  return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

const int MAX = 510000;

void	ComInit(vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) {
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

ll	COM(int N, int K, vector<ll> &fac, vector<ll> &finv, vector<ll> &inv) {
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	ll S=1;
	for (ll i=K, j=N; i>0; i--, j--) {
		S *=j;
		S %=MOD;
		S *=inv.at(i);
		S %=MOD;
	}
	return S;
	//return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int	main() {
	ll n, a, b;
	cin >>n >>a >>b;
	ll nn=n;
	vector<ll> B(10, 0);
	B.at(0)=2;
	for (int i=1; i<=9; i++) {
		ll s=1;
		for (int j=0; j<10; j++) {
			s *=B.at(i-1);
			s %=MOD;
		}
		B.at(i)=s;
	}
	// Array
	vector<ll> fac(MAX);
	vector<ll> finv(MAX);
	vector<ll> inv(MAX);
	// Initialize
	ComInit(fac, finv, inv);
	ll S=1;
	ll K=0;
	while (n>0) {
		ll a=n%10;
		ll s=1;
		if (a>0)
			for (ll i=0; i<a; i++) {
				s *=B.at(K);
				s %=MOD;
			}
		S *=s;
		S %=MOD;
		K++;
		n /=10;
	}
	S--;
	if (S<0)
		S+=MOD;
	S %=MOD;
	S -=COM(nn, a, fac, finv, inv);
	if (S<0)
		S +=MOD;
	S %=MOD;
	if (a!=b) {
		S -=COM(nn, b, fac, finv, inv) ;
		if (S<0)
			S +=MOD;
		S %=MOD;
	}
	cout <<S <<endl;
	return 0;
}



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

using ll=long long; 

void solve(){
	string s1, s2;
	cin>>s1>>s2;
	for(int i=0; i<s1.size(); i++){
		cout<<s1[i];
		if(i<s2.size())cout<<s2[i];
	}
	cout<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int x, a;
    cin >> x >> a;
    cout << ( x < a ? 0 : 10) << endl;
    return 0;
}


Measured memory_bytes: 764
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int H, W = 0;
        while(true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if(H==0&&W==0) break;
            for(int i=0; i<H; i++) {
                for(int j=0; j<W; j++) {
                    if(i==0||j==0||i==H-1||j==W-1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        
        
    }
}



Measured memory_bytes: 34120
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;

class UnionFind{
public:
  //親の番号を格納する変数。数値がマイナスの場合は親であり、その絶対値のサイズのグループを持っている
  vector<int> Parent;
  
  //コンストラクタ。-1で初期化する。
  UnionFind(int N){
    Parent = vector<int>(N,-1);
  }
  
  //Aが何処のグループに属しているか返す
  int root(int A){
    if(Parent[A] < 0) return A; //0以下の時は自分が親。自分のグループなので自分を返す
    return Parent[A] = root(Parent[A]); //根でなかった場合は再帰的に関数を呼ぶ。ついでにParent[A]を更新して次の時高速化する。
  }
  
  //自分の親の頂点数を返す。マイナスでグループのサイズを持っているので反転して返す。
  int size(int A){
    return -Parent[root(A)];
  }
  
  //AとBを連結する関数
  bool connect(int A, int B){
    A = root(A); //Aの親を持ってくる
    B = root(B); //Bの親を持ってくる
    if (A==B){ //親が同じだったらくっつけない
      return false;
    }
    
    //Aが必ず大きい数にする
    if (size(A) < size(B)) swap(A,B);
    
    //AにBのグループをくっつける。
    Parent[A] += Parent[B];
    //Bの親をAにする。
    Parent[B] = A;
    
    return true;
  }
};

int main(){
  int n,k,l; cin >> n >> k >> l;
  UnionFind road(n),train(n);
  rep(i,k){
    int p,q; cin >> p >> q;
    p--,q--;
    road.connect(p,q);
  }
  rep(i,l){
    int r,s; cin >> r >> s;
    r--,s--;
    train.connect(r,s);
  }
  
  map<pair<int,int>,int> mp;
  
  rep(i,n){
    mp[{road.root(i),train.root(i)}]++;
  }
  
  rep(i,n) cout << mp[{road.root(i),train.root(i)}] << " ";
  
  return 0;
}

Measured memory_bytes: 13568
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	int p[100000][2];
	
	scanf("%d %d", &N, &M);
	for(int i = 0; i < M; i++){
		char s[100];
		scanf("%d %s", &p[i][0], s);
		p[i][1] = strcmp(s, "AC") == 0 ? 1 : 0;
	}
	
	bool pp[100001];
	int ppp[100001];
	for(int i = 0; i < N+1; i++){
		pp[i] = false;
		ppp[i] = 0;
	}
	
	int penalty = 0;
	int ac = 0;
	for(int i = 0; i < M; i++){
		if(!pp[p[i][0]] && p[i][1] == 1){
			pp[p[i][0]] = true;
			ac ++;
			penalty += ppp[p[i][0]];
		}else if(!pp[p[i][0]] && p[i][1] == 0){
			ppp[p[i][0]] ++;
		}
	}
	printf("%d %d\n", ac, penalty);
	
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double minkowsky_distance(int *x,int *y,int n,char p,int inf){
  int i;
  double sum;
  double distance;
  //Finite
  if(inf==0){
    sum=0;
    for(i=0;i<n;i++){
      sum+=pow(fabs(x[i]-y[i]),p);
    }
    distance=pow(sum,(double)1/p);
  }
  //Infinite
  else{
    distance=0;
    for(i=0;i<n;i++){
      if(fabs(x[i]-y[i])>distance){
	distance=fabs(x[i]-y[i]);
      }
    }
  }
  return(distance);
}

int main(int argc, char *argv[]){
  int i,n;
  int *x,*y;
  
  //get two vectors
  scanf("%d",&n);
  x=(int *)malloc(sizeof(int)*n);
  y=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&y[i]);
  }
  
  //calc distance
  printf("%lf\n",minkowsky_distance(x,y,n,1,0));
  printf("%lf\n",minkowsky_distance(x,y,n,2,0));
  printf("%lf\n",minkowsky_distance(x,y,n,3,0));
  printf("%lf\n",minkowsky_distance(x,y,n,3,1));
  
  //
  free(x);
  free(y);
  return(0);
}

Measured memory_bytes: 692
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<lli,pi>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5 + 5;

lli limit = 1e18;
int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		lli x;
		cin >> x;
		map<lli,lli> hs,hs1;
		for(lli i=-1000;i <= 1000;i++)
		{
			hs[i] = i*i*i*i*i;
			hs1[x] = i;
		}
		for(lli i=1;i*i <= x;i++)
		{
			if(x%i) continue;
			for(lli b = -1000;i+b<=1000;b++)
			{
				if(hs[i+b] - hs[b] == x)
				{
					cout << i + b << " " << b << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3788
using System;
    using System.Linq;
    using System.Collections.Generic;
    using static System.Math;
 
 
    public class Program
    {
        public static void Main(string[] args)
        {
            List<int> task = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToList();
            int answer = 0;
 
            for(int i = 0; i < task.Count() - 1; i++)
            {
                answer += task[i + 1] - task[i];
            }
 
            Console.WriteLine(answer);
        }
    }

Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	char S[100];
	int i, N, x = 0, max = 0;
	scanf("%d%s", &N, &S);
	for (i = 0; i<N; i++) {
		if (S[i] == 73) {
			x += 1;
			if (x>max) {
				max = x;
			}
		}
		if(S[i]==68){
                       x-=1;
               }
	}
	printf("%d", max);
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  
  int i,j;
  int n=0,k;
  int p[10000];
  int ans=0;
  int min;
  
  scanf("%d%d",&n,&k);
  
  for(i = 0; i < n; i++){scanf("%d",&p[i]);}
  
  for(i = 0; i < n; i++){
    for(j = i+1; j < n; j++){
    
      if(p[i] > p[j]){
        min = p[i];
        p[i] = p[j];
        p[j] = min;
      }
    }
  }
  
  for(i = 0; i < k; i++){ans += p[i];}
    
  printf("%d\n",ans);
  
  return 0;
  
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k; cin >> n >> m >> k;
    bool ans = false;
    [&]{
        REP(i,n+1) {
            REP(j,m+1) {
                ll b = m*i;
                b += (n-i)*j - (i*j);
                if(b==k) {
                    ans = true;
                    return;
                }
            }
        }
    }();
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n,i,r=0,t=0;
  cin>>n;
  long long int a[n];
  cin>>a[0];
  for(i=1;i<n;i++)
  { cin>>a[i];
     if(a[i-1]>=a[i]) ++r;
     else {if(t<r) {t=r;  } r=0; }
  }
  if(t<r) t=r;
  cout<<t;
  return 0;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
ll mod = 1000000007;

int main()
{
	string s;
	cin >> s;
	bool issame = true;

	char p = s[0];
	rep(i, s.size()) {
		if (p != s[i]) {
			issame = false;
		}
	}

	if (issame && s.size() >= 2) {
		cout << 1 << " " << s.size() << endl;
		return 0;
	}
	rep(i, s.size() - 1) {
		if (i == 0) {
			continue;
		}
		if ((s[i - 1] == s[i] && s[i] != s[i + 1]) ||
			(s[i - 1] != s[i] && s[i] == s[i + 1]) ||
			(s[i - 1] == s[i + 1] && s[i - 1] != s[i] && s[i] != s[i + 1]))
		{
			cout << i - 1 + 1 << " " << i + 1 + 1 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <cmath>
#include <cstring>
#include<string>
using namespace std;



int main()
{
    int a,b;
    int sum,t;
    cin>>a>>b;
    sum=a*b;
    if(a>b)
       {
           t=a;
          a=b;
         b=t;
        }
    for(int i=a;i<=b;i++)
    {
        if(sum*i%2!=0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
     }
     cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007

const int MAX =210000;
int N;
int A[200001];
int ans[200001];
int findsum(int x){
  	int g=0;
	for(int i=2;i*x<=N;i++){
    	g+=ans[i*x];
    }  
  return g;
}
int main(){
  cin>>N;
  rep(i,N){
  	cin >>A[i+1];
  }
  for(int j=N;j>=1;j--){
  	int p=(findsum(j))%2;
  	if(p!=A[j]){ans[j]=1;}
    else{ans[j]=0;}
  }
  int count=0;
  rep(i,N){
  	if(ans[i+1]==1)count++;
  }
  cout<<count<<endl;
  rep(i,N){
  	if(ans[i+1]==1){cout<<i+1<<' ';}
  }
  
}

Measured memory_bytes: 2432
n = int(input())
d = {}

for _ in range(n):
    s = ''.join(sorted(input()))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

ans = 0
for k, v in d.items():
    ans += (v * (v - 1)) / 2

print(int(ans))


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

using namespace std;

bool next_va(vector<int> &va, int m) {
  int i = va.size() - 1;
  while (i >= 0 && va[i] >= m) {
    i--;
  }

  if (i < 0) {
    return false;
  }

  va[i]++;
  fill(va.begin() + i, va.end(), va[i]);
  return true;
}

long long calc_rank(vector<int> &va, vector<array<int, 4>> &abcd) {
  long long ans = 0;
  for (auto [a, b, c, d] : abcd) {
    if (va[b] - va[a] == c) {
      ans += d;
    }
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, m, q;
  cin >> n >> m >> q;

  vector<array<int, 4>> abcd(q);
  for (int i = 0; i < q; ++i) {
    cin >> abcd[i][0];
    cin >> abcd[i][1];
    cin >> abcd[i][2];
    cin >> abcd[i][3];
    abcd[i][0]--;
    abcd[i][1]--;
  }

  vector<int> va(n, 1);
  long long ans = 0;
  do {
    ans = max(ans, calc_rank(va, abcd));
  } while (next_va(va, m));

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long ans = 0;
    for(int i = 1; i <= n; i++){
        if((i%3==0)&&(i%5==0)){
        }else if(i%3==0){
        }else if(i%5==0){
        }else{
            //cout << i << endl;
            ans+=i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

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

	public void run() throws Exception {
		FastIO file = new FastIO();
		String s = file.next();
		int a = Integer.parseInt(s.substring(0, 2));
		int b = Integer.parseInt(s.substring(2));
		boolean aa = a >= 1 && a <= 12;
		boolean bb = b >= 1 && b <= 12;
		if (aa && bb) {
			System.out.println("AMBIGUOUS");
		}
		else if (aa) {
			System.out.println("MMYY");
		}
		else if (bb) {
			System.out.println("YYMM");
		}
		else {
			System.out.println("NA");
		}
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, (p - 1) / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, (p - 1) / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


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

using namespace std;

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

  int N;
  cin >> N;
  vector<vector<pair<int, bool>>> claims(N + 1);
  for (int i = 1; i <= N; ++i) {
    int A;
    cin >> A;
    claims[i].resize(A);
    for (int j = 0; j < A; ++j) {
      int x, y;
      cin >> x >> y;
      claims[i][j] = {x, y};
    }
  }

  // cerr << "started" << endl;

  int max_cnt = 0;
  int end = pow(2, N + 1);
  for (int i = 0; i < end; ++i) {
    // cerr << "i " << i << endl;
    int cnt = 0;
    vector<bool> good(N + 1);
    int n = i;
    for (int j = 1; j <= N; ++j, n >>= 1) {
      good[j] = n & 1;
      if (good[j]) {
        ++cnt;
      }
    }
    if (max_cnt < cnt) {
      bool ok = true;
      for (int j = 1; ok && j <= N; ++j) {
        if (good[j]) {
          for (auto& p : claims[j]) {
            if (good[p.first] != p.second) {
              ok = false;
              break;
            }
          }
        }
      }

      if (ok) {
        max_cnt = cnt;
      }
    }
  }
  cout << max_cnt << endl;
}


Measured memory_bytes: 512
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q) ]
point = [0]*(N+1)
for i in range(Q):
    point[A[i]] += 1
for i in range(N):
    if K-Q+point[i+1]<=0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 8592
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m;
  ll ans = 0;
  lep(i,0,n){
    lep(j,0,n){
      int p = i + j;
      if(0 <= m-p && m-p <= n)ans++;
    }
  }
  print(ans);
  return 0;
}

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


#define ff				first
#define ss				second
#define int				long long
#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> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}




// Graph------------------------------------------------------------------------
int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
// Never GIVE UP !!!!



	int num;
	int i;
	for ( i = 1; i <= 5; i++)
	{
		cin >> num;
		if (num != i)
			break;
	}

	cout << i << endl;





}


Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int n;
  std::string a, b, c;
  std::cin >> n >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i] && b[i] == c[i])
      continue;
    else if (a[i] ==b[i] || b[i] == c[i] || c[i] == a[i])
      ++ans;
    else
      ans += 2;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    auto cnt = new long[](S.length + 1);
    foreach (i; 0 .. S.length)
        if (S[i] == 'W')
            cnt[i + 1]++;
    foreach (i; 0 .. S.length)
        cnt[i + 1] += cnt[i];
    long ans;
    foreach (i; 0 .. S.length)
        if (S[i] == 'B')
        {
            ans += cnt[$ - 1] - cnt[i + 1];
        }
    writeln(ans);
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
const int lim = 1e6+100;
int num_div[lim];
void sieve(int lim){
	for(int i=1;i<lim;i++){
		for(int j=i;j<lim;j+=i){
			num_div[j]++;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	sieve(lim);
	int n;
	cin>>n;
	long long ans=0;
	for(int c=1;c<=n-1;c++){
		ans+=num_div[n-c];
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 7552
use std::io::*;

fn dfs(v: usize, graph: &Vec<Vec<usize>>, memo: &mut Vec<u64>) -> u64 {
    if memo[v] > 0 {
        memo[v]
    } else {
        let mut res = 0;
        for &nv in graph[v].iter() {
            res = std::cmp::max(res, dfs(nv, &graph, memo) + 1);
        }
        memo[v] = res;
        res
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let xy: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            (
                itr.next().unwrap().parse::<usize>().unwrap() - 1,
                itr.next().unwrap().parse::<usize>().unwrap() - 1,
            )
        })
        .collect();
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut memo: Vec<u64> = vec![0; n];
    for i in 0..m {
        graph[xy[i].0].push(xy[i].1);
    }

    for i in 0..n {
        if memo[i] == 0 {
            dfs(i, &graph, &mut memo);
        }
    }
    let mut ans = 0;
    for i in 0..n {
        ans = std::cmp::max(ans, memo[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 17276
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n, len, q;
int a[MAXN];

int input() {
	if (scanf("%d %d %d", &n, &len, &q) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

long solve() {
	int r = INT_MAX;
	for (int t=0; t<n; t++) {
		int x = a[t];
		vector<int> v;
		for (int i=0; i<n; ) {
			if (a[i]>=x) {
				vector<int> s;
				int j;
				for (j=i; j<n && a[j]>=x; j++)
					s.push_back(a[j]);
				i = j;
				sort(s.begin(), s.end());
				for (j=0; j+len<=s.size(); j++)
					v.push_back(s[j]);
			}
			else i++;
		}
		sort(v.begin(), v.end());
		if (q<=v.size())
			r = min(r, v[q-1]-v[0]);
	}
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
ll n,m;
ll a[105],ant[100005],num[100005],ans[100005];
ll qm(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1)
        {
            ret=(ret*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ret;
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(ll i=1;i<=n;i++)
    {
        ll x=a[i];
        ll cnt=0;
        for(ll j=2;j<=x;j++)
        {
            if(x%j==0)
            {
                num[cnt]=j;
                ant[cnt]=0;
                while(x%j==0)
                {
                    ant[cnt]++;
                    x/=j;
                }
                cnt++;
            }
        }
        if(x>1)
        {
            num[cnt]=x;
            ant[cnt++]=1;
        }
        for(ll j=0;j<cnt;j++)
        {
            ans[num[j]]=max(ans[num[j]],ant[j]);
        }
    }
    ll ent=1;
    for(ll i=2;i<=1005;i++)
    {
        if(ans[i]>0)
        {
            ent=ent*qm(i,ans[i]);
        }
    }
    printf("%d\n",ent);
    return 0;
}



Measured memory_bytes: 3232
N = int(input())
train = [ list(map(int,input().split())) for i in range(N-1)]
for i in range(N-1):
    a = [ 0 for i in range(i+1)]
    a[i] = train[i][1] + train[i][0]
    for j in range(i):
        if train[i][1] >= b[j]:
            a[j] = a[i]
        else:
            a[j] = (((b[j] - train[i][1] - 1) // train[i][2]) + 1) * train[i][2] + a[i]
    b = a
for i in a:
    print(i)
print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

constexpr lnt MOD = 998244353;
struct mint
{
    lnt v;
    mint():v(0){}
    mint(lnt v):v((v+MOD)%MOD){}
    mint operator-()const{ return mint(0) - *this; }
    mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
    mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
    mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
    mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a; }
    mint operator-(const mint& a)const{ return mint(*this) -= a; }
    mint operator*(const mint& a)const{ return mint(*this) *= a; }
    mint operator/(const mint& a)const{ return mint(*this) /= a; }
    bool operator<(const mint& a)const{ return v < a.v; }
    bool operator==(const mint& a)const{ return v == a.v; }
    mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
    mint inv()const{ return pow(MOD-2); }
    static mint comb(lnt n, lnt k) {
        if(n-k<k) k=n-k;
        mint num(1), dom(1);
        for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
        return num/dom;
    }
    static std::vector<mint> construct_comb(int n) {
        std::vector<mint> c(n+1);
        mint a = 1; c[0] = a;
        for(int i=1;i<=n;i++) {
            a = a*mint(n+1-i)/i;
            c[i] = a;
        }
        return c;
    }
    static std::vector<mint> construct_fact(int n) {
        std::vector<mint> f(n+1,1);
        for(int i=2;i<=n;i++) f[i]=f[i-1]*i;
        return f;
    }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	lnt n,s;
	std::cin >> n >> s;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<mint> dp(s+1,0);
	dp[0]=1;
	mint half = mint(2).inv();
	rep(i,n) {
		for(int j=s;j>=0;j--) {
			if(j-a[i]<0) break;
			dp[j]+=dp[j-a[i]]*half;
		}
	}
	print(dp[s]*mint(2).pow(n));
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.length();
    ll num=0,ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A')num++;
        else if(s[i]=='C'&&i&&s[i-1]=='B')ans+=num;
        else if(s[i]=='B'&&i!=n-1&&s[i+1]=='C')continue;
        else num=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 720
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K  = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.cumsum()
x = Pcum[K:] - Pcum[0:-K]
print(x.max() / 2)

Measured memory_bytes: 21252