akhauriyash/Code-Regression huggingface dataset:
/*
Yasashii iro shita sora wo utsushite kousou biru ga yake ni kirei da
Yuukikau hitotachi sorezore no mune no naka de keshiki wa kawatte mieru

Kanashii iro shita dare ka no tameni ima no jibun ni nani ga dekiru no ka?
Tobenai tori tachi sonna ni sora ga takai to wa omowanai omoitakunai

Chotto shita koto de fuan ni narukara
Daijoubu datte kaita "note" no "page" wo yabutte tsukutta...

Kamihikouki ga tonde yuku yo ashita ni douka maniauyou ni
Zutto zutto zutto zutto yuuhi wo oikakete iruyo...

Kamihikouki ga ochinai youni boku wa sora ni negai wo kakeru
Zutto zutto zutto zutto yume ga mitai kara

Yasashii iro shita jikan no nakade jibun ga totemo chiisaku mieta
Owatte shimau kyou wo omotte nani ka dekiru koto wo sagasu keredo

Nandaka chotto kangae sugitana
Daijoubu datte omoereba sore ga dai ippou ni naru

Kamihikouki ga tonde yuku yo ashita ni douka maniauyou ni
Zutto zutto zutto zutto yuuhi wo oikakete iruyo...

Kamihikouki ga ochinai youni boku wa sora ni negai wo kakeru
Zutto zutto zutto zutto yume ga mitai kara

Kamihikouki ga tonde yuku yo nando mo kaze ni butsukari nagara
Zutto zutto zutto zutto tooku made dokomade mo takaku

Kamihikouki ga tonde yuku yo yume ga yume de owaranai youni
Zutto zutto zutto zutto shinji tsuzuketeiru

Dakara zutto zutto zutto zutto tonde yukeru yo...
*/ 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void solve()
{
    int n;
    cin>>n;
    string sr[n];
    int ar[n];

    for(int i=0;i<n;i++)
    {
        cin>>sr[i]>>ar[i];
    }

    string req;
    cin>>req;
    int ans=0;
    int i=0;
    for(;i<n;i++)
    {
        if(sr[i]==req)
            break;
    }
    i++;

    for(;i<n;i++)
    {
        ans+=ar[i];
    }

    cout<<ans;

}
 
int32_t main()
{
    //clock_t z = clock();
    //c_p_c();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    //cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll dp[100010];
map<int, bool> mp;
int main()
{
    int n, m;
    cin >> n >> m;
    ll a[100010];
    ll mod = 1e9 + 7;
    a[0] = 0;
    for (int i = 1; i <= m; i++)
    {
        cin >> a[i];
        mp[a[i]] = true;
    }
    a[m + 1] = n;
    dp[0] = 1;
    if (mp[1] == true){
        dp[1] = 0;
    }
    else{
        dp[1] = 1;
    }

    for (int i = 2; i <= n; i++)
    {   
        if(mp[i]==true){
            dp[i] = 0;
            continue;
        }

        dp[i] = (dp[i-1] + dp[i-2])%mod;
       // cerr << dp[i] << endl;
    }
    cout << dp[n] << endl;
  /*   ll ans = 1;
    for (int i = 1; i <= m + 1; i++)
    {   
        cerr <<a[i]-a[i-1]-1 <<endl;
         cerr <<dp[a[i]-a[i-1]-1] <<endl;

        if(a[i]==1){
            ans *= 1;
            continue;
        }
       

        ans *= dp[a[i]-a[i-1]-1] % mod;
        ans = ans % mod;
    }
    cout << ans % mod << endl;
    */

    return 0;
}

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

using namespace std;
using ll = long long;

class Scc {
private:
    int n;
    vector<vector<int>> edge, rev;
    vector<int> post_order;
    vector<bool> seen0, seen1;
    vector<int> typea;         //type[i] := 頂点iの種類(番号のトポロジカルソート順)
    vector<vector<int>> new_edge; //comb[i] := type[i]からのびる辺の集合
    int ord;
    int type_num;

    void dfs0(int v) {
        if(seen0[v])return;
        seen0[v] = true;
        for(auto i : edge[v]) {
            dfs0(i);
        }
        post_order[v] = ord++;
    }

    void dfs1(int v, int typ) {
        if(seen1[v])return;
        seen1[v] = true;
        typea[v] = typ;
        for(auto i : rev[v]) {
            dfs1(i, typ);
        }
    }


public:


    int types(){return type_num;}
    int type(int vertex){return typea[vertex];}
    vector<int> dag(int vertex){return new_edge[vertex];}

    Scc(const vector<vector<int>>& _edge):edge(_edge) {
        n = edge.size();
        typea.resize(n), post_order.resize(n), seen0.resize(n), seen1.resize(n), rev.resize(n);
        ord = 0;
        for(int i = 0; i < n; i++)dfs0(i);
        for(int i = 0; i < n; i++) {
            for(auto j : edge[i])rev[j].push_back(i);
        }
        vector<int> dfs1_ord(n);
        for(int i = 0; i < n; i++)dfs1_ord[post_order[i]] = i;
        type_num = 0;
        for(int i = n - 1; i >= 0; i--)if(!seen1[dfs1_ord[i]])dfs1(dfs1_ord[i], type_num++);
    }
};


int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> hen(n);
    for(int i = 0; i < m; i++) {
        int a, b;cin >> a >> b;
        hen[a].emplace_back(b);
    }
    Scc scc(hen); int q; cin >> q;
    for(int i = 0;  i< q; i++) {
        int a, b; cin >> a >> b;
        cout << (scc.type(a) == scc.type(b)) << endl;
    }

}



