akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
ll mini=inf;
cin>>n;
ll ar[n];
for(i=0;i<n;i++)
{
  cin>>ar[i];
  if(ar[i]<mini)
  {
    mini=ar[i];
    count1++;
  }
}
cout<<count1;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <set>

using namespace std;

int main()
{
    int A, B;

    cin >> A;
    cin >> B;

    cout << (B-1+(A-2))/(A-1) << endl;
    return 0;
}


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

int main() {
  int n, k; cin >> n >> k;
  int a[200500];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int backet[n] = {};
  for(int i = 0; i < n; i++) backet[a[i] - 1]++;  //--- backet 1 ずらす ---//
  sort(backet, backet + n);
  int res = 0;
  for(int i = n-1 - k; i >= 0 ; i--) res += backet[i];
  cout << res << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <queue>
using namespace std;
#pragma warning (disable: 4996)

long long N, X, D, A[1 << 19], V[1 << 19];
map<long long, vector<pair<long long, long long>>>M;
vector<long long> M2;

long long Div(long long a, long long b) {
	// b > 0 を仮定
	if (a >= 0) {
		return a / b;
	}
	else if (a % b == 0) {
		return -(abs(a) / b);
	}
	else {
		long long V = (abs(a) / b);
		return -V - 1LL;
	}
}

long long solve(vector<pair<long long, long long>> a) {
	vector<long long> F;
	for (int i = 0; i < a.size(); i++) {
		F.push_back(a[i].first);
		F.push_back(a[i].second);
	}
	sort(F.begin(), F.end());
	F.erase(unique(F.begin(), F.end()), F.end());

	for (int i = 0; i <= F.size(); i++) V[i] = 0;

	for (int i = 0; i < a.size(); i++) {
		int pos1 = lower_bound(F.begin(), F.end(), a[i].first) - F.begin();
		int pos2 = lower_bound(F.begin(), F.end(), a[i].second) - F.begin();
		V[pos1]++; V[pos2]--;
	}
	for (int i = 1; i < F.size(); i++) V[i] += V[i - 1];

	long long ret = 0;
	for (int i = 0; i < F.size() - 1; i++) {
		if (V[i] >= 1) ret += (F[i + 1] - F[i]);
	}
	return ret;
}

int main() {
	cin >> N >> X >> D;
	if (D == 0) {
		if (X == 0) cout << "1" << endl;
		else cout << N + 1 << endl;
		return 0;
	}
	if (D < 0) {
		long long LAST = X + 1LL * (N - 1LL) * D;
		X = LAST;
		D *= -1LL;
	}

	// 等差数列を計算する
	A[1] = X;
	for (int i = 2; i <= N; i++) A[i] = A[i - 1] + D;

	// 通り数を計算する
	long long c1 = 0, c2 = 0;
	for (int i = 0; i <= N; i++) {
		long long pl = Div(c1, D), pr = Div(c2, D);
		long long amari = c1 - D * pl;
		M[amari].push_back(make_pair(pl, pr + 1));
		M2.push_back(amari);
		if (i != N) { c1 += A[i + 1]; c2 += A[N - i]; }
	}

	// いもす法
	sort(M2.begin(), M2.end());
	M2.erase(unique(M2.begin(), M2.end()), M2.end());

	long long answer = 0;
	for (long long i : M2) {
		vector<pair<long long, long long>> R = M[i];
		answer += solve(R);
	}

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 26348
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

//typedef __int64 lint;

const double EPS = 1e-10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int INF = 1001001001;
//const lint INFLL = (__int64)1001001001001001001;

#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))

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


pair<int, int> seg[1 << 18];

void update(int k, int x)
{
	int id = k + 1;
	k += (1 << 17) - 1;
	seg[k].first += x;
	seg[k].second = id;
	while (k){
		k = (k - 1) / 2;
		if (seg[k * 2 + 1].first > seg[k * 2 + 2].first){
			seg[k] = seg[k * 2 + 1];
		}
		else if (seg[k * 2 + 1].first < seg[k * 2 + 2].first){
			seg[k] = seg[k * 2 + 2];
		}
		else {
			seg[k] = seg[k * 2 + 1];
		}
	}
}

int main()
{
	int N, R, L;
	int team[100000] = {0};
	
	scanf("%d %d %d", &N, &R, &L);
	
	for (int i = 0; i < N; i++) update(i, 0);
	
	int prev = 0;
	int top = 0;
	for (int i = 0; i < R; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		team[top] += b - prev;
		update(a - 1, c);
		top = seg[0].second - 1;
		prev = b;
	}
	team[top] += L - prev;
	
	int maxi = 0;
	for (int i = 1; i < N; i++) if (team[maxi] < team[i]) maxi = i;
	
	printf("%d\n", maxi + 1);
	
	return (0);
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long e[100005],f[100005],h[100005];
long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
long long max(long long a,long long b)
{
	return a>b?a:b;
}
int main()
{
	long long ans=0;
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&e[i]);
		if(i==0)
			f[i] = e[i];
		else
			f[i] = gcd(f[i-1],e[i]);
	}
	for(i=n-1;i>=0;i--)
	{
		if(i==n-1)
			h[i] = e[i];
		else
			h[i] = gcd(h[i+1],e[i]);
	}
	for(i=0;i<n;i++)
	{
		if(i==0)
			ans = max(ans,h[i+1]);
		else if (i==n-1)
			ans = max(ans,f[i-1]);
		else
			ans = max(ans,gcd(f[i-1],h[i+1]));
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6116
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Fdn(i,b,a) for(int i=b;i>=a;--i)
#define Printno {puts("-1"); return 0;}
using namespace std;
const int MAXN=1000005;

int n,ans,p[MAXN],ed[MAXN],tot;
char a[MAXN],b[MAXN],ch[MAXN];

int main(){
	scanf("%d%s%s",&n,a+1,b+1);
	int j=n+1, pr=n;
	bool bo=1;
	Fdn(i,n,1){
		if(b[i-1]!=b[i]){
			j=min(j-1,i);
			while(j>0&&a[j]!=b[i]) j--;
			//printf("%d :find %d\n",i,j);
			if(!j) Printno;
			p[++tot]=j;
			ed[tot]=pr; pr=i-1;
			ch[tot]=b[i];
		}
		if(a[i]!=b[i]) bo=0;
	}
	if(bo){puts("0"); return 0;}
	//Fdn(i,tot,1) printf("test: %d %d\n",p[i],ed[i]);
	p[0]=n+1;
	For(i,1,tot){
		while(p[i-ans]-ans<ed[i]) ans++;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 11008
# GRL1_C: All Pairs Shortest Path

INF = 1 << 32

def warshall_floyd(mtx)
  n = mtx.size
  n.times do |k|
    n.times do |i|
      n.times do |j|
        next if mtx[i][k] == INF || mtx[k][j] == INF
        mtx[i][j] = [
          mtx[i][j], mtx[i][k] + mtx[k][j]
        ].min
      end
    end
  end
end

def negative_cycle?(mtx)
  mtx.each_with_index.any? do |costs, from|
    costs.each_with_index.any? do |cost, to|
      from == to && cost < 0
    end
  end
end

def make_matrix_from_input
  n_verts, n_edges = gets.split.map &:to_i

  path_mtx = n_verts.times.map do |from|
    n_verts.times.map do |to|
      from == to ? 0 : INF
    end
  end

  n_edges.times do
    from, to, cost = gets.split.map &:to_i
    path_mtx[from][to] = cost
  end

  path_mtx
end


path_mtx = make_matrix_from_input
warshall_floyd path_mtx

if negative_cycle?(path_mtx)
  puts 'NEGATIVE CYCLE'
else
  path_mtx.each do |costs|
    puts costs.map { |cost|
      cost == INF ? 'INF' : cost
    }.join(' ')
  end
end

Measured memory_bytes: 9808
#include <iostream>

int main()
{
	int h, w;

	while (std::cin >> h >> w) {
		if (h == 0 || w == 0) break;
		for (int j = 0; j < h; j++) {
			for (int i = 0; i < w; i++) {

				if (j % 2 == 1) {
					if (i % 2 != 0)
						printf("#");
					else
						printf(".");
				}

				else {
					if (i % 2 == 0)
						printf("#");
					else
						printf(".");
				}

			}
			printf("\n");
		}
		printf("\n");
	}
	

	return 0;
}


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main  {
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		long L = 1;
		long A[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			long a = sc.nextLong();
			A[i] = a;
			long b = a / 2;
			L = (L * b) / gcd(L , b);
			if(M < L){
				System.out.println(0);
				return ;
			}
		}
		for(int i = 0 ; i < A.length ; ++i){
			if(L % A[i] == 0){
				System.out.println(0);
				return ;				
			}
		}
		long ret = 0;
		if(M < L){
			ret = 0;
		}else{
			ret = (M - L) / (2 * L) + 1;
		}
		System.out.println(ret);
	}
}


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

int p[100000];

int find(int a) {
    if (p[a]<0) {
        return a;
    }
    return p[a]=find(p[a]);
}

void merge(int a,int b) {
    a=find(a);
    b=find(b);
    if (a==b) {
        return;
    }
    p[b]=a;
}

bool used[100000];

int main(void) {
    memset(p,-1,sizeof(p));
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        a--;
        b--;
        merge(a,b);
    }
    int ret=-1;
    for(int i=0;i<n;i++) {
        if (!used[find(i)]) {
            used[find(i)]=true;
            ret++;
        }
    }
    printf("%d",ret);
}

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

using namespace std;

int main(){
  string s; cin >> s;
  int n = s.size();
  
  vector<char> c0(n);
  vector<char> c1(n);
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      c0[i] = '0';
      c1[i] = '1';
    }else{
      c0[i] = '1';
      c1[i] = '0';
    }
  }
  
  int diff0 = 0;
  int diff1 = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == c0[i]){
      diff1++;
    }else{
      diff0++;
    }
  }
  
  cout << min(diff0, diff1) << endl;
  
  return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 1e6 + 10;
