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

int main(){
    string str,sub;
    cin>>str>>sub;
    
    int m = str.length();
    int n = sub.length();
    
    int min = n;
    for(int i=0;i<m-n+1;i++){
        int count = 0;
        for(int j=0;j<n;j++){
            if(str[i+j]!=sub[j]){
                count++;
            }
        }
        if(count<min){
            min = count;
        }
    }
    cout<<min<<endl;
    
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char const *argv[])
{
   int N;
   cin >> N;
   vector<int> d(N);
   for (int i = 0; i < N; i++)
   {
      cin >> d[i];
   }
   int ans = 0;
   for(int i = 0; i < N; i++)
   {
      for(int j = i+1; j < N; j++)
      {
         ans += d[i]*d[j];
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
import sys
x = ""
x = sys.stdin.read()
# while True:
#     x += str(input())
#     t = time.time()

alist = list(x)
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
aa = [0]*27
for num in alist:
    itr =0
    for alp in alphabet:
        if num == alp:
            aa[itr] += 1
            break;
        itr += 1
    itr = 0
    for ALP in ALPHABET:
        if num == ALP:
            aa[itr] += 1
            break;
        itr += 1
for i in range(26):
    print("{} : {}".format(alphabet[i], aa[i]))


Measured memory_bytes: 5572
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int a[10000], b[10000],i;
	char c[10000];
	i = 1;
	while (1) {
		cin >> a[i] >> c[i] >> b[i];
		if (c[i] == '?' ) { break; }
		else if (c[i] == '+') { printf("%d\n", a[i] + b[i]); }
		else if (c[i] == '-') { printf("%d\n", a[i] - b[i]); }
		else if (c[i] == '*') { printf("%d\n", a[i] * b[i]); }
		else if (c[i] == '/') { printf("%d\n", a[i] / b[i]); }
	
		i++;
	}
	return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int minv = -1;
  int maxv = INT_MAX;
  vector<p> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i].first >> v[i].second;
    minv = max(minv, v[i].first);
    maxv = min(maxv, v[i].second);
  }
  int res = max(maxv - minv + 1, 0);
  cout << res << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s;
        int flag = 0;
        for(int k=0;k<n;k++){
            int[] x = new int[9];
            //int[] c = new int[9];
            int[] red = new int[9];
            int[] green = new int[9];
            int[] blue = new int[9];
            //List<Integer> red = new ArrayList<>();
            //List<Integer> blue = new ArrayList<>();
            //List<Integer> green = new ArrayList<>();
            flag=0;
            for(int i=0; i<9;i++){
                x[i] = sc.nextInt();           
            }
            for(int i=0; i<9;i++){
                s = sc.next();
                if(s.equals("R")){
                    red[x[i]-1]++;
                }
                else if(s.equals("G")){
                    green[x[i]-1]++;
                }    
                else {
                    blue[x[i]-1]++;
                }         
            }
            for(int i=0; i<7;i++){
                if((red[i]%3)==1||red[i]%3==2){
                    red[i+1]-=red[i]%3;
                    red[i+2]-=red[i]%3;
                    red[i]-=red[i]%3;
                }
            }
            for(int i=0; i<9;i++){
                if(red[i]%3==0){
                    red[i]-=(red[i]/3)*3;
                }
            }
            for(int i=0; i<7;i++){
                if((green[i]%3)==1||green[i]%3==2){
                    green[i+1]-=green[i]%3;
                    green[i+2]-=green[i]%3;
                    green[i]-=green[i]%3;
                }
            }
            for(int i=0; i<9;i++){
                if(green[i]%3==0){
                    green[i]-=(green[i]/3)*3;
                }
            }
            for(int i=0; i<7;i++){
                if((blue[i]%3)==1||blue[i]%3==2){
                    blue[i+1]-=blue[i]%3;
                    blue[i+2]-=blue[i]%3;
                    blue[i]-=blue[i]%3;
                }
            }
            for(int i=0; i<9;i++){
                if(blue[i]%3==0){
                    blue[i]-=(blue[i]/3)*3;
                }
            }
            for(int i=0; i<9;i++) {
                if(red[i]!=0||blue[i]!=0||green[i]!=0){
                    flag++;
                    //System.out.println(red[i]+":"+green[i]+":"+blue[i]);
                }
                red[i]=0;blue[i]=0;green[i]=0;
            }
            if(flag==0){
                System.out.println(1);
            }
            else {
                System.out.println(0);
            }
            //Collections.sort(red);
            //Collections.sort(green);
            //Collections.sort(blue);
            
        }
        
        sc.close();
    }
}



