akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_macros)]
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::max($x, max!( $($y),+)));
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => (::std::cmp::min($x, min!( $($y),+)));
}

// solution 
use std::cmp;
use std::collections::{HashMap, HashSet, BTreeMap, BTreeSet};
fn main() {
    input! {
        N: usize,
        T: usize,
        t: [usize; N],
    }

    let mut sum = 0;
    for ind in 0..N-1 {
        if t[ind] + T < t[ind+1] {
            sum += T;
        } else {
            sum += t[ind+1] - t[ind];
        }
    }
    sum += T;
    println!("{}", sum);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main() {
  double a,b;cin>>a>>b;
  cout << a/b << endl;
}


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

void print(auto x) {
    cout << x << endl;
}

ll sum(auto x) {
    return accumulate(x.begin(), x.end(), 0LL);
}

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x >= K) ans++;
    }
    print(ans);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, M, p, y, c;
	map<pair<int, int>, ll> num;
	vector<pair<int, int> > data, data2;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &p, &y);
		data.push_back(make_pair(p, y));
		data2.push_back(make_pair(p, y));
	}
	sort(all(data2));
	p = 0;
	for (auto v : data2) {
		if (v.first != p)c = 1;
		num[v] = c + (ll)v.first * 1000000;
		p = v.first;
        c++;
	}
	for (auto v : data) {
		printf("%012lld\n", num[v]);
	}
	return 0;
}


Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i) // マクロ
using namespace std;                          // stdの省略
using pii = pair<int, int>;                   // pairの略記
using ll = long long;                         // long longの略記

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main(void)
{

    int h, w, si, sj, ti, tj;
    cin >> h >> w >> si >> sj >> ti >> tj;
    --si;
    --sj;
    --ti;
    --tj; // ０スタートなのでデクリメント

    vector<string> s(h);
    rep(i, h) cin >> s[i]; // repマクロの利用

    const int INF = 1e9; // あり得ない数字
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pii> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while (!q.empty())
    {
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        if (dist[i][j] != d) continue;
        rep(v, 4)
        {
            int ni = i + di[v], nj = j + dj[v];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (s[ni][nj] == '#') continue;
            if (dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }
        for (int ei = -2; ei <= 2; ++ei) {
            for (int ej = -2; ej <= 2; ++ej) {
                int ni = i + ei, nj = j + ej;
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') continue;
                if (dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

/**********************************

ll cnt = 0;
    while (ch!=dh || cw!=dw)
    {
        
}

int bf = -1;
for (auto x : a)
{
    if (bf > x)
        cnt += bf - x;
    else
        bf = x;
}

cout << cnt << endl;

return 0;

**********************************/

Measured memory_bytes: 9496
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

struct SegTree
{
    // 一次元配列に完全二分木
    std::vector<int> data;
    // 単位元 (min なら inf)
    int e = 0;
    int N = 1;

    SegTree(int size)
    {
        while (N < size) N <<= 1;
        // 要素数 n ではノード数は 2*n - 1
        data.resize(2 * N - 1, e);
    }

    void update(int i, char x)
    {
        i += N - 1;  // 要素 i の木中ノード番号
        data[i] = (1 << (x - 'a'));
        while (i > 0)
        {
            i = (i - 1) / 2;  // 親ノード番号

            data[i] = data[2 * i + 1] | data[2 * i + 2];
        }
    }

    int query(int q_l, int q_r)
    {  // [q_l, q_r) に対するクエリの処理
        return _query(q_l, q_r, 0, 0, N);
    }

   private:
    int _query(int q_l, int q_r, int k, int k_l, int k_r)
    {  // ノード k : 区間は [k_l, k_r) について
        if (k_r <= q_l || q_r <= k_l)
            return e;  // 交差しない
        if (q_l <= k_l && k_r <= q_r)
            return data[k];  // 完全に含む→受け止める
        else
        {
            int vl = _query(q_l, q_r, k * 2 + 1, k_l, (k_l + k_r) / 2);
            int vr = _query(q_l, q_r, k * 2 + 2, (k_l + k_r) / 2, k_r);
            return vl | vr;
        }
    }
};

void solve()
{
    int N;
    cin >> N;
    SegTree st(5000000);

    string S;
    cin >> S;

    REP0 (i, S.length())
    {
        st.update(i, S[i]);
    }

    int Q;
    cin >> Q;
    REP0 (_, Q)
    {
        int cmd;
        cin >> cmd;
        if (cmd == 1)
        {
            int i;
            char c;
            cin >> i >> c;
            st.update(i - 1, c);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            cout << __builtin_popcount(st.query(l - 1, r)) << endl;
        }
    }
}

int main(int argc, char const* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 66708
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
ll k;

int dig(long long x){
    int ret = 0;
    while(x){
        ret += x % 10;
        x /= 10;
    }
    return ret;
}
double s(long long x){
    return (double)x / (double)dig(x);
}
long long f(long long n){
    if(n <= 8) return n+1;
    int d = (int)log10(n) + 1;
    double MIN = (double)LONG_MAX;
    long long res;
    for(ll i = 0;i <= d;i++){
        if(MIN > s(qp(10,i+1)*(n/qp(10,i+1) + 1)-1)){
            MIN = s(qp(10,i+1)*(n/qp(10,i+1) + 1)-1);
            res = qp(10,i+1)*(n/qp(10,i+1) + 1)-1;
        }
    }
    return res;
}

int main(void){
    cin >> k;
    long long n = 9;
    for(int i = 0;i < k;i++){
        if(i <= 8) n = i+1;
        else n = f(n+1);
        printf("%lld\n",n);
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}


int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int q;
    cin >> q;
    while(q--){
        ll a, b;
        cin >> a >> b;
        if((a == b) || (abs(a - b) == 1)){
            cout << 2 * min(a,b) - 2 << endl;
        }
        else{
            ll c = sqrt(a * b);
            if(c * c == a * b){
                c--;
            }
            if(c * (c + 1) >= a* b){
                cout << 2 * c - 2 << endl;
            }
            else{
                cout << 2 * c - 1 << endl;
            }
        }

    }

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int l, r;
	cin >> l >> r;
	if (r / 2019 != (l - 1) / 2019) {
		cout << 0 << endl;
		return 0;
	}
	int ans = INF;
	for (int i = l; i < r; i++) {
		for (int j = i + 1; j <= r; j++)ans = min(ans, i * j % 2019);
	}
	cout << ans << endl;
	return 0;
}

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

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

  int n, k;
  cin >> n >> k;

  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  
  sort(v.begin(), v.end());

  int ans = 0;
  for (int i = 0; i < k; i++)
  {
    ans += v.at(i);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[m+1],b[m+1];
  vector<vector<int> > g(n+1);
  rep(i,1,m+1){
    cin >> a[i] >> b[i];
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  queue<int> q;
  q.push(1);

  int prev[n+1];
  rep(i,0,n+1) prev[i] = -1;

  while(!q.empty()){
    int tmp = q.front();
    q.pop();
    rep(i,0,g[tmp].size()){
      int v = g[tmp][i];
      if(prev[v]==-1){
        prev[v] = tmp;
        q.push(v);
      }
    }
  }
  rep(i,2,n+1){
    if(prev[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  rep(i,2,n+1) cout << prev[i] << endl;
  return 0;
}

Measured memory_bytes: 11684
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int r,g,b;cin>>r>>g>>b;
    YN((10*g+b)%4==0);

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int arr[a];
	for(int i=0; i<a; i++)
		cin >> arr[i];
	int count = 0;
	for(int i=0; i < a; i++)
	{
		int temp = i;
		for(int j= i + 1; j<a; j++)
		{
			if(arr[j] < arr[temp])
				temp = j;
		}
		if(temp != i)
		{
			count++;
			int hehe = arr[temp];
			arr[temp] = arr[i];
			arr[i] = hehe;
		}
	}
	if(count > 1) printf("NO");
	else          printf("YES");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _001_FindingMissingCards
{
    /*
     */

    class Program
    {
        static void Main()
        {
            string line_1st = Console.ReadLine();
            string []line_1st_split = line_1st.Split(' ');
            int n = Convert.ToInt32(line_1st_split[0]);
            int m = Convert.ToInt32(line_1st_split[1]);
            
            int [,] a = new int [n,m];
            int[] b = new int[m];
            int[] c = new int[n];

            for (int i = 0; i < n; i++)
            {
                string line_matrix = Console.ReadLine();
                string[] line_matrix_split = line_matrix.Split(' ');
                for (int j = 0; j < m; j++)
                {
                    a[i, j] = Convert.ToInt32(line_matrix_split[j]);
                }
            }
            for (int i = 0; i < m; i++)
            {
                string line_vector = Console.ReadLine();
                b[i] = Convert.ToInt32(line_vector);

            }
            for (int i = 0; i < n; i++)
            {
                c[i] = 0;
                for (int j = 0; j < m; j++)
                {
                    c[i] += a[i,j]*b[j];
                }
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("{0}", c[i]);
            }

        }
    }
}

Measured memory_bytes: 9288
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

int d[120][120];

int main() {
    int n, m, s, t1, t2;
    while (cin >> n >> m >> s >> t1 >> t2, n) {
        s--; t1--; t2--;
        fill_n(*d, 120 * 120, INF);
        rep(i, n) d[i][i] = 0;
        rep(i, m) {
            int a, b, c; scanf("%d%d%d", &a, &b, &c);
            a--; b--;
            d[a][b] = c;
        }
        rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
        int ans = INF;
        rep(i, n) {
            chmin(ans, d[s][i] + d[i][t1] + d[i][t2]);
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

const int N = (int) 2e5;
long long s[N + 1];
int a[N];
vector<int> bit;

int get(int x) {
	int res = 0;
	while (x >= 0) {
		res += bit[x];
		x -= ~x & (x + 1);
	}
	return res;
}

void update(int x, int delta) {
	while (x < (int) bit.size()) {
		bit[x] += delta;
		x |= x + 1;
	}
}

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= k;
		s[i + 1] = s[i] + a[i];
	}
	vector<long long> v (s, s + n + 1);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	bit.assign(v.size(), 0);
	long long res = 0;
	for (int i = 0; i <= n; ++i) {
		int p = lower_bound(v.begin(), v.end(), s[i]) - v.begin();
		res += get(p);
		update(p, 1);
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin>>n>>m;
  int A[n + 1];
  memset(A, 0, sizeof(A));
  for(int i = 0; i < m; i++) {
    int a, b;
    cin>>a>>b;
    A[a]++;
    A[b + 1]--;
  }
  int  ans = 0;
  for(int i = 1; i <= n; i++) {
    A[i] += A[i - 1];
   	if(A[i] == m)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
N,C = map(int,input().split())
imos = [[0]*100005 for i in range(30)]
for i in range(N):
    s,t,c = map(int,input().split())
    s -= 1
    c -= 1
    imos[c][s] += 1
    imos[c][t] -= 1
for c in range(C):
    for i in range(1,100005):
        imos[c][i] += imos[c][i-1]
for c in range(C):
    for i in range(1, 100005):
        if imos[c][i]:
            imos[c][i] = 1

ans = 0
for i in range(100005):
    cnt = 0
    for c in range(C):
        cnt += imos[c][i]
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 69720
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cmath>
#include <utility>
#include <map>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r;
    else
        cout << r + 100 * (10 - n);
    //cin.close();
    //cout.close();
    return 0;
}

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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    long long int n;
    long long int sum = 0;
    cin >> n;

    for(int i=1; i<=n; i++){
        if(!(i%3 == 0 || i%5 == 0)){
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 1; i <= 1000; i++){
        if(i*108/100 - i == a && i*110/100 - i == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3600
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


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

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    dp = [[0]*(W+1) for _ in range(N+1)]

    # init
    # update
    for i in range(1, N+1):
        for w in range(W+1):
            if w-items[i-1][0] >= 0:
                dp[i][w] = max(dp[i-1][w], dp[i-1]
                               [w-items[i-1][0]]+items[i-1][1])
            else:
                dp[i][w] = dp[i-1][w]

    print(max(dp[N]))


def solve2():
    dp = [0]*(W+1)
    for i in range(N):
        for w in reversed(range(W+1)):
            if w-items[i][0] >= 0:
                dp[w] = max(dp[w], dp[w-items[i][0]]+items[i][1])
    print(dp[-1])


solve2()


Measured memory_bytes: 41708
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


M,M = nm()
A  = nl()
As = sorted(A,reverse=True)
# rint(As)
s = sum(A)
# print(s)
limit=(s + 4*M -1) // (4 *M )
if As[M-1] >= limit:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            :oyhhhhhhyo:    
#define next         .sdNNNmNNNNNNNmds. 
#define y0          -hNNNNy`yNNNNNN`/Nh-
#define y1          mNNNNNd+dNNNNNN+sNNm
#define yn          mNNNNNNNNy--:smNNNms
#define tm          .+oooooosyysooooo+- 
#define read               :yhy/        
#define rank              :mNmo         
#define index              ... 
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

k = 0
for v in c.values():
    if v == 1:
        continue
    else:
        k += cmb(v, 2)

for a in al:
    if c[a] == 1:
        print(k)
    elif c[a] == 2:
        print(k-cmb(c[a], 2))
    else:
        print(k-cmb(c[a], 2)+cmb(c[a]-1,2))


Measured memory_bytes: 33940
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<long> ss(A), ts(B), xs(Q);
  for (int i = 0; i < A; i++) {
    cin >> ss[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> ts[i];
  }
  for (int i = 0; i < Q; i++) {
    cin >> xs[i];
  }

  for (int i = 0; i < Q; i++) {
    long ans = LONG_MAX;
    long x = xs[i];

    auto s_high = lower_bound(ss.begin(), ss.end(), x);
    auto s_low = s_high - 1;
    auto t_high = lower_bound(ts.begin(), ts.end(), x);
    auto t_low = t_high - 1;

    if (s_high != ss.end() && t_high != ts.end()) {
      long tmp = *s_high - x;
      ans = min(ans, tmp + abs(*s_high - *t_high));
    }
    if (s_high != ss.end() && t_low != ts.begin() - 1) {
      long tmp = *s_high - x;
      ans = min(ans, tmp + abs(*s_high - *t_low));
    }
    if (s_low != ss.begin() - 1 && t_high != ts.end()) {
      long tmp = x - *s_low;
      ans = min(ans, tmp + abs(*s_low - *t_high));
    }
    if (s_low != ss.begin() - 1 && t_low != ts.begin() - 1) {
      long tmp = x - *s_low;
      ans = min(ans, tmp + abs(*s_low - *t_low));
    }

    if (t_high != ts.end() && s_high != ss.end()) {
      long tmp = *t_high - x;
      ans = min(ans, tmp + abs(*t_high - *s_high));
    }
    if (t_high != ts.end() && s_low != ss.begin() - 1) {
      long tmp = *t_high - x;
      ans = min(ans, tmp + abs(*t_high - *s_low));
    }
    if (t_low != ts.begin() - 1 && s_high != ss.end()) {
      long tmp = x - *t_low;
      ans = min(ans, tmp + abs(*t_low - *s_high));
    }
    if (t_low != ts.begin() - 1 && s_low != ss.begin() - 1) {
      long tmp = x - *t_low;
      ans = min(ans, tmp + abs(*t_low - *s_low));
    }

    cout << ans << endl;
  }

  return 0;
}

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

int main(){
    int a[3];
    for( int i = 0; i < 3; i++ ) cin >> a[i];
    sort(a, a+3);
    int tmp = 0;
    tmp += a[2] - a[1];
    a[0] += tmp;
    int tmp2 = a[2] - a[0];
    if( tmp2 % 2 == 1){
        tmp2 /= 2;
        tmp2 += 2;
    }
    else tmp2 /= 2;
    tmp += tmp2;
    cout << tmp << endl; 


    // for( int i = 0; i < 3; i++ ) cout << a[i] << endl;


    return 0;
}

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

int main(){
  long long  N;
  cin>>N;
  long long a[N];
  long long cnt=0;
  long long temp=0;
  for(long long i=0;i<N;i++){
    cin>>a[i];
    temp=a[i];
    //cout<<temp<<endl;
    while(temp%2==0){
      temp/=2;
      cnt++;
    }
    //cout<<i<<" "<<temp<<" "<<cnt<<endl;
  }
  cout<<cnt<<endl;
  return 0;
}
  
       

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h, w, m;
    cin >> h >> w >> m;
    ump<ll, ll> rows, cols;
    ump<ll, ll> rows2, cols2;
    vector<P> v(m);
    rep(i, m) {
        ll h1, w1;
        cin >> h1 >> w1;
        rows[h1]++, cols[w1]++;
        rows2[h1]++, cols2[w1]++;
        v[i] = P(h1, w1);
    }
    ll mx1 = 0;
    ll x;
    each(e, rows) {
        if (e.second > mx1) {
            mx1 = e.second;
            x = e.first;
        }
    }
    rep(i, m) {
        if (v[i].first == x) cols[v[i].second]--;
    }
    ll mx2 = 0;
    ll y;
    each(e, cols) {
        if (e.second > mx2) {
            mx2 = e.second;
            y = e.first;
        }
    }
    ll ans1 = mx1 + mx2;

    mx2 = 0;
    each(e, cols2) {
        if (e.second > mx2) {
            mx2 = e.second;
            y = e.first;
        }
    }
    rep(i, m) {
        if (v[i].second == y) rows2[v[i].first]--;
    }
    mx1 = 0;
    each(e, rows2) {
        if (e.second > mx1) {
            mx1 = e.second;
            x = e.first;
        }
    }
    ll ans2 = mx1 + mx2;

    cout << max(ans1, ans2) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 3e5 + 5;

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

  ll n;
  cin >> n;
  vector < ll > a(n + 1), b(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  b[1] = a[n];
  for(int i = 1; i < n; i += 2){
    b[1] += a[i] - a[i + 1];
  }

  for(int i = 2; i <= n; i++){
    b[i] = 2 * a[i - 1] - b[i - 1];
  }

  for(int i = 1; i <= n; i++) cout << b[i] << " ";
  cout << endl;
}


Measured memory_bytes: 2944
class Heap:
    def __init__(self, L):
        self.H = len(L)
        self.heap = L
        self.heap.insert(0, 0)

    def parent(self, i):
        return self.heap[i // 2]

    def left(self, i):
        return self.heap[2 * i]

    def right(self, i):
        return self.heap[2 * i + 1]

H = int(input())
L = list(map(int, input().split()))
heap = Heap(L)
for i in range(1, H + 1):
    print("node {}: key = {}, ".format(i, heap.heap[i]), end='')
    if i != 1:
        print("parent key = {}, ".format(heap.parent(i)), end='')
    if i * 2 <= H:
        print("left key = {}, ".format(heap.left(i)), end='')
    if i * 2 + 1 <= H:
        print("right key = {}, ".format(heap.right(i)), end='')
    print()

Measured memory_bytes: 7824
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(H: int, W: int, a: "List[str]"):
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1

    for i in range(1, W):
        dp[0][i] = dp[0][i-1] if a[0][i] == '.' else 0

    for i in range(1, H):
        dp[i][0] = dp[i-1][0] if a[i][0] == '.' else 0
    
    for i in range(1, H):
        for j in range(1, W):
            if a[i][j] == '.':
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
    return dp[-1][-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, a)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45624
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int A, B;
    cin >> A >> B;
    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;
    return 0;
}

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

int N,M,S,T,a;
vector<int> value(400000,-3);
queue<int> q;

void wfs(vector<vector<int>>&graph){
  if(q.empty()==0){
    a=q.front();
    q.pop();
    for(int i=0; i<graph.at(a).size(); i++){
      if(value.at(graph.at(a).at(i))==-3){
        q.push(graph.at(a).at(i));
        value.at(graph.at(a).at(i))=value.at(a)+1;
      }
    }
  wfs(graph);
  }
}
 
int main(){
  cin >> N >> M;
  vector<int> u(M),v(M);
  for(int i=0; i<M; i++){
    cin >> u.at(i) >> v.at(i);
  }
  cin >> S >> T;
  
  vector<vector<int>> graph3(3*N+1);
  for(int i=0; i<M; i++){
    graph3.at(u.at(i)*3-2).push_back(v.at(i)*3);
    graph3.at(u.at(i)*3-1).push_back(v.at(i)*3-2);
    graph3.at(u.at(i)*3).push_back(v.at(i)*3-1);
  }
  
  S=S*3-2;
  T=T*3-2;
  
  q.push(S);
  value.at(S)=0;
  wfs(graph3);
  
  cout << value.at(T)/3 << endl;
}

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

int main() {
  string s,t;
  cin >> s>>t;
  int ls,lt;
  ls=s.size();
  lt=t.size();

  int dp[3001][3001];
  //dp[i+1][j+1]= 0-i番目の文字列Sと0-j番目の文字列の最長のLCS`
  
  for(int i=0;i<=ls;i++){
    for(int j=0;j<=lt;j++){
       if(i==0|| j==0) dp[i][j] = 0;
       else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1; 
      //もし最後の文字が一致してるならlcsに使う
      //そうでないなら最後の文字は同時には使っても意味がないのでdp[i][j+1] dp[i+1][j]
      else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      
    }
  }

  int i=ls; int j=lt;
  string str="";
  
  while(i>0 && j>0){
    if(s[i-1]==t[j-1])
    {
      str.push_back(s[i-1]);//もし共通ならその文字を足す
      i--;
      j--;
    }else if(dp[i-1][j]>dp[i][j-1]){ //共通文字列の長さが長い方に行く
       i--;
    }else j--;
    //これを繰り返すと長い方に導かれて最後はstrがこたえ
  }
  reverse(str.begin(),str.end());
    cout<<str<<endl;
   
}

Measured memory_bytes: 35456
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,e[300010],w[300010];
string s;

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

    REP(i,n) e[i+1] = e[i] + (s[i]=='W');
    REP(i,n) w[n-i] = w[n-i+1] + (s[n-i-1]=='E');
    int ret = mod;
    FOR(i,1,n+1) ret = min(ret,e[i]+w[i]);
    cout << ret-1 << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#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 Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a;
    cin >> a;
    pr(3*a*a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,maxn;
	scanf("%lld%lld",&n,&m);
	if(m%n==0)
	{cout<<m/n;
	return 0;}
	for(long long i=1;i<=m;i++)
	{
		if(m%i==0&&n*i<=m)
		{
		maxn=i;}
		if(n*i>m)break;
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] monsters = new int[n + 1];
        int[] savers = new int[n];
        
        for (int i = 0; i <= n; i++) {
            monsters[i] = sc.nextInt();
        }
        
        for (int i = 0; i < n; i++) {
            savers[i] = sc.nextInt();
        }
        
        long count = 0;
        for (int i = 0; i < n; i++) {
            if (savers[i] <= monsters[i]) {
                count += savers[i];
                monsters[i] -= savers[i];
            } else {
                count += monsters[i];
                savers[i] -= monsters[i];
                monsters[i] = 0;
                if (savers[i] < monsters[i + 1]) {
                    count += savers[i];
                    monsters[i + 1] -= savers[i];
                } else {
                    count += monsters[i + 1];
                    monsters[i + 1] = 0;
                }
            }
        }
        
        
        System.out.println(count);
    }
}


Measured memory_bytes: 82344
#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
int n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	if(n==1)
		printf("Hello World");
	else
		cout<<read()+read();
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

int n,A[22];                                               

bool solve(int i,int m){ 
    if(m==0)return 1;
    if(i>=n)return 0;
    bool res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}
int main(){
    int q,M;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>M;
        if(solve(0,M))cout<<"yes"<<"\n";
        else cout<<"no"<<"\n";
    }   
    return 0;
}



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

int match_alfa (char a, string alfa){
    int m;
    for (int i = 0; i < 27; i++){
        if( a == alfa[i]){
            m = i;
            break;
        }
    }
    return m;
}

int main(){
  //std::string a;
  int n;
  int m;
  std::string a;
  std::string b;
  cin >> n;
  cin >> a;
  
  string alfa = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < a.length(); i++) {
    m = match_alfa(a[i],alfa);
    a[i] = alfa[m+n];
	}
  cout <<  a << endl;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	string s;
	cin >> s;
	int flag = 1;
	for(int i = 0; i < s.size(); i++){
		if(i%2 == 0){
			if(s[i] == 'L') flag = 0;
		}else{
			if(s[i] == 'R') flag = 0;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto& e : a) cin >> e;

  vector<set<int>> s(n);
  int t = 0;
  for (auto e : a) {
    int i;
    for (i = t; i > 0; i--) {
      auto it = s[i - 1].lower_bound(e);
      if (it != s[i - 1].end() && *it - e <= k) break;
      if (it != s[i - 1].begin() && e - *(--it) <= k) break;
    }
    s[i].insert(e);
    t = max(t, i + 1);
  }
  cout << t << endl;
}


Measured memory_bytes: 32496
/*_BELIEVE_*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;

void solve()
{
    int n;
    cin>>n;
    
    vector<double> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];
        
    sort(all(v));
    
    for(int i=1;i<n;++i)
    {
        v[i]=(v[i]+v[i-1])/2;
    }
    
    cout<<v[n-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if(S==U) --A;
	else --B;
	cout << A << ' ' << B << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

An = np.array(A)
Bn = np.array(B)
Cn = np.array(C)

An.sort()
Bn.sort()
Cn = -Cn
Cn.sort()

AB = np.searchsorted(An,Bn,side='left')
CB = np.searchsorted(Cn,-Bn,side='left')

print((AB*CB).sum())

Measured memory_bytes: 39828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  int count = 0;
  if (n % 2 == 1) {
    cout << count << endl;
    return 0;
  }

  count = d[n / 2] - d[n / 2 - 1];

  cout << count << endl;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
    int N,Q;
    cin >> N >> Q;
    string S;cin >> S;

    vector<int> vec(N+1,0);
    for (int i = 0;i<N;++i){
        if(i+1<N && S[i] == 'A' && S[i+1] == 'C'){
            vec[i+1] = vec[i] + 1;
        } else {
            vec[i+1] = vec[i];
        }
    }

    for (int j=0;j<Q;++j){
        int L,R; cin >> L >> R;
        --L,--R;
        cout << vec[R] - vec[L] << endl;
    }

}

Measured memory_bytes: 1408
a,b = 1,0
while a > 0:
    a=int(input())
    if a == 0:
        break
    b = 1000 - a
    c = b // 500
    d = b % 500 // 100
    e = b % 100 // 50
    f = b % 50 // 10
    g = b % 10 // 5
    h = b % 5
    print(c + d + e + f + g + h)


Measured memory_bytes: 5592
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

int main() {
  char buf[8192];
  scanf("%s", buf);
  std::string s=buf;

  std::set<std::string> ss;
  for (size_t i=0; i<s.length(); ++i) {
    for (size_t j=1; j<=5; ++j) {
      ss.emplace(s.substr(i, j));
    }
  }

  size_t K;
  scanf("%zu", &K);
  {
    size_t i=0;
    for (const std::string &s: ss) {
      if (s.empty()) continue;
      // fprintf(stderr, "%zu: %s\n", i+1, s.c_str());
      if (++i == K)
        return !printf("%s\n", s.c_str());
    }
  }
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>

#define ALL(a)  (a).begin(),(a).end()

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    vector<int> x;
    vector<int> y;

    double c = 0.0, l = 0.0, ans = 0.0;

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
         int temp;
         cin >> temp;
         x.push_back (temp);
         cin >> temp;
         y.push_back (temp);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l += sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2));
        }
    }

    c = (n * (n - 1)) / 2;
    ans = (n - 1) * l / c;

    cout << fixed << setprecision(10);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 111111
using namespace std;

int n,num[maxn],top;

bool check(int x){
    top=0;
    while(x){
        num[++top]=x%10;
        x/=10;
    }
    for(int i=top;i>1;i--)
        if(num[i]!=num[i-1])
            return 0;
    return 1;
}

signed main()
{
    scanf("%d",&n);
    for(int i=max(n,111);i<=10000;i++){
        if(check(i)){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> a(N, vector<pair<int, int>> (N, make_pair(-1,-1)));
    int tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        for(int j = 0; j < tmp; j++){
            cin >> a.at(i).at(j).first >> a.at(i).at(j).second;
            a.at(i).at(j).first--;
            //printf("%d %d\n", a.at(i).at(j).first, a.at(i).at(j).second);
        }
    }
    //cout << endl;
    int ans = 0;
    int tmp2;
    for(int S = 0; S < pow(2,N); S++){
        tmp2 = 1;
        for(int i = 0; i < N; i++){
            if( S>>i & 1 ){
                for(pair<int, int> j : a.at(i)){
                    if(j.first == -1){
                        break;
                    }
                    if( j.second != (S>>j.first & 1)){
                        tmp2 = 0;
                        //printf("%d %d %d %d\n", S, i, j.first, j.second);
                        continue;
                    }
                    //printf("%d %d %d %d\n", S, i, j.first, j.second);
                }
            }
            if(!tmp2){
                continue;
            }
        }
        if(!tmp2){
            continue;
        }
        else{
            ans = max(ans, __builtin_popcount(S));
        }
    }
    
    printf("%d\n", ans);
    
}


Measured memory_bytes: 256
INTEGER N
CHARACTER(100) S
CHARACTER(26)::A="abcdefghijklmnopqrstuvwxyz"
INTEGER B,P!PはパワフルのP
INTEGER M,U!前、後ろ
READ*,N,S
P=0
DO I=1, N-1!前の文字列の長さを決めています
  B=0
  DO J=1,26
    M=SCAN(S,A(J:J))
    IF(M==0)CYCLE!後ろのif文にいれてMとUを並べて書いた方が綺麗に見えるけどこっちのが処理少なくて済むはず
    U=SCAN(S,A(J:J),.TRUE.)
    IF( M<=I .AND. I<U )B=B+1
  END DO
  P=MAX(P,B)
END DO
PRINT"(I0)",P
END

Measured memory_bytes: 256