akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    double ans=0;
    ll ans_w=0;
    ll ans_s=0;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            ll w=100*A*i+100*B*j;
            //ll max_s=min(F-w,(E*w)/100);
            ll max_s=F-w;
            for(int k=0;k<=max_s;k+=C){
                for(int l=0;l<=max_s;l+=D){
                    ll s=k+l;
                    if(w+s<=F&&s<=(E*w)/100){
                        double v=double(s)*100/double(w+s);
                        if(v>=ans){
                            ans=v;
                            ans_w=w;
                            ans_s=s;
                        }
                    }
                }
            }
            
        }
    }
    cout << ans_w+ans_s << " " << ans_s << endl;
}

Measured memory_bytes: 256
while True:
    a , op , b = input().split()
    a=int(a)
    b=int(b)
    if op=='+':
        print(a+b)
    if op=='-':
        print(a-b)
    if op=='*':
        print(a*b)
    if op=='/':
        print(a//b)
    if op=='?':
        break


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

using namespace std;

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

int memo[3005][3005];   /// ... for storing DP values ...

string a,b; /// ... Two Strings ...

int call(int len1,int len2){
    /// if two string come to the end then there are no substring can create ... so we return Zero.
    if(len1 == (int)a.size() || len2 == (int)b.size()) return 0;
    /// ... if the value is saved before then return it ...
    if(memo[len1][len2] != -1) return memo[len1][len2];
    /// ... if two charecture is matched ... then the length is increased by one and we go to the next phase
    /// (i + 1, j + 1) ...
    if(a[len1] == b[len2]){
        return memo[len1][len2] = 1 + call(len1 + 1, len2 + 1);
    }
    /**
        if not then we go to either by removing charecture of first or form second.
        then we collect the maximun the two function returns and saves it.
    **/
    else return memo[len1][len2] = max(call(len1 + 1,len2),call(len1, len2 + 1));
}

/// ... printing LCS ...
vector <char> res;
void PrintLCS(int len1, int len2){
    if(len1 == (int)a.size() || len2 == (int)b.size()) return;
    if(a[len1] == b[len2]){
        cout << a[len1];
        PrintLCS(len1 + 1,len2 + 1);
    }
    else{
        if(memo[len1 + 1][len2] > memo[len1][len2 + 1]) PrintLCS(len1 + 1,len2);
        else PrintLCS(len1,len2 + 1);
    }
}

int main(){
    IO;
    memset(memo, -1, sizeof(memo));
    cin >> a >> b;
    call(0,0);
    PrintLCS(0,0);
}


Measured memory_bytes: 35968
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

int ans = 0, p, q, a, n;

void reduce(int &p, int &q, int &x, int &y){
  p = p * y;
  x = x * q;
  q = q * y;
  y = q;
}

bool isSame(int x, int y){
  // 求める分数とx, yで通分
  int tmp_p = p, tmp_q = q;
  reduce(tmp_p, tmp_q, x, y);

  // 値が同じならok
  if(tmp_p == x){
    return true;
  } else{
    // 違うならだめ
    return false;
  }
}

// 必要なもの ... 今までの和の分子、分母、何個見たか、どの数まで見たか
// 必ず通分すれば積は求めなくていい
// 答えを求めるときも通分する
void dfs(int x, int y, int cnt, int max){

  // それが答えならばansを1増やす、これ以上は探索しても意味が無いので打ち切る
  if(isSame(x, y)){
    ans++;
    return ;
    // 答えじゃないけど、もうn個まで見てしまったか、積がaぴったし
  } else if(cnt >= n || y >= a){
    return ;
  }

  // 見た数から、積がリミット以上になるまで
  for(int i = max; i * y <= a; ++i){
    int tmp_x = x, tmp_y = y, tmp = 1, tmp_i = i;
    // 通分して、足す
    reduce(tmp_x, tmp_y, tmp, tmp_i);
    // 再帰
    dfs(tmp_x + tmp, tmp_y, cnt + 1, i);
  }
}

int main() {
  while(cin >>p >>q >>a >>n && p){
    ans = 0;
    // 再帰処理, 最初は 0 / 1
    dfs(0, 1, 0, 1);
    cout <<ans <<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n;
  cin >> n;
  double a, s = 0;
  for (int i = 0; i < n; i++){
    cin >> a;
    s += 1/a;
  }

  printf("%.6lf\n", 1/s);

  return 0;
}


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

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    cout << n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<deque>
#include<vector>

using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64, i64>;
i64 h, w, ch, cw, dh, dw;
i64 dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
vector<string> s(3001);
vector<vector<i32>> cost(3001, vector<i32>(3001, 1e9));

void bfs() {
    deque<P> dq;
    dq.push_front(P(ch, cw));
    cost[ch][cw] = 0;
    while (dq.size()) {
        P now = dq.front();
        dq.pop_front();
        rep(i, 4) {
            i64 ny = now.first + dy[i];
            i64 nx = now.second + dx[i];
            if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.') {
                if (cost[ny][nx] > cost[now.first][now.second]) {
                    cost[ny][nx] = cost[now.first][now.second];
                    dq.push_front(P(ny, nx));
                }
            }
            for (i64 i = -2; i <= 2; i++) {
                for (i64 j = -2; j <= 2; j++) {
                    if (i == j and i == 0)continue;
                    i64 ny = now.first + i;
                    i64 nx = now.second + j;
                    if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.') {
                        if (cost[ny][nx] > cost[now.first][now.second] + 1) {
                            cost[ny][nx] = cost[now.first][now.second] + 1;
                            dq.push_back(P(ny, nx));
                        }
                    }
                }
            }
        }
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >> h >> w >> ch >> cw >> dh >> dw;
    rep(i,h)cin >> s[i];
    ch--;
    cw--;
    dh--;
    dw--;
    bfs();
    cout << (cost[dh][dw] == 1e9 ? -1 : cost[dh][dw]) << endl;
}

Measured memory_bytes: 75336
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  sa <- BS.getLine
  ta <- BS.getLine
  let n = BS.length sa
      m = BS.length ta
  let result = solve (n,sa) (m,ta)
  putStrLn $ restore sa result n m

solve :: (Int, ByteString) -> (Int, ByteString) -> UArray (Int,Int) Int
solve (n',sa) (m',ta) = runSTUArray $ do
  dp <- newArray ((0,0),(n',m')) 0
  forM_ [(n_,m_) | n_ <- [1..n'], m_ <- [1..m']] $ \(n,m) -> do
    a <- readArray dp (n-1,m-1)
    b <- readArray dp (n,m-1)
    c <- readArray dp (n-1,m)
    if sa `BS.index` (n-1) == ta `BS.index` (m-1)
      then writeArray dp (n,m) $ maximum [a+1,b,c]
      else writeArray dp (n,m) $ maximum [b,c]
  return dp

restore :: ByteString -> UArray (Int,Int) Int -> Int -> Int -> String
restore st ary n m = go n m ""
  where go 0 _ ss = ss
        go _ 0 ss = ss
        go i j ss
          | ary U.! (i,j) == ary U.! (i-1,j) = go (i-1) j ss
          | ary U.! (i,j) == ary U.! (i,j-1) = go i (j-1) ss
          | otherwise                        = go (i-1) (j-1) ((st `BS.index` (i-1)):ss)


Measured memory_bytes: 71932
N = gets.to_i
W = Array.new
for i in 0..N-1
    W[i] = gets.chomp
end
a = 0
for i in 0..N-2
    if W[i].split('')[W[i].length-1] != W[i+1].split('')[0]
        a += 1
    end
end
if W.uniq != W
    a += 1
end
if a == 0
    puts 'Yes'
else
    puts 'No'
end



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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

//vector<vector<ll>> dp(1001,vector<ll>(1001));
vector<ll> S(1001),v;
int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
    }
    rep(i,N){
        S[i+1] = a[i] + S[i];
    }
    for(ll i=0;i<=N-1;i++){
        for(ll j=1;j<=N-i;j++){
            v.push_back(S[i+j]-S[i]);
        }
    }
    //cout << v.size() << endl;
    ll x=0;
    for(ll t=41;t>=0;t--){ 
        ll cnt = 0;
        //cout << x << endl;
        rep(i,((N*(N+1))/2)){
            if(((x+((1LL) << t)) & v[i]) == (x + ((1LL) << t))){
                cnt++;
            }
            if(cnt >= K)break;
        }
        if(cnt >= K){
            x += ((1LL) << t);
        }
    }
    cout << x << endl;
    /*

    priority_queue<ll> que;
    REP(i,0,N){
        rep(j,N-i){
            que.push(S[i+j+1] - S[i]);
            //dp[j][i] = S[j+i] - S[j];//beauty when used from j to i.
        }
    }
    ll ans = que.top();
    rep(i,K){
        ans = ans & que.top();
        //cout << que.top() << endl;
        que.pop();
    }
    cout << ans << endl;*/
}



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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    rp(i,n){
        cin >> a.at(i);
    }
    int i=0,ans=0;
    
    while(i<n){
        int cnt=1;
        int j=i;
        while(j<n-1&&a.at(j)==a.at(j+1)){
            cnt++;
            j++;
        }
        i=j+1;
        ans += cnt/2;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  int a, b, c, d, e, f;
  double x, y;
  while(cin >> a >> b >> c >> d >> e >> f){
    x = (double) (c * e - b * f) / (a * e - b * d);
    y = (double) (c * d - a * f) / (b * d - a * e);
    if(x == 0) x = 0;
    if(y == 0) y = 0;
    printf("%.3lf %.3lf\n", x, y);
  }
}

