akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
	cin >> n;
	string s;
	cin >> s;
	vvi freq(n+1, vi(3, 0));
	vi rp, gp, bp;
	REP(i, 0, n) {
		if (s[i] == 'R')
			rp.pb(i);
		if (s[i] == 'G')
			gp.pb(i);
		if (s[i] == 'B')
			bp.pb(i);
	}
	RREP(i, n-1, -1) {
		freq[i] = freq[i+1];
		if (s[i] == 'R')
			freq[i][0]++;
		if (s[i] == 'G')
			freq[i][1]++;
		if (s[i] == 'B')
			freq[i][2]++;
	}
	ll ans = 0, p, k;
	REP(i, 0, n) {
		if (s[i] == 'R') {
			p = lower_bound(all(gp), i+1) - gp.begin();
			REP(j, p, gp.size()) {
				if (j+1 < n)
					ans += freq[gp[j]+1][2];
				k = gp[j] + (gp[j] - i);
				if (k < n && s[k] == 'B')
					ans--;
			}
			p = lower_bound(all(bp), i+1) - bp.begin();
			REP(j, p, bp.size()) {
				if (j+1 < n)
					ans += freq[bp[j]+1][1];
				k = bp[j] + (bp[j] - i);
				if (k < n && s[k] == 'G')
					ans--;
			}
		}
		if (s[i] == 'G') {
			p = lower_bound(all(rp), i+1) - rp.begin();
			REP(j, p, rp.size()) {
				if (j+1 < n)
					ans += freq[rp[j]+1][2];
				k = rp[j] + (rp[j] - i);
				if (k < n && s[k] == 'B')
					ans--;
			}
			p = lower_bound(all(bp), i+1) - bp.begin();
			REP(j, p, bp.size()) {
				if (j+1 < n)
					ans += freq[bp[j]+1][0];
				k = bp[j] + (bp[j] - i);
				if (k < n && s[k] == 'R')
					ans--;
			}
		}
		if (s[i] == 'B') {
			p = lower_bound(all(gp), i+1) - gp.begin();
			REP(j, p, gp.size()) {
				if (j+1 < n)
					ans += freq[gp[j]+1][0];
				k = gp[j] + (gp[j] - i);
				if (k < n && s[k] == 'R')
					ans--;
			}
			p = lower_bound(all(rp), i+1) - rp.begin();
			REP(j, p, rp.size()) {
				if (j+1 < n)
					ans += freq[rp[j]+1][1];
				k = rp[j] + (rp[j] - i);
				if (k < n && s[k] == 'G')
					ans--;
			}
		}
	}
	cout << ans << endl;
}


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

int main()
{
    string S;
    cin >> S;
    long long dp[4] = {};
    dp[0] = 1;
    long long mod = 1000000007;
    for (int i = 0; i < S.size(); i++)
    {
        switch (S[i])
        {
        case 'A':
            dp[1] = (dp[1] + dp[0]) % mod;
            break;
        case 'B':
            dp[2] = (dp[2] + dp[1]) % mod;
            break;
        case 'C':
            dp[3] = (dp[3] + dp[2]) % mod;
            break;
        default:
            dp[3] = (3 * dp[3] + dp[2]) % mod;
            dp[2] = (3 * dp[2] + dp[1]) % mod;
            dp[1] = (3 * dp[1] + dp[0]) % mod;
            dp[0] = (dp[0] * 3) % mod;
            break;
        }
    }

    cout << dp[3] << endl;
}


Measured memory_bytes: 512
#include <iostream>

#define rep(i, n) for (i = 1; i <= n; i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	
	while (n) {
		if (n % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
		else n /= 10;
	}
	
	cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]
PY.sort(key = lambda x: x[1])
PY.sort(key = lambda x: x[0])

ans_lst = []
x = 1
tmp_p = None
for p, y, i in PY:
    if p == tmp_p: #属している県が同じ時
        ans_lst.append([p, x, i])
        x += 1
    else:
        ans_lst.append([p, 1, i])
        tmp_p = p
        x = 2

ans_lst.sort(key = lambda x: x[2])


#output
for p, x, i in ans_lst:
    ans_p = str('000000') + str(p)
    ans_x = str('000000') + str(x)
    # print (ans_p, ans_x)
    # print (ans_p[-6:])
    print (ans_p[-6:], ans_x[-6:], sep = '')


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