Measured memory_bytes: 5072
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int count = 0;
        for (int i = 0; i < N; i++) {
            int A_i = sc.nextInt();
            while (A_i % 2 == 0) {
                A_i = A_i / 2;
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35312
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b + c == 17 && (a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

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

  for (ll i = 1; i <= 3500; ++i) {
    for (ll j = 1; j <= 3500; ++j) {
      ll x = n * i * j;
      ll y = 4 * i * j - n * (i + j);
      if (y > 0 && x % y == 0) {
        printf("%lld %lld %lld\n", i, j, x / y);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
N, L = map(int, input().split())
taste_all = 0
for i in range(N):
    taste_all += L + i
if abs(L) < N and L < 0:
    print(taste_all)
elif L == 0:
    print(taste_all)
elif L < 0:
    print(taste_all - (L + N - 1))
elif L > 0:
    print(taste_all - L)



Measured memory_bytes: 2940
import Data.List
import Data.Function
import Control.Monad
import Control.Applicative

main = do
  _ <- getLine
  xs <- sort <$> map read <$> words <$> getLine :: IO [Int]
  --let xs = sort [6,9,4,2,11]
  let n = last xs
  let xs' = init xs
  let r = minimumBy (compare `on` (\i -> abs $ n - (i * 2))) xs'
  putStrLn $ unwords $ map show [n, r]


Measured memory_bytes: 40572
// Vicfred
// https://atcoder.jp/contests/abc160/tasks/abc160_b
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n = readln.chomp.to!int;

    long ans = (n/500)*1000;
    n -= (n/500)*500;
    ans += (n/5)*5;

    ans.writeln;
}



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

int main(){
    ll K;
    string S;
    cin >> K;
    
    queue<string> que;
    que.push("1");
    que.push("2");
    que.push("3");
    que.push("4");
    que.push("5");
    que.push("6");
    que.push("7");
    que.push("8");
    que.push("9");
    ll cnt = 0;
    string ans;
    while(!que.empty()){
        string s = que.front();
        que.pop();
        cnt++;
        if(cnt == K){
            ans = s;
            break;
        }
        ll N = s.size();
        ll x = s[N-1] - '0';
        if(x == 0){
            que.push(s+"0");
            que.push(s+"1");
            continue;
        }else if(x == 9){
            que.push(s+"8");
            que.push(s+"9");
        }else{
            string t ="1";
            t[0] = x - 1 + '0';
            que.push(s+t);
            t[0] = x + '0';
            que.push(s+t);
            t[0] = x + 1 + '0';
            que.push(s+t);
        }
    }

    cout << ans <<endl;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  double n;
  int k;
  cin >> n >> k;
  
  double sum = 0.0;
  for(int i = 1; i <= n; ++i) {
    int t = i;
    double cnt = 1.0;
    while(t < k) {
      t *= 2;
      cnt *= (1.0/2.0);
    }
    sum += cnt;
  }
  
  double ans = (1.0/n) * sum;
  
  cout << fixed << setprecision(12);
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 3816
package main

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

func main() {
	k := readi()
	a := readi()
	b := readi()

	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}

func mod(a, b float64) float64 {
	for a >= b {
		a -= b
	}
	return a
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 1856
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

#define val ff
#define wt ss
// #define MXN 109
// #define MXW 100009
ll n,W;
vpll v;

int main(){
	fastio;
	// for(auto& i: dp){
	// 	for(auto& j: i){
	// 		j= INF;
	// 	}
	// }
	cin>>n>>W;
	v.resize(n);
	ll wmax= 0;
	for(auto& i: v){
		cin>>i.wt>>i.val;
		wmax+=  i.wt;
	}

	// so need for dp with state elements allowed and weight
	// hence to save space make only 1D dp
	// dp[i] at any time is the maximum value u can acheive with 
	//        exactly i as weight 
	// So firstly only 1 item is allowed and then allowed lost grows to
	// n size. 
	// dp state will be like dp[wt_already + w[i]] = max(self, dp[wt_already] + val[i]) 
	// makes sense but the problem is order of execution
	// so notice that though dp is 1D but there id a hidden state of allowed elements
	// hence the dp[wt_already] should be the one when allowed items were till i-1
	// so when we add another item and inc it by val[i] we will be eligible to call it 
	// a state for i allowed items
	// Since allowed items increase hence loop goes for(i :0-> n-1)
	// now notice to update a dp of higher weight we need dp state of previuos i in lower dp states
	// hence update larger wights first hence rev for loop for weights
	// see possible updates in weight can be wmax - w[i] to zero , becuase its the range of
	// wt_already

	vll dp(wmax+1, 0);

	auto maxself = [](ll &a, ll b){
		a = max(a,b);
	};

	for(ll i=0; i<n; i++){
		for(ll j=wmax - v[i].wt; j>=0; j--){
			maxself(dp[j + v[i].wt], dp[j] + v[i].val);
		}
	}

	ll ans=0;
	for(ll i=0; i<=min(W,wmax); i++){
		maxself(ans, dp[i]);
		// LG(i,dp[i])
	}
	cout<<ans;

}

Measured memory_bytes: 40852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin>>s;
    string subs=s.substr(0,3);
    cout<<subs<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約?条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int mask[58];
vector<pint> gr[58];
lint dp[52][(1<<20)+10];
lint dfs(int v,int u,int g){
	if(v==g) return 0;
	rep(i,gr[v].size()){
		pint p=gr[v][i];
		if(p.fi==u) continue;
		lint x=dfs(p.fi,v,g);
		if(x>=0L) return x+(1LL<<p.se);
	}
	return -1;
}
int main()
{
	int n,a,b,m;
	cin>>n;
	rep(i,n-1){
		cin>>a>>b;gr[a].pb(mp(b,i));gr[b].pb(mp(a,i));
	}
	cin>>m;
	memset(mask,false,sizeof(mask));
	rep(i,m){
		cin>>a>>b;
		lint ma=dfs(a,-1,b);
		rep(j,n-1){
			if((ma&(1LL<<j))) mask[j]+=(1<<i);
		}
		//cout<<ma<<endl;
	}
	//rep(i,n-1) cout<<i<<' '<<mask[i]<<endl;
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,n-1) rep(j,(1<<m)){
		dp[i+1][j]+=dp[i][j];
		dp[i+1][(j|mask[i])]+=dp[i][j];
	}
	cout<<dp[n-1][(1<<m)-1]<<endl;
}



Measured memory_bytes: 426240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    ll ans=0;
    rep(i,N){
        bool sym=true;
        rep(j,N){
            rep(k,N){
                if (S[j][k]!=S[k][j]){
                    sym=false;
                }
            }
        }
        if (sym){
            ans+=N;
        }
        rep(j,N){
            char s=S[j][0];
            rep(k,N){
                if (k!=N-1){
                    S[j][k]=S[j][k+1];
                }
                else {
                    S[j][k]=s;
                }
            }
        }
    }
    cout << ans << endl;
}

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


int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a.at(i) >> b.at(i);
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  
  long long mi, ma;
  long long ans;
  if(n%2){
    mi = a.at(n/2), ma = b.at(n/2);
    ans = ma - mi + 1;
  }
  else{
    mi = a.at(n/2) + a.at(n/2-1), ma = b.at(n/2) + b.at(n/2-1);
    ans = ma - mi + 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 4812
#include<bits/stdc++.h>
#include<random>
#include <chrono>
#define lowbit(i) (i&(-i))
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'A'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int len;
string str;
int ans[1000000 + 5];

int main()
{
	cin >> str;
	int len = str.length();
	int res = 0;
	for (int i = 0; i < len; i++)
	{
		if (str[i] == 'R')res++;
		else ans[i] += res/2,ans[i-1]+=(res+1)/2, res = 0;
	}
	res = 0;
	for (int i = len-1; i >= 0; i--)
	{
		if (str[i] == 'L')res++;
		else ans[i] += res/2,ans[i+1]+=(res+1)/2, res = 0;
	}
	for (int i = 0; i < len; i++)
		printf("%d%c", ans[i], " \n"[i == len - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n; cin >> n;
    vector<ll> a(n+1);
    vector<ll> wa(n+1);
    rep(i,n+1) {
        cin >> a[i];
    }
    wa[n]=a[n];
    rep(i,n){
        wa[n-i-1]=wa[n-i]+a[n-i-1];
    }
    ll ans=1;
    ll pa=1;
    if(a[0]!=0){
        if(n==0 && a[0]==1){
            cout << 1 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }
    rep(i,n){
        pa=min(wa[i+1],pa*2);
        //cout << i << ' ' << n-1 << endl;
        if(pa-a[i+1]<=0 && i!=n-1){
            cout << -1 << endl;
            return 0;
        }
        if(i==n-1 && pa-a[i+1]<0){
            cout << -1 << endl;
            return 0;
        }
        ans+=pa;
        pa-=a[i+1];
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int ans[200005]={0};
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		ans[x]++;
	}

	for(int i=1;i<=n;i++)
	{
		printf("%d\n",ans[i] );
	}
	return 0;
}

Measured memory_bytes: 4536
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

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

  bool ans = false;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if(k == j * n + i * m - 2 * i * j){
        ans = true;
        break;
      }
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

/**
 * problem: https://atcoder.jp/contests/dp/tasks/dp_c
 * solved: https://atcoder.jp/contests/dp/submissions/11646489
 */
public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n + 10][3];
        for (int i = 0; i < n; i++) {
            arr[i] = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        }

        int[][] dp = new int[n + 10][3];
        // dp[i][j] ... i日目にjをする場合に得られる最大の幸福度 => ans = Max(dp[n][0..2])
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) continue;
                    dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][k] + arr[i][j]);
                }
            }
        }
//        debug(dp);
        int ans = Math.max(Math.max(dp[n][0], dp[n][1]), dp[n][2]);
        System.out.println(ans);

    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int a=0;
  int b=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='0'){
      a++;
    }
    else{
      b++;
    }
  }
  cout<<2*min(a,b)<<endl;
  
  
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

