akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem131a(s))
}

fun problem131a(s: String): String {
    val str = s.toList()
    var result = "Good"
    (0..str.size).forEach { i ->
        if (i >= str.size - 1) return@forEach
        if (str[i] == str[i + 1]) {
            result = "Bad"
            return result
        }
    }
    return result
}

Measured memory_bytes: 31004
#include <bits/stdc++.h>
#define SE second
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define REP(i,a,b) for(long long i=a;i<b;i++)
#define PER(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl

using namespace std;

int main() {
    int A,B,C,D,E,F,a=0,b=0;
    cin >> A >> B >> C >> D >> E >> F;
    double aa=1,ab=0;

    for(int i=F/(100*A); i>=0; i--){
        for(int j=(F-i*100*A)/(100*B); j>=0; j--){
            double a=(i*A+j*B)*100;
            for(int k=0; k<=a*E/(100*C); k++){
                for(int h=0; h<=(a*E/100-k*C)/D; h++){
                    double b=k*C+h*D;
                    if(a!=0&&a+b<=F&&b*100/(a+b)>=ab*100/(aa+ab)){
                        aa=a;
                        ab=b;
                    }
                }
            }
        }
    }
    cout << aa+ab << ' ' << ab << endl;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}
int n;
string s;
bool ju[100100];

bool check(bool a, bool b, vector<bool> &da){
	da[0] = a, da[1] = b;
	rip(i,n,2){
		da[i] = (da[i-1] ^ da[i-2]^ju[i-1]);
	}
	return (da[n-1]^da[n-2]^ju[n-1]  == da[0])&(da[n-1]^da[0]^ju[0] == da[1]);
}

void out(vector<bool> &da){
	rip(i,n,0){
		if(da[i]) printf("W"); else printf("S");
	}
	cout << endl;
}