const int MOD = 1e9 + 7;

ll inv[N], fact[N], ifact[N], pot[N];

ll comb(int m, int n) {
    if (n < 0 || n > m) return 0;
    return fact[m] * ifact[n] % MOD * ifact[m-n] % MOD;
}

void add(int &a, ll b) {
    a += b%MOD;
    if (a >= MOD) a-= MOD;
    if (a < 0) a += MOD;
}

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

    inv[1] = 1; forsn(n,2,N) inv[n] = (MOD - MOD/n) * inv[MOD%n] % MOD;
    fact[0] = 1; forsn(n,1,N) fact[n] = n * fact[n-1] % MOD;
    ifact[0] = 1; forsn(n,1,N) ifact[n] = inv[n] * ifact[n-1] % MOD;
    pot[0] = 1; forsn(n,1,N) pot[n] = pot[n-1]*3 % MOD;

    int a,b,c; cin >> a >> b >> c;


    ll res = 0;
    int l = 0, r = b; ll inter = 1;
    for (int yz = 0; yz <= b+c; yz++) {
        while (l < yz-c) {
            inter -= comb(yz,l++);
            if (inter < 0) inter += MOD;
        }

        res += inter * comb(a-1+yz,a-1) % MOD * pot[b+c-yz] % MOD;

        inter = 2*inter - comb(yz,r) + comb(yz,l-1);
        inter %= MOD; if (inter < 0) inter += MOD;
    }
    res %= MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<int,pair<int,int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000

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

  if(S=="RRR"){
    cout<<3<<endl;
  }else if(S=="SSS"){
    cout<<0<<endl;
  }else if(S=="RRS"||S=="SRR"){
    cout<<2<<endl;
  }else{
    cout<<1<<endl;
  }
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
  int a,b,c,d,e,f;
  double x,y;
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
    x = (double)(e*c-b*f) / (double)(a*e-b*d);
    y = (double)(a*f-c*d) / (double)(a*e-b*d);
    if(x==-0.000000) x = 0.000000;
    if(y==-0.000000) y = 0.000000;
    printf("%.3f %.3f\n",(double)x,(double)y);
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  char ch;
  cin >> ch;
  if (ch >= 'A' && ch <= 'Z') {
    cout << 'A' << endl;
  } else if (ch >= 'a' && ch <= 'z') {
    cout << 'a' << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int i,j,c=0,n,m;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      if(i+j<=m&&i+j+n>=m)c++;
    }
  }
  printf("%d\n",c);
  return 0;
}
		     


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.TreeMap;
import java.util.Map;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    Map<String,Integer>map = new TreeMap<String,Integer>();
    for(int i = 0;i < N;i++){
      map.put(scanner.next(),0);
    }
    System.out.println(map.size());
  }
}

