akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
const int N=2e5+5;
//ll cum[N+4];
int main()
{
    string str;
    int n;
    cin>>n>>str;
    int len=str.size();
    if(n>=len)
    {
        cout<<str<<endl;
    }
    else{
        for(int i=0;i<n;i++)
        {
            cout<<str[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}


Measured memory_bytes: 3604
N, Y = gets.chomp.split(' ').map(&:to_i)

(0..N).each do |x|
  (0..(N-x)).each do |y|
    if Y == 10000 * x + 5000 * y + 1000 * (N - x - y)
      puts "#{x} #{y} #{N - x - y}"
      exit
    end
  end
end
puts '-1 -1 -1'


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll N, i, a[110001], u, v, w, visited[100010], dist[100010];
vector<int>Adj[100010], W[100010];
void dfs(ll v)
{
    visited[v] = 1;
    for(ll i=0;i<Adj[v].size();i++)
    {
        ll u = Adj[v][i];
        if(!visited[u])
        {
            dist[u] = dist[v] + W[v][i];
            dfs(u);
        }
    }
}
int main()
{
    cin >> N;
    for(i=0;i<N-1;i++)
    {
        cin >> u >> v >> w;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
        W[u].push_back(w);
        W[v].push_back(w);
    }
    dfs(1);
    for(i=1;i<=N;i++)
        cout << dist[i]%2 << endl;
    return 0;
}


Measured memory_bytes: 18488
a,q,o,x,b;
main(){
  for(scanf("%d");~scanf("%s",&a)&&(a%=9);o=o==3?b=x=!printf("%d\n",x):o){
    for(a-8?b=b*2+1,x+=b>>3&1,b&=7:o++;a<7&&b;b/=2)x+=b&1;
    //if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll v[100], w[100], dp[105][100005];

int main() {
    init();
    ll N,W;
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];
    fill(dp[0] + 1, dp[0] + 10001, INF);
    
    rep(i,N){
        rep(j, 10001){
            dp[i + 1][j] = dp[i][j];
            if (j >= v[i]){
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }

    ll ans;
    rep(i, 10001) if (dp[N][i] <= W) ans = i;

    cout << ans << endl;
}


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

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

    long long int ans = x / 11 * 2;

    if (x % 11 == 0)
    {
        // do nothing
//        ans += 0;
    }
    else if (x % 11 <= 6)
    {
        ans += 1;
    }
    else
    {
        ans += 2;
    }

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

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

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((a * 100 + b * 10 + c) % 4 ? "NO" : "YES") << endl;
	return 0;
}


































Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 50000;

int main(void){
    ll N;
    vector<pair<ll, ll>> cnt_o; 
    vector<pair<ll, ll>> cnt_e;
    rep(i, 2 * MAX_N){cnt_o.push_back(make_pair(0, i)); cnt_e.push_back(make_pair(0, i));}
    ll answer;

    cin >> N;
    rep(i, N / 2){
        ll e, o;
        cin >> e >> o;
        cnt_e[e - 1].first ++; cnt_o[o - 1].first ++;
    }

    sort(rall(cnt_o));
    sort(rall(cnt_e));

    if (cnt_o[0].second != cnt_e[0].second) answer = N - cnt_e[0].first - cnt_o[0].first; 
    else answer = min(N - cnt_e[1].first - cnt_o[0].first, N - cnt_e[0].first - cnt_o[1].first);

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 1e5 + 10;
int n, a[N];
int main() {	
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a + i);	
	sort(a + 1, a + n + 1);
	if (a[1] == a[n]) {
		if (a[1] <= n / 2 || a[1] == n - 1) printf("Yes\n");
		else printf("No\n"); 
	} else if (a[1] + 1 == a[n]) {
		int cnt = 0;
		rep(i,1,n) if (a[i] == a[1]) cnt++;
		if (a[n] <= cnt) printf("No\n");
		else if (a[n] > cnt + (n - cnt) / 2) printf("No\n");
		else printf("Yes\n");
	} else printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
ll n ;
bool inarea(ll x,ll y){
  return x >= 0 && y >= 0 && x < n && y < n ;
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main()
{
cin >> n ;
vector<vector<ll>> v(n, vector<ll>(n,0) );
vector<vector<ll>> vv(n, vector<ll>(n,1) );
rep(i,n)rep(j,n){
  v[i][j]=min({i+1,n-i,j+1,n-j});
}
rep(i,n*n){
  ll a ;
  cin >> a ;
  a--;
  ll x=a/n,y=a%n;
  ans+=v[x][y];
  queue<pair<ll,ll>> q;
  q.push({x,y});
  v[x][y]--;
  vv[x][y]--;
  while(!q.empty()){
    auto r=q.front();
    q.pop();
    rep(j,4)if(inarea(r.first+dx[j],r.second+dy[j])&&v[r.first][r.second]+vv[r.first+dx[j]][r.second+dy[j]]<v[r.first+dx[j]][r.second+dy[j]]){
      v[r.first+dx[j]][r.second+dy[j]]=v[r.first][r.second]+vv[r.first+dx[j]][r.second+dy[j]];
      q.push({r.first+dx[j],r.second+dy[j]});
    }
  }
}
cout << ans-n*n << endl;
return 0;
}

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

#define inf 1000000007
#define P pair<int, int>

int n, a, b, j, ans;
P p[2][105];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n*2; i++){
		scanf("%d%d", &a, &b);
		p[i/n][i%n] = P(a, b);
	}
	sort(p[0], p[0]+n);
	sort(p[1], p[1]+n);
	p[0][n] = P(inf, inf);
	multiset<int> st;
	for(int i = 0; i < n; i++){
		while(p[0][j].first < p[1][i].first) st.insert(p[0][j++].second);
		auto it = st.lower_bound(p[1][i].second);
		if(it != st.begin()){
			st.erase(--it);
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if (x-r>=0 && x+r<=w && y+r<=h && y-r>=0)
    cout<<"Yes" << endl;
    else cout<<"No" << endl;
    return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int dfs(int n, int max, int s) {
	if (n == 1) {
		if (max <= s&&s <= 9)return 1;
		else return 0;
	}
	int sum(0);
	for (int i = max; i <= 9; i++) {
		sum += dfs(n - 1, i + 1, s - i);
	}
	return sum;
}
signed main() {
	int n, s;
	while (cin >> n >> s, n || s) {
		cout << dfs(n, 0, s) << endl;
	}

	return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
using namespace __gnu_pbds;
using namespace std;

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

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n ,temp=0;     cin>>n;
    vector<double> v(n+1,0);
    forin(0,n)
    {
        cin>>v[i+1];
    }
    vector<double> dp(n+1,0);
    dp[0]=1;
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=i;j>=0;--j)
        {
            dp[j] = (j==0 ? 0 : dp[j-1]*v[i]) + dp[j]*(1-v[i]);
        }
    }
    double ans=0;
    for(ll i=n/2+1;i<=n;i++)
    {
        ans += dp[i];
    }
    cout.precision(16);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	bool flag = false;
	for(int i = 0; i < s.length(); ++i){
		for(int j = i; j < s.length(); ++j){
			if(s.substr(0, i) + s.substr(j, s.length() - j) == "keyence"){
				flag = true;
			}
		}
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
n=int(input())

keta=len(str(n))

cnt=0

if keta%2==0:
    cnt+=9
    for i in range(4,keta+1,2):
        cnt+=9*(100**((i-2)//2))
        
if keta%2!=0:
    cnt+=9
    if keta==3:
        cnt+=n-99
    else:
        for i in range(5,keta+1,2):
            cnt+=9*(100**((i-3)//2))
            cnt+=n-(10**(i-1)-1)            

if keta==1:
    print(n)
else:
    print(cnt)

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  REP(i, h) { s[i] = readString(); }
  auto isBlack = [&](int k, int l) {
    if (k >= 0 && k < h && l >= 0 && l < w) {
      if (s[k][l] == '#') return true;
    }
    return false;
  };
  auto canPaint = [&](int i, int j) {
    if (isBlack(i - 1, j) || isBlack(i, j - 1) || isBlack(i + 1, j) ||
        isBlack(i, j + 1))
      return true;
    return false;
  };
  REP(i, h) {
    REP(j, w) {
      if (s[i][j] == '#' && !canPaint(i, j)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

long long inv(long long x){
	long n=MOD-2,a=1;
	while(n>0){
		if(n%2) a=a*x%MOD;
		x=x*x%MOD;
		n=n/2;
	}
	return a;
}

int main(){
    int n,k;
    cin>>n>>k;
    ll ans = 1;
    ll r1=1, r2=1;

    rep(i,1,min(n,k+1)){
        r1 *= (n-i+1)*inv(i)%MOD;
        r1 %= MOD;
        r2 *= (n-i)*inv(i)%MOD;
        r2 %= MOD;
        ans += r1*r2 % MOD;
        ans %= MOD;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
x = [a, b, c]
x.sort()
if (x[1] - x[0]) % 2 == 0:
    print((2 * x[2] - (x[1] + x[0])) // 2)
else:
    x[0] += 1
    x[2] += 1
    print((2 * x[2] - (x[1] + x[0])) // 2 + 1)


Measured memory_bytes: 3060
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
GCD= a[0]
dp = [set() for i in range(n)]
dp[1].add(a[0])
dp[1].add(a[1])
for i in range(1,n):
    x = a[i]
    for j in dp[i-1]:
            dp[i].add(gcd(j,x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD,x)
print(max(dp[n-1]))


Measured memory_bytes: 32040
#include<stdio.h>
i;int main(){
	int w,n,x,y,t;
	int b[31];
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=1;i<=w;i++)b[i]=i;
	for(i=0;i<n;i++){
		scanf("%d,%d",&x,&y);
		t=b[x];
		b[x]=b[y];
		b[y]=t;
	}
	for(i=1;i<=w;i++)printf("%d\n",b[i]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> v;
    rep(i,n){
        int tmp;
        cin >> tmp;

        v.pback(tmp);
    }

    int ans = 0;
    int tmp = 0;

    rep(i,n - 1){
        if(v[i] >= v[i + 1]){
            tmp++;
        }else{
            tmp = 0;
        }
        ans = max(ans,tmp);
    }

    cout << ans << endl;

    return 0;
}


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

typedef struct node{
  int *children;
  int n_children;
  int depth;
  int height;
  int sibling;
  int parent;
}Node;

void depth_plus(Node *a, int x, int d) {
  int i;
  (a+x)->depth += d;
  for (i = 0; i < (a+x)->n_children; i++) {
    depth_plus(a,((a+x)->children)[i], d);
  }
}

int height_plus(Node *a, int x) {
  int i,v2;
  v2 = 0;
  for (i = 0; i < (a+x)->n_children; i++) {
    int v1 = height_plus(a,((a+x)->children)[i]);
    if(v1 > v2) v2 = v1;
  }
  (a+x)->height = v2;
  return v2+1;
}

int main()
{
  int i,j,n,id,n_children,child1,child2;
  Node *a;
  scanf("%d",&n);
  a = (Node*)malloc(sizeof(Node) * n);
  for (i = 0; i < n; i++) {
    (a+i)->children = NULL;
    (a+i)->depth = 0;
    (a+i)->height = 0;
    (a+i)->parent = -1;
    (a+i)->sibling = -1;
    (a+i)->n_children = 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d %d",&id,&child1,&child2);
    n_children = 0;
    if(child1 >= 0 || child2 >= 0) n_children = 1;
    if(child1 >= 0 && child2 >= 0) n_children = 2;
    (a+id)->n_children = n_children;
    if(n_children != 0)
      (a+id)->children = (int*)malloc(sizeof(int) * n_children);
    if(n_children == 2) {
      (a+child1)->sibling = child2;
      (a+child2)->sibling = child1;
    }
    j=0;
    if(child1 != -1) {
      ((a+id)->children)[j] = child1;
      depth_plus(a,child1,(a+id)->depth+1);
      (a+child1)->parent = id;
      j++;
    }
    if(child2 != -1) {
      ((a+id)->children)[j] = child2;
      depth_plus(a,child2,(a+id)->depth+1);
      (a+child2)->parent = id;
    } 
  }
  for (i = 0; i < n; i++) {
    if((a+i)->parent == -1) id = i;
  }
  id = height_plus(a,id);
  
  for (i = 0; i < n; i++) {
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,(a+i)->parent,(a+i)->sibling,(a+i)->n_children,(a+i)->depth,(a+i)->height);
    if((a+i)->parent == -1) {
      printf("root\n");
    }else if((a+i)->n_children > 0){
      printf("internal node\n");
    }else{
      printf("leaf\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 612
s = input()

if s == "a":
    print("b")
elif s == "b":
    print("c")
elif s == "c":
    print("d")
elif s == "d":
    print("e")
elif s == "e":
    print("f")
elif s == "f":
    print("g")
elif s == "g":
    print("h")
elif s == "h":
    print("i")
elif s == "i":
    print("j")
elif s == "j":
    print("k")
elif s == "k":
    print("l")
elif s == "l":
    print("m")
elif s == "m":
    print("n")
elif s == "n":
    print("o")
elif s == "o":
    print("p")
elif s == "p":
    print("q")
elif s == "q":
    print("r")
elif s == "r":
    print("s")
elif s == "s":
    print("t")
elif s == "t":
    print("u")
elif s == "u":
    print("v")
elif s == "v":
    print("w")
elif s == "w":
    print("x")
elif s == "x":
    print("y")
elif s == "y":
    print("z")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 1e4+7;
const int D = 1e2+7;

string k;
int d;
ll dp[N][D][2];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
    cin >> k >> d;
    int n = k.size();
    // dp[i][j] = number of ways for first i digits to sum j

    REP(c,0,9)
    {
        if (c < k[0]-'0') dp[0][c%d][0] += 1;
        if (c == k[0]-'0') dp[0][c%d][1] += 1;
    }

    REP(i,1,n-1)
    {
        REP(j,0,d-1)
        {
            REP(c,0,9)
            {
                dp[i][j][0] = (dp[i][j][0]+dp[i-1][(j-c+d*10)%d][0])%MOD;
                if (c < k[i]-'0')
                {
                    dp[i][j][0] = (dp[i][j][0]+dp[i-1][(j-c+d*10)%d][1])%MOD;
                }
                if (c == k[i]-'0')
                {
                    dp[i][j][1] = dp[i-1][(j-c+d*10)%d][1];
                }
            }
            //cout << i << ' ' << j << ' ' << dp[i][j][0] << ' ' << dp[i][j][1] << endl;
        }
    }
    cout << (dp[n-1][0][0]+dp[n-1][0][1]-1+MOD)%MOD << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	string S; cin >> S;

	int ans = 0;
	REP(i,N-2){
		if(S.substr(i,3) == "ABC") ans++;
	}
	
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
N,X = map(int,input().split())
#入力が一文字ずつだから split()は不要
moto = [int(input()) for _ in range(N)]

num = 0
for i in moto:
    num = num + int(i)

X = X - num
#余ったXから最小のmiを作れるだけ作る
k2 = X // min(moto)
#最初作った個数とその後最小のmiのものだけ作った個数の和
print(N + k2)

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

ll n,ans,pos=1;
ll a[200005],r[200005],t[200005];

int main(){
    string s;
    cin>>s;
    for(ll i=1;i<=s.size();i++)
        a[i]=s[i-1]-'0';
        
    for(ll i=s.size();i>=1;i--){
        r[i]=(r[i+1]+a[i]*pos)%2019;
        pos=(pos*10)%2019;
    }
    
    t[0]++;
    
    for(ll i=1;i<=s.size();i++)
        t[r[i]]++;
    for(ll i=0;i<=2018;i++){
        ll x=t[i];
        if(x==0 || x==1)
            continue;
        else
            ans+=(x*x-x)/2;
    }
    
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 6824
import collections
import math
N,A,B  = map(int, input().split())
v = list(map(int,input().split()))

nums = collections.defaultdict(int)
for x in v:
    nums[x] += 1
ave = [[0 for i in range (B - A + 1)] for j in range(2)]
v.sort(reverse = True)
for i in range(A , B + 1):
    ave[0][i - A] = sum(v[:i]) / i
    ave[1][i - A] = v[:i]
ans = max(ave[0])
print(ans)

indexes = [i for i in range(B - A + 1) if ave[0][i] == ans]
max_counter = [] * len(indexes)
ans = 0
for i in indexes:
    counter = collections.Counter(ave[1][i])
    tmp_ans = 1
    for x in counter:
        tmp_ans *= math.factorial(nums[x]) // math.factorial(counter[x]) // math.factorial(nums[x] - counter[x])
    ans += tmp_ans
print(ans)


Measured memory_bytes: 3316
// 21
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef LOCAL
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}

// Notes: https://searleser97.gitlab.io/competitive-programming-notes/AtCoder/dp_n.png

void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];
  const li inf = 2e18;
  vector<li> pref = v;
  rep(i, 1, n) pref[i] += pref[i - 1];
  /************* Recursive *************
  vector<vector<li>> mem(n, vector<li>(n, inf));
  function<li(int, int)> f = [&](int L, int R) -> li {
    if (L == R) return 0;
    if (mem[L][R] != inf) return mem[L][R];
    li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
    rep(pivot, L, R) {
      mem[L][R] = min(mem[L][R], f(L, pivot) + f(pivot + 1, R) + sum);
    }
    return mem[L][R];
  };
  cout << f(0, n - 1) << endl;
  *********** End Recursive ***********/
  vector<vector<li>> mem(n, vector<li>(n, inf));
  rep(R, n) {
    rep(L, R, -1) {
      if (L == R) {
        mem[L][R] = 0;
        continue;
      }
      li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
      rep(pivot, L, R) {
        mem[L][R] = min(mem[L][R], mem[L][pivot] + mem[pivot + 1][R] + sum);
      }
    }
  }
  cout << mem[0][n - 1] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, K; cin >> N >> K;
    if ((N - 1) * (N - 2) / 2 < K) {
        cout << -1 << endl;
        return 0;
    }

    int total = (N - 1) * (N - 2) / 2;
    vector<pair<int, int>> ans;
    REP(i, 2, N + 1) ans.push_back({1, i});

    REP(i, 2, N + 1) {
        REP(j, i + 1, N + 1) {
            if (total == K) break;
            ans.push_back({i, j});
            total--;
        }
    }

    cout << ans.size() << endl;
    for (auto a : ans) cout << a.first << " " << a.second << endl;

    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;

    if (a > b)
        cout << "Alice";
    else if (a < b)
        cout << "Bob";
    else
        cout << "Draw";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int main(void){
  string s, t;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  cin >> t;
  char c1;
  char c2;
  map<char, char> m;
  map<char, char> rm;
  for(int i=0; i<s.length(); i++){
    if(m.find(s[i])==m.end()){
      if(rm.find(t[i]) != rm.end()) {
        cout << "No";
        return 0;
      }
      m[s[i]] = t[i];
      rm[t[i]] = s[i];
    }
    else {
      if (m[s[i]] != t[i]) {
        cout << "No";
        return 0;
      } else {
        rm[t[i]] = s[i];
      }
    }
  }
 cout << "Yes";
}


Measured memory_bytes: 1020
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<string.h>
typedef long long ll;
using namespace std;
ll ar[100004],rem[100003];
int main()
{
	ll n;
	ll i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
	cin>>ar[i];
	rem[i]=ar[i];
    }
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		if(ar[i]>=rem[i-1])
		{
			ll k=rem[i-1];
			ans=ans+rem[i-1];
			rem[i-1]=0;
			ar[i]=ar[i]-k;
			ll p=ar[i]/2;
			ans=ans+p;
			ar[i]=ar[i]-p*2;
			rem[i]=ar[i];
		}
		else
		{
			ans=ans+min(ar[i],rem[i-1]);
			ar[i]=0;
		}
		
	}
	cout<<ans;
	return 0;
		
}

Measured memory_bytes: 1792
class Dice():
    def __init__(self):
        self.nums = list(range(6))
        self.work = list(range(6))

    def set_nums(self, n0, n1, n2, n3, n4, n5):
        self.nums[0] = n0
        self.nums[1] = n1
        self.nums[2] = n2
        self.nums[3] = n3
        self.nums[4] = n4
        self.nums[5] = n5

    def rotate(self, cmd):
        for i in range(6):
            # deepcopy
            self.work[i] = self.nums[i]

        if cmd == 'N':
            self.set_nums(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif cmd == 'S':
            self.set_nums(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1]),
        elif cmd == 'E':
            self.set_nums(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        else:
            self.set_nums(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def top(self):
        return self.nums[0]

nums = [int(arg) for arg in input().split()]
d = Dice()
d.set_nums(*nums)
for cmd in list(input()):
    d.rotate(cmd)
print(d.top())



Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

bool small(char cc){
  return ((cc - 'a') >= 0) && ((cc - 'a') < 26);
}

int main(){
  string S;
  cin >> S;

  if(S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  if(!small(S[1]) || !small(S[S.size() - 1])){
    cout << "WA" << endl;
    return 0;
  }

  ll cnt = 0;
  rep2(i, 2, S.size() - 1){
    if(!small(S[i])){
      if(S[i] == 'C'){
		cnt++;
      } else{
        cout << "WA" << endl;
        return 0;
      }
    }
  }

  if(cnt != 1){
    cout << "WA" << endl;
    return 0;
  }

  cout << "AC" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    unsigned long long int n; scanf("%llu", &n);
    // n / x = n % x = a とすると n = a * (x + 1) : ただし, x > a
    unsigned long long int res = 0;
    for(unsigned long long int t = 1; t * t <= n; ++t) if(!(n % t)){
        unsigned long long int s = n / t;
        if(s - 1 > t) res += s - 1;
        if(s != t){
            if(t - 1 > s) res += t - 1;
        }
    }
    printf("%llu\n", res);
    return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long a[100005];
    for(long long i=0;i<n;i++) cin >> a[i];
    long long sum=a[0];
    for(long long i=1;i<n;i++) sum=sum^a[i];
    if(sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N, A, B;
    cin >> N >> A >> B;
    prints(min(A*N, B));

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll I, O, T, J, L, S, Z;

void solve() {
	cin >> I >> O >> T >> J >> L >> S >> Z;
	ll res = 0;
	if(I >= 1 && J >= 1 && L >= 1) {
		MAX(res, O + (I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (L - 1) / 2 * 2 + 3);
	}
	MAX(res, O + I / 2 * 2 + J / 2 * 2 + L / 2 * 2);
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define each(i,a) for(auto&&i:a)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const vector<ll> four={0,1,0,-1,0};
using tuplis=pair<ll,pair<ll,ll>>;
template<class T>using pq=priority_queue<T,vector<T>,greater<T>>;
template<class T>inline constexpr bool update_min(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline constexpr bool update_max(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}





signed main(){
    ll n;
    cin>>n;
    vv(ll,f,n,10);
    each(i,f)each(j,i)cin>>j;
    vv(ll,p,n,11);
    each(i,p)each(j,i)cin>>j;
    ll ans=-LINF;
    rep(i,1,1<<10){
        ll cnt=0;
        rep(j,0,n){
            ll c=0;
            rep(k,0,10)if(i&(1<<k)&&f[j][k])c++;
            cnt+=p[j][c];
        }
        update_max(ans,cnt);
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a,v = inp
b,w = inp
sa = (a-b).abs
t = inp[0]
puts ((v-w)*t >= sa)? "YES" : "NO"


Measured memory_bytes: 14404
N, M = gets.split.map(&:to_i)
dist = Array.new(N + 1){Array.new(N + 1, Float::INFINITY)}
edges = []

M.times do |i|
    a, b, c = gets.split.map(&:to_i)
    edges.push([a, b, c])
    dist[a][b] = c
    dist[b][a] = c
end

(1..N).each do |i|
    dist[i][i] = 0
end

(1..N).each do |k|
    (1..N).each do |i|
        (1..N).each do |j|
            d2 = dist[i][k] + dist[k][j]
            if dist[i][j] > d2
                dist[i][j] = d2
            end
        end
    end
end

p edges.count{|s, d, c| dist[s][d] < c }

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);

int main(){
    int n,m; cin >> n >> m;
    int sum=0;
    vector<int> a(m);
    rep(0,m){
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n) cout << "-1" << endl;
    else cout << n-sum << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int max1=0,min1=1e5;
    rep(i,n){
        cin>>a[i];
        max1=max(max1,a[i]);
        min1=min(min1,a[i]);
    }
    cout<<max1-min1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<ll> vl;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    string s;
    cin >> s;
    int numr = 0;
    int numw = 0;
    vi cumr(n+1);
    vi cumw(n+1);
    rep(i,0,n){
        if(s[i] == 'R'){
            numr++;
            cumr[i+1] = cumr[i]+1;
            cumw[i+1] = cumw[i];
        }else{
            numw++;
            cumr[i+1] = cumr[i];
            cumw[i+1] = cumw[i]+1;
        }
    }
    int ans = n;
    rep(i,0,n+1){
        int cand = max(cumw[i], cumr[n]-cumr[i]);
        ans = min(ans, cand);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5192
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <cmath>
using namespace std;
int main(void) {
	for (;;) {
		int x, y, s;
		cin >> x >> y >> s;
		if (!x)return 0;
		int max=0;
		for (int i = 1; i <s; i++) {
			for (int j = i; j + i <= s; j++) {
				if (i*(100 + x) / 100 + (j)*(100 + x) / 100 != s)continue;
				max = std::max(max, i*(100 + y) / 100 + (j)*(100 + y) / 100);
			}
		}
		cout << max << endl;
	}
}

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

main(){
  int n;
  int x1, y1, z1, w1, x2, y2, z2, w2;
  int a, b, c, d, e, f, g, h;
  while(1){
   
    cin >> n;
    if ( n == 0 ) break;
    for ( int i = 0; i < n; i++ ){
      cin >> a >> b >> c >> d;
      cin >> e >> f >> g >> h;
      cout << (a*e-b*f-c*g-d*h ) << " ";
      cout << (a*f+b*e+c*h-d*g) << " ";
      cout << (a*g+c*e+d*f-b*h) << " ";
      cout << (a*h+d*e+b*g-c*f) << endl;
    }
  }
}

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

int main(){
    int N, X;
    int L[10003];
    int count = 1;
    int sumL = 0;

    cin >> N >> X;
    for(int i=0;i<N;i++) cin >> L[i];

    for(int i=0;i<N;i++){
        sumL += L[i];
        if(sumL <= X) count++;
    }

    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,-1,1,-1};
int field[150][150];
void dfs(int x, int y);
int main(){
  int h,w;
  while(cin >>h>>w,h||w){
    for(int i=0; i<150; i++) for(int j=0; j<150; j++) field[i][j] = 0;
    for(int i=0; i<w; i++) for(int j=0; j<h; j++) cin >>field[i+50][j+50];
    int ans = 0;
    for(int i=0; i<w; i++){
      for(int j=0; j<h; j++){
	if(field[i+50][j+50] == 1){
	  dfs(i+50,j+50);
	  ans++;
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}
void dfs(int x, int y){
  field[x][y] = 0;
  for(int i=0; i<8; i++) if(field[x+dx[i]][y+dy[i]] == 1) dfs(x+dx[i],y+dy[i]);
}

Measured memory_bytes: 1316
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());

    int result = Math.min(A, B) + Math.min(C, D);
    System.out.println(result);

  }
}


Measured memory_bytes: 23764
// AOJ 1009
#include<cstdio>

int gcd( int a, int b )
{
	if( !b )
		return a;

	return gcd( b, a%b );
}

int main()
{
	int a, b;
	while( scanf( "%d%d", &a, &b ) != EOF )
		printf( "%d\n", gcd( a, b ) );

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int r,d,x2000;cin>>r>>d>>x2000;
    vector<ll>x(10);
    rep(i,10){
        if(i==0){
            x.at(i)=r*x2000-d;
        }else{
            x.at(i)=r*x.at(i-1)-d;
        }
        cout<<x.at(i)<<endl;
    }
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
int main()
{
    ll i,j,n,x,y,t;
    //cin>>t;
    cin>>n;
    if(n==0)
    {
        cout<<0<<endl;
        return 0;
    }
    while(n!=0)
    {
        v.push_back(n%-2);
        if(n%-2<0)
        {
            n+= n%-2;
        }
        n = n/-2;
    }
    for(i=v.size()-1;i>=0;i--)
    {
        cout<<abs(v[i]);
    }
    cout<<endl;

}



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

long long n, x, y, arr[200005], brr[200005], ans;

int main(){
	cin>>n;
	
	for(long long i=1; i<=n; i++){
		cin>>x>>y;
		
		arr[i]=x+y;
		brr[i]=x-y;
	}
	sort(arr+1, arr+n+1);
	sort(brr+1, brr+n+1);
	
	ans=max(abs(arr[n]-arr[1]), abs(brr[n]-brr[1]));
	cout<<ans<<endl;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define Max 100005
int N;
struct Node{int p ,l,r;};
Node T[Max];
int D[Max];

void setDepth(int u, int p){
  D[u] = p;
  if(T[u].r != -1)setDepth(T[u].r, p);
  if(T[u].l != -1)setDepth(T[u].l, p+1);
}

void print(int u){
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
  if(T[u].p == -1)printf("root, ");
  else if(T[u].l == -1)printf("leaf, ");
  else printf("internal node, ");
  printf("[");

  for(int i=0, c = T[u].l; c != -1; ++i, c = T[c].r){
    if(i)printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main()
{
  int id, k, c, l;
  scanf("%d", &N);
  for(int i=0; i<N; ++i)T[i].p = T[i].l = T[i].r = -1;

  for(int i=0; i<N; ++i){
    scanf("%d%d", &id, &k);

    for(int j=0; j<k; ++j){
      scanf("%d", &c);
      if(j == 0)T[id].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = id;
    }

  }

  for(int i=0; i<N; ++i){
    if(T[i].p == -1){
      setDepth(i, 0);
      break;
    }
  }

  for(int i=0; i<N; ++i)print(i);

}

Measured memory_bytes: 7772
N = str(input())

resultdist = {}

ketalist = [1,11,111,1111,11111]

def chukan(N):
    if(len(N) > 2):
        return int(N[1:-1])
    else:
        return 0

def retketa1(N):
    if(len(N) > 1):
        return ketalist[len(N)-2]
    else:
        return 0

def retketa2(N):
    if(len(N) > 2):
        return ketalist[len(N)-3]
    else:
        return 0

for i in range(1,10):
    for j in range(1,10):
        count = 1 if i==j else 0
        if(i < int(N[0])):
            count += retketa1(N)
        if(i > int(N[0])):
            count += retketa2(N)
        if(i == int(N[0])):
            count += retketa2(N)
            if(j > int(N[-1])):
                count += chukan(N)
            else:
                if(len(N) > 1):
                    count += chukan(N) + 1
                else:
                    count += chukan(N)

        resultdist[str(i)+str(j)] = count

resulutcount = 0

for i in range(1, int(N)+1):
    l = str(i)[0]
    f = str(i)[-1]
    if(f != "0"):
        resulutcount += resultdist[f+l]
print(resulutcount)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int ans;
    ans = n / 2;
    if(n % 2 != 0) ans++;
    cout << ans << endl;
    return 0; 
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];
ll pos[N];
int main()
{

   ll a,b,c,d,gcd=0,lcm=0,ans1=0,ans=0,sum=0,bug=0,ans2=0,ans3=0;

   cin>>a>>b>>c>>d;

   gcd=__gcd(c,d);

   lcm=(c*d)/gcd;

   ans=b/c;

   ans1=b/d;

   sum=ans+ans1;

   bug=b/lcm;

   sum-=bug;

   sum=b-sum;

   ans3=sum;

    a--;

    ans=a/c;

   ans1=a/d;

   sum=ans+ans1;

   bug=a/lcm;

   sum-=bug;

   sum=a-sum;

   cout<<abs(sum-ans3)<<endl;








}





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


int main(){
    int N;
    char S[100000];
    cin >> N;
    cin >> S;

    int count = N;

    for(int i=0; i<N; i++){
        if(S[i] == S[i+1]){
            count--;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 384
//https://atcoder.jp/contests/abc056/tasks/arc070_a
//C - Go Home
//n(n+1)/2 = X
//n(n+1) = 2*X
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll x;

int main() {
    cin >> x;
    ll sum = 0;
    ll count = 0;
    int flag = 1;
    for (int i = 1; flag; i++) {
        sum+=i;
        count++;
        if (abs(x) <= abs(sum)) flag = 0;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256