Measured memory_bytes: 28632
#include<stdio.h>
int main()
{
    long x,yen=100,i;
    int u=0;
    scanf("%ld",&x);
    while(yen<x)
    {
        i=yen/100;
        yen+=i;
        u+=1;
    }
    printf("%d",u);
    return 0;
}


Measured memory_bytes: 1732
#include<stdio.h>
#include<math.h>
int main(){
    double x1, x2;
    double y1, y2;
    double L, l;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    L = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
    l = sqrt(L);
    printf("%f", l);
    return 0;
}

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

bool used[100010];
vector<pair<int,int>> mp[100010];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  pair<pair<int,int>,int> p1[n];
  pair<pair<int,int>,int> p2[n];
  for (int i = 0; i < n; i++) {
    cin >> p1[i].first.first >> p1[i].first.second;
    p1[i].second = i;
    p2[i].first.first = p1[i].first.second;
    p2[i].first.second = p1[i].first.first;
    p2[i].second = i;
  }
  sort(p1, p1+n);
  sort(p2, p2+n);
  for (int i = 1; i < n; i++) {
    int md = abs(p1[i].first.first-p1[i-1].first.first);
    mp[p1[i].second].push_back(make_pair(md,p1[i-1].second));
    mp[p1[i-1].second].push_back(make_pair(md,p1[i].second));
  }
  for (int i = 1; i < n; i++) {
    int md = abs(p2[i].first.first-p2[i - 1].first.first);
    mp[p2[i].second].push_back(make_pair(md,p2[i-1].second));
    mp[p2[i-1].second].push_back(make_pair(md,p2[i].second));
  }

  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
  for (int i = 0; i < mp[0].size(); i++) {
    pq.push(mp[0][i]);
  }
  used[0] = 1;
  n--;
  ll ans = 0;
  while (n) {
    pair<int,int> tp = pq.top();
    pq.pop();
    if (used[tp.second]) continue;
    used[tp.second] = 1;
    ans += tp.first;
    n--;
    for (int i = 0; i < mp[tp.second].size(); i++) {
      pq.push(mp[tp.second][i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e5 + 5, M = 1e18;
vector<ll> dp(N + 1, M);
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, m, v, w, x;
    dp[0] = 0;
    cin >> n >> m;
    while (n--)
    {
        cin >> w >> v;
        for (ll j = N; j >= v; j--)
            dp[j] = min(dp[j], dp[j - v] + w);
    }
    for (ll i = 0; i < N; i++)
        if (dp[i] <= m)
            x = i;
    cout << x;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define M 1005
#define ll long long
int cnt[M];
int main(){
	int n,x,y;
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++){
			int d=min(j-i,abs(i-x)+abs(j-y)+1);
			cnt[d]++;
		}
	for(int i=1;i<n;i++)printf("%d\n",cnt[i]); 
	return 0;
} 

Measured memory_bytes: 256
<?php
$searchQuery = fgets(STDIN);
$delimiters = array(' ', '.', ',');
$minlength = 3;
$maxlength = 6;

$searchQuery = str_replace($delimiters[1], $delimiters[0], $searchQuery);
$searchQuery = str_replace($delimiters[2], $delimiters[0], $searchQuery);
$allSearchWords = explode($delimiters[0], $searchQuery);

$searchWords = array();
foreach ($allSearchWords as $word) {
  if (strlen($word) >= $minlength && strlen($word) <= $maxlength)
    array_push($searchWords, $word);
}

echo implode(' ', $searchWords)."\n";

Measured memory_bytes: 15476
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans;
	string s;

	vector<vector<long long>> c(10, vector<long long>(10, 0));

	cin >> n;
	for (i = 1; i <= n; i++) {
		s = to_string(i);
		c[s[0] - '0'][i % 10]++;
	}

	ans = 0;
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			if (i != j) ans += c[i][j] * c[j][i];
		}
	}
	for (i = 0; i < 10; i++) ans += c[i][i] * c[i][i];

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = sum(B)
for i in range(N-1):
  if A[i+1] == A[i]+1:
    ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

int evaluate(const char* expr, int mode) {
	int rp_data[100];
	int data_num = 0;
	int stack[100];
	int stack_num = 0;
	int i;
	/* siki wo gyaku poorando kihou ni hennkann suru */
	for (i = 0; expr[i] != '\0'; i++) {
		if (expr[i] == '+' || expr[i] == '*') {
			while (stack_num > 0 && (mode || expr[i] == '+' || stack[stack_num - 1] == '*')) {
				rp_data[data_num++] = stack[--stack_num];
			}
			stack[stack_num++] = expr[i];
		} else {
			rp_data[data_num++] = expr[i];
		}
	}
	while (stack_num > 0) {
		rp_data[data_num++] = stack[--stack_num];
	}
	/* evaluate the converted data */
	stack_num = 0;
	for (i = 0; i < data_num; i++) {
		if (rp_data[i] == '+') {
			stack[stack_num - 2] += stack[stack_num - 1];
			stack_num--;
		} else if (rp_data[i] == '*') {
			stack[stack_num - 2] *= stack[stack_num - 1];
			stack_num--;
		} else {
			stack[stack_num++] = rp_data[i] - '0';
		}
	}
	return stack[0];
}

int main(void) {
	char expr[32];
	int value;
	if (scanf("%s", expr) != 1) return 1;
	if (scanf("%d", &value) != 1) return 1;
	printf("%c\n", "IMLU"[(evaluate(expr, 0) == value) + (evaluate(expr, 1) == value) * 2]);
	return 0;
}

Measured memory_bytes: 596
a=str(input())
d=a.split(sep='/')
if(int(d[0])<2019):
        print("Heisei")
elif(int(d[0])==2019 and int(d[1])<4):
        print("Heisei")
elif(int(d[0])==2019 and int(d[1])==4 and int(d[2])<=30):
        print("Heisei")
else:
        print("TBD")

Measured memory_bytes: 3064
from collections import deque
import random
isdebug=0
if isdebug==0:
    N=int(input())
    G=[[] for i in range(N)]
    for i in range(N-1):
        a,b=map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
else:
    N=20*10**4
    G=[[] for i in range(N)]
    for i in range(N-1):
        a,b=random.randrange(i+1),i+1
        G[a].append(b)
        G[b].append(a)
dist=[-1 for i in range(N)]
X=[]
Y=[]
q=deque([0])
dist[0]=0
while(len(q)>0):
    r=q.popleft()
    if dist[r]%2==0:
        X.append(r)
    else:
        Y.append(r)
    for p in G[r]:
        if dist[p]==-1:
            dist[p]=dist[r]+1
            q.append(p)
P=[0 for i in range(N)]
que=deque([])
if min(len(X),len(Y))<=N//3:
    for i in range(1,N+1):
        if i%3==0:
            que.appendleft(i)
        else:
            que.append(i)
    if len(X)<len(Y):
        for i in X:
            t=que.popleft()
            P[i]=t
        for i in Y:
            t=que.pop()
            P[i]=t
    else:
        for i in Y:
            t=que.popleft()
            P[i]=t
        for i in X:
            t=que.pop()
            P[i]=t
else:
    for i in range(1,N+1):
        if i%3==0:
            que.appendleft(i)
    for i in range(1,N+1):
        if i%3==1:
            que.appendleft(i)
        elif i%3==2:
            que.append(i)
    for i in X:
        t=que.popleft()
        P[i]=t
    for i in Y:
        t=que.pop()
        P[i]=t
print(*P)


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for (int i=a;i<=b;i++){
    if (i/10000==i%10 && (i/1000)%10==(i/10)%10) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a,b,k=[int(i) for i in input().split()]
if(k>a):
    k=k-a
    a=0
elif(k<=a):
    a=a-k
    k=0
if(k>b):
    k=k-b
    b=0
elif(k<=b):
    b=b-k
    k=0
print(a,b)

Measured memory_bytes: 61696
using System;


class Program
{
    static void Main(string[] arg)
    {
        var res = Console.ReadLine().ToString();
      	
      
      	
        Console.WriteLine(IsCoffee(res) ? "Yes" : "No");
    }
  
    static bool IsCoffee(string s)
    {
        if (s.Length != 6) return false;

        return s[2] == s[3] && s[4] == s[5];
    }
  
}

Measured memory_bytes: 13140
n = int(input())
a = [int(x) for x in input().split()]

M_NUM = 10**18

ans = 1
for item in a:
    if ans > M_NUM:
        break
    ans *= item

if 0 in a:
    print('0')
elif ans > M_NUM:
    print('-1')
else:
    print(ans)


Measured memory_bytes: 21660
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005],dp[200005];
int main()
{
	boost
	ll n;
	cin>>n;
	ll i;
	for(i=0; i<n; i++)
		cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(i=2; i<n; i++)
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int a, b, x;
    cin >> a >> b >> x;

    if((a + b) >= x && a <= x) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  int s=0;
  int t=0;
  for (auto c:x) {
    if (c == 'S') {
      s++;
    } else {
      if (s > 0) s--;
      else t++;
    }
  }
  cout << t+s << endl;

  return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>
double memo[100000]={0,1},x;
double F(int n, double p)
{
	if(n<=1)return n*p;
	else if(x=p*memo[n-1],x<1e-12)return x;
	else return p*(1+F(n-1,p/2)) + (1-p)*memo[n-1];
}
int main()
{
	int n,i,j;
	for(i=2;i<100001;++i)memo[i]=F(i,1);
	while(scanf("%d",&n),n)printf("%.12f\n", memo[n]);
	return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 998244353

lli p2[(int)2e5 + 10];
void preprocess(void) {
  p2[0] = 1;
  rep(i,1,2e5+10) {
    p2[i] = p2[i-1] * 2;
    p2[i] %= MOD;
  }
  return;
}

struct ft {
  vector<int> s;  //can also use map here
  ft(int n) : s(n) {}
  void resize(int n) {
    s.clear();
    s.resize(n);
  }
  void update(int pos, int dif) { // a[pos] += dif
    for (; pos < (int)s.size(); pos |= pos + 1) s[pos] += dif;
  }
  int query(int pos) { // sum of values in [0, pos)
    int res = 0;
    for (; pos > 0; pos &= pos - 1) res += s[pos-1];
    return res;
  }
  int query_r(int l, int r) {
    return query(r) - query(l);
  }
  /*
  int lower_bound(lli sum) {// min pos st sum of [0, pos] >= sum
    // returns n if no sum is >= sum, or -1 if empty sum is.
    if (sum <= 0) return -1;
    int pos = 0;
    for (int pw = 1 << 25; pw; pw >>= 1) {
      if (pos + pw <= sz(s) && s[pos + pw-1] < sum)
        pos += pw, sum -= s[pos-1];
    }
    return pos;
  }*/
};




int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int n; cin>>n;
  vector<pair<ii, int>> points;
  vector<vi> cnt(n, vi(4, 0));
  rep(i,0,n) {
    int x, y; cin>>x>>y;
    points.pb({{x, y}, i});
  }
  vi pp;
  rep(i,0,n) {
    pp.pb(points[i].fi.fi);
    pp.pb(points[i].fi.se);
  }
  sort(all(pp));
  map<int, int> mm;
  mm[pp[0]] = 0;
  rep(i,1,SZ(pp)) {
    if(pp[i] != pp[i-1]) mm[pp[i]] = mm[pp[i-1]] + 1;
  }
  rep(i,0,n) {
    points[i].fi.fi = mm[points[i].fi.fi];
    points[i].fi.se = mm[points[i].fi.se];
  }
  ft tree(SZ(pp)+10);
  debug(SZ(pp));
  debug(points);
  sort(all(points));
  rep(i,0,n) {
    auto p = points[i];
    cnt[i][0] = tree.query(p.fi.se);
    cnt[i][3] = tree.query_r(p.fi.se+1, SZ(pp)+10);
    tree.update(p.fi.se, 1);
  }
  tree.resize(SZ(pp)+10);
  for(int i = n-1; i>=0; i--) {
    auto p = points[i];
    cnt[i][1] = tree.query(p.fi.se);
    cnt[i][2] = tree.query_r(p.fi.se+1, SZ(pp)+10);
    tree.update(p.fi.se, 1);
  }
  debug(points, cnt);
  lli ans = 0;
  rep(i,0,n) {
    lli anss = p2[n]-1;
    rep(j,0,4) {
      anss -= (p2[cnt[i][j] + cnt[i][(j == 3)?0:(j+1)]]);
      anss += (p2[cnt[i][j]]);
      anss %= MOD;
      if(anss<0) anss += MOD;
    }
    debug(i, anss);
    ans = (ans + anss) % MOD;
  }
  cout<<ans<<endl;
}



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


vector<P> v;
double dist(double x1,double y1,double x2,double y2){
  double r=0;
  double x=abs(x1-x2);
  double y=abs(y1-y2);
  r=sqrt(x*x+y*y);
  return r;
}

double D(double x,double y){
  double r=0;
  rep(i,v.size()){
    r=max(r,dist(x,y,v[i].first,v[i].second));
   //cout<<r<<endl;
  }
  return r;
}

double g(double x){
  double l=0;
  double r=1500;
  rep(i,80){
    double c1=(2*l+r)/3;
    double c2=(l+2*r)/3;
    double d1=D(x,c1);
    double d2=D(x,c2);
  //  cout<<d1<<' '<<d2<<endl;
    if (d1>d2)l=c1;
    else r=c2;
  }
  return D(x,l);
}


int main(){
  double n;
  cin>>n;
  rep(i,n){
    double x1,y1;
    cin>>x1>>y1;
    P p=make_pair(x1,y1);
    v.push_back(p);

  }
//  cout<<D(1,2);
  double l=0;
  double r=1500;

  rep(i,80){
    double c1=(2*l+r)/3;
    double c2=(l+2*r)/3;
    double d1=g(c1);
    double d2=g(c2);
  //  cout<<d1<<' '<<d2<<endl;
    if (d1>d2)l=c1;
    else r=c2;
  }

  cout<<setprecision(10)<<g(l);

}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in range(min(n,k+1)):
  for j in range(min(n-i+1,k-i+1)):
    h=sorted(a[:i]+a[n-j:])[::-1]
    for _ in range(k-i-j):
      if h and h[-1]<0:h.pop()
    x=max(x,sum(h))
print(x)

Measured memory_bytes: 3064
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
#define     PI          3.141592653589793238462643383279502884L
 
 
int main()
{
	int N,i,t;
	cin >> N;

	while(1)
	{
		t = N%10;
		if(t==3)
		{
			cout << "bon" << endl;
			break;
		}
		else if(t==2||t==4||t==5||t==7||t==9)
		{
			cout << "hon" << endl;
			break;
		}
		else if(t==0||t==1||t==6||t==8)
		{
			cout << "pon" << endl;
			break;
		}
	}
    
    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define N 500002
struct edge{int to,nxxt;}e[N<<1];
vector<int>v[N];
int head[N],cnt=1,m,n,a[N],b[N],w[N],id[N],f[N];
bool vis[N];
ll sum[N],dp[N];
bool cmp(int x,int y){return w[x]<w[y];}
inline void ins(int u,int v)
{e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
int getroot(int t){return f[t]==0?t:f[t]=getroot(f[t]);}
void dfs(int te)
{sum[te]=b[te];
	for(int i=0;i<v[te].size();i++)
	{
		int j=v[te][i];dfs(j);sum[te]+=sum[j];
	}dp[te]=b[te]+w[te];if(!v[te].empty())dp[te]=1e18;
	for(int i=0;i<v[te].size();i++)
	{int j=v[te][i];
		dp[te]=min(dp[te],sum[te]-sum[j]+max(1ll*w[te],dp[j]));
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),w[i]=max(0,a[i]-b[i]);
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y),ins(y,x);
	}
	for(int i=1;i<=n;i++)id[i]=i;
	sort(id+1,id+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		int x=id[i];
		for(int j=head[x];j;j=e[j].nxxt)
		{
			int y=e[j].to;
			int yy=getroot(y);
			if(x!=yy&&vis[yy])
			{
				f[yy]=x;
				v[x].push_back(yy);
			}
		}vis[x]=1;
	}dfs(id[n]);
	printf("%lld\n",dp[id[n]]);
}


Measured memory_bytes: 25996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll q,h,s,d;
  ll n;
  cin>>q>>h>>s>>d;
  cin>>n;
  ll t=n/2;
  ll ans=8*q*t;
  ans=min(ans,4*h*t);
  ans=min(ans,2*s*t);
  ans=min(ans,d*t);
  if(n%2){
    ll tmp=s;
    tmp=min(tmp,2*h);
    tmp=min(tmp,4*q);
    ans+=tmp;
  }
 cout<<ans<<endl;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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; }

typedef long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int X;
    cin >> X;
    string ans = "NO";

    if(X == 7 || X == 5 || X == 3)
    {
        ans = "YES";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include<stdio.h>

int main(void){
 char s[120];
 long long int k,i;
scanf("%s",s);
scanf("%lld",&k);
for(i=0; i<k; i++){
 if(s[i] !='1'){
  printf("%c",s[i]);
  break;
 }  
 else if(s[i]=='1' &&i==k-1){
  printf("%c",s[i]);
 }
 
}
return 0;
}


Measured memory_bytes: 128
#include <iostream>
typedef long long LL;

int main() {
  LL N; std::cin >> N;
  if (N % 2 == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }

  LL count = 0;
  N = N/10;
  while (N>0) {
    count += N;
    N = N / 5LL;
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    return 0;
}


Measured memory_bytes: 256
S = list(input())
T = list(input())
ans = []
for i in range(len(S) - len(T) + 1):
    SS = S[i:i+len(T)]
    for j in range(len(T)):
        if SS[j] != T[j] and SS[j] != '?':
            break
    else:
        sfir = ''.join(S[:i])
        saft = ''.join(S[i+len(T):])
        sfir = sfir.replace('?', 'a')
        saft = saft.replace('?', 'a')
        ans.append(sfir+''.join(T)+saft)
    
if ans:
    print(sorted(ans)[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	static int N;
	static int M;
	static int[] A;
	public static int calc() {
		int ans=0;
		for(int i=0;i<M;i++) {
			ans+=A[i];
		}
		if(ans>N) {
			return -1;
		}
		else {
			return N-ans;
		}
	}
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		M=sc.nextInt();
		A=new int[M];
		for(int i=0;i<M;i++) {
			A[i]=sc.nextInt();
		}
		System.out.println(calc());
	}
}

Measured memory_bytes: 46124
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

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

////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5 + 10;

int n, m;
int h[N];
vector<int> adj[N];

int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	for(int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans = 0;
	for(int v = 1; v <= n; v++) {
		bool ok = true;
		for(int u : adj[v]) {
			if(h[u] >= h[v]) ok = false;
		}
		ans += ok;
	}
	cout << ans << '\n';


	return 0;
}


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

int INF = 1001001001;

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;
    vector<bool> ac(n, false);
    vector<int> wa(n);
    rep(i,m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") ac[p] = true;
        if (s == "WA") {
            if (!ac[p]) wa[p]++;
        } 
    }
    int ansac = 0, answa = 0;
    rep(i,n) {
        if (ac[i]) ansac++;
    }
    rep(i,n) {
        if (ac[i]) answa += wa[i];
    }
    printf("%d %d\n", ansac, answa);
    return 0;
}


Measured memory_bytes: 3748
program ABC062A
    implicit none
    integer(8)::x,y
    integer(8),dimension(12)::group=(/1,3,1,2,1,2,1,1,2,1,2,1/)
    read(5,*)x,y

    if(group(x)==group(y))then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if
end program ABC062A

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var dict = new Dictionary<char, int>();
            var answer = false;
            var l = -1;
            var r = -1;
            for (var i = 0; i < S.Length - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    answer = true;
                    l = i + 1;
                    r = i + 2;
                }
            }
            for (var i = 0; i < S.Length - 2; i++)
            {
                if (S[i] == S[i + 2])
                {
                    answer = true;
                    l = i + 1;
                    r = i + 3;
                }
            }

            Console.WriteLine($"{l} {r}");

        }
    }
}