Measured memory_bytes: 68124
import math

def eulers_phi_function(n):
    s = math.sqrt(n)
    x = n
    rst = n
    for y in range(2, math.ceil(s)):
        if x == 1: break
        while True:
            if x%y == 0:
                rst *= 1 - 1/y
                while x%y == 0:
                    x = x/y
            else:
                break
    if x > s: rst *= 1 - 1/x
    return int(rst)

n = int(input())
print(eulers_phi_function(n))



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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010;
const double eps = 1e-6;

int k;
string s;
vector<string> str;

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

    int len = min((int)s.size(), 5);
    for(int l = 1; l <= len; l++)
        for(int i = 0; i < s.size() - l + 1; i++)
        {
            string t = s.substr(i, l);
            str.push_back(t);
        }

    sort(str.begin(), str.end());
    str.erase(unique(str.begin(), str.end()), str.end());

    cout << str[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <typename T> istream & operator >> (istream & in, vector<T> & xs) { REP (i, xs.size()) { in >> xs[i]; } return in; }

template <typename UnaryPredicate>
int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    -- l;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;
        (p(m) ? r : l) = m;
    }
    return r;
}

/**
 * @return $\max \lbrace x \in (l, r] \mid p(x) \rbrace$, or l if it doesn't exist
 */
template <typename UnaryPredicate>
int64_t binsearch_max(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    ++ r;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;
        (p(m) ? l : r) = m;
    }
    return l;
}


