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

const int N = 100010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt, ind[N];

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
    ind[from]++, ind[to]++;
}

int dep[N], mx, pos, tmp[N]; vector<int> hh, ans1, ans2;

void dfs(int u, int f) {
    dep[u] = dep[f] + 1, tmp[u] = 0;
    if (dep[u] > mx) mx = dep[u], pos = u;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) dfs(e[i].to, u), tmp[u] = max(tmp[u], tmp[e[i].to] + 1);
}

void dfs2(int u, int f) {
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f && tmp[e[i].to] + 1== tmp[u]) {
            dfs2(e[i].to, u); break;
        }
    hh.push_back(ind[u] - (!!f) - (!!tmp[u]) + 1);
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) 
        scanf("%d%d", &a, &b), adde(a, b);
    dfs(1, 0); int tp = 0, tot = 0, u = pos; ans1.resize(n + 1);
    dfs(u, 0),dfs2(u, 0);
    for (auto t : hh) {
        ans1[tp + t] = ++tot;
        for (int i = tp + 1; i < tp + t; i++) ans1[i] = ++tot;
        tp += t;
    }
    reverse(hh.begin(), hh.end()), ans2.resize(n + 1), tot = 0, tp = 0;
    for (auto t : hh) {
        ans2[tp + t] = ++tot;
        for (int i = tp + 1; i < tp + t; i++) ans2[i] = ++tot;
        tp += t;
    }
    if (ans1 > ans2) swap(ans1, ans2);
    for (int i = 1; i <= n; i++) if (!ans1[i]) 
        return puts("-1"), 0;
    for (int i = 1; i <= n; i++) printf("%d ", ans1[i]);
}

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
	double a,b;
	cin >> a >> b;
	cout << fixed << setprecision(10) << a / b << endl;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b, temp,i;
   for(i=1; i<=3000; i++)
   {
     cin >>a >> b;
     
     if(a > b)
     {
         temp =a;
         a = b;
         b = temp;
     }
     if (a == 0 && b == 0)
     break; 
   
   cout << a << " " << b << endl;
   }
}


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


int table[25][50005] = {};

int main()
{
	int n;
	int m;
	int coin[25];
	
	
	cin >> n >> m;
	
	
	for(int i = 0; i < m; ++i)
	{
		cin >> coin[i];
	}
	
	
	for(int now = 0; now < m; ++now)
	{
		for(int sum = 0; sum < n; ++sum)
		{
			if(sum - coin[now] < 0 && now - 1 < 0) table[now][sum] = 1;
			else if(sum + 1 - coin[now] < 0) table[now][sum] = table[now - 1][sum];
			else if(now - 1 < 0) table[now][sum] = table[now][sum - coin[now]] + 1;
			else table[now][sum] = min(table[now][sum - coin[now]] + 1, table[now - 1][sum]);
		}
	}
	
	cout << table[m - 1][n - 1] << endl;
	
	return 0;
}

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

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

  int n=s.size(), m=t.size();
  vector<char> ss, tt;
  for(int i=0; i<n; i++)ss.push_back(s[i]);
  for(int i=0; i<m; i++)tt.push_back(t[i]);
  sort(ss.begin(), ss.end());
  sort(tt.begin(), tt.end());
  reverse(tt.begin(), tt.end());

  string sx, tx;
  for(int i=0; i<n; i++)sx.push_back(ss[i]);
  for(int i=0; i<m; i++)tx.push_back(tt[i]);

  if(sx<tx)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    vector<ll> A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    vector<ll> tensu(N - K + 1);

    tensu.at(0) = A.at(0);
    for(ll i = 1;i < K;i++){
        tensu.at(0) *= A.at(i);
        //cout << tensu.at(0) << endl;
    }

    for(ll i = 1;i < N - K+1;i++){
        tensu.at(i) = tensu.at(i-1);
        //cout << tensu.at(i) << endl;
        tensu.at(i) -= A.at(i-1);
        //cout << "watta : "<<tensu.at(i) << endl;
        tensu.at(i) += A.at(i+K-1);
    }

    /*for(ll i = 0;i < N - K + 1;i++)
        cout << tensu.at(i) << endl;
    */

    for(ll i = 0;i < N - K;i++){
        if(tensu.at(i) < tensu.at(i+1))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;

    }

    return 0;
}

