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

int main(){
  
  int N;
  string S;
  cin >>N>>S;
  
  int ans = 0;
  
  for (int i=0; i<N-2; i++){
    bool sub1 = S[i] == 'A';
    bool sub2 = S[i+1] == 'B';
    bool sub3 = S[i+2] == 'C';
    if(sub1 && sub2 && sub3) ans ++;
  }
  
  cout << ans << endl;
}

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

#define SYNC ios::sync_with_stdio(0);
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 58;
const ll mod = 1000000007;



int main() {
    SYNC
    int a, b;
    cin >> a >> b;
    cout << max(max(a+a-1, a+b), b+b-1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  int x, y;
  cin >> x >> y;

  int ans = 0;
  ans += max(4 - x, 0);
  ans += max(4 - y, 0);
  if (x == 1 && y == 1) ans += 4;
  ans *= 100000;

  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

const int MX = 100005;
int ans[MX];
vector<pair<int,int>> gr[MX];

void dfs(int v, int u, int c){
  int ne=1;
  rep(i,gr[v].size()){
    pair<int,int> p = gr[v][i];
    if(p.first==u) continue;
    if(ne==c) ne++;
    ans[p.second]=ne;
    dfs(p.first,v,ne);
    ne++;
  }
}

int main()
{
  int n,a,b;
  cin >> n;
  rep(i,n-1){
    cin >> a >> b;
    gr[a].push_back(make_pair(b,i));
    gr[b].push_back(make_pair(a,i));
  }

  int col=0;
  rep(i,1,n+1) col=max(col,(int)gr[i].size());
  dfs(1,0,0);

  cout << col << "\n";
  rep(i,n-1) cout << ans[i] << "\n";
}


Measured memory_bytes: 9344
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9 + 7;
const ll mod = 998244353;

string S;
ll N, M, ans, A[100005]; pair<ll, ll> P[100005];



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

	FOR(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	FOR(i, 0, M) {
		cin >> P[i].second >> P[i].first;
	}
	sort(P, P + M);
	reverse(P, P + M);

	ll memo = 0;
	for (ll i = 0; i < N; i++) {//Aを見る
		if (memo == M)break;
		if (P[memo].first > A[i]) {
			A[i] = P[memo].first;
			P[memo].second--;
			if (P[memo].second == 0)memo++;
		}
		}
	FOR(i, 0, N)ans += A[i];
	cout << ans << endl;

	

	return 0;
}

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

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

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n, m;
    string s;
    cin >> n >> m >> s;

    vt<int> ans;
    for (int i = n; i > 0;) {
        int t = max(0, i - m);
        for (; t < i && s[t] == '1'; t++);
        if (t == i) return cout << -1, 0;
        ans.push_back(i - t);
        i = t;
    }

    reverse(all(ans));
    for (int i : ans) cout << i << ' ';
}


Measured memory_bytes: 4016
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //n????????????k??????
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}