int64_t solve(int64_t n, int64_t m, vector<int64_t> a) {
    sort(ALL(a));
    vector<int64_t> acc(n + 1);
    partial_sum(ALL(a), acc.begin() + 1);
    auto count_pairs_ge = [&](int64_t limit) {
        int64_t cnt = 0;
        int64_t sum = 0;
        REP (i, n) {
            int l = binsearch(i + 1, n, [&](int j) {
                return a[i] + a[j] >= limit;
            });
            cnt += (n - l) * 2;
            sum += (acc[n] - acc[l]) * 2;
            sum += a[i] * (n - l) * 2;
            if (a[i] * 2 >= limit) {
                cnt += 1;
                sum += a[i] * 2;
            }
        }
        return make_pair(cnt, sum);
    };
    int64_t limit = binsearch_max(0, 2 * *max_element(ALL(a)), [&](int64_t limit) {
        return count_pairs_ge(limit).first >= m;
    });
    int64_t cnt, sum; tie(cnt, sum) = count_pairs_ge(limit);
    return sum - (cnt - m) * limit;
}

int main() {
    int64_t n, m; cin >> n >> m;
    vector<int64_t> a(n); cin >> a;
    cout << solve(n, m, a) << endl;
    return 0;
}


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

#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define all(v) v.begin(),v.end()

int main()
{
	FIO
	string s;
	cin >> s;
	int i = 0;
	int j = (int)s.length() - 1;
	int cnt = 0;
	while(i < j) {
		if(s[i] != s[j])
			cnt+=1;
		i+=1;
		j-=1;
	}
	cout << cnt << "\n";
	return 0;
}

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

if __name__ == "__main__":
    # str_list = [map(int, input().split())]
    # if str_list.count(5) == 2 and str_list.count(7) == 1:
    #     print('YES')
    # else:
    #     print('NO')
    str_list = list(map(int, input().split()))
    if sum(str_list) == 17:
        print('YES')
    else:
        print('NO')







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

int main(){

  string a,b;
  cin >> a >> b;

  if ((a == "H" && b == "H") || (a == "D" && b == "D")) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }

}