int main()
{
    long long x;
    cin >> x;
    long long ans = 2 * (x / 11);
    if(x % 11 > 0){
        ans++;
    }
    if(x % 11 > 6){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import deque

h, w = map(int, input().split())
s = [input() for _ in range(h)]

memo = [[0] * w for _ in range(h)]


ans = 0
for i in range(h):
    for j in range(w):
        if memo[i][j] == 1:
            continue
        memo[i][j] = 1
        black = 0
        white = 0
        if s[i][j] == ".":
            white += 1
        else:
            black += 1
        q = deque([(i, j)])

        while q:
            x, y = q.popleft()
            if x > 0:
                if memo[x - 1][y] == 0 and s[x - 1][y] != s[x][y]:
                    memo[x - 1][y] = 1
                    if s[x - 1][y] == ".":
                        white += 1
                    else:
                        black += 1
                    q.append((x - 1, y))
            if x < h - 1:
                if memo[x + 1][y] == 0 and s[x + 1][y] != s[x][y]:
                    memo[x + 1][y] = 1
                    if s[x + 1][y] == ".":
                        white += 1
                    else:
                        black += 1
                    q.append((x + 1, y))
            if y > 0:
                if memo[x][y - 1] == 0 and s[x][y - 1] != s[x][y]:
                    memo[x][y - 1] = 1
                    if s[x][y - 1] == ".":
                        white += 1
                    else:
                        black += 1
                    q.append((x, y - 1))
            if y < w - 1:
                if memo[x][y + 1] == 0 and s[x][y + 1] != s[x][y]:
                    memo[x][y + 1] = 1
                    if s[x][y + 1] == ".":
                        white += 1
                    else:
                        black += 1
                    q.append((x, y + 1))

        ans += black * white

print(ans)



Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;
    map<string, int> mp;

    cin >> n;

    string s, s1;
    bool ans = true;
    REP(i, n)
    {
        cin >> s;

        if (i == 0 || (s[0] == s1[s1.size() - 1] && mp[s] == 0))
        {
            mp[s] = 1;
        }
        else
        {
            ans = false;
        }

        s1 = s;
    }

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

    return 0;
}

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

#define INF 100100100
#define MOD 1000000007

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

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

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   ll X;
   cin >> X;

   ll left = -1;
   ll right = X;
   ll midle;
   while(right - left > 1){
      midle = (left+right)/2;
      if(midle*(midle+1)/2 < X)left = midle; 
      else right = midle;
   }

   cout << right << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int f( int sum, int d, int md, vector<bool> &digit, vector<int> &vs ) {
  if ( d == md ) {
    return ( sum % 10 == 0 ? 1 : 0 );
  } else {
    int ans = 0;
    for ( int val : vs ) {
      int v = digit[ d ] ? ( val >= 5 ? val * 2 - 9 : val * 2 ) : val;
      ans += f( sum + v, d + 1, md, digit, vs );
    }
    return ans;
  }
}

int main() {
  int n, m;
  string s;
  cin >> n >> s >> m;
  reverse( s.begin(), s.end() );
  vector<int> vs( m );
  for ( int i = 0; i < m; i++ ) {
    cin >> vs[ i ];
  }
  const int c = count( s.begin(), s.end(), '*' );
  vector<bool> digit( c );
  int sum = 0;
  int idx = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( s[ i ] == '*' ) {
      digit[ idx++ ] = ( i + 1 ) % 2 == 0;
    } else {
      int val = s[ i ] - '0';
      if ( ( i + 1 ) % 2 == 0 ) {
	sum += ( val >= 5 ? val * 2 - 9 : val * 2 );
      } else {
	sum += val;
      }
    }
  }
  cout << f( sum, 0, c, digit, vs ) << endl;
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,mod=1e9+7,inf=0x3f3f3f;
struct point{
	int x,v;
	bool operator <(const point &rhs) const{
		return x<rhs.x;
	}
}a[maxn];
int id[maxn],dp[maxn],L[maxn],f[maxn];
bool cmp(const int A,const int B){
	return a[A].v<a[B].v;
}
int main(){
	int n=read();
	REP(i,1,n) a[i].x=read(),a[i].v=read();
	sort(a+1,a+n+1);
	REP(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cmp);
	int Max=0;
	REP(i,1,n){
		chkmax(Max,id[i]);
		L[id[i]]=Max;
	}
	Max=inf;
	DREP(i,n,1){
		chkmin(Max,id[i]);
		chkmax(f[L[id[i]]],Max);
	}
	dp[0]=1,Max=0;
	int sum=1;
	REP(i,1,n){
		dp[i]=sum;
		while(Max<f[i]) sum=(sum+mod-dp[Max])%mod,++Max;
		sum=(sum+dp[i])%mod;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 4992
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll n;
    cin >> n;
    if(n<=2)
    {
    	cout<<0;
    }
    else cout<<n/3;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

int main()
{
   long long int i,j,k,n,a[4534],x,t,b,count=0,sum=0 ;
    scanf("%lld %lld %lld",&n,&x,&t) ;
    b=n/x;
    if(n%x==0)
     printf("%lld",b*t) ;
     else
        printf("%lld",(b+1)*t) ;
     return 0 ;





}


Measured memory_bytes: 1728
#ifndef _WIN32
#include<iostream>
#endif

#include <complex>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <iomanip>
using namespace std;


#define FOR(i,bg,ed) for(int i = (bg);<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back

#define IL inline
namespace geo{
	typedef double D;
	typedef bool B;
	typedef complex<D> P;
#define X real()
#define Y imag()
	B comp(const P& l, const P& r)
	{
		return (l.X == r.X) ? l.Y < r.Y : l.X < r.X;
	}
	typedef pair<P, P> L;
	typedef pair<P, P> LS;
	typedef pair<P, D> C;
	typedef vector<P> Poly;
	const D EPS = 1e-8;

	//Decomposition Macro
#define DCI(a,b,l) P(a),(b);tie(a,b)=l;
#define DCc(a,b,c) P(a);D(b);tie(a,b)=c;

	//A dot B
	IL D dot(P a, P b)
	{
		return a.X*b.X + a.Y*b.Y;
	}
	IL D cross(P a, P b)
	{
		return a.X*b.Y - a.Y*b.X;
	}
	IL D ccw(P a, P b, P c)
	{
		return cross(b - a, c - a);
	}

	IL int sgn(P a, P b, P c){
		if (cross(b - a, c - a) > EPS)return 1;
		if (cross(b - a, c - a) < -EPS)return -1;
		if (dot(b - a, c - a) < -EPS)return 2;
		if (dot(a - b, c - b) < -EPS)return -2;
		return 0;
	}
	IL D signed_distance_P_L(P p, L l){
		DCI(a, b, l);
		return cross(b - a, p - a) / abs(b - a);
	}
	IL D dinstance_P_L(P p, L l){
		return abs(signed_distance_P_L(p, l));
	}
	IL D distance_P_LS(P p, LS ls){
		DCI(a, b, ls);
		if (dot(b - a, p - a) < EPS)return abs(p - a);
		if (dot(a - b, p - b) < EPS)return abs(p - b);
		return abs(cross(b - a, p - a)) / abs(b - a);
	}

	IL B is_L_L(L p, L q){
		DCI(a, b, p);
		DCI(c, d, q);
		return abs(cross(a - b, c - d))>EPS ||
			abs(cross(a - b, d - b)) < EPS; 
	}
	IL B is_LS_LS(LS p, LS q){
		DCI(a, b, p);
		DCI(c, d, q);
		return sgn(a, b, c) * sgn(a, b, d) <= 0 &&
			sgn(c, d, a) * sgn(c, d, b) <= 0;
	}
	IL D distance_LS_LS(LS p, LS q){
		if (is_LS_LS(p, q))
			return 0;
		return
			min({ distance_P_LS(p.fi, q) ,
			 distance_P_LS(p.se, q) ,
			 distance_P_LS(q.fi, p) ,
			 distance_P_LS(q.se, p) });
	}
	IL P cross_point_L_L(L p, L q){
		DCI(a, b, p);
		D d1 = signed_distance_P_L(a, q);
		D d2 = signed_distance_P_L(b, q);
		return (a*d2 - b*d1) / (d2 - d1);
	}
}

using namespace geo;


int main()
{
	int n;

	cin >> n;
	while (n--){
		D x1, x2, x3, y1, y2, y3, x4, y4;

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		P p(x1,y1),q(x2,y2),r(x3,y3),s(x4,y4);

		LS pq(p, q), rs(r, s);
		cout<<fixed;
		cout << setprecision(11);

		auto ans = distance_LS_LS(pq, rs);
		cout << ans  << endl;
	}
	return 0;
}

Measured memory_bytes: 3352
#include<stdio.h>
int f(int a,int b){
  if(b)return f(b,a%b);
  return a;
}
int main(){
  int a,b,c;
  while(scanf("%d %d",&a,&b)!=EOF){
    if(a<b){
      c=a;
      a=b;
      b=c;
    }
    c=f(a,b);
    printf("%d %d\n",c,(a/c)*b);
  }
  return 0;
}

Measured memory_bytes: 596
import math

def A():
    x, a, b = [int(x) for x in input().split()]
    if abs(x-a) < abs(x-b):
        print('A')
    else:
        print('B')
def B():
    S = input()
    alphabet = [False for x in range(26)]
    for char in S:
        i = ord(char) - ord('a')
        alphabet[i] = True
    printed = False
    for i in range(len(alphabet)):
        if alphabet[i] == False:
            print(chr(ord('a')+i))
            printed = True
            break
    if printed == False:
        print("None")
def C():
    pass

def E():
    n, m = [int(x) for x in input().split()]
    P = [[] for i in range(n)]
    for j in range(m):
        p, y = [int(x) for x in input().split()]
        P[p-1].append([y, ('000000'+str(p))[-6:], j])

    for i in range(n):
        P[i] = sorted(P[i], key=lambda x:x[0])
        for j in range(len(P[i])):
            P[i][j][1] += (('000000'+str(j+1))[-6:])
    P = [e for inner_list in P for e in inner_list]
    P = sorted(P, key=lambda x:x[2])
    for p in P:
        print(p[1])
E()


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


def get_input() -> tuple:
    """標準入力の取得

    Returns:
        list -- 標準入力
    """
    S = input()
    T = input()
    return S, T


def main(S: str, T: str) -> None:
    """Entry point

    Arguments:
        S {str} -- 英子文字列
        T {str} -- 英子文字列
    """
    # 求解処理
    """
    Tの最後の一文字を消去して得られる文字列とSを比較
    """
    result = ""
    if S == T[:-1]:
        result = "Yes"
    else:
        result = "No"

    # 結果出力
    print(result)


if __name__ == "__main__":
    S, T = get_input()
    main(S, T)


Measured memory_bytes: 9072
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
using namespace std;
string str;
stack<char>st;
int main(){
    int n;cin>>n;
    cin>>str;
    st.push(str[0]);
    for(int i=1;i<n;i++){
        if(st.size()==0){
            st.push(str[i]);
            continue;
        }
        if(st.top()=='('&&str[i]==')'){
            st.pop();
        }else st.push(str[i]);
    }
    int x=0,y=0;
    int w=st.size();
    for(int i=0;i<w;i++){
        if(st.top()==')')x++;
        else y++;
        st.pop();
    }
    while(x--)cout<<"(";
    cout<<str;
    while(y--)cout<<")";
    cout<<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>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a, k;
    vector<lli> v;
    cin >> n >> k;
    input(n, v);
    sort(all(v));
    vector<lli> dp(k + 2, 0);

    for (lli i = 0; i <= k; i++) {
        for (lli j = 0; j < n; j++) {
            if (v[j] <= i && dp[i - v[j]] == 0) {
                dp[i] = 1;
            }
        }
    }

    if (dp[k] == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    rt;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for(int i = 1; i <= 1000; i++) {
    int h1 = (i*(i+1))/2;
    int k = i+1;
    int h2 = ((k)*(k+1))/2;
    if (abs(a-h1) == abs(b-h2))
    {
      cout << abs(a-h1) << endl;
      break; 
    }
  }
  return 0;

}


Measured memory_bytes: 256
N = int(input())
A = [int(item) for item in input().split()]
B = [int(item) for item in input().split()]
C = [int(item) for item in input().split()]

ans = sum(B)
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	ll N, K, C;
	string S;
	cin >> N >> K >> C >> S;

	C++;
	vector<ll> ans(N, 0);
	ll workMax = 0;
	for (int i = 0; i < N;) {
		if (S[i] == 'o') {
			ans[i]++;
			workMax++;
			i += C;
		} else {
			i++;
		}
	}
	if (K != workMax) {
		return 0;
	}

	workMax = 0;
	for (int i = N - 1; i >= 0;) {
		if (S[i] == 'o') {
			ans[i]++;
			workMax++;
			i -= C;
		} else {
			i--;
		}
	}
	if (K != workMax) {
		return 0;
	}

	for (int i = 0; i < N; i++) {
		if (ans[i] == 2) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  string S; cin >> S;
  vector <int> ans(S.length());

  bool flagL = false;
  int L = 0, R = 0, start = 0;
  for (int i = 0; i < S.length(); i++){
    if (flagL == false && S[i] == 'R'){
      R++;
    }else if(S[i] == 'L'){
      L++;
      flagL = true;
    }else{
      ans[start + R] = R / 2 + (L - L / 2);
      ans[start + R - 1] = (R - R / 2) + L / 2;
      R = 0; L = 0;
      flagL = false;
      start = i;
      i--;
    }
  }
  ans[start + R] = R / 2 + (L - L / 2);
  ans[start + R - 1] = (R - R / 2) + L / 2;

  for (int i = 0; i < S.length(); i++){
    cout << ans[i];
    if (i != S.length() - 1){
      cout << " ";
    }
  }
  cout << endl;
  

  return 0;
}


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

using namespace std;

int main()
{
	string weather[3] = { "Sunny", "Cloudy", "Rainy" };
	string S;
	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (S == "Rainy") {
		cout << "Sunny" << endl;
	}

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n), b(n), d(n);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;
    int64_t sum = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        d[i] = a[i] - b[i];
        if(d[i] < 0){
            sum += d[i];
            cnt++;
        }
    }
    if(accumulate(begin(d), end(d), 0LL) < 0){
        cout << -1 << endl;
        return 0;
    }
    if(cnt == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(begin(d), end(d), greater<int64_t>());
    for(int i = 0; i < n; i++){
        sum += d[i];
        if(sum >= 0){
            cout << (i + 1) + cnt << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N; cin >> N;
  bool flg = true;
  vector<int> H(N, 0);
  for(int i = 0; i < H.size(); i++) cin >> H[i];
  for(int i = 0; i < H.size(); i++) {
    if(i == 0) continue;
    if(H[N - i - 1] - H[N - i] == 1) H[N - i - 1]--;
    else if(H[N - i - 1] - H[N - i] > 1) { flg = false; break; }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 640
n,t = map(int,input().split())
menu = []
time = [] #(time,value)
value = []

for _ in range(n):
    a,b = map(int,input().split())
    menu.append([a,b])

menu = sorted(menu,key=lambda x:x[1])

for i in range(n):
    time.append(menu[i][0])
    value.append(menu[i][1])

dp = [[0 for _ in range(t+1)] for __ in range(n+1)]
ind = [[-1 for _ in range(t+1)] for __ in range(n+1)]

#dp[i+1][w]: i番目までを使う、時間w超えない

for i in range(n):
    for w in range(t+1):
        if time[i] < w:
            if dp[i][w-time[i]]+value[i] > dp[i][w]:
                dp[i+1][w] = dp[i][w-time[i]]+value[i]
                ind[i+1][w] = ind[i][w-time[i]]
            else:
                dp[i+1][w] = dp[i][w]
                ind[i+1][w] = i
        else:
            dp[i+1][w] = dp[i][w]
            ind[i+1][w] = i

if ind[n][t] < 0:
    print(dp[n][t])
else:
    print(dp[n][t]+value[ind[n][t]])


Measured memory_bytes: 194436
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d ",&n);
	char s[n];
	scanf("%s",s);
	int k;
	scanf("%d",&k);
	for(int i=0;i<n;i++) {
		if(s[i]==s[k-1]) printf("%c",s[i]);
		else printf("*");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
def main():
    S = input().rstrip()
    if S[0] != "A":
        print("WA")
        exit()
    if S[2:-1].count("C") != 1:
        print("WA")
        exit()
    chars = [chr(i) for i in range(97, 97+26)]
    for s in S[1:]:
        if s == "C":
            continue
        elif s not in chars:
            print("WA")
            exit()
    print("AC")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61732
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    long long A,B,C;
    cin >> A >> B >> C;
    
    long long sum = C - A - B;
    if (sum > 0 && 4*A*B < sum*sum) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,k;
  cin>>n>>k;
  vll t(n);
  rep(i,n){
    cin>>t[i];
  }
  ll ans=INF;
  for(int i=0;i<n-k+1;i++){
    ll d=min(abs(t[i]),abs(t[i+k-1]));
    d+=abs(t[i+k-1]-t[i]);
    ans=min(d,ans);
  }
  COUT(ans);
}
    
    


Measured memory_bytes: 1152
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 1000010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int nt[MAXN], n, a[MAXN];
bool x[MAXN];

void sieveBase(int n) {
    FOR(i,2,n) {
        if (nt[i] == 0) {
            nt[i] = i;
            for (ll j = (ll) i * i; j <= n; j += i) nt[j] = i;
        }
    }
}

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

bool isPairwise() {
    FOR(i,1,n) {
        int p = a[i];
        set<int> b;
        while (p > 1) {
            b.insert(nt[p]);
            p /= nt[p];
        }
        FORALL(it, b) {
            if (x[*it]) return false;
            x[*it] = true;
        }
    }
    return true;
}

bool isSetwise() {
    int g = a[1];
    FOR(i,1,n) g = gcd(g, a[i]);
    return g == 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    sieveBase(1000000);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    if (isPairwise()) cout << "pairwise coprime";
    else if (isSetwise()) cout << "setwise coprime";
    else cout << "not coprime";
    return 0;
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
using namespace std;

int main(){
    int n, i, j, k;
    cin >> n >> k;
    int h[n], dp[n];
    for(i = 0; i < n; i++){
        cin >> h[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(i = 1; i < n; i++){
        for(j = 1; j <= k && i-j >= 0; j++){
            dp[i] = MIN(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n-1] << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

bool aka[111111];
int hako[111111];

int main(void){
  int n,m;
  cin>>n>>m;
  aka[1]=true;
  int x,y;
  int res=0;
  for(int i=1;i<=n;i++) hako[i]=1;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    if(aka[x]) aka[y]=true;
    hako[x]--;
    hako[y]++;
    if(hako[x]==0) aka[x]=false;
  }
  
  for(int i=0;i<=n;i++){
    //printf("%d %d %d\n",i,aka[i],hako[i]);    
    if(aka[i]) res++;
  }
  cout<<res<<endl;
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s;
    cin >> s;
    vstr v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, v.size())
    {
        if (s == v[i])
        {
            cout << 7 - i << endl;
            return;
        }
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int64_t a[100'000];
int64_t b[100'000];

int main()
{
    int N;
    int64_t H;
    cin >> N >> H;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }

    int64_t amax = 0;
    for (int i = 0; i < N; i++)
    {
        amax = max(amax, a[i]);
    }

    sort(b, b + N, [](const auto &lh, const auto &rh) {
        return lh > rh;
    });

    int attacks = 0;
    for (int i = 0; i < N; i++)
    {
        if (b[i] <= amax || H <= 0)
        {
            break;
        }
        H -= b[i];
        attacks++;
    }

    if (H > 0)
    {
        int additional = (H + amax - 1) / amax;
        attacks += additional;
    }

    cout << attacks << endl;
}

Measured memory_bytes: 1792
//Minor Change

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

int main(){
  int cnt=0;
  string S,T;
  cin >> S >> T;
  for(int i=0; i<S.length(); i++){
    if(S[i]!=T[i]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll    long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

struct st
{
	ll a, b, c;

};

void solve() {


	ll n;
	cin >> n;
	vector<st> v(n + 1);
	ll dp[n + 1][3];

	for (ll i = 1; i <= n; i++) {
		cin >> v[i].a >> v[i].b >> v[i].c;
	}

	dp[1][0] = v[1].a;
	dp[1][1] = v[1].b;
	dp[1][2] = v[1].c;

	for (ll i = 2; i <= n; i++) {
		dp[i][0] = v[i].a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = v[i].b + max(dp[i - 1][2], dp[i - 1][0]);
		dp[i][2] = v[i].c + max(dp[i - 1][1], dp[i - 1][0]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));

}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 7956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,h,w;cin>>n>>h>>w;
  int ans=(n-h+1)*(n-w+1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3580
from math import sqrt, ceil

N = int(input())

result = [0] * (N + 1)
t = ceil(sqrt(N))
for x in range(1, t + 1):
    for y in range(1, t + 1):
        for z in range(1, t + 1):
            n = x * x + y * y + z * z + x * y + y * z + z * x
            if n > N:
                break
            result[n] += 1

print(*result[1:], sep='\n')


Measured memory_bytes: 9268
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(0);
        String a = "";
        String b = "";
        for (int i = 0; i<s.length(); i++){
            a += c;
        }
        for (int i = 0; i<s.length(); i++){
            b += Integer.parseInt(String.valueOf(c))+1;
        }
        if (Integer.parseInt(a) >= Integer.parseInt(s))
            System.out.println(a);
        else
            System.out.println(b);
    }
}

Measured memory_bytes: 39192
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int x4 = 0;
    int x2 = 0;
    int xn = 0;

    for (int i = 0; i < N; i++) {
        int v;
        cin >> v;
        if ((v % 4) == 0) {
            x4++;
        } else if ((v % 2) == 0) {
            x2++;
        } else {
            xn++;
        }
    }

    bool ok = false;

	if ((x2 % 2) != 0) {
		xn++;
		x2--;
	}

	if (x4 != 0) {
		if ((xn - 1) <= x4)  {
			ok = true;
		}
	} else {
		// multiple of 4 are not exist.
		if (x2 != 0) {
			if (xn <= 1) {
				ok = true;
			}
		}
	}

    cout << (ok ? "Yes": "No") << endl;

    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	M := nextInt()
	uf := NewUnionFind(N)
	for i := 0; i < M; i++ {
		a := nextInt() - 1
		b := nextInt() - 1
		uf.Unit(a, b)
	}
	ans := 0
	for i := 0; i < len(uf.link); i++ {
		ans = maxInt(ans, len(uf.link[i]))
	}
	fmt.Println(ans)
}

type UnionFind struct {
	par  []int
	size []int
	link [][]int
}

func NewUnionFind(count int) *UnionFind {
	par := make([]int, count)
	size := make([]int, count)
	link := make([][]int, count)
	for i := 0; i < count; i++ {
		link[i] = make([]int, 1)
	}
	for i := 0; i < count; i++ {
		par[i] = i
		size[i] = 1
		link[i][0] = i
	}
	return &UnionFind{par: par, size: size, link: link}
}

func (uf *UnionFind) Find(a int) int {
	for uf.par[a] != a {
		uf.par[a] = uf.par[uf.par[a]]
		a = uf.par[a]
	}
	return a
}

func (uf *UnionFind) Unit(a, b int) {
	a = uf.Find(a)
	b = uf.Find(b)
	if a != b {
		if uf.size[a] > uf.size[b] {
			a, b = b, a
		}
		uf.par[a] = b
		uf.size[b] += uf.size[a]
		uf.link[b] = append(uf.link[b], uf.link[a]...)
	}
}

func (uf *UnionFind) Same(a, b int) bool {
	return uf.Find(a) == uf.Find(b)
}

func (uf UnionFind) Weight(a int) int {
	return uf.size[uf.Find(a)]
}


Measured memory_bytes: 33012
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define rep(i, n)      for (int i=0; i<int(n); i++)
#define rep3(i, s, n)  for (int i=int(s); i<int(n); i++)
#define rev_rep(i, n)  for (int i=int(n)-1; i>=0; i-=1)

#define MAX_N 52
#define MAX_M 52
char flag[MAX_N][MAX_M];

int main() {
  int N, M;
  cin >> N >> M;
  rep(i, N) cin >> flag[i];

  int ans = INT_MAX;
  rep3(i, 0, N) {
    rep3(j, i+1, N-1) {
      //cout << "i: " << i << ", j: " << j << "\n";
      int cost = 0;
      // ???
      rep3(y, 0, i+1) {
        rep3(x, 0, M) if (flag[y][x] != 'W') cost++;
      }
      // ??????
      rep3(y, i+1, j+1) {
        rep3(x, 0, M) if (flag[y][x] != 'B') cost++;
      }
      // ???
      rep3(y, j+1, N) {
        rep3(x, 0, M) if (flag[y][x] != 'R') cost++;
      }
      //cout << cost << "\n";
      ans = min(ans, cost);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3072
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var charArray = cin.Read.ToCharArray();
            Array.Reverse(charArray);
            var s = new string(charArray);
            var words = new string[] { "maerd", "remaerd", "esare", "resare" };

            var i = 0;
            while (i < s.Length)
            {
                var flag = false;
                foreach (var word in words)
                {
                    if (s.Length - i < word.Length)
                    {
                        continue;
                    }
                    if (s.Substring(i, word.Length) == word)
                    {
                        i += word.Length;
                        flag = true;
                    }
                }
                if (!flag)
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Console.WriteLine("YES");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

const int maxn=200000+10;
int n,a[maxn],cnt[maxn],vis[maxn];
long long ans;

void ins(int x){
	++cnt[x];
	int y=x-cnt[x]+1;
	if(y>=1){
		if(!vis[y]) --ans;
		++vis[y];
	}
}

void delate(int x){
	int y=x-cnt[x]+1;
	if(y>=1){
		if(vis[y]==1) ++ans;
		--vis[y];
	}
	--cnt[x];
}

void yu(int x,int y){
	delate(a[x]),a[x]=y,ins(a[x]);
}
int m,x,y;
int main()
{
	cin>>n>>m;
	ans=n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ins(a[i]);
	}
	for(int i=m;i>=1;i--){
		cin>>x>>y;
		yu(x,y);
//		for(int j=1;j<=n;j++) if(vis[j]>1) ans+=(vis[j]-1);
		cout<<ans<<endl;
	}
//	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3712
require 'set'

dic = Set.new
class << dic
  def insert str
    self << str
  end

  def find str
    if self.include? str
      puts 'yes'
    else
      puts 'no'
    end
  end
end

n = gets.to_i
n.times do
  op, str = gets.chomp.split
  dic.send(op, str)
end



Measured memory_bytes: 40448
package main

import (
  "fmt"
)

func main() {
  var a, b, c string 
  fmt.Scan(&a, &b, &c)
  res := make(map[rune][]rune)
  res['a'] = []rune(a)
  res['b'] = []rune(b)
  res['c'] = []rune(c)
  nxt := 'a'
  for {
    p := nxt
    if len(res[p]) == 0 {
      fmt.Println(string(p - 32))
      return
    }
    nxt = res[p][0]
    res[p] = res[p][1:]
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    if(s < t)print("Yes");
    else print("No");
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int can(int x){
    return ((x % 3 == 0) || (x % 5 == 0));
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        int x;
        cin >> x;
        if(x % 2 == 0 && !can(x)){
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
}


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

using namespace std;



int main() {
	int K;
	string S;
	cin >> K >> S;
	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		string S2;
		S2.append(S,0, K);
		S2 += "...";
		cout << S2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

vector<pair<int,int>> G[200010];
char BW[200010];
map<pair<int,int>, int> edge;
int ans[200010];

int main() {
	int N, M, U, V, dis;
	cin >> N >> M;
	vector<int> D(N);
	vector<pair<int, int>> Ds(N);
	for (int i = 0;i < N;i++) {
		cin >> D[i];
		Ds[i] = { D[i],i };
	}
	sort(all(Ds));
	vector<pair<int, int>> Vs(M);

	for (int i = 0;i < M;i++) {
		cin >> U >> V;
		U--;V--;
		G[U].push_back(make_pair(D[V], V));
		G[V].push_back(make_pair(D[U], U));
		edge.insert({ {U,V},1000000000 });
		edge.insert({ {V,U},1000000000 });
		Vs[i] = { U,V };
	}

	for (int i = 0;i < N;i++) {
		sort(all(G[i]));
		BW[i] = 49;
	}

	
	int gs, fir, sec, s, t;
	for (int x = 0, i;x < N;x++) {
		i = Ds[x].second;
		dis = Ds[x].first;

		fir = G[i][0].first;
		sec = G[i][0].second;
		//for (int k = 0;k < N;k++)cout << BW[k];cout << endl;
		if (fir < dis) {
			if (BW[i] == 49) {
				edge[{i, sec}] = dis - fir;
				edge[{sec, i}] = dis - fir;
				BW[i] = BW[sec];
			}
		}
		else if (fir == dis) {
			edge[{i, sec}] = dis;
			edge[{sec, i}] = dis;
			if (BW[i] == 49) {
				if (BW[sec] == 'B')BW[i] = 'W';
				else BW[i] = 'B', BW[sec] = 'W';
			}
			else if (BW[sec] == 49) {
				if (BW[i] == 'B')BW[sec] = 'W';
				else BW[sec] = 'B';
			}
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 0;i < N;i++) {
		cout << BW[i];
	}
	cout << endl;

	for (int i = 0;i < M;i++) {
		cout << edge[Vs[i]] << endl;
	}
}

Measured memory_bytes: 40576
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
string X,Y;
int main() {
	cin>>X>>Y;
	int A,B;
	if(X=="A")A=10;
	if(X=="B")A=11;
	if(X=="C")A=12;
	if(X=="D")A=13;
	if(X=="E")A=14;
	if(X=="F")A=15;

    if(Y=="A")B=10;
	if(Y=="B")B=11;
	if(Y=="C")B=12;
	if(Y=="D")B=13;
	if(Y=="E")B=14;
	if(Y=="F")B=15;

	if(A>B)cout<<">"<<endl;
	else if(A==B)cout<<"="<<endl;
	else if(A<B)cout<<"<"<<endl;

	return 0;
}


Measured memory_bytes: 256
s = int(input())
a = s
i = 1
s_ = set()
s_.add(a)
while True:
  i += 1
  if a%2 == 0:
    a = a//2
  else:
    a = 3*a+1
  if a in s_:
    print(i)
    exit()
  else:
    s_.add(a)

Measured memory_bytes: 3060