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

int main() {
  int N,i;
  cin >> N;
  vector<int> H(N);
  for(i=0; i<N; i++)
    cin >> H.at(i);
  
  for(i=1; i<N; i++)
    if(H.at(i)>H.at(i-1))
      H.at(i)--;
    else if(H.at(i)<H.at(i-1))
      break;
  
  if(i==N)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
}

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

int main() {

	int max=1,X=0,k=0;

	cin >> X;

	for (int i = 2;i <= X;i++) {

		for (int n = 2;pow(i,n) <= X;n++) {

			k = pow(i,n);

			if (k >= max)
				max = k;
			
		}

	}

	cout << max;

	cin >> X;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define i64 unsigned long long

using namespace std;

i64 arr[1000005];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", arr+i);
    }
    printf("%lld\n", *max_element(arr, arr+n) - *min_element(arr, arr+n));
}


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  if (N == 0) {
    cout << "1" << endl;
  }
  else {
    cout << "0" << endl;
  }
}
      


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

bool check(const string& s) {
	for (auto c : s) {
		if (c == 'A') continue;
		if (c == 'T') continue;
		if (c == 'C') continue;
		if (c == 'G') continue;
		return false;
	}
	return true;
}

int main() {
	string s; cin >> s;
	int res = 0;
	int l = s.size();
	for (int i = 0; i < l; i++) {
		for (int len = res + 1; i + len <= l; len++) {
			if (check(s.substr(i, len))) {
				res = len;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
/*
 * Author: Khan
 * Date: 10th October, 2017
 */
#include <stdio.h>

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", gcd(a, b));
    return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
#define int long long
using namespace std;

int bsum, q, a, b;
int ls, rs;
multiset<int> stl, str;

void balance() {
	if(str.size() > stl.size()) {
		int x = *str.begin();
		stl.insert(x);
		str.erase(str.find(x));
		rs -= x;
		ls += x;
	}
	else if(stl.size() - 1 > str.size()) {
		auto it = stl.end();
		it--;
		int x = *it;
		str.insert(x);
		stl.erase(stl.find(x));
		rs += x;
		ls -= x;
	}
}

void upd() {
	cin >> a >> b;
	bsum += b;
	if(stl.empty()) {
		stl.insert(a);
		ls += a;
		return;
	}
	auto it = stl.end();
	it--;
	int med = *it;
	if(a <= med) {
		ls += a;
		stl.insert(a);
	}
	else {
		str.insert(a);
		rs += a;
	}
	balance();
}

void solve() {
	int res = bsum;
	auto it = stl.end();
	it--;
	int x = *it;
	res -= ls;
	res += rs;
	res += -x * str.size();
	res += x * stl.size();
	cout << x << " " << res << '\n'; 
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> q;
	while(q--) {
		int t;
		cin >> t;
		if(t == 1)  {
			upd();
		}
		else
			solve();
	}
}

Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>
#include<set>


using namespace std;


int main(){
	//freopen("in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	set<int> record;
	for(int i = 0;i < n;i++){
		int num; cin >> num;
		if(record.count(num)>0) {cout << "NO" << endl; return 0;}
		record.insert(num);
	}
	cout << "YES" << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a==b){
        cout <<  "Draw"  << endl;
    }else if(a == 1){
        cout <<  "Alice" << endl;
    }else if(b == 1){
        cout << "Bob" << endl;
    }else if( a > b){
         cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    string O, E;
    cin >> O >> E;
    string ans = "";
    rep(i, E.length()) {
        ans += O[i];
        ans += E[i];
    }
    if (O.length() > E.length()) ans += O[O.length() - 1];
    cout << ans << endl;


    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = 3;
  if (a == b || b == c || c == a) ans--;
  if (a == b && b == c) ans--;
  cout << ans << endl; 
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	set<string> sset;
	string S;
	rep(i, 0, N)
	{
		cin >> S;
		sset.insert(S);
	}

	cout << SZ(sset) << endl;

	return 0;
}

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i <= n-3; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
int main(void){
  int N;
  int L[200];
  int sum = 0;
  std::cin >> N;
  for(int i=0;i<2*N;i++){
    std::cin >> L[i];
  }
  std::sort(L,L+2*N);
  for(int i=0;i<2*N;i+=2){
    if(L[i] < L[i+1]){
      sum += L[i];
    }else if(L[i] >= L[i+1]){
      sum += L[i+1];
    }
  }
  printf("%d",sum);
  return 0;
}

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


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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





int main() {
    string s;
    cin >> s;
    if(s <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC011A Airport Bus
  int N, C, K; cin >> N >> C >> K;
  vector<int> T(N);
  REP(i, N){
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  int cnt = 1, tim = T[0], now = T[0], ans = 0;
  for(int i = 1; i < N; i++){
    if(cnt <= C && now <= tim + K){
      now = T[i];
      cnt++;
    }
    if(cnt > C || now > tim + K){
      ans++;
      cnt = 1;
      tim = now;
    }
  }
  cout << ans + 1 << endl;
}

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

void testcase(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll mx= LLONG_MIN;
    mx=max(a*c,mx);
    mx=max(a*d,mx);
    mx=max(b*c,mx);
    mx=max(b*d,mx);
    ll zero = 0;
    if((a<=0 && b >=0) || (c<=0 && d>=0))
    mx=max(zero,mx);
    cout << mx;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;

        typedef tuple<int,int,int> triple;
        set<triple> intervals;
        intervals.insert(triple(0,0,-inf));
        rep(i,0,n){
            /*
            for(const auto& interval:intervals){
                cout << get<0>(interval) << " " << get<1>(interval) << " " << get<2>(interval) << endl;
            }
            */
            char command;
            cin >> command;
            if(command=='W'){
                int id,len;
                cin >> id >> len;
                auto a=intervals.begin();
                auto b=intervals.begin();
                ++b;
                while(len>0){
                    int l=get<1>(*a);
                    if(b==intervals.end()){
                        intervals.insert(triple(l,l+len,id));
                        break;
                    }
                    auto r=get<0>(*b);
                    if(l==r){
                        a=b;
                        ++b;
                        continue;
                    }
                    if(r-l>len) r=l+len;
                    b=intervals.insert(triple(l,r,id)).first;
                    a=b;
                    ++b;
                    len-=r-l;
                }
            }else if(command=='D'){
                int id;
                cin >> id;
                for(auto it=intervals.begin();it!=intervals.end();){
                    if(get<2>(*it)==id) it=intervals.erase(it);
                    else ++it;
                }
            }else{
                int addr;
                cin >> addr;
                bool ok=false;
                for(const auto& interval:intervals) if(get<0>(interval)<=addr and addr<get<1>(interval)){
                    cout << get<2>(interval) << endl;
                    ok=true;
                    break;
                }
                if(!ok) cout << -1 << endl;
            }
        }
        cout << endl;
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

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

int main()
{
	string s;
	cin>>s;
	
	if(s[0]=='7' || s[1]=='7' || s[2]=='7')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<int> a;
    rrep(j,9) rrep(i,j) {
        a.push_back(i*j);
    }
    rep(i,45) {
        if(n == a[i]) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	char S[51];
	char T[51];
	cin >> S >> T;

	int slen = strlen(S);
	int tlen = strlen(T);
	for (int i = slen - tlen; i >= 0; i--)
	{
		char a[51];
		memcpy(a, S, sizeof(S));
		bool restorable = true;
		for (int j = 0; j < tlen; j++)
		{
			if (a[i + j] == '?')
			{
				a[i + j] = T[j];
			}
			else if (a[i + j] != T[j])
			{
				restorable = false;
			}
		}

		if (!restorable) continue;

		for (int j = 0; j < slen; j++)
		{
			if (a[j] == '?')
			{
				a[j] = 'a';
			}
		}

		cout << a << endl;
		return 0;
	}

	cout << "UNRESTORABLE" << endl;
}



Measured memory_bytes: 256
s = input()
t = input()

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(0 , len(s) - len(t)+1):
        flag = True
        for j in range(i , i + len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp[:i] + t + tmp[i + len(t):]
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])


Measured memory_bytes: 3064
n,w=map(int,input().split())
vw=[list(map(int,input().split())) for i in range(n)]

dp=[-1]*(w+1)
dp[0]=0
for i in range(w+1):
    if dp[i]==-1:continue
    for V,W in vw:
        if i+W<=w:
            dp[i+W]=max(dp[i]+V,dp[i+W])
print(max(dp))


Measured memory_bytes: 5920
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int N,M,i,j,num[50]={};
    long int a[50],b[50],c,d,min[50];
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++) scanf("%ld %ld",&a[i],&b[i]);
    for(i=0;i<M;i++){
        scanf("%ld %ld",&c,&d);
        for(j=0;j<N;j++) min[j]>labs(a[j]-c)+labs(b[j]-d)?(min[j]=labs(a[j]-c)+labs(b[j]-d),num[j]=i):i==0?min[j]=labs(a[j]-c)+labs(b[j]-d):0;
    }
    for(i=0;i<N;i++) printf("%d\n",num[i]+1);
    return 0;
}

Measured memory_bytes: 128
def main():
    input = sys.stdin.readline
    try:
        S = input()
        before = S[0]
        cnt = 0
        for s in S[1:]:
            if s == before:
                cnt += 1
                if s == "0":
                    before = "1"
                else:
                    before = "0"
            else:
                before = s
        print(cnt)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;



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

    int n; string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 0; i+2 < n; i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            ans++;
    }

    cout << ans << endl;

    return 0;
%>

Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,M,r[99]={0},a,b;
int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++)
	{
		scanf("%d%d",&a,&b);
		a--;b--;
		r[a]++;r[b]++;
	}
	for(int i=0;i<N;i++)
		printf("%d\n",r[i]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  vll A(n);
  FOR(i,0,n){
    ci(A[i]);
    m-=A[i];
  }
  SORT(A);
  co(n+m/A[0])
}

Measured memory_bytes: 256
s = input()
s = s.replace("BC", "D")
acnt = 0
mode = 1
ans = 0
"""
AD -> DA
AAD -> ADA -> DAA
ADAD -> DAAD -> DADA -> DDAA

Dを見る→前にあるAは何個？（その分だけ数える）
"""
for i in range(len(s)):
	if s[i] == "A":
		acnt += 1
	elif s[i] == "D":
		ans += acnt
	else:
		acnt = 0
print(ans)

Measured memory_bytes: 9344
import itertools
def main():
    n,m,q=map(int,input().split())
    Se=[]
    for i in range(q):
        Se.append(tuple(map(int,input().split())))
    #print(Se)
    integerset={i for i in range(1,m+1)}
    #print(integerset)
    everyset=itertools.combinations_with_replacement(integerset,n)
    max=0
    for v in everyset:
    #  print(v)
    #   print(len(v))
        sum=0
        for i in range(len(Se)):
            if v[Se[i][1]-1]-v[Se[i][0]-1]==Se[i][2]:
                sum+=Se[i][3]
    # print(sum)
        if sum>max:
            max=sum
    print(max)
if __name__=="__main__":
    main()

Measured memory_bytes: 9212
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    ll ans=0;
    if(K%2==0){
        ans+=(N/K)*(N/K)*(N/K);
        ans+=((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K);
        cout<<ans<<endl;
    }
    else{
        cout<<(N/K)*(N/K)*(N/K)<<endl;
    }
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int h[109];
  cin>>n;
  int cnt=0;
  for(int i=0;i<n;i++)cin>>h[i];
  for(int i=0;i<n;i++){
    bool f=0;
    for(int j=0;j<i;j++){
      if(h[j]>h[i]){
	f=1;
      }
    }
    if(f==0)cnt++;
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll H, W, N;
    std::cin >> W >> H >> N;
    ll x_min = 0;
    ll x_max = W;
    ll y_min = 0;
    ll y_max = H;
    ll x, y, a;
    for (size_t i = 0; i < N; i++) {
        std::cin >> x >> y >> a;
        if (a == 1) {
            x_min = std::max(x_min, x);
        } else if (a == 2) {
            x_max = std::min(x_max, x);
        } else if (a == 3) {
            y_min = std::max(y_min, y);
        } else {
            y_max = std::min(y_max, y);
        }
    }
    if (x_max > x_min && y_max > y_min) {
        std::cout << (x_max - x_min) * (y_max - y_min) << '\n';
    } else {
        std::cout << 0 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
// Enumeration
// 2012/09/19
public class Main{
    Scanner sc=new Scanner(System.in);
 
    int n;
    long m;
    long[] a;
    int[] p;
 
    void run(){
        n=sc.nextInt();
        m=sc.nextLong();
        a=new long[n];
        for(int i=0; i<n; i++){
            a[i]=sc.nextLong();
        }
        p=new int[n];
        for(int i=0; i<n; i++){
            p[i]=sc.nextInt();
        }
        solve();
    }
 
    void solve(){
        long[] f=new long[1<<n];
        for(int s=0; s<1<<n; s++){
            long lcm=1;
            for(int i=0; i<n; i++){
                if((s>>i&1)==1){
                    lcm=lcm(lcm, a[i]);
                }
            }
            if(lcm!=0){
                f[s]=m/lcm;
            }
        }
        f[0]=0;
 
        for(int i=0; i<n; i++){
            for(int s=0; s<1<<n; s++){
                if((s>>i&1)==1){
                    f[s]-=f[s^(1<<i)];
                }
            }
        }
 
        double ans=0;
        for(int s=0; s<1<<n; s++){
            f[s]=abs(f[s]);
            double E=f[s];
            for(int i=0; i<n; i++){
                if((s>>i&1)==1){
                    E*=p[i]/100.0;
                }else{
                    E*=(100-p[i])/100.0;
                }
            }
            ans+=E;
        }
        println(String.format("%f", ans));
    }
 
    long gcd(long a, long b){
        return a==0?b:gcd(b%a, a);
    }
 
    long lcm(long a, long b){
        if(overflow(a/gcd(a, b), b)){
            return 0;
        }else{
            return a/gcd(a, b)*b;
        }
    }
 
    // a*b
    boolean overflow(long a, long b){
        return b!=0&&a>Long.MAX_VALUE/b;
    }
 
    void println(String s){
        System.out.println(s);
    }
 
    public static void main(String[] args){
        new Main().run();
    }
}

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

typedef unsigned long long int ulli;

int main(void)
{
  unsigned N;
  std::cin >> N;
  
  ulli P = 1, Q = 1;
  
  for(unsigned n=0; n<N; ++n)
  {
    unsigned T, A;
    std::cin >> T >> A;
    
    ulli m = std::max(
      (P + T - 1) / T,
      (Q + A - 1) / A
    );
    P = m * T;
    Q = m * A;
  }
  
  std::cout << (P + Q) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll n,m,k;
ll a[N];

main(){
    n=in();
    k=in();
    cout<<(k*2-1<=n?"YES":"NO");
}   

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

bool chk(const string &s) {
  int cnt = 0;
  for (int i = 2; i < s.length() - 1; ++i) cnt += s.at(i) == 'C';
  return cnt == 1;
}

bool chk2(const string &s) {
  if (isupper(s.at(1)) || isupper(s.back())) return false;
  for (int i = 2; i < s.length() - 1; ++i) if (s.at(i) == 'C') continue; else if (isupper(s.at(i))) return false;
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  string s; cin >> s; cout << (s.at(0) == 'A' && chk(s) && chk2(s) ? "AC" : "WA");
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int euglid(int a, int b)
{
	int divdr;
	int res;
	divdr = b;
	while ((res = a % b) != 0) {
		a = b;
		b = res;
	}
	return b;
}

int gcd3(int a, int b, int c) 
{
	return euglid(euglid(a+1, b+1), c+1);
}
	

int main()
{
	int k;
	scanf("%d", &k);
	
	int i, j, l;
	int sum = 0;
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			for (l = 0; l < k; l++) {
				sum += gcd3(i, j, l);
				//printf("[%d %d %d]: %d\n", i, j, l, gcd3(i, j, l));
			}
		}
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>

int main(void)
{
	int a, b;
	while (1) {
		scanf("%d", &a);
		if (a == 0) {
			break;
		}
		b = 0;
		while (a != 0) {
			a /= 5;
			b += a;
		}
		printf("%d\n", b);
	}
	
	return (0);
}

Measured memory_bytes: 596
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], y = tmp[1];

    int yukichi = -1, ichiyou = -1, hideyo = -1;

    foreach (i; 0 .. n+1) {
        foreach (j; 0 .. n-i+1) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                yukichi = i;
                ichiyou = j;
                hideyo = k;
                break;
            }
        }
    }

    writeln(yukichi, " ", ichiyou, " ", hideyo);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (int i = 0; i < N; i++)cin >> A[i];

    map<int, int> m;
    for (int j = 0; j < N; j++) m[A[j]]++;

    vector<int> B;
    for (auto x: m) B.push_back(x.second);
    sort(B.begin(), B.end());

    int ans = accumulate(B.begin(), B.begin() + max(0, (int) B.size() - K), 0);

    cout << ans << endl;

}














































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

using namespace std;

char S[1010];
int s, e, n, w;

int main() {
	scanf("%s", S);
	for(int i = 0; S[i]; i++) {
		if(S[i] == 'W') w = 1;
		if(S[i] == 'E') e = 1;
		if(S[i] == 'S') s = 1;
		if(S[i] == 'N') n = 1;
	}

	if((w ^ e) || (s ^ n)) puts("No");
	else puts("Yes");
	return 0;
}

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

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  
  int x[510][510] = {0};
  int c[510][510] = {0};
  
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    
    x[L][R]++;
    
  }
  
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      c[i][j] = c[i][j-1] + x[i][j];
    }
  }
  

  
  for (int i = 0; i < Q; i++) {
    int ans = 0;
    
    int p, q;
    cin >> p >> q;
    
    for (int j = p; j <= q; j++) {
      ans += c[j][q] - c[j][p-1];
    }
    
    cout << ans << endl;
    
    
  }
}

Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

