akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 666;
vector<pair<int, int> > p[2], w[4];
vector<int> to[2][maxn * maxn];
int vis[2][maxn * maxn], cs[2][maxn * maxn];
void dfs(int r, int u){
	vis[r][u] = 1;
	for(int n : to[r][u]){
		if(vis[r][n]){
			assert(cs[r][n] ^ cs[r][u]);
			continue;
		}
		cs[r][n] = cs[r][u] ^ 1;
		dfs(r, n);
	}
}
int main(){
	int n, d1, d2;
	cin >> n >> d1 >> d2; 
	int want = n * n;
	n *= 2;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i * i + j * j == d1){
				p[0].push_back({i, j});
			}
			if(i * i + j * j == d2){
				p[1].push_back({i, j});
			}
		}
	}
	auto cell = [&](int i, int j){
		return i * n + j;
	};
	auto add = [&](int b, int i, int j){
		to[b][i].push_back(j);
		to[b][j].push_back(i);
	};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			for(int rot = 0; rot < 2; rot++){
				for(auto e : p[rot]){
					if(i + e.first < n && j + e.second < n){
						add(rot, cell(i, j), cell(i + e.first, j + e.second));
					}
                  	if(i + e.first < n && j - e.second >= 0){
						add(rot, cell(i, j), cell(i + e.first, j - e.second));
					}
                  	if(i - e.first >= 0 && j + e.second < n){
						add(rot, cell(i, j), cell(i - e.first, j + e.second));
					}
				}
			}
		}
	}
	for(int rot = 0; rot < 2; rot++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(!vis[rot][cell(i, j)]){
					dfs(rot, cell(i, j));
				}
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int cc = cell(i, j);
			w[cs[0][cc] * 2 + cs[1][cc]].push_back({i, j});
		}
	}
	for(int i = 0; i < 4; i++){
		if(w[i].size() >= want){
			w[i].resize(want);
			for(auto e : w[i]) cout << e.first << " " << e.second << endl;
			return 0;
		}	
	}
	assert(0);
	return 0;
}


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

using namespace std;

int find(int e)
{
    int m = 1000000;
    for(int z=0; z<=100; z++)
    {
        int r = e - z*z*z;
        if(r<0) break;
        for(int y=0; y<=1000; y++)
        {
            int x = r - y*y;
            if(x<0) break;
            m = min(m, x+y+z);
        }
    }
    return m;
}

int main()
{
    int e;
    while(cin >> e, e) cout << find(e) << endl;
}

Measured memory_bytes: 2976
n=int(input())
x=[1,2,3,4,5,6,7,8,9,10,11,12,13]
s=[]
h=[]
c=[]
d=[]
for i in range(n):
    egara,no=input().split()
    No=int(no)
    if egara=='S':
        s.append(No)
    elif egara=='H':
        h.append(No)
    elif egara=='C':
        c.append(No)
    elif egara=='D':
        d.append(No)
    
s.sort()
h.sort()
c.sort()
d.sort()

for j in range(4):
    if j==0:
        ls=set(x)^set(s)
        lslist=list(ls)
        for k in range(len(ls)):
            print('S',end=' ')
            print(lslist[k])
    elif j==1:
        lh=set(x)^set(h)
        lhlist=list(lh)
        for l in range(len(lh)):
            print('H',end=' ')
            print(lhlist[l])
    elif j==2:
        lc=set(x)^set(c)
        lclist=list(lc)
        for m in range(len(lc)):
            print('C',end=' ')
            print(lclist[m])
    elif j==3:
        ld=set(x)^set(d)
        ldlist=list(ld)
        for o in range(len(ld)):
            print('D',end=' ')
            print(ldlist[o])
        


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