Measured memory_bytes: 256
/*
	dp[i][j] = no. of ways to reach (H, W) from (i, j)	
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

int main(){
	int H, W;
	vector<vector<ll> > dp;
	vector<string> a;
	cin>>H>>W;
	a.assign(H+1, "");
	dp.assign(H+1, vector<ll>(W+1, 0));
	for(int i=0;i<H;i++){
		cin>>a[i];
	}
	for(int i=W-1;i>=0;i--){
		if(a[H-1][i] != '#')
			dp[H-1][i] = 1;
		else
			break;
	}
	for(int i=H-1;i>=0;i--){
		if(a[i][W-1] != '#')
			dp[i][W-1] = 1;
		else
			break;
	}
	for(int i=H-2;i>=0;i--){
		for(int j=W-2;j>=0;j--){
			if(a[i][j] != '#')
				dp[i][j] = (dp[i+1][j] + dp[i][j+1])%mod;
		}
	}
	cout<<dp[0][0]<<"\n";
	/*for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char in[20];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	long long ret=0;
	for(int i=0;i<(1<<(n-1));i++){
		long long tmp=0;
		for(int j=0;j<n;j++){
			tmp*=10;tmp+=in[j]-'0';
			if((i&(1<<j))||j==n-1){
				ret+=tmp;tmp=0;
			}
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
int main(){
    int n;cin>>n;
    vector<set<int> > st(10,{inf});
    string s;cin>>s;
    for(int i=0;i<n;++i){
        st[s[i]-'0'].insert(i);
    }
    int ans=0;
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            for(int k=0;k<10;++k){
                int a,b,c;
                a=*st[i].lower_bound(0);
                if(a==inf) continue;
                b=*st[j].upper_bound(a);
                if(b==inf) continue;
                c=*st[k].upper_bound(b);
                if(c!=inf) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5072
/*
Breadth First Search(https://onlinejudge.u-aizu.ac.jp/#/problems/ALDS1_11_C)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define pb(v) push_back(v)
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

const int MAX = 128;

//隣接リスト
vector <int> adj[MAX];
//頂点１からの距離
int d[MAX];

void solve(void){
	//init
	ENJYU;
	memset(d, -1, sizeof(d));
	//input
	int N;
	cin >> N;
	rep(N, i) {
		int u, k;
		cin >> u >> k;
		u--;
		rep(k, i) {
			int v;
			cin >> v;
			v--;
			adj[u].pb(v);
		}
	}
	//bfs
	queue <int> q;
	q.push(0);
	d[0] = 0;
	while (!q.empty()) {
		int n = q.front();
		q.pop();
		for (int nv : adj[n]) {
			if (d[nv] >= 0) {
				continue;
			}
			d[nv] = d[n] + 1;
			q.push(nv);
		}
	}

	rep(N, i) cout << i+1 << ' ' << d[i] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>

int main()
{
int x,y;


while (1){
scanf("%d %d",&x,&y);

if (x == 0 && y == 0){
break;
}

if (x < y){
printf("%d %d\n",x,y);
}
else
{
printf("%d %d\n",y,x);
}

}

return 0;
}

Measured memory_bytes: 600
import math 
import functools

K= int(input())
gcd_list = [ [float('INF') for i in range(K+1)] for j in range(K+1)]
#print(gcd_list)

for i in range(1,K+1):
    for j in range(1, K+1):
        gcd_list[i][j] = math.gcd(i,j)
#for g in gcd_list:
    #print(g)
mysum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        mygcd = gcd_list[i][j]
        for k in range(1,K+1):
            mygcd2 = math.gcd(mygcd, k)
            mysum += mygcd2 
        
print(mysum)

Measured memory_bytes: 10880
#include <stdio.h>

int main(void){

  int a,b;
  int i;

  scanf("%d %d",&a,&b);

  if(a <= 5){
    i = 0;
  } else if(a >= 6 && a <= 12){
    i = b/2;
  } else {
    i = b;
  }

  printf("%d",i);
}


Measured memory_bytes: 1712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    ans = a-b-c;
    if(ans < 0){
        cout << (-1*ans);
    }
    else{
        cout << 0;
    }
}

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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;
const int K = 3e3 + 5;
const ll mod = 1e9 + 7;

typedef pair <ll, ll> pll;

ll dp[K];
ll fact[N];
vector < pll > p;

ll bigmod(ll p, ll q) {
  ll res = 1ll;
  while(q) {
    if(q & 1ll) {
      res = (res * p) % mod;
    }
    q >>= 1;
    p = (p * p) % mod;
  }
  return res;
}


ll inverse(ll p) {
  return bigmod(p, mod - 2);
}

ll combi(ll n, ll r) {
  if(n < 0 or r < 0 or r > n) return 0;
  ll u = fact[n];
  ll v = (fact[r] * fact[n - r]) % mod;
  return (u * inverse(v)) % mod;
}

ll ways(pll x, pll y) {
  ll p = (y.first - x.first);
  ll q = (y.second - x.second);
  return combi(p + q, p) % mod;
}

ll get(int pos) {
  if(dp[pos] != -1) {
    return dp[pos];
  }
  ll res = ways({1, 1}, p[pos]);
  for(int i = 0; i < pos; i++) {
    ll paths = (get(i) * ways(p[i], p[pos])) % mod;
    res = (res + mod - paths) % mod;
    assert(res >= 0);
  }
  return dp[pos] = res;
}

int main() {
  fact[0] = 1;
  for(int i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  int t; t = 1;
  while(t--) {
    memset(dp, -1, sizeof dp);
    p.clear();
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    if(k == 0) {
      printf("%lld\n", ways({1, 1}, {n, m}));
    } else {
      for(int i = 0; i < k; i++) {
        int x, y; scanf("%d %d", &x, &y);
        p.push_back({x, y});
      }
      p.push_back({n, m});
      sort(p.begin(), p.end());
      printf("%lld\n", get(k) % mod);
    }
  }
  return 0;
}

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

string S;

int main(){
	cin>>S;
	cout<<S.substr(0,5)<<" "<<S.substr(6,7)<<" "<<S.substr(14,5)<<endl;
	return 0;
}


Measured memory_bytes: 764
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
nums = list(map(int,input().split()))
cnt =0
while True:
  if x-cnt not in nums:
    print(x-cnt)
    break
  if x+cnt not in nums:
    print(x+cnt)
    break
  cnt +=1


Measured memory_bytes: 9108
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    A, B, C, X, Y = Scanner.map_int()
    ans = 0
    C *= 2
    if A + B >= C:
        n = min(X, Y)
        X -= n
        Y -= n
        ans += C * n
    if A <= C:
        ans += X * A
    else:
        ans += X * C
    if B <= C:
        ans += Y * B
    else:
        ans += Y * C
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _n: usize = read()[0];
    let a: Vec<usize> = read();
    let mut v = vec![0_usize; 100_002];
    for &i in a.iter() {
        v[i] += 1;
        v[i + 1] += 1;
        v[i + 2] += 1;
    }
    let ans = v.iter().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 6396
[N, M] = list(map(int, input().split()))
list_cnt = []
for i in range(M):
  ab = list(map(int, input().split()))
  list_cnt.append(ab[0])
  list_cnt.append(ab[1])
for k in range(1, N+1):
  print(list_cnt.count(k))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p[200005],k,ans=0;
signed main(){
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>p[i];
    sort(p,p+n);
    for(int i=0;i<n-k;i++){
        ans+=p[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<assert.h>
#include<stdbool.h>
#include<math.h>
#include<string.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];




void ini(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE,
    col[i]=FREE;
  }
 for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }

}


void pri(){
  
  int i,j;
  for(i=0;i<N;i++){
     for(j=0;j<N;j++){
       if(X[i][j]){
         if(row[i]!=j) return;
       }
     }
  }

  for(i=0;i<N;i++){
     for(j=0;j<N;j++){
       printf("%s",((row[i]==j)?"Q":"."));
     }
     printf("\n");
  }
}


void rec(int i){
  int j;
  if(i==N){
    pri();
    return;
  }

   for(j=0;j<N;j++){
     if(NOT_FREE==col[j] || NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+N-1]) continue;

     row[i]=j;
     col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
     rec(i+1);

     row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
   }
}


int main(){
  int i,j;
  
  ini();

   for(i=0;i<N;i++){
     for(j=0;j<N;j++){
       X[i][j]=false;
     }}


   int k,r,c;
   scanf("%d",&k);

   
   for(i=0;i<k;i++){
     scanf("%d%d",&r,&c);
     X[r][c]=true;
   }

   rec(0);

   return 0;
}




Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

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

		double r = sc.nextDouble();

		System.out.println(String.format("%.6f", r*r*Math.PI) + " " + String.format("%.6f", 2*r*Math.PI));

	}
}



Measured memory_bytes: 28264
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define PI 3.14159265358979323846
int main(void) {
    double A, B , H , M;
    double ans;
    cin >> A >> B >> H >> M;

    if(H==0 && M==0) {
      cout << abs(A-B) << endl;
      return 0;
    }

    double ang_A,ang_B;

    ang_A = 30.0*H + 0.5*M;
    ang_B = 6.0*M;

    double rad;
    rad = (ang_A-ang_B)*PI/180.0;
    ans = A*A + B*B - 2.0*A*B*cos(rad);
    printf("%.10lf\n",sqrt(ans) );

    return 0;
}


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

using namespace std;

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)



void solve()
{
    int n,i,j;
    cin>>n;
    vector<double> p(n);
    for(i=0;i<n;i++)
        cin>>p[i];
    if(n==1)
    {
        cout<<p[0]<<endl;
        return;
    }
    vector< vector<double> > dp(2, vector<double> (n+1, 0)); // dp[i][x] denotes probability of x heads
    bool currIndex = 0;
    dp[1][0] = 1-p[0];
    dp[1][1] = p[0];
    for(i = 1; i < n; i++)
    {
        dp[currIndex][0] = dp[!currIndex][0]*(1-p[i]);
        for(j = 0; j < n; j++)
            dp[currIndex][j+1] = (dp[!currIndex][j]*p[i]) + (dp[!currIndex][j+1]*(1-p[i]));
        currIndex = !currIndex;
    }
    currIndex = !currIndex;
    double ans = 0;
    for(i = n/2+1; i<=n; i++)
        ans+=dp[currIndex][i];
    cout<<setprecision(10)<<ans<<endl;
}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
	tc = 1;
    // cin>>tc;
    while(tc--)
        solve();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    string S; cin >> S;
    int n = bit(N);
    vec P(n); cin >> P;

    mat Q(N + 1, vec(n));
    Q[0] = P;
    REP(i, N){
        REP(j, n){
            int a = Q[i][j], b = Q[i][(j + bit(i)) % n];
            if(S[llabs(a - b) - 1] == '0') Q[i + 1][j] = min(a, b);
            else Q[i + 1][j] = max(a, b);
        }
    }
    REP(i, n) Out(Q[N][i]);

    return 0;
}



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

using namespace std;

const int N = 3005;

int n; long long a[N], f[N][N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int l = n; l > 0; --l) {
    f[l][l] = a[l];
    for (int r = l + 1; r <= n; ++r) {
      f[l][r] = max(a[l] - f[l + 1][r], a[r] - f[l][r - 1]);
    }
  }
  cout << f[1][n] << endl;
  return 0;
}



Measured memory_bytes: 70016
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	int n;
	cin >> n;
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		
		while (!(a % 2)) {
			ans++;
			a /= 2;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1e8;
    int size = s.size();
    int wcnt = 0;
    int rcnt = 0;
    rep(i,size){
        if(s.at(i) == 'W'){
            wcnt++;
        }
        else{
            rcnt++;
        }
    }
    wcnt = 0;
    ans = min(ans, max(0,rcnt));
    rep(i,size){
        if(s[i] == 'W'){
            wcnt++;
            ans = min(ans,max(wcnt,rcnt));
        }
        else{
            rcnt--;
            ans = min(ans,max(wcnt,rcnt));
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF (1e9)

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N-1; i++) {
        cin >> a[i];
    }

    int dp[2][5010][2];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 5010; j++) {
            for (int k = 0; k < 2; k++) {
                dp[i][j][k] = INF;
            }
        }
    }

    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        int curr = (i & 1), next = (~i & 1);
        for (int j = 0; j <= N/2; j++) {
            dp[next][j+1][0] = min(dp[curr][j][0], dp[curr][j][1] + a[i]);
            dp[next][j][1] = min(dp[curr][j][1], dp[curr][j][0] + a[i]);
        }
        dp[curr][0][0] = INF;
    }
    cout << dp[N%2][N/2][0] << endl;
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1000000000;/* 1e+9a */

