akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)

int main(){
    ll x; cin >> x;
    ll cnt = 0;
    ll y = 100.0;
    while(x > y){
        y += y/(100);
        cnt ++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3612
N, K = map(int, input().split())

def solve():
    if K>(N-1)*(N-2)//2:
        print(-1)
        return
    M = (N-1)*N//2-K
    print(M)
    for i in range(1,N):
        print(i,N)
    edge = N-1
    if edge==M:
        return
    for i in range(1,N-1):
        for j in range(i+1,N):
            print(i,j)
            edge += 1
            if edge==M:
                return
solve()

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;
const int INF = 1e9;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector<int> dp(n,INF);;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (i-1 >= 0) dp[i] = min(dp[i], abs(h[i]-h[i-1]) + dp[i-1]);
        if (i-2 >= 0) dp[i] = min(dp[i], abs(h[i]-h[i-2]) + dp[i-2]);
    }

    out(dp[n-1]);
    
    return 0;
}


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

int main(){
int N,M;
  cin>>N>>M;
  vector<int>a(N), b(N), c(M), d(M);
  for(int i=0; i<N; i++){ cin>>a[i]>>b[i]; }
  for(int i=0; i<M; i++){ cin>>c[i]>>d[i]; }
 
  for(int i=0; i<N; i++){
      int checkpoint=0;
      int min_dist=abs(a[i]-c[0])+abs(b[i]-d[0]); // j=0を基準とする
     for(int j=0; j<M; j++){
       int ma=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(min_dist>ma){
        min_dist=ma;
        checkpoint=j;  } // j=0よりも近いマンハッタン距離がある場合はそのjに書き換わる
     } // マンハッタン距離が最小の時のチェックポイントの座標jが出る
    cout<<checkpoint+1<<endl;
  }
  
}


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  int ind;
  long long out = 0, tmp = 0;
  for(int i = 0; i < k; i++){
    tmp += p.at(i);
  }
  out = tmp;
  long long sum;
  for(int j = k; j < n; j++){
    sum = tmp - p.at(j - k) + p.at(j);
    if(sum > out) out = sum;
    tmp = sum;
  }
  double e = (double(out) + k) / 2;
  cout << setprecision(10) << e;
}


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

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const int INF = (int) 1e9 + 9;
//vi ing(100005);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi ing(n);
    rep(i, 0, n) cin >> ing[i];
    sort(all(ing));
//    for (int x : ing) cout << x << '\n';
    double ans = (ing[0]+ing[1])/(double)2;
//    cout << ans << '\n';
    rep(i, 2, n) ans = (ans + (double)ing[i])/(double)2;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(n == 3 || n == 5 || n == 7) cout << "YES" << endl;
    else dunk("NO");
    
}

   

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

