akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], ok[12345678];
signed main() {
	ll n, m, q, k = 1, a = 1, b = 0, c = 0, d = 0, keta = 0, ans = 0; string s = "";
	cin >> n;
	while (true) {
		b = pow(26, a); a++; d += b;
		if (d >= n) { break; }
		c = b; //cout << d << endl;
		test[k] = c; ok[k] = d; k++;
	}
	test[0] = 1; ok[0] = 0;
	for (int h = k - 1; h >= 0; h--) {
		ll z = 96;
		while (n >= test[h]) {
			if (z == 122) { break; }
			if (h != 0 && n - test[h] <= ok[h - 1]) { break; }
			n -= test[h]; z++;
		}
		//cout << n << ' ' << test[h] << endl;
		s.push_back((char)z);
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const double EPS = 1e-9;
const int N = 1000000;

template <class T> T gcd(T a, T b) {
	if (b == 0) { return a; }
	return gcd(b, a % b);
}

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}



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

	int n, m;
	unordered_map<int, int> mp;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> m;
		++mp[m];
	}

	int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		if ((it->second) & 1) ++ans;
	}

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


Measured memory_bytes: 7228
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define forn(i,a,b) for (int i = a; i <= b; i ++ )
#define mod(n,k) (((n%k)+k)%k)
using namespace std;
typedef long long ll;

ll N, cnt[MAX], x;