Measured memory_bytes: 6380
N = int(input())
A = [int(input()) for _ in range(N)]
B=sorted(A,reverse=True)
max=B[0]
sec=B[1]

if max==sec:
    for n in range(N):
        print(max)
else:
    for a in A:
        if a==max:
            print(sec)
        else:
            print(max)

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const ll mod = 1000000007;
struct matrix {
	ll v[50][50];
	matrix() {
		rep(i, 0, 50) rep(j, 0, 50) v[i][j] = 0;
	}
	matrix I() const {
		matrix m;
		rep(i, 0, 50) m.v[i][i] = 1;
		return m;
	}
	matrix operator*(const matrix m) const {
		matrix m2;
		rep(i, 0, 50) rep(j, 0, 50) rep(k, 0, 50)
			(m2.v[i][j] += v[i][k] * m.v[k][j]) %= mod;
		return m2;
	}
	matrix operator^(ll p) const {
		matrix rv = I(), b = *this;
		for (; p; p >>= 1, b = b * b) if (p & 1) rv = rv * b;
		return rv;
	}
	void print(string name, int n) {
		printf("%s:\n", name.c_str());
		rep(i, 0, n) { rep(j, 0, n) { printf("%lld ", v[i][j]); } printf("\n"); }
	}
};

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

	int n; ll k; read(n, k);
	matrix m;
	rep(i, 0, n) rep(j, 0, n) read(m.v[i][j]);
	//m.print("m",n);
	matrix r = m ^ k;

	//m.print("m",n);
	//r.print("r",n);

	ll ans = 0;
	rep(i, 0, n) rep(j, 0, n) (ans += r.v[i][j]) %= mod;

	die(ans);
}


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

#define pb push_back
#define INF 1e9
#define mod 998244353
#define mod2 1000000007
#define dbg(x) cout << (#x) << " --> " << x << "\n";
#define dbgarr(y)                                                                                            \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x << '\n';
#define dbgparr(y)                                                                                           \
  cout << (#y) << " --> " << '\n';                                                                           \
  for(auto& x : y) cout << x.first << ", " << x.second << '\n';
using namespace std;

typedef priority_queue<int, vector<int>, greater<int>> minPq;
typedef priority_queue<int> maxPq;
typedef long long ll;

void goodLuckHaveFun() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
/* clang-format off */
  #ifdef _DEBUG
  freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
  #endif
  /* clang-format on */
}

int main() {
  goodLuckHaveFun();
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, Q = map(int, readline().split())

N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [INF]*(2*N0)
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])
def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s


ans = []
for q in range(Q):
    t, x, y = map(int, readline().split())
    if t:
        ans.append(str(query(x, y+1)))
    else:
        update(x, y)
write("\n".join(ans))
write("\n")



Measured memory_bytes: 12512
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include <vector>
 
#define MOD 1000000007
typedef long long ll;
 
using namespace std;


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

	ll l, r, d, ans = 0;

	cin >> l >> r >> d;

	for(ll i=l; i<=r; i++) {
		if(i%d==0) ans++;
	}

	cout << ans << '\n';
	return 0;
}

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

int main() {
  

}
*/

#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    int X;
    
    cin >> X;
    
    if(X >= 30){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}