int main(){
	int n;
	cin>>n;
	vector<int> s(n);
	rep(i,n){
		cin>>s[i];
	}
	int q;
	cin>>q;
	vector<int> t(q);
	rep(i,q){
		cin>>t[i];
	}
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	int ans=0;
	int ss=0;
	int T;
	rep(i,q){
		T=t[i];
		while(s[ss]<=T){
			if(s[ss]==T){
				ans++;
				ss++;
				break;
			}
			ss++;
			if(ss>=n){
				cout<<ans<<endl;
				return 0;
			}
		}
		ss--;
		if(ss>=n){
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main(void){
	int n,i,j,tmp,ans=0;

	scanf("%d",&n);

	int a[n+1];

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	a[n]=0;

	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(a[j-1]<a[j]){
				tmp=a[j-1];
				a[j-1]=a[j];
				a[j]=tmp;
			}
		}
	}

	for(i=0;i<n;i+=2){
		ans+=a[i]-a[i+1];
	}

	printf("%d",ans);

	return 0;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t cnt=0;
    int64_t n,p,k;
    cin>>n;
    p=n;
    for(int64_t i=1;i<=sqrt(n);i++){
        if(i==1){
            cnt++;
            continue;
        }
       while(n%i==0){
           n=n/i;
           if(n%i==1)cnt++;
       }
        n=p;
    }
    // cout<<cnt<<" "<<sqrt(n)<<endl;
    for(int64_t i=1;i<=sqrt(p-1);i++){
       if(i==1&&(p-1)!=1){
           cnt++;
           continue;
       }
       if((p-1)%i==0&&(p-1)!=1){
           k=(p-1)/i;
           if(i==k){
               cnt++;
           }else cnt+=2;
       }
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double calc(double *x,double *y,int i,int j){
 // printf("%lf %lf %lf %lf\n",x[i],y[i],x[j],y[j]);
double dx=(x[i]-x[j]);
  double dy=(y[i]-y[j]);
  return sqrt(dx*dx+dy*dy);
}
int main(void){
  int n;
 scanf("%d",&n);
  double x[n],y[n];
  for(int i=0;i<n;i++){
	scanf("%lf%lf",&x[i],&y[i]);
    	//printf("%lf %lf\n",x[i],y[i]);
  }
  
  double l=0;
  for(int i=0;i<n-1;i++){
    	for(int j=i+1;j<n;j++){
         
          //printf("%lf\n",calc(x,y,i,j));
          l+=calc(x,y,i,j);
        }
  }

  printf("%.10lf",2*l/n);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int a;
	a = 0; 
	int d = s.size();
	for(int i=0;i<d;i++){
		for(int j=i+1;j<d;j++){
			if(s[i]==s[j]){
				a++;
			}
		}
	}
	if(a==2){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long a, b, q;

std::set<long> s, t;

long solve(long x){
	long s1, s2, t1, t2;
	auto its = s.lower_bound(x);
	s2 = *its;
	s1 = *(--its);
	auto itt = t.lower_bound(x);
	t2 = *itt;
	t1 = *(--itt);
	//printf("  %ld %ld %ld %ld\n", s1, s2, t1, t2);
	long ret = LINF;
	ret = std::min(ret, std::max(s2, t2) - x);
	//printf("  (%ld ", ret);
	ret = std::min(ret, x - std::min(s1, t1));
	//printf("%ld ", ret);
	ret = std::min(ret, std::min(s2-x, x-t1) + s2-t1);
	//printf("%ld ", ret);
	ret = std::min(ret, std::min(t2-x, x-s1) + t2-s1);
	//printf("%ld)\n", ret);
	return ret;
}
	

int main(){
	scanf("%ld %ld %ld", &a, &b, &q);
	for(int i = 0; i < a; i++){
		long k;
		scanf("%ld", &k);
		s.insert(k);
	}
	for(int i = 0; i < b; i++){
		long k;
		scanf("%ld", &k);
		t.insert(k);
	}
	s.insert(-LINF);
	s.insert(LINF);
	t.insert(-LINF);
	t.insert(LINF);
	for(int i = 0; i < q; i++){
		long k;
		scanf("%ld", &k);
		printf("%ld\n", solve(k));
	}
	return 0;
}


Measured memory_bytes: 11008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        int hyaku = n / 100;
        int juu = n / 10 % 10;
        int iti = n % 10;
        System.out.println(hyaku + juu + iti);
    }
}

Measured memory_bytes: 21716
// AOJ_C++.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <iomanip>
#include <string>

void Output(int n, int* result) {
	for (int i = 0; i < n; ++i) {
		std::cout << result[i] << std::endl;
	}
}

int main()
{
	int result[1000];
	for (int i = 0; true; ++i) {
		std::string op;
		int a, b;
		std::cin >> a >> op >> b;
		if (op == "+") {
			result[i] = a + b;
		}
		else if (op == "-") {
			result[i] = a - b;
		}
		else if (op == "*") {
			result[i] = a * b;
		}
		else if (op == "/") {
			result[i] = a / b;
		}
		else if (op == "?") {
			Output(i, result);
			break;
		}
	}
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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 (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros


ll M = 1000000;
vector<ll> spf(M + 1);

void init() {
    for (int i = 0; i <= M; i++) {
        spf[i] = i;
    }
    for (int i = 2; i * i <= M; i++) {
        if (spf[i] != i) continue;
        for (int j = i * i; j <= M; j += i) {
            spf[j] = i;
        }
    }
}

set<ll> pf(ll n){
    set<ll> res;
    
    while(n!=1){
        res.insert(spf[n]);
        n /= spf[n];
    }

    return res;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    if(*max_element(A.begin(), A.end()) == 1){
        cout << "pairwise coprime";
        return 0;
    }

    init();

    vector<ll> c(M + 1);
    
    rep(i,N){
        auto s = pf(A[i]);
        for(auto x : s){
            c[x]++;
        }
    }

    string ans;

    ll max_cnt = *max_element(c.begin(), c.end());
    if (max_cnt == 1) {
        ans = "pairwise coprime";
    }else if(max_cnt == N){
        ans = "not coprime";
    }else{
        ans = "setwise coprime";
    }

    cout << ans << endl;
}


Measured memory_bytes: 26692
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n,m,u,v;
		cin>>n>>m;
		vector<int> gr[n];
		ll h[n];
		FOR(i,0,n)
		cin>>h[i];
		FOR(i,0,m)
		{
			cin>>u>>v;
			gr[u-1].pb(v-1);
			gr[v-1].pb(u-1);
		}
		int ans=0;
		FOR(i,0,n)
		{
			ll m=h[i]-1;
			FOR(j,0,gr[i].size())
			{
				m=max(m,h[gr[i][j]]);
			}
			if(m<h[i])ans++;
		}
		cout<<ans;
	}
	return 0;
}


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

int partition(vector<char> &c, int l, int r, bool order) {
  int x = c[r];
  int i = l - 1;
  for (int j = l; j < r; ++j) {
    if (order) {
      if (c[j] <= x) {
        i++;
        swap(c[i], c[j]);
      } 
    } else {
      if (c[j] >= x) {
        i++;
        swap(c[i], c[j]);
      }
    }
  }
  swap(c[i + 1], c[r]);
  return i + 1;
}

void quickSort(vector<char> &c, int l, int r, bool order) {
  if (l < r) {
    int m = partition(c, l, r, order);
    quickSort(c, l, m - 1, order);
    quickSort(c, m + 1, r, order);
  }
  return;
}

string sortString(string s, bool order) {
  int n = s.size();
  vector<char> c(n);
  for (int i = 0; i < n; ++i) c[i] = s[i];
  quickSort(c, 0, n - 1, order);
  string res;
  for (int i = 0; i < n; ++i) res += c[i];
  return res;
}

int main() {
  string s, t; cin >> s >> t;
  s = sortString(s, true);
  t = sortString(t, false);
  if (s.compare(t) < 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e3+15;
const ll inf = 1e18+7;

ll fun(string s){
  ll cont=0,ans =0;
  if(s[0]=='R') cont=1;
  if(sz(s)==1) {return cont;}
  f(i,1,sz(s)){
    if(s[i]!=s[i-1] && s[i]=='R') cont = 1;
    if(s[i]==s[i-1] && s[i]=='R') cont++;
    if((s[i]=='S' && s[i-1]=='R') || i==(sz(s)-1)) {ans = max(ans,cont);cont=0;}
  }
  return ans;
}



int main() {
  fastio;
  string s;
  cin>>s;
  cout<<fun(s)<<"\n";
 return 0;
}
 

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    string a , b , c ;
    cin >> a >> b >> c ;

    cout << "A" << b[0] << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const ll MOD=1e9+7;
const int INF=1<<30;


using namespace std;

ll dat[25][25];
ll res[25][2100005];
int mul[25];
int in;

void pre(){
	repp(i,0,21,1){
		repp(j,0,2098000,1){
			res[i][j]=-1;
		}
	}
	mul[0]=1;
	rep(i,22,1){
		mul[i]=mul[i-1]*2;
	}
}


ll find(int pos,int mask){
	if(pos==in&&mask==0)return res[pos][mask]=1;
	if(res[pos][mask]!=-1)return res[pos][mask];
	ll temp=0;
	repp(i,0,in-1,1){
		if(dat[pos][i]==1&&mask&mul[i]){
			temp+=find(pos+1,mask-mul[i]);
			temp%=MOD;	
		}
	}
	return res[pos][mask]=temp%MOD;
}

int main(){
	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	pre();
	cin>>in;
	repp(i,0,in-1,1){
		repp(j,0,in-1,1){
			cin>>dat[i][j];
		}
	}
	cout<<find(0,mul[in]-1)<<endl;
	return 0;
}



Measured memory_bytes: 362880
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	int a[100000];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	int x = a[0];
	int p = 0;
	for (int i = 0; i < N; i++) {
		p++;
		if (x != a[i]) {
			if (p - 1 < x)
				ans += p - 1;
			else if (p-1 > x)
				ans += p-1 - x;
			x = a[i];
			p = 1;
		}
	
	}
	if (p < x)
		ans += p;
	else if (p > x)
		ans += p - x;
	cout << ans;
	return 0;
}

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

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

int vis[10]; 
bool ok(int n) {
	while(n) {
		int d = n % 10; n /= 10;
		if(vis[d]) return 0;
	} return 1;
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n, k; cin >> n >> k;
	for(int i = 0; i < k; i++) {
		int d; cin >> d; vis[d] = 1;
	}
	for(int i = n; ; ++i) if(ok(i)) return cout << i << endl, 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size()<=k){
        cout << s << endl;
    }else{
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  double D, T, S;
  cin >> D >> T >> S;
  if(D/S <= T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    unordered_set<string> K;
    string s;
    REP(i, N) {
        cin >> s;
        K.insert(s);
    }
    cout << K.size() << endl;

    return 0;
}

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

from itertools import permutations

k = int(input())
queens_input = []
for _ in range(k):
    r, c = map(int, input().split())
    queens_input.append([r, c])
# print(k, queens_input)


def create_square(queens):
    square = [['.' for col in range(8)] for row in range(8)]
    for r, c in queens:
        square[r][c] = 'Q'
    return square


def print_square(square):
    for row in range(8):
        for col in range(8):
            print(square[row][col], end='')
        print('')


def includes(queens, queens_input):
    for q in queens_input:
        if q not in queens:
            return False
    return True


def calc_direction(queen):
    row, col = queen
    v, h, d_r, d_l = [], [], [[row, col]], [[row, col]]
    for i in range(8):
        v.append([i, col])
        h.append([row, i])
    for i in range(1, 8):
        if row - i >= 0 and col + i < 8:
            d_r.append([row - i, col + i])
        if row + i < 8 and col - i >= 0:
            d_r.append([row + i, col - i])
        if row - i >= 0 and col - i >= 0:
            d_l.append([row - i, col - i])
        if row + i < 8 and col + i < 8:
            d_l.append([row + i, col + i])
    return v, h, d_r, d_l


def count(direction, queens):
    res = 0
    for queen in queens:
        res += direction.count(queen)
    return res


def is_valid(queens):
    for queen in queens:
        v, h, d_r, d_l = calc_direction(queen)
        v_c, h_c = count(v, queens), count(h, queens)
        d_r_c, d_l_c = count(d_r, queens), count(d_l, queens)
        if not (v_c == 1 and h_c == 1 and d_r_c == 1 and d_l_c == 1):
            return False
    return True


perms = list(map(list, permutations(list(range(8)), 8)))
for perm in perms:
    queens = []
    for row in range(8):
        queens.append([row, perm[row]])
    if includes(queens, queens_input):
        if is_valid(queens):
            # print(f"queens = {queens}")
            square = create_square(queens)
            print_square(square)
            break



Measured memory_bytes: 12376
# include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[103];
    int n, sum = 0;
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(sum % 10)
        return 0*printf("%d\n",sum);
    sort(a, a+n);
    for(int i=0; i<n; ++i)
    {
        if(a[i]%10==0) continue;
        sum -= a[i];
        if(sum % 10)
            return 0*printf("%d\n",sum);
    }
    puts("0");
    return 0;
}


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

using namespace std;

int gcd( int, int );

int main()
{
	char str[21];

	scanf("%s", str );
	for ( int i = strlen( str ) - 1; 0 <= i; i-- )
	{
		putchar( str[i] );
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long tenth[100005];
vector<long long>question;
long long dp[13][100005];

long long f(int r,int curr){
	if(curr>=question.size()) return (r==0);
	long long&ret = dp[r][curr];
	if(~ret) return ret;
	ret = 0;
	for(int i=0; i<10; i++){
		int x = question[curr]*i;
		x%=13;
		ret+=f((13+r-x)%13,curr+1);
		ret%=mod;
	}
	return ret;
}
int main(){
	memset(dp,-1,sizeof(dp));
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	int r = 0;
	tenth[0] = 1;
	for(int i=0; s[i]; i++){
		if(i==0){
			if(s[i]=='?') continue;
			r+=(int)(s[i]-'0');
		}
		else{
			tenth[i] = 10*tenth[i-1];
			tenth[i]%=13;
			if(s[i]=='?') continue;
			r+=tenth[i]*(int)(s[i]-'0');
			r%=13;
		}
	}

	r = (18-r)%13;
	for(int i=0; s[i]; i++){
		if(s[i]=='?') question.push_back(tenth[i]);
	}
	cout<<f(r,0);
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

ll to(ll target, ll now_sum, ll n) {

    ll next_sum = now_sum + n;
    if (target == -1 && next_sum <= -1) return n;
    if (target == 1 && next_sum >= 1) return n;
    ll ab = abs(now_sum - target);

    if (target == -1) return -ab;
    return ab;

}

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

    vector<ll> numbers(n);
    rep(i, n)cin >> numbers[i];

    auto func = [&](int target) {
        ll now_sum = 0;

        vector<ll> changed = vector<ll>(n);
        for (ll i = 0; i < n; i++) {
            ll t = to(target, now_sum, numbers[i]);
            changed[i] = t;
            now_sum += t;
            target = -target;
        }

        ll now = 0;
        for (ll i = 0; i < n; i++) {
            now += abs(numbers[i] - changed[i]);
        }
        return now;
    };
    // 最初をマイナス
    ll ans = min(func(1), func(-1));

    cout << ans << endl;

}



Measured memory_bytes: 1804
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 27, 2018, 12:08 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 100
#define INF 100000
#define min(X, Y) (((X) < (Y)) ? (X) : (Y))
/*
 * 
 */

int p[MAX+1], m[MAX+1][MAX+1];

void matrixChainOrder(int size);

int main(int argc, char** argv) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d %d", &p[i-1], &p[i]);
    
    matrixChainOrder(n);
    
//    int j, q;
//    for (int i = 1; i <= n; i++) m[i][i] = 0;
//    
//    for (int l = 2; l <= n; l++)
//    {
//        for (int i = 1; i <= n-l+1; i++)
//        {
//            j = i+l-1;
//            m[i][j] = INF;
//            for (int k = i; k <= j-1; k++)
//            {
//                q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
//                m[i][j] = min(m[i][j], q);
//            }
//        }
//    }
    
    printf("%d\n", m[1][n]);
    
    return (EXIT_SUCCESS);
}

void matrixChainOrder(int size)
{
    int j, q;
    for (int i = 1; i <= size; i++) m[i][i] = 0;
    
    for (int l = 2; l <= size; l++)
    {
        for (int i = 1; i <= size-l+1; i++)
        {
            j = i+l-1;
            m[i][j] = INF;
            for (int k = i; k <= j-1; k++)
            {
                q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                m[i][j] = min(m[i][j], q);
            }
        }
    }
}



Measured memory_bytes: 2088
K,A,B = map(int,input().split())
if K <= A:
    print(K+1)
elif K == A+1:
    print(max(B,K+1))
elif (K-(A+1))%2 == 1:
    first = max(B,A+2)
    second = max(2,B-A)
    third = second*int((K-A-2)/2)
    print(first+third+1)
else:
    first = max(B,A+2)
    second = max(2,B-A)
    third = second*int((K-A-1)/2)
    print(first+third)
    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		long r = 0;
		for (int i=1;i<n;i++) {
			if (a[i] < a[i - 1]) {
				r += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
		System.out.println(r);
	}
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define ALL(x) (x).begin(),(x).end() 

#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 

#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, b[100], dp[100];
    cin >> n;
    REP(i, n-1) cin >> b[i];
    int ans = b[n-2];
    REP(i, n-2) ans += min(b[i], b[i+1]);
    ans += b[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{ 
  int N,K;
  cin>>N>>K;
  int ANS = 0;
  
  for (int i = 1; i <= N; i++)
  {
    int b = i;
    ANS += (N/b)*max(b-K,0LL) + max(0LL,N%b-K+1) - (int)(K == 0);
    // DEBUG(ANS);
  }
  cout<<ANS<<endl;
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
status = {str(i): 0 for i in range(1, N+1)}
error = 0
for _ in range(M):
  q, r = input().split()
  if r == "AC": 
    if status[q] <= 0: 
    	error += -(status[q])
    status[q] = 1
  elif r =="WA":
    if status[q] <= 0: 
      status[q] -= 1

print(sum([i for i in status.values() if i > 0]), error)


Measured memory_bytes: 17132
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		System.out.printf("%d %d %f%n",a/b,a%b,(double)a/(double)b);
	}

}



Measured memory_bytes: 26336
n = int(input())
as_ =  list(map(int, input().split()))

l = [0]*n
m = [0]*n
r = [0]*n
for i in range(n):
  l[i] = as_[i]
  m[i] = as_[n+i]
  r[i] = (-1)*as_[2*n+i]

import heapq
heapq.heapify(l)
heapq.heapify(r)

l_maxs = [0]*(n+1)
r_mins = [0]*(n+1)

sl = sum(l)
sr = sum(r)

for i in range(n+1):
  if i != 0:
    j = i-1
    heapq.heappush(l, m[j])
    a = heapq.heappop(l)
    sl += m[j] -a
    
    k = -i
    heapq.heappush(r, m[k]*(-1))
    b = heapq.heappop(r)
    sr += m[k]*(-1) - b
    
  l_maxs[i] = sl
  r_mins[i] = sr

#print(l_maxs)
#print(r_mins)

print(max([l_maxs[i] + r_mins[n-i] for i in range(n+1)]))

Measured memory_bytes: 37084
N = int(input())
AC, WA, TLE, RE = 0, 0, 0, 0
for _ in range(N):
  S = input()
  if S == 'AC':
    AC+=1
  elif S == 'WA':
    WA+=1
  elif S == 'TLE':
    TLE+=1
  elif S == 'RE':
    RE+=1

print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')

Measured memory_bytes: 9204
#include <stdio.h>
#define cns (int)(1e9+7)
 
int fn(int a,int b){
	if(b<a){
		return 0;
	}
	else{
		return fn(a,b/a)+b/a;
	}
}
 
int main(){
	int N,i,j;
	long long int num=1;
	scanf("%d",&N);
	int p[N+1];
	for(i=0;i<=N;i++){
		p[i]=i;
	}
	for(i=2;i<=N;i++){
		if(p[i]!=0){
			for(j=1;i*j<=N;j++){
				p[i*j]=0;
			}
			num=(num*(fn(i,N)+1))%cns;
		}
	}
	printf("%d\n", num);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=100010;
bool w[N];
int fa[N],pa[N];
vector <int> q[N];
long long a[N],b[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct Dat {
    int x,y,z;
    inline bool operator < (const Dat &A) const {return z<A.z;}
} g[N];
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
inline int get(int x) {return pa[x]==x?x:pa[x]=get(pa[x]);}
int main() {
    int n,m,ans;
    cin>>n>>m,ans=m;
    for(int i=1;i<=n;i++) a[i]=b[i]=gi(),fa[i]=pa[i]=i;
    for(int i=1;i<=m;i++) g[i].x=gi(),g[i].y=gi(),g[i].z=gi();
    sort(g+1,g+1+m);
    for(int i=1;i<=m;i++) {
	int x=find(g[i].x),y=find(g[i].y);
	if(x!=y) {
	    if(q[x].size()<q[y].size()) swap(x,y);
	    ++w[i],q[x].push_back(i);
	    fa[y]=x,a[x]+=a[y];
	    for(auto j:q[y]) q[x].push_back(j);
	    if(a[x]>=g[i].z) {
		for(auto j:q[x]) {
		    int X=get(g[j].x),Y=get(g[j].y);
		    pa[Y]=X,b[X]+=b[Y],--ans;
		}
		q[x].clear();
	    }
	}
    }
    for(int i=1;i<=m;i++)
	if(!w[i]&&b[get(g[i].x)]>=g[i].z) --ans;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9856
#include<iostream>
  #include<fstream>
  #include<vector>
  #include<initializer_list>
  #include<string>
  using namespace std;
    int main(){
	int N;
      int M;
scanf ("%d""%d",&N,&M);

if (N == M)
{printf("Yes\n");}

else {printf ("No\n");}



  }

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e12
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    int n,m;
    int goals[maxn];
    vector<int> dis;
    
    cin >> n>>m;
    
    rep(i,m){
        cin >> goals[i];
    }
    
    sort(goals,goals+m);
    
    for(int i=0;i+1<m;i++){
        dis.push_back(goals[i+1]-goals[i]);
    }
    
    sort(all(dis));
    
    ll ans=0;
    
    if(n>=m){
        cout << 0<<endl;
    }else{
        for(int i=0;i<m-n;i++){
            ans+=dis[i];
        }
        cout << ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=5e5+5,mo=998244353;
int n,m,ans,nn;
int jc[N],ny[N],_n[N],_m[N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
int main(){
	cin>>n>>m;nn=max(n,m);
	jc[0]=_n[0]=_m[0]=1;
	fo(i,1,nn)jc[i]=(ll)jc[i-1]*i%mo,_n[i]=(ll)_n[i-1]*(n+1)%mo,_m[i]=(ll)_m[i-1]*(m+1)%mo;
	ny[nn]=ksm(jc[nn],mo-2);
	fd(i,0,nn-1)ny[i]=(ll)ny[i+1]*(i+1)%mo;
	fo(i,0,min(n,m))
		ans=((ll)(i&1?-1:1)*jc[n]*jc[m]%mo*ny[n-i]%mo*ny[m-i]%mo*ny[i]%mo*_n[m-i]%mo*_m[n-i]+ans)%mo;
	cout<<(ans+mo)%mo;
}

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

int main() {
  int N, M, i;
  cin >> N ;
  
  vector<int> a(N);

  for (i = 0; i < N; i++)
    cin >> a.at(i);
  
  int count = 1, key = 0;
  
  while (a.at(key) != 2) {
    int temp = a.at(key);
    if (temp == 0) {
      count = -1;
      break;
    }
    count++;
    a.at(key) = 0;
    key = temp - 1;
  }
  
  cout << count << endl;
  
}

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

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> ai(n), fi(n);
  for(int i=0; i<n; ++i) cin >> ai[i];
  for(int i=0; i<n; ++i) cin >> fi[i];
  sort(ai.begin(),ai.end());
  sort(fi.begin(),fi.end());
  reverse(fi.begin(),fi.end());
  /*
  for(int i=0; i<n; ++i) cout << ai[i] << " ";
  cout << endl;
  for(int i=0; i<n; ++i) cout << fi[i] << " ";
  cout << endl;
  */
  ll l=-1, r= (ll)ai[n-1]*(ll)fi[0];
  while(l<r-1){
    ll mid = (l+r)/2;
    ll cnt = 0;
    for(int i=0; i<n; ++i){
      ll tar = mid/(ll)fi[i];
      if(tar < ai[i]) cnt += (ll)ai[i] - tar;
    }
    //cout << l << " " << r << " " << mid << " " << cnt << endl;
    if(cnt > k) l = mid;
    else r = mid;
  }
  cout << r << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  scanf("%d", &n);
  vi a(n), b(n), c(n), d(n);
  vector<pii> red(n), blue(n);
  rep (i, n) {
    scanf("%d %d", &(red[i].first), &(red[i].second));
  }
  rep (i, n) {
    scanf("%d %d", &(blue[i].first), &(blue[i].second));
  }
  vvi ab(n*2, vi(3, 0));
  rep (i, n) {
    ab[i][0] = red[i].first;
    ab[i][1] = red[i].second;
    ab[i][2] = 0;
  }
  rep (i, n) {
    ab[n+i][0] = blue[i].first;
    ab[n+i][1] = blue[i].second;
    ab[n+i][2] = 1;
  }
  sort(all(ab));

  set<vi> svred;
  int ans = 0;
  rep (i, 2*n) {
    if (ab[i][2] == 0) {
      svred.insert((vi){ab[i][1], ab[i][0]});
      continue;
    }
    auto lb = svred.lower_bound((vi){ab[i][1], 0});
    if (lb == svred.begin()) {
      continue;
    }
    lb--;
    svred.erase(lb);
    ans += 1;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(){
  int N, T;
  cin >> N >> T;
  int c[110];
  int t[110];
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    cin >> t[i];
  }

  int min_c = 1001;
  for (int i = 0; i < N; i++) {
    if (t[i] <= T && c[i] < min_c) min_c = c[i];
    //cout << t[i] << c[i] << endl;
  }

  if (min_c == 1001) cout << "TLE" << endl;
  else cout << min_c << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int n, a, b;

   scanf("%d", &n);

   if(n==1) printf("Hello World\n");

   if(n==2){
     scanf("%d%d", &a, &b);
     printf("%d\n", a+b);
     }

   return 0;
}

Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  int cur = 1;
  forn(i,n){
    int a;
    cin >> a;
    if (a == cur) cur++;
  }
  if (cur == 1) cout << -1;
  else cout << n - cur + 1;
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

aattccooddeerrbreeggiunlnaerrccoonntteesstt
aattccooddeerrbreeggiunlnaerrccoonntteesstt
*/

Measured memory_bytes: 3668
var
  a:array[1..10000]of longint;
  i,j,k,n,m,p,q,w:longint;
  s:string;
procedure qsort(l,r:longint);
var
  i,j,mid,p:longint;
begin
  i:=l;j:=r;
  mid:=a[(l+r) div 2];
  repeat
    while a[i]<mid do inc(i);
    while a[j]>mid do dec(j);
    if i<=j then
      begin
        p:=a[i];a[i]:=a[j];a[j]:=p;
        inc(i);
        dec(j);
      end;
  until i>j;
  if l<j then qsort(l,j);
  if i<r then qsort(i,r);
end;
begin
  readln(k);
  readln(n,m);
  for i:=1 to k do read(a[i]);
  qsort(1,k);
  p:=0;
  q:=0;
  w:=0;
  for i:=1 to k do
  begin
    if a[i]>n then break;
    inc(p);
  end;
  for j:=i to k do
  begin
    if a[j]>m then break;
    inc(q);
  end;
  for i:=j to k do
  begin
    if a[i]>m then inc(w);
  end;
  if p>q then p:=q;
  if p>w then p:=w;
  writeln(p);
end.


Measured memory_bytes: 128
from itertools import accumulate

n, k = list(map(int, input().split()))
aaa = list(map(int, input().split()))
bk = '{:041b}'.format(k)
bbb = list(map('{:041b}'.format, aaa))
ks = 0
best = []
thr = []
base = []
for i, c in enumerate(bk):
    d = 1 << (40 - i)
    c1 = list(b[i] for b in bbb).count('1')
    d0, d1 = c1 * d, (n - c1) * d
    best.append(max(d0, d1))
    thr.append(d0 if c == '0' else d1)
    base.append(d0)

best.reverse()
best = list(accumulate(best))
best.reverse()
best.append(0)
thr = list(accumulate(thr))

ans = thr[-1]
for i, c in enumerate(bk):
    if c == '0':
        continue
    ans = max(ans, thr[i - 1] + base[i] + best[i + 1])

print(ans)


Measured memory_bytes: 18700
loop do
  l = gets.to_i
  break if l.zero?
  sum=0
  1.upto(12) do |i|
    m,n = gets.split.map(&:to_i)
    sum+=m-n
    if sum>=l
      puts i
      (12-i).times{gets}
      break
    end
    puts :NA if i==12
  end
end

Measured memory_bytes: 2792
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,maxn=3e5+5;

int n;
char s[maxn];
int sum[maxn];

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)sum[i] = sum[i-1] + (s[i] == 'E');
	int ans=inf;
	for(int i=1;i<=n;i++){
		int r = i - 1 - sum[i-1] + (sum[n]-sum[i]);
		ans = min(ans, r);
	}
	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

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

  vector<int> memo;
  vector<int> usable;

  int use_six = 6;
  int use_nine = 9;

  usable.push_back(1);
  memo.push_back(1);

  int ming = 99999;

  for (int i = 2; i <= n; i++){
    if (i == use_six){
      memo.push_back(1);
      usable.push_back(i);
      use_six *= 6;
    } else if(i == use_nine){
      memo.push_back(1);
      usable.push_back(i);
      use_nine *= 9;
    } else{
      ming = 9999;
      for(int x: usable){
        ming = min(memo[x-1] + memo[i - x - 1], ming);
      }
      memo.push_back(ming);
    }
    //cout << memo[i-1] << endl;

  }

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


  return 0;

}


Measured memory_bytes: 892
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int a[11];
bool flg[11];
int num[] = {0,2,5,5,4,5,6,3,7,6};
string dp[101010];

string smax(string a, string b){
    if(a == "#")return b;
    if((int)a.size() < (int)b.size())return b;
    if((int)a.size() > (int)b.size())return a;
    if(a < b)return b;
    else return a;
}

int main(){
    INIT;
    cin >> n >> m;
    REP(i, m)cin >> a[i];
    REP(i, m)flg[a[i]] = true;
    REP(i, 101010)dp[i] = "#";
    dp[0] = "";
    REP(i, n + 1){
        if(dp[i] == "#")continue;
        //cout << i << ":" <<dp[i] << endl;
        for(int j = 1;j <= 9;j++){
            if(flg[j]){
                string t = dp[i] + char('0' + j);
                dp[i + num[j]] = smax(dp[i + num[j]], t);
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 49792