akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

int const N = 3e3 + 41;
int const MOD = 1e9 + 7;

int n, m, a[N], dp[N][N], was[N][N], maxi[N], mini[N], sum, pMini[N], pMaxi[N];

bool comp(int a, int b){
	return b < a;
}

void read(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%1d",&a[i]);
		sum += a[i];
		mini[i] = maxi[i] = a[i];
	}
	for(int i=0;i<m;++i){
		int le, ri;
		scanf("%d %d",&le,&ri);
		sort(mini+le,mini+ri+1,comp);
		sort(maxi+le,maxi+ri+1);
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

void findP(){
	int curMini = 0;
	int curMaxi = 0;
	for(int i=1;i<=n;++i){
		curMini += mini[i];
		curMaxi += maxi[i];
		if(mini[i] == 1){
			pMini[curMini] = i;
		}
		if(maxi[i] == 1){
			pMaxi[curMaxi] = i;
		}
	}
}

int rec(int one, int pos){
	if(was[one][pos]){
		return dp[one][pos];
	}
	was[one][pos] = 1;
	if(one == 0){
		return dp[one][pos] = 1;
	}
	if(pos == 0){
		return dp[one][pos] = 0;
	}

	if(pos < pMini[one]){
		return dp[one][pos] = 0;
	}
	if(pMini[one] <= pos && pos <= pMaxi[one]){
		dp[one][pos] += rec(one-1, pos-1);
	}
	dp[one][pos] += rec(one, pos-1);
	dp[one][pos] %= MOD;

	return dp[one][pos];
}

void solve(){
	findP();
	printf("%d\n",rec(sum, n));
}

int main(){
	prepare();
	read();
	solve();




	return 0;
}

Measured memory_bytes: 13312
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var D=Arr.shift()-0;
var x=Arr.shift()-0;
var X=[];
for(var i=0;i<x;i++){
   var v=Arr.shift().split(" ");
   if(v[0]=="D")X.push(v[1]-0);
}
X.sort(function(a,b){return b-a;});
var y=Arr.shift()-0;
var Y=[];
for(var i=0;i<y;i++){
   var v=Arr.shift().split(" ");
   if(v[0]=="DD")Y.push(v[1]-0);
}
Y.sort(function(a,b){return b-a;});
var max=0;
for(var x=0;x<=X.length;x++){
   for(var y=0;y<=Y.length;y++){
      if(D<x+(y*2))break;
      var sum=0;
      for(var i=0;i<x;i++)sum+=X[i];
      for(var i=0;i<y;i++)sum+=Y[i];
      max=Math.max(max,sum);
   }
}
console.log(max);

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int x;
  cin >> x;
  int sum = 100;
  int cnt = 0;
  while (sum < x)
  {
    cnt++;
    sum += (sum / 100);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	double w,h,x,y,max;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	max=(w*h)/2;
	printf("%lf",max);
	if(2*x==w&&2*y==h)
	printf(" 1");
	else printf(" 0");
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define pb push_back
#define fori(j,n) for(int i=j ; i<n ; i++)
#define forj(i,n) for(int j=i ; j<n ; j++)
#define fork(i,n) for(int k=i ; k<n ; k++)
#define ppb pop_back()
#define umap unordered_map
#define uset unordered_set
#define lli long long int
#define mod 1000000007

using namespace std;

void solve()
{
	double d,t,s;cin>>d>>t>>s;
	if(d<=t*s) cout<<"Yes";
	else cout<<"No";
	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	// int t;cin>>t;
	// while(t--)
	// {
		solve();
		// cout<<endl;
	// }

	return 0;

}


Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> P(N);
  REP(i, N){
    cin >> P[i];
    P[i]--;
  }


  vector<int> C(N);
  REP(i, N) cin >> C[i];

  REP(i, N){
    if(C[i] > 0) break;
    if(i == N-1){
      sort(ALL(C));
      cout << C.back() << "\n";
      return 0;
    }
  }

  vector<vector<int>> visited(N, vector<int>(N, 0));
  vector<vector<int>> score(N, vector<int>(N+1, 0));

  REP(i, N){
    int now = i;
    int cnt = 1;
    while(1){
      int next = P[now];
      visited[i][next] = visited[i][now]+1;

      if(cnt != 0) score[i][cnt] = score[i][cnt-1];
      score[i][cnt] += C[next];

      if(next == i) break;

      now = next;
      cnt++;
    }
  }

  int ans = -INF;
  REP(i, N){
    int cycle = visited[i][i];
    int loop = K/cycle;
    int amari = K%cycle;
    int ret = -INF;

    if(loop >= 1){
      REP(j, cycle+1){
        chmax(ret, score[i][j]);
      }
      if(score[i][cycle] >= 0) ret += (loop-1)*score[i][cycle];
      chmax(ans, ret);
    }
    {
      ret = -INF;
      REP(j, amari+1){
        chmax(ret, score[i][j]);
      }
      if(score[i][cycle] >= 0) ret += loop*score[i][cycle];
      chmax(ans, ret);
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 394388
n, m = map(int, input().split())

input_list = [0] * n

input_list_str = input().split()
input_list = [int(s) for s in input_list_str]
input_list = sorted(input_list, reverse=True)

vote_sum = sum(input_list)
vote_standard = vote_sum / (4 * m)

flag = True
for i in range(m):
    if input_list[i] < vote_standard:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
namespace ABC128.B
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;
    public struct Restaurant
    {
        public string City { get; set; }
        public int Point { get; set; }

        public Restaurant(string city, int point)
        {
            City = city;
            Point = point;
        }
    }
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadInputAsInt();
            var inputlines = Read(n);
            foreach (var item in Solve(inputlines.ToList()))
            {
                WriteLine(item);
            }
        }

        static int ReadInputAsInt() => int.Parse(ReadLine());

        public static IEnumerable<int> Solve(List<Restaurant> restaurants)
        {
            var rs = restaurants.Select((r, i) => new { R = r, Idx = i + 1 }).ToList();
            //rs.Sort((a, b) => a.R.Point < b.R.Point ? 1 : -1);

            rs.Sort((a, b) => string.Compare(a.R.City, b.R.City));

            string now = rs.First().R.City;

            var ret = new List<int>();
            while (true)
            {
                var samecity = rs.SkipWhile(x => x.R.City != now).TakeWhile(x => x.R.City == now).ToList();

                samecity.Sort((a, b) => a.R.Point < b.R.Point ? 1 : -1);

                ret.AddRange(samecity.Select(x => x.Idx));

                int v = rs.SkipWhile(x => x.R.City != now).SkipWhile(X => X.R.City == now).Count();
                if (v == 0) break;
                now = rs.SkipWhile(x => x.R.City != now).SkipWhile(X => X.R.City == now).First().R.City;
            }

            return ret;
        }


        static IEnumerable<Restaurant> Read(int lines)
        {
            for (int i = 0; i < lines; i++)
            {
                var l = ReadLine().Split(' ');
                yield return new Restaurant(l[0], int.Parse(l[1]));
            }
        }
    }
}

Measured memory_bytes: 11744
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ar<int,3>> v(n);
	for(int i = 0,j,k,l; i<n; i++)
	{
		cin>>j>>k>>l;
		v[i] = {j,k,l};
	}
	int flag = 1;
	int h = v[0][1]+v[0][2];
	if(v[0][0]!=h)
		if((v[0][0]-h)%2!=0 || v[0][0]<h) flag = 0;
	for(int i = 1; i<n; i++)
	{
		int t = v[i][0]-v[i-1][0];
		int dist = abs(v[i][1]-v[i-1][1])+abs(v[i][2]-v[i-1][2]);
		if(t<dist) flag = 0;
		else if((t-dist)%2!=0) flag = 0;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}


int main() {
	int n, a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
N,M = map(int, input().split())

"""
 xyz
0+++
1++-
2+-+
3+--
4-++
5-+-
6--+
7---

"""
dp = [[0]*N for i in range(8)]


for i in range(N):
    x,y,z = map(int, input().split())
    dp[0][i] = x+y+z
    dp[1][i] = x+y-z
    dp[2][i] = x-y+z
    dp[3][i] = x-y-z
    dp[4][i] = -x+y+z
    dp[5][i] = -x+y-z
    dp[6][i] = -x-y+z
    dp[7][i] = -x-y-z

ans = 0
for i in range(8):
    sums = sorted(dp[i], reverse=True)
    ans = max(sum(sums[:M]),ans)
print(ans)

Measured memory_bytes: 3316
n=int(input())
taro=[]
for _ in range(n):
    taro.append(list(map(str,input().split())))
s=list(range(1,14))
h=list(range(1,14))
c=list(range(1,14))
d=list(range(1,14))
for i in range(n):
    if taro[i][0]=='S':
        num=int(taro[i][1])
        s[num-1]=0
    elif taro[i][0]=='H':
        num=int(taro[i][1])
        h[num-1]=0
    elif taro[i][0]=='C':
        num=int(taro[i][1])
        c[num-1]=0
    else:
        num=int(taro[i][1])
        d[num-1]=0

new_s=[i for i in s if i !=0]
new_h=[i for i in h if i !=0]
new_c=[i for i in c if i !=0]
new_d=[i for i in d if i !=0]

for i in new_s:
    print('S {0}'.format(i))
for i in new_h:
    print('H {0}'.format(i))
for i in new_c:
    print('C {0}'.format(i))
for i in new_d:
    print('D {0}'.format(i))


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
int n,a[max_n];
ll suf[max_n];
ll ans[max_n];
int main(){
    scanf("%d",&n);
    for(int i=0;i<=n;i++)scanf("%d",a+i);
    for(int i=n;i>=0;i--)suf[i]=suf[i+1]+a[i];
    ans[0]=1;
    for(int i=1;i<=n;i++){
        //ans[i]=min(ans[i-1]*2)
        ans[i]=min((ans[i-1]-a[i-1])*2,suf[i]);
    }
    for(int i=0;i<=n;i++)if(ans[i]<a[i])return printf("-1\n"),0;
    ll res=0;
    for(int i=0;i<=n;i++)res+=ans[i];
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e9;


int main()
{
    ios::sync_with_stdio(false);
    int n,d;
    cin>>n>>d;
    int t=n/(2*d+1);
    if(n%(2*d+1))cout<<t+1<<endl;
    else cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;}
const int maxn=2e5;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
/*
vector<int> adj[maxn+1];
bool vis[maxn+1];
ll power(ll a,ull b){
    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a)%MAX;
        a=(a*a)%MAX;
        b/=2;
    }
    return(ans);
}
void dfs(int node){
    vis[node]=true;
    for(auto nex:adj[node]){
        if(!vis[nex]) dfs(nex);
    }
}
*/
void solve(){
    int n;
    cin>>n;
    int a[n+1],b[n];
    for(int i=0;i<n+1;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    ll cnt=0;
    int c=0;
    for(int i=0;i<n;i++){
        if(b[i]>a[i]){
            cnt+=a[i];
            c=a[i+1];
            a[i+1]=max(0,a[i+1]-(b[i]-a[i]));
            cnt+=c-a[i+1];
        }
        else if(b[i]<=a[i]){
            cnt+=b[i];
        }
    }
    cout<<cnt;
    return;
}
int main(){
    IO
    solve();



    return(0);
}


Measured memory_bytes: 4408
import java.util.Scanner;

//Problem B
public class Main{

	int get(int t, int m){
		int r = 0;
		while(true){
			if(r+t<=m)r+=t;
			else return r;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			int assign = 0;
			int time = get(a[0], m);
			int d = a[0];
			boolean f = false;
			for(int i=1;i<n;i++){
				int t = get(a[i], m);
				if(time < t)continue;
				if(time==t){
					if(a[i]<d){
						f = false;
						assign = i;
						d = a[i];
					}
					else if(a[i]==d){
						f = true;
					}
				}
				else{
					f = false;
					assign = i;
					d = a[i];
					time = t;
				}
			}
			System.out.println(f?n+"":++assign+"");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <string>
using namespace std;
static const double pi = 3.141592653589793;


int main(){
  int n, m, a = 0, b, ans = 0;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++){
    cin >> b;
    a = a + b;
  }
  if(0 <= n - a){
    ans = n -a;
  }else{
    ans = -1;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3648
import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import qualified Data.Vector.Unboxed as V

solve :: [String] -> [[Int]]
solve [] = []
solve (s:ss) = f s:solve ss
  where
    f s = map (\a -> length (elemIndices a s)) ['a' .. 'z']

count :: [[Int]] -> [Int] -> [Int]
count iss xs = foldl (flip (zipWith min)) xs iss

create :: [Int] -> String -> String
create [] _ = []
create (c:cs) (x:xs) = replicate c x ++ create cs xs

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n $ sort <$> getLine
  let cs = solve ss
      as = count cs (replicate 26 50)
  putStrLn $ create as ['a' .. 'z']


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

const long MAXN=200100;

map<string,long> m;
long n;
string s;

struct v{
	long num;
	string name;
} p[MAXN];

bool cmp(v a,v b) {
	if(a.num!=b.num)
		return a.num>b.num;
	return a.name<b.name;
}

int main() {
	cin>>n;
	register long i;
	for(i=1;i<=n;++i) {
		cin>>s;
		++m[s];
	}
	
	i=0;
	for(map<string,long>::iterator it=m.begin();it!=m.end();it++) {
		p[++i].name=it->first;
		p[i].num=it->second;
	}
	sort(p+1,p+n+1,cmp);
	
	long max_vote=p[1].num;
	for(i=1;i<=n;++i)
		if(p[i].num==max_vote)
			cout<<p[i].name<<endl;
	return 0;
}

Measured memory_bytes: 28288
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1])
    cout << "Bad" << endl;
  else if (s[1] == s[2])
    cout << "Bad" << endl;
  else if (s[2] == s[3])
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        if (a < b){
        System.out.println("a < b");
        
        }else if (a > b){
        System.out.println("a > b");
        
        }else{
        System.out.println("a == b");
        }
}
}



Measured memory_bytes: 26184
N, X = map(int, input().split())
Ls = list(map(int, input().split()))

kaisuu=1
kyori=0

for i in range(len(Ls)):
  kyori=kyori+Ls[i]
  if kyori>X:
    break
  else:
    kaisuu=kaisuu+1

if kaisuu>N+1:
  kaisuu==N+1
    
print(kaisuu)

Measured memory_bytes: 3060
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;


const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}



ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}




int main(){
ll n;cin>>n;
string s;cin>>s;
ll red = 0;
for(ll i = 0 ; i<n ; i++){
	if(s[i] == 'R'){red++;}
	
	
}
ll wit = 0;
ll rd = 0;
for(ll i = 0; i<red ; i++){
	if(s[i] == 'W'){wit++;}
}
for(ll i = red ; i<n ; i++){
	if(s[i] == 'R'){rd++;}
}
cout<<max(wit,rd);







}

Measured memory_bytes: 3756
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter syso = new PrintWriter(System.out);
		int n=sc.nextInt();
		if(n>=30)syso.println("Yes");
		else syso.println("No");
        syso.close();
    }
    
 
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
 
	}
}