//vector<int> a(3);
//a.at(0);
//a.size();
//vector<vector<int>> a(3, vector<int>(3));
//uint64_t sum = 0;
//max(a, b);
//min(a, b);
//swap(a, b);
//sort(vec.begin(), vec.end())
//reverse(vec.begin(), vec.end())


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
int main(){
    string s, t;
    cin >> s >> t;
    ll cnt = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3920
n = int(input())
s = input()
q = int(input())
K = list(map(int,input().split()))

for ii in range(q):
    # D = [[0] * 3 for i in range(n)]
    d = 0
    m = 0
    dm = 0
    ans = 0
    k = K[ii]
    for i in range(n):
        # for j in range(3):
        #     D[i][j] = D[i-1][j]
        
        if i-k >= 0:
            if s[i-k] == "D":
                d -= 1
                dm -= m
            if s[i-k] == "M":
                m -= 1
        
        if s[i] == "D":
            d += 1
        if s[i] == "M":
            m += 1
            dm += d
        if s[i] == "C":
            ans += dm
    print(ans)
    # print(D)

Measured memory_bytes: 75532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=1;
    rep(i,n-1) if(s[i]!=s[i+1]) ans++;
    cout<<ans;
}

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

int linesearch(int key, int A[], int n){
  A[n] = key;
  int i = 0;
  while(A[i] != key){
    i++;
  }

  if (i != n){
    return 1;
  }else{
    return 0;
  }
}