int main(){
	cin >> n >>s;
	s += s[0];
	rip(i,n,0) ju[i] = (s[i] == 'x');
	bool a = false, b = true;
	vector<bool> da(n);
	rip(i,2,0){
		rip(j,2,0){
			if(check(a,b,da)){
				out(da);
				return 0;
			}
			a^=true;
		}
		b^=true;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int X = Integer.parseInt(tokens[0]);
		int Y = Integer.parseInt(tokens[1]);
		int Z = Integer.parseInt(tokens[2]);

		X -= Z;
		int result = X / (Y + Z);
		System.out.println(result);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const double pi = 3.14159265358979;

long long n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	map<long long, long long> fac;
	for(long long i = 2; i * i <= n; i++)
		while(n % i == 0){
			fac[i]++;
			n /= i;
		}
	if(n > 1) fac[n]++;
	long long op = 0;
	for(auto &i : fac){
		long long l = 1, r = (int)1e7;
		for(int j = 0; j < 50; j++){
			long long mid = l + (r - l) / 2;
			if((mid * (mid + 1)) / 2 > i.second) r = mid;
			else l = mid;
		}
		op += l;
	}
	cout << op << "\n";
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

#define INT_MAX 2147483647

int main( void ){

	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v;
	vector<int> ans;
	for( int i = 1; i <= a; i++){
		if(a%i == 0 ) v.push_back(i);
	}
	for( int i = 1; i <= b; i++){
		if(b%i == 0 ){
			for( int j = 0; j < v.size(); j++ ){
				if( v[j] == i ) ans.push_back(i);
			}
		}
	}

	cout << ans[ans.size()-c] << endl;

	return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

template <typename T>
class WarshallFloyd {
private:
    int m_V;                   
    vector<vector<T>> m_d;
    
public:
    const T INF = std::numeric_limits<T>::max();
    WarshallFloyd(int V)
        : m_V(V) {

        // 辺のコストを初期化
        // 辺が存在しないときはINFとする
        m_d.resize(m_V, vector<T>(m_V, INF));
        REP(i,V) m_d[i][i] = 0;
    }
    void add_dir_edge(int from, int to, T cost) {
        m_d[from][to] = cost;
    }
    void add_undir_twoways(int v1, int v2, T cost) {
        add_dir_edge(v1, v2, cost);
        add_dir_edge(v2, v1, cost);
    }
    // 全点間の最短距離を求める
    vector<vector<T>> shortest_path() {
        REP(k, m_V) REP(i, m_V) REP(j, m_V) 
            // 辺が存在するときのみ短縮できる
            if(m_d[i][k] != INF && m_d[k][j] != INF)
                m_d[i][j] = min(m_d[i][j], m_d[i][k] + m_d[k][j]);
        return m_d;
    }
    // shortest_pathを呼んだあとに呼ぶこと
    bool has_negative_loop() {
        REP(i, m_V) {
            if (m_d[i][i] < 0) return true;
        }
        return false;
    }
};

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M, L;
    cin >> N >> M >> L;

    // 頂点間の距離を算出
    WarshallFloyd<ll> wf(N);
    REP(m, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        if (c <= L) {
            wf.add_undir_twoways(a, b, c);
        }
    }
    auto res = wf.shortest_path();

    // 距離がL以下の頂点間は補給なしでいけるので長さ1のエッジを張る
    WarshallFloyd<ll> wf2(N);
    REP(i, N - 1) {
        FOR(j, i + 1, N) {
            if (res[i][j] <= L) wf2.add_undir_twoways(i, j, 1);
        }
    }
    auto res2 = wf2.shortest_path();

    int Q;
    cin >> Q;
    REP(q, Q) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        if (res2[s][t] == wf2.INF) {
            cout << -1 << endl;
        } else {
            cout << (res2[s][t] - 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3456
a,b,c,x,y = map(int,input().split())
plan1 = a*x+b*y
plan2 = c*max(x,y)*2
plan3 = c*x*2+b*(y-x) if x<y else c*y*2+a*(x-y)
print(min(plan1,plan2,plan3))

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define umi unordered_map<int,int>
#define uml unordered_map<ll,ll>
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define inf 1000000000000000
#define md 998244353
#define endl "\n"

ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

ll gcd(ll a, ll b)
{ 
	return !b ? a : gcd(b, a % b); 
}
ll lcm(ll a, ll b)
{ 
	return (a / gcd(a, b)) * b; 
}
ll fastExponentiation(ll n, ll x, ll modulo) 
{
	ll res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}


ll power(ll n , ll p ){
	if(p==0)
	   return 1;
 
	 ll res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}


void solve()
{
	string s;
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5])
	cout<<"Yes\n";
	else
	cout<<"No\n";
	
	
}


int main()
{
	fastio
	
	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

}

Measured memory_bytes: 21972
#解答確認後
n=int(input())
aa=[[int(i) for i in input().split()] for i in range(n)]
bb=[[int(i) for i in input().split()] for i in range(n)]

#print(aa)
#print(bb)

import operator
aa.sort(key=operator.itemgetter(1),reverse=True)
bb.sort()
  
#print(aa)
#print(bb)

answer=0
for b in bb:
  xb,yb=b
  for a in aa:
    xa,ya=a
    if xa<xb and ya<yb:
      answer=answer+1
      aa. remove (a)
      #print(aa)
      #print(bb)
      #print(answer)
      break
      
print(answer)      
  


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <sstream>
using namespace std;

int main()
{
        stringstream ss;
        string s, p, line, str;
        vector<string> result;
        int cnt = 0;

        getline(cin, s);
        while(getline(cin, p), p != "END_OF_TEXT") {
                line += p;
                line += ' ';
        }

        ss << line;

        while(getline(ss, str, ' ')) {
                result.push_back(str);
        }

        for(int i = 0; i < result.size(); i++) {
                for(int j = 0; j < result[i].size(); j++) {
                        if(result[i][j] >= 0x41 && result[i][j] <= 0x5a) {
                                result[i][j] += 0x20;
                        }
                }
                if(result[i] == s) cnt++;
        }

        cout << cnt << endl;

        return 0;
}


Measured memory_bytes: 3212
#####################################################################################################
##### ナップサック問題 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C&lang=ja
#####################################################################################################


import sys
input = sys.stdin.readline

M, W = map(int, input().split())                                # M: 品物の種類 W: 重量制限

dp_min = 0                                                      # 総和価値の最小値


price_list = [0]
weight_list = [0]

for _ in range(M):
    weight, price = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)

# price_list = [0] + list(map(int, input().split()))              # item = 0 は 0 種類の品物を用いた場合に対応するため、参照されることはない。item = 1 で品物の 0 番目に対応させるためにインクリメントが必要となる。
# weight_list = [0] + list(map(int, input().split()))             # item = 0 は 0 種類の品物を用いた場合に対応するため、参照されることはない。item = 1 で品物の 0 番目に対応させるためにインクリメントが必要となる。

# dp[item <= M ][weight <= W]
dp = [[dp_min] * (W + 1) for _ in range(M + 1)]                       # 左端と上端の境界条件で W, M を一個ずつ多めに取る

for item in range(M+1):                                         # 左端の境界条件
    dp[item][0] = 0                                             # 重さ 0 を実現するのに必要な品物の個数は 0 個

# for weight in range(W+1):                                     # 上端の境界条件
#     dp[0][weight] = dp_max                                    # 0 種類の品物で実現できる重量は存在しない　（dpの初期化で自動的に課せる場合が多い）


for item in range(1,M+1):                                       # 境界条件を除いた M 回のループ（※ f[item] = g.f[item-i] の漸化式なので、list index out of range となる）
    for weight in range(1, W + 1):
        if weight < weight_list[item]:                          # weight (重量価値) < weight_list[item] (品物の重量) の時は無視してよい
            dp[item][weight] = dp[item - 1][weight]
        else:
            dp[item][weight] = max(dp[item-1][weight], dp[item-1][weight - weight_list[item]] + price_list[item])        # 重複なし: dp[item][weight - weight_list[item]] ⇒　dp[item-1][weight - weight_list[item]]

print(dp[M][W])

Measured memory_bytes: 147148
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n,m,x,y,xmax=0,ymin=0,t;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(i==0)
            xmax=t;
        else if(xmax<t)
            xmax=t;
    }
    for(int i=0;i<m;i++)
    {
        cin>>t;
        if(i==0)
            ymin=t;
        else if(ymin>t)
            ymin=t;
    }
    if(ymin<=y && xmax<ymin && ymin>x)
        cout<<"No War"<<endl;
    else
        cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

a,v = gets.split.map(&:to_i)
b,w = gets.split.map(&:to_i)
t = gets.to_i


if a < b
  at = a + v*t
  bt = b + w*t
  puts at >= bt ? "YES" : "NO"
else
  at = a - v*t
  bt = b - w*t
  puts at <= bt ? "YES" : "NO"
end


# 1 2
# 3 1
# 3

Measured memory_bytes: 14304
s=str(input())
count=0
for i in range(3):
    if s[i]=='R':
        count+=1
if count==0:
    print('0')
elif count==1:
    print('1')
elif count==2:
    if s[1]=='R':
        print('2')
    else:
        print('1')
else:
    print('3')

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

#define i64 long long int

i64 p5(int x) {
	i64 res = 1LL;
	for(int i=0;i<5;i++) res *= x;
	return res;
}

pair<i64, i64> calc(i64 x) {
	i64 lastA = 0;
	for(int i=1;;i++) {
		i64 A = p5(i);
		if(A-lastA>1e9) break;
		
		for(int j=0;j<i;j++) {
			i64 B = p5(j);
			if(A-B==x) return make_pair(i, j);
			if(A+B==x) return make_pair(i, -j);
		}
		lastA = A;
	}
	
	return make_pair(-1, -1);
}

int main() {
	i64 x;
	cin>>x;
	
	pair<i64, i64> p = calc(x);
	cout<<p.first<<' '<<p.second<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int n;
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[MAX_N][3];

void solve()
{
  for (int i = 0; i < 3; i++) dp[0][i] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      int m = 0;
      if (j == 0)
        dp[i + 1][j] = max(dp[i][1] + b[i], dp[i][2] + c[i]);
      else if (j == 1)
        dp[i + 1][j] = max(dp[i][0] + a[i], dp[i][2] + c[i]);
      else if (j == 2)
        dp[i + 1][j] = max(dp[i][0] + a[i], dp[i][1] + b[i]);
    }
  }
  int res = 0;
  for (int i = 0; i < 3; i++) res = max(res, dp[n][i]);
  cout << res << endl;
}