int main()
{
    optimiza_io
    cin >> N;
    forn( i , 2 , N ) {
        cin >> x;
        cnt[x]++;
    }
    forn( i , 1 , N )
        cout << cnt[i] << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 5108
import Data.List

cnv _ [] = []
cnv m (n:t:r) = (m, n',t):(cnv (m+1) r)
    where
        n' = read n :: Int

srt :: (Int,Int,String) -> [(Int,Int,String)] -> [String]
srt d@(m,n,s) ds =
    let cs= filter (\ (_,n1,_) -> m == n1) ds
        o = filter (\ (_,n1,_) -> m /= n1) ds
        a = map (\ c -> srt c o) cs
        r = map (\ ss -> ('.':ss)) $ concat a
    in
        (s:r)

cmp (m1,n1,s1) (m2,n2,s2) = if cn /= EQ then cn else cm
    where
        cn = compare n1 n2
        cm = compare m1 m2

ans c =
    let l = lines c
        (d:ds) = sortBy cmp $ cnv 1 l
        s = srt d ds
    in
        s

main = do
    _ <- getLine
    c <- getContents
    let o = ans c
    mapM_ putStrLn o 


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
   ld w, h, x, y;
   cin >> w >> h >> x >> y;

	cout << (w * h / 2) << " ";
   
   if ((w == 2 * x) and (h == 2 * y)) {
   		COUT(1);
   }
   else {
   		COUT(0);
	}
}

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


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

vector<ll> factors;
vector<ll> factors1;


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    vector<ll> A(n);
    // n = 100000;
    // REP(i, n) {
    //     A.pb(1000000000);
    // }
    REP(i, n) cin >> A[i];
    sort(all(A));
    factors.pb(1);
    factors.pb(A[0]);
    factors1.pb(1);
    factors1.pb(A[1]);
    for (int i = 2; i < sqrt(A[0]) + 2; i++) {
        if (A[0] % i == 0) {
            factors.pb(i);
            factors.pb(A[0] / i);
        }
    }
    for (int i = 2; i < sqrt(A[1]) + 2; i++) {
        if (A[1] % i == 0) {
            factors1.pb(i);
            factors1.pb(A[1] / i);
        }
    }
    int ans = 1;
    REP(i, SZ(factors)) {
        int ccc = 0;
        FOR(j, 1, n-1) {
            if (A[j] % factors[i]) {
                ccc++;
                if (ccc > 1) {
                    break;
                }
            }
        }
        if (ccc < 2 && factors[i] > ans) ans = factors[i];
    }
    REP(i, SZ(factors1)) {
        int ccc = 0;
        FOR(j, 0, n-1) {
            if (j == 1) continue;
            if (A[j] % factors1[i]) {
                ccc++;
                if (ccc > 1) {
                    break;
                }
            }
        }
        if (ccc < 2 && factors1[i] > ans) ans = factors1[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() { // Yes / No
    input! {
        n: usize, m: usize,
        lrd: [(Usize1, Usize1, i64); m]
    }

    let mut graph = vec![Vec::new(); n];
    for (l, r, d) in lrd {
        graph[l].push((r, d));
        graph[r].push((l, -d));
    }

    let mut rel = vec![None; n];
    let mut que = VecDeque::new();
    for i in 0..n {
        if graph[i].is_empty() {
            continue;
        }
        rel[i] = Some(0);
        while let Some((next, d)) = graph[i].pop() {
            que.push_back((i, next, d));
        }
        while let Some((now, next, d)) = que.pop_front() {
            let base = rel[now].unwrap();
            if let Some(dist) = rel[next] {
                if dist != base + d {
                    println!("No");
                    return;
                }
            } else {
                rel[next] = Some(base + d);
                while let Some((next2, d2)) = graph[next].pop() {
                    que.push_back((next, next2, d2));
                }
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 30700
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  lld k, a, b;
  cin >> k >> a >> b;
  if (b - a >= k - 1 || b / k > a / k || a % k == 0 || b % k == 0) {
    cout << "OK\n";
  } else {
    cout << "NG\n";
  }
}


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

int main(){
  int n;
  cin >> n; 
  int a[n];

  for(int i=0;i<n;i++){
    cin >> a[i];   }
  for(int i=n-1;i>=1;i--){
    cout << a[i] << " " ;
    }
  cout << a[0] << endl;
  return 0;
  }    



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

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt();
        int[] l=new int[n];
        for(int i=0;i<n;i++){
            l[i]=sc.nextInt();
        }
        sc.close();
        Arrays.sort(l);
        int len=0;
        for(int i=0;i<k;i++){
            len+=l[n-i-1];
        }
        System.out.println(len);
    }
    
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  string S;
  cin >> S;

  vector<vll> alpha(26);
  rep(i, S.size()) {
    ll index = S[i] - 'a';
    alpha[index].pb(i);
  }

  ll Q;
  cin >> Q;

  rep(i, Q) {
    int type;
    cin >> type;
    // scanf("%d", &type);
    if (type == 1) {
      ll a;
      // char bb[10];
      char b;
      cin >> a >> b;
      // scanf("%lld", &a);
      --a;
      // scanf("%s", bb);
      // char b = bb[0];

      if (b == S[a]) {
        continue;
      }

      // --
      ll index = S[a] - 'a';
      alpha[index].erase(find(ALL(alpha[index]), a));

      S[a] = b;

      // ++
      auto lb = lower_bound(ALL(alpha[b - 'a']), a);
      alpha[b - 'a'].insert(lb, a);
    } else {
      int a, b;
      cin >> a >> b;
      // scanf("%d %d", &a, &b);
      --a;
      --b;
      ll ans = 0;
      rep(i, alpha.size()) {
        if (alpha[i].size() == 0) continue;
        ll lb = lower_bound(ALL(alpha[i]), a) - alpha[i].begin();
        ll ub = upper_bound(ALL(alpha[i]), b) - alpha[i].begin();
        if (lb <= (ll)alpha[i].size() - 1 && lb != ub) {
          ans++;
        }
      }
      ANS;
      // printf("%lld\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 10076
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll mod = 1000000007;

ll modpowl(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = modpowl((a*a) % mod, b / 2);
			c = c % mod;

			return c;
		}
		else {
			ll c = (modpowl((a*a) % mod, b / 2) % mod)*a;
			c = c % mod;

			return c;
		}
	}
}
ll llpow(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = llpow((a*a), b / 2);
			c = c;

			return c;
		}
		else {
			ll c = (llpow((a*a), b / 2))*a;
			c = c;

			return c;
		}
	}
}
std::vector<ll> Eratosthenes(ll N)
{
	std::vector<bool> is_prime(N + 1);
	for (ll i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<ll> P;
	for (ll i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (ll j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

int main() {
	cout.precision(20);
	ll N, M;
	cin >> N >> M;
	vector<string>S(M);
	vector<ll>p(M);
	vector<int>check(N + 1, 0);
	vector<ll>wa(N + 1, 0);
	rep(M) {
		cin >> p[i] >> S[i];
		if (S[i] == "AC") {
			check[p[i]] = 1;
		}
		else {
			if (check[p[i]] == 0) {
				wa[p[i]]++;
			}
		}
	}
	ll ac = 0;
	ll pe = 0;
	rep(N) {
		ac += check[i + 1];
		if (check[i + 1] > 0)
			pe += wa[i + 1];
	}
	cout << ac <<" "<< pe;
}

Measured memory_bytes: 7680
# -*- coding: utf-8 -*-
#AGC029A https://atcoder.jp/contests/cf17-final-open/tasks/cf17_final_a
import sys
#import collections

#n= int(input())
#s= input()
#tmp = input().split()
#n,m = list(map(lambda a: int(a), tmp))
s= input()

t=["AKIHABARA",
"AKIHABAR",
"AKIHABRA",
"AKIHABR",
"AKIHBARA",
"AKIHBAR",
"AKIHBRA",
"AKIHBR",
"KIHABARA",
"KIHABAR",
"KIHABRA",
"KIHABR",
"KIHBARA",
"KIHBAR",
"KIHBRA",
"KIHBR"]

for i in range(len(t)):
	if(t[i]==s):
		print("YES")
		sys.exit()
print("NO")

#print(t[0])
#print(t[1])

Measured memory_bytes: 3060
n = input()
op = len(n) - 1  # すきまの数
result = ""
for i in range(2**op):
    op_list = ['-']*op  # -で初期化しておく
    for j in range(op):
        if (i >> j) & 1:
            op_list[2-j] = '+'  # フラグが立ってるところだけ＋にする
    result = n[0] + op_list[0] + n[1] + op_list[1] + n[2] + op_list[2] + n[3]
    if eval(result) == 7:
        print(result + "=7")
        break



Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    int d,x; cin>>d>>x;
    rep(i,n){
        int a; cin>>a;
        if(a==1) x+=d;
        else x+=(d+a-1)/a;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 3652
import java.io.IOException;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		
		Scanner sc = new Scanner(System.in);
		int k =  Integer.parseInt(sc.next());
		int n =  Integer.parseInt(sc.next());
		int[] A  = new int[n];
		
		int m = 0;
		for(int i = 0 ; i < n ; i++ ) {
			A[i] =  Integer.parseInt(sc.next());
		}
		
		for(int i = 0 ; i < n -1 ; i++ ) {
			m = Math.max(m, A[i+1] - A[i]);
		}
		
		m = Math.max(m, (k - A[n-1]) + A[0]);
		
		System.out.println(k - m);
		
		
		}
}

Measured memory_bytes: 60292
n, p = map(int,input().split())
num = list(map(int,input().split()))

semua_angka_genap = True
for i in num:
  if i % 2 == 1:
    semua_angka_genap = False

if semua_angka_genap:
  if p == 0:
    print(2**n)
  else:
    print(0)

else:
  print(2**(n-1))

Measured memory_bytes: 61824
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
s=str(input())
ans=0

cb=0
for i in range(len(s)):
    if(s[i]=='W'):
        ans+=cb
    else:
        cb+=1

print(ans)
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3500
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  vint h(n+1);
  rep(i,n){
    cin>>h[i+1];
  }
  vint dp(n+5,INF);
  dp[1]=0;
  REP(i,1,n+1){
    REP(j,1,k+1){
      if(i-j<=0){
        break;
      }
      chmin(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
  }
  cout<<dp[n]<<'\n';
  return(0);
}

Measured memory_bytes: 3976
/*
 * Author: OldY
 * Created Time:  2011/8/31 16:30:04
 * File Name: E.cpp
 */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const int maxint = -1u>>1;
const double pi = acos(-1.0);
typedef long long lint;

const int maxn = 10000 + 10;

int n,m,r;
vector <int> point[maxn];
int cirx[10*maxn] , ciry[10*maxn];
int tmpx,tmpy;
lint ans;
int top,y,nowx,nowy;

int find(const int & x , const int & i){
    int sz = point[i].size();
    int l = 0 , r = sz - 1 , mid;
    while(l <= r){
        mid = ((l+r) >> 1);
        if(mid < 0 || mid >= sz) break;
        if(point[i][mid] <= x)
            l = mid + 1;
        else r = mid - 1;
    }
    return l - 1;
}

int main() {
    while(scanf("%d%d%d",&n,&m,&r)){
        if(n == 0 && m == 0) break;
        ans = 0;
        top = 16*r*r;
        for(int i = 0 ; i < maxn ; i++)
            point[i].clear();
        for(int i = 0 ; i < n ; i++)
            scanf("%d%d",cirx+i,ciry+i);
        for(int i = 0 ; i < m ; i++){
            scanf("%d%d",&tmpx,&tmpy);
            point[tmpx].push_back(tmpy);
        }
        for(int i = 0 ; i < 10000 ; i++)
            sort(point[i].begin() , point[i].end());
        for(int i = 0 ; i < n ; i++){
            y = 0;
            for(int x = 4*r ; x >= 0 ; x--){
                while(x*x+y*y <= top) y++;
                y--;
                nowx = cirx[i] - x;
                if(nowx >= 0){
                    ans += find(ciry[i]+y,nowx) - find(ciry[i]-y-1, nowx);
                }
                if(x == 0) break;
                nowx = cirx[i] + x;
                if(nowx < 10000){
                    ans += find(ciry[i]+y,nowx) - find(ciry[i]-y-1 , nowx);
                }
            }
        }
        printf("%lld\n",ans);
    }   
    return 0;
}

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

int main()
{
     long long n,k;
    cin>>n>>k;
    vector<long long>v(n);

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

    sort(v.begin(),v.begin()+n);
    if(k>=n){
        cout<<0<<endl;
    }
    else{
        for(int i=0;i<n-k;i++){
            cnt+=v[i];
        }
        cout<<cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,ll> ii; 
typedef pair <ii,int> iii;
 
const int inf = 0x3F3F3F3F;
const ull mod = 998244353;

void solve(){
	int n, atual = 1, qt = 0,x;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x;
		if(x == atual)atual++, qt++;
	}
	if(qt == 0)cout << -1 << endl;
	else cout << n-qt << endl;
}

int main(){
	fastio;
	solve();
	return 0;
}


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

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

	cout << r*r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,m;cin>>n>>m;
    ll x[n+1];rep(i,1,n)cin>>x[i];
    ll y[m+1];rep(i,1,m)cin>>y[i];
    ll xsum=0,ysum=0;
    rep(i,1,n)xsum=mod(xsum+(x[i]*(2*i-n-1)));
    rep(i,1,m)ysum=mod(ysum+(y[i]*(2*i-m-1)));
    cout<<mod(xsum*ysum)<<endl;
    
    return 0;
}





Measured memory_bytes: 5104
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> list = new LinkedHashSet<String>();

        for (int i = 0; i < N; i++) {
            String a = sc.next();
            list.add(a);
        }
        System.out.println(list.size());
    }
}

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

int main(){
    int N, K;  cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    for(int i=1; i<N; i++) dp[i] = 1e9;

    for(int i=1; i<N; i++){
        for(int j=1; j<=min(K,i); j++){
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1e18;

const int N = 2000;
vector<int> conns[N];
string str;

ll dp_min[N];
ll dp_max[N];
int count[N];

ll recDP(int i, int p = -1) {
	dp_min[i] = 0;
	dp_max[i] = 0;
	count[i] = 0;
	for (auto t : conns[i]) {
		if (t == p) continue;
		recDP(t, i);
		dp_max[i] += dp_max[t];
		count[i] += count[t];
	}

	dp_min[i] = dp_max[i] % 2;
	for (auto t : conns[i]) {
		if (t == p) continue;
		ll offer = dp_min[t] + dp_max[t] - dp_max[i];
		dp_min[i] = max(dp_min[i], offer);
	}

	if (p == -1) {
		// Solve at root
		if (dp_min[i] == 0) return dp_max[i] / 2;
		else return INF;
	}

	if (str[i] == '1') ++count[i];
	dp_min[i] += count[i];
	dp_max[i] += count[i];

	return -1; // Not root
}

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

	int n;
	cin >> n;
	cin >> str;
	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		conns[a].push_back(b);
		conns[b].push_back(a);
	}

	// Possible iff sum of distances to the target node is even
	// Given that, we then need that the minimum total distance at every branch is at most the sum of the maximum distances of other branches.
	// No operation in a branch can bring two pieces further away from the root, but a operation can bring both of two pieces closer.

	// So for every branch DP 3 values:
	//	1. Total minimum distance of pieces to parent
	//	2. Total maximum distance of pieces to parent
	//	3. Count of pieces
	// Say we count these for every subtree. To do that, first solve all subtrees of a node, then find sum of maximum distances,
	// then loop over every node, subtract its maximum from the total maximum, and check if its minimum is <= the sum of other maximums.
	// If it isn't, the total minimum distance of pieces to parent of this node will be that node's minimum - sum of other maximums.
	// If no node has such a situation, the minimum distance for this node will be the sum of maximums mod 2.

	ll ans = INF;
	for (int i = 0; i < n; ++i) {
		ans = min(ans, recDP(i));
	}
	if (ans == INF) cout << "-1\n";
	else cout << ans << '\n';
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d %d %d", $n, $x, $y);

$ans = array();
$graph = array();
$dists = array();
for ($i=1; $i <= $n; $i++) {
  if ($i !== $n) $ans[$i] = 0;
  if ($i !== 1 && $i !== $n) {
    $graph[$i] = array($i-1, $i+1);
  }
  if ($i === 1) {
    $graph[$i] = array($i+1);
  }
  if ($i === $n) {
    $graph[$i] = array($i-1);
  }
  if ($i === $x) {
    $graph[$i][] = $y;
  }
  if ($i === $y) {
    $graph[$i][] = $x;
  }

  $dists[$i] = -1;
}

$graph_temp = $graph;
$dists_temp = $dists;

for ($i=1; $i < $n; $i++) {
  $graph = $graph_temp;
  $dists = $dists_temp;
  $que = array();

  // 開始位置
  $dists[$i] = 0;
  $que[]     = $i;

  // BFS
  while (!empty($que)) {
    $p = array_shift($que);

    foreach ($graph[$p] as $np) {
      if ($dists[$np] !== -1) continue;

      $dists[$np] = $dists[$p] + 1;
      $que[] = $np;

      if ($i < $np) {
        $ans[$dists[$np]]++;
      }
    }
  }
}

foreach ($ans as $v) {
  echo $v . PHP_EOL;
}


Measured memory_bytes: 4728
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();
		
		if(a < 3200) {
			System.out.println("red");
		}
		else {
			System.out.println(s);
		}
	}
}


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

int main(){
  int N;
  cin>>N;
  string A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int sum =1;
  sort(A,A+N);
  for(int i=0;i<N-1;i++){
    if(A[i]!=A[i+1]){
      sum++;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 9852
//
//AtCoder Beginner Contest 170
//D - Not Divisible
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    const int A_MAX = 1e+6 + 1;
    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a));
    map<int, int> m;
    REP(i,n){
        for(int j=a[i]; j<=a[n-1]; j+=a[i]) {
            m[j]++;
        }
    }

    int ans=0;
    REP(i, n){
        if (m[a[i]]==1) ans++;
    }

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


Measured memory_bytes: 50684
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MAX_WALK = 16010;
const int MAX_DP = 3010;
const int OFS = MAX_WALK / 2;

int main(){
    string s; cin >> s;
    s = s + "T";
    int ghrz, gvrt; cin >> ghrz >> gvrt;
    int forward = 0;
    vector<int> hrz;
    vector<int> vrt;
    int state = 0;
    vector<vector<int>> dp(MAX_DP, vector<int>(MAX_WALK, 0));
    // Initialize robot
    int i=0;
    for(; i<(int)s.length(); i++){
        if(s[i] == 'T'){
            break;
        }
        else{
            forward++;
        }
    }
    dp[0][OFS+forward] = 1;
    int cnt = 0;
    // Parse F and T
    for(; i<(int)s.length(); i++){
        if(s[i] == 'T'){
            if(state && cnt > 0){
                vrt.push_back(cnt);
            }
            else if(cnt > 0){
                hrz.push_back(cnt);
            }
            cnt = 0;
            state = !state;
        }
        else if(s[i] == 'F'){
            cnt++;
        }
    }
    for(int i=0; i<(int)hrz.size(); i++){
        for(int j=0; j<MAX_WALK; j++){
            if(dp[i][j] != 0){
                dp[i+1][j+hrz[i]] = 1;
                dp[i+1][j-hrz[i]] = 1;
            }
        }
    }
    int is_ok_hrz = dp[hrz.size()][OFS+ghrz];
    fill(dp.begin(), dp.end(), vector<int>(MAX_WALK, 0));
    dp[0][OFS+0] = 1;
    for(int i=0; i<(int)vrt.size(); i++){
        for(int j=0; j<MAX_WALK; j++){
            if(dp[i][j] != 0){
                dp[i+1][j+vrt[i]] = 1;
                dp[i+1][j-vrt[i]] = 1;
            }
        }
    }
    int is_ok_vrt = dp[vrt.size()][OFS+gvrt];
    if(is_ok_vrt && is_ok_hrz){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 188800
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++) 
typedef long long int lli;
const int inf = 1e9;

int main(){
	string str;
	int k;
	cin >> str >> k;
	int n = str.length();
	set<string> s;
	for(int i=0; i<n; i++){
		for(int j=1; j<=5; j++){
			if(i+j <= n){
				s.insert(str.substr(i, j));
			}
		}
	}
	auto itr = s.begin();
	REP(i, k-1) itr++;
	cout << *itr << endl;
	return 0;
}

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

bool canClear(const long long t, const int a, const int b, const vector<int>& h){
  long long base = t * b;
  int add = a - b;
  long long count = 0;
  for(int i = 0; i < h.size(); i++){
    if(h[i] > base){
      int c = (h[i] - base - 1) / add + 1;
      count += c;
    }
  }
  return count <= t;
}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> h(n);
  int hmax = -1;
  for(auto& x:h){
    cin >> x;
    if(hmax < x)
      hmax = x;
  }
  int tmin = 1;
  int tmax = hmax / b + 1;
  int tnow;
  while(tmax - tmin > 0){
    tnow = (tmin + tmax) / 2;
    if(canClear(tnow, a, b, h)){
      tmax = tnow;
    }else{
      tmin = tnow+1;
    }
  }
  cout << tmax << endl;
}



Measured memory_bytes: 640
program tetromino_tiling
  implicit none
  integer, parameter :: i = 1, o = 2, t = 3, j = 4, l = 5, s = 6, z = 7
  integer(8) :: a(7), k0, k1
  a = 0_8
  read(*,*) a(i:z)
  k0 = 2_8*(a(i)/2_8+a(j)/2_8+a(l)/2_8)+a(o)
  k1 = 3_8+2_8*((a(i)-1_8)/2_8+(a(j)-1_8)/2_8+(a(l)-1_8)/2_8)+a(o)
  if (a(i).eq.0_8.or.a(j).eq.0_8.or.a(l).eq.0_8) k1 = 0_8
  write(*,'(i0)') max(k0,k1)
  stop
end program tetromino_tiling

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

def main():
    H, W = map(int, input().split())

    INF = int(1e7)
    a = np.array([list(map(lambda x: 0 if x=="#" else INF, list(input().strip()))) for i in range(H)])

    for i in range(H-1):
        a[i+1] = np.minimum(a[i] + 1, a[i+1])
    for i in range(H-1, 0, -1):
        a[i-1] = np.minimum(a[i] + 1, a[i-1])
    
    for i in range(W-1):
        a[:, i+1] = np.minimum(a[:, i] + 1, a[:, i+1])
    for i in range(W-1, 0, -1):
        a[:, i-1] = np.minimum(a[:, i] + 1, a[:, i-1])

    print(np.max(a))

if __name__ == "__main__":
    main()

Measured memory_bytes: 28496
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string A;
	string B;
	int i,flag = 0;
	cin >> A >> B;
	if(A.length() > B.length())
		cout << "GREATER" << endl;
		else if(A.length() < B.length())
			cout << "LESS" << endl;
			else
			{
				for(i = 0;i < A.length(); i++)
				{
					if(A[i] > B[i])
					{
						flag = 1;
						break;
					}
						else if(A[i] < B[i])
						{
							flag = 2;
							break;
						}
				}
				if(flag == 0)
					cout << "EQUAL" << endl;
					else if(flag == 1)
						cout << "GREATER" << endl;
						else
							cout << "LESS" << endl;
			}
							return 0;
}

Measured memory_bytes: 256
local n = io.read("*n")
local tm = {}
for i = 1, n do
  local a = io.read("*n")
  if not tm[a] then tm[a] = 1
  else tm[a] = tm[a] + 1 end
end
local t = {}
for len, cnt in pairs(tm) do
  table.insert(t, {len, cnt})
end
table.sort(t, function(a, b) return a[1] < b[1] end)
local function solve()
  local maxlen = t[#t][1]
  if maxlen % 2 == 0 then
    if t[1][1] ~= maxlen // 2 or t[1][2] ~= 1 then
      return false
    end
    for i = 2, #t do
      if t[i][2] < 2 then
        return false
      end
      if t[i][1] ~= t[i - 1][1] + 1 then
        return false
      end
    end
    return true
  else
    if t[1][1] ~= (maxlen + 1) // 2 or t[1][2] ~= 2 then
      return false
    end
    for i = 2, #t do
      if t[i][2] < 2 then
        return false
      end
      if 1 < i and t[i][1] ~= t[i - 1][1] + 1 then
        return false
      end
    end
    return true
  end
end
print(solve() and "Possible" or "Impossible")


Measured memory_bytes: 888
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
ll n, w[1009], v[1009], W;
ll dp[100009];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>W;
    for(int i=1;i<=n;i++) {
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=n;i++) {
        for(ll j=W;j>=1;j--) {
            if(j >= w[i]) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
        
    }
    cout<<dp[W];
}
/*
 2
 ((
 )))(
 */


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n, m;
    cin >> n >> m;
    vii G(n);
    rep (i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vi ans(n, -1);

    queue<int> qu;
    qu.push(0);
    while (qu.size()) {
        int u = qu.front();
        qu.pop();
        for (int v: G[u]) {
            if (ans[v] != -1) continue;
            ans[v] = u;
            qu.push(v);
        }
    }

    cout << "Yes" << endl;
    rep1 (i, n - 1) {
        cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 13088
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll ans = n * (n-1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    double a,b,x;
    cin>>a>>b>>x;
    x/=a;
    if( a*b/2 > x ){
	double y = 2*x/b;
	printf("%0.10lf\n",atan2( b, y )/atan2(0.0,-1.0)*180.0 );
    }else{
	double y = 2*x/a - b;
	printf("%0.10lf\n",atan2(b-y,a)/atan2(0.0,-1.0)*180.0);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char n[2],a=0;
    scanf("%s",n);
    for(int i=0;i<=1;i++){
        if(n[i]=='9') {a=1;break;}
    }
    if(a==1) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

ll mod = 1e9 + 7;

void
solve() {
  ll n;
  cin>>n;

  vector<vector<ll>> a(n, vector<ll>(n, 0));
  for (ll i=0; i<n; i++)
    for (ll j=0; j<n; j++) 
      cin>>a[i][j];

  vector<ll> dp(1<<n, 0);
  dp[0] = 1;
  for (ll i=0; i<(1<<n); i++) {
    for (ll j=0; j<n; j++) {
      if ((i & (1 << j)) && a[j][__builtin_popcount(i)-1]) {
        dp[i] += dp[i - (1<<j)];
        dp[i] %= mod;
      }
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 19568
N,A,B,C,D = map(int,input().split())
S = input().strip()
S = "."+S
flag=0
if C<B:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag=1
            break
    for i in range(B,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
elif B<C<D:
    for i in range(A,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
else:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag = 1
            break
    if flag==1:
        print("No")
    else:
        flag = 1
        for i in range(B+1,D):
            if S[i]=="#":continue
            if (S[i-1]=="#" and S[i+1]=="#") or (S[i-2:i]=="#." and S[i+1]=="#") or (S[i-1]=="#" and S[i+1:i+3]==".#"):continue
            else:
                flag=0
                break
        if flag==1:
            if S[B+1]=="#" or (S[B-1]=="#" and S[B+1:B+3]==".#"):
                flag=1
            else:
                flag=0
        if flag==1:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 40816
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	ll b;
	while (cin >> b, b) {
		ll k = sqrt(b);
		vector<ll> v;
		rep1(i, k) {
			if (b%i == 0) {
				v.push_back(i);
				v.push_back(b / i);
			}
		}
		sort(v.begin(), v.end());
		LP out;
		rep(i, (int)v.size()) {
			ll x = v[i];
			ll num = b / x;
			if (num % 2 == 0)continue;
			if (x - num / 2 > 0) {
				out = { x - num / 2,x + num / 2 }; break;
			}
		}
		//cout << out.first << " " << out.second << endl;
		per(i, (int)v.size()) {
			ll x = v[i];
			ll d = b / x;
			if (d % 2 == 0)continue;
			ll mid = d / 2+1;
			if (mid - x > 0) {
				ll le = mid - x; ll ri = mid + x - 1;
				//cout << le << " " << ri << endl;
				if (ri - le > out.second - out.first) {
					out = { le,ri };
				}
				break;
			}
		}
		cout << out.first << " " << out.second-out.first+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
import math

N = int(input())
sq = int(math.sqrt(N))

if N == 2 or N == 3:
    print(N-1)
elif sq*sq == N:
    print(2*sq-2)
else:
    for i in reversed(range(1,sq+1)):
        if N % i == 0:
            print(i+(N//i)-2)
            break


Measured memory_bytes: 3060
def gcd(x, y):
  if x < y:
    tmp = x
    x = y
    y = tmp
  while True:
    if y == 0:
      break
    x = x % y
    tmp = x
    x = y
    y = tmp

  return x

def lcm(x, y):
  return x * y / gcd(x, y)

while True:
  try:
    a, b = map(int, input().split())
    print(gcd(a, b), int(lcm(a, b)))
  except EOFError:
    break

Measured memory_bytes: 7540
if __name__ == "__main__":
    s = input()
    case1 = 0
    isZero = True
    for ss in s:
        if (isZero and ss == "1") or (not isZero and ss == "0"):
            case1 += 1
        isZero = not isZero
    isZero = False
    case2 = 0
    for ss in s:
        if (isZero and ss == "1") or (not isZero and ss == "0"):
            case2 += 1
        isZero = not isZero
    print(min(case1, case2))
        

Measured memory_bytes: 3188
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

#define		MXINPUT		100

int		main(void)
{
	int		n;
	int		i;
	int		a[MXINPUT];

	scanf("%d",&n);

	for(i=0; i<n; i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=n-1; 0<=i ; i--)
	{
		if(i !=0 )
		{
			printf("%d ",a[i]);
		}
		else
		{
			printf("%d",a[0]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  int k;
  cin >> k;
  
  sort(a.begin(), a.end(), greater<int>());
  rep(i, k) a[0] *= 2;
  cout << a[0] + a[1] + a[2] << endl;


  
  return 0;
}

Measured memory_bytes: 256
def main(argv)
  (n, k) = STDIN.gets.chomp.split(' ').map(&:to_i)
  a = STDIN.gets.chomp.split(' ').map(&:to_i)

  c = [0] * n
  a.each {|v| c[v - 1] += 1}

  b = []
  c.each_with_index {|v, i| b.push({:key => i + 1, :val => v})}
  b = b.sort{|a, b| a[:val] <=> b[:val]}

  d = 0
  while b.size > k do
    v = b.shift
    d += v[:val]
  end

  STDOUT.puts d.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 73224