akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val wcs = (0..(n - 1)).toMutableList()

    s.forEachIndexed { index, c ->
        wcs[index] = if (index == 0) 0 else wcs[index - 1]
        if (c == 'W') {
            wcs[index]++
        }
    }

    val min = (0..(n - 1)).map {
        val w = if (it == 0) 0 else wcs[it - 1]
        val e = n - (it + 1) - (wcs.last() - wcs[it])
        w + e
    }.min()

    println(min)
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  double k;
  cin>>k;
  cout<<setprecision(8)<<2*PI*k<<endl;
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int N;
    cin>>N;
    int S=0;;
    int P=N;
    bool a=true;
    while(a==true){
        if(P==0){
            a=false;
        }
        else{
            S+=P%10;
            P-=P%10;
            P/=10;
        }
    }


    if(N%S==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3604
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let S = read_line();
    let c = S.chars()
        .collect::<Vec<char>>()
        .iter()
        .filter(|&c| *c == '0')
        .count();
    println!("{}", std::cmp::min(c, S.len()-c) * 2);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n;
int a[100000];
int b[100000];



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

	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];

	priority_queue<int> pq;

	int ans = 0;
	long long yobi = 0;
	rep(i,n) {
		if (a[i] > b[i]) {
			pq.push(a[i] - b[i]);
		}
	}
	rep(i, n) {
		if (a[i] < b[i]) {
			int diff = b[i] - a[i];

			while (yobi < diff && !pq.empty()) {
				yobi += pq.top();
				pq.pop();
				ans++;
			}
			if (yobi < diff) {
				ans = -1;
				break;
			}
			yobi -= diff;
			ans++;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1408
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)

	if a+b > n+1 {
		fmt.Println(-1)
		return
	}

	if a*b < n {
		fmt.Println(-1)
		return
	}

	ans := make([]int, n)

	for i := 0; i < n; i++ {
		ans[i] = n - i
	}

	sort.Ints(ans[0:a])
	if b > 1 {
		mod := (n - a) % (b - 1)
		div := (n - a) / (b - 1)
		for i := a; i < n; i += div {
			if mod > 0 {
				sort.Ints(ans[i : i+div+1])
				i++
				mod--
				continue
			}
			sort.Ints(ans[i : i+div])
		}
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(writer, ans[i])
		if i < n-1 {
			fmt.Fprint(writer, " ")
		}
	}
	fmt.Fprintln(writer, "")
	writer.Flush()
}

func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 7808
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c,d,k;
  int num,num2,s;
  cin >> a >> b >> c >> d >> k;
  num = c-a;
  num2 = d-b;
  s = num*60+num2;
  if(s-k>=0)cout<<s-k<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstdio>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

using namespace std;

const int maxn = 200005;
int n;
ll a[maxn];
ll sum = 0;
inline ll solve(int k)
{
    ll cnt = 0;
    for (int i = 1; i <= n; i++)cnt += abs(a[i] - k);
    return cnt;
}
int main()
{
    IOS
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
        a[i] = a[i] - i;
    }
    ll ans, lmid, rmid;
    ll l = -1e9, r = 1e9;
    while (l < r - 1)
    {
        lmid = (l + r) >> 1, rmid = (lmid + r) >> 1;
        if (solve(lmid) > solve(rmid))l = lmid;
        else r = rmid;
    }
    if (solve(l) < solve(r))ans = l;
    else ans = r;
    printf("%lld\n", solve(ans));
    return 0;
}
/**
8 2
5 3 2 0 4 4 7 1
1 2
1 3
2 4
2 5
3 6
3 7
6 8

**/


Measured memory_bytes: 1792
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
	long double l;
	cin >> l;
	long double ans = (l/3) * (l/3) * (l/3); 
	printf("%0.10Lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
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; }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> 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(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  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;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x - a) < abs(x - b) ? "A" : "B") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> vec(n);
    els(vec) {
        cin >> el;
    }
    int64_t less = 0;
    int64_t from_pos = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            less += (vec[j] < vec[i]);
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            from_pos += (vec[j] < vec[i]);
        }
    }
    int64_t mult = k * (k - 1) / 2;
    mult %= INF;
    int64_t res = (less * mult) % INF;
    res += (from_pos * k) % INF;
    res %= INF;
    cout << res << endl;;
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}


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