void dfs(vector<vector<int>> &a, vector<bool> &b, int key){
    for(int i=0; i<a[key].size(); ++i){
        if(b[a[key][i]]){
            b[a[key][i]]=false;
            dfs(a, b, a[key][i]);
        }
    }
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<int>> v(N+1);
	for(int i=0; i<M; ++i){
	    int x, y, z; cin >> x >> y >> z;
	    v[x].push_back(y);
	    v[y].push_back(x);
	}
	vector<bool> c(N+1, true);
	int ans=0;
	for(int i=1; i<=N; ++i){
	    if(c[i]){
	        ++ans;
	        c[i]=false;
	        dfs(v, c, i);
	    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<queue>
using namespace std;
queue<int>q;
int c[100001];
int n,k,cnt,ans;
int main()
{
    c[0]=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        char a;
        cin>>a;
        c[i]=a-48;
        q.push(i);
        if(c[i]==0&&c[i-1]==1)cnt++;
        if(cnt>k)
        {
            cnt--;
            while(c[q.front()]==1)q.pop();
            while(c[q.front()]==0)q.pop();
        }
        //cout<<i-q.front()+1<<endl;
        ans=max(ans,i-q.front()+1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


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

  string n;
  cin >> n;

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

  } else {
cout << "Sunny" << endl;
  }
  
}


Measured memory_bytes: 888
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cctype>
#include <cstring>
#include <utility>
#include <cmath>
#include <string>
#define FOR(i,a,n) for(int i=(a);i<(n);i++)
#define INF (1<<21)
using namespace std;


int main(){
    int a,b,c,d,tmp;
    char num[4],mark[3];
    scanf("%s",num);
    tmp=atoi(num);
    a=tmp/1000;
    b=(tmp-1000*a)/100;
    c=(tmp-1000*a-100*b)/10;
    d=tmp-1000*a-100*b-c*10;
    if(a+b+c+d==7){
        mark[0]='+';
        mark[1]='+';
        mark[2]='+';
    }
    else if(a+b+c-d==7){
        mark[0]='+';
        mark[1]='+';
        mark[2]='-';
    }
    else if(a+b-c+d==7){
        mark[0]='+';
        mark[1]='-';
        mark[2]='+';
    }
    else if(a+b-c-d==7){
        mark[0]='+';
        mark[1]='-';
        mark[2]='-';
    }
    else if(a-b+c+d==7){
        mark[0]='-';
        mark[1]='+';
        mark[2]='+';
    }
    else if(a-b+c-d==7){
        mark[0]='-';
        mark[1]='+';
        mark[2]='-';
    }
    else if(a-b-c+d==7){
        mark[0]='-';
        mark[1]='-';
        mark[2]='+';
    }
    else if(a-b-c-d==7){
        mark[0]='-';
        mark[1]='-';
        mark[2]='-';
    }
    printf("%d%c%d%c%d%c%d=7",a,mark[0],b,mark[1],c,mark[2],d);
    return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map &:to_i
S=$<.map{|s|s.chop.chars}
H.times{|h|
  W.times{|w|
    if S[h][w] != ?#
      S[h][w] = S[[0,h-1].max..h+1].flat_map{|a|a[[0,w-1].max..w+1]}.count ?#
    end
  }
}
puts S.map &:join


Measured memory_bytes: 2172
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
A=[]
S=[]
p=2**N-1
for i in range(N):
  if p>>i&1:
    s=i+1
    tmp=[C[i]]
    while s!=P[i]:
      i=P[i]-1
      tmp.append(C[i])
      p^=1<<i
    A.append(tmp)
    S.append(sum(tmp))
ans=-1*(10**9)-1
for i in range(len(A)):
  a=A[i]
  n=len(a)
  s=S[i]
  for j in range(n):
    t=0
    k=n
    if K>n:
      if s > 0:
        k=K%n
        if k==0:
          k=n
          t=s*(K//n-1)
        else:
          k=K%n
          t=s*(K//n)
    else:
      k=K
    for jj in range(j,k+j):
      if jj>=n:
        jj-=n
      t+=a[jj]
      ans=max(ans,t)
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 74948
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        sort(all(v));
        cout << accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2) << endl;
    }
}

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


int main()
{
  string s ,t;
  cin>>s;
  cin>>t;
  int n = s.length();
  int m = t.length();
  int dp[n+1][m+1];
  for(int i =0;i<=n;i++)
  {dp[i][0]=0;}
  for(int j =0;j<=m;j++)
  {dp[0][j]=0;}
  for(int i =1;i<=n;i++)
  {  for(int j =1;j<=m;j++)
  { if(s[i-1]==t[j-1])
  {dp[i][j]=1+dp[i-1][j-1];}
  else
  {
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
  }

  }

  }
  string ans="";
  int i=n,j=m;
  while(i>0&&j>0)
  {
      if(s[i-1]==t[j-1])
      {ans+=s[i-1];
      i--;j--;}
      else{
          if(dp[i-1][j]>dp[i][j-1])
          {i--;}
          else
          {j--;}
      }
  }
 reverse(ans.begin(),ans.end());
 cout<<ans<<endl;

     return 0;

}

Measured memory_bytes: 38748
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef pair<int, int> R;
int INF = 100000;
int N;
vector<R> blue(0);
vector<R> red(0);

int main(){
    cin >> N;
    int temp1, temp2;
    for (int i = 0; i < N; i++){
        cin >> temp1 >> temp2;
        red.push_back(R(temp1, temp2));
    }
    for (int i = 0; i < N; i++){
        cin >> temp1 >> temp2;
        blue.push_back(R(temp1, temp2));
    }
    sort(red.begin(), red.end()); //昇順にソート
    sort(blue.begin(), blue.end());
    //赤が青よりも内側にあるべき
    int cnt = 0;
    for (int blue_idx = 0; blue_idx < N; ++blue_idx){
        int max_red = - INF, max_idx = 0;
        for (int red_idx = red.size() - 1; red_idx >= 0; --red_idx){
            if (red.at(red_idx).first < blue.at(blue_idx).first && red.at(red_idx).second < blue.at(blue_idx).second){
                if (red.at(red_idx).second > max_red){
                    max_red = red.at(red_idx).second; 
                    max_idx = red_idx;
                }
            }
        }
        if (max_red != -INF){
            ++cnt;
            red.erase(red.begin() + max_idx);
        }
    }
    cout << cnt << endl;
}

        
    
    

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 9e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int k,n;
vp p;

int main(int argc, char const* argv[])
{
    cin >> n >> k;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        p.pb(mp(a,b));
    }
    sort(all(p));

    ll ans = LINF;
    rep(x1,n){
        rep(x2,n){
            vi ylist;
            for(int i=x1; i<=x2; i++) ylist.pb(p[i].se);
            sort(all(ylist));
            int m = (int)ylist.size();
            if(m < k) continue;

            rep(y1,m){
                rep(y2,m){
                    if((y2-y1+1) < k || (y2-y1+1) > k) continue;
                        ll siz = ((ll)p[x2].fi - (ll)p[x1].fi) * ((ll)ylist[y2] - (ll)ylist[y1]);
                        ans = min(ans, siz);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <sstream>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include <vector>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
const int mod = 1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    ll sumx=0,sumy=0;
    int ln;
    ll num;
    for(int i=1;i<=n;i++)
    {
        cin>>num;
        sumx+=num*(i-1)-num*(n-i);
        sumx=sumx%mod;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>num;
        sumy+=num*(i-1)-num*(m-i);
        sumy=sumy%mod;
    }
    cout<<sumx*sumy%mod<<endl;
    return 0;
}


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

//Hoshino search and replace Hoshina
void replace_word(std::string s){
	const std::string find_word("Hoshino");
	//Hoshino search
	std::string::size_type pos = s.find(find_word);
	while(pos != std::string::npos){
		//Hoshino replace Hoshina
		s.replace(pos, find_word.length(), "Hoshina");
		pos = s.find(find_word, pos + find_word.length());
	}
	//output
	std::cout << s << std::endl;
	return;
}

int main(){
	std::string s;
	int num;
	std::cin >> num; //data set
	std::getline(std::cin, s); //read a new line
	for(int i=0; i<num; ++i){
		//read text
		std::getline(std::cin, s);
		//replace
		replace_word(s);
	}
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  sort(all(a));

  ll ans = 0;

  while (a[n - 1] >= n) {
    vll b(n);
    ll sum = 0;
    rep(i, n) {
      if (a[i] >= n) {
        b[i] = a[i] / n;
      }
      sum += b[i];
    }

    ans += sum;

    rep(i, n) {
      a[i] += sum - (n + 1) * b[i];
    }

    sort(all(a));

    if (a[0] >= n) {
      ll cnt = (a[0] - (n - 1));
      ans += n * cnt;
      rep(i, n) {
        a[i] -= cnt;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::string S){
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>

int main()
{
    int a, b, c;
    int num;

    std::cin >> a >> b >> c;
    num = 0;

    for (int i = a; i <= b; i++)
    {
        if ((c % i) == 0)
        {
            num++;
        }
    }

    std::cout << num << std::endl;

    return 0;
}



Measured memory_bytes: 3096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CDivideTheProblems {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> d(N);
        REP(i, N) cin >> d[i];
        sort(d.begin(), d.end());

        int r = N / 2;
        int l = r - 1;
        cout << d[r] - d[l] << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CDivideTheProblems solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024