akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s, a[4] = {"dream", "dreamer", "erase", "eraser"};
bool solve(int n){
  if(n > s.size())return false;
  if(n == s.size())return true;
  int i;
  bool res = false;
  rep(i, 4){
    if(n + a[i].size() <= s.size() && s.substr(n, a[i].size()) == a[i]){
      //pri2(i, n);
      res = res | solve(n + a[i].size());
      //pri(res);
    }
  }
  return res;
}
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    cin >> s;
    puts(solve(0) ? "YES" : "NO");

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>

using namespace std;

int main()
{
  	int n=0;
    string s;
    cin >> s;
    if (s[0]==s[1] || s[0] == s[2] || s[0] == s[3])
    {
        n++;
    }
    if (s[1]==s[2] || s[1] == s[3])
    {
        n++;
    }
    if (s[2]==s[3])
    {
       n++;
    }
    if (n==2)
      cout << "Yes";
  	else cout << "No";
}

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

using namespace std;

void test_case() {
  string s;
  cin >> s;

  int q = 0;
  for (int i = 0; i < s.size(); i++) {
    q += s[i] - '0';
  }

  if (q % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  int t = 1;
  // cin >> t;
  while (t--) {
    test_case();
  }

  return 0;
}



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

template <typename T>
using Matrix = vector<vector<T>>;

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

    const auto n = int(s.size());
    auto f = Matrix<int>(n+2, vector<int>(27, n+1));
    auto children = vector<vector<int>>(n+2);
    children[n+1].push_back(n);
    for (auto i = n-1; i >= 0; i--)
    {
        const auto start = s[i]-'a';
        f[i][start] = i+1;
        for (auto c = start+1; c <= 26; c++)
            f[i][c] = f[f[i][c-1]][c-1];
        for (auto c = 0; c < start; c++)
            f[i][c] = f[f[i][26]][c];

        children[f[i][26]].push_back(i);
    }

    auto time = 0;
    auto start_times = vector<int>(n+2), exit_times = vector<int>(n+2);
    const function<void(int)> dfs = [&](const int v)
    {
        start_times[v] = time++;
        for (const auto c : children[v])
            dfs(c);
        exit_times[v] = time;
    };
    dfs(n+1);

    int Q; cin >> Q;
    for (auto q = 0; q < Q; q++)
    {
        int l, r; cin >> l >> r;
        l--; r--;
        cout << (start_times[r+1] <= start_times[l] && start_times[l] < exit_times[r+1] ? "Yes": "No") << endl;
    }
}


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

using namespace std;

int main(){
    int n,r;
    while(cin>>n>>r,n){
        vector<int> hana,array;
        for(int i=n;i>=1;i--){
            hana.push_back(i);
        }
        for(int i=0;i<r;i++){
            int p,c;
            cin>>p>>c;
            for(int j=0;j<c;j++){
                array.push_back(hana[p-1+j]);
            }
            for(int j=p-2;j>=0;j--){
                hana[j+c]=hana[j];
            }
            hana=array;
            array.clear();
        }
        cout<<hana[0]<<endl;
    }
    return 0;
}

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

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << '\n';
  }
  else if(b == c){
    cout << a << '\n';
  }
  else if(a == c){
    cout << b << '\n';
  }
}


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