int n;
multiset<int> a;
long long sum;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0, x; i < 3*n; i++) {
		cin >> x;
		a.insert(x);
	}
	for(int i = 0; i < n; i++) {
		auto it = a.end();
		it--;
		a.erase(it);
		it--;
		sum += *it;
		a.erase(it);
		a.erase(a.begin());
	}
	cout << sum;
}


Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    ll A, B, C;
    map<ll, ll> cnt;
    for (int i = 0; i < N; i++) {
        cin >> A;
        cnt[A]++;
    }
    for (int i = 0; i < M; i++) {
        cin >> B >> C;
        cnt[C] += B;
    }
    vector<ll> number;
    for (auto i = cnt.begin(); i != cnt.end(); i++) {
        number.push_back(i->first);
    }
    /*
    for (int i = 0; i < number.size(); i++) cout << number[i] << ' ';
    cout << endl;
    */
    sort(number.begin(), number.end());
    reverse(number.begin(), number.end());
    ll rest = N;
    ll ans = 0;
    int idx = 0;
    while (rest > 0) {
        ll num = min(rest, cnt[number[idx]]);
        ans += num * number[idx];
        rest -= num;
        idx++;
    }
    cout << ans << endl;
    return 0;
}

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

int main () {

    int N, K;
    scanf("%d %d", &N, &K);

    int x[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &x[i]);
    }

    long long ans = INT_MAX;

    for (int i = 0; i < N-K+1; i++) {
        long long left = x[i], right = x[i+K-1];

        ans = min(ans, min(abs(left) + abs(right - left), abs(right) + abs(left - right)));
    }
    printf("%lld\n", ans);

    return 0;
}

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

vector<vector<int> > G;

int main(){

    int n, m;
    cin >> n >> m;
    G.resize(n);
    vector<int> deg(n, 0);
    vector<int> a(n-1+m), b(n-1+m);
    for(int i = 0; i < n-1+m; ++i) {
        cin >> a[i] >> b[i]; --a[i]; --b[i];
        G[a[i]].push_back(b[i]);
        ++deg[b[i]];
    }
    vector<int> d(n, 0);
    queue<int> q;
    for(int i = 0; i < n; ++i) {
        if(deg[i] == 0) q.push(i);
    }

    while(!q.empty()) {
        int x = q.front(); q.pop();
        for(auto e : G[x]) {
            --deg[e];
            d[e] = max(d[e], d[x]+1);
            if(deg[e] == 0) q.push(e);
        }
    }

    vector<int> parent(n, 0);
    for(int i = 0; i < n-1+m; ++i) {
        if(d[b[i]] == d[a[i]]+1) parent[b[i]] = a[i]+1;
    }
    for(auto x : parent) cout << x << endl;

    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(l, n);
    pri(n);
    for(;n--;){
      int2(x, w);
      pri2(-x, w);
    }


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)

typedef pair<int, int> pint;

struct union_find {
    vector<int> p;
    union_find(int n) : p(n, -1) {}

    int root(int u){
        int r = (p[u] < 0) ? u :  (p[u] = root(p[u]));
        return r;
    }

    bool same(int a, int b){
        return root(a) == root(b);
    }

    void unite(int a, int b){
        a = root(a);
        b = root(b);
        if(a == b){
            return ;
        }
        if(p[a] < p[b]){
            swap(a, b);
        }
        p[a] += p[b];
        p[b] = a;
    }

};

int main(){
    int N, K, L;
    cin >> N >> K >> L;

    union_find rd(N);
    union_find rl(N);

    rep(i, K){
        int p, q;
        cin >>  p >> q;
        p --;
        q --;
        rd.unite(p, q);
    }

    rep(i, L){
        int r, s;
        cin >>  r >> s;
        r --;
        s --;
        rl.unite(r, s);

    }

    map<pint, int> p_map;
    rep(i, N){
        pint p = {rd.root(i), rl.root(i)};
        p_map[p] ++;
    }
    rep(i, N){
        pint p = {rd.root(i), rl.root(i)};
        cout << p_map[p] << (i == N - 1 ? "" : " ");
    }
    cout << endl;
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,K;
double dd,cc;
ll i, j, k,l;
vector<pll> tv[101010];
ll ans[101010];
void dfs(ll ii,ll mm){
    if(ans[ii]!=0)
        return;
    ans[ii] = mm + 1;
    ll i, j;
    fornum(i,0,tv[ii].size()){
        dfs(tv[ii][i].first, (mm+tv[ii][i].second) % 2);
    }
}

int main(){
    scanf("%lld", &N);
    fornum(i,1,N){
        ll u, v, w;
        scanf("%lld%lld%lld", &u, &v, &w);
        tv[u].push_back({v, w});
        tv[v].push_back({u, w});
    }
    dfs(1, 0);
    fornum(i,0,N){
        printf("%lld\n", ans[i + 1] - 1);
    }
    return 0;
}

Measured memory_bytes: 10240
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i, n){
        if(s[i] == 'R')cnt++;
    }
    if(cnt * 2 > n)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