const int INF = pow(2, 31) - 1;
#define DEBUG(x) cout << "DEBUG PRINT (" << #x << " = " << x  << ")" << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> count(5, 0);
  REP(i, N) {
    cin >> S[i];
    if(S[i][0] == 'M') {
      count[0]++;
    } else if(S[i][0] == 'A') {
      count[1]++;
    } else if(S[i][0] == 'R') {
      count[2]++;
    } else if(S[i][0] == 'C') {
      count[3]++;
    } else if(S[i][0] == 'H') {
      count[4]++;
    }
  }
  long long ans = 0;
  int bit = 5;
  for(int mask = 0; mask < pow(2, bit); mask++) {
    long long sum = 0;
    string sb;
    long long c = 1;
    int co = 0;
    for(int i = 0; i < bit; i++) {
      if(mask >> i & 1) {
        sb += '1';
        co++;
      } else {
        sb += '0';
      }
    }
    if(co == 3) {
      for(int i = 0; i < bit; i++) {
        if(sb[i] == '1') {
          c *= count[i];
        }
      }
      ans += c;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.SplittableRandom;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static long[] buf = new long[200000];

  public static void main(String[] args) {
    SplittableRandom rnd = new SplittableRandom();

//    for (int turn = 0; turn < 1000000; turn++) {
//      int N = rnd.nextInt(10) + 1;
//      long[] A = new long[N];
//      long[] B = new long[N];
//      for (int i = 0; i < N; i++) {
//        A[i] = rnd.nextInt(1 << 28);
//        B[i] = rnd.nextInt(1 << 28);
//      }
//      long brute = 0;
//      for (int i = 0; i < N; i++) {
//        for (int j = 0; j < N; j++) {
//          brute ^= A[i] + B[j];
//        }
//      }
//      System.err.println("brute:" + brute);

    int N = sc.nextInt();
    long[] A = new long[N];
    long[] B = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }

      int ans = 0;
      for (int i = 0; i < 30; i++) {
        int bb = 0;
        for (int j = 0; j < N; j++) {
          if ((B[j] & (1 << i)) != 0) ++bb;
        }
        int bbAll = bb;
        long mask = (1L << i) - 1;
        long count = 0;
        int bp = N;
        for (int j = 0; j < N; j++) {
          long av = A[j] & mask;
          while (bp > 0) {
            if ((av + (B[bp - 1] & mask)) <= mask) {
              break;
            }
            --bp;
            if ((B[bp] & (1 << i)) != 0) --bb;
          }
          if ((A[j] & (1 << i)) == 0) {
            // zero & carry or one & no carry
            count += bb;
            count += N - bp - (bbAll - bb);
          } else {
            // zero & no carry or one & carry
            count += bp - bb;
            count += bbAll - bb;
          }
        }
        if (count % 2 == 1) ans |= 1 << i;
        sort(A, i);
        sort(B, i);
      }
//      if (brute != ans) {
//        System.out.println(turn);
//        System.out.println(Arrays.toString(A));
//        System.out.println(Arrays.toString(B));
//        System.out.println(brute);
//        System.out.println(ans);
//        System.exit(0);
//      }
      System.out.println(ans);
//    }
  }

  static void sort(long[] a, int k) {
    int ap = 0;
    int bp = 0;
    long bit = 1L << k;
    for (int i = 0; i < a.length; i++) {
      if ((a[i] & bit) == 0) {
        a[ap++] = a[i];
      } else {
        buf[bp++] = a[i];
      }
    }
    for (int i = 0; i < bp; i++) {
      a[ap++] = buf[i];
    }
  }

}


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




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

    vector<int>a(4);
    rep(i,4)cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
   int a,b,c;
   cin >>a;
   cin >>b;
   cin >>c;
   if(a<b&&b<c){
       cout << "Yes";
   } else {
       cout << "No";
   }
   cout << endl;
}



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

using namespace std;

int dp[(int)1e5+105];
int main()
{

    ios_base::sync_with_stdio(0);cin.tie(0);



    fill(dp, dp+(int)1e5+105 , INT_MAX );

    dp[1] = 0;
    int n,k;
    cin>>n>>k;
    vector <int> v(n+k+5,0);
    for( int i = 1; i <= n ; i++ ) {

        cin>>v[i];

    }
    for( int i = 1; i <= n ; i++ ) {
        for( int j = 1; j <= k ; j++ )
            dp[i+j] = min( dp[i]+abs(v[i+j]-v[i]) , dp[i+j] );
    }
    cout<<dp[n]<<"\n";
}


Measured memory_bytes: 1024
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()
s = set()
H = load_list()
for i in range(m):
    a, b = load_list()
    a -= 1
    b -= 1
    target = 0
    if H[a] < H[b]:
        target = a
    elif H[a] > H[b]:
        target = b
    else:
        s.add(a + 1)
        s.add(b + 1)
        continue
    s.add(target + 1)

print(n - len(s))