ull calc(ull X){
    ull ans = 0;
    if(X % 4 == 1 or X % 4 == 2){
        ans = 1;
    }
    ull p2 = 2;
    while(p2 <= X){
        ll mask = p2 * 2 - 1;
        ll od = X & mask;
        if(od >= p2){
            od -= p2 - 1;
            if(od % 2){
                ans |= p2;
            }
        }
        p2 *=2;
    }
    return ans;
}

void solve(istream &cin) {
    ull A, B;
    cin >> A >> B;
    if(!cin) return;
    if(A == 0){
        cout << calc(B) << endl;
    }
    else {
        cout << (calc(B) ^ calc(A-1)) << endl;
    }
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>

using namespace std;

int main()
{
	int k, s;
	cin >> k >> s;
	int x, y, z;
	int c = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			x = i;
			y = j;
			z = s - x - y;
			if (0 <= z && z <= k)c++;
		}
	}
	cout << c;
	return 0;
}



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

using namespace std;

int main(){
  string X, Y;
  cin >> X;
  cin >> Y;
  int n = X.size();
  int m = Y.size();
  int dp[n+1][m+1];
  for(int i=0;i<n+1;i++){
    dp[i][0] = i;
  }
  for(int i=0;i<m+1;i++){
    dp[0][i] = i;
  }
  for(int i=1;i<n+1;i++){
    for(int j=1;j<m+1;j++){	
      if(X[i-1] == Y[j-1]){
	dp[i][j] = min(dp[i-1][j-1],min(dp[i][j-1]+1, dp[i-1][j]+1));
      }else{
	dp[i][j] = min(dp[i-1][j-1]+1,min(dp[i][j-1]+1,dp[i-1][j]+1));
	
      }
      //cout << dp[i][j];
    }
    //cout << endl;
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 7080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		String t = scan.next();
		
		String[] s1 = s.split("");
		String[] t1 = t.split("");
		
		if(s1.length == t1.length) {
			int ans1 = s1.length;
			
			for(int i = 0; i < t1.length; i++) {
				
				if(s1[i].equals(t1[i])) {
					ans1--;
				}
			}
			
			System.out.print(ans1);
			return;
		}
		
		int[] ans = new int[s1.length-t1.length-1];
		
		for(int j = 1; j < s1.length-t1.length; j++) {
			
			String str = s.substring(j, j+t1.length);
			//System.out.println(str);
			String[] str1 = str.split("");
			
			ans[j-1] = t1.length;
			
			for(int i = 0; i < t1.length; i++) {
				
				if(str1[i].equals(t1[i])) {
					ans[j-1]--;
				}
			}
		}
		
		int sm = 10000000;
		
		for(int i = 0; i < ans.length; i++) {
			//System.out.println(ans[i]);
			if(ans[i] < sm) {
				sm = ans[i];
			}
		}
		
		System.out.print(sm);

	}

}

