akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, K;
    cin >> N >> K;
    int A[N];
    vector<vector<int>> V(200001);
    rep(i, N) {
        cin >> A[i];
        V[A[i]].push_back(i);
    }
    rep(i, 200001) {
        if(V[i].size() > 0) V[i].push_back(V[i][0] + N);
    }
//    rep(i,200001){
//        if(V[i].size()>0){
//            cout<<i<<':';
//            for(auto x:V[i])cout<<x<<' ';
//            cout<<endl;
//
//    }
    int last = N * K - 1;
    vector<int> X;
    vector<bool> Judge(N, false);
    X.push_back(0);
    Judge[0] = true;
    int now = 0, near = -1;
    while(true) {
        int now0 = now % N;
        int a = A[now0];
        int dis = *upper_bound(all(V[a]), now0) - now0 + 1;
        int next = now + dis;
        if(next > last) {
            near = now;
            break;
        } else {
            X.push_back(next);
            if(Judge[next % N])
                break;
            else
                Judge[next % N] = true;
        }
        now=next;
    }
    if(near == -1) {
        int s = X.size();
        int r = s - 1;
        int l, k;
        rep(i, s) {
            if(X[i] % N == X[r] % N) {
                l = i;
                k = X[r]-X[l];
                if(k == 0) k = 1;
                break;
            }
        }
        for(int i=l;i<r;i++){
            near=max(near,X[i]+(last-X[i])/k*k);
            //cout<<X[i]<<' '<<k<<' '<<endl;
        }
    }
   // for(auto x:X)cout<<x<<' ';
    stack<int> Ans;
    vector<bool> JJ(200001, false);
    for(int i = near; i <= last; i++) {
        int a = A[i % N];
        //cout<<a<<endl;
        if(JJ[a]) {
            while(!Ans.empty()) {
                int n = Ans.top();
                JJ[n]=false;
                Ans.pop();
                if(n == a) break;
            }
            continue;
        } else {
            JJ[a] = true;
        }
        Ans.push(a);
    }
    vector<int> ANS;
    while(!Ans.empty()) {
        ANS.push_back(Ans.top());
        Ans.pop();
    }
    reverse(all(ANS));
    for(auto x : ANS) cout << x << ' ';
}


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


using namespace std;

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

  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M,0));
  for(int i=0;i<M;i++){
    cin >> B[i];
  }


  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    int total = C;
    for(int j=0;j<M;j++){
      total = total + A[i][j] * B[j];
    }

    if(total > 0){
      ans++;
    }
  }


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

Measured memory_bytes: 256
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n,len;
ll ans;
int x[maxn];
ll sum[maxn];