Measured memory_bytes: 1176
program payment
    implicit none
    integer(4)::i,digits,next_digits,move_up=0, count=0
    character(100000000):: s

    read*, s

    do i=len_trim(s),1,-1
        digits = ichar(s(i:i))-48
        next_digits = ichar(s(i-1:i-1))-48
        if ( digits+move_up  <= 5) then
            if (digits+move_up == 5 .and. next_digits >= 5) then
                count=count+10-(digits+move_up)
                move_up=1
            else
                count=count+digits+move_up
                move_up=0
            end if
        else
            count=count+10-(digits+move_up)
            move_up=1
        end if
        ! print*, digits, count
    end do

    print*,count+move_up

    
end program payment

Measured memory_bytes: 100156
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1100;
int n,tot = 1,st,en;
queue<int> q;
struct node{int nex,to,val,flow;}a[N << 5];
int head[N << 2],flow[N << 2],dis[N << 2],vis[N << 2],pre[N << 2],last[N << 2];
int bfs()
{
	memset(flow,0x3f,sizeof(flow));
	for(int i = 0;i <= 2 * n + 5;i ++) dis[i] = -flow[i];
	pre[en] = -1; dis[st] = 0; q.push(st);
	while(!q.empty())
	{
		int f = q.front(); q.pop(); vis[f] = 0;
		for(int i = head[f],to;i;i = a[i].nex)
		{
			to = a[i].to;
			if(dis[to] < dis[f] + a[i].val && a[i].flow)
			{
				dis[to] = dis[f] + a[i].val; 
				flow[to] = min(flow[f],a[i].flow);
				pre[to] = f; last[to] = i;
				if(!vis[to]){vis[to] = 1; q.push(to);}
			}
		}
	}
	return pre[en] != -1;
}
void add(int f,int t,int v,int flow)
{
	a[++ tot].nex = head[f]; a[tot].to = t;
	a[tot].val = v; a[tot].flow = flow;
	head[f] = tot;
	a[++ tot].nex = head[t]; a[tot].to = f;
	a[tot].val = -v; a[tot].flow = 0;
	head[t] = tot;
}
signed main()
{
	n = read(); st = 0; en = 2 * n + 5; 
	for(int i = 1,x,y,c;i <= n;i ++)
	{
		x = read(); y = read(); c = read();
		add(st,i,0,c);
		add(i,2 * n + 1,x + y,c); add(i,2 * n + 2,x - y,c);
		add(i,2 * n + 3,-x + y,c);add(i,2 * n + 4,-x - y,c);
	}
	
	for(int i = 1,x,y,c;i <= n;i ++)
	{
		x = read(); y = read(); c = read();
		add(i + n,en,0,c);
		add(2 * n + 1,i + n,- x - y,c); add(2 * n + 2,i + n,-x + y,c);
		add(2 * n + 3,i + n,x - y,c); add(2 * n + 4,i + n,x + y,c);
	}
	int mdmf = 0,maxflow = 0;
	while(bfs())
	{
		mdmf += dis[en] * flow[en];
		maxflow += flow[en];
		int t = en;
		while(t != st)
		{
			a[last[t]].flow -= flow[en];
			a[last[t] ^ 1].flow += flow[en];
			t = pre[t];
		}
	}
	cout << mdmf << "\n";
	return 0;
}

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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