const int max_n = 18, inf = 1000111222;

bool is_power_two(int x) {
    return x > 0 && ((x & (x - 1)) == 0);
}

bool get_bit(int mask, int pos) {
    return (bool) (mask & (1 << pos));
}

int get_cnt(int n, int x) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += get_bit(x, i);
    }
    return res;
}

int upd(int n, int x, const vector<int> &p) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += get_bit(x, i) * (1 << p[i]);
    }
    return res;
}

vector<int> solve(int n, int a, int b) {
    // cout << n << " " << a << " " << b << endl;
    if (n == 1) {
        return {a, b};
    }
    b ^= a;
    vector<int> pos, p(n);
    for (int i = 0; i < n; ++i) {
        if (get_bit(b, i)) {
            pos.push_back(i);
            p[n - pos.size()] = i;
        }
    }
    int cur = 0;
    for (int i = 0; i + pos.size() < n; ++i) {
        while (get_bit(b, cur)) {
            ++cur;
        }
        p[i] = cur;
        ++cur;
    }
    int x = 0;
    for (int i = n - 1; i >= (int) (n - pos.size()); --i) {
        x += (1 << i);
    }
    vector<int> v1, v2;
    int to = x;
    to ^= (1 << (n - 1));
    to ^= (1 << (n - 2));
    v1 = solve(n - 1, 0, to);
    v2 = solve(n - 1, to, x ^ (1 << (n - 1)));
    for (int i = 0; i < v2.size(); ++i) {
        v2[i] ^= (1 << (n - 1));
    }
    vector<int> v;
    for (int x : v1) {
        v.push_back(a ^ upd(n, x, p));
    }
    for (int x : v2) {
        v.push_back(a ^ upd(n, x, p));
    }
    return v;
}

void check(int n, int a, int b, const vector<int> &ans) {
    if (ans.size() != (1 << n)) {
        exit(1);
    }
    if (ans[0] != a) {
        exit(2);
    }
    if (ans.back() != b) {
        exit(2);
    }
    for (int i = 0; i + 1 < ans.size(); ++i) {
        if (!is_power_two(ans[i] ^ ans[i + 1])) {
            exit(3);
        }
        if (!(0 <= ans[i] && ans[i] < ans.size())) {
            exit(4);
        }
    }
}

void go(int n, int a, int b) {
    if (get_cnt(n, a ^ b) % 2 == 0) {
        puts("NO");
        return;
    }
    const vector<int> &ans = solve(n, a, b);
    puts("YES");
    for (int x : ans) {
        printf("%d ", x);
    }
    puts("");
    check(n, a, b, ans);
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    if (0) {
        for (int n = 1; n <= 4; ++n) {
            for (int a = 0; a < (1 << n); ++a) {
                for (int b = 0; b < (1 << n); ++b) {
                    if (a != b) {
                        cout << n << " " << a << " " << b << ": ";
                        go(n, a, b);
                    }
                }
            }
        }
    }
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    go(n, a, b);
    return 0;
}


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

using namespace std;

#define ll long long
#define sf scanf
#define pf printf 
#define nl printf("\n")

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif

	int n,m,arr[200],total=0;
	sf("%d %d",&n,&m);
	for(int i=0; i<n; i++){
		sf("%d",&arr[i]);
		total += arr[i];
	}
	sort(arr,arr+n);
	int check;
	if(total%(4*m)==0) check = total/(4*m);
	else check = (total/(4*m))+1;
	for(int i=n-1; i>=0; i--){
		if(m<=0) break;
		if(arr[i]>=check) m--;
		else break;
	}
	if(m<=0) pf("Yes\n");
	else pf("No\n");
	return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