int main(){
  int n;
  cin >> n;

  int S[n + 1];
  rep(i, n) cin >> S[i];

  int q;
  cin >> q;

  int T[q];
  rep(i, q) cin >> T[i];
  
  int cnt = 0;

  rep(i, q){
    cnt += linesearch(T[i], S, n);
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3128
int main(void) {
    int a,b;
    char s[100];
    scanf("%d%d",&a,&b);
    scanf("%s",s);
    if (s[a] != '-') {
        puts("No");
        return 0;
    }
    for (int i = 0; i < strlen(s); i++) {
        if (i == a) {
            continue;
        }
        if (s[i] == '-') {
            puts("No");
            return 0;
        }
    }
    if (strlen(s) != a + b + 1) {
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string c; cin >> c;
	if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll N;
vector<vector<ll>> V(17, vector<ll>(17));
vector<ll> DP;

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> V[i][j];
        }
    }
    DP.resize(1<<N);
    for(int i = 0; i < (1<< N); i++){
        bitset<17> B = i;
        ll score = 0;
        for(int i = 0; i < N; i++){
            for(int j = i; j < N; j++){
                if(B[i] == 1 && B[j] == 1) score += V[i][j];
            }
        }
        DP[i] = score;
    }
    for(int i1 = 0; i1 < (1<<N); i1++){
        bitset<17> B = i1;
        ll cnt = B.count();
            for(int t = (i1-1)&i1; t > 0; t = (t-1)&i1){
                DP[i1] = max(DP[i1], DP[t]+DP[i1-t]);
            }
    }
    cout << DP[(1<<N)-1] << endl;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

const int N=1e5+7;
int n,m,k,q,l,r,x,y,z;
int a[N],b[N],c[N];
string s,t;
int ans=0,cnt=0,f=0;

void solve(){
	cin>>n;
	for(int i=0 ; i<n ; i++) cin>>a[i];
	for(int i=0 ; i<n ; i++){
		if(a[i]==0) f=1;
	}
	if(f){
		cout<<0;LOL
		return;
	}
	ld d=0;
	for(int i=0 ; i<n ; i++){
		d+=log10(a[i]);
	}
	if(d>18){
		cout<<-1;LOL
		return;
	}
	cnt=1;
	ans=1000000000000000000;
	for(int i=0 ; i<n ; i++){
		cnt*=a[i];
		if(cnt>ans){
			cout<<-1;LOL
			return;
		}
	}
	if(cnt>ans){
		cout<<-1;LOL
		return;
	}
	else{
		cout<<cnt;LOL
	}
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  cout<<setprecision(2);
  int _=1; //cin>>_;
  for(int i=1 ; i<=_ ; i++) solve();
  return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, cap, k, cur, ans;
int ptr, s[100005];
int main(){
	scanf("%d %d %d", &n, &cap, &k);
	FI(i, 1, n) scanf("%d", &s[i]);
	sort(s + 1, s + n + 1);
	ptr = 1;
	FI(i, 1, n){
		if(i - ptr + 1 > cap || s[i] - s[ptr] > k){
			ans++;
			ptr = i;
		}
	}
	ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int x,y,z,p,lu,min,minloc;
	x=sc.nextInt();
	y=sc.nextInt();
	z=sc.nextInt();
	p=sc.nextInt();
	int[] ini = new int[x];
	
	for(int i=0; i<x; i++)
	    ini[i]=sc.nextInt();
	
	for(int i=x-1; i>0; i--)
	    for(int j=0; j<i; j++)
		if(ini[j]<ini[j+1]){
		    lu=ini[j];
		    ini[j]=ini[j+1];
		    ini[j+1]=lu;
		}
	lu=p;
	min=lu/y;
	minloc=min;
	for(int i=0; i<x; i++){
	    lu+=ini[i];
	    minloc=lu/(y+(i+1)*z);
	    if(minloc>min)
		min = minloc;
	}
	System.out.println(min);
    }
}

Measured memory_bytes: 12000
#include <cstdio>

int main() {
	int x, i = 0, a[10000] = {};

	do {
		scanf("%d", &x);
		a[i] = x;
		i++;
	} while (x != 0);

	i = 0;
	while (a[i] != 0) {
		printf("Case %d: %d\n", i+1, a[i]);
		i++;
	}

	return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    //cerr<<string(n ,'R')<<endl;
    if(s==string(n ,'R') || s==string(n, 'W')){
        cout<<0<<endl;
        return 0;
    }
    vector<int>w,r;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='W') w.push_back(i);
        else r.push_back(i);
    }
    reverse(ALL(r));
    int cnt=0;
    for (int i = 0; i < min(r.size(),w.size()); i++)
    {
        if(w[i] > r[i]){
            break;
        }
        cnt++;
    }
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 6244
N, M = list(map(int, input().split()))
temp = [list(map(int, input().split())) for i in range(M)]
temp = list(zip(*temp))
P, Y = temp
#print(P, Y)
data = dict()
for p, y in zip(P, Y):
  if p not in data:
    data[p] = [y]
  else:
    data[p].append(y)

data = {i:{value:j+1 for j, value in enumerate(sorted(data[i]))} for i in data.keys()}

for p, y in zip(P, Y):
  print("{:06}{:06}".format(p, data[p][y]))

Measured memory_bytes: 62372
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);

        public static void main(String[] args) {

        int n = Integer.parseInt(sc.next());
        int h[]= new int[n];

        for(int i=0;i<n;i++){
            h[i]=Integer.parseInt(sc.next());
        }
        int ans=0;
        int high=h[0];
        for(int curr:h){
            if(high<=curr){
                ans+=1;
                high=curr;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22868
//30
#include<iostream>
#include<set>
#include<string>
#include<algorithm>

using namespace std;

struct L{
  string s[10];
  string h;
  bool operator<(L a)const{
    return h<a.h;
  }
  void mh(){
    string ss;
    for(int i=0;i<4;i++){
      for(int j=0;j<2;j++){
	for(int i=0;i<5;i++){
	  swap(s[i*2],s[i*2+1]);
	}
	string t;
	for(int i=0;i<10;i++){
	  t+=s[i];
	}
	if(ss<t){
	  ss=t;
	}
      }
      for(int i=0;i<1;i++){
	string r[10];
	for(int i=0;i<5;i++){
	  r[9-i*2]=s[i*2];
	  r[i*2]=s[i*2+1];
	  reverse(r[i*2].begin(),r[i*2].end());
	}
	copy(r,r+10,s);
      }
    }
    h=ss;
  }
};

string s[10];
set<L> st;

void dfs(int d,int u,const L &c){
  if(d==10){
    L fc=c;
    fc.mh();
    st.insert(fc);
  }else{
    for(int i=0;i<10;i++){
      if(!(u>>i&1)){
	//	for(int k=0;k<1+(s[i]!=string(s[i].rbegin(),s[i].rend()));k++){
	for(int k=0;k<2;k++){
	  reverse(s[i].begin(),s[i].end());
	  bool f=false;
	  for(int j=!(d&1);j<d;j+=2){
	    f|=c.s[j][d/2]==s[i][j/2];
	  }
	  if(!f){
	    L nc=c;
	    nc.s[d]=s[i];
	    dfs(d+1,u|1<<i,nc);
	  }
	}
      }
    }
  }
}

int main(){
  while(cin>>s[0],s[0]!="END"){
    for(int i=1;i<10;i++){
      cin>>s[i];
    }
    st.clear();
    dfs(0,0,L());
    cout<<st.size()<<endl;
  }
  return 0;
}

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

using namespace std;

int
main(void){
  int a, b;
  cin >> a >> b;

  int count = 0;
  for(int i=a; i<=b; i++){
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]){
      count++;
    }
  }

  cout << count << endl;
  
  return 0;
}


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

using namespace std;





int main(){
    
    int N, H;
    cin >> N >> H;
    vector<int> a(N);
    vector<int> b(N);
    
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    int ans = 0;

    while (H > 0) {
        if (b[b.size()-1] > a[a.size()-1]) {
            ans += 1;
            H -= b[b.size()-1];
            b.pop_back();
        }else{
            if (a[a.size()-1] == 1) {
                ans += H;
                H = 0;
            }else{
                int aa = a[a.size()-1] ;
                if (H%aa == 0) {
                    ans += H/aa;
                    
                }else{
                    ans += H/aa;
                    ans += 1;
                    
                }
                
                H = 0;
            }
            
        }
            
    }
    
    cout << ans << endl;
    
    
    
}




Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[110],b[110],i,max=0;
    cin>>n;
    for(i=0; i<n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
        cin>>b[i];
    int sum=0,temp=n;
    while(temp!=0)
    {
        sum=0;
        for(i=0; i<temp; i++)
            sum=sum+a[i];
        temp=temp-1;
        for(i=temp; i<n; i++)
            sum=sum+b[i];
        if(sum>max)
            max=sum;
    }
    cout<<max<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
using ld=long double;

int V[4],N;
ld n,dp[301][301][301];
ld f(int a,int b,int c){
  if(dp[a][b][c]>=0)return dp[a][b][c];
  ld res=n;
  if(a)res+=(ld)a*f(a-1,b,c);
  if(b)res+=(ld)b*f(a+1,b-1,c);
  if(c)res+=(ld)c*f(a,b+1,c-1);
  return dp[a][b][c]=res/(a+b+c);
}

signed main(){
  cin>>N;n=N;
  REP(i,N){int x;cin>>x;V[x]++;}
  REP(i,301)REP(j,301)REP(k,301)dp[i][j][k]=-1; dp[0][0][0]=0;
  cout<<fixed<<setprecision(12)<<f(V[1],V[2],V[3])<<endl;
}


Measured memory_bytes: 426368
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int, raw_input().split())
MOD = 10**9+7
fact = [1]*(n+1)
frev = [1]*(n+1)

rcd = range(c, d+1)

dp = [0]*(n+1)
dp[0] = 1

for i in xrange(1, n+1):
    v = fact[i] = (fact[i-1] * i) % MOD
    frev[i] = pow(v, MOD-2, MOD)
if a==c==1 and b==d==n:
    Y = [None]*(n+1)
    for g in xrange(1, n+1):
        y = frev[g]
        Y[g:n+1:g] = (pow(y, j, MOD)*frev[j] for j in xrange(1, n/g+1))
        dp[g:] = (dp[i] + frev[n-i]*sum(dp[i-j] * fact[n-i+j] * Y[j] for j in xrange(g, i+1, g)) % MOD for i in xrange(g, n+1))
else:
    Y = [None]*(d+1-c)
    for g in xrange(a, min(n/c, b)+1):
        p = c*g
        y = frev[g]
        Y[:min(d,n/g)+1-c] = (pow(y, j, MOD)*frev[j] for j in xrange(c, min(d, n/g)+1))
        dp[p:] = (dp[i] + frev[n-i]*sum(dp[i-g*j] * fact[n-i+g*j] * Y[j-c] for j in xrange(c, min(d, i/g)+1)) % MOD for i in xrange(p, n+1))
print dp[n]%MOD

Measured memory_bytes: 2884
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x is not None: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


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

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *root, int key)
{
	while (root != NIL && key != root->key)
	{
		if (key < root->key) root = root->left;
		else root = root->right;
	}
	return root;
}