Measured memory_bytes: 28136
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<pair<int, int>> v;
    string s;
    while(cin >> s)
    {
        if(s == "0,0") break;
        int idx = -1;
        for(int i = 0; i < s.size(); i++) if(s[i] == ',') idx  = i;
        int num = stoi(s.substr(0, idx));
        int score = stoi(s.substr(idx + 1));
        v.push_back(make_pair(score, num));
    }
    sort(v.begin(), v.end(), greater<pair<int, int>>());
    int val = 0, rank = 0;
    vector<int> result(110);
    for(int i = 0; i < v.size(); i++)
    {
        if(v[i].first != val)
        {
            rank++;
            val = v[i].first;
        }
        result[v[i].second] = rank;
    }
    int q;
    while(cin >> q)
    {
        cout << result[q] << endl;
    }
    return 0;
}




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

int main(){
  int N,count=0;
  string S;
  cin>>N>>S;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') count++;
  }
  cout<<count<<endl;
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 610;
int n, ans;
char a[N][N];

int main() {
	int i, j, k, f;
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%s", a[i]+1);
		rep(j, 1, n) a[i+n][j] = a[i][j+n] = a[i+n][j+n] = a[i][j];
	}
	//rep(i, 1, n+n) {rep(j, 1, n+n) printf("%c", a[i][j]); puts("");}
	rep(k, 1, n) {
		f = n+1-k;
		rep(i, 1, n) {
			rep(j, 1, n) {
				if(a[i+k-1][j] != a[j+k-1][i]) f = 0;
				if(!f) break;
			}
			if(!f) break;
		}
		ans += f;
	}
	rep(k, 2, n) {
		f = n+1-k;
		rep(i, 1, n) {
			rep(j, 1, n) {
				if(a[i][j+k-1] != a[j][i+k-1]) f = 0;
				if(!f) break;
			}
			if(!f) break;
		}
		ans += f;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<cstdio>
#include <iomanip>
#include <limits>
#include<vector>
using namespace std;

int main()
{
	int N, i, j, k, l, m, n, o, p;
	long long int sum, flag, cc, cnt;
	sum = 0;
	flag = 1;
	cc = 0;
	cnt = 0;
	cin >> N;
	vector<int>A(N);
	for (i = 0; i<N; i++) {
		cin >> A[i];
	}
	for (i = 0; i < N; i++) {
		sum += A[i]-1;
	}
	cout << sum << endl;


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
 
typedef pair<long long int,long long int>pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
 
# define  MAX 200005
long long int MOD=998244353;
long long int INF=1e18;
 
int main()
{
    
       ios_base::sync_with_stdio(false); 
       cin.tie(NULL);
     cout.tie(NULL);
      long long int i,j,k=0,l=0,r=0,m=0,n,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t;
cin>>n;
long long int A[n+1];
long long int B[n];
for(i=0;i<=n;i++)
{
    cin>>A[i];
} 

for(i=0;i<n;i++)
{
   cin>>B[i];
   if(B[i]>A[i])
   {
          cnt=cnt+A[i];
          B[i]=B[i]-A[i];
          l=min(B[i],A[i+1]);
          cnt=cnt+l;
          A[i+1]-=l;
   }
   else
   {
       
       cnt=cnt+B[i];
       A[i]=A[i]-B[i];
   }
}

cout<<cnt;

}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int check = N * 100;
		int x = (int) Math.floor(check / 108);
		int y = x + 1;

		int checkX = (int) Math.floor(x * 1.08);
		int checkY = (int) Math.floor(y * 1.08);

		if(N == checkX) {
			System.out.println(x);
		}else if(N == checkY) {
			System.out.println(y);
		}else {
			System.out.println(":(");
		}
	}

}