Measured memory_bytes: 91056
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define add(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
using namespace std;
int n,m,ee,d[N+5],lnk[N+5];struct edge {int to,nxt;}e[N<<1];
class FastIO
{
    private:
        #define FS 100000
        #define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
        #define pc(c) (C==E&&(clear(),0),*C++=c)
        #define tn (x<<3)+(x<<1)
        #define D isdigit(c=tc())
        int T;char c,*A,*B,*C,*E,FI[FS],FO[FS],S[FS];
    public:
        I FastIO() {A=B=FI,C=FO,E=FO+FS;}
        Tp I void read(Ty& x) {x=0;W(!D);W(x=tn+(c&15),D);}
        Ts I void read(Ty& x,Ar&... y) {read(x),read(y...);}
        Tp I void write(Ty x) {W(S[++T]=x%10+48,x/=10);W(T) pc(S[T--]);}
        Tp I void writeE(Con Ty& x,Con Ty& y) {write(x),pc(' '),write(y),pc('\n');}
        I void clear() {fwrite(FO,1,C-FO,stdout),C=FO;}
}F;
template<int SZ> class UnionFindSet//并查集用于找生成树时判连通性
{
    private:
        int f[SZ+5];
        I int getfa(CI x) {return f[x]?f[x]=getfa(f[x]):x;}
    public:
        I void Union(CI x,CI y) {f[getfa(x)]=getfa(y);}
        I bool Identify(CI x,CI y) {return getfa(x)==getfa(y);}
};UnionFindSet<N> U;
I void dfs(CI x,CI lst=0)//遍历树
{
    RI i;for(i=lnk[x];i;i=e[i].nxt) e[i].to^lst&&(dfs(e[i].to,x),0);//先处理子节点
    lst&&(d[x]?F.writeE(x,lst):(d[lst]^=1,F.writeE(lst,x)),0);//根据当前节点度数奇偶性确定到父节点边的方向
}
int main()
{
    RI i,x,y;if(F.read(n,m),m&1) return puts("-1"),0;
    for(i=1;i<=m;++i) F.read(x,y),U.Identify(x,y)?
        (F.writeE(x,y),d[x]^=1):(U.Union(x,y),add(x,y),add(y,x));//生成树上边在树上连边，非树边随便定方向
    return dfs(1),F.clear(),0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  for (int i=0;i<n;i++){
    cin >> s[i];
  }
  bool f=false;
  for (int i=0;i<n;i++){
    if(s[i]=='Y'){
      f=true;
    }
  }
  if(f){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (countBlack, pointBlack) = readLine()!!.split(" ").map { it.toInt() }
    val (min, max) = Pair((pointBlack - countBlack + 1), (pointBlack + countBlack - 1))

    val sb = StringBuilder()
    for (i in min..max){
        sb.append("$i ")
    }

    println(sb.dropLast(1))
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n; cin >> n;
    if (n == 0) return;
    vector<set<int>> v(n);
    rep(i, n) {
      int m; cin >> m;
      rep(j, m) {
        int p; cin >> p;
        v[i].insert(p);
      }
    }
    int k; cin >> k;
    set<int> l;
    rep(i, k) {
      int s; cin >> s;
      l.insert(s);
    }
    int ans = -1;
    rep(i, n) {
      bool f = true;
      each(e, l) {
        if (!v[i].count(e)) f = false;
      }
      if (f) {
        if (ans != -1) { ans = -1; break; }
        else ans = i + 1;
      }
    }
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3604
S = input()
if S == "SUN":
        print(7)
if S == "MON":
        print(6)
if S == "TUE":
        print(5)
if S == "WED":
        print(4)
if S == "THU":
        print(3)
if S == "FRI":
        print(2)
if S == "SAT":
        print(1)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


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

#define MOD 1000000007
#define AB 2000
#define AB2 4001
#define N 200005

typedef struct set {
	int a;
	int b;
} set;

int main(){
	int i,j;
	long long int ii,jj,rii,rjj;
	int n;
	int a,b;
	long long int **dp;
	long long int **root;
	long long int res = 0;
	set s[N];
	dp = calloc(sizeof(long long int*),AB2);
	for(i = 0;i < AB2;i++){
		dp[i] = calloc(sizeof(long long int),AB2);
	}
	root = calloc(sizeof(long long int*),AB2);
	for(i = 0;i < AB2;i++){
		root[i] = calloc(sizeof(long long int),AB2);
	}
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d %d",&a,&b);
		s[i].a = a;
		s[i].b = b;
		root[AB - a][AB - b]++;
	}
	dp[0][0] = 1;
	for(i = 0;i < AB2;i++){
		for(j = 0;j < AB2;j++){
			ii = (i == 0 ? 0 : dp[i - 1][j]);
			jj = (j == 0 ? 0 : dp[i][j - 1]);
			rii = (i == 0 ? 0 : root[i - 1][j]);
			rjj = (j == 0 ? 0 : root[i][j - 1]);
			dp[i][j] += (ii + jj);
			dp[i][j] %= MOD;
			root[i][j] += (rii + rjj);
			root[i][j] %= MOD;
		}
	}
	for(i = 0;i < n;i++){
		res += root[AB + s[i].a][AB + s[i].b];
		res %= MOD;
		res += MOD - dp[s[i].a*2][s[i].b*2];
		res %= MOD;
	}
	printf("%lld\n", res % 2 == 0 ? res / 2 : (res + MOD) / 2);
	return 0;
}

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

int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans;
  if(a % x) ans = b/x - a/x;
  else ans = b/x - a/x + 1;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"container/heap"
	"fmt"
	"bufio"
	"os"
	"strconv"
)

type IntHeap []int

func (h IntHeap) Len() int {
	return len(h)
}

func (h IntHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h IntHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0:n-1]
	return x
}

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

	h := &IntHeap{}
	heap.Init(h)

	LOOP:
	for {
		scanner.Scan()
		switch scanner.Text() {
		case "end":
			break LOOP
		case "insert":
			scanner.Scan()
			element, _ := strconv.Atoi(scanner.Text())
			heap.Push(h, element)
		case "extract":
			fmt.Printf("%d\n", heap.Pop(h))
		default:
			panic("No such operation.")
		}
	}
}


Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    // f(n) = n * f(n - 2)
    // f(12) = 12 * 10 * 8 * 6 * 4 * 2 -> 1
    // f(9) = 9 * 7 * 5 * 3 * 1 -> 0

    // 奇数のときは末尾に0はつかない
    if(n % 2) {
        cout << 0 << endl;
        return 0;
    }

    // nに5が何個含まれるかが答えになる
    // 偶数列なので、2の成分は無限にあり、それと組み合わせて10を作れるため
    // このとき、-2してった値を全部見る必要はない
    // 例えば50/2/5=5なので0~50の値で5を含むものの個数がわかるため
    n /= 2; // 最初に割っておくのはf(n - 2)の部分をn-1と読み替えるためか？
    int64_t ans = 0;
    while(n > 0) {
        ans += (n /= 5);
        // cout << n << " " << ans << endl;
    }

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

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