Measured memory_bytes: 25352
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		List<Integer> numbers = new ArrayList<Integer>(200);
		for(int i = 1; i <= n; i++) {
			numbers.add(sc.nextInt());
		}

		Integer countDivide = -1;
		boolean canDivide = true;

		while(canDivide) {
			countDivide += 1;
			for(int i = 0; i < n; i++) {
				Integer checkingNum = numbers.get(i);
				if(checkingNum % 2 == 1) {
					canDivide = false;
				} else {
					numbers.set(i, checkingNum / 2);
				}
			}
		}

		System.out.println(countDivide);
	}
}

Measured memory_bytes: 21716
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


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

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, q;
	while(cin >> n >> q) {
		string s;
		cin >> s;
		vector<char> t(q), d(q);
		REP(i, q) {
			cin >> t[i] >> d[i];
		}


		int rv = -1;
		{
			auto check = [&](int x) {
				REP(i, q) {
					if(s[x] == t[i]) {
						if(d[i] == 'L') {
							x--;
						} else {
							x++;
						}
					}
					if(x >= n) return true;
				}
				return false;
			};
			if(check(0)) {
				rv = n;
			} else {
				int l = 0, r = n;
				while(l + 1 < r) {
					int m = (l + r) / 2;
					if(check(m)) {
						r = m;
					} else {
						l = m;
					}
				}
				rv = n-r;
			}
		}


		int lv = -1;
		{
			auto check = [&](int x) {
				REP(i, q) {
					if(s[x] == t[i]) {
						if(d[i] == 'L') {
							x--;
						} else {
							x++;
						}
					}
					if(x < 0) return false;
				}
				return true;
			};
			
			if(check(0)) {
				lv = 0;
			} else {
				int l = 0, r = n;
				while(l + 1 < r) {
					int m = (l + r) / 2;
					if(check(m)) {
						r = m;
					} else {
						l = m;
					}
				}
				lv = r;
			}
		}
		cout << max(0, n - lv - rv) << endl;
	}
	return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    int a[4],b[4];
    
    while((cin>>a[0]>>a[1]>>a[2]>>a[3])){
        cin>>b[0]>>b[1]>>b[2]>>b[3];
        int hit =0;
        for(int i=0; i<4; i++){
            if(a[i]==b[i]){
                hit++;
                a[i]=10;
                b[i]=10;
            }
        }
        
        int blow=0;
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                if(b[i]==10){
                    break;
                }
                if(b[i]==a[j]){
                    blow++;
                    a[j]=10;
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int A = in.nextInt();
        int B = in.nextInt();

        if (A >= 13) {
            out.println(B);
        } else if (6 <= A && A <= 12) {
            out.println(B / 2);
        } else {
            out.println(0);
        }
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 20692
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) throws IOException {

        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    public static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            long x = in.nextLong();
            long y = in.nextLong();

            if (x % y == 0) {
                out.println("-1");
                return;
            }

            out.println(x % y == 0 ? "-1" : x);

        }

    }