int main(void)
{
  cin >> n;
  REP(i, n) cin >> a[i] >> b[i] >> c[i];
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;
int n;
int arr[55];

int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	  cin>>n;
	 
	  for(int i=1;i<=n;i++)
	  cin>>arr[i];
	  int mx,mn;
	  bool b=false;
	  int idx,idy;
	  mx=*max_element(arr+1,arr+n+1);
	  for(int i=1;i<=n;i++)
	  {
	  	if(arr[i]==mx)
	  	idx=i;
	  }
	  mn=*min_element(arr+1,arr+n+1);
	  for(int i=1;i<=n;i++)
	  if(arr[i]==mn)
	  idy=i;
	  cout<<2*n-1<<endl;
	  if(abs(mx)>=abs(mn))
	  {
	  	b=true;
	  for(int i=1;i<=n;i++)
	  cout<<idx<<" "<<i<<endl;

	  }
	  else
	  {
	  	for(int i=1;i<=n;i++)
	  	cout<<idy<<" "<<i<<endl;
	  }
	  if(b)
	  for(int i=1;i<n;i++)
	  {
	  	cout<<i<<" "<<i+1<<endl;
	  }
	  else
	  for(int i=n;i>1;i--)
	  cout<<i<<" "<<i-1<<endl;
}


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