int main(){
    long int N;
    cin>>N;
    
    long int ans=0;
    for(long int i=1;i<=N;i++){
        long int count=0;
        for(int j=i;j>0;j/=10){
           count+=1;
        }
        if(count%2==1)ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i, n){
    int t;
    cin >> t;
    t--;
    p[i] = t;
  }

  vector<int> idx(n);
  REP(i, n) idx[p[i]] = i;

  set<int> s;
  ll ans = 0;
  FORr(x, n-1, -1){
    int i = idx[x];
    
    ll c = 0;
    s.insert(i);
    vector<int> l(2,-1);
    vector<int> r(2, n);
    auto itr = s.find(i);
    REP(j, 2){
      if(itr == s.begin()) break;
      itr--;
      l[j] = *itr;
    }
    itr = s.find(i);
    REP(j, 2){
      itr++;
      if(itr == s.end()) break;
      r[j] = *itr;
    }
    vector<int> ls(2), rs(2);
    ls[0] = i-l[0];
    ls[1] = l[0]-l[1];
    rs[0] = r[0]-i;
    rs[1] = r[1]-r[0];
    c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];

    ans += c*(x+1);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
	ll n,k; cin >> n >> k;
	vl h(n); rep(i,n)cin >> h[i];
	sort(h.begin(), h.end());
	ll d = h[k-1] -h[0];
	rep(i,n-k+1)d = min(d , h[i+k-1] - h[i]);
	cout << d << endl;
}

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

int main() {
	int k;
	string s;
	string ans;
	cin >> k >> s;
	int n= s.size();
	if (n <= k) {
		cout << s;
		return 0;
	}
	else {
		rep(i, k) {
			ans += s[i];
		}
	}
	ans += "...";
	cout << ans;
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0,ans=min(a,b);
	while (cnt<c)
	{
		if (a%ans==0&&b%ans==0)
		{
			++cnt;
		}
		--ans;
	}
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 256
s = [int(i) for i in input().split()]
if (s[0] == 0 or s[0] == 1):
  s0 = 0
else:
  s0 = s[0]*(s[0]-1)/2
if (s[1] == 0 or s[1]==1):
  s1 = 0
else:
  s1 = s[1]*(s[1]-1)/2

print(int(s0+s1))

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    for (;;) {
        C = C - B;
        if (C <= 0) {
            goto yes;
        }
        A = A - D;
        if (A <= 0) {
            goto no;
        }
    }
yes:
    cout << "Yes" << endl;
    return 0;
no:
    cout << "No" << endl;
    return 0;
}

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