ll dis(int a,int b){
	if(a<b)return x[b]-x[a];
	return len-(x[a]-x[b]);
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&len,&n);
	REP(i,n)scanf("%d",&x[i]),sum[i]=sum[i-1]+x[i];
	REP(i,n){
		ll cur=dis(0,i);
		int now=n-i;			
		cur+=1LL*len*now;
		if(now&1){
			now/=2;
			cur-=2*(sum[n]-sum[n-now])+x[n-now];
			cur+=2*(sum[i+now]-sum[i]);
		}
		else{
			now/=2;
			cur-=2*(sum[n]-sum[n-now]);
			cur+=2*(sum[i+now-1]-sum[i])+x[i+now];
		}
		cur+=x[i];
		ans=max(ans,cur);
	}
	REP(i,n){
		ll cur=dis(i,0);
		int now=i-1;
		cur+=1LL*len*now;
		if(now&1){
			now/=2;
			cur+=2*sum[now]+x[now+1];
			cur-=2*(sum[i-1]-sum[i-now-1]);
		}
		else{
			now/=2;
			cur+=2*sum[now];
			cur-=2*(sum[i-1]-sum[i-now])+x[i-now];
		}
		cur-=x[i];
		ans=max(ans,cur);
	}
	printf("%lld\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 2560
from itertools import permutations
from math import sqrt, factorial

N = int(input())
XY = [[int(i) for i in input().split()] for _ in range(N)]
sum = 0.0
for p in permutations(range(N), N):
    for i in range(N - 1):
        now = p[i]
        next = p[i + 1]
        dx = abs(XY[next][0] - XY[now][0])
        dy = abs(XY[next][1] - XY[now][1])
        sum += sqrt(dx * dx + dy * dy)
print(sum / factorial(N))


Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n, m; cin >> n >> m;
    int mod = 1e9+7;
    set<int> a;
    rep(i, m){
        int t; cin >> t;
        a.insert(t);
    } 
    ll dp[100010] = {0};
    dp[0] = 1;
    for(int i=0; i<n; i++){
        if(a.count(i)) continue;
        if(!a.count(i+1)) dp[i+1] += dp[i];
        if(!a.count(i+2)) dp[i+2] += dp[i];
        dp[i+1] %= mod;
        dp[i+2] %= mod;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void) {
	int a, b, c, d, e, f;
	float x, y;
	while(scanf("%d %d %d %d %d %d",&a, &b, &c, &d, &e, &f) != -1){
		x = (float)(c*e -b*f)/(a*e - b*d);
		y = (float)(c*d - a*f)/(b*d - a*e);
		
		
		if(-0.005<x && x <= 0){
			x=0;
		}
		if(-0.005<y && y <= 0){
			y=0;
		}
		printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001;

int main() {
    int n,m; cin >> n >> m;
    ll l; cin >> l;
    ll dist[n][n]; rep(i,n) rep(j,n) dist[i][j] = INF;
    rep(i,n) dist[i][i] = 0;
    rep(i,m) {
        ll a,b,c; cin >> a >> b >> c;
        if (c > l) continue;
        a--; b--;
        dist[a][b] = min(dist[a][b], c);
        dist[b][a] = min(dist[b][a], c);
    }
    rep(k,n) rep(i,n) rep(j,n) dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    rep(i,n) rep(j,n) {
        if (dist[i][j] > l) dist[i][j] = INF;
        else dist[i][j] = 1;
    }
    //rep(i,n) {rep(j,n) printf("%lld ", dist[i][j]); printf("\n");}
    rep(k,n) rep(i,n) rep(j,n) dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    int q; cin >> q;
    rep(i,q) {
        int s,t; cin >> s >> t;
        s--; t--;
        if (dist[s][t] == INF) printf("%d\n", -1);
        else printf("%lld\n", dist[s][t]-1);
    }
    
    return 0;
}


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

using namespace std;

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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    ll n;
    cin >> n;

    ll sum = 0;
    for (ll k = 1; k * k <= n; ++k) {
        ll km = n - k;
        if (km % k != 0) continue;

        ll m = km / k;
        if (m <= 0) continue;
        ll div = n / m, am = n % m;
        if (div == k && am == k) sum += m;
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c[110000],d[110000];
string s;
signed main()
{
	cin>>a;
	rep(i,a){
		cin>>c[i];
		d[c[i]-1]=i+1;
	}
	rep(i,a){
		cout<<d[i]<<" ";
	}
}

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

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

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

typedef pair<long long, long long> pii;
int N;
vector<long long> A, B;

void f(){
    cout << -1 << '\n';
    exit(0);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> N;
    //debug(N);
    for(int i = 0; i < N ; i++) {
        long long x;
        cin >> x;
        A.push_back(x);
    }

    for(int i = 0 ; i < N ; i++){
        long long x;
        cin >> x;
        B.push_back(x);
    }

    priority_queue<pii> pq;
    for(int i = 0 ; i < N ; i++) {
        if(A[i] < B[i]) pq.push(pii(B[i], i));
        if(A[i] > B[i]) f();
    }

    long long cnt = 0;
    while(pq.size()){
        pii val = pq.top(); pq.pop();
        int l = (val.second + N - 1) % N;
        int r = (val.second + 1) % N;
        int mid = val.second;
        
        if(B[mid] < B[l] + B[r]) f();

        cnt += (B[mid] - A[mid]) / (B[l] + B[r]);
        B[mid] -= (B[mid] - A[mid]) / (B[l] + B[r]) * (B[l] + B[r]);
        debug(l, r, mid, B[mid], A[mid]);
        
        if(B[mid] < A[mid]) f();
        if(B[mid] != A[mid]) pq.push(pii(B[mid], mid));
    }

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

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int>v(n);
	int ma=-1e9,mi=1e9,fma=0,fmi=0;
	for(int i=0;i<n;++i){
		cin>>v[i];
		if(ma<v[i]){
			ma=v[i];
			fma=i+1;
		}
		if(mi>v[i]){
			mi=v[i];
			fmi=i+1;
		}
	}
	if(mi>=0){
		cout<<n-1<<endl;
		for(int i=1;i<n;++i){
			printf("%d %d\n",i,i+1);
		}
		return 0;
	}
	if(ma<=0){
		cout<<n-1<<endl;
		for(int i=0;i<n-1;++i){
			printf("%d %d\n",n-i,n-i-1);
		}
		return 0;
	}
	if(abs(ma)>abs(mi)){
		cout<<2*n-2<<endl;
		for(int i=1;i<=n;++i){
			if(fma==i)continue;
			printf("%d %d\n",fma,i);
		}
		for(int i=1;i<n;++i){
			printf("%d %d\n",i,i+1);
		}
		return 0;
	}
	else{
		cout<<2*n-2<<endl;
		for(int i=1;i<=n;++i){
			if(fmi==i)continue;
			printf("%d %d\n",fmi,i);
		}
		for(int i=0;i<n-1;++i){
			printf("%d %d\n",n-i,n-i-1);
		}
		return 0;
	}
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string s;
    cin >> s;
    li num = s.back() - '0';
    if (num == 3) {
        puts("bon");
    } else if (num == 0 || num == 1 || num == 6 || num == 8) {
        puts("pon");
    } else {
        puts("hon");
    }

    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll x;
    cin >> x;
    if(x < 7) cout << 1;
    else
    if(x <= 11) cout << 2;
    else
    {
      ll res = (x / 11) * 2;
      if(x % 11 > 6) res += 2;
      else if(x % 11 > 0) res++;
      cout << res;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var p = int.Parse(line[2]);
        Console.WriteLine(n * a > p ? p : n * a);
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        c = a+b;
        if(a%3==0||b%3==0||c%3==0) printf("Possible\n");
        else printf("Impossible\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;

struct Solver{
  string s;
  string t;
  map<char, set<int>> mpp;
  ll s_size;
  ll t_size;
  explicit Solver(string S, string T) : s(S), t(T){
    s_size = (ll)s.size();
    t_size = (ll)t.size();
    for(int i=0; i<s_size; i++){
      mpp[s[i]].emplace(i);
    }
  }
  void solve(){
    ll count = 0;
    ll prev_pos = -1;
    for(auto t_i : t){
      auto &stt = mpp[t_i];
      if(stt.empty()){cout << "-1\n"; return;}
      
      auto iter = stt.upper_bound(prev_pos);
      if(iter == stt.end()){
        prev_pos = -1;
        ++count;
        iter = stt.upper_bound(prev_pos);
      }
      prev_pos = *iter;
    }
    cout << s_size*count+prev_pos+1 << "\n";
    return;
  }
};

int main(){
  string S,T;
  cin >> S >> T;
  
  Solver solver(S,T);
  //cout << solver.solve() << "\n";
  solver.solve();
}



Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std;
ll h,w;
char a[1101][1101];
ll dp[1101][1101];
ll vis[1101][1101];
ll solve(ll i,ll j)
{
    if(vis[i][j]==1)return dp[i][j];
    if(i>=h||j>=w)return 0;
    if(a[i][j]=='#')return 0;
    if(i==h-1&&j==w-1){dp[i][j]=1;return dp[i][j];}
    vis[i][j]=1;
    dp[i][j]=(solve(i+1,j)+solve(i,j+1))%mod;
    return dp[i][j];
}
int main()
{
    cin>>h>>w;
    for(ll i=0;i<h;i++)for(ll j=0;j<w;j++)cin>>a[i][j];
    cout<<solve(0,0);
}

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

using namespace std;

int n,m;
int hon[100];
//3 9 5 3 8 2 1 6 9 7 4

int doteki(){
	int d[101][30];
	int p[101];
	p[0]=hon[0];
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			d[i][j]=1<<29;
		}
	}
	for(int i=1;i<m;i++){
		p[i]=p[i-1]+hon[i];
	}
	for(int i=0;i<n;i++){
		d[0][i]=p[0];
	}
	for(int i=0;i<m;i++){
		d[i][0]=p[i];
	}
	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			for(int k=0;k<i;k++){
				d[i][j]=min(max(d[k][j-1],p[i]-p[k]),d[i][j]);
			}
		}
	}
	return d[m-1][n-1];
}
int nibun(){
	int R,L;R=L=0;
	if(n>=m){
		return *max_element(hon,hon+n);
	}
	for(int i=0;i<m;i++){
		L+=hon[i];
	}
	while(1){
		if(R==L){
			return R;
		}
		double H=(double)(R+L)/2;
		
		int dan=0;
		int at=0;
		for(int i=0;i<m;i++){
			if(at+hon[i] <= H){
				at+=hon[i];
			}else{
				at=0;
				dan++;
				at+=hon[i];
			}
		}
		
		if(dan<n){
			L=H;
		}else{
			R=H+0.5;
		}
		
	}
}

int main(){
	
	//3 9 5 3 8 2 1 6 9 7 4
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0&&m==0){
			break;
		}
		for(int i=0;i<m;i++){
			scanf("%d",&hon[i]);
		}
		
		printf("%d\n",doteki());
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <assert.h>
#include <numeric>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> p(n + 1);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (p[i] == i + 1)
		{
			swap(p[i], p[i + 1]);
			ans++;
		}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define max1 1000005
#define siz 100000
#define mod 998244353
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  vector<vector<ll> > dp(n,vector<ll>(3,0));
  for(ll i=0;i<n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(ll i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

Measured memory_bytes: 8064
void main() {
	real PII = 3.1415926535897932384626;
	auto ip = readAs!(real[]), A = ip[0], B = ip[1], H = ip[2], M = ip[3];
	auto theta = abs(2*PII*(H*60+M)/60/12 - 2*PII*M/60);
	debug writefln("%f %f", 2*PII*(H*60+M)/60/12, 2*PII*M/60);
	debug theta.writeln;
	theta = min(theta, 2*PII - theta);
	debug theta.writeln;
	debug writeln(2*PII*(H*60+M)/60/12 * 57.2958);
	debug writeln(2*PII*M/60 * 57.2958);
	debug writeln(theta*57.2958);

	writefln("%.15f", sqrt(pow(A, 2) + pow(B, 2) - 2*A*B*cos(theta)));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 3048
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	boolean fig1=false;
	boolean fig2=false;
	boolean fig3=false;
	boolean fig4=false;
	for(int i=0;i!=a.length();i++) {
		char ch=a.charAt(i);
		switch(ch) {
		case 'S':fig1=true;break;
		case 'E':fig2=true;break;
		case 'N':fig3=true;break;
		case 'W':fig4=true;break;
		}
	}
	boolean ans=false;
	if(fig3&&fig1&&fig2==false&&fig4==false){
		ans=true;
	}
	if(fig3==false&&fig1==false&&fig2&&fig4){
		ans=true;
	}
	if(fig1&&fig2&&fig3&&fig4) {
		ans=true;
	}
	System.out.println(ans?"Yes":"No");
	scan.close();
	}
}

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

int main(){
  int n;
  cin >> n;
  int c = 0;
  for (int i = 3; i<=n;i+=2){
    int cd(0);
    for (int j = 1; j <= i; j++){
      if (i%j==0){
        cd++;
      }
    }
    if (cd==8){
      c++;
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    x = 0
    ans = 0
    for i in S:
        if i == 'I':
            x += 1
            ans = max(x, ans)
        else:
            x -= 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9904
#include <iostream>
#include <assert.h>
#include <algorithm>

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

    int32_t N, M, Q;
    std::cin >> N >> M >> Q;
    int32_t train[N+1][N+1] = {};

    for(int32_t i = 0; i < M; i++){
        int32_t L, R;
        std::cin >> L >> R;
        train[L][R]++;
    }

    int32_t sum_train[N+1][N+1] = {};
    for(int32_t l = 1; l <= N; l++){
        for(int32_t r = l; r <= N; r++){
            sum_train[l][r] = sum_train[l][r-1];
            for(int32_t nl = l; nl <= r; nl++){
                sum_train[l][r] += train[nl][r];
            }
        }
    }

    for(int32_t i = 0; i < Q; i++){
        int32_t p,q;
        std::cin >> p >> q;
        std::cout << sum_train[p][q] << std::endl;
    }

    return 0;

}


Measured memory_bytes: 2944
from Queue import Queue
mv=((1,0),(1,1),(0,1),(0,-1),(-1,0),(-1,-1))

while True:
    t,n=map(int,raw_input().split())
    if t==n==0:break
    obj=set(tuple(map(int,raw_input().split())) for i in range(n))
    x,y=map(int,raw_input().split())
    Q=Queue()
    visited=set()
    visited.add((x,y))
    tt=0
    Q.put((x,y,tt))
    while not Q.empty():
        x,y,tt=Q.get()
        if tt==t:break
        for dx,dy in mv:
            mx,my=x+dx,y+dy
            if (mx,my) not in obj and (mx,my) not in visited:
                Q.put((mx,my,tt+1))
                visited.add((mx,my))
    print len(visited)

Measured memory_bytes: 5324
#include<iostream>
using namespace std;
int main(){
long long n,a,min=1000000,max=-1000000,sum=0;
cin >> n;
for(int i=0; i<n; i++){
cin >> a;
if(a<min) min=a;
if(max<a) max=a;
sum+=a;
}
cout << min << " " << max << " " << sum <<endl;
return 0;
}


Measured memory_bytes: 3132
import numpy as np

N, W = map(int, input().split())

dp = np.zeros((N+1, W+1), dtype='uint64')

for i in range(N):
  w, v = map(int, input().split())
  dp[i+1][:w] = dp[i][:w]
  dp[i+1][w:] = np.maximum(dp[i][w:], dp[i][:-w]+v)
  
print(np.max(dp[N, :]))

Measured memory_bytes: 92056
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
int R, C;
char grid[1005][1005];
int dist[1005][1005];
queue<pair<int, int>> q;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> R >> C;
    
    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') q.push({i, j});
            dist[i][j] = 1e9;
            // if (grid[i][j] == '#') dist[i][j] = 0;
        }
    }
    int step = 0, ans = 0;
    while (q.size()) {
        int sz = q.size();
        while (sz--) {
            pair<int, int> f = q.front(); q.pop();
            // cout << f.fi << " " << f.se << "\n";
            if (dist[f.fi][f.se] == 1e9) {
                if (dist[f.fi + 1][f.se] == 1e9 && f.fi < R) q.push({f.fi + 1, f.se});
                if (dist[f.fi - 1][f.se] == 1e9 && f.fi > 1) q.push({f.fi - 1, f.se});
                if (dist[f.fi][f.se + 1] == 1e9 && f.se < C) q.push({f.fi, f.se + 1});
                if (dist[f.fi][f.se - 1] == 1e9 && f.se > 1) q.push({f.fi, f.se - 1});
            }
            dist[f.fi][f.se] = min(dist[f.fi][f.se], step);
        }
        step++;
    }
    // cout << step << "\n";
    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 21684
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	ll Z, W, a[2010];
	cin >> N >> Z >> W;
	for (int i = 0; i < N; i++)cin >> a[i];
	if (N == 1) cout << abs(a[0] - W) << endl;
	else cout << max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int n=s.nextInt(),k=s.nextInt(),x=s.nextInt(),y=s.nextInt();
		System.out.println(n<=k?n*x:n*x-(n-k)*(x-y));
	}
}

Measured memory_bytes: 25172
import std.stdio;

immutable mod = 4294967311L;

void main(){
	long x, y;
	int n, op;
	scanf("%d", &n);
	long[] inv = new long[1000_001];
	inv[1] = 1;
	foreach(i; 2..inv.length){
		inv[i] = mul(inv[mod%i], mod - mod/i);
	}
	foreach(_; 0..n){
		scanf("%d%lld", &op, &y);
		if(op >= 3 && y < 0) x = -x, y = -y;
		if(op == 1) x += y;
		else if(op == 2) x -= y;
		else if(op == 3) x *= y;
		else if(op == 4) x = mul(x, inv[cast(int)y]);
		x %= mod;
	}

	if(x < 0) x += mod;
	if(x > int.max) x -= mod;

	writeln(x);
}

long mul(long x, long y){
	return ( ((x*(y>>16)%mod)<<16) + (x*(y&0xffff)) ) % mod;
}

Measured memory_bytes: 10728
N = int(input())
A = list(map(int,input().split()))

cnt = 0

for a in A:
    if a < 0:
        cnt += 1

nA = [abs(a) for a in A]

if cnt % 2 == 0:
    print(sum(nA))
else:
    print(sum(nA)-2*min(nA))

Measured memory_bytes: 14284
#include<stdio.h>
#include<stdlib.h>
#define nMax 200000
#define nMin 2
#define RMax 1000000000
#define RMin 1

 int main(){

   int R[nMax],time,i,max=0,sub;

   scanf("%d",&time);
   if(nMin<=time && time<=nMax){
     for(i=0;i<time;i++){
       scanf("%d",&R[i]);
       if(RMin>R[i] || R[i]>RMax)
	 exit(1);
       }
     max=R[i-1];
     sub=R[i-1]-R[i-2];
     for(i=time-2;i>=0;i--){

       if(max<R[i] && i!=0){
	 max=R[i];
       }
       if(sub<max-R[i] && R[i]!=max){
	 sub=max-R[i];
       }
     }
   }
   else exit(1);

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

   return 0;
 }
       
 



Measured memory_bytes: 2540
h,w = map(int,input().split())          #周りを.で囲む↓
S=['.'+input()+'.' for i in range(h)]   #S[h][w+2]にする
S=['.'*(w+2)]+S+['.'*(w+2)]             #S[h+2][w+2]にする
ans = "Yes"
for i in range(1,h):
    for j in range(1,w):
        if S[i][j] == '#' and S[i][j-1] != '#' and S[i][j+1] != '#' and S[i-1][j] != '#' and S[i+1][j] != '#':
            ans ="No"
print(ans)

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    char tmp;
    bool flag = false;
    cin >> n;
    rep(i, n)
    {
        cin >> tmp;
        if (tmp == 'Y')
        {
            flag = true;
            break;
        }
    }
    cout << (flag ? "Four" : "Three") << endl;
    return 0;
}

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

const double eps=1e-9;
double x,y,d;
int n;

int main(){
	cin>>n>>d;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		double len=sqrt(x*x+y*y);
	//	cout<<len<<endl;
		if(len<=d)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3772
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string str =Console.ReadLine();
      int N=str.Length;
      int ans=0;

        for(int i=0;i<=(N/2-1);i++){
          if(str.Substring(i,1)!=str.Substring(N-1-i,1)){
            ans+=1;
          }
        }
      Console.WriteLine(ans);
      
    }
    
  }

}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
double dp[310][310][310];