Measured memory_bytes: 22100
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;
typedef vector<P> Poly;
#define X real()
#define Y imag()
const double EPS = (1e-10);
const double INF = (1e15);

//2D version
namespace std{
  bool operator < (const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
  bool operator == (const P& a, const P& b){
    return abs(a-b) < EPS;
  }
}
double dot(P a, P b){
  return a.X * b.X + a.Y * b.Y;
}
double cross(P a, P b){
  return a.X * b.Y - a.Y * b.X;
}
P intersection(L a, L b){
  //直線aと直線bの交点
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return af + cross(bs-bf,af-bf)/(-cross(bs-bf,as-bf)+cross(bs-bf,af-bf))*(as-af);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < 0) return +2;
  if(abs(b) + EPS < abs(c)) return -2;
  return 0;
}

Poly convex_cut(Poly p, L l){
  Poly ret;
  int n = p.size();
  for(int i = 0; i < n; ++i){
    if(ccw(l.first, l.second, p[i]) != -1)
      ret.push_back(p[i]);
    if(ccw(l.first, l.second, p[i]) != -1 ^
       ccw(l.first, l.second, p[(i+1)%n]) != -1)
      ret.push_back(intersection(L(p[i], p[(i+1)%n]), l));
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  Poly Po;
  for(int i = 0; i < N; ++i){
    double x,y;
    cin >> x >> y;
    Po.emplace_back(x,y);
  }
  int M;
  cin >> M;
  Poly C;
  for(int i = 0; i < M; ++i){
    double x,y;
    cin >> x >> y;
    C.emplace_back(x,y);
  }
  double ans = 0;
  for(int i = 0; i < M; ++i){
    Poly Q = Po;
    for(int j = 0; j < M; ++j){
      if(j == i) continue;
      P m = (C[i]+C[j])/2.0;
      Q = convex_cut(Q,L(m,m+(C[j]-C[i])*P(0,1)));
    }
    for(size_t j = 0; j < Q.size(); ++j){
      ans = max(ans, abs(Q[j]-C[i]));
    }
  }
  printf("%.12f\n",ans);
  return 0;
}



Measured memory_bytes: 3356
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b, c,k;
	cin >> a >> b >> c >> k;
	ansYes(!(abs(c - a) > k && (abs(b - a) > k || abs(c - b) > k)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,p,x,d,a;
	while(cin>>n>>m>>p,n){
		int sum=0;
		for(int i=0;i<n;i++){
			cin>>x;
			if(i+1==m)d=x;
			sum+=x;
		}
		a=sum*100*(100-p)/100;
		if(d!=0)cout<<a/d<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>   
#include<string>
#include<vector>
using namespace std; 
 
int main()
{
	int a, b; 
	cin >> a >> b;
	if (a*b%2==1)
	{
		cout << "Yes" << "\n";
	} 
	else
	{
		cout << "No" << "\n";
	}


	
	
}

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

int main() {
	int n;
	cin >> n;
	uint64_t a[n];
	for(int i = 0;i< n;i++){
		cin >> a[i];
	}
	for(int i = 0; i < 33;i++){
		int counter = 0;
		for(int j = 0;j < n;j++){
			counter += (a[j] & 1); 
			a[j] >>= 1;
		}
		if(counter > 0){
			cout << i << endl;
			break;
		}
	}
	return 0;
}



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

using namespace std;

int main()
{
    int data_num;
    while (cin >> data_num && data_num != 0) {
        vector<int> idx;
        map<int, long long> sale;

        while (data_num--) {
            int no, price, num;
            cin >> no >> price >> num;

            long long sum = static_cast<long long>(price) * num;
            if (sale.find(no) == sale.end()) {
                idx.push_back(no);
                sale.insert(make_pair(no, sum));
            } else {
                sale.at(no) += sum;
            }
        }

        bool is_NA = true;
        for (size_t i = 0; i < idx.size(); i++) {
            if (sale.at(idx.at(i)) >= 1000000) {
                cout << idx.at(i) << endl;
                is_NA = false;
            }
        }

        if (is_NA) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1284
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: u32,
        b: u32,
    }
    println!("{}", (a+b-3)/(a-1));
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

  int n, ans = 0;
  char inp, old = '#';
  double clay, third;
  cin >> clay;
  third = clay / 3;
  cout << fixed << setprecision(12) << third * third * third;
  return 0;
}


Measured memory_bytes: 3780
using System;

class Program
{
  public static void Main(string[] args)
  {
    while(true)
    {
      string[] read = Console.ReadLine().Split(' ');
      int H = int.Parse(read[0]);
      int W = int.Parse(read[1]);
      if(H == 0 && W == 0) break;
      for(int i = 0;i < H;i++)
      {
        for(int j = 0;j < W;j++)
        {
          Console.Write("#");
        }
        Console.WriteLine();
      }
      Console.WriteLine();
    }
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<vi> cnt(n,vi(26));
    rep(i,n){
        string s; cin>>s;
        rep(j,s.size()) cnt[i][s[j]-'a']++;
    }
    string ans;
    rep(i,26){
        int c=100;
        rep(j,n) chmin(c,cnt[j][i]);
        rep(j,c) ans.pb(char(i+'a'));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
 
int main() {
int x;
cin >> x;
int ans;
if(400<=x&&x<600)ans = 8;
else if(x<800)ans=7;
else if(x<1000)ans = 6;
else if(x<1200)ans = 5;
else if(x<1400)ans = 4;
else if(x<1600)ans = 3;
else if(x<1800)ans = 2;
else if(x<2000)ans = 1;
cout << ans << endl;
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    map<int, int> M;
    set<int> ST;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int t; cin >>t;
        ST.insert(t);
        M[t]++;
    }
    for(auto e: ST){
        if(M[e] != 0 && M[e] < e) ans += M[e];
        if(M[e] > e) ans += M[e] - e;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 9600
def resolve():
  n = int(input())
  p = list(map(int, input().split()))

  prev = False
  ans = 0
  for i in range(n):
    if i == p[i]-1:
      if (prev):
        prev = False
      else:
        ans += 1
        prev = True
    else:
      prev = False

  print(ans)

  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 14008