m=(n-1)//2
t=s[:m]
u=s[(n+3)//2-1:]
#print(t,u)
for i in range(n):
  if s[i]!=s[n-1-i]:
    print("No")
    exit()

for i in range(m):
  if t[i]!=t[m-1-i] or u[i]!=u[m-1-i]:
    print("No")
    exit()




print("Yes")

Measured memory_bytes: 3064
import numpy as np
from copy import deepcopy

N, x = map(int,raw_input().split())
A = map(int,raw_input().split())

def myfunc(N, x, A):
  A = np.array(A)
  B = deepcopy(A)
  m = sum(B)
  for idx in xrange(1,N):
    A = np.append(A, A[0])
    A = np.delete(A, 0)
    np.fmin(B, A, out=B)
    m = min(np.sum(B)+idx*x, m)
  print int(m)

myfunc(N, x, A)

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

int main(){
    int N,X;
    cin >> N >> X;
    int D = 0;
    int count = 0;
    vector<int> l(N);
    for(int i = 0;i < N;i++){
        cin >> l.at(i);
    }
    for(int i = 0;i < N+1;i++){
        if(i == 0){
            count++;
        }else{
            D = D + l.at(i-1);
            if(D <= X){
                count++;
            }else{
            break;
            }
        }
    }

    cout << count << endl;
    
    
}


Measured memory_bytes: 256
K, N = map(int, input().split(' '))
A_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(N):
    l = A_ls[(i + 1) % N] - A_ls[i]
    if l < 0:
        l = K - A_ls[i] + A_ls[(i + 1) % N]
    if rst == -1:
        rst = l
    else:
        rst = max(rst, l)
print(K - rst)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    ll ans = 0;
    ul base = 1;
    rep(num, 60) {
        ll zero = 0, one = 0;
        rep(i, n) {
            if (a[i] & (1ul << num)) {
                one++;
            } else {
                zero++;
            }
        }
        ans += ((zero * one) % mod) * base;
        ans %= mod;
        base = (base * 2) % mod;
    }

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



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
#define INF 1000000000

int main() {
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> p(N, K);
  rep(i, Q) {
    int A; cin >> A;
    A--;
    p[A]++;
  }
  rep(i, N) {
    if(p[i] - Q > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll r,D,s;
int main(){FAST;
cin>>r>>D>>s;
ll nx = s;
for(ll i=0;i<10;i++){
	nx = nx*r-D;
	cout<<nx<<'\n';
}
return 0;
}




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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

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

    rep(i, t) {
        bool b = [&] {
            ll a, b, c, d;
            cin >> a >> b >> c >> d;

            if (b > a) return false;
            if (b > d) return false;
            if (c >= b) return true;

            assert(b <= a);
            assert(b <= d);
            assert(c < b);

            ll g = gcd(b, d);
            ll ma = (b - a % g + g - 1) / g * g + a % g - g;
            return ma <= c;
        }();
        cout << (b ? "Yes" : "No") << endl;
    }

}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 1e7 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll INF = 2e18;

ll ho[N];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	ll k, n;
	cin >> k >> n;
	for (int i = 0; i < n; ++i) {
		cin >> ho[i];
	}
	ll ans = INF;
	for (int i = 0; i < n; ++i) {
		if(i == 0) {
			ll c1 = ho[n - 1] - ho[i];
			ans = min(ans, c1);
		} else if(i + 1 == n) {
			continue;
		} else {
			ll c1 = ho[i] + (k - ho[i + 1]);
			ll c2 = (k - ho[i]) + ho[i - 1];
			ans = min(ans, min(c1, c2));
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

const int MOD = 1000000007;

long long modPow(long long a, long long p){
	if(p == 0) return 1;
	long long res = modPow(a, p/2);
	res = (res * res) % MOD;
	if(p%2 == 1) res = (res * a) % MOD;
	return res;
}

pair<long long, long long> solve(const vector<int>& h){
	if(h.empty()) return make_pair(1, 1);
	int minH = h[0];
	for(auto& t : h) minH = min(t, minH);
	if(minH > 1){
		vector<int> nh = h;
		for(auto& t : nh) t -= minH - 1;
		auto res = solve(nh);
		long long p2 = modPow(2, minH - 1);
		res.first = (res.first + (2 * p2 + MOD - 2) % MOD * res.second) % MOD;
		res.second = (res.second * p2) % MOD;
		return res;
	} else {
		for(int i=0;i<h.size();i++){
			if(h[i] == 1){
				vector<int> h1, h2;
				for(int j=0;j<i;j++) h1.push_back(h[j]);
				for(int j=i+1;j<h.size();j++) h2.push_back(h[j]);
				auto res1 = solve(h1);
				auto res2 = solve(h2);
				pair<long long, long long> res;
				res.first = 2 * res1.first * res2.first % MOD;
				res.second = res1.second * res2.second % MOD;
				return res;
			}
		}
	}
	return make_pair(0, 0);
}

int main(){
	int N;
	while(cin >> N){
		vector<int> h(N);
		for(auto& t : h) cin >> t;
		cout << solve(h).first << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n;
int main(){
	cin>>n;
	cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  ll l, r;
  cin >> l >> r;
  ll min1 = 2020;
  ll min2 = 2021;
  ll ans = 10000000000;
  ll tmp;
  if(r - l > 2019){
    cout << 0 << endl;
    return 0;
  }
  for(ll i = l; i <= r; i++ ){
    for(ll j = i + 1; j <= r; j++ ){
      tmp = i%2019;
      if(tmp == 0){
	cout << 0 << endl;
	return 0;
      }else{
	ans = min(ans, (i*j)%2019);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 764
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;
// #define DEBUG
const int maxn = 1e5+5;
char s[maxn];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifdef DEBUG
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	scanf("%s", s);
	int n = strlen(s);
	int ans = 0;
	
	rep(i, 0, n) {
		if (s[i] == 'g') {
			++ans;
		} else {
			--ans;
		}
	}
	
	printf("%d\n", ans/2);
	
	// #ifdef DEBUG
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int H = scanner.nextInt();
		int N = scanner.nextInt();
		int i;
		int sum = 0;
		for(i=0;i<N;i++) {
			sum += scanner.nextInt();;
		}
		if(H>sum) {
			System.out.print("No");
		}else {
			System.out.print("Yes");
		}
		
		
		
	}

}



Measured memory_bytes: 49040
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            // 長方形のたてとよこの長さを受け取る
            int[] line = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();

            // 面積 周の長さの順で出力
            var area = line[0] * line[1];
            var perimeter = line[0] * 2 + line[1] * 2;
            Console.WriteLine(area + " " + perimeter);
        }
    }
}


Measured memory_bytes: 16320
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x, y;
	cin >> x >> y;
	if (y&1) {cout << "No\n"; return 0;}
	int mn = 2*x, mx = 4*x;
	if (mn <= y && y <= mx) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>n;
    vl<ll> arr(n),brr(n);
    for(i=0;i<n;i++) cin>>arr[i];
    brr=arr;
    sort(brr.begin(),brr.end());
    ll flag=0;
    if(brr[n-1]==brr[n-2]) flag=1;
    if(flag==1) for(i=0;i<n;i++) cout<<brr[n-1]<<endl;
    else
    {
        for(i=0;i<n;i++) 
        {
            if(arr[i]==brr[n-1]) cout<<brr[n-2];
            else cout<<brr[n-1];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 6400
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit

# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class SegmentTree:

    def __init__(self, array, operator, identity):
        self.identity = identity
        self.operator = operator

        self.array_size = len(array)
        tree_height = (self.array_size - 1).bit_length()
        self.tree_size = 2 ** (tree_height + 1)
        self.leaf_start_index = 2 ** tree_height
        self.tree = [identity] * self.tree_size

        for i in range(self.array_size):
            self.tree[self.leaf_start_index + i] = array[i]

        for i in range(1, tree_height):
            begin = 1 << (tree_height - i)
            end = begin << 1
            for j in range(begin, end):
                self.tree[j] = self.operator(self.tree[j << 1], self.tree[j << 1 | 1])

    def update(self, index, val):
        cur_node = self.leaf_start_index + index
        self.tree[cur_node] = val

        while cur_node > 1:
            self.tree[cur_node >> 1] = self.operator(self.tree[cur_node], self.tree[cur_node ^ 1])
            cur_node >>= 1

    def query(self, begin, end):
        res = self.identity

        if begin < 0:
            begin = 0
        elif begin > self.array_size:
            return self.identity

        if end > self.array_size:
            end = self.array_size
        elif end < 1:
            return self.identity

        left = begin + self.leaf_start_index
        right = end + self.leaf_start_index

        while left < right:
            if left & 1:
                res = self.operator(res, self.tree[left])
                left += 1

            if right & 1:
                right -= 1
                res = self.operator(res, self.tree[right])

            left >>= 1
            right >>= 1

        return res


def main():
    from fractions import gcd

    n = int(input())
    a = list(map(int, readline().split()))
    seg = SegmentTree(a, gcd, 0)
    ans = 0

    for i in range(n):
        temp1 = seg.query(0, i)
        temp2 = seg.query(i + 1, n)
        temp = gcd(temp1, temp2)
        ans = max(ans, temp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85856
#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef complex<int> P;

P conv[4] = {
	P(-1, 0),
	P(0, -1),
	P(1, 0),
	P(0, 1),
};

int main() {
	int N;
	while ( cin >> N, N ) {
		vector<P> v;
		v.push_back( P(0, 0) );
		int mx = 0, my = 0, Mx = 0, My = 0;
		for (int i = 0; i < N-1; ++i) {
			int n, d; cin >> n >> d;
			P p = v[n] + conv[d];
			mx = min(mx, p.real());
			my = min(my, p.imag());
			Mx = max(Mx, p.real());
			My = max(My, p.imag());
			v.push_back(p);
		}
		int w = Mx - mx + 1;
		int h = My - my + 1;
		cout << w << " " << h << endl;
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

bool cmp(pii x, pii y) {
    return 1ll * x.first * y.second < 1ll * x.second * y.first;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m = 0;
    pii a[1000006] = {};
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        int x = 0, y = 0;
        for (int j = 0; j < s.length(); j++) {
            if (s[j] == '(') x++;
            else x--;
            y = min(y, x);
        }
        a[i] = {-y, x};
    }
    sort(a, a + n, cmp);
    //for (int i = 0; i < n; i++) cout << a[i].first << ' ' << a[i].second << '\n';
    for (int i = 0; i < n; i++) {
        if (m < a[i].first) {
            cout << "No";
            return 0;
        }
        m += a[i].second;
    }
    if (m) cout << "No";
    else cout << "Yes";
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T, bool isMin>
struct ConvexHullTrick{
  #define F first
  #define S second
  using P = pair<T, T>;
  deque<P> H;

  bool empty()const{return H.empty();}
  void clear(){H.clear();}

  inline Int sgn(T x){return x == 0?0:(x<0? -1:1);}
  using D = long double;
  inline bool check(const P &a, const P &b, const P &c){
    if(b.S == a.S || c.S == b.S)
      return sgn(b.F - a.F) * sgn(c.S - b.S) >= sgn(c.F - b.F) * sgn(b.S - a.S);

    return
      D(b.F - a.F) * sgn(c.S - b.S)/D(abs(b.S - a.S)) >=
      D(c.F - b.F) * sgn(b.S - a.S)/D(abs(c.S - b.S));
  }

  void addLine(T m, T b){
    if(!isMin) m *= -1, b *= -1;
    P line(m, b);
    if(empty()){
      H.emplace_back(line);
      return;
    }

    if(H.front().F <= m){
      if(H.front().F == m){
        if(H.front().S <= b) return;
        H.pop_front();
      }
      while(H.size() >= 2 && check(line, H.front(), H[1])) H.pop_front();
      H.emplace_front(line);
    }else{
      assert(m <= H.back().F);
      if(H.back().F == m){
        if(H.back().S <= b) return;
        H.pop_back();
      }
      while(H.size() >= 2 && check(H[H.size() - 2], H.back(), line)) H.pop_back();
      H.emplace_back(line);
    }
  }

  inline T getY(const P &a, const T &x){
    return a.F * x + a.S;
  }

  T query(T x){
    assert(!empty());
    Int l = -1, r = H.size() - 1;
    while(l + 1 < r){
      Int m = (l + r) >> 1;
      if(getY(H[m], x) >= getY(H[m+1], x)) l = m;
      else r = m;
    }
    if(isMin) return getY(H[r], x);
    return - getY(H[r], x);
  }

#undef F
#undef S
};

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

  Int n;
  cin>>n;

  Int zx,zv;
  cin>>zx>>zv;

  vector<Int> xs(n),vs(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>vs[i];

  for(Int i=0;i<n;i++){
    xs[i]-=zx;
    vs[i]-=zv;
  }

  using D = double;
  const D INF = 1e10;
  vector<D> ans(n,INF);
  for(Int i=0;i<n;i++){
    if(xs[i]==0) ans[i]=0;
    if((D)xs[i]*(D)vs[i]<0) chmin(ans[i],-(D)xs[i]/(D)vs[i]);
  }

  for(Int uku=0;uku<2;uku++){
    for(Int i=0;i<n;i++){
      xs[i]*=-1;
      vs[i]*=-1;
    }

    using P = pair<D, D>;
    vector<P> vp;
    Int sp=0;
    for(Int i=0;i<n;i++){
      if(xs[i]>=0) continue;
      if(vs[i]<=0) continue;
      vp.emplace_back(vs[i],xs[i]);
      chmax(sp,vs[i]);
    }
    if(vp.empty()) continue;

    sort(vp.begin(),vp.end());
    ConvexHullTrick<D, false> cht;
    for(auto p:vp) cht.addLine(p.first,p.second);

    for(Int i=0;i<n;i++){
      if(xs[i]<=0) continue;
      if(sp<=vs[i]) continue;
      D L=0,R=INF;
      for(Int k=0;k<80;k++){
        D M=(L+R)/2;
        if(cht.query(M)>=(D)vs[i]*M+(D)xs[i]) R=M;
        else L=M;
      }
      chmin(ans[i],R);
    }
  }

  cout<<fixed<<setprecision(12);
  for(Int i=0;i<n;i++){
    if(ans[i]>=INF) cout<<-1<<"\n";
    else cout<<ans[i]<<"\n";
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 11620
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S; cin >> S;
    cout << S.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if (400 <= x && x < 600) {
      System.out.println(8);
    } else if (600 <= x && x < 800) {
      System.out.println(7);
    } else if (800 <= x && x < 1000) {

      System.out.println(6);
    } else if (1000 <= x && x < 1200) {

      System.out.println(5);
    } else if (1200 <= x && x < 1400) {

      System.out.println(4);
    } else if (1400 <= x && x < 1600) {

      System.out.println(3);
    } else if (1600 <= x && x < 1800) {

      System.out.println(2);
    } else {
      System.out.println(1);
    }
  }
}


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

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for (int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

ll dp[110][30];

int main()
{   
    int N;
    cin >> N;
    vector<int> num(N);

    rep(i, N) cin >> num[i];

    dp[0][num[0]] = 1;

    rep(i, N - 1)
    {
        rep(j, 21)
        {
            if(dp[i][j] == 0) continue;

            int plus = j + num[i + 1], minus = j - num[i + 1];

            if(0 <= plus && plus <= 20)
                dp[i + 1][plus] += dp[i][j];
            
            if(0 <= minus && minus <= 20)
                dp[i + 1][minus] += dp[i][j];
        }
    }

    cout << dp[N - 2][num[N - 1]] << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=a;i<=b;++i)

using namespace std;

const int maxn=1e5+10;
int a[maxn],n;

int main(void)
{
	scanf("%d",&n);
	For(i,1,n)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	int x=1,y=1;
	while(y+1<=a[x+1])
		x++,y++;
	int qaq=x+1;
	while(a[qaq]==y)
		qaq++;
	if(((qaq-x)&1)&&((a[x]+1-y)&1))
		puts("Second");
	else
		puts("First");
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#define N 1000000
using namespace std;

int main(){
	int n,k,s=0,d=0;
	scanf(" %d %d", &n , &k);
	int a[N],h;
	for(int i=0;i<n;i++){
		scanf(" %d", &h);
		s += h/k;
		d = max(d, h);
		a[i] = h;
	}
	
	int low=s-1,high,mid;
	high = min(1000000000,(d*n)/k);
	while(1){
		if(high-low <= 1) break;
		mid = (low+high)/2;
		int count=0, bef=0,bag,p;
		bool f = true;
		while(1){
			if(bef == n) break;
			if(count >= k){
				f = false;
				break;
			}
			bag = mid;
			for(p=bef;p<n;p++){
				if(bag >= a[p]) bag-=a[p];
				else break;
			}
			bef = p;
			count++;
		}
		if(f) high = mid;
		else low = mid;
	}
	
	printf("%d\n", high);	
	return 0;
}

Measured memory_bytes: 3252