const double eps=1e-8;

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		double x[4], y[4];
		for(int j=0; j<4; ++j) scanf(" %lf %lf", &x[j], &y[j]);
		
		double dx1=x[1]-x[0], dx2=x[3]-x[2], dy1=y[1]-y[0], dy2=y[3]-y[2];
		bool ans=true;
		if(dx1==0){
			if(dx2!=0) ans=false;	
		}
		else{
			double a=dx2/dx1, b=dy2/dy1;
			if(fabs(a-b)>eps) ans=false; 
		}
		
		if(ans) printf("YES\n");
		else printf("NO\n");
	}
}

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

signed main() {
  string s;
  cin >> s;
  int i = 0;
  while (i + 5 <= int(s.size())) {
    if (!(s[i] == 'd' || s[i] == 'e')) {
      cout << "NO\n";
      return 0;
    }
    else if (s[i] == 'd') {
      if (s.substr(i, 5) != "dream") {
        cout << "NO\n";
        return 0;
      }
      else if (i + 7 <= int(s.size())) {
        if (s[i + 5] == 'e' && s[i + 6] == 'r') {
          if (i + 8 <= int(s.size()) && s[i + 7] == 'a') 
            i += 5;
          else if (i + 7 <= int(s.size()))
            i += 7;
          else
            i += 5;
        }
        else
          i += 5;
      }
      else 
        i += 5;
    }
    else {
      if (s.substr(i, 5) != "erase") {
        cout << "NO\n";
        return 0;
      }
      else if (i + 6 <= int(s.size())) {
        if (s[i + 5] == 'r') {
          if (i + 7 <= int(s.size()) && s[i + 6] == 'a') 
            i += 5;
          else if (i + 6 <= int(s.size()))
            i += 6;
          else
            i += 5;
        }
        else
          i += 5;
      }
      else 
        i += 5;
    }
  }
  if (int(s.size()) == i)
    cout << "YES\n";
  else
    cout << "NO\n";
}

Measured memory_bytes: 512
<?php
$input = trim(fgets(STDIN));
$len = strlen($input);

$len = strlen($input);

for ($i = 0; $i < $len; $i++) {
  $currentChar = $input[$i];
  if ($i % 2 === 0 && $currentChar === 'L' ||
      $i % 2 === 1 && $currentChar === 'R'
     ) {
    echo 'No';
    return;
  }
}

echo 'Yes';

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

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

  int t = 1;
  while(true){
    if((t * (t + 1)) / 2.0 >= x){
      break;
    }
    t++;
  }
  cout << t << endl;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {

	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = b-a;
    int sum =0;
    for(int i=1;i<=c;i++){
    	sum = sum +i;
    }
    int x = sum-b;
    System.out.println(x);
	}
}

Measured memory_bytes: 21844
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
l = 0
m = 0
ans = 0
for i in range(n):
    if l == 0:
        m = t[i]
        l += 1
    elif l < c:
        if m + k >= t[i]:
            l += 1
        else:
            ans += 1
            l = 1
            m = t[i]
    else:
        ans += 1
        l = 1
        m = t[i]