// 文字列から数値へ変換して key を生成する
long long getKey(char str[]) {
  long long sum =0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) %M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str); // より高速なscanfを使用
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


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

using namespace std;

#define ll long long

ll gcd(ll a, ll b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

void solve() {
  ll a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  if (a < b || d < b) {
    puts("No");
    return ;
  } else if (b <= c + 1) {
    puts("Yes");
    return ;
  }
  a -= b;
  if (a <= c) a += d;
  ll g = gcd(b, d);
  ll have = a - c - 1;
  if (b <= c + have % g + 1) {
    puts("Yes");
  } else {
    puts("No");
  }
}

main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    solve();
  }
}


Measured memory_bytes: 256
d=dict()
d["AC"]=0
d["WA"]=0
d["TLE"]=0
d["RE"]=0
t=int(input())
while t:
	t-=1
	s=input()
	d[s]+=1
#print(d)
print("AC x",d["AC"])
print("WA x",d["WA"])
print("TLE x",d["TLE"])
print("RE x",d["RE"])

Measured memory_bytes: 9184
#include "iostream"
#include "string"
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) cin >> p[i];
    for(int i=0; i<N; i++) p[i]--;
    int ans = 0;
    for(int i=0; i<N-1; i++){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[N-1]==N-1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> H(N);
    for(int i=0;i<N;i++) cin>>H[i];
    int visible=0;
    int saidai=0;
    for(int i=0;i<N;i++){
        if(H[i]>=saidai){
            visible++;
            saidai=H[i];
        }
    }
    cout<<visible<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    int c=0;
    cin>>S>>T;
    for(int i=0;i<3;i++)
    {
        if(S[i]==T[i])
        {
            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 1
r,g,b = 0,0,0

for x in a:
    ans *= [r,g,b].count(x)
    ans %= 1000000007
    if r == x:r+=1
    elif g == x:g +=1
    elif b == x:b +=1
    else:
        print(0)
        exit()

print(ans)

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

typedef long long ll;

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  ll cnt=0;
  if(a.at(0)>x) {
    cnt+=(a.at(0)-x);
    a.at(0)=x;
  }

  for (int i = 0; i < N-1; i++) {
    if((a.at(i)+a.at(i+1))>x){
      ll d=a.at(i)+a.at(i+1)-x;
      cnt+=d;
      a.at(i+1)-=d;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ull unsigned long long 
#define ul unsigned long
#define ll long long
#define pb push_back
#define sodayoda_C  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,b) for(int i = a;i<b;i++)
#define fb(i,a,b) for(int i = a;i>b;i--)
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mp make_pair
//memset(name,'',size)
//reverse(s,begin(),s.end())

using namespace std;

int fact(int n){
	if(n == 0) return 1;
	return n*fact(n-1);
}

int main(){	
	sodayoda_C;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int t;
	//cin>>t;
	t = 1;
	while(t--){
		int n;
		cin>>n;
		double x[n],y[n];
		f(i,0,n) cin>>x[i]>>y[i];
		double ans = 0;
		f(i,0,n){
			f(j,0,n){
				if(j!=i){
					ans+= (1/(double)n)*sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
				}
			}
		}
		printf("%.7f",ans);
	}
	return 0;
}


Measured memory_bytes: 3828
import scala.io.StdIn.readLine

object Main extends App {
  val Array(a, b) = readLine().split(" ").map { _.toInt }

  val op = solve(a, b)
  println(s"a $op b")

  def solve(a: Int, b: Int): String = a.compare(b) match {
    case 0  => "=="
    case -1 => "<"
    case 1  => ">"
  }
}



Measured memory_bytes: 43956
#include <cstdio>

long long leftL[2000];
long long rightL[2000];

constexpr long long MOD = 1000000007;

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  long long a[2000];
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
  }
  for (long long i = 0; i < n; ++i)
  {
    for (long long j = 0; j < i; ++j)
    {
      if (a[j] < a[i]) ++leftL[i];
    }
    for (long long j = i + 1; j < n; ++j)
    {
      if (a[j] < a[i]) ++rightL[i];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i)
  {
    ans = (ans + ((k * (k + 1) / 2) % MOD) * rightL[i] + (((k - 1) * k / 2) % MOD) * leftL[i]) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;
typedef long long ll;
typedef vector<ll> vll;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    ll n,k;
    cin >> n >> k;
    vll cnt(n+1, 0);
    rep(i,n){
        ll a;
        cin >> a;
        cnt[a]++;
    }

    sort(all(cnt));
    ll r = 0;
    rep(i,n-k+1)r += cnt[i];
    cout << r << endl;

    return 0;
} 

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int ct = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.length() / 2; i++) {
        if (S[i] != S[S.length() - 1 - i])
            ct++;
    }
    cout << ct << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <cstring>          // memset()
#include <vector>
#include <queue>
#include <algorithm>        // min()

using namespace std;
static const int MAX_V = 100;
static const int INF = 100000000;

typedef struct edge_tbl
{
	int to, cap;
	unsigned long rev;
} edge;

vector<edge> G[MAX_V];
int level[MAX_V];
unsigned int iter[MAX_V];

void
bfs(int s)
{
	queue<int> que;

	memset(level, -1, sizeof(level));
	level[s] = 0;
	que.push(s);
	while (!que.empty())
	{
		int v = que.front(); que.pop();
		for (unsigned int i = 0; i < G[v].size(); ++i)
		{
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0)
			{
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int
dfs(int v, int t, int f)
{
	if (v == t)
		return f;

	for (unsigned int &i = iter[v]; i < G[v].size(); ++i)
	{
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to])
		{
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}

	return 0;
}

int
max_flow(int s, int t)
{
	int flow = 0;
	while (true)
	{
		bfs(s);
		if (level[t] < 0)
			return flow;

		memset(iter, 0, sizeof(iter));
		int f;
		while ((f = dfs(s, t, INF)) > 0)
			flow += f;
	}
}

int
main(int argc, char** argv)
{
	int V, E;
	int u, v, c;

	scanf("%d %d", &V, &E);
	for (int i = 0; i < E; ++i)
	{
		scanf("%d %d %d", &u, &v, &c);
		G[u].push_back((edge){v, c, G[v].size()});
		G[v].push_back((edge){u, 0, G[u].size() - 1});
	}

	printf("%d\n", max_flow(0, V - 1));
	return 0;
}

Measured memory_bytes: 2764
#include <stdio.h>
/*ABC
Smeke's current rating is less than 1200, thus the output should be ABC.
*/
int main ()
{
	int a=0;
	scanf("%d",&a);
	if(a<1200)
		{
			printf("ABC\n");
		
		}
	else if(a>=1200&&a<2800)
	{
		printf("ARC\n");
		
	}
	else if(a>=2800)
	{
		printf("AGC\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**13
# sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

A,B,Q = LI()
s = [0 for i in range(A)]
t = [0 for i in range(B)]
x = [0 for i in range(Q)]
for i in range(A):
    s[i] = int(input())
for i in range(B):
    t[i] = int(input())
for i in range(Q):
    x[i] = int(input())


def solve(pos):
    ans1,ans2,ans3,ans4 = mod,mod,mod,mod
    s_left = bisect.bisect_left(s,pos)-1
    t_left = bisect.bisect_left(t,pos)-1
    # print("s",s_left,"t",t_left)
    if s_left >= 0 and t_left >= 0:
        ans1 = pos - min(s[s_left],t[t_left])
    if s_left+1 < A and t_left >= 0:
        ans2 = s[s_left+1] - t[t_left] + min(s[s_left+1]-pos, pos - t[t_left])
    if t_left + 1 < B and s_left>= 0:
        ans3 = t[t_left+1] - s[s_left] + min(t[t_left+1] - pos, pos-s[s_left])
    if s_left+1 < A and t_left+1 < B:
        ans4 = max(s[s_left+1],t[t_left+1]) - pos
    # print(ans1,ans2,ans3,ans4)
    ans = min(ans1,ans2,ans3,ans4)
    return ans


for i in range(Q):
    print(solve(x[i]))


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

int digits(long x){
  int d=0;
  while(x>0){
    d++;
    x/=10;
  }
  return d;
}

int main() {
  long N;
  cin >> N ;
  long rt = sqrt(N)/1;
  int ans =1234567890;
  for(int i=1;i<=rt*2;i++){
    long a=N/i;
    long b=i;
    if(a*b==N){
    int di = max(digits(a),digits(b));
    ans=min(di,ans);
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// true:a < b false:a > b
bool mycomp(pair <int, int> a, pair <int, int> b)
{
	int c = a.first*a.first + a.second*a.second;
	int d = b.first*b.first + b.second*b.second;
	if (c == d){
		return a.first < b.first;
	}
	return c < d;
}

int main(void)
{
	int h, w;

	// cout << mycomp(make_pair(1, 2), make_pair(1, 3)) << endl;
	while (cin >> h >> w){
		if (h == 0 && w == 0){
			return 0;
		}
		pair <int, int> rect(h, w);
		pair <int, int> ret(-1, -1);
		int nowmax = 10e9;
		for (int i = 1; i <= 150; i++){
			for (int j = i+1; j <= 150; j++){
				if (i == h && j == w) continue;
				pair <int, int> tmp(i, j);
				if (mycomp(rect, tmp)){ // tmpの方が大きい
					if (ret.first == -1 || mycomp(tmp, ret)){
						ret = tmp;
					}
				}
			}
		}

		cout << ret.first << " " << ret.second << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
using namespace std;
 
int main(void){
	int r, c, tmp;
	cin >> r >> c;
	vector < vector<int> > d(r+1, vector<int>(c+1));

	for (int i=0; i<r; i++)
		for (int j=0; j<c; j++){
			cin >> tmp;
			d[i][j] = tmp;
			d[i][c] += tmp;
			d[r][j] += tmp;
		}

	for (int j=0; j<c; j++)
		d[r][c] += d[r][j];

	for (int i=0; i<r+1; i++)
		for (int j=0; j<c+1; j++){
			cout << d[i][j];
			if (j!=c) cout << " ";
			else cout << endl;
		}
	return 0;
}

Measured memory_bytes: 1256
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] c = new int[N];
        int[] t = new int[N];
        for (int i = 0; i < N; i++) {
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
        }
        int ans = -1;
        for (int i = 0; i < N; i++) {
            if (t[i] <= T) {
                if (ans == -1 || ans > c[i])
                    ans = c[i];
            }
        }
        if (ans == -1)
            System.out.println("TLE");
        else
            System.out.println(ans);

    }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int x;
    cin >> x;
    int ans;
    if (x < 600)
    {
        ans = 8;
    }
    else if (x < 800)
    {
        ans = 7;
    }
    else if (x < 1000)
    {
        ans = 6;
    }
    else if (x < 1200)
    {
        ans = 5;
    }
    else if (x < 1400)
    {
        ans = 4;
    }
    else if (x < 1600)
    {
        ans = 3;
    }
    else if (x < 1800)
    {
        ans = 2;
    }
    else if (ans < 2000)
    {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3668
def main():
    N = int(input())
    h = [int(x) for x in input().split()]
    dp = [float('INF')]*N
    dp[0] = 0

    for i in range(1,N):
        if i != 1:
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
        dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))

    print(dp[N-1])

if __name__ == '__main__':
    main()

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

int main() {
	long long a,b,c;
	string ans;

	cin >> a >> b >> c;

	long long x;
	x=(c-(a+b))*(c-(a+b));
	if(4*a*b<x){
		ans="Yes";
	}
	else{
		ans="No";
	}

	if(c-(a+b)<=0){
		ans="No";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
ll factorial(long long int k){
    ll i,ans=1;
    for(i=1;i<=k;i++){
		ans=(ans*i)%MOD;
    }
    return ans;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	ll n,m,a,b;
	ll ans;
    cin>>n>>m;
    if(n==m){
		a=factorial(n);
		b=factorial(m);
		ans=(a*b*2)%MOD;
    }
	else if(n-m==1||m-n==1){
		a=factorial(n);
		b=factorial(m);
		ans=(a*b)%MOD;
    }else{
		ans=0;
    }
    cout<<ans;
	//system("pause");
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

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

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

int main(void){
    int N; cin >> N;
    string S; cin >> S;

    VI nd(N,0), nm(N,0), nc(N,0);
    REP(i,N){
        if(S[i]=='D') nd[i] = 1;
        else if(S[i]=='M') nm[i] = 1;
        else if(S[i]=='C') nc[i] = 1;
    }
    REP(i,N-1) nd[i+1] += nd[i]; REP(i,N-1) nm[i+1] += nm[i]; REP(i,N-1) nc[i+1] += nc[i];
    ll ndmc = 0;
    REP(i,N) if(S[i]=='M') ndmc += (ll)nd[i]*(nc[N-1]-nc[i]);
    VL sc(nc[N-1]+1);
    REP(i,N) if(S[i]=='C') sc[nc[i]] = nm[i];
    REP(i,nc[N-1]) sc[i+1] += sc[i];

    int Q; cin >> Q;
    REP(i,Q){
        int k; cin >> k;
        ll ans = 0;
        REP(i,N-k){
            if(S[i] != 'D') continue;
            ll M = nm[i];
            ll t = nc.back() - nc[i+k-1];
            ans += sc.back() - sc[nc.back()-t] - M*t;
        }
        cout << ndmc - ans << en;
    }
    return 0;
}

Measured memory_bytes: 20868
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

/**
 *
 * @author Pradyumn Agrawal coderbond007
 */

public class Main{
    public static InputStream inputStream = System.in;
    public static StringTokenizer tok = null;
    public static BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32768);
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws java.lang.Exception{
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new Main().run();
                    out.close();
                } catch(IOException e){

                }
            }
        }, "1", 1 << 26).start();
    }
    public void run() throws IOException
    {
    	char a = nc(),b = nc();
    	if(a == 'H'){
    		out.println(b);
    	} else {
    		out.println(b == 'H' ? "D" : "H");
    	}
    }
    public static int ni() throws IOException {
        return Integer.parseInt(ns());
    }
    public static long nl() throws IOException {
        return Long.parseLong(ns());
    }
    public static double nd() throws IOException {
        return Double.parseDouble(ns());
    }
    public static char nc() throws IOException {
        return ns().charAt(0);
    }
    public static BigInteger nextBigInteger() throws IOException {
        return new BigInteger(ns());
    }
    public static String ns() throws IOException {
        while(tok == null || !tok.hasMoreTokens()){
            try {
                tok = new StringTokenizer(br.readLine());
            } catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tok.nextToken();
    }
    public static int[] na(int n) throws IOException {
        int[] a = new int[n];
        for(int i = 0;i < n; i++){
            a[i] = ni();
        }
        return a;
    }
    public static long[] nal(int n) throws IOException {
        long[] a = new long[n];
        for(int i = 0;i < n; i++){
            a[i] = nl();
        }
        return a;
    }
    public static char[] ns(int n) throws IOException {
        return ns().substring(0,n).toCharArray();
    }
    public static char[][] nm(int n, int m) throws IOException{
        char[][] map = new char[n][];
        for(int i = 0;i < n; i++){
            map[i] = ns(m);
        }
        return map;
    }
    public static String readLine() {
    	try {
    		return br.readLine();
    	} catch(IOException e){
    		throw new RuntimeException(e);
    	}
    }
}

Measured memory_bytes: 23508
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
aa=[]
bb=[]
cc=[]
dd=[]
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations_with_replacement(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))

Measured memory_bytes: 71576
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep (i, n) {
    int tmp;
    cin >> tmp;
    auto itr = mp.find(tmp);
    if (itr != mp.end()) mp[tmp]++;
    else mp[tmp] = 1;
  }

  ll ans[2] = {0, 0};
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second > 1) {
      if (itr->second > 3) {
        ans[0] = ans[1] = itr->first;
      } else {
        ans[0] = ans[1];
        ans[1] = itr->first;
      }
    }
  }
  P(ans[0] * ans[1]);
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  //input
  long long N,D;
  cin >> N >> D;
  long long E = D*D;
  long long X[N],Y[N];
  for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
  
  //setup
  int Total=0;
  for(int i=0;i<N;i++){
    if(E>=X[i]*X[i]+Y[i]*Y[i]) Total++;
  }
  
  //output
  cout << Total << endl;
}

Measured memory_bytes: 6752
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    void solve() throws IOException {
        int n=ni();
        String s=next();
        for (int x=0;x<s.length();x++) {
            int b=s.charAt(x)+n;
            if (b>90) b=b-26;
            out.print((char)b);
        }
        out.println();
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 21332
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for(int i = 0; i < n; i++){
            a.add(scan.nextInt());
        }
        ArrayList<Integer> aa = new ArrayList<>(new HashSet<>(a));
        if(aa.size() == n){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 96420
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string s;
	cin>>s;

	int W =0;
	long long sum = 0;

	for(int  i = (int)s.length()-1;i>=0;i--)
	{
		  if(s[i]=='W')
		  	W++;
		  else
		  	sum+=W;
	}
	cout<<sum<<endl;
}

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

int main(){
    long long n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1||m==1)cout<<max(n*m-2ll,0ll)<<endl;
    else cout<<(n-2)*(m-2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int main(){

	priority_queue<int> pq;
	for(int i = 0; i < 10; i++){
		int tmp;
		cin >> tmp;
		pq.push(tmp);
	}

	for(int i = 0; i < 3; i++){
		cout << pq.top() << endl;
		pq.pop();
	}

	int x;
	cin >> x;

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long[] ri = new long[n], le = new long[n];
		
		for(int i=0;i<n;i++) {
			int x = sc.nextInt();
			if(i-x >=0) le[i - x]++;
			if(i + x <n) ri[i + x]++;
		}
		
		long ans=0;
		for(int i=0;i<n;i++) ans += le[i] * ri[i];
		
		out.print(ans);
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 57036
#include<stdio.h>
int main(void)
{
	int a[10],b[10],n,m,x,y,w=0,k=0,i,j;
	for(i=0; i<10; i++)
	scanf("%d", &a[i]);
	for(i=0; i<10; i++)
	scanf("%d", &b[i]);
	for(i=0; i<3; i++)
	{
		n=0;
		m=0;
		for(j=0; j<10; j++)
		{
			if(a[j]>n)
			{
				n=a[j];
				x=j;
			}
			if(b[j]>m)
			{
				m=b[j];
				y=j;
			}
		}
		w+=n;
		k+=m;
		a[x]=0;
		b[y]=0;
	}
	printf("%d %d\n", w, k);
	
	return 0;
}


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

int main()
{
    long a, b, c;
    cin >> a >> b >> c;
    if ((c - a - b) < 0) {
        cout << "No" << endl;
        return 0;
    }
    if ((c - a - b) * (c - a - b) > 4 * a * b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;ll
#define Nmax 200005
#define OFF 100001
using namespace std;

ll n,m,v[Nmax], k,x;
vector<ll> d;

vector<ll> compound(vector<ll> A, vector<ll> B){
    vector<ll> ans;
    ans.resize(A.size());
    for (ll i=1;i<B.size();i++){
        ans[i] = A[B[i]];
    }
    return ans;
}

vector<ll> _pow(vector<ll> A, ll b){
    if (b==1) return A;
    if (b%2) return compound(_pow(compound(A,A), b/2), A);
    return _pow(compound(A,A), b/2);
}

int main()
{
    cin >> n;
    for (ll i=1;i<=n;i++) cin >> v[i];
    d.resize(n);
    iota(d.begin(),d.end(),0);
    cin >> m >> k;
    for (ll i=1;i<=m;i++){
        cin >> x;
        swap(d[x],d[x-1]);
    }
    d = _pow(d, k);
    cout << v[1] << '\n';
    ll ant = v[1];
    for (ll i=1;i<n;i++){
        ant += v[d[i]+1] - v[d[i]];
        cout << ant << '\n';
    }
    return 0;
}


Measured memory_bytes: 160128
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    A = list(map(int, input().split()))

    four, two = 0, 0

    for a in A:
        if a % 4 == 0:
            four += 1
        elif a % 2 == 0:
            two += 1
    if two:
        N -= two - 1
    if N // 2 <= four:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15016
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,p,x,y,tot;
int dist[505][505],emp[505][505];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void upd(int x,int y){
	int nd=dist[x][y]+(!emp[x][y]);
	int nx,ny;
	for(int i=0;i<4;i++){
		nx=x+dx[i],ny=y+dy[i];
		if(nx>=1&&nx<=n&&ny>=1&&ny<=n&&dist[nx][ny]>nd){
			dist[nx][ny]=nd;
			upd(nx,ny);
		}
	}
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dist[i][j]=min(min(i-1,n-i),min(j-1,n-j));
	for(int i=1;i<=n*n;i++){
		cin>>p;
		x=(p-1)/n+1,y=(p-1)%n+1;
		tot+=dist[x][y];
		emp[x][y]=1;
		upd(x,y);
	}
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 24972
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int a[n+1];
    for(int i =1;i<= n; i++){
        int m;
        cin>>m;
        a[m] = i;
    }
    for(int i =1;i<=n;i++){
        if(i>1) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 1e5+10;
const int mod = 1e9+7;
const int inf = 2e9+10;
long long a[mxn];

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

	int n, k; cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>a[i];

	vector<long long> onlyPositive(n+1, 0);
	for(int i=1; i<=n; i++) if(a[i]>0) onlyPositive[i] = a[i];

	vector<long long> onlyPositivePref(n+1, 0);
	for(int i=1; i<=n; i++) onlyPositivePref[i] = onlyPositivePref[i-1]+1ll*onlyPositive[i];
	vector<long long> normalPref(n+1, 0);
	for(int i=1; i<=n; i++) normalPref[i] = normalPref[i-1]+1ll*a[i];

	long long mx = 0;
	for(int i=k; i<=n; i++) {
		long long Black = normalPref[i]-normalPref[i-k]+onlyPositivePref[i-k]+(onlyPositivePref[n]-onlyPositivePref[i]);
		long long White = onlyPositivePref[i-k]+(onlyPositivePref[n]-onlyPositivePref[i]);
		mx = max(mx, max(Black, White));
	}

	cout << mx << '\n';

	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 6360