using namespace std;
typedef long long ll;

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

    int S_size = S.size();

    //vector<int> child_num(S.length(), 1);

    vector<vector<char>> blocks;
    vector<char> block;

    vector<int> concent_point_R;
    int break_point = 0;

    char _c = S[0];
    block.push_back(_c);

    for(int i = 1; i < S_size; i++) {
        char c = S[i];

        if(_c == 'R' && c == 'L') {
            concent_point_R.push_back(i - 1 - break_point);
        }

        if(_c == 'L' && c == 'R') {
            blocks.push_back(block);
            block.assign({});
            break_point = i;
        }

        block.push_back(c);

        _c = c;
    }

    blocks.push_back(block);

    //vector<vector<int>> even_pos_num;

    for(int i = 0; i < blocks.size(); i++) {
        //vector<int> _even_pos_num;
        int current_concent_point_R = concent_point_R[i];

        int R_num = 0;
        int L_num = 0;

        for(int j = 0; j < blocks[i].size(); j++) {
            if(abs(current_concent_point_R - j) % 2 == 0) R_num++;
            else L_num++;
        }

        for(int j = 0; j < blocks[i].size(); j++) {
            if(j == current_concent_point_R) {
                cout << R_num;
                //_even_pos_num.push_back(R_num);
            } else if(j == current_concent_point_R + 1) {
                cout << L_num;
                //_even_pos_num.push_back(L_num);
            } else {
                cout << 0;
                //_even_pos_num.push_back(0);
            }

            if(i == blocks.size() - 1 && j == blocks[i].size() - 1) cout << endl;
            else cout << " ";
        }

        //even_pos_num.push_back(_even_pos_num);
    }

    return 0;
}

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

using namespace std;

typedef long long LL;

int a[100000];

int main(){
	int n,b,kind=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>b;
		a[b]++;
	}
	for(int i=1;i<=100000;i++){
		if(a[i]!=0){
			kind++;
		}
	}
	if(kind%2==0){
		cout<<kind-1<<endl;
	}
	else{
		cout<<kind<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
    cin >> n >> m;
    if(m<=2*n)cout<<m/2<<endl;
    else{
        cout<<(m-2*n)/4 + n<<endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

vector<int> retrograde(const graph& g) { // (0, 1, 2) = (lose, win, draw)
	int n = g.size();
	graph rg(n);
	vector<int> cnt(n), res(n, 2);
	queue<int> q;
	for (int i = 0; i < n; i++) {
		for (int to : g[i]) rg[to].push_back(i);
		cnt[i] = g[i].size();
		if (!cnt[i]) res[i] = 0, q.push(i);
	}
	while (!q.empty()) {
		int v = q.front(); q.pop();
		if (res[v]) {
			for (int to : rg[v]) if (res[to] != 1) {
				--cnt[to];
				if (cnt[to]) continue;
				res[to] = 0;
				q.push(to);
			}
			continue;
		}
		for (int to : rg[v]) if (res[to] != 1) res[to] = 1, q.push(to);
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int H, W, R, C;
	while (cin >> H >> W >> R >> C, H | W | R | C) {
		int S = (H + 2) * (W + 2);
		graph G(S * 3);
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				G[i * (W + 2) + j + S * 2].push_back(i * (W + 2) + j);
				G[i * (W + 2) + j + S * 2].push_back(i * (W + 2) + j + S);
			}
		}
		for (int t = 0; t <= H * 2; t++) {
			int i = (t + 1) >> 1;
			int s;
			if (t % 2 == 0) {
				for (int j = 1; j <= W; j++) {
					cin >> s;
					if (0 < i) G[i * (W + 2) + j + S * s].push_back((i + 1) * (W + 2) + j + S * 2);
					if (i < H) G[(i + 1) * (W + 2) + j + S * s].push_back(i * (W + 2) + j + S * 2);
				}
			}
			else {
				for (int j = 0; j <= W; j++) {
					cin >> s;
					if (0 < j) G[i * (W + 2) + j + S * s].push_back(i * (W + 2) + (j + 1) + S * 2);
					if (j < W) G[i * (W + 2) + (j + 1) + S * s].push_back(i * (W + 2) + j + S * 2);
				}
			}
		}
		cout << (retrograde(G)[R * (W + 2) + C] == 1 ? "Yes" : "No") << endl;
	}
	return 0;
}



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

using namespace std;

const int N = 100, oo = 1e9;
int n, a[N];
vector<pair<int, int> > res;

void allPositive() {
    for(int i = 2; i <= n; i++) res.push_back(make_pair(i - 1, i));
}

void allNegative() {
    for(int i = n; i > 1; i--) res.push_back(make_pair(i, i - 1));
}

int main() {
    cin >> n;
    int Max = -oo, Min = oo, iMax, iMin;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] > Max) Max = a[i], iMax = i;
        if (a[i] < Min) Min = a[i], iMin = i;
    }

    if (Max >= 0 && Min >= 0) allPositive();
    else if (Max <= 0 && Min <= 0) allNegative();
    else if (Max <= abs(Min)) { // convert to all neg
        for(int i = 1; i <= n; i++) if (a[i] > 0) res.push_back(make_pair(iMin, i));
        allNegative();
    } else { // convert to all pos
        for(int i = 1; i <= n; i++) if (a[i] < 0) res.push_back(make_pair(iMax, i));
        allPositive();
    }

    cout << res.size() << '\n';
    for(auto x: res) cout << x.first << ' ' << x.second << '\n';
}