typedef long long ll;

int main(){
   std::string S;
   ll K;
   std::cin >> S >> K;

   int N = S.size();
   int T[N];
   for(int i=0; i<N; ++i){
      for(char j='1'; j<='9'; ++j){
   	 if(j==S[i]){
	    T[i] = j - '0';
	    break;
	 }
      }
   }

   int n = 0;
   for(int i=0; i<N; ++i){
      if(T[i]>1) break;
      else ++n;
   }
   if(K<=n) std::cout << T[0] << std::endl;
   else std::cout << T[n] << std::endl;

   /*
   ll ndays = 5000000000000000;
   ll n = 0;
   for(int i=0; i<N; ++i){
      std::cout << i << ' ' << T[i] << std::endl;
      ll m = 1;
      if(T[i]>1){
	 for(int j=0; j<ndays; ++j){
	    m *= T[i];
	    if(m>K){
	       std::cout << T[i] << std::endl;
	       return 0;
	    }
	 }
      }
      n += pow(T[i],ndays);
      std::cout << n << std::endl;
      if(n>K) {
	 std::cout << T[i] << std::endl;
	 return 0;
      }
   }*/

   return 0;
}


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

int main()
{  
    int n;
    cin>>n;
    multiset<int>s;
    REP(i,n)
    {
        int x,y;
        cin>>x>>y;
        if(x==0){s.insert(y);cout<<s.size()<<endl;}
        if(x==1)cout<<s.count(y)<<endl;
        if(x==2)
        {
            if(s.find(y)!=s.end())s.erase(y);
        }
        if(x==3)
        {
            int z;
            cin>>z;
            decltype(s)::iterator it=s.lower_bound(y);
            decltype(s)::iterator end=s.upper_bound(z);
            while(it!=end)
            {
                cout<<*it<<endl;
                ++it;
            }
        }
    }
}