n, W = [int(x) for x in input().split()]
wv = [[int(x) for x in input().split()] for _ in range(n)]

dp = [[0] * (W + 1) for _ in range(n + 1)]

for i in range(1, n + 1):
    w, v = wv[i - 1]
    for j in range(W + 1):
        if j - w >= 0:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[-1][-1])

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

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;



int main(){
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h; i++) {
			for (int i = 0; i < w; i++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3092
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
int main()
{
    int a ,nowa ,sum=0;
    scanf("%d",&a);
    nowa = a;
    while(nowa)
    {
        sum += nowa%10;
        nowa /= 10;
    }
    printf(a%sum==0 ? "Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc103/tasks/abc103_c
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
#list
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n=ii()
arr=limii()
p=lcm(arr)-1

ans=0
for i in range(n):
    ans+=p%arr[i]
print(ans)


Measured memory_bytes: 66152
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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 s;
	cin >> s;
	set<int>st;
	int x = s;
	while (st.count(x) == 0) {
		st.insert(x);
		if (x % 2 == 0) {
			x /= 2;
		}
		else {
			x = x * 3 + 1;
		}
	}
	cout << (st.size() + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize, M : usize,
        LR : [(usize, usize); M]
    }

    let (mut li, mut ri) = (0usize, usize::max_value());
    for t in &LR {
        li = max(li, t.0);
        ri = min(ri, t.1);
    }
    if ri < li {
        println!("0");
    }
    else {
        println!("{}", ri - li + 1);
    }
}


Measured memory_bytes: 6396
import numpy as np

N, K = map(int, input().split())
a = []
b = []
for i in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
    
c = np.argsort(a)
ans = 0
for i in range(N):
    ans += b[c[i]]
    if ans >= K:
        print(a[c[i]])
        break

Measured memory_bytes: 21636
s = input()
gu = ['R','U','D']
ki = ['L','U','D']
bad = False
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in gu:
            bad = True
    else:
        if s[i] not in ki:
            bad = True
if bad:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool pallin(string s)
{
  for(int i=0;i<s.size()/2;i++)
    if(s[i]!=s[s.size()-i-1])
       return false;
  return true;
}

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

  if(pallin(s)&&pallin(s.substr(0,(s.size()-1)/2)))
     cout<<"Yes"<<endl;
   else
     cout<<"No"<<endl;
}




Measured memory_bytes: 256
# -*- coding : utf-8 -*-
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

even = [] #偶数番目のリスト
odd = [] #奇数番目のリスト

#偶数番目、奇数番目のリストを作成
for i in range(n):
    if i % 2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])

 #頻出順に並び替え
even_most = Counter(even).most_common()
odd_most = Counter(odd).most_common()

#頻出する数字が同じ場合
if even_most[0][0] == odd_most[0][0]:
    if len(even_most) == 1:
        if len(odd_most) == 1:
            ans = n / 2
        else:
            ans = n - even_most[0][1] - odd_most[1][1]
    elif len(odd_most) == 1:
            ans = n - even_most[1][1] - odd_most[0][1]
    else:
        ans = n - max(even_most[0][1] + odd_most[1][1], even_most[1][1] + odd_most[0][1])

#それ以外の場合（頻出する数字が同じでない場合）
else:
    ans = n - even_most[0][1] - odd_most[0][1]

print(int(ans))