Measured memory_bytes: 256
import itertools

N, M, X = [int(i) for i in input().split()]

cost = 0
books = []

for _ in range(N):
    books.append([int(i) for i in input().split()])
    
book_numbers = [i for i in range(0, N)]

cnt = set()

for i in range(1, N+1):
    c = list(itertools.combinations(book_numbers, i))
    for j in range(len(c)):
        combi = c[j]
        after_study = [0 for _ in range(M + 1)]
        for k in combi:
            for l in range(len(books[k])):
                after_study[l] += books[k][l]
                
        cost = after_study.pop(0)
        if min(after_study) >= X:
            cnt.add(cost)

if cnt :
    print(min(cnt))
else :
    print(-1)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	REP(i, n) {
		cin >> d[i];
	}
	int res = 0;
	int s = 0;
	int s2 = 0;
	REP(i, n) {
		s += d[i];
		s2 += d[i] * d[i];
	}
	put((s* s - s2) / 2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a%mod;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res)%mod;
    else return (a*res*res)%mod;
}

// vi adj[100005];
// vector<bool> vis(100005,false);


// void dfs(int s)
// {
//     vis[s]=true;
    
//     for(int u:adj[s])
//     {
//         if(!vis[u])
//         {
//             vis[u]=true;
//             dfs(u);
//         }
//     }
// }

void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-5,flag=0,count=0;
    string S,T,U;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes";
            return;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No";
            return;
        }
    }
}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

int main(void) {
  int n;
  scanf("%d", &n);
  
  int a = n % 2 == 1 ? n / 2 + 1 : n / 2;
  double ans = (double)a / (double)n;
  printf("%f\n", ans);
  return 0;
}


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

using namespace std;