double rec(int c3, int c2, int c1) {
  if (c3 == 0 && c2 == 0 && c1 == 0) return 0;
  if (dp[c3][c2][c1] > 0) return dp[c3][c2][c1];

  double res = (double)N / (c1 + c2 + c3);
  if (c3) res += rec(c3 - 1, c2 + 1, c1) * c3 / (c1 + c2 + c3);
  if (c2) res += rec(c3, c2 - 1, c1 + 1) * c2 / (c1 + c2 + c3);
  if (c1) res += rec(c3, c2, c1 - 1) * c1 / (c1 + c2 + c3);
  return dp[c3][c2][c1] = res;
}

signed main() {
  cin >> N;

  int a = 0, b = 0, c = 0;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (tmp == 3) a++;
    if (tmp == 2) b++;
    if (tmp == 1) c++;
  }

  cout << fixed << setprecision(14) << rec(a, b, c) << endl;
  return 0;
}


Measured memory_bytes: 225536
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    char s[n + 1];
    char t[n + 1];
    char ans[n * 2 + 1];
    scanf("%s %s",s,t);
    for(int i = 0;i < n * 2;i++){
        if(i % 2 == 0){
            ans[i] = s[i / 2];
        }else{
            ans[i] = t[(i - 1) / 2];
        }
    }
    ans[n * 2] = '\0';
    printf("%s",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
int main(){
    lli n, m;
    cin >> n >> m;
    vector<lli> vec(n+1, -1);
    rep0(i,m){
        int temp; string str;
        cin >> temp >> str;
        if(str == "AC"){
            if(vec[temp] > 0) continue;
            vec[temp] = -vec[temp];
        }
        else{
            if(vec[temp] < 0){
                vec[temp]--;
            }
        }
    }
    lli ac=0, wa=0;
    rep0(i, n+1){
        if(vec[i] > 0){
            ac++;
            wa += vec[i]-1;
        }
    }
    cout << ac << ' ' << wa;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmax(int &x, int v) { if (x < v) x = v; }

string S;
int N, K;
int dp[301][301][302];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S >> K;
  N = S.length();
  rep(i, N) rep(j, N) rep(k, K+1) dp[i][j][k] = -INF;
  dp[0][N-1][0] = 0;
  int m = 0;
  for (int len=N; len>=2; len--) {
    rep(l, N) {
      int r = l+len-1;
      if (r >= N) break;
      rep(k, K+1) {
        if (dp[l][r][k] < 0) continue;
        chmax(dp[l+1][r-1][k+(S[l]!=S[r])], dp[l][r][k] + 2);
        chmax(dp[l+1][r][k], dp[l][r][k]);
        chmax(dp[l][r-1][k], dp[l][r][k]);
      }
    }
  }
  rep(i, N) rep(j, N) rep(k, K+1) chmax(m, dp[i][j][k] + (i<=j));
  cout << m << "\n";
  return 0;
}


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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];
int head[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

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

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

int main(){
	int T;
	int x, y, z;
	scanf("%d%d%d%d", &x, &y, &z, &k);
	if (k < x) {
		cout << k << endl;
	}
	else if (k < x + y) {
		cout << x << endl;
	}
	else cout << x - (k - x - y) << endl;
	return 0;
}



Measured memory_bytes: 3772
# coding: utf-8

num = int(input())
str = input().split()
table = [int(i) for i in str]
count = 1
maxi = table[0]
pointed = table[0]
for i in range(1, num):
    if maxi <= table[i]:
        maxi = table[i]
        count += 1
print(count)


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

int n, m, l, ans = 1;
pair<int, int> dem[100010];

int main(){
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> dem[i].second >> dem[i].first;
  sort(dem, dem + m);
  l = dem[0].first;
  for (int i = 1; i < m; i++){
    if(dem[i].second >= l){
      l = dem[i].first;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000
#define N -1
 
int D[MAX],H[MAX];
int n;
int A;

void print(int);
 
struct Node{ int p, l, r;};
struct Node T[MAX];

void arr(int a){
  if(getD(a) == 0){
    printf("root\n");
  }else if(T[a].r ==N && T[a].l ==N){ 
    printf("leaf\n");
  }else if(T[a].r!=N || T[a].l!= N){
    printf("internal node\n"); 
  }
}
 
 
int getD(int u){
  int d = 0;
  int i;
  if(u == A) return 0;
  else{
    i = n-1;
    while(1){
      if(u == A) break;
      if(T[i].l == u || T[i].r == u){
	d++;
	u = T[i].p;
      }
      i--;
      if(i<0) i = n-1;
    }
    return d;
  }
   
}
 
int par(int a){
  int i;
  if(a==A) return -1;
  else {
    for(i=0;i<n;i++){
      if(T[i].l==a || T[i].r == a){
	return T[i].p;
	break;
      }
    }
  }
}
 
int sibling(int b){
  int i;
  if(b==A) return -1;
  else {
    for(i=0;i<n;i++){
      if(T[i].l == b){
	return T[i].r;
      }
      if(T[i].r == b){
	return T[i].l;
      }
    }
  }
}
 
int degree(int d){
  if(T[d].l==-1 && T[d].r == -1){
    return 0;
  }
  else if(T[d].l != -1 && T[d].r != -1){
    return 2;
  }
  else if((T[d].l == -1 && T[d].r != -1) || (T[d].l != -1 && T[d].r == -1)){
    return 1;
  }
  
}
int hei(int c){
  int l=0;
  int r=0;
 
  if(T[c].l==-1 && T[c].r == -1){
    return 0;
  }
  if(T[c].l!=-1 && T[c].r != -1){
    l = hei(T[c].l)+1;
    r = hei(T[c].r)+1;
    if(l<r){
      return r;
    }
    else return l;
  }
  else if(T[c].l==-1&&T[c].r!=-1){
    return hei(T[c].r)+1;
  }
  else if(T[c].l!=-1&&T[c].r==-1){
    return hei(T[c].l)+1;
  }
}
void print(int u){
  
   
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,par(u),sibling(u),degree(u),D[u],hei(u));
  arr(u);
}
 
 
main(){
  int i, j, d, v, c, l;
  int t;
  int f=0;
 
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = N;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &d, &c);
 
    T[v].p = v;
    T[v].l = d;
    T[v].r = c;
  }
  A = 0;
  for(i=n-1;i>0;i--){
    if(T[i].l==A || T[i].r==A){
      A = T[i].p;   
      f++;
      if(A == 0){
	break;
      }
      else {
	i = n-1;
      }
    } 
  }

  if(f == 0){
    A= 0;
  }
  
  for(i=0;i<n;i++){
    D[i] = getD(i);
  }
 
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

Measured memory_bytes: 620
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_line(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let mut a: usize = iter.next().unwrap().parse().unwrap();
    let mut b: usize = iter.next().unwrap().parse().unwrap();

    // 答え
    let mut num_coins: usize = 0;

    for i in 0..2 {
        if (a > b) {
            num_coins += a;
            a -= 1;
        } else {
            num_coins += b;
            b -= 1;
        }
    }

    println!("{}", num_coins);
}

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, P; cin >> N >> P;
	vector<int> A(N, 0);
	rep (i, N) cin >> A[i];

	int odd = 0;
	int even = 0;
	rep (i, N){
		if (A[i] % 2 == 0){
			++even;
		}else{
			++odd;
		} // end if
	} // end rep

	ll res = 0LL;

	if (P == 0){
		res = (1LL<<even);
		if (odd > 1){
			res += (1LL<<even)*((1LL<<(odd-1)) - 1);
		} // end if
	}else{ // if (P == 1)
		if (odd >= 1){
			res = (1LL<<even)*(1LL<<(odd-1));
		} // end if
	} // end if

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e12, cnt;

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-a-b;
	if(4*a*b<d*d && d>0){
		cout<<"Yes";
	}
	else cout<<"No";
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  int M = nextInt();
  int ans = (N-1)*N/2 + (M-1)*M/2;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
N=int(input())
m = {}
ans=0
for i in range(N):
  s = list(input())
  s = sorted(s)
  s = "".join(s)
  if s in m:
    ans+=m[s]
    m[s]+=1
  else:
    m[s] = 1
print(ans)

  


Measured memory_bytes: 17804
def examA():
    X = [I() for _ in range(5)]
    k = I()
    X.sort()
    ans = "Yay!"
    if X[-1]-X[0]>k:
        ans = ":("
    print(ans)
    return

def examB():
    X = [I() for _ in range(5)]
    ans = 0
    for i in range(5):
        ans += (X[i]+9)//10 *10
        X[i] = (X[i]-1)%10
    ans -= (9-min(X))
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;

const int N = 3e5 + 5;

int w, h, n, ans, num[N];
struct node {
	int x, y;
	node (int _x = 0, int _y = 0) {x = _x, y = _y;}
} a[N], b[N];


int pl, pr, px;
struct tree {
	int mx, z;
} t[N * 4];
void down(int i) {
	if(t[i].z) {
		t[i + i].z += t[i].z; t[i + i].mx += t[i].z;
		t[i + i + 1].z += t[i].z; t[i + i + 1].mx += t[i].z;
		t[i].z = 0;
	}
}
void add(int i, int x, int y) {
	if(y < pl || x > pr) return;
	if(x >= pl && y <= pr) {t[i].z += px; t[i].mx += px;return;}
	int m = x + y >> 1; down(i);
	add(i + i, x, m); add(i + i + 1, m + 1, y);
	t[i].mx = max(t[i + i].mx, t[i + i + 1].mx);
	
}
void cc(int x, int y, int c) {
	pl = x, pr = y, px = c; add(1, 1, n + 2);
}
	
int z1[N], z2[N], d1, d2, z;

bool cmp(node a, node b) {return a.x < b.x;}

int b1[N], b2[N];

void GG() {
	memset(b1, 0, sizeof b1);
	memset(b2, 0, sizeof b2);
	z = h / 2;
	a[n + 1] = node(0, z + 1); a[n + 2] = node(0, z); a[n + 3] = node(w, h);
	sort(a + 1, a + n + 4, cmp);
	memset(t, 0, sizeof t);
	int tot = 0;
	fo(i, 1, n + 3) {
		if(i == 1 || a[i].x != a[i - 1].x)
			++ tot, cc(tot, tot, h - a[i].x);
		num[i] = tot;
	}
	fo(i, 1, n + 3)
		if(a[i].y > z) {
			if(!b1[num[i]]) b1[num[i]] = i; else {
				if(a[i].y < a[b1[num[i]]].y)
					b1[num[i]] = i;
			}
		} else {
			if(!b2[num[i]]) b2[num[i]] = i; else {
				if(a[i].y > a[b2[num[i]]].y)
					b2[num[i]] = i;
			}
		}
	d1 = d2 = 1;
	fo(i, 1, n + 3) {
		if(!a[i].x && a[i].y == z) z1[1] = i;
		if(!a[i].x && a[i].y == z + 1) z2[1] = i;
	}
	fo(i, 1, n + 3) {
		if(!a[i].x && (a[i].y == z || a[i].y == z + 1))
			continue;
		if(a[i].y > z) {
			if(i != b1[num[i]]) continue;
		} else {
			if(i != b2[num[i]]) continue;
		}
		ans = max(ans, t[1].mx + a[i].x);
		if(a[i].y > z) {
			cc(num[z1[d1]], num[i] - 1, a[i].y - h);
			while(a[z1[d1]].y > a[i].y) {
				cc(num[z1[d1 - 1]], num[z1[d1]] - 1, a[i].y - a[z1[d1]].y);
				d1 --;
			}
			z1[++ d1] = i;
		} else {
			cc(num[z2[d2]], num[i] - 1, -a[i].y);
			while(a[z2[d2]].y < a[i].y) {
				cc(num[z2[d2 - 1]], num[z2[d2]] - 1, a[z2[d2]].y - a[i].y );
				d2 --;
			}
			z2[++ d2] = i;
		}
	}
	return;
}

int main() {
	scanf("%d %d %d", &w, &h, &n);
	fo(i, 1, n) scanf("%d %d", &a[i].x, &a[i].y);
	fo(i, 1, n) b[i] = a[i];
	GG();
	swap(w, h); fo(i, 1, n) a[i] = node(b[i].y, b[i].x);
	GG();
	printf("%d", ans * 2);
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   vector<string> s(n);
   rep(i, n) cin>>s[i];

   map<string, int> ma;
   rep(i, n) ma[s[i]]++;
   int mx=0;
   for(auto p : ma) mx=max(mx, p.second);
   vector<string> li;
   for(auto p : ma) if(p.second==mx) li.push_back(p.first);
   sort(li.begin(), li.end());

   for(string t : li) cout<<t<<endl;
   return 0;
}


Measured memory_bytes: 33476
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> v[100005];
ll dp[100005][2];
const ll m = 1e9 + 7;
ll solve(ll node,ll colour,ll parent){
    ll ans = 0;
    if(dp[node][colour] != -1){
        return dp[node][colour];
    }
    ll way1 = 1;
    for(auto child : v[node]){
        if(child != parent){
            way1 = way1 * solve(child,0,node)%m;
        }
    }
    ans += way1;
    if(!colour){
        ll way2 = 1;
        for(auto child : v[node]){
            if(child != parent){
                way2 = way2 * solve(child,1,node)%m;
            }
        }
    ans += way2;
    }
    return dp[node][colour] = ans%m;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cout<<solve(1,0,-1)<<"\n";
}

Measured memory_bytes: 17448
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a[n];
    long long res[n];
    res[0]=0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        if(i&1) res[0]-=a[i];
        else res[0]+=a[i];
    }
    for(int i=1;i<n;i++) res[i]=2*a[i-1]-res[i-1];
    for(int i=0;i<n;i++) cout << res[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816