Measured memory_bytes: 12268
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	int N, A;
    cin >> N;
    cin >> A;
    vector<int> x(N, 0);
  	for (int i = 0; i < N; ++i){
      cin >> x[i];
    }
  
  	long count = 0;
  	long dp[N+1][N+1][A*N+1];
  
  	for (int i = 0; i < N+1; ++i) {
      for (int j = 0; j < N+1; ++j) {
        for (int k = 0; k < A*N+1; k++) {
          if (i == 0 && j == 0 && k ==0) {
            dp[i][j][k] = 1;
          }
          else if (i >= 1 && x[i-1] > k) {
            dp[i][j][k] = dp[i-1][j][k];
          }
          else if (i >= 1 && j >= 1 && x[i-1] <= k){
            dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
          }
          else {
            dp[i][j][k] = 0;
          }
        }
      }
    }
  
  	for(int i = 1; i <= N; ++i){
      count = count + dp[N][i][A*i];
    }
  
    cout << count << endl;
}


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


int N;
int sum;
int T[50];

bool dp[51][2501][2501];
int ans = 1e9;
void dfs(int k,int x1,int x2){
	if( x1 < x2 ) swap(x1,x2);
	int x3 = sum - x1 - x2;

	if( max({x1,x2,x3}) >= ans && max({x1,x2,x3}) != x3 ) return;
	//cout << x1 << " " << x2 << " " << x3 << endl;
	ans = min(ans,max({x1,x2,x3}));
	if( k == N ) return;
	
	if( dp[k][x1][x2] ) return;

	dp[k][x1][x2] = true;
	dfs(k+1,x1+T[k],x2);
	dfs(k+1,x1,x2);
	
	dfs(k+1,x1,x2+T[k]);


}