//  }  ----------------------------------------------------------------------------
    // MAIN - INPUT - OUTPUT 

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }

            return array;
        }

        public char[][] nextMatrix(int row, int col) {

            char[][] m = new char[row][col];

            for (int i = 0; i < row; i++) {

                m[i] = next().toCharArray();
            }
            return m;
        }

    }
}


Measured memory_bytes: 21332
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 30 21:39:36 2017

@author: kanako_note
"""

A, B = map(int, input().split())
S = input()

if S[A]=='-' and S.count('-')==1 and len(S)==(A+B+1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        HashMap<Integer, Integer> hm = new HashMap<>();
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 1; i <= a; i++){
            hm.put(sc.nextInt(), i);
        }
        for(int i = 1; i <= a; i++){
            list.add(hm.get(i));
        }
        for(int i = 0; i < a; i++){
            System.out.print(list.get(i) + " ");
        }
    }
}

Measured memory_bytes: 69004
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  string s;
  cin >> s;
  rep(i,s.size()) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
  long long X, y, z;

  scanf("%lld",&X);

  y = X / 500;
  z = (X % 500) / 5;

  X = 1000 * y + 5 * z;
  printf("%lld\n", X);
  return 0;
}

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

int main() {
  int n , k; cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin() , h.end());

  vector<int> diff(n-1);
  rep(i,n-1) diff[i] = h[i+1] - h[i];
  //rep(i,n-1) cout << diff[i] <<" ";

  ll ans = 1000000000000000;
  for(int i = 0; i+(k-2) < (n-1); i++){
    ll nowans = 0;
    for(int j = i; j < i+(k-1); j++) {
      nowans += diff[j];
    }
    ans = min(ans , nowans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** n):
    flag = 1
    s_lst = []
    for j in range(n):
        if i >> j & 1:
            s_lst.append(1)
        else:
            s_lst.append(0)
    for j, k in zip(ks, p):
        if k == 1:
            tmp = 0
            for l in j[1:]:
                tmp += s_lst[l-1]
            if tmp % 2 != 1:
                flag = 0
        if k == 0:
            tmp = 0
            for l in j[1:]:
                tmp += s_lst[l-1]
            if tmp % 2 != 0:
                flag = 0
        #print(j, k)
    if flag == 1:
        ans += 1
    #print(bin(i), s_lst, flag)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#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>

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

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a, b;

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

	if (s == "AAA") {
		cout << "No" << endl;
	}
	else if (s == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    set<int> s;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            s.insert(i*j);
        }
    }
    cout << (s.count(n) ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
hoge=list(map(int,input().split()))
ans=0
rec=0
now=hoge[0]
for i in range(n-1):
  migi=hoge[i+1]
  if(now>=migi):
    ans+=1
  else:
    ans=0
  rec=max(ans,rec)
  now=migi
print(rec)

Measured memory_bytes: 15020
//ええなにそれ・・・割り算ってllよりdoubleの方が速いとでも？
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int tmp[200001];
void pakuri_sort(int N, int A[]) {
	const int b = 10;
	rep(k, 2) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
void pakuri_sort2(int N, int A[]) {
	const int b = 10;
	rep(k, 2) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu[i] += kazu[i + 1];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu2[i] += kazu2[i + 1];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort2(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			if ((ll)A[i] * F[i] > M) {
				kazu += A[i] - (int)((double)M / F[i]);
				if (kazu > K) break;
			}
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);

	Would you please return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> t(N);
  for(int i=0;i<N;i++){
    cin >> t.at(i);
  }
  int M; cin >> M;
  vector<pair<int,int>> drink(M);
  for(int i=0;i<M;i++){
    cin >> drink.at(i).first >> drink.at(i).second;
  }
  int time=0;
  for(int i=0;i<N;i++){
    time+=t.at(i);
  }
  vector<int> sa(M);
  for(int i=0;i<M;i++){
    sa.at(i)=t.at(drink.at(i).first-1)-drink.at(i).second;
  }
  for(int i=0;i<M;i++){
    cout << time-sa.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#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 f           first
#define se          second
#define maxn        100005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}


void solve(){ 
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << "\n";
}

signed main()   
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

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

int main()
{
	string s, w;
	s = "CODEFESTIVAL2016";
	cin >> w;
	int cnt = 0;
	for (int i = 0; i < 16; i++) {
		if (w[i] != s[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    double a[n], pro=1, sum=0, ans=1;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    for(int i=0; i<n; i++) pro *= a[i];
    for(int i=0; i<n; i++) sum += pro/a[i];

    ans = pro/sum;
    cout << ans << endl;

    return 0;
}



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

string S, T;

void solve() {
	cin >> S >> T;
	int res = 0;
	rep(i, 0, sz(S)) {
		if(S[i] == T[i]) res++;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
void calcDist(vector<long long>& dist, const vector<vector<pair<int,int>>>& G, int v0) {
	priority_queue<pair<long long,int>> Q;
	dist[v0] = 0;
	Q.push({0, v0});
	while (!Q.empty()) {
		long long d = -Q.top().first;
		int v = Q.top().second;
		Q.pop();
		if (dist[v] != d) continue;
		for (auto p : G[v]) {
			int vv = p.first;
			long long dd = d + p.second;
			if (dd < dist[vv]) {
				dist[vv] = dd;
				Q.push({-dd, vv});
			}
		}
	}
	//for (auto x : dist) cout << x << " "; cout << endl;
}
int main() {
	int N, M, S, T;
	cin >> N >> M >> S >> T;
	-- S; -- T;
	vector<vector<pair<int,int>>> G1(N), G2(N);
	for (int i = 0; i < M; ++ i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		-- u; -- v;
		G1[u].push_back({v,a});
		G1[v].push_back({u,a});
		G2[u].push_back({v,b});
		G2[v].push_back({u,b});
	}
	vector<long long> dist1(N, INF), dist2(N, INF);
	calcDist(dist1, G1, S);
	calcDist(dist2, G2, T);
	vector<long long> r(N);
	long long rr = INF;
	for (int i = N-1; i >= 0; -- i) {
		//cerr << dist1[i] + dist2[i] << endl;
		rr = min(rr, dist1[i] + dist2[i]);
		r[i] = rr;
	}
	for (auto x : r) cout << (1000000000000000LL-x) << endl;
}


Measured memory_bytes: 16068
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int X;
int ans=0;
int main(){
  cin >> X;
  int i;
  for(i=1;i<X;i++){
    ans+=i;
    if(ans>=X)break;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
ans = 0
for i in range(K):
    current_list = []
    k = i
    while k < len(T):
        current_list.append(T[k])
        k += K
    current_value = current_list[0]
    c = 1
    for j in range(1,len(current_list)):
        if current_value == current_list[j]:
            c += 1
        else:
            if current_value == 'r':
                ans += ((c+1)//2)*P
            elif current_value == 's':
                ans += ((c+1)//2)*R
            else:
                ans += ((c+1)//2)*S
            c = 1
            current_value = current_list[j]
    if current_value == 'r':
        ans += ((c+1)//2)*P
    elif current_value == 's':
        ans += ((c+1)//2)*R
    else:
        ans += ((c+1)//2)*S
print(ans)

Measured memory_bytes: 4212
// frogs.cpp
#include<iostream>
#include<cstring>
using namespace std;

int main(){

int n;
cin >>n;
int arr[n];
for(int i=0;i<n;i++) cin>> arr[i];
int dp[n];
memset(dp,0,sizeof(dp));
dp[0] = 0;
int ans = 0;

// cout << dp[0] << " ";
for(int i = 1;i<n;i++){
	// cout << "i "<<i <<endl;
	if(i-2 >=0)
	dp[i] =  min(abs(arr[i-2]  - arr[i]) + dp[i-2] , abs(arr[i-1]  -arr[i]) + dp[i-1]);
	else{
		dp[i] = abs(arr[i-1] - arr[i]) + dp[i-1];
	}
	// ans +=dp[i];

	// cout << dp[i] << " ";
}
// cout << endl;

cout << dp[n-1]<< endl;



return 0;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string S;
int N;
int DP[2010010][3];

int main(){
    cin >> S;
    N = S.size();
    S += "####";
    rep(i,N+1){
        rep(pre,3){
            DP[i][pre] = -INF;
        }
    }

    DP[0][0] = 0;

    rep(i,N){
        rep(pre,3){
            REP(d,1,3){
                if(0<=DP[i][pre]){
                    if(pre==d){
                        if(d==1){
                            if(S[i-1]==S[i]) continue;
                        }else{
                            if(S[i-2]==S[i]&&S[i-1]==S[i+1]) continue;
                        }
                    }
                    chmax(DP[i+d][d],DP[i][pre]+1);
                }
            }
        }
    }

    cout << max(DP[N][1],DP[N][2]) << endl;
}

Measured memory_bytes: 4612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class abc100_c
    {
        static void Main(string[] args)
        {
            ReadLine();
            double[] input = ReadLine().Split().Select(Double.Parse).ToArray();
            int count=0;
            for(int i=0; i<input.Length; i++){
                while(input[i]%2 == 0){
                    input[i] /= 2;
                    count++;
                }
            }
            WriteLine(count);
        }

        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
    }
}

Measured memory_bytes: 14304
import sys
a, b, c, d = map(int, input().split())

if a>=c and a-c <= d:
  print("Yes")
  exit()
elif a<c and c-a <= d:
  print("Yes")
  exit()

count = 0
if a>=b and a-b <= d:
  count += 1
elif a<b and b-a <= d:
  count += 1

if b>=c and b-c <= d:
  count += 1
elif b<c and c-b <= d:
  count += 1
  
if count == 2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
import itertools
n,k=map(int,input().split())
aa=k/2
a=[]
b=[]
if k%2==0:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
        elif i%k==aa:
            b.append(i)
else:
    for i in range(1,n+1):
        if i%k==0:
            a.append(i)
tot=len(set(a))**3+len(set(b))**3
print(tot)


Measured memory_bytes: 23336