int main(void)
{
    int a,b,c;
    cin>>a>>b;
    if((a%2==1)&&(b%2==1))
    {
        cout <<"Yes"<<endl;
    }
    else
    {
        cout <<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 18 21:50:39 2018
ABC106D
@author: maezawa
"""

n, m, qn = list(map(int, input().split()))

lr = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    li, ri = list(map(int, input().split()))
    lr[li][ri] += 1
    
for i in range(n+1):
    for j in range(n):
        lr[i][j+1] += lr[i][j]
for i in range(n+1):
    for j in range(n):
        lr[j+1][i] += lr[j][i]

for _ in range(qn):
    pi, qi = list(map(int, input().split()))
    ans = lr[qi][qi] - lr[qi][pi-1] - lr[pi-1][qi] +lr[pi-1][pi-1]
    
    print(ans)


Measured memory_bytes: 13428
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int w[300000];
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k = next<int>(), n = next<int>(), Max = -1;
	rep(i, 0, n)
	{
		cin>>w[i];
		if (i) Max = max(Max, abs(w[i]-w[i-1]));
	}
	Max = max(Max, w[0]+k-w[n-1]);
	cout<<k-Max<<endl;
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

int main(){
    auto s = string();
    cin >> s;
    int num = s.size();
    auto n0 = count_if(s.begin(),s.end(),[](char a){
        return a == '0';
    });
	
  	auto _min = min(num - n0,n0);
    cout << _min*2;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> a(N); REP(i, N) cin >> a[i];

  int ans = 0;
  for (int i = 0, cur = a[0], cnt = 0; i < N; ++i) {
    if (cur == a[i]) {
      cnt++;
    }

    if (i == N-1 || cur != a[i]) {
      ans += cnt / 2;
      cur = a[i];
      cnt = 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[2][100],sum=0,ans=0;
	cin>>n;
	for(int i=0;i<2;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	for(int i=0;i<n;i++)
		sum+=a[1][i];
	sum+=a[0][0];
	ans=sum;
	for(int i=1;i<n;i++){
		sum-=a[1][i-1];
		sum+=a[0][i];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
}


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

int H;
int solve(vector<vector<int>> board) {
    bool update = true;
    int score = 0, prev_score = 0;
    while (update) {
        update = false;

        // delete
        rep(r, H) {
            int tmp = 0, prev = -1;
            rep(c, 5) {
                if (board[r][c] == -100) {
                    prev = -1;
                    tmp = 0;
                    continue;
                }
                if (prev == -1) {
                    prev = board[r][c];
                    tmp++;
                }
                else {
                    if (prev == board[r][c]) {
                        tmp++;
                    }
                    else {
                        if (tmp >= 3 and prev > 0) {
                            score += prev * tmp;
                            for (int k=c-tmp; k<c; ++k) board[r][k] = -100;
                        }
                        prev = board[r][c];
                        tmp = 1;
                    }
                }
            }
            if (tmp >= 3 and prev > 0) {
                score += prev * tmp;
                for (int k = 5-tmp; k < 5; ++k) board[r][k] = -100;
            }
        }

        // fall
        for (int r = H-1; r >= 0; --r) {
            for (int c = 0; c < 5; ++c) {
                if (board[r][c] > 0) {
                    for (int rr=r+1; rr < H; ++rr) {
                        if (board[rr][c] == -100) {
                            board[rr][c] = board[rr-1][c];
                            board[rr-1][c] = -100;
                        }
                        else break;
                    }
                }
            }
        }

        // rep(r, H) {
        //     rep(c, 5) {
        //         if (board[r][c] == -100) {
        //             cout << "  ";
        //         }
        //         else cout << board[r][c] << " ";
        //     }
        //     cout << endl;
        // }

        if (prev_score < score) {
            update = true;
        }
        prev_score = score;

    }
    return score;
}

int main() {
    while (cin >> H, H) {
        vector<vector<int>> board(H, vector<int>(5, 0));
        rep(r, H) rep(c, 5) cin >> board[r][c];
        cout << solve(board) << endl;
    }
    return 0;
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll fun(ll s,ll x,ll y){
	ll a=x>>1,b=y>>1;
	ll t1[3],t2[3];
	t1[0]=abs(a*y-s),t1[1]=abs((x-a)*y-s),t1[2]=abs(a*y-(x-a)*y);
	sort(t1,t1+3);
	ll ans=t1[2];
	t2[0]=abs(b*x-s),t2[1]=abs((y-b)*x-s),t2[2]=abs(b*x-(y-b)*x);
	sort(t2,t2+3);
	return min(ans,t2[2]);
}
int main(){
	ll h,w;cin>>h>>w;
	ll s=h*w;
	if(s%3==0)  puts("0");
	else {
		ll ans=1e15;
		for(int i=1;i<h;i++){
			ans=min(ans,fun(i*w,h-i,w));
		}
		for(int i=1;i<w;i++){
			ans=min(ans,fun(i*h,w-i,h));
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n,k,a[200010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	double l=0.0,r=1000000000.0,ans=0.0;
	for(int i=1;i<=100;i++){
		double mid=(l+r)/2;
		int cnt=0;
		for(int j=1;j<=n;j++) cnt+=(int)ceil((double)a[j]*1.0/mid)-1;
		if(cnt<=k){
			ans=mid;
			r=mid;
		}
		else l=mid;
	}
	cout<<(int)ceil(ans)<<endl;
	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define ing long long
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

#define MAX 400

#define s first.first
#define l first.second
#define p second

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    vector<int> w;
    vector<pair<pair<int,int>,int>> in;
    vector<vector<int>> dp;
    
    cin>>n;

    in.resize(n);

    for(int i = 0; i  < n; i++){
        cin>>in[i].s>>in[i].l>>in[i].p;
    }

    cin>>m;
    
    w.resize(m);

    dp.resize(2,vector<int>(MAX*MAX,0));

    dp[0][0] = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < MAX; j++){
            for(int k = in[i].s; k <= in[i].l ; k++){
                int num = j + k;
                if(num < MAX) dp[0][num] = max(dp[0][num], dp[0][j] + in[i].p);

                //dp[0][num] = max(dp[0][num], dp[0][num]);
            }
        }
    }


    
    for(int i = 0; i < m; i++){
        cin>>w[i];

        if(dp[0][w[i]] == 0){

            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i = 0; i < m; i++){
        cout<<(dp[0][w[i]]?dp[0][w[i]]:-1)<<endl;
    }

    return 0;
}



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

using namespace std;

int n,a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    cin>>n;
    cout<<a[n-1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  ll A,B; cin>>A>>B;
  cout<<A*B<<endl;

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string N;
  cin >> N;
  int n=N.size();
  for(int i=0;i<n;i++){
    if(N[i]=='1') cout << '9';
    else cout << '1';
  }
  cout << endl;
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	if(S[0]==S[1]&&S[0]==S[2]) return _P("Yes\n");
	if(S[1]==S[2]&&S[1]==S[3]) return _P("Yes\n");
	_P("No\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
    ll N,K;
    cin >> N >> K;
    int cnt = 0;
    while(N > 0){
        N /= K;
        cnt++;
    }

    cout << cnt << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
string ar[105];
int32_t main(){
	int n,l;cin>>n>>l;
	for(int i=1;i<=n;cin>>ar[i++]);
	sort(ar+1,ar+n+1);
	for(int i=1;i<=n;i++) cout<<ar[i];
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inS = Console.ReadLine().Split(' ');
            int r = int.Parse(inS[0]);
            int D = int.Parse(inS[1]);
            int x = int.Parse(inS[2]);

            for(int i = 0; i < 10; i++)
            {
                x = x * r - D;

                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public class TXY
        {
            public int T;
            public int X;
            public int Y;
        }

        public void Calc()
        {
            var HN = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(HN[0] - A.Sum() <= 0 ? "Yes" : "No");


        }
    }
}

Measured memory_bytes: 19808
<?php

$n = explode(' ', fgets(STDIN));


$seven = 0;
$five = 0;
for ($i=0;$i<3;$i++) {
    if ($n[$i] == 5) {$five++;continue;}
    if ($n[$i] == 7) {$seven++;continue;}
}

if ($seven === 1 && $five === 2) {
    echo 'YES'.PHP_EOL;
} else {
    echo 'NO'.PHP_EOL;
}

Measured memory_bytes: 5368
#include <stdio.h>
int main(void)
{
	int n,a,i;
	scanf("%d\n",&n);
	scanf("%d",&a);
	for(i=0;i<=a;i++){
		int v;
		v=n-i;
		if(v%500==0){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll D, G;
        cin >> D >> G;
        vll p(D), c(D);

        rep(i, 0, D) cin >> p[i] >> c[i];

        vll ord(D);
        rep(i, 0, D) ord[i] = i;


        ll ans = inf;
        do {
                ll score = 0;
                ll cnt = 0;
                rep(i, 0, D) {
                        ll nowp = p[ord[i]];
                        ll nowc = c[ord[i]];

                        if (score + (ord[i] + 1) * 100 * nowp + nowc >= G) {
                                rep(j, 0, nowp) {
                                        if (score + (ord[i] + 1) * 100  < G) {
                                                score += (ord[i] + 1) * 100;
                                                ++cnt;
                                        } else {
                                                ++cnt;
                                                goto e;
                                        }
                                }
                                if (score + nowc >= G) goto e; 
                                

                        } else {
                                score += (ord[i] + 1) * 100 * nowp + nowc;
                                cnt += nowp;
                        }

                }
                e:
                chmin(ans, cnt);

        } while(next_permutation(all(ord)));

        cout << ans << endl;
}

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

int main()
{
    long int N;
    cin >> N;
    
    vector<long int> A(N);
    
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    long int now = 1;
    for(int i=0; i<N; i++){
        if(A[i] == now){
            now++;
        }
    }
    if(now == 1){
        cout << -1 << endl;
    }
    else{
        cout << N - now + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#B

#デバッグ
debug=1
def pront(*n):
    if debug==1:
        print(n)
        
#10**9+7を底とした処理

base=10**9+7

def add(a,b):#a+b
    return (a+b)%base

def sub(a,b):#a-b
    return (a-b)%base

def multi(a,b):#a*b
    return (a*b)%base

def exp(a,b):#a**b
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):#a/b
    return(multi(a,exp(b,base-2)))

#入力
N,M=map(int,input().split())

A=list(map(int,input().split()))

#処理

x=N-sum(A)

if x<0:
    print(-1)
else:
    print(x)

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i,n)cin >> d[i];


    int ans = 0;
    rep(i,n){
        srep(j,i+1,n){
            ans += d[i]*d[j];
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;

const int N=1e5+5;
int n,m;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    if(n>=10) return cout<<m,0;
    n=10-n;
    cout<<m+n*100;
}


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

using namespace std;


int N, M, V, P;
vector<int> A;
vector<long long>B, C;



bool calc(int index);

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

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

	sort(A.begin()+1,A.end(),greater<int>());


	B = C =vector<long long>(N + 1);
	for (int i = 1; i <= N; i++) {
		if (i < P) {
			B[i] = -1;
			C[i] = 0;
		}
		else {
			B[i] = max(0,V-P-N+i)* (long long)M;
			C[i] = C[i - 1] + max(0, A[P] - A[i]);
		}
	}

	long long n = 1;
	while (n <= N) { n *= 2; }

	int ans = 1;

	while (n > 1) {
		n /= 2;

		if (calc(ans + n)) {
			ans += n;
		}
	}

	cout << ans << endl;

	return 0;
}

bool calc(int index)
{
	if (index <= P) { return true; }
	if (index > N) { return false; }

	long long o = A[index] + (long long)M - A[P];
	if (o<0) { return false; }
	
	return B[index] <= C[index-1] + o*(index-P);

}



Measured memory_bytes: 2176
#define VERNIY st();int ver=0,niy=0,hbk=0
#define HIBIKI int ver=0,niy=0,hbk=0
//#pragma GCC optimize("0fast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
typedef unsigned long long LLU;
typedef long long LL;
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
typedef vector<int> vd;
typedef vector<pair<int,int> > vpd;
typedef pair<int,int> pd;
typedef queue<int> qd;
typedef queue<pair<int,int> > qpd;
typedef priority_queue<int> maxpqd;
typedef priority_queue<int, vector<int>, greater<int> > minpqd;
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein(oo) freopen(oo,"r",stdin);
#define fileout(oo) freopen(oo,"w",stdout);
#define setarr(a,b,c) memset(a,b,sizeof(c))

template<class Ver>
inline void in(Ver &a){cin>>a;}
template<class Ver,class Niy>
inline void in(Ver &a, Niy &b){cin>>a>>b;}
template<class Ver,class Niy, class Hbk>
inline void in(Ver &a, Niy &b, Hbk &c){cin>>a>>b>>c;}

template<class Ver>
inline void out(Ver a){cout<<a<<"\n";};
template<class Ver,class Niy>
inline void out(Ver a,Niy b){cout<<a<<" "<<b<<"\n";};
template<class Ver,class Niy, class Hbk>
inline void out(Ver a, Niy b, Hbk c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){cout<<"asd"<<endl;}
template<class Ver>
inline void debug(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver,class Niy>
inline void debug(Ver a,Niy b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver,class Niy, class Hbk>
inline void debug(Ver a,Niy b,Hbk c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
/*	HIBIKI;
	filein("in.txt");
	fileout("out.txt");
*/
	in(ver,niy);
	vd count(niy+4,0);
	forin(i,0,ver)
	{
		int n;
		in(n);
		forin(j,0,n)
		{
			in(hbk);
			++count[hbk];			
		}
	}
	int ans=0;
	forineq(i,0,niy)
	{
		ans+=(count[i]==ver);
	}
	out(ans);
	return 0;
}


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

using namespace std;

int main(){
  string S;cin >> S;
  int c1 = 0; int c2 = 0;
  
  for(int i= 0; i < (int)S.size(); i++){ 
    if(S[i] == '+'){ c1++;}
    else{ c2++;}
  }
  
  cout << c1-c2 << endl;
  
  return 0;
}

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


using ll = long long int;
using namespace std;





int main()
{
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
	string S, A, Z;
	
	cin >> S;
	
	int n, q, i, j, t, f, r;
	char c;
	
	cin >> q;
	r = 0;
	while(q--)
	{
		cin >> t;
		if (t == 1)
		{
			r ^= 1;
		}
		else
		{
			cin >> f >> c;
			if (f == 1)
			{
				if (r)
				{
					Z.push_back(c);
				}
				else
				{
					A.push_back(c);
				}
			}
			else
			{
				if (!r)
				{
					Z.push_back(c);
				}
				else
				{
					A.push_back(c);
				}
			}
		}
	}
	reverse(A.begin(), A.end());
	if (!r)
	{
		S = A + S + Z;
	}
	else
	{
		reverse(A.begin(), A.end());
		reverse(S.begin(), S.end());
		reverse(Z.begin(), Z.end());
		S = Z + S + A;
	}
	cout << S;
	
	
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    int test=0;
    for(int i=0;i<n;i++)
    {
        int x=nxt();
        if(x>=k)
            test++;
    }
    cout<<test<<endl;
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
/*******source code below********/
int main(void) {
	string S; cin >> S;
	int A = S[0] - '0';
	int B = S[1] - '0';
	int C = S[2] - '0';
	int D = S[3] - '0';

	for (int i = -1; i <= 1; i += 2) {
		for (int j = -1; j <= 1; j += 2) {
			for (int k = -1; k <= 1; k+= 2)
			{
				char op1, op2, op3;
				if (i == -1) op1 = '-';
				else op1 = '+';
				if (j == -1) op2 = '-';
				else op2 = '+';
				if (k == -1) op3 = '-';
				else op3 = '+';

				if ((A + (i * B) + (j * C) + (k * D)) == 7) {
					cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, K; cin >> N >> K;
	set<int> st;
	REP(i, K) {
		int d; cin >> d;
		st.insert(d);
	}
	REP(i, 100000) {
		if (i < N) continue;
		int tmp = i;
		bool flag = true;
		while (tmp > 0) {
			int n = tmp % 10;
			if (st.find(n) != st.end()) {
				flag = false;
				break;
			}
			tmp /= 10;
		}
		if (flag) {
			cout << i << endl;
			return;
		}
	}
}

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


Measured memory_bytes: 256
#include<stdio.h>


int main(void){

  double v;
  double t, y;
  int N;

  while(scanf("%lf", &v)!=EOF){
    t = v/9.8;
    y = 4.9*t*t;

    N=1;
    while(5*N-5<y) N++;

    printf("%d\n", N);
  }


  return(0);
}



Measured memory_bytes: 2056
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	stack<int> s;
	int res = 0;
	while (n--)
	{
		int h; cin >> h;
		if (s.empty())
		{
			res += h;
			s.push(h);
		}
		else
		{
			if (s.top() < h)res += h - s.top();
			s.push(h);
		}
	}
	cout << res << '\n';
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int K, X;
    cin >> K >> X;
    for (int i=X-K+1;i<X+K;i++) {
        cout << i;
        if (i<X+K-1) cout << " ";
        else cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
const long double PI=3.14159265358979323846;
int main(){
    long double a,b,h,m;
    cin >> a>> b >> h >> m;
    long double ans;
    long double rad;
    h = h/6 +m/360;
    m /=30;
    rad = max(h,m)- min(h,m);
    if(rad>1){
        rad = 2-rad;
    }
    ans = sqrt(a*a + b*b -2*a*b*cos(rad*PI));
    cout <<setprecision(11) << ans << endl;
}

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

using namespace std;

long long MOD = 1000000007;

bool increment(map<long long, long long>& m, long long key) {
    if (m.count(key) == 0) {
        m.insert(make_pair(key, 0));
    }
    m[key] += 1;
    if (m[key] > 2) {
        return false;
    }
    return true;
}

long long pow2Mod(int n) { // pow(2, n) % MOD
    long long ret = 1LL;
    for (int i = 1; i <= n; ++i) {
        ret *= 2;
        ret %= MOD;
    }
    return ret;
}

void Main() {
    long long N;
    cin >> N;
    map<long long, long long> position;
    for (long long i = 0; i < N; ++i) {
        long long a;
        cin >> a;
        if (N % 2 == 0) { // N : even
            if (a % 2 == 0) {
                cout << 0 << endl;
                return;
            }
            a -= 1;
            a /= 2;
            bool valid = increment(position, N / 2 - 1 - a);
            valid &= increment(position, N / 2 + a);
            if (!valid) {
                cout << 0 << endl;
                return;
            }
        }
        else { // N : odd
            if (a % 2 == 1) {
                cout << 0 << endl;
                return;
            }
            a /= 2;
            bool valid = increment(position, (N - 1) / 2 + a);
            valid &= increment(position, (N - 1) / 2 - a);
            if (!valid) {
                cout << 0 << endl;
                return;
            }
        }
    }

    if (N % 2 == 0) {
        cout << pow2Mod(N / 2) << endl;
    }
    else {
        if (position.count((N - 1) / 2) != 1) {
            cout << 0 << endl;
            return;
        }
        cout << pow2Mod((N - 1) / 2) << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
	string s;
	int max = 0;
	int a,z;
	cin >>s;


/*

	for(int i=0;i<s.length();i++){
		if(s[i] == 'A'){
			for(int j=i+1;j<s.length();j++){
//				cout <<"	" << j <<endl;
				if(s[j] == 'Z'){
					if(max < (j-i+1)){
						max = j-i+1;
//						cout << max <<endl;
					}
				}
			}
		}
	}
	cout << max <<endl;
*/

	for(int i=0;i<s.length();i++){
		if(s[i] == 'A'){
			a = i;
			break;
		}
	}
	for(int i=s.length()-1;i>=0;i--){
		if(s[i] == 'Z'){
			z = i;
			break;
		}
	}
	cout << z-a+1 <<endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
 
struct P {
    int x, y;
    P(int x, int y) : x{x}, y{y} {}
};
 
int limit;
vector<int> v;

constexpr int X[] = {2, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 2};
constexpr int Y[] = {0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4};
 
int next_pos(int x, int y)
{
    for (int i = 0; i < 13; i++) {
        if (x == X[i] && y == Y[i]) {
            return i;
        }
    }        
    return -1;
}
 
int getMD()
{
    int sum = 0;
    for (int i = 0; i < 13; i++) {
        if (v[i] == 0) continue;
        sum += abs(X[i] - X[v[i]]) + abs(Y[i] - Y[v[i]]);
    }
    return sum;
}
 
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};
 
bool dfs(const int* sp, int step)
{
    int md = getMD();
    if (md == 0) return 1;
    if (md + step > limit) {
        return 0;
    }
    
    for (int i = 0; i < 2; i++) {
        int x = X[sp[i]], y = Y[sp[i]];
        for (int j = 0; j < 4; j++) {
            int nx = x + dx[j], ny = y + dy[j];
            int next = next_pos(nx, ny);
            if (next == -1) continue;
            
            const int nsp1[] = {next, sp[1]}, nsp2[] = {sp[0], next};
            
            swap(v[sp[i]], v[next]);
            if (i == 0 && dfs(nsp1, step + 1)) {
                return 1;
            }
            if (i == 1 && dfs(nsp2, step + 1)) {
                return 1;
            }
            swap(v[sp[i]], v[next]);
        }
    }
    return 0;
}
 
int main()
{
    int x;
    while (cin >> x, x != -1) {
        int sp[2];
        v.resize(13); v[0] = x;
        for (int i = 1; i < 13; i++) {
            cin >> v[i];
        }

        for (int i = 0, j = 0; i < 13; i++) {
            if (v[i] == 0) {
                sp[j++] = i;
            }
        }

        bool found = 0;
        constexpr int LIMIT = 20;
        for (limit = 0; limit <= LIMIT; limit++) {
            if (dfs(sp, 0)) {
                cout << limit << endl;
                found = 1;
                break;
            }
        }
        if (!found) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2964
#include<math.h> 
 #include<iostream>
#include<string.h>
#include<algorithm>
using namespace std; 
const int maxn=1e5+5;
int a[maxn]; 
long long b[2*maxn]; 

int main(){
    int n,m,x; 
    long long t,mm; 
    t=0; 
    memset(a,0,sizeof(a)); 
    memset(b,0,sizeof(b)); 
	scanf("%d%d",&n,&m); 
	mm=0; 
	for(int i=1;i<=n;i++){ 
	   scanf("%d",&a[i]); 
	   } 
	for(int i=1;i<=n-1;i++){
		int l,r; 
	    l=a[i],r=a[i+1]; 	    
	    if(r<l) r=r+m;
		t+=r-l; 
		if(r>l+1){ 
		   b[l+2]+=1;
		   b[r+1]-=r-l;
		   b[r+2]+=r-l-1; 		   
		} 
    } 
	for(int i=1;i<=2*m;i++){
	   b[i]+=b[i-1]; 
	} 
	for(int i=1;i<=2*m;i++){
	   b[i]+=b[i-1]; 
	} 
	for(int i=1;i<=m;i++){
	   b[i]+=b[i+m]; 
	   //mm=max(b[i],mm); 
	   mm= b[i] > mm ? b[i]:mm;  
	    
	} 
//	printf("%lld,%lld\n",t,mm);
	printf("%lld\n",t-mm) ;
	return 0; 
	
} 


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

void printVec(vector<pair<char, int>> vec) {
  for (size_t i = 0; i < vec.size(); i++) {
    if (i == vec.size() - 1) {
      cout << vec[i].first << vec[i].second << endl;
    } else {
      cout << vec[i].first << vec[i].second << " ";
    }
  }
}

vector<pair<char, int>> selectionSort(vector<pair<char, int>> A) {
  auto N = A.size();
  for (size_t i = 0; i < N; i++) {
    auto minA = i;

    for (size_t j = i; j < N; j++) {
      if (A[minA].second > A[j].second) {
        minA = j;
      }
    }
    if (minA != i) {
      auto tmp = A[minA];
      A[minA] = A[i];
      A[i] = tmp;
    }
  }

  return A;
}

vector<pair<char, int>> bubbleSort(vector<pair<char, int>> A) {
  auto N = A.size();
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < N - i - 1; j++) {
      if (A[j].second > A[j + 1].second) {
        auto tmp = A[j];
        A[j] = A[j + 1];
        A[j + 1] = tmp;
      }
    }
  }

  return A;
}

bool isStable(vector<pair<char, int>> A, vector<pair<char, int>> B) {
  for (size_t i = 0; i < A.size(); i++) {
    if (A[i] != B[i]) {
      return false;
    }
  }
  return true;
}
int main() {
  int N, cnt = 0;
  cin >> N;
  vector<pair<char, int>> A(N);
  string card;
  for (size_t i = 0; i < N; i++) {
    cin >> card;
    A[i].first = card.at(0);
    A[i].second = card.at(1) - '0';
  }

  auto B = bubbleSort(A);
  printVec(B);
  cout << "Stable" << endl;

  auto S = selectionSort(A);
  printVec(S);

  if (isStable(B, S)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
long long n,i,a[100000001],dem[1000001];
int main()
{
    cin>>n;
    for(i=1;i<=n-1;i++)
    {
        cin>>a[i];
        dem[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<dem[i]<<endl;
    }
}


Measured memory_bytes: 6728
import sys
import itertools
import math
input=sys.stdin.readline
n=int(input())
G=[]
for i in range(n):
    x,y=map(int,input().split())
    G.append((x,y))
l=[i for i in range(n)]
p=itertools.permutations(l,n)
Sum=0
for i in p:
    pre=i[0]
    for j in range(1,n):
        now=i[j]
        Sum+=math.sqrt((G[pre][0]-G[now][0])**2+(G[pre][1]-G[now][1])**2)
        pre=now
ans=Sum/math.factorial(n)
print(ans)


    



Measured memory_bytes: 40556
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int main() {
	int n, a, b, sum = 0, ans = 0;;string s;
	cin >> n >> a >> b >> s;
	rep(i, n) {
		if (s[i] == 'a') {
			if (sum < a + b) {
				cout << "Yes" << endl;
				sum++;
			}
			else
				cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (sum < a + b && ans < b) {
				cout << "Yes" << endl;
				sum++;
				ans++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else
			cout << "No" << endl;
	}
}

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

int main(void){
  int sum=0, N, i, l, r;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d %d",&l, &r);
    sum+=r-l+1;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b,c;
    char s[101];
    char *kawaisou = "No";
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);

    if(a == b){
        if(a != c){
            kawaisou = "Yes";
        }
    }
    else if(b == c){
        if(a != b){
            kawaisou = "Yes";
        }
    }
    else if(c == a){
        if(c != b){
            kawaisou = "Yes";
        }
    }
    // 出力
    printf("%s\n",kawaisou);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	int len=a.size();
	int ans=0;
	for(int i=0;i<len;i++){
		if(a[i]==b[i])
			ans++;
	}
	cout<<ans<<endl;
}

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

signed main(){
  int x,a,b;cin>>x>>a>>b;
  int N;cin>>N;
  while(N--){
    string s;cin>>s;
    if(s[0]=='n')x=max(0,x+a);
    if(s[0]=='t')x=max(0,x+b);
    if(s[0]=='k')x=0;
  }
  cout<<x<<endl;
}



Measured memory_bytes: 3192
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 %.10f",a/b, a%b, (double)a/b);

    }

}


Measured memory_bytes: 26584
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int n, cnt = 0;
	scanf("%d", &n);
	for (size_t i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		if (a == cnt+1)
		{
			cnt++;
		}
	}

	if (cnt)
	{
		printf("%d", n - cnt);
	}
	else
	{
		printf("-1");
	}
}




Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <bitset>

using namespace std;

#define FSIO  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DEBUG(a)   cout<<"DEBUG: "<<(a)<<endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define MP make_pair
#define X  first
#define Y  second
#define REP(i,st,ed)    for(int i=st;i<=ed;++i)
#define IREP(i,st,ed)   for(int i=st;i>=ed;--i)
#define TCASE(T)    cin>>T;while(T--)

const int MAXN = 100005;
const ll MOD = 1e9+7 ;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-8;

int _;

using namespace std;


pair<int,int> roads[3];

vector<int> togo = {0,1,2};
int mk[5];


int main()
{
    //freopen("test.in","r+",stdin);
    //freopen("test.out","w+",stdout);
    FSIO;
    int a, b;
    while(cin>>a>>b)
    {
        roads[0] = MP(a,b);
        for(int i=1;i<=2;++i)
        {
            cin>>a>>b;
            roads[i] = MP(a,b);
        }
        int cnt;
        int flag = 0;
        int cur;
        togo = {0,1,2};
        do
        {
            /*for(int i:togo) cout<<i<<" ";
            cout<<endl;*/
            cnt = 0;
            memset(mk,0,sizeof(mk));
            if(roads[togo[0]].X==roads[togo[1]].X||
               roads[togo[0]].X==roads[togo[1]].Y)
               cur = roads[togo[0]].X;
            else if(roads[togo[0]].Y==roads[togo[1]].X||
               roads[togo[0]].Y==roads[togo[1]].Y)
               cur = roads[togo[0]].Y;
            else    continue;
            a = roads[togo[0]].X;
            b = roads[togo[0]].Y;
            if(!mk[a])  mk[a]=1, cnt++;
            if(!mk[b])  mk[b]=1, cnt++;
            for(int i=1;i<3;++i)
            {
                a = roads[togo[i]].X;
                b = roads[togo[i]].Y;
                if(a==cur)
                {
                    cur = b;
                    if(!mk[cur])    mk[cur]=1,cnt++;
                }
                else if(b==cur)
                {
                    cur = a;
                    if(!mk[cur])    mk[cur]=1,cnt++;
                }
                else    break;
            }
            if(cnt==4)
            {
                flag = 1;
                break;
            }
        }while(next_permutation(togo.begin(),togo.end()));
        if(flag)    cout<<"YES"<<endl;
        else    cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256