akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int lim = 100100;
using edge = struct{int to; ll cost;};
vector<edge> G[lim];
ll dep[lim];

void dfs(int v, int p, ll d){
  dep[v] = d;
  for(auto &e : G[v]){
    if(e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}

signed main(){
  int n; cin>>n;
  rep(i,n-1){
    int a,b,c; cin>>a>>b>>c;
    a--; b--;
    G[a].PB({b,c}); G[b].PB({a,c});
  }

  int q,k; cin>>q>>k; k--;

  dfs(k,-1,0);
  rep(i,q){
    int x,y; cin>>x>>y;
    x--; y--;
    cout << dep[x]+dep[y] << endl;
  }


  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    ll maxsum(ll N,ll W,ll wts[],ll val[])
    {
        ll dp[N+1][W+1],i,j;
        for(j=0;j<=W;j++)
        {
            dp[1][j]=0;
        }
        dp[1][wts[1]]=val[1];
     
        for(i=2;i<=N;i++)
        {
         for(j=0;j<=W;j++)
         {
             dp[i][j]=dp[i-1][j];
             if(wts[i]>j)
             continue;
             dp[i][j]=max(dp[i][j],val[i]+dp[i-1][j-wts[i]]);
         }
        }
        sort(dp[N],dp[N]+W+1);
        return dp[N][W];
     
    }
    int main()
    {
      ll N,W;
      cin>>N>>W;
     
      ll w[N+1],i;
      ll val[N+1];
     
      for(i=1;i<=N;i++)
      {
          cin>>w[i]>>val[i];
      }
      cout<<maxsum(N,W,w,val)<<endl;
    }

Measured memory_bytes: 78336
while True:
    H,W = map(int,input().split())
    if H==W==0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    print()


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

struct edge { int to, cost; };
typedef pair<int, int> P;
int n, inf = 1000000007;
vector<edge> g[110];
int d[110];
int pre[110];
map<P, bool> mp;
int kekka = 0;

void dijkstra(int s) {
	for (int i = 1; i <= n; i++) {
		d[i] = inf;
	}
	for (int i = 0; i <= n; i++) {
		pre[i] = -1;
	}
	priority_queue<P, vector<P>, greater<P>> que;
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < g[v].size(); i++) {
			edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				pre[e.to] = v;
				//cout << s << " " << pre[e.to] << " " << e.to << endl;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void get_path(int t) {
	for (; pre[t] != -1; t = pre[t]) {
		if (mp[P(t, pre[t])] != true && mp[P(pre[t], t)] != true) {
			kekka++;
			mp[P(t, pre[t])] = true;
			mp[P(pre[t], t)] = true;
			//cout << t << " " << pre[t] << endl;
		}
	}
}

int main() {
	int m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		edge e;
		edge f;
		int a;
		cin >> a >> e.to >> e.cost;
		f.to = a;
		f.cost = e.cost;
		g[a].push_back(e);
		g[e.to].push_back(f);
		mp[P(a, e.to)] = false;
		mp[P(e.to, a)] = false;
	}
	for (int i = 1; i <= n; i++) {
		dijkstra(i);
		for(int j = 1;j <= n;j++){
			if (i == j) continue;
			get_path(j);
		}
	}
	cout << m - kekka << endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for(int i=0;i <= x;i++){
    if(2*i+4*(x-i) == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
signed main () {
	long long n;
	cin >> n;
	long long fives = 5 * (((n / 5LL) * ((n / 5LL) + 1)) / 2);
	long long threes = 3 * (((n / 3LL) * ((n / 3LL) + 1)) / 2);
	long long fift = 15 * (((n / 15LL) * ((n / 15LL) + 1)) / 2);
	long long ans = (n * (n + 1)) / 2;
	cout << ans + fift - fives - threes << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int n,s=0,a,b;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		s+=abs(a-b)+1;
	}
	cout<<s<<endl;
	return 0;
}

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

int top, s[300];

void push(int n)
{
  top++;
  s[top] = n;               //上に積む
}

int pop()
{
  top--;
  return s[top + 1];        //積んだものを返す
}

int main(void)
{
  int i, j, n;
  char s[100];
  top = 0;

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      i = pop();
      j = pop();
      n = i + j;
      push(n);
    }
    else if(s[0] == '-'){
      j = pop();
      i = pop();
      n = i - j;
      push(n);
    }
    else if(s[0] == '*'){
      i = pop();
      j = pop();
      n = i * j;
      push(n);
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n", pop());

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int r,g,b,n,count;
  cin >>r>>g>>b>>n;
  count = 0;
  
  for(int i=0; i<1+n/r; i++){
    for(int j=0; j<1+n/g; j++){
      if ((n-r*i-g*j)/b>=0){
          if((n-r*i-g*j)%b==0){
            count++;
          }
      }
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
la=[]
lb=[]
for i in range(N):
    la.append(input())
for i in range(M):
    lb.append(input())
f=0
for i in range(N-M+1):
    if f==1:
        break
    for j in range(N-M+1):
        if f==1:
            break
        f=0
        for k in range(M):
            for l in range(M):
                if la[i+k][j+l]!=lb[k][l]:
                    f=-1
                    break
            if f==-1:
                break

        if f!=-1:
            f=1
if f==1:
    print("Yes")
else:
    print("No")


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

int main(void){
    ll N,D;
    cin >> N >> D;
    vector<ll> X,Y;
    rep(i,N){
        ll temp1,temp2;
        cin >> temp1 >> temp2;
        X.push_back(temp1);
        Y.push_back(temp2);
    }
    int cnt=0;
    rep(i,N){
        double dis = 0;
        dis = sqrt(pow(X[i],2)+pow(Y[i],2));
        if(dis <= D) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

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

int main(){
  int N  ;
  cin >> N ; 
  vector<int> V(N) , C(N) ; 
  int T=0;
  
  for(int i = 0 ; i < N ; i++){
    cin >> V.at(i) ; 
  }
  
  for(int i = 0 ; i < N ; i++){
    cin >> C.at(i) ; 
  }
    
  for(int i = 0 ; i < N ; i++){
    if( V.at(i) - C.at(i) > 0 ){
      T = T + V.at(i) - C.at(i) ;
    }
  }
  
  cout << T <<endl ; 
  
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> x(N), y(N), z(N);
	REP(i, N) cin >> x[i] >> y[i] >> z[i];



	ll pm[3];
	ll res = -1;
	REP(k, 8){
		REP(l, 3){
			pm[l] = ((k>>l & 1) ? 1 : -1);
		}
		vector<ll> tmp(N);
		REP(i, N){
			tmp[i] = pm[0]*x[i] + pm[1]*y[i] + pm[2]*z[i];
		}
		sort(tmp.begin(), tmp.end());
		ll cand = 0;
		REP(i, M){
			cand += tmp[N-1-i];
		}
		if(res < cand) res = cand;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define MAX(a, b) ((ll)(a) > (ll)(b)) ? (ll)(a) : (ll)(b)
#define MIN(a, b) ((ll)(a) > (ll)(b)) ? (ll)(b) : (ll)(a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll N, X;


vector<ll> L;
int main() {
	cin >> N;

	ll x;

	rep(i, 2 * N) {
		cin >> x;
		L.push_back(x);
	}

	sort(L.begin(), L.end());

	reverse(L.begin(), L.end());
	ll ans = 0;
	for (int i = 0; i < 2 * N - 1; i += 2) {

		ans += L[i + 1];
	}


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

Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    s = input()[::-1]

    for i in range(1, len(s)):
        temp = s[i:]
        if len(temp) % 2 == 0:
            before = temp[:len(temp)//2]
            after = temp[len(temp)//2:]
            if before == after:
                print(len(temp))
                break

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
	int n,m,cb[100002],posibles=0,from,to;
	bool could[100002];
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		could[i]=false;
		cb[i]=1;
	}
	could[1]=true;
	for(int i=0;i<m;i++)
	{
		cin>>from>>to;
		if(cb[from]>0)
		{
			if(could[from] && cb[from]==1)
			{
				could[from]=false;
				could[to]=true;
			}
			if(could[from] && cb[from]>1)
			{
				could[to]=true;
			}
			cb[from]--;
			cb[to]++;
		}
	}
	posibles=0;
	for(int i=1;i<=n;i++)
		if(could[i])
			posibles++;
	cout<<posibles<<endl;
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
int main()
{
	int H, W, i=0, j=0;
	while(1){
		scanf("%d %d", &H, &W);
		if(H==0 && W==0){
			break;
		} 
		for(i=0; i<H; i++){
			if(i==0 || i==H-1){
				for(j=0; j<W; j++){
					printf("#");
				}
				printf("\n");
			} else {
				for(j=0; j<W; j++){
					if(j==0 || j==W-1){
						printf("#");
					} else {
						printf(".");
					}
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d){
    cout << "Left";
  }
  else if (a+b<c+d){
    cout << "Right";
  }
  else{
    cout << "Balanced";
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main() {
	int a[4];
	for (int i = 0; i < 4; i++)scanf("%d", &a[i]);
	a[0] *= a[1];
	a[2] *= a[3];
	printf("%d", a[0] > a[2] ? a[0] : a[2]);
	return 0;
}

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

struct Card{ char suit, value;};

void BubbleSort(Card C[], int N){
	for ( int i = 0; i < N; i++){
		for ( int j = N - 1; j > i; j--){
			if ( C[j].value < C[j-1].value){
				Card tmp = C[j];
				C[j] = C[j-1];
				C[j-1] = tmp;
			}
		}
	}
}

void SelectionSort( Card C[],int N){
	for ( int i = 0; i < N; i++){
		int minj = i;
		for ( int j = i; j < N; j++){
			if ( C[j].value < C[minj].value){
				minj = j;
			}
		}
		Card tmp = C[i];
		C[i] = C[minj];
		C[minj] = tmp;
	}
}

void print( Card C[], int N){
	for( int i = 0; i < N; i++){
		if (i) cout << " ";
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

bool isStable(Card C1[], Card C2[], int N){
	for ( int i = 0; i < N; i++){
		if ( C1[i].suit != C2[i].suit ) return 0;
	}
	return 1;
}


int main(){
	int N;
	Card C1[36], C2[36];
	cin >> N;
	for ( int i = 0; i < N; i++){ 
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}

	BubbleSort(C1, N);
	print (C1, N);
	cout << "Stable" << endl;
	SelectionSort(C2, N);
	print(C2, N);
	if (isStable(C1, C2, N)){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int64_t ans=0;
    cin>>N;
    vector<int64_t> num(5);
    for(int i=0;i<N;i++){
        string S;
        cin>>S;
        if(S[0]=='M') num[0]++;
        else if(S[0]=='A') num[1]++;
        else if(S[0]=='R') num[2]++;
        else if(S[0]=='C') num[3]++;
        else if(S[0]=='H') num[4]++;
    }
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=num[i]*num[j]*num[k];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import product
import math
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

ans = []

for lst in product([0, 1], repeat=D):
    temp = 0
    cnt = 0
    max0 = -1
    p = 0
    for i, j in enumerate(lst):
        temp += (pc[i][0] * 100 * (i+1) + pc[i][1]) * j
        cnt += pc[i][0] * j
        if j == 0 and max0 < i: max0 = i
    if temp < G and max0 != -1:
        p = math.ceil((G - temp)/(100 * (max0 + 1)))
        if p < pc[max0][0]:
            cnt += p
            temp += p * 100 * (max0 + 1)
    if temp >= G: ans.append(cnt)

print(min(ans))

Measured memory_bytes: 9068
N, H = gets.split.map(&:to_i)
list = Array.new(N * 2)
N.times.each do |i|
  a, b = gets.split.map(&:to_i)
  list[i * 2] = [:a, a, b]
  list[i * 2 + 1] = [:b, b, a]
end
sorted = list.sort_by { |(_, n, _)| -n }
sum = 0
sorted.each.with_index do |(t, n, m), i|
  if t == :b
    sum += n
    if sum >= H
      puts i + 1
      exit 0
    end
  else
    b_count = i
    rest = H - sum
    ans = b_count + (rest + (n - 1)) / n
    puts ans
    exit 0
  end
end


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int k;
string s;
const int N = 1e6 * 2 + 10;
ll fac[N];
ll inv[N];

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

void init() {
    fac[0] = 1;
    for (int i = 1; i < N; ++i) {
        fac[i] = fac[i - 1] * i % mod;
    }
    inv[N - 1] = power(fac[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; --i) {
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
}

ll C(ll a, ll b) {
    return fac[a] * inv[b] % mod * inv[a - b] % mod;
}

int main() {
    init();
    cin >> k >> s;
    int n = s.length();
    ll res = 0;
    ll sum = k + n;
    for (int i = 0; i <= k; ++i) {
        res = (res + power(26, i) * C(sum - 1 - i, n - 1)
                % mod * power(25, k - i) % mod) % mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 35504
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M, P;
  cin>>N>>M>>P;
  vector<tuple<int, int, int> > edge(M);
  vector<vector<int> > edge1(N), edgeN(N);
  int A, B, C;
  for(int i=0;i<M;++i){
    cin>>A>>B>>C;
    A--;
    B--;
    edge[i] = make_tuple(A, B, P-C);
    edge1[A].push_back(B);
    edgeN[B].push_back(A);
  }
  bool reachN[N];
  for(int i=0;i<N;++i) reachN[i] = false;
  queue<int> queN;
  queN.push(N-1);
  int state;
  while(!queN.empty()){
    state = queN.front();queN.pop();
    if(reachN[state]==true) continue;
    reachN[state] = true;
    for(int i=0;i<edgeN[state].size();++i){
      if(reachN[edgeN[state][i]]==true) continue;
      queN.push(edgeN[state][i]);
    }
  }

  bool reach1[N];
  for(int i=0;i<N;++i) reach1[i] = false;
  queue<int> que1;
  que1.push(0);
  while(!que1.empty()){
    state = que1.front();que1.pop();
    if(reach1[state]==true) continue;
    reach1[state] = true;
    for(int i=0;i<edge1[state].size();++i){
      if(reach1[edge1[state][i]]==true) continue;
      que1.push(edge1[state][i]);
    }
  }

  bool reach[N];
  for(int i=0;i<N;++i) reach[i] = reach1[i] & reachN[i];

  int dist[N];
  dist[0] = 0;
  for(int i=1;i<N;++i) dist[i] = inf;
  bool neg = false;
  for(int i=0;i<N;++i){
    for(int j=0;j<M;++j){
      if(reach[get<0>(edge[j])]==false || reach[get<1>(edge[j])]==false) continue;
      if(dist[get<1>(edge[j])] > dist[get<0>(edge[j])] + get<2>(edge[j])) {
        dist[get<1>(edge[j])] = dist[get<0>(edge[j])] + get<2>(edge[j]);
        if(i==N-1) neg = true;
      }
    }
  }
  if(neg) cout<<-1<<endl;
  else cout<<max(0, -dist[N-1])<<endl;
}



Measured memory_bytes: 3928
import collections

def main():
    N, C = map(int, input().split())
    D = []
    for _ in range(C):
        D.append(list(map(int, input().split())))
    grid = []
    for _ in range(N):
        grid.append(list(map(int, input().split())))

    if N == 1: return 0

    color = collections.defaultdict(dict)
    for i in range(N):
        for j in range(N):
            c = grid[i][j]
            k = (i+j+2) % 3
            color[k][c] = color[k].get(c, 0) + 1

    cost = []
    for k in color:
        temp = []
        for c1 in range(1, C+1):
            v = 0
            for c2 in color[k]:
                v += D[c2-1][c1-1] * color[k][c2]
            temp.append(v)
        cost.append(temp)

    # print(cost)
    # print(C)
    ans = float('inf')
    for c1 in range(C):
        for c2 in range(C):
            for c3 in range(C):
                if c1 != c2 and c2 != c3 and c3 != c1:
                    ans = min(ans, cost[0][c1]+cost[1][c2]+cost[2][c3])
    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,a,b;
  cin >> n>>a>>b;
  int64_t c=a+b;
  int64_t d=n/c;//a+bを受け入れられる数
  int64_t f=n%c;//d回受け入れ後に生じる端数
  if(f>a){//端数がaより大きい場合は
    f=a;//個数はaでカウント
  }
  cout<<d*a+f<<endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, ans;
    cin >> N;

    ans = pow(N, 3);
    cout << ans << endl;
}

Measured memory_bytes: 4012
N = int(input())
A = list(map(int,input().split()))
ans = 0
L = A.copy()
for i in range(-2,-len(A)-1,-1):
    L[i] += L[i+1]
for i in range(len(A)-1):
    ans += (A[i] * L[i+1]) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % (10**9+7)
print(ans)


Measured memory_bytes: 93980
import os, sys, re, math, queue

S = input()

al = 'abcdefghijklmnopqrstuvwxyz'

def doit():
	for a in al:
		m = re.search(a+'{2,}', S)
		if m:
			return str(m.start()+1) + ' ' + str(m.end())
		m = re.search(a+'[^'+a+']'+a, S)
		if m:
			return str(m.start()+1) + ' ' + str(m.end())
	
	return '-1 -1'

print(doit())

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

int main(){
  ll A,B; cin>>A>>B;
  vvi ans(100,vi(100));
  REP(i,A-1){
    ll x=(i/50)*2,y=(i%50)*2;
    ans[x+1][y]=ans[x][y+1]=ans[x+1][y+1]=1;
  }
  if(A==1){
    REP(i,B){
      ll x=99-(i/50)*2,y=(i%50)*2;
      ans[x][y]=1;
    }
  }else{
    REP(i,B-1){
      ll x=99-(i/50)*2,y=(i%50)*2;
      ans[x][y]=1;
    }
  }
  cout<<100<<' '<<100<<endl;
  REP(i,100){
    REP(j,100){
      if(ans[i][j]==1) cout<<'#';
      else cout<<'.';
    }
    cout<<endl;
  }
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;

// ---
const int Nlim = 100;
int N;
vector<int> b;

vector<int> Ans() {
  vector<int> ans;
  REP(i, N) {
    bool fail = true;
    RFOR(j, b.size() - 1, 0) {
      if (b[j] == j+1 && j+1 <= N-i) {
        b.erase(b.begin() + j);
        ans.push_back(j+1);
        fail = false;
        break;
      }
    }
    if (fail) { return {-1}; }
  }
  reverse(ans.begin(), ans.end());
  return ans;
}

signed main() {
  cin >> N;
  b.resize(N); REP(i, N) { cin >> b[i]; }

  vector<int> ans = Ans();
  REP(i, ans.size()) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  int a,b,h;
  std::cin >> a >> b >> h;
  std::cout << (a+b)*h/2 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

bool check(ll a) {
    Rep (i, 200) {
        if (i * i == a) return true;
        if (i * i > a) break;
    }
    return false;
}

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

    ll N, D;
    cin >> N >> D;
    vector<vector<ll>> X(N, vector<ll>(D));
    Rep (i, N) Rep (j, D) cin >> X[i][j];
    ll ans = 0;

    Rep (i, N) Rep (j, N) {
        if (i >= j) continue;
        ll dis = 0;
        Rep (k, D) {
            dis += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
        }
        if (check(dis)) {
            // cout << i << " " << j << "\n";
            ans++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int n;
        int r;


        try (InputScanner is = new InputScanner(System.in)) {
            n = is.ni();
            r = is.ni();
        }
        if(n >= 10){
            System.out.println(r);
        }else{
            System.out.println(r + 100 * (10 -n));
        }
    }

    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


Measured memory_bytes: 21076
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll mp[2][111];
ll a[111];
ll b[111];


int main()
{
	int n;cin >> n;
	
	REP(i,2)
	{
		REP(j,n)
		{
			cin >> mp[i][j];
		}
	}
	
	REP(i,n)
	{
		if(i == 0)
		{
			a[i] = mp[0][0];
			b[n-i-1] = mp[1][n-1];
		}
		else
		{
			a[i] = a[i-1] + mp[0][i];
			b[n-i-1] = b[n-i] + mp[1][n-i-1];
		}
	}
	
	ll ans = 0;
	
	REP(i,n)
	{
		ans = max(ans,a[i]+b[i]);
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(){
 
  int x=0,i;
  char T[1000],W[11];
  char end[]="END_OF_TEXT";
 
  scanf("%s",W);
 
  while(1){
    scanf("%s",T);
    if(strcmp(T,end)==0){
      break;
    }
    if(strcasecmp(T,W)==0){
      x++;
    }
  }
    printf("%d\n",x);
    return 0;
  }


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;

int findDigits(long long n){
	int digits = 0;
	while(n>0){
  	  digits++;
      n = n/10;
    }
  	return digits;
}

int main(){

  long long N;
  cin >> N;

  long long minF = 100000;
  for(long long i=1; i*i<=N ; i++){
  	if(N%i!=0)
      continue;
    long long B = N/i;
    long long F = max(findDigits(i), findDigits(B));
    minF = min(minF, F);
  }
 
  cout << minF << endl;

  return 0;
  
}


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

using namespace std;

int n,m,d[200000],t[200000];

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>d[i];
	cin>>m;
	for(int i=0;i<m;i++) cin>>t[i];
	
	sort(d,d+n);
	sort(t,t+m);
	for(int i=0,j=0;i<m;i++)
	{
		while(true)
		{
			if(j>=n) goto failed;
			if(t[i]==d[j]) break;
			j++;
		}
		j++;
	}
	cout<<"YES";
	return 0;
	failed:
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 998244353;

ll dfs(ll v,ll p,ll bord,ll mode,vector<vector<ll>>& ctree_vs,vector<vector<ll>>& lis){

    if (v > bord) return 0;

    ll ret = 1;
    if (mode == 1){
        ctree_vs[ctree_vs.size()-1].push_back(v);
    }

    rep(i,0,lis[v].size()){
        ll nex = lis[v][i];
        if (nex != p){
            ret += dfs(nex,v,bord,mode,ctree_vs,lis);
        }
    }

    return ret;
}

void get_st(ll v,ll p,ll nmax,vector<ll>& stlis,vector<ll>& last_st,vector<ll>& plis,vector<vector<ll>>& lis){

    plis[v] = p;
    last_st[v] = nmax;
    if (v > nmax) stlis.push_back(v);
    rep(i,0,lis[v].size()){
        if (lis[v][i] != p) get_st(lis[v][i],v,max(nmax,v),stlis,last_st,plis,lis);
    }
    return;
}

int main(){

    ll N;
    cin >> N;

    vector<vector<ll>> lis(N,vector<ll> (0));
    ll a,b;
    rep(i,0,N-1){

        cin >> a >> b;
        a--;
        b--;

        lis[a].push_back(b);
        lis[b].push_back(a);

    }

    vector<ll> dis(N,INT_MAX);
    dis[0] = 0;

    vector<ll> stlis(0);
    vector<ll> last_st(N,0);
    vector<ll> plis(N,0);

    get_st(0,0,0,stlis,last_st,plis,lis);

    rep(loop,0,stlis.size()){

        ll st = stlis[loop];

        vector<vector<ll>> ctree_vs(0);
        vector<ll> on_st(0);
        vector<ll> on_lb(0);

        rep(i,0,lis[st].size()){
            ll nex = lis[st][i];

            if (nex != plis[st]){
                ctree_vs.push_back({});
                on_st.push_back( dfs(nex,st,st,1,ctree_vs,lis) );
                on_lb.push_back( dfs(nex,st,last_st[st],0,ctree_vs,lis));
            }
        }

        ll lbsum = 0;
        rep(i,0,on_lb.size()){
            lbsum += on_lb[i];
        }

        rep(i,0,ctree_vs.size()){
            rep(j,0,ctree_vs[i].size()){
                ll v = ctree_vs[i][j];
                dis[v] = dis[plis[st]] + 1 + lbsum -on_lb[i] + on_st[i];
            }
        }

        dis[st] = dis[plis[st]] + 1 + lbsum;
    }

    rep(i,1,N){
        cout << dis[i] << endl;
    }
}

Measured memory_bytes: 36856
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int n, w;
vector<int> vs;

#define MAX 101
int hist[MAX];

int main(void)
{
	while(cin >> n >> w, n|w) {
		memset(hist, 0, sizeof(hist));

		int highest = 0;
		int len = 0;
		vs = vector<int>(n);
		rep(i, n) {
			cin >> vs[i];
			hist[vs[i]/w]++;
			highest = max(highest, hist[vs[i]/w]);
			len = max(len, vs[i]/w+1);
		}

		double ans = 0.01;
		for (int i = len-1, j = 0; i >= 0; i--, j++) {
			double color_level = 1.0*i/(i+j);
			double amount = 1.0*hist[j]/highest;
			ans += color_level*amount;
		}

		printf("%.10lf\n", ans);
	}
	return 0;
}

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



int main (){

int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i=0; i<H; i++) cin >> S.at(i);
int field[H][W];
for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if(S.at(i).at(j)=='#') field[i][j]=-1;
        else field[i][j]=0;
    }
}

for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]==-1){
            for(int dx=-1; dx<=1; dx++){
                for(int dy=-1; dy<=1; dy++){
                    int nx=x+dx, ny=y+dy;
                    if(0<=nx && nx<H && 0<=ny && ny<W && field[nx][ny]!=-1){
                        field[nx][ny]++;
                    }
                }
            }
        }
    }
}
for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]>=0) cout << field[x][y];
        else cout << "#";
    }
    cout << endl;
}


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;
#define INF 100000

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  int minM = INF;
  for(int i = 0; i < N; ++i){
    cin >> m[i];
    X -= m[i];
    minM = min(minM, m[i]);
  }

  cout << N + X/minM << endl;

  
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
ans = 'No'        
for i in range(3):
  if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'Yes'
  if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'Yes'
    
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{	int n;
	long long int a[45];
	a[0]=a[1]=1;
	for(int i=2;i<=44;i++)
		a[i]=a[i-2]+a[i-1];
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>

const int mod = 1e9+7;
const int MAXN = 1e5+5;
const int N = 1e5+5;

int fac[N];
int spf[MAXN]; 

void pre(int p) {
    fac[0] = 1;
    for(int i=1; i<N; i++) {
        fac[i] = (fac[i-1] * i) % p;
    }
}


void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) if (spf[j]==j) spf[j] = i; 
        } 
    } 
} 

vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
unsigned long long nCr(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) return 1; 
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}

///////////////////////////////////////////////////////////////////////////////////////////////////
 
void solve(int TC) { 
    int n, a; cin >> n >> a;
    cout << max(0LL, n - a);
}
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);
 
 
    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve(i);
    }
    return 0;
 
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[200010],l[200010],r[200010];
ll s[200010],tol=0;
signed main(){
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		l[i]=0;
		r[i]=n+1;
	}
	for(ll i=1;i<=n;i++){
		while(tol&&a[s[tol]]>a[i]){
			r[s[tol]]=i;
			tol--;
		}
		l[i]=s[tol];
		tol++;
		s[tol]=i;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=(i-l[i])*(r[i]-i)*a[i];
	}
	cout<<ans;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 6528
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

class atC {
public:
    void solve(istream& in, ostream& out) {
        long long X;
        in >> X;
        
        long long cur = 0, i;
        for (i = 1; cur < X; ++i) {
            cur += i;
        }
        
        out << i-1 << "\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	atC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 08-03-2020 08:24:59
**/


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

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n;
string s;

void solve() {
	read(n,s);
	int ans = 0, cnt = 0;
	for(int i = 0; i < n; ++i) {
		if(s[i] == 'W')
			++cnt;
	}
	ans = cnt;
	for(int i = n - 1; i >= n - cnt; --i)
		if(s[i] == 'W')
			--ans;
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


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

vector<vector<pair<int, int>>> tree;
vector<int> col;

void dfs(int current, int c) {
  col.at(current) = c;
  for (pair<int, int> e : tree.at(current)) {
    int to = e.first;
    if (col.at(to) != -1) continue;
    int dist = e.second;
    if (dist % 2 == 0) {
      dfs(to, c);
    } else {
      dfs(to, 1 - c);
    }
  }
}

int main() {
  int N;
  cin >> N;
  tree.resize(N);
  col.resize(N, -1);
  
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    
    tree.at(u).push_back(make_pair(v, w));
    tree.at(v).push_back(make_pair(u, w));
  }
  
  dfs(0, 0);
  
  for (int i = 0; i < N; i++) {
    cout << col.at(i) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int A[N];
    int v;
    for(int i=0;i<N;i++)cin>>A[i];
    
    for(int i=0;i<N;i++){
        cout<<A[i];
        if(i<N-1)cout<<" ";
    }
    cout << endl;
    
    for(int i=1;i<N;i++){
        v=A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        
        for(int i=0;i<N;i++){
            cout<<A[i];
            if(i<N-1)cout<<" ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	m := make([][]bool, h)
	dp := make([][]int, h)

	for i := 0; i < h; i++ {
		dp[i] = make([]int, w)
		m[i] = make([]bool, w)
		var s string
		fmt.Scan(&s)
		for j := 0; j < w; j++ {
			if s[j] == '#' {
				m[i][j] = true
				dp[i][j] = 1
			}
		}
	}

	for i := 1; i < w; i++ {
		dp[0][i] += dp[0][i-1]
		if m[0][i] && m[0][i-1] {
			dp[0][i]--
		}
	}
	for i := 1; i < h; i++ {
		dp[i][0] += dp[i-1][0]
		if m[i][0] && m[i-1][0] {
			dp[i][0]--
		}
	}
	for i := 1; i < h; i++ {
		for j := 1; j < w; j++ {
			x := dp[i][j] + dp[i-1][j]
			if m[i][j] && m[i-1][j] {
				x--
			}
			y := dp[i][j] + dp[i][j-1]
			if m[i][j] && m[i][j-1] {
				y--
			}
			if x > y {
				dp[i][j] = y
			} else {
				dp[i][j] = x
			}
		}
	}

	fmt.Println(dp[h-1][w-1])
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int d; cin >> d;
	string s = "Christmas";
	for (int i = 0; i < 25 - d; ++i)
	{
		s += " Eve";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;


int32_t main() {
	// your code goes here
	int t,x=1;
	
	  //cout<<"Case #"<<x++<<":\n";
	  int n,i,j,k;
	  cin>>n;
	  cout<<10-(n/200)<<"\n";
	  
	    
	  
	
	
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll x = 0;
    ll max_x = 0;
    ll N;
    string s;
    cin >> N >> s;
    rep(i, N) {
        if (s[i] == 'I') {
            x++;
            max_x = max(max_x, x);
        } else {
            x--;
        }
    }
    cout << max_x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
queue<int>q;
int nedge=0,p[1000010],nex[1000010],head[1000010],rp[1000010];
int dist[200010],vis[200010],n,m,s,t,g,l;
inline void addedge(int x,int y){
	p[++nedge]=y;nex[nedge]=head[x];head[x]=nedge;
}
inline void spfa(){
	memset(dist,0x3f,sizeof dist);
	dist[1]=0;q.push(1);vis[1]=1;
	while(!q.empty()){
		int now=q.front();q.pop();
		for(int k=head[now];k;k=nex[k])if(dist[p[k]]>dist[now]+1){
			dist[p[k]]=dist[now]+1;
			if(!vis[p[k]]){vis[p[k]]=1;q.push(p[k]);}
		}vis[now]=0;
	}
}
int main()
{
	ios::sync_with_stdio(0);
	int n,m;cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;cin>>x>>y;
		addedge(x,y);
	}
	spfa();
	if(dist[n]>2)puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int main () {
    int m,d,ret=0;
    scanf ("%d %d",&m,&d);
    for (int i = 1; i <= m; i++) {
        for (int j = 10; j <= d; j++) {
            ret += j%10 != 1 && j/10 != 1 && (j%10)*(j/10) == i;
        }
    }
    printf("%d\n",ret);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll n, m;
bool g[60][60];
vector<bool> done(60);
ll a[60], b[60];

void dfs(ll q){
    done[q] = true;
    for(ll i=0;i<n;++i){
        if(g[q][i] == false or done[i] == true){
            continue;
        }
        dfs(i);
    }
}

int main(){
    cin>>n>>m;
    for(ll i=0;i<m;++i){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }

    ll ans = 0;
    for(ll i=0;i<m;++i){
        g[a[i]][b[i]] = false;
        g[b[i]][a[i]] = false;

        fill(done.begin(), done.end(), false);
        dfs(0);

        bool flag = false;
        for(ll j=0;j<n;++j){
            if(done[j] == false){
                flag = true;
            }
        }
        if(flag == true){
            ans++;
        }
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(int, input().split()))
s = set(D)

for i in range(N, 10**6+1):
  l = [j for j in str(i)]
  flag = True
  for n in l:
    if int(n) in s:
      flag = False
      break
  if flag:
    ans = i
    break
print(ans)

Measured memory_bytes: 9084
m = map(int,raw_input().split())
a = 0
b = 0
c = 0
if m[0] < m[1] < m[2] or m[0] == m[1] == m[2] or m[0] < m[1] == m[2] or m[0] == m[1] < m[2]:
 print m[0],m[1],m[2]
elif m[2] < m[0] < m[1] or m[2] < m[0] == m[1] or m[2] == m[0] < m[1]: 
 print m[2],m[0],m[1]
elif m[1] < m[2] < m[0] or m[1] < m[2] == m[0] or m[1] == m[2] < m[0]: 
 print m[1],m[2],m[0]
elif m[0] < m[2] < m[1]:
 print m[0],m[2],m[1]
elif m[2] < m[1] < m[0]:
 print m[2],m[1],m[0]
elif m[1] < m[0] < m[2]:
 print m[1],m[0],m[2]

Measured memory_bytes: 6472