void insert(int key)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NIL) root = z;
	else
	{
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *root)
{
	if (root == NIL) return;
	inorder(root->left);
	cout << " " << root->key;
	inorder(root->right);

}

void preorder(Node *root)
{
	if (root == NIL) return;
	cout << " " << root->key;
	preorder(root->left);
	preorder(root->right);
}

int main()
{
	int n, key;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str == "find")
		{
			cin >> key;
			Node *t = find(root, key);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
}

Measured memory_bytes: 21748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll d[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') continue;
            ll cnt = 0;
            rep(k, 4) {
                ll nx = j + d[k][0];
                ll ny = i + d[k][1];
                if ((nx < 0) || (nx >= w) || (ny < 0) || (ny >= h)) continue;
                if (s[ny][nx] == '#') cnt++;
            }
            if (cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {

    int n;
    cin>>n;

    bool flag = false;
    while(n){
        int rem = n%10;
        if(rem==7){
            flag = true;
            break;
        }
        n = n/10;
    }

    if(flag){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


Measured memory_bytes: 3564
package main

import (
	"fmt"
	"sort"
)
func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
	var s string; var k int
	fmt.Scan(&s, &k)

	n := len(s)
	res := make(map[string]bool)
	for i := 0; i < n; i++ {
		for j := 1; j < minInt(k, n - i) + 1; j++ {
			res[string(s[i:i+j])] = true
		}
	}
	a := make([]string, len(res))
	i := 0
	for t := range res {
		a[i] = t; i++
	}
	sort.Strings(a)
	fmt.Println(a[k-1])
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	cin>>n; 
	int a[n+5];
	for(int i=1;i<=n;i++) 
	{
		cin>>a[i];
		while(a[i]%2==0)
		{
			a[i]=a[i]/2;
			s++;
		} 
	}
	cout<<s;
	return 0;
}


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

int main() {
    int n;
    string m;
 
   cin >> n >> m;
   int sum = 0;
   int max = 0;
  
   for(int i = 0;i<n;i++){
     
     if(m[i]=='I'){
       
       sum+=1;
     }else{
       sum-=1;
     }
     

     if(max < sum){
       
       max = sum;
     }
      // cout << sum << endl;
   }
  
   cout << max << endl;
  // cout << m << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while(a >= b){
        k--;
        b *= 2;
    }
    while(b >= c){
        k--;
        c *= 2;
    }
    cout << (k >= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

 
ll inv(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x%N;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

int main(void){
	ll n;
	cin>>n;
	ll t = inv(10LL,n);
	ll s = inv(9LL,n);
	ll u = inv(8LL,n);
	ll ans = (2*s-u)%N;
	ans = (ans+N)%N;
	ans = (t-ans+N)%N;
	cout<<ans%N<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int x1,y1,x2,y2,x3,y3;
    scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3);

    double a[3];
    a[0]=sqrt((double)(x1-x2)*(x1-x2)+(double)(y1-y2)*(y1-y2));
    a[1]=sqrt((double)(x1-x3)*(x1-x3)+(double)(y1-y3)*(y1-y3));
    a[2]=sqrt((double)(x3-x2)*(x3-x2)+(double)(y3-y2)*(y3-y2));
    sort(a+0, a+3);

    double cos0=(a[1]*a[1]+a[2]*a[2]-a[0]*a[0])/(2*a[1]*a[2]);
    double tan0=(1-cos0)/(1+cos0);
    tan0=sqrt(tan0);

    double cos1=(a[0]*a[0]+a[2]*a[2]-a[1]*a[1])/(2*a[0]*a[2]);
    double tan1=(1-cos1)/(1+cos1);
    tan1=sqrt(tan1);

    double r = a[2]/(2+(1/tan0)+(1/tan1));
    printf("%.10lf\n", r);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	int ans = 0;
	for (int x = 1; x <= k; x++) {
		for (int y = 1; y <= k; y++) {
			int g = gcd(x, y);
			for (int z = 1; z <= k; z++) {
				ans += gcd(g, z);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;



int main() {
	while(1) {
		int N; cin >> N;
		if (!N)break;
		vector<pair<string, long double>>pls;
		for (int i = 0; i < N; ++i) {
			string st;
			int p, a, b, c, d, e, f, s, m; cin >> st>>p >> a >> b >> c >> d >> e >> f >> s >> m;
			int initime = a + b + c;
			int rooptime = d + e;
			int money = m*s*f-p;
			long double eff = static_cast<long double>(money) / static_cast<long double>(initime + rooptime*(m));
			pls.push_back(make_pair(st, eff));
		}
		sort(pls.begin(), pls.end(), [](const pair<string, long double>&l, const pair<string, long double>&r) {return abs(l.second-r.second)<1e-7?l.first<r.first:l.second > r.second; });
		for (int i = 0; i < pls.size(); ++i) {
			cout << pls[i].first << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
A - HonestOrDishonest
https://atcoder.jp/contests/abc056/tasks/abc056_a

"""
import sys


def solve(a, b):
    if a == 'H':
        return b
    return ['H', 'D'][b=='H']


def main(args):
    a, b = input().split()
    ans = solve(a, b)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

#define MAX_SIZE 50
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX_SIZE];
int n;

void preParse(int u) {
    if (u == NIL) return;
    cout << " " << u;
    preParse(T[u].left);
    preParse(T[u].right);
    return;
}

void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].left);
    cout << " " << u;
    inParse(T[u].right);
    return;
}

void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    cout << " " << u;
    return;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    int id, left, right;
    for (int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;
        if (left != NIL) T[left].parent = id;
        if (right != NIL) T[right].parent = id;
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }

    cout << "Preorder" << endl;
    preParse(root);
    cout << "\n";

    cout << "Inorder" << endl;
    inParse(root);
    cout << "\n";

    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3092
s = input()
t = input()
cnt = 0
ans = 0
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            cnt += 1
        ans = max(cnt,ans)
print(len(t)-ans)

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    go;
    string s;
    cin>>s;
    if(s=="ARC")
        
        cout<<"ABC";
    else
        cout<<"ARC";
    return 0;
}


Measured memory_bytes: 3592
"""
atcoder : 173B
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""

ans = {
    "AC": 0,
    "WA": 0,
    "TLE": 0,
    "RE":0
}

n = int(input())
for _ in range(n):
    ans[input()] += 1
print(f"AC x {ans['AC']}")
print(f"WA x {ans['WA']}")
print(f"TLE x {ans['TLE']}")
print(f"RE x {ans['RE']}")

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

int cnt;
int n;
int l;
int A[1000000];
vector<int> G;

void insertionSort(int A[],int n, int g){
    for (int i = g; i < n ; ++i) {
        int v = A[i];
        int j = i-g;
        while (j >= 0 && A[j] > v ){
            A[j+g] = A[j];
            j = j-g;
            cnt ++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[],int n){
    for (int h = 1 ; ; ){
    if(h > n)break;
    G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main(){
    cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
    cnt = 0;

    shellSort(A,n);

    cout << G.size() << endl;
    for (int i = G.size() -1 ; i >= 0 ; i--) {
        cout << G[i];
        if (i) cout << (" ");
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n ; ++i) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
def egcd(a, b):
    """Returns a triple (g, x, y), such that ax + by = g = gcd(a,b).
       Assumes a, b >= 0, and that at least one of them is > 0.
       Bounds on output values: |x|, |y| <= max(a, b)."""
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m) 
    if g != 1:
        return None
    else:
        return x % m

def main():
    s = input()
    n = len(s)
    h = [0]
    for i in range(n):
        h.append((h[-1] * 10 + int(s[i])) % 2019)
    p = [1]
    for i in range(n):
        p.append((p[-1] * 10) % 2019)
    lk = {0 : 1}
    cnt = 0
    for i in range(1, len(h)):
        curr = (h[i] * modinv(p[i], 2019)) % 2019
        # print(i, curr)
        if curr in lk:
            cnt += lk[curr]
            lk[curr] += 1
        else:
            lk[curr] = 1 
    print(cnt)
    
if __name__ == '__main__':
    main()   
        

Measured memory_bytes: 98656
#include<stdio.h>

int main(void){
    int k,x;
    int i;
    int min;
  	int temp;
    scanf("%d %d",&k,&x);
    min = x-k+1;
    for(i=0; i<2*k-1; i++){
        if(i==2*k-1){
            printf("%d\n",min);
        }
        else{
            printf("%d ",min);
        }
      min++;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, a[200005], l=0, r=1e9, m;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n) scanf("%d", a+i);
	while(l+1 < r){
		m = (l+r) / 2;
		long long c = 0;
		rep(i,n) c += (a[i]-1) / m;
		(c <= k ? r : l) = m;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 4584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

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

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main() {
	int b, r, g, c, s, t;
	while (cin >> b >> r >> g >> c >> s >> t, b || r || g || c | s || t) {
		int ans = 100;
		ans += b * 15 + 15 * 5 * b;
		ans += r * 15 + 15 * 3 * r;
		ans += g * 7;
		ans += c * 2;
		
		t -= s;
		ans -= (5 * b + 3 * r) * 2;
		ans -= (t - 5 * b - 3 * r) * 3;
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int main(){
  int a,b;
  cin>>a>>b;
  
  cout<<max({a+b,a-b,a*b})<<endl;

  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h> 

int main() {
    for(int i=0;i<1000;i++){
	int n = 0;
	int p = 0;
	int x[100] = {};
	int y = 0;
	int z = 0;
	int a = 0;

	scanf("%d %d", &n, &p);

	y = p;

	while (1) {
		while (y>0) {
			if (z<n) {
				x[z]++;
				y--;
				z++;
			}
			else if (z == n) {
				z = 0;
				x[z]++;
				y--;
				z++;
			}
		}


		while (y == 0) {
			if (z == n) {
				z = 0;
			}

			a = x[z];
			if (a == p) {
				break;
			}
			y = a;
			x[z] = 0;
			a = 0;
			z++;
		}
		
		if (n == 0 || p == 0) {
			break;
		}

		if (a == p) {
			printf("%d\n", z);
			break;
		}
	}
    }
	return 0;
}


Measured memory_bytes: 2636
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    int N=100001;
    char str[N];
    int ans=-1;
    cin >> str;
    if (strlen(str)==2){
        if (str[0]==str[1]){
            ans=-2;
        }
    }
    for (int i=0; i<N; i++){
        if (str[i+2]=='\0'){
            break;
        }
        if (str[i]==str[i+1] || str[i]==str[i+2]){
            ans=i;
            break;
        }
    }
    if (ans==-1){
        cout << -1 << ' ' << -1;
    }else if (ans==-2){
        cout << 1 << ' ' << 2;
    }else{
        cout << ans+1 << ' ' << ans+3;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    vector<P> l;
    l.emplace_back(a[0], 0);
    for (int i=0; i<n; i++) {
        if (l.back().first == a[i]) l.back().second++;
        else l.emplace_back(a[i], 1);
    }


    int ans = 0;
    for (auto p : l) {
        if (p.first < p.second) ans += p.second - p.first;
        if (p.first > p.second) ans += p.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1784
import java.util.Scanner;

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

        long A = sc.nextLong();
        long B = sc.nextLong();

        System.out.println(solve(A, B));

        sc.close();
    }

    static long solve(long A, long B) {
        return computeXORTo(B) ^ ((A == 0) ? 0 : computeXORTo(A - 1));
    }

    static long computeXORTo(long limit) {
        long result = 0;
        for (int i = 0;; ++i) {
            long placeValue = 1L << i;
            if (placeValue > limit) {
                break;
            }

            long count1 = 0;
            if (i == 0) {
                count1 += limit / 2;
            }
            count1 += Math.max(0, limit % (placeValue * 2) - (placeValue - 1));

            if (count1 % 2 != 0) {
                result += placeValue;
            }
        }

        return result;
    }
}

Measured memory_bytes: 35668