int main(){
	cin >> N;
	for(int i = 0 ;i < N ; i++){
		cin >> T[i];
		sum += T[i];
	}
	dfs(0,0,0);
	cout << ans << endl;

}

Measured memory_bytes: 85004
#include <stdio.h>

int map[10][10];
int sup[10][2];
int n;
int pdx[12]={-1,0,1,2,2,2,-1,0,1,-2,-2,-2};
int pdy[12]={-2,-2,-2,-1,0,1,2,2,2,1,0,-1};


int tansaku(int, int, int);

main(){
  int x, y, i, j, nx, ny;
  
  while(1){
    scanf("%d %d", &nx, &ny);
    if(nx==0 && ny==0) break;
    
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	map[i][j]=0;
      }
    }
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++){
      scanf("%d %d", &x, &y);
      sup[i][0]=y;
      sup[i][1]=x;
    }
    
    if(tansaku(nx, ny, 0)) printf("OK\n");
    else printf("NA\n");
  }
  return 0;
}

int tansaku(int x, int y, int t){
  int i, tx, ty;
  
  for(i=0;i<12;i++){
    tx=x+pdx[i];
    ty=y+pdy[i];
    if(tx>=0 && tx<=9 && ty>=0 && ty<=9){
      if((tx-sup[t][1])>=-1 && (tx-sup[t][1])<=1 && (ty-sup[t][0])>=-1 && (ty-sup[t][0])<=1){
	if(t>=n-1) return 1;
	if(tansaku(tx,ty,t+1)) return 1;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
def dfs(S):
    if len(S) == N:
        ans.append(S)
    else:
        for c in range(max(S) + 2):
            dfs(S + [c])


N = int(input())
ans = []
dfs([0])
for li in ans:
    print("".join(chr(c + ord("a")) for c in li))


Measured memory_bytes: 26368
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

//UnionFind
class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) {
        par.resize(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, M; input(N,M);
    UnionFind uni(N + M);
    REP(i, N) {
        int K; input(K);
        REP(j, K) {
            int L; input(L);
            uni.unite(i, N + L - 1);
        }
    }
    REP(i, N) {
        if (!uni.same(i, 0)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

void insertionSort(vector<int> &A, int n, int g, int &cnt) {
    for (int i=g; i<n; ++i) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j = j - g;
            cnt ++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int> &A, int n) {
    int cnt = 0;
    vector<int> G;

    G.push_back(1);
    for (int h=4; h<=n; h=h*3+1) {
        G.push_back(h);
    }
    int m = G.size();

    cout << m << endl;

    for (int i=m-1; i>=0; --i) {
        cout << (i==m-1 ? "" : " ") << G[i];
        insertionSort(A, n, G[i], cnt);
    }
    cout << endl;

    cout << cnt << endl;

    for (int i=0; i<n; ++i) {
        cout << A[i] << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i=0; i<n; ++i) {
        cin >> A[i];
    }
    shellSort(A, n);
    return 0;
}

Measured memory_bytes: 4964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll x;
    cin >> x;
    for(int i = 0; i <= 1000; i++) {
        for(int j = -1000; j <= 1000; j++) {
            ll ni = 1, nj = 1;
            for(int a = 0; a < 5; a++) ni *= i; 
            for(int a = 0; a < 5; a++) nj *= j;
            if(ni-nj==x) {
                cout << i << " " << j << endl;
                return 0;
            } 
        }
    }
}

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

int main(void) {
	int i, j;
	int max, min;
	char str[9];
	char swap;
	int answer;
	int n;
	scanf("%d", &n);
	while (n--) {
		scanf("%s", str);
		for (i = 1; i < 8; i++) {
			for (j = 0; j < 8 - i; j++) {
				if (str[j] < str[j+1]) {
					swap = str[j];
					str[j] = str[j+1];
					str[j+1] = swap;
				}
			}
		}
		max = atoi(str);
		for (i = 0; i < 4; i++) {
			swap = str[i];
			str[i] = str[7-i];
			str[7-i] = swap;
		}
		min = atoi(str);
		answer = max - min;
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Grid {
    Grid(int h, int w) : h(h), w(w), st(w + 1), v(h * st, -1) {}
    void bfs() {
        queue<int> q;

        char s[21];
        for (int i = 0; i < h; i++) {
            cin >> s;
            for (int j = 0; j < w; j++) {
                if (s[j] == '.') {
                    v[st * i + j] = 0;
                }
            }
        }

        int r = 0;
        for (int i1 = 0; i1 < h; i1++) {
            for (int j1 = 0; j1 < w; j1++) {
                if (v[st * i1 + j1] < 0) continue;
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (v[st * i + j] > 0) v[st * i + j] = 0;
                    }
                }
                q.push(st * i1 + j1);
                while (!q.empty()) {
                    int k = q.front(); q.pop();
                    for (auto d : { -st, -1, 1, st }) {
                        int l = k + d;
                        int i = l / st;
                        int j = l % st;
                        if (l < 0 || i == h || j == w) continue;
                        if (v[l] == 0 && !(i == i1 && j == j1)) {
                            q.push(l);
                            v[l] = v[k] + 1;
                            r = max(r, v[l]);
                        }
                    }
                }
            }
        }
        cout << r << endl;
    }
    int h, w, st;
    vector<int> v;
};

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

    int h, w;
    cin >> h >> w;

    Grid g(h, w);
    g.bfs();

    return 0;
}

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


int main() {
    string s;
    cin >> s;
    if((s=="a")||(s=="i")||(s=="u")||(s=="e")||(s=="o")){
        cout << "vowel" << endl;

    }else{
        cout << "consonant" << endl;
    }
}

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

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int in0 = int.Parse(Console.ReadLine());

            Console.WriteLine("{0}", (in0 - 2) * 180);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int, int>;

void solve_1() {//14m
	int a, b;
	cin >> a >> b;
	int total;
	int n = 0;
	while (!((a-1)*n + 1 >= b)) {
		n++;
	}
	cout << n << endl;

}

void solve_2() {//30m
	int n;
	cin >> n;
	vector<int> x;
	int total = 0;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
		total += tmp;
	}
	int p1 = (double(total)/double(n)*2 - 1.0) / 2;
	int p2 = (double(total)/double(n)*2 - 1.0) / 2 + 1;
	int point_sum1 = 0, point_sum2= 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;

}

void solve_2re() {
	int n;
	cin >> n;
	vector<int> x(n);
	int total = 0;
	rep(i, n) {
		cin >> x[i];
		total += x[i];
	}
	int p1 = total / n;
	int p2 = total / n + 1;
	int point_sum1 = 0, point_sum2 = 0;
	rep(i, n) {
		point_sum1 += pow(x[i] - p1, 2);
		point_sum2 += pow(x[i] - p2, 2);
	}
	cout << min(point_sum1, point_sum2) << endl;
}

void solve_3() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	rep(i, n) {
		if (s[i] == 'a') {
			cout << (sum > 0 ? "Yes" : "No") << endl;
			if (sum>0) {
				sum--;
			}
		}
		else if (s[i] == 'b') {
			cout << (sum > 0 && b > 0 ? "Yes" : "No") << endl;
			if (sum > 0 && b > 0) {
				if (b>0) {
					sum--;
					b--;
				}
				else {
					sum--;
				}
			}
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
}

void solve_4() {

}

void solve_5() {

}

void solve_6() {

}

int main() {
	//solve_1();
	//solve_2();
	//solve_2re();
	solve_3();
	//solve_4();
	//solve_5();
	//solve_6();
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main()
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=b;b=a;a=d;
	}
	if(b>c){
		d=c;c=b;b=d;
	}
	if(a>b){
		d=b;b=a;a=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x)) //最大値を求める
#define MIN(x) *min_element(all(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define pb emplace_back //vectorヘの挿入
#define mp make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int up_b(vector<ll> v,ll i){
    int itr=upper_bound(all(v),i)-v.begin();
    if(itr==v.size()){
        return -1;
    }else{
        return itr;
    }
}
int lo_b(vector<ll> v,ll i){
    int itr=lower_bound(all(v),i)-v.begin();
    if(itr==v.size()){
        return -1;
    }else{
        return itr;
    }
}
//------------------------------------------------------------

//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n;cin>>n;
    vector<ll> v(0);
    rep(i,n){
        ll hoge;cin>>hoge;
        if(i==0){
            v.pb(-hoge);
        }else{
            int itr=up_b(v,-hoge);
            if(itr==-1){
                v.pb(-hoge);
            }else{
                v[itr]=-hoge;
            }
        }
    }
    
    
    
    O(v.size());
    
    
    
    
//------------------------------------------------------------
	return 0;
}


Measured memory_bytes: 5200
#include <stdio.h>

int main() {

  int n;
  int a,b,c;
  int i,j,k;
  int w,h; 
  int u,l,r,d;

  while(1) {

  scanf("%d",&n);

 if(n == 0) break;


 int x[205] = {0};
 int y[205] = {0};

 
 
 for(i=1;i<n;i++) {
   
   scanf("%d %d",&a ,&b);
   

   
   if(b == 0  ) {
      x[i] = x[a]-1;
      y[i] = y[a];
    }else if(b == 1){
      x[i] = x[a];
      y[i] = y[a] - 1;
    } else if(b == 2) {
      x[i] = x[a] + 1;
      y[i] = y[a];
    } else if(b == 3){
      x[i] = x[a];
      y[i] = y[a] + 1;
    }
   }
 
 
  
 u = 0;
 d = 0;
 r = 0;
 l = 0;

  for(i=1;i<205;i++) {
   
	  if(x[i] > r) r = x[i];
	  if(x[i] < l) l = x[i];
	  if(y[i] > u) u = y[i];
	  if(y[i] < d) d = y[i];
	}

 
  if(l < 0) l = l *(-1);
  if(d < 0) d = d*(-1);

  w = r+l;
  h = u+d;


  printf("%d %d\n",w+1,h+1);

 }


  return 0;




}

Measured memory_bytes: 600
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

print("Left" if A + B > C + D else "Right" if A + B < C + D else "Balanced")

Measured memory_bytes: 3700
N, M = map(int, input().split())
Alist = []
for _ in range(N):
    K, *A = map(int, input().split()) # *の付いたアンパックはリストになる
    Alist += A # 1次元配列に格納

Aset = list(set(Alist)) # セットはインデックスを取れないのでリストにしておく
ans = 0

for i in range(len(Aset)):
    if Alist.count(Aset[i]) == N: # Alistにある個数がNこなら全員が好き
        ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
s = input()

ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1, i+(n-i-1)//2+1):
        k = 2*j-i
        if k < n and s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
            ans -= 1

print(ans)


Measured memory_bytes: 9180
#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;
const long long int MOD = 1000000007;
const int INF = 1000000000;

char bo[19][15];
int h = 19, w = 15;
int y, x;
int ans = INF;

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

void dfs(int yy, int xx, int dep){
    rep(i,8){
        int nowy = yy, nowx = xx;
        for(int j = 0;;j++){
            nowy += dy[i];
            nowx += dx[i];
            if(nowy >= h){
                ans = min(ans,dep+1);
                return;
            }
            if(0>nowy||0>nowx||nowx>=w){
                break;
            }
            if(bo[nowy][nowx] == '.'){
                if(j == 0) break;
                if(nowy == h-1){
                    ans = min(ans,dep+1);
                    return;
                }
                int prey = nowy, prex = nowx;
                prey -= dy[i];
                prex -= dx[i];
                while(prey != yy || prex != xx){
                    bo[prey][prex] = '.';
                    prey -= dy[i];
                    prex -= dx[i];
                }
                dfs(nowy,nowx,dep+1);
                prey += dy[i];
                prex += dx[i];
                while(prey != nowy || prex != nowx){
                    bo[prey][prex] = 'X';
                    prey += dy[i];
                    prex += dx[i];
                }
                break;
            }
        }
    }
}

int main(){
    rep(i,h) rep(j,w) cin >> bo[i][j];
    rep(i,h) rep(j,w){
        if(bo[i][j] == 'O'){
            y = i;
            x = j;
            bo[i][j] = '.';
        }
    }
    dfs(y,x,0);
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>

using namespace std;

int main() {
    string str;
    cin >> str;
    
    int ans=0;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='g') ans++;
        else ans--;
    }
    cout << ans/2 << endl;

    return 0;
    
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// Q2
int main()
{
	int nN = 0;
	long lnL[100];
	int nSum = 0;
	cin >> nN;
	for (int i = 0; i < nN; i++)
	{
		cin >> lnL[i];
	}
	for (int i = 0; i < nN-2; i++)
	{
		for (int j = i + 1; j < nN - 1; j++)
		{
			if (lnL[i] == lnL[j])
				continue;
			for (int k = j + 1; k < nN; k++)
			{
				if (lnL[i] == lnL[k])
					continue;
				if (lnL[j] == lnL[k])
					continue;
				if (lnL[i] > lnL[j] && lnL[i] > lnL[k] && lnL[i] < (lnL[j] + lnL[k]))
					nSum++;
				else if (lnL[j] > lnL[i] && lnL[j] > lnL[k] && lnL[j] < (lnL[i] + lnL[k]))
					nSum++;
				else if (lnL[k] > lnL[i] && lnL[k] > lnL[j] && lnL[k] < (lnL[i] + lnL[j]))
					nSum++;
			}
		}
	}

	cout << nSum;
	return 0;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
#define ll long long
using namespace std;

ll N, K;
ll a[5050];

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N;i++) {
		cin >> a[i];
	}
	sort(a, a + N,greater<ll>());

	ll ans = -1;
	for (int i = 0; i < N;i++) {
		ll sum = 0;
		for (int j = i; j < N;j++) {
			if (sum + a[j] < K) {
				sum += a[j]; continue;
			}
			ans = max(ans, (ll)j);
		}
	}
	cout << N - ans - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int h, w;
    int c[10][10], a[200][200];

    cin >> h >> w;
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            cin >> c[i][j];
        }
    }
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> a[i][j];
        }
    }

    bool ischanged = true;
    while (ischanged) {
        ischanged = false;
        for (int i=0; i<10; i++) {
            for (int j=0; j<10; j++) {
                int m = 1000000000;
                for (int k=0; k<10; k++) {
                    m = min(m, c[i][k]+c[k][j]);
                }

                if (min(c[i][j], m) == m && c[i][j] != m) {
                    c[i][j] = m;
                    ischanged = true;
                }
            }
        }
    }

/*
    cout << "-----" << endl;
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    cout << "-----" << endl;
*/

    int ans = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (a[i][j] != -1) {
                ans += c[a[i][j]][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384