Measured memory_bytes: 55788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) cin >> L.at(i);
	int sum = 0;
	sort(L.begin(), L.end());
	rep(i,n) {
		rep2(j, i + 1, n) {
			auto it = lower_bound(L.begin()+j+1, L.end(), L[i] + L[j]);
			int index =it-L.begin() ;
			sum += index - j - 1;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;
LL N, K; 
LL Gcd(LL A, LL B) {
	if(!B) return A;
	return Gcd(B, A % B);
}
int main() {
	scanf("%lld%lld", &N, &K);
	LL M = N - K;
	if(M == K) printf("%lld", 3 * K);
	else printf("%lld", (N - Gcd(N, K)) * 3);
}

Measured memory_bytes: 128
if __name__ == "__main__":
    a,b,c,d=map(int,input().strip().split())
    jishu1=0
    jishu2=0
    while True:
        a=a-d
        jishu1+=1
        if a<=0:
            break
    while True:
        c=c-b
        jishu2+=1
        if c<=0:
            break
    if jishu1<jishu2:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
	int n;
	cin >> n;
	vector<string> w(n);
	rep(i,n) cin >> w[i];
	char e=w[0][w[0].size()-1];
	string ans = "Yes";
	rep(i,n){
		for(int j=i+1;j<n;j++){
			if(w[i] == w[j]){
				ans = "No";
				break;
			}
		}
	}
	rep(i,n-1){
		if(e!=w[i+1][0]) {
			ans = "No";
			break;
		}
		e=w[i+1][w[i+1].size()-1];
	}

	cout << ans << endl;

	return 0;

}




Measured memory_bytes: 764
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
#define out return cout << "-1" << endl, 0
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//const int mx = 1e5 + 10;
const int m = 1e9 + 7, mx = 1e5 + 10;
int dp[mx];
int _pow(int a , int b){
	return(!b ? 1 : _pow(a * a % m , b >> 1) * ((b & 1) ? a : 1) % m);
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, k, ans = 0;
	cin >> n >> k;
	for(int i = k; i; i--){
		dp[i] = _pow(k / i , n);
		for(int j = 2 * i; j <= k; j += i){
			dp[i] -= dp[j];
			dp[i] = (dp[i] % m + m) % m;
		}
		ans = (ans + dp[i] * i % m) % m;
	}
	cout << ans << endl;
	return 0;
}


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

int main(void){
	string s;
	cin>>s;
	bool flag=true;
	if(s[0]!='A')flag=false;

	int num=0;
	for(int i=1;i<s.length();i++){
		if((i==1 || i==s.length()-1) && s[i]=='C')flag=false;
		if(s[i]=='C')num++;
		else{
			if(!('a'<=s[i] && s[i]<='z'))flag=false;
		}
	}
	if(num != 1)flag=false;
	if(flag)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
	return 0;
}


Measured memory_bytes: 256