ans += 1
print(ans)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }

  bool is_ok = true;
  rep(i, N - 1)
  {
    if (A[i + 1] < A[i])
      continue;

    if (A[i + 1] == A[i] || A[i + 1] == A[i] + 1)
      continue;

    is_ok = false;
  }

  if (A[0] != 0)
    is_ok = false;

  if (!is_ok)
  {
    cout << -1 << endl;
    return 0;
  }

  long long ans = 0;
  rep(i, N - 1)
  {
    if (A[i] + 1 == A[i + 1])
      ans++;
    else
      ans += A[i + 1];
  }

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

Measured memory_bytes: 4860
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define ll long long
using namespace std;
const int N=55,M=2510;
int a[N];
ll dp[2][N][M];

int main(){
	int n,m;scanf("%d%d",&n,&m);
	fr(i,1,n) scanf("%d",&a[i]);
	dp[0][0][0]=1;
	int nw=0;
	fr(i,1,n){
		memset(dp[nw^1],0,sizeof dp[nw^1]);
		fr(j,0,i-1) fr(k,0,2500){
			if(!dp[nw][j][k]) continue;
			dp[nw^1][j][k]+=dp[nw][j][k];
			dp[nw^1][j+1][k+a[i]]+=dp[nw][j][k];
		}
		nw^=1;
	}
	ll ans=0;
	fr(i,1,n) ans+=dp[nw][i][i*m];
	printf("%lld\n",ans);
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

int n;


const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;

int fac[maxn], inv[maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}

int comb(int n, int m){
    if(m > n or m < 0) return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int dp[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    pre_comb();
    cin >> n; 
    if(n == 2){
        cout << 1 << endl;
    }else if(n == 3){
        cout << 4 << endl;
    }else{
        for(int i = 0;i <= n - 1;i++){
            dp[i] = 1LL * comb(i - 1, n - 1 - i) * fac[i] % mod * fac[n - 1 - i] % mod;
        } 
        int ans = 0;
        for(int i = n - 1;i >= 1;i--){
            dp[i] = (dp[i] - dp[i - 1] + mod) % mod;
            ans = (ans + 1LL * i * dp[i]) % mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{   
    int n;cin>>n;
    int a[n];REP(i,n)cin>>a[i];
    int ans=0;
    REP(i,n){
        if(a[i]==i+1){
            ans++;
            if(i+1<n&&a[i+1]==i+2)i++;
        }
    }cout<<ans<<endl;
}

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


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define ll long long


int main()
{
	int a, b;
	cin >> a >> b;

	int ans = 0;
	if (a <= 5)
	{
	}
	else if (a <= 12)
	{
		ans = b / 2;
	}
	else
	{
		ans = b;
	}

	cout << ans << endl;

	return 0;
}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

/*map<ll, ll> mp;
ll ans(ll v, ll u, ll w) {
    ll total = 0;
    while (v != u) {
        if (v > u) {
            total += mp[v];
            mp[v] += w;
            v /= 2;
        } else {
            total += mp[u];
            mp[u] += w;
            u /= 2;
        }
    }
    return total;
}*/

void solve() {
    int n;
    cin >> n;
    ll total = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int cur_max = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] < cur_max) total += cur_max - a[i];
        else cur_max = a[i];
    }
    cout << total << endl;
}

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

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

    return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";

ll bittree[1000001];
void update(ll index,ll n, ll val){
	for(ll i=index;i<=n;){
		bittree[i] = max(bittree[i],val);
		i += i & (-i);
	}
}

ll get(ll u, ll n){
	ll index = u;
	ll sum = 0;
	for(ll i=index;i>0;){
		sum = max(bittree[i],sum);
		i -= i & (-i);
	}
	return sum;
}

void solve(){
	ll n;
	cin>>n;
	vector<ll>height(n),val(n);
	vector<pair<ll,ll>>pair;
	for(ll i=0;i<n;i++){
	   	cin>>height[i];
	   	pair.pb({height[i],i});
	}
	for(auto &i : val) cin>>i;
	sorted(pair);
	memset(bittree,0,sizeof(bittree));
	ll ans = 0;
	for(ll i=0;i<n;i++){
		ll res = val[pair[i].second] + get(pair[i].second+1,n);
		ans = max(ans,res);
		update(pair[i].second+1,n,res);
	}
	ans = max(ans,get(n,n));
	// t2(bittree)
	// t1(endl)
	t1(ans);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--){
		solve();
	}

return 0;
}

Measured memory_bytes: 17392
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

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

  if(n>=400 && n<=599)
    cout<<8<<endl;
  else if(n>=600 && n<=799)
    cout<<7<<endl;
  else if(n>=800 && n<=999)
    cout<<6<<endl;
  else if(n>=1000 && n<=1199)
    cout<<5<<endl;
  else if(n>=1200 && n<=1399)
    cout<<4<<endl;
  else if(n>=1400 && n<=1599)
    cout<<3<<endl;
  else if(n>=1600 && n<=1799)
    cout<<2<<endl;
  else
    cout<<1<<endl;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = a * x + b * y;
	Foz(i, max(x, y) + 1) {
		int t = 2 * c * i +
		max(0, x - i) * a +
		max(0, y - i) * b;
		ckmin(ans, t);
	}
	cout << ans << '\n';
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    bool ans = false;
    rep(i, N + 1) {
        rep(j, M + 1) {
            ll cnt = i * (M - j) + j * (N - i);
            if (cnt == K){
                ans = true;
                break;
            }
        }
    }
    if(ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	int now=0;
	cin>>s;
	int ans[2];
	ans[0]=ans[1]=0;
	for (int i=0;i<s.size();i++){
		s[i]-='0';
		if (s[i]==now) ans[0]++;
		else ans[1]++;
		now^=1;
	}
	cout<<min(ans[0],ans[1]);
}

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

int main(){
	int D,G; cin>>D>>G;
	int P[D], C[D];
	rep(i, D) cin>>P[i]>>C[i];
	int ans = INT_MAX;
	rep(bin, 1<<D){
		int cnt = 0, tot = 0, rest_max_bit = -1;
		rep(i, D)
			if(bin & 1<<i){
				int t = (i + 1)*100;
				tot += P[i]*t + C[i];
				cnt += P[i];
			}
			else rest_max_bit = i;
		if(tot < G){
			int t = (rest_max_bit + 1)*100;
			int p = (G - tot + t - 1)/t;
			if(p >= P[rest_max_bit]) continue;
			cnt += p;
		}
		ans = min(ans, cnt);
	}
	cout<< ans <<endl;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
vector<int> E[100050];
vector<vector<int>> dist(2,vector<int>(100050));

void dfs(int u,int pre,int i){
    for(int v : E[u]){
        if(v == pre)continue;
        dist[i][v] = dist[i][u] + 1;
        dfs(v,u,i);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    for(int i=0;i<n-1;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    dfs(v,-1,0);
    dfs(u,-1,1);
    int ans = 0;
    for(int i=0;i<n;++i){
        if(dist[0][i] > dist[1][i]){
            ans = max(dist[0][i],ans);
        }
    }
    cout << ans-1 << endl;
    return 0;
}



Measured memory_bytes: 12920
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    rep(i, 1, n) {
        if (a[i - 1] > a[i]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
void send(int a,int b,int c,int d){
  printf("%d %d %d %d\n",a,b,c,d);
}
struct edge{
  int to;
  ll cost;
};
int n;
vector<edge> G[max_n];
ll color[max_n]={0};
void solve(int u, int c){
  color[u] = c;
  for(int i=0 ; i<G[u].size();i++){
    edge e = G[u][i];
    if(color[e.to]==0){
      if(e.cost%2==0){
        solve(e.to, c);
      }else{
        solve(e.to,-c);
      }
    }
  }
}
int main(){
  cin >> n;

  rep(i,0,n-1){
    int x,y; ll z;   cin >> x >> y >> z;
    --x;  --y;
    G[x].pb((edge){y,z});
    G[y].pb((edge){x,z});
  }
  solve(0, 1);
  rep(i,0,n){
    int ans = color[i];
    if(ans<0) ans = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10240
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis_sort = sorted(inlis)

    low = inlis_sort[int(n/2)-1]
    high = inlis_sort[int(n/2)]
    ave = (low + high) / 2

    for i in inlis:
        if i >= ave:
            print(low)
        else:
            print(high)

    
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 26772
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define mygc(c) (c)=getchar()
#define mypc(c) putchar(c)
#define fi first
#define se second
#define ls(x) t[x].lson
#define rs(x) t[x].rson
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = (1<<18)+5;
const int maxm = 1000005;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
inline void rd(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(db *x){scanf("%lf",x);}
inline int rd(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
inline void rd(int a[],int n){FOR(i,0,n)rd(&a[i]);}
inline void rd(ll a[],int n){FOR(i,0,n)rd(&a[i]);}
template <class T, class S> inline void rd(T *x, S *y){rd(x);rd(y);}
template <class T, class S, class U> inline void rd(T *x, S *y, U *z){rd(x);rd(y);rd(z);}
template <class T, class S, class U, class V> inline void rd(T *x, S *y, U *z, V *w){rd(x);rd(y);rd(z);rd(w);}
inline void wr(int x){if(x < 10) putchar('0' + x); else wr(x / 10), wr(x % 10);}
inline void wr(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(db x, char c){printf("%.15f",x);mypc(c);}
inline void wr(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
inline void wr(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> inline void wrn(T x){wr(x,'\n');}
template<class T, class S> inline void wrn(T x, S y){wr(x,' ');wr(y,'\n');}
template<class T, class S, class U> inline void wrn(T x, S y, U z){wr(x,' ');wr(y,' ');wr(z,'\n');}
template<class T, class S, class U,class H> inline void wrn(T x, S y, U z,H h){wr(x,' ');wr(y,' ');wr(z,' ');wr(h,'\n');}
template<class T> inline void wra(T x[], int n){int i;if(!n){mypc('\n');return;}FOR(i,0,n-1)wr(x[i],' ');wr(x[n-1],'\n');}


int main(){
	int n,x,t;
	rd(&n,&x,&t);
	wrn((n+x-1)/x*t);
} 

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
using namespace std;
const int maxn = 4e5+5;
int en[maxn],nt[maxn],la[maxn],owo;
void adg(int x,int y) {
	en[++owo]=y; nt[owo] = la[x]; la[x] = owo;
}
int n;
int cc[2][maxn],V[maxn];
struct cmp{
	bool operator() (int a,int b) {
		if(1ll * cc[0][a] * cc[1][b] != 1ll * cc[1][a] * cc[0][b])return 1ll * cc[0][a] * cc[1][b] > 1ll * cc[1][a] * cc[0][b];
		return a < b;
	}
};
int fa[maxn];
int gf(int x) { return fa[x]==x?x:fa[x]=gf(fa[x]); }
multiset<int,cmp>se;
int ST[maxn],TP,F[maxn];
int main() {
	scanf("%d",&n);
	for(int i=2;i<=n;i++) {
		int x; scanf("%d",&x);
		F[i] = x;
		adg(x,i);
	}
	for(int i=1;i<=n;i++) {
		scanf("%d",&V[i]);
		cc[V[i]][i] = 1;
		fa[i] = i;
	}
	for(int i=2;i<=n;i++) {
		se.insert(i);
	}
	long long ans = 0;
	for(int i=1;i<n;i++) {
		int x = *se.begin(); 
		int p = gf(F[x]);
		se.erase(x); se.erase(p);
		fa[x] = p;
		ans += 1ll * cc[1][p] * cc[0][x];
		cc[1][p] += cc[1][x]; cc[0][p] += cc[0][x];
		if(p!=1)se.insert(p);
 	}
	cout<<ans;
}

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

typedef long long ll;

const ll MOD = 1e9;

int main(){
ll S; cin >> S;
  if( S <= MOD){
    cout << 0 << " " << 0 << " " << S << " " << 0 << " " << 0 << " " << 1 << endl;
      return 0;}
  //1e9以下の時はそのまんま表してしまえばいいから楽
  
  else{
    ll ad; ll bc;
    if( S % MOD == 0){
      ll a = MOD; ll b = S / MOD;
       cout << 0 << " " << 0 << " " << a << " " << 0 << " " << 0 << " " << b << endl;}
    
 
    else{
      //Sが1e9の倍数でない時, adはSの9の位を切り上げたものとする
       bc = S % MOD;
      S /= MOD; S += 1; ad = S * MOD; bc = MOD - bc;
       ll a,b,c,d;
      a = MOD; d = ad / a;  b = bc; c = 1;
      
      cout << 0 << " " << 0 << " " << a << " " << b << " " << c << " " << d << endl; }
  }
  
  return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<set>
#include<queue>
using namespace std;

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

set<pair<int,int> > OB;
set<pair<int,int> > D;

int main()
{
	int t,n;
	while(cin>>t>>n && t!=0){
		OB.clear();
		D.clear();
		for(int i=0;i<n;i++){
			int x,y;cin>>x>>y;
			OB.insert(make_pair(x,y));
		}
		queue<pair<pair<int,int> ,int> > Q;
		int x,y; cin>>x>>y;
		Q.push(make_pair(make_pair(x,y),0));
		while(!Q.empty()){
			pair<int,int> now=Q.front().first;
			int cost=Q.front().second;
			Q.pop();
			if(OB.count(now)) continue;
			if(D.count(now)) continue;
			D.insert(now);
			if(cost==t) continue;
			for(int r=0;r<6;r++)
				Q.push(make_pair(make_pair(now.first+dx[r],now.second+dy[r]),cost+1));
		}
		cout<<D.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
es = [[] for _ in range(N)]
connected = [0] * N
for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    connected[a] += 1
    connected[b] += 1
    es[a].append((b, i))
    es[b].append((a, i))


ans = [0] * (N-1)
used = [False] * (N-1)
q = []
q.append((0, 0)) 

while q:
    curr, pc = q.pop()
    nxt_es_color = 1
    for nxt, es_num in es[curr]:
        if used[es_num]:
            continue
        if nxt_es_color == pc:
            nxt_es_color += 1

        ans[es_num] = nxt_es_color
        used[es_num] = True
        q.append((nxt, ans[es_num]))
        nxt_es_color += 1


print(max(connected))
print(*ans, sep="\n")




Measured memory_bytes: 42076
#include<stdio.h>

#define M 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[M+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    
    if(parent(i)>=1)
      printf("parent key = %d, ",A[parent(i)]);
    
    if(left(i)<=H)
      printf("left key = %d, ",A[left(i)]);
    
    if(right(i)<=H)
      printf("right key = %d, ",A[right(i)]);
    
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2104
def main():
    n = int(input())
    a = list(map(int,input().split()))
    onaji =[]
    tmp = 0
    now = 0

    for i in range(n):

        if now == a[i]:
            tmp+=1
        else:
            onaji.append(tmp)
            tmp = 1
            now = a[i]

    onaji.append(tmp)

    ans = 0
    for i in onaji:
        ans += i//2


    print(ans)





if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
N = int(input())
n = list(map(int, input().split()))

cnt = 0
for i in range(N - 2):
    if max(n[0 + i], n[1 + i], n[2 + i]) \
            > n[1 + i] \
            > min(n[0 + i], n[1 + i], n[2 + i]):
        cnt += 1

print(cnt)

Measured memory_bytes: 8976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) f2or (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int num[5], k;
    bool ans = true;
    
    rep(i,5) {
        cin >> num[i];
    }
    cin >> k;
    rep(i,5) {
        for(int j = i+1; j < 5; j++) {
            if(num[j]-num[i] > k) {
                ans = false;
            }
        }
    }

    if(ans == true) cout << "Yay!"<< endl;
    else cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto arr = readMatrix!dchar(H, W).join.sort().group.map!(v => v[1]).array;
	auto a4 = (H/2) * (W/2);
	auto a2 = (H/2)*(W%2) + (W/2)*(H%2);
	auto a1 = (H%2) * (W%2);
	foreach(ref v; arr) while(a4 > 0 && v >= 4) { a4--; v -= 4; }
	foreach(ref v; arr) while(a2 > 0 && v >= 2) { a2--; v -= 2; }
	foreach(ref v; arr) while(a1 > 0 && v >= 1) { a1--; v -= 1; }
	if(a4 + a2 + a1 == 0) writeln("Yes");
	else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
int main(){
    long x;
    cin>>x;
    if(x<=6){
        cout<<"1";
        return 0;
    }
    else if(x%11>=7)
        cout<<(x/11+1)*2;
    else if(x%11==0)
        cout<<x/11*2;
    else
        cout<<(x/11)*2+1;
}

Measured memory_bytes: 256