int main(){
	int dice[6] = {1,2,3,4,5,6};
	int total=1;
	int n;
	int tmp;
	string command;
	
	while(cin>>n,n){
		total=1;
		for(int i=0;i<6;i++)dice[i]=i+1;
		for(int i=0;i<n;i++){
			cin>>command;
			if(command == "North"){
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
			}else if(command == "East"){
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
			}else if(command == "South"){
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
			}else if(command == "West"){
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
			}else if(command == "Right"){
				tmp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = tmp;
			}else{
				tmp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = tmp;
			}
			total += dice[0];
		}
		cout<<total<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll a, b, q;
        cin >> a >> b >> q;
        vector<ll> s(a + 2), t(b + 2), x(q);
        s[0] = t[0] = -ll_inf;
        s[a + 1] = t[b + 1] = ll_inf;
        repone(i, a) cin >> s[i];
        repone(i, b) cin >> t[i];
        rep(i, q) cin >> x[i];

        each(m, x) {
            auto bs = lower_bound(s.begin(), s.end(), m);
            auto bt = lower_bound(t.begin(), t.end(), m);
            ll ls = *bs, ps = *(--bs);
            ll lt = *bt, pt = *(--bt);

            ll ans = min({max(lt - m, ls - m),
                            max(m - pt, m - ps),
                            ls - pt + min(m - pt, ls - m),
                            lt - ps + min(m - ps, lt - m)
                           });
            cout << ans << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
#define rg register
#define LL long long
using namespace std;
const int MAXN=5000;
int a,b,c,d;
 
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	printf("%d\n",(a-c)*(b-d));
	
	return 0;
}


Measured memory_bytes: 256
//コンパイラ最適化用
// #pragma GCC optimize("O3")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n= 0, ac = 0, wa=0, tle=0, re=0;
    cin >> n;
    for(int i = 0; i < n; i++){
        string d;
        cin >> d;
        if(d=="AC"){
            ac+=1;
        } else if (d=="WA"){
            wa+=1;
        } else if (d=="TLE"){
            tle+=1;
        } else {
            re+= 1;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3224
#include <stdio.h>

int main() {
    int a, b, c, ret;
    scanf("%d %d %d", &a, &b, &c);
    ret = a + b + c;        
    if (a >= b && a >= c)
        ret -= a;
    else if (b >= c && b >= a)
        ret -= b;
    else if (c >= a && c >= b)
        ret -= c;
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD = 1e9 + 7;
 
int dp[310][310][310];
vector<int> cond[310];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;

	// cond[r] : 与えられた条件のうち右端がrのもののidx
	vector<int> l(m), r(m), x(m);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i] >> x[i];
		cond[r[i]].push_back(i);
	}

	dp[0][0][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j != 0 && j == i) continue;
			for (int k = 0; k <= n; k++) {
				if (k != 0 && (k == i || k == j)) continue;
				// 0以外はi,j,kがすべて異なる場合をチェック
				// (右端に塗れるのは1色のみ)
				int cmax = max({i, j, k});
				for (int idx : cond[cmax]) {
					// 右端がcmaxの条件を確認していく
					// (l[idx] <= i) --- 左端l[idx]以降で赤を塗っている
					int cnt = 0;
					cnt += (l[idx] <= i);
					cnt += (l[idx] <= j);
					cnt += (l[idx] <= k);

					// 左端l[idx]以降で塗った種類数が一致していなければ除外
					if (cnt != x[idx]) dp[i][j][k] = 0;
				}

				// 次に色を塗って塗っていく
				// dp[i][j][k]はcmaxまで色が塗られているため、次に塗るのはcmax+1
				// cmax+1に色を塗るときはdp[i][j][k]通りからそれぞれ赤、青、緑が塗られる
				// これが条件を満たすかは先のループで検証される
				(dp[cmax + 1][j][k] += dp[i][j][k]) %= MOD;
				(dp[i][cmax + 1][k] += dp[i][j][k]) %= MOD;
				(dp[i][j][cmax + 1] += dp[i][j][k]) %= MOD;
			}
		}
	}
 
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != 0 && i == j) continue;
			(ans += dp[n][i][j]) %= MOD;
			(ans += dp[i][n][j]) %= MOD;
			(ans += dp[i][j][n]) %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int ans = 0;
    int a, b, c, x; cin >> a >> b >> c >> x;
    for (int num_a=0; num_a<=a; ++num_a) {
        for (int num_b=0; num_b<=b; ++num_b) {
            for (int num_c=0; num_c<=c; ++num_c) {
                if (500*num_a+100*num_b+50*num_c == x) ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
int n,x;
int main(){
    scanf("%d",&n);
    int flag=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        if(x%2==0){
            if(x%3==0 || x%5==0)
                continue;
            else
                flag=0;
        }
    }
    if(flag)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){

int sum = 0; 
string s,t;

cin >> s >> t;

for (int i = 0; i < 3; i++){
    if (s[i] == t[i]){
        sum++;
    }
}

cout << sum << endl;
 
 return 0; 
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import defaultdict

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    S = input()
    T = input()

    s1 = {}
    t1 = {}

    for i, (s, t) in enumerate(zip(S, T)):
        if s in s1 and t in t1:
            if s1[s] != t1[t]:
                print('No')
                return
        elif s not in s1 and t not in t1:
            s1[s] = i
            t1[t] = i
        else:
            print('No')
            return
    
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9644
def factorization(n):#素因数分解
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
fac = factorization(N)
cnt = 0

if N == 1:
    print(0)
    exit()

for i in range(len(fac)):
    e = 1
    while fac[i][1]-e >= 0:
        fac[i][1] -= e
        e += 1
        cnt += 1 
print(cnt)

Measured memory_bytes: 63420
/// Solution No.: 01

/// Approach:

/// Comment:

/// Verdict:

/// Report:


#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <string.h>
#include <climits>
#include <set>
#include <cassert>
#include <cfloat>
#include <stack>

///using namespace std;         /// Recommended not to use

#define p(x) std::cout<<#x<<" = "<<x<<"\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define absolute(x) (((x)<0)?(-(x)):(x))
/// #define _DEBUG

typedef long long int ll;
typedef unsigned long long llu;
typedef long double lld;

/// lld pi = 2 * acos(0.0);   /// precision error
lld pi = 2 * acosl(0.0);

int test_case_number, test_case=1;

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
/// Direction Array
/// int dx[]={0, 0, 1, -1, -1, 1, -1, 1};
/// int dy[]={-1, 1, 0, 0, 1, 1, -1, -1};

///place for problem specific functions


void function_name()
{
    int element_number;
    scanf("%d", &element_number);
    std::vector<int> dp(3,0);
    for(int i=0;i<element_number;i++)
    {
        std::vector<int>main_array(3),new_dp(3,0);
        for(int i=0;i<3;i++)
        {
            scanf("%d", &main_array[i]);
        }
        for(int i=0;i<3;i++)
        {
            for(int j =0; j<3;j++)
            {
                if(i!=j)
                {
                    new_dp[i]= std::max(new_dp[i], dp[j]+main_array[i]);
                }
            }
        }
        dp= new_dp;
    }

    int ans = std::max({dp[0],dp[1],dp[2]});
    printf("%d\n", ans);

}
void function_name(int v1, int v2, int v3)
{

}
void function_name(std::string line)
{

}
class initial_works
{
public:

    void with_test_case_number()
    {
        scanf("%d", &test_case_number);
        ///getchar();
        while(test_case <= test_case_number)
        {
            function_name();
            test_case++;
        }
    }

    void single_iteration()
    {
        function_name();
    }

    void without_test_case_number()
    {
        int v1, v2, v3;
        while(scanf("%d %d %d", &v1, &v2, &v3)==3 && v1!=0)
        {
            function_name(v1, v2, v3);
            test_case++;
        }
    }

    void eoof()
    {
        char dummy_char_array[100];
        while(scanf("%[^\n]", dummy_char_array)!=EOF)
        {
            ///it only takes the absence of one getchar to ruin your life. Don't understand remove the getchar below and then input the sample input
            getchar();
            ///if not given getchar. the dummu_char_array will not take new input as there is newline after the first input is taken. It will continue with the previous value.
            /// So, the function will run with same argument.
            std::string line = dummy_char_array;
            function_name(line);
            test_case++;
        }
    }
};


int main()
{
    //std::ios_base::sync_with_stdio(false);
    initial_works a;
    a.single_iteration();

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void) {
  int n, a, b;
  long long ans=0;
  cin>>n>>a>>b;
  for(int i=1; i<=n; i++) {
    int x=i;
    int y=0;
    while(x!=0) {
      y+=x%10;
      x=x/10;
    }
    if(a<=y and y<=b) ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n,C=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(n):
    s,t,c=map(int,input().split())
    d[c].append((s,t))
T=[0 for i in range(2*10**5+3)]
for i in d.values():
    i.sort()
    T[i[0][0]*2-1]+=1
    T[i[-1][1]*2+1]-=1
    for x,y in zip(i,i[1:]):
        s1,t1=x
        s2,t2=y
        if t1!=s2:
            T[s2*2-1]+=1
            T[t1*2+1]-=1
from itertools import accumulate
T=list(accumulate(T))
print(max(T))

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

using namespace std;

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

  string S[N];
  map<string, int> ans_num;
  string ans[] = {"AC", "WA", "TLE", "RE"};
  for (int i = 0; i < 4; i++) {
    ans_num[ans[i]] = 0;
  }

  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "AC") {
      ans_num[ans[0]] += 1;
    } else if (S[i] == "WA") {
      ans_num[ans[1]] += 1;
    } else if (S[i] == "TLE") {
      ans_num[ans[2]] += 1;
    } else if (S[i] == "RE") {
      ans_num[ans[3]] += 1;
    }
  }

  cout << "AC x " << ans_num[ans[0]] << endl;
  cout << "WA x " << ans_num[ans[1]] << endl;
  cout << "TLE x " << ans_num[ans[2]] << endl;
  cout << "RE x " << ans_num[ans[3]] << endl;

  return 0;
}

Measured memory_bytes: 6756
A,B,C,D=map(int,input().split())

def ans164(A, B, C, D):
    while True:
        C=C-B
        if A<=0:
            return"No"
            break
        A=A-D
        if C<=0:
            return "Yes"
            break

print(ans164(A,B,C,D))

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

int main(){
  vector<char> MY(15);
  for(int i=0;i<15;i++){
    cin >> MY.at(i);
  }
  int count=0;
  for(int i=0;i<15;i++){
    if(MY.at(i)=='x'){
      count++;
    }
  }
  if(count<8){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
// Problem : B - Postdocs
// Contest : AtCoder - NOMURA Programming Competition 2020
// URL : https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
void solve()
{
	string str;
	cin >> str;
	rep(i,0,str.size())
	{
		if(str[i]=='?')
		str[i]='D';
	}
	cout << str;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}

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

using namespace std;

using ll = long long;

struct State {
    int at;
    ll cost;
    //int prev;
    State(int at, ll cost/*, int prev*/) : at(at), cost(cost)/*, prev(prev)*/ {}
    bool operator>(const State& s) const {
        //if (cost != s.cost) return cost > s.cost;
        //if (prev != s.prev) return prev > s.prev; //最短経路を辞書順最小にする(省略可)
        //return at > s.at;
        return cost > s.cost;
    }
};

struct Edge {
    int to;
    ll cost;
    Edge(int to, ll cost) : to(to), cost(cost) {}
};

using Graph = vector<vector<Edge> >; //隣接リスト

const ll INF = 1e15;
//const int NONE = -1;

//sは始点、mincは最短経路のコスト、prevsは最短経路をたどる際の前の頂点
void dijkstra(int s, const Graph& graph, vector<ll>& minc/*, vector<int>& prevs*/){
    minc.assign(graph.size(), INF);
    //prevs.assign(graph.size(), NONE);

    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0/*, NONE*/);
    minc[s] = 0;

    while(!pq.empty()) {
        State cur = pq.top();
        pq.pop();
        if (minc[cur.at] < cur.cost) continue; 

        for(const Edge& e : graph[cur.at]) {
            ll cost = cur.cost + e.cost;
            if (minc[e.to] <= cost) continue;
            minc[e.to] = cost;
            //prevs[e.to] = cur.at;
            pq.emplace(e.to, cost/*, cur.at*/);
        }
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    Graph g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
        g2[u].emplace_back(v, b);
        g2[v].emplace_back(u, b);
    }
 
    vector<ll> minc1(n, INF), minc2(n, INF);
    dijkstra(s, g1, minc1);
    dijkstra(t, g2, minc2);
 
    vector<ll> ans(n, INF);
    for (int i = n - 1; i >= 0; i--) {
        ans[i] = min(ans[i], minc1[i] + minc2[i]);
        if (i < n - 1) ans[i] = min(ans[i], ans[i + 1]);
    }
 
    for (int i = 0; i < n; i++) {
        cout << INF - ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19016
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    char[] s = sc.next().toCharArray();
    int[] pn = new int[n];
    for (int i = 0; i < n; i++) {
      if (String.valueOf(s[i]).equals("L")) {
        pn[i] = -1;
      } else {
        pn[i] = 1;
      }
    }
    int happy = 0;
    int previous = -2;
    for (int i = 0; i < n; i++) {
      if (previous == pn[i]) {
        happy += 1;
      }
      previous = pn[i];
    }
    pw.println(Math.min(n - 1, happy + 2 * k));
  }
}


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

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


Measured memory_bytes: 256
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1}
};

#[fastout]
fn main() {
   input! {
      k: usize,
      a: usize,
      b: usize,
   }
   for i in a..=b {
      if i%k==0 {
         println!("OK");
         return;
      }
   }
   println!("NG");
}


Measured memory_bytes: 2136
// バケット法による解
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

    int c;

    for (int a = 0; a <= N; ++a) {
    	for (int b = 0; b <= N-a; ++b) {
    		c = N-a-b;
    		if(Y == 10000*a + 5000*b + 1000*c){
    			cout << a << " " << b << " " << c << endl;
    			return 0;
    		}
    	}
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int ans = 0;
	int M = N - 1;
	vector< int > d;
	for (int i = 1; i * i <= M; i++) {
		if (M % i == 0) {
			d.push_back(i);
			if (i != M / i)
				d.push_back(M / i);
		}
	}
	ans += d.size() - 1;
	d.clear();
	M = N;
	for (int i = 1; i * i <= M; i++) {
		if (M % i == 0) {
			d.push_back(i);
			if (i != M / i)
				d.push_back(M / i);
		}
	}
	for (auto x : d) {
		if (x == 1)
			continue;
		int M = N;
		while (M % x == 0)
			M /= x;
		if (M % x == 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,max1=0,max2=0,max3=0,max4=0,ans1=0,ans2=0,ans3=0,ans4=0,x,y;
  bool flag1=false,flag2=false;
  cin>>n;
  vector<long long int> a(n/2),b(n/2);
  unordered_map<long long int,long long int> mp1,mp2;
  rep(i,n){
    int m;
    cin>>m;
    if(i%2==0){
      a[i/2]=m;
    }else{
      b[i/2]=m;
    }
  }
  rep(i,n/2){
    mp1[a[i]]++;
    mp2[b[i]]++;
    
  }
  
  rep(i,n/2){
    if(max1<mp1[a[i]]){
      ans1=a[i];
      max1=mp1[a[i]];
    }
  }
  rep(i,n/2){
    if(max2<mp2[b[i]]){
      ans2=b[i];
      max2=mp2[b[i]];
    }
  }
  x=mp1[ans1];
  y=mp2[ans2];
  mp1[ans1]=0;
  mp2[ans2]=0;
  max1=0;
  max2=0;
  rep(i,n/2){
    if(max1<mp1[a[i]]){
      ans3=a[i];
      max1=mp1[a[i]];
    }
  }
  rep(i,n/2){
    if(max2<mp2[b[i]]){
      ans4=b[i];
      max2=mp2[b[i]];
    }
  }
  if(ans1!=ans2){
    cout<<n-x-y<<endl;
  }else{  
    cout<<min(n-x-mp2[ans4],n-y-mp1[ans3])<<endl;
  }
  
  
  
}
///////////////////////////





Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  string s, t; cin >> s;
  int checked;
  do {
    t = "";
    checked = 0;
    if (s=="mew") {
      s="";
      break;
    }

    for (int i = 0; i < s.length(); i++) {
      if (i==0 || s.length()-4 < i) {
        t+=s[i];
      } else if (s.substr(i, 3) == "mew") {
        i+=2;
        checked = 1;
      } else {
        t+=s[i];
      }
    }
    s=t;
  } while (checked);

  if (s.length() > 0) {
    cout << "Rabbit" << endl;
  } else {
    cout << "Cat" << endl;
  }
}



Measured memory_bytes: 3236
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    int k;
    int h[100005];
    int ans = 0;
    
    cin >> n >> k;
    for (int i = 0;i < n;i++){
        cin >> h[i];
        if (h[i] >= k){
            ans++;
        }
    }
    cout << ans << endl;
}


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


#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
 
using namespace std;
using ll = long long;
typedef pair<int, int> Pair;
 
const int MOD = 1000000007;
 
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
 
vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
 
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}
 
mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }
 

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

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,temp,r=0;
    scanf("%d",&n);
    while(n!=0)
    {
        temp=n%10;
        if(temp==9)
        {
            r=9;
        }
        n=n/10;
    }
    r==9?printf("Yes\n"):printf("No\n");
}

Measured memory_bytes: 128
#include <stdio.h>
void insert(int key);
int heapExtractMax(void);
void heapIncreasekey(int i,int key);
void maxHeapify(int A[],int i);

int H,s[1000000];

int main()
{
  int i,key;
  char cmd[10];

  while(1){
    scanf("%s",cmd); 
    if(cmd[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(cmd[1]=='x') printf("%d\n",heapExtractMax());
    else break;
  }
  
  return 0;
}

void insert(int key)
{
  H++;
  s[H]=-1;
  heapIncreasekey(H,key);
}

int heapExtractMax(void)
{
  int max;
  
  if(H<1) return;
  
  max=s[1];
  s[1]=s[H];
  H--;
  maxHeapify(s,1);
  
  return max; 
}

void heapIncreasekey(int i,int key)
{
  int temp;
  
  if(key<s[i]) return;

  s[i]=key;
  while(i>1 && s[i/2]<s[i]){
    temp=s[i];
    s[i]=s[i/2];
    s[i/2]=temp;
    i=i/2;
  }
}

void maxHeapify(int A[],int i)
{
  int l,r,largest,temp;

  l = i*2;
  r = l+1;

  // ????????????????????????????????§???????????§????????????????????¶
  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest]) largest = r;
	       
  if(largest != i){  // i ???????????????????????§????????´???
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest); // ?????°??????????????????
  }	     
}

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == '7'){
			cnt++;
		}
	}
	cnt > 0 ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, cnt = 0;
    cin >> n;
    vector< pair<int, int> > red(n), blue(n);
    vector<bool> used(n, false);
    for (vector<int>::size_type i = 0; i < n; ++i) cin >> red.at(i).first >> red.at(i).second;
    for (vector<int>::size_type i = 0; i < n; ++i) cin >> blue.at(i).first >> blue.at(i).second;
    sort(red.begin(), red.end(), greater< pair<int, int> >());
    sort(blue.begin(), blue.end());
    for (int i = 0; i < blue.size(); ++i) {
        int max = -1, pos = -1;
        for (int j = 0; j < red.size(); ++j) {
            if (used.at(j)) continue;
            if (blue.at(i).first <= red.at(j).first || blue.at(i).second <= red.at(j).second) continue;
            if (max < red.at(j).second) {
                max = red.at(j).second;
                pos = j;
            }
        }
        if (pos >= 0) {
            ++cnt;
            used.at(pos) = true;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    s = collections.Counter(s)
    t = 1
    for k, v in s.items():
        t *= (v + 1)
        t %= mod
    print(t - 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
    COMinit();
    ll sum1=0;
    for(ll i=c1;i<=c2;i++){
    	//cout << COM(r2+i+1,i+1)<<endl;
    	sum1+=COM(r2+i+1,i+1);
    	sum1%=inf;
    }
    ll sum2=0;
    for(ll i=c1;i<=c2;i++){
    	//cout << COM(r1+i,i+1)<<endl;
    	sum2+=COM(r1+i,i+1);
    	sum2%=inf;
    }    
    if(sum1-sum2<0){
    	sum1+=inf;
    }
    cout <<sum1-sum2;
	// your code goes here
	return 0;
}


Measured memory_bytes: 123128