Measured memory_bytes: 21076
//abc 158:A

     #include <bits/stdc++.h>
     #include <cstdio>
     #include <cstring>
     #include <cmath>
     #include <cstring>
     #include <chrono>
     #include <complex>
     #define endl "\n"
     #define ll long long int
     #define vi vector<int>
     #define vll vector<ll>
     #define vvi vector < vi >
     #define pii pair<int,int>
     #define pll pair<long long, long long>
     #define mod 1000000007
     #define inf 1000000000000000001;
     #define all(c) c.begin(),c.end()
     #define mp(x,y) make_pair(x,y)
     #define mem(a,val) memset(a,val,sizeof(a))
     #define eb emplace_back
     #define f first
     #define s second

     using namespace std;
     int reverse1(string s)
     {
         string s1=s;
        reverse(s1.begin(),s1.end());
        int f=0;
        for(int i=0;i<s.length();i++)
        {

            if(s[i]!=s1[i])
            {
              return 0;
            }
        }
        return 1;
     }
     int main()
     {
         std::ios::sync_with_stdio(false);
        string s;
        cin>>s;
        string s1=s;
        reverse(s1.begin(),s1.end());
        int f=0;
        for(int i=0;i<s.length();i++)
        {

            if(s[i]!=s1[i])
            {
                f=1;
                break;
            }
        }
        if(f)
        {
            cout<<"No"<<endl;
            return 0;
        }

        f=0;
        string s2="",s3="";

        int n=s.length();
        int index=(n-1)/2;
        int index1=(n+3)/2;
        for(int i=0;i<index;i++)
            s2+=s[i];
        for(int i=index1-1;i<n;i++)
        {
            s3+=s[i];
        }
        if(reverse1(s2) && reverse1(s3))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
         return 0;
     }


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

ans = 0
(1 .. N - 1).each do |c|
   x = 0
   l, r = 0, N - 1
   if (N - 1) % c == 0
     while l < r
       x += Ss[l] + Ss[r]
       ans = [ans, x].max
       l += c
       r -= c
     end
   else
     while l + c < N - 1
       x += Ss[l] + Ss[r]
       ans = [ans, x].max
       l += c
       r -= c
     end
   end
 end
 puts ans

Measured memory_bytes: 11140
route = {"a" => ["x", "y"], "x" => ["s", "z"], "y" => ["x", "s"], "z" => ["w", "b"], "w" => ["b", "y"], "b" => ["y", "x"], "s" => ["s", "s"]}
while line = gets
    line = line.chomp
    break if line == "#"
    city = "a"
    line.split("").map(&:to_i).each{|x| city = route[city][x]}
    puts city == "b" ? "Yes" : "No"
end



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

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

    int a, b;
    cin >> a >> b;
    if (max(a, b) == 2)
        cout << 3 << endl;
    else if (min(a, b) == 2)
        cout << 1 << endl;
    else
        cout << 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	long long n,a,b;cin>>n>>a>>b;
	long long ans;
	if((b-a)%2==0)
		ans=(b-a)/2;
	else if(a-1<n-b)
		ans=(a+b-1)/2;
	else
		ans=n+(1-a-b)/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
ll anslen = 1e15;
const int N = 4005;
void solve()
{

    ll i, j, n;
    vector<string> ss(3);
    std::vector<int> v {0, 1, 2};
    rep(i, 3)
    cin >> ss[i];
    auto ok = [](const string & a, const string & b, int j)
    {
        rep(i, b.size())
        {
            if(i + j < a.size() and a[i + j] != '?' and b[i] != '?' and a[i + j] != b[i])
                return 0;

        }
        return 1;

    };

    do
    {
        // cout<<"1";
        string a[3];
        rep(i, 3) a[i] = ss[v[i]];

        std::vector<bool> x(N);
        rep(i, N) x[i] = ok(a[0], a[1], i);

        std::vector<bool> y(N);
        rep(i, N) y[i] = ok(a[0], a[2], i);

        std::vector<bool> z(N);
        rep(i, N) z[i] = ok(a[1], a[2], i);

        rep(i, N)
        if(x[i])
            for(ll j = i; j < N; j++)
                if(y[j] and z[j - i])
                    anslen = min(anslen, max({si(a[0]), si(a[1]) + i, si(a[2]) + j}));

    }
    while(next_permutation(all(v)));


    cout << anslen;
}

int main()
{



    // ios_base::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        // cout << endl;
    }


}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val a = readLine()!!.groupBy { it }.values.map { it.size.toLong() }.toLongArray()
    var ans = 1L
    for (i in a.indices) {
        for (j in 0 until i) {
            ans += a[i] * a[j]
        }
    }
    println(ans)
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) 
    cin >> a.at(i);
    vector<int> b(n);
    for(int i = 0; i < n; i++) 
    b.at(a.at(i)-1) = i+1; 
    for(int i : b) cout << i << endl;
}

Measured memory_bytes: 1664
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int A,B;
  	cin>>A>>B;
  	cout<<(A+B)%24<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

s = 0

b = [abs(x) for x in a]

c = 0
for x in a:
    if x < 0:
        c += 1

if c % 2 == 0:
    s = sum(b)
else:
    s = sum(b) - 2 * min(b)

print(s)

Measured memory_bytes: 85120
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int i,j,k;
  int mat[100][100]={{}};
  int ve[100]={};
  cin >> n >> m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> mat[i][j];
    }
  }
  for(j=0;j<m;j++) cin >> ve[j];
  for(i=0;i<n;i++){
    int x=0;
    for(j=0;j<m;j++) x+=mat[i][j]*ve[j];
    cout << x << endl;
  }

  return 0;
}



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

using namespace std;

int main(){
	long long H, N;
	scanf("%lld %lld", &H, &N);
	long long sum = 0;
	while(N--) {
		long long aux;
		scanf("%lld", &aux);
		sum += aux;
	}
	if (H <= sum) {
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

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

template<typename T> T gcd(T x, T y) { if (!x) return y; return gcd(y % x, x); }
template<typename T> T lcm(T x, T y) { return x / gcd(x, y) * y; }

using ll = long long;

constexpr int MAX_N = 100;


int main() {
  ll ans{1};
  int N; cin >> N;
  for (int i{}; i < N; ++i) {
    ll T;
    cin >> T;
    ans = lcm(ans, T);
  }

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


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a+=[None]
ans=0
if n==1:print(1);exit()
r=0
check=a[0]
for i in range(n):
  if r==n-1:
    ans+=(r-i+1)*(r-i+2)//2
    break
  for j in range(r+1,n+1):
    if j==n:
      ans+=j-i
      r=j-1
      break
    if check^a[j]==check+a[j]:
      check+=a[j]
    else:
      ans+=j-i
      r=j-1
      break
  check^=a[i]
print(ans)

Measured memory_bytes: 24584
/*
.....   .   .   .   .
  .    . .   . .   . .
  .   .....   .   .....
  .  .     .  .  .     .
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
   
using namespace std;
   
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
   
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}



#define left left228
#define right right228
#define set set228


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    long long res = 0;
    reverse(s.begin(), s.end());
    int W = 0;
    for (char c : s) {
        if (c == 'W') {
            ++W;
        } else {
            res += W;
        }
    }
    cout << res << '\n';
    return 0;
}
  
  
  
  

Measured memory_bytes: 720
#include <stdio.h>
int gcd(int x,int y)
{
	if(y==0)
		return x;
	else
		return gcd(y,x%y);
}
int main()
{
	int x,y;
	while(scanf("%d %d",&x,&y) != EOF)
		printf("%d %d\n",gcd(x,y),x/gcd(x,y)*y);
	return 0;
}

Measured memory_bytes: 596
N=int(input())
aList=sorted(list(map(int,input().split())))[::-1]

Alice=0
Bob=0

for i in range(1,N+1):
  if i%2 == 1:
    Alice+= aList[i-1]
  else :
    Bob+= aList[i-1]

print(Alice-Bob)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define x first
#define y second
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define SZ(x) int(x.size())
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b-1; i >= a; i--)
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define ll long long
#define inf 1000000007
#define mod 1000000007
#define N 100005

template<typename U, typename V> void Min(U &a, const V & b){if(a > b)a = b;}
template<typename U, typename V> void Max(U &a, const V & b){if(a < b)a = b;}
template<typename U, typename V> void add(U &a, const V & b){a = (a + b) % mod;}
template<typename U> U gcd(U a, U b){
    if(a == 0)return b;
    if(b == 0)return a;
    if(a >= b)return gcd(a % b, b);
    else return gcd(a, b % a);
}
int pow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1)ans = 1LL * ans * a % mod;
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return ans;
}

int co[505][505];
int main(){
    int T, m, n, i, j, k, K;
    scanf("%d", &n);
    k = 1;
    while((1<<k) < n)k++;
    DBG(k)
    rep(i, 0, n){
        rep(j, i+1, n){
            rep(l, 0, k)if((i >> l & 1) != (j >> l & 1)){
                printf("%d ", l+1);
                break;
            }
        }
        puts("");
    }
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s[100000 + 1];
int n;

int main(void) {
  scanf("%s", s);
  n = strlen(s);
  int ans = 0, l = 0, r = n - 1;
  while (l < r) {
    if (s[l] == s[r]) {
      ++l;
      --r;
    } else if (s[l] == 'x') {
      ++l;
      ++ans;
    } else if (s[r] == 'x') {
      --r;
      ++ans;
    } else {
      puts("-1");
      return 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  bool ans = false;
  for(int i7=0;i7*7<=N;i7++){
    if((N-i7*7)%4==0) ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {	
	Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	
	public Main(){		
		new AOJ1103();
	}
	
	class AOJ1103{
		Relative relative[];
		public AOJ1103() {
			while(true){
				relative = new Relative[4];
				boolean sw=false;
				for(int i=0;i<4;i++){
					int a = in.nextInt();
					if(a>=4){
						sw=true;break;
					}
					int b = in.nextInt();
					relative[i]=new Relative(a,b);
				}
				if(sw)break;
				int[][] map = new int[4][4];for(int i=0;i<4;i++)Arrays.fill(map[i],-1);
				System.out.println(bfs(map,0));
			}
		}
		void print(int[][] map){
			for(int i=0;i<4;i++){
				for(int s=0;s<4;s++)System.out.print(map[i][s]+" ");
				System.out.println();
			}
		}
		
		int bfs(int[][] map,int num){
			
//			System.out.println(num);
//			print(map);
//			System.out.println();
			
			int result = 0;
			if(num>=7){
				boolean sw = true;
				for(int i=0;i<4;i++)for(int s=0;s<4;s++)if(map[s][i]==-1)sw=false;
				if(sw)return 1;
			}else if(num>=7)return 0;
			int x=0,y=0;
			for(y=0;y<4;y++){//一番目に置くカードの位置
				boolean sw=true;
				for(x=0;x<4;x++)if(map[y][x]==-1){
					sw=false;
					break;
				}
				if(!sw)break;
			}
			
			for(int i=0;i<4;i++){//二枚目に置くカードの位置
				int nx = x+relative[i].x;
				int ny = y+relative[i].y;//もう片方の数字
				if(nx<0||nx>=4||ny<0||ny>=4)continue;
				if(map[ny][nx]!=-1)continue;
				map[ny][nx]=map[y][x]=num;
				result+=bfs(map,num+1);
//				if(bfs(map, num+1)==1){
//					System.out.println(num);
//					print(map);
//					System.out.println();
//				}
				map[ny][nx]=map[y][x]=-1;
			}
			return result;
		}
		
		class Relative{
			int x,y;
			public Relative(int x,int y) {
				this.x = x;
				this.y = y;
			}
		}
	}
	
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    if (s == "SUN") cout << 7 << '\n';
    if (s == "MON") cout << 6 << '\n';
    if (s == "TUE") cout << 5 << '\n';
    if (s == "WED") cout << 4 << '\n';
    if (s == "THU") cout << 3 << '\n';
    if (s == "FRI") cout << 2 << '\n';
    if (s == "SAT") cout << 1 << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n;
ll a[300005];
P mx[1<<18];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++){
		scanf("%lld",&a[i]);
	}
	for(int j=0;j<(1<<n);j++){
		int k=j;
		do{
			//printf("%d %d\n",j,k);
			if(mx[j].first<=a[k]){
				mx[j].second=mx[j].first;
				mx[j].first=a[k];
			}else if(mx[j].second<=a[k]){
				mx[j].second=a[k];
			}
			k=(k-1)&j;
		}while(k!=j);
	}
	ll ma=0;
	for(int i=1;i<(1<<n);i++){
		printf("%lld\n",max(ma,mx[i].first+mx[i].second));
		ma=max(ma,mx[i].first+mx[i].second);
	}
	return 0;
}

Measured memory_bytes: 9216
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	vector<int>ns(N);
	for (int i = 0; i < N; ++i)cin >> ns[i];
	vector<int>sums(N,1);
	vector<int>vs;
	int from = -1;
	int num = 0;
	for (int i = 0; i < N; ++i) {
		if (from == -1) {
			num = 1;
		}
		else {
			if (from != ns[i]) {
				num++;
			}
			else {
				vs.push_back(num);
				num = 1;
			}
		}
		from = ns[i];
	}
	if (num)vs.push_back(num);
	accumulate(vs.begin(), vs.end(), 0);
	if (vs.size() <= 2) {
		cout << accumulate(vs.begin(), vs.end(), 0) << endl;
	}
	else {
		int ans = 0;
		
		for (int i = 0; i < vs.size() - 2; ++i) {
			ans = max(ans, accumulate(vs.begin() + i, vs.begin() + i + 3, 0));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3976