akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int rm=700;
	rep(i,3){
		char a;
		cin>>a;
		if(a=='o')rm+=100;
	}
	cout<<rm;
}

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long x,y,z;
	cin>>x>>y>>z;
	
	if(y>z){		long long a = x*(z);
		a/=y;
		long long b = x*(z-1);
		b/=y;
		cout<<max(a,b);
	}else {
		long long a = x*(y-1);
		a/=y;
		long long b = x*(y-2);
		b/=y;
		cout<<max(a,b);
}
}



Measured memory_bytes: 3632
sx, sy, tx, ty = map(int, input().split())
tx = tx - sx
ty = ty - sy
sx, sy = 0, 0

def move(x, y):
    if x == 1:
        print('R', end='')
    elif x == -1:
        print('L', end='')
    elif y == 1:
        print('U', end='')
    elif y == -1:
        print('D', end='')
    else:
        print('Something wrong')

# first loop
for i in range(tx):
    move(1, 0)      # right
for i in range(ty):
    move(0, 1)      # up
for i in range(tx):
    move(-1, 0)     # left
for i in range(ty):
    move(0, -1)     # down

# second loop
move(-1, 0)
for i in range(ty + 1):
    move(0, 1)
for i in range(tx + 1):
    move(1, 0)
move(0, -1)
move(1, 0)
for i in range(ty + 1):
    move(0, -1)
for i in range(tx + 1):
    move(-1, 0)
move(0, 1)
print()


Measured memory_bytes: 4468
#include<stdio.h>
int main()
{
	int x,y,s,p[10][10]={0},nou=0,nul=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		p[x][y]++;
		if(x!=0){
			p[x-1][y]++;
		}
		if(x<9){
			p[x+1][y]++;
		}
		if(y!=0){
			p[x][y-1]++;
		}
		if(y<9){
			p[x][y+1]++;
		}
		if(s!=1){
			if(x!=0){
				if(y!=0){
					p[x-1][y-1]++;
				}
				if(y<9){
					p[x-1][y+1]++;
					}

			}
			if(x<9){
				if(y!=0){
					p[x+1][y-1]++;
				}
				if(y<9){
					p[x+1][y+1]++;
				}
			}
		}
		if(s==3){
			if(x>2){
				p[x-2][y]++;
			}
			if(y>2){
				p[x][y-2]++;
			}


			if(x<8){
				p[x+2][y]++;
			}
			if(y<8){
				p[x][y+2]++;
			}
		}

	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(p[i][j]==0){
				nul++;
			}
			if(p[i][j]>nou){
				nou=p[i][j];
			}
		}
	}
	printf("%d\n%d\n",nul-1,nou);
	return 0;
}

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

int main (){

    int N,ans=0;
    cin >> N;
    int s[N];
    for(int i = 0; i < N; i++) {
        cin >> s[i];
        ans += s[i];
    }

    if(ans % 10 != 0) {
        cout << ans << endl;
        return 0;
    }else {
        sort(s,s+N);
        for(int i = 0; i < N; i++) {
            if(s[i] % 10 != 0) {
                cout << ans - s[i] << endl;
                return 0;
            }
        }
    }

    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
readInt() = parse(Int,readline())

function solve()
    ans = 0
    N = readInt()
    f = fill(0, N)
    for i in 1:N
        j = i
        while j <= N
            f[j] += 1
            j += i
        end
    end
    for i in 1:N
        ans += i*f[i]
    end
    println(ans)
end

solve()

Measured memory_bytes: 236688
#include<iostream>

using namespace std;

int main(){
    int n,m=0,a[10000],ans =0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        for(int k=i+1;k<n;k++){
            ans += a[i] * a[k];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;
}


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

#define INF 1000000001

using namespace std;

int partition(pair<char,int> a[],int p,int r){
  int x=a[r].second;
  int i=p-1;
  for(int j=p;j<r;j++){
    if(a[j].second<=x){
      i++;
      swap(a[i],a[j]);
    }
  }
  swap(a[i+1],a[r]);
  return i+1;
}

void quicksort(pair<char,int> a[],int p,int r){
  if(p<r){
    int q=partition(a,p,r);
    quicksort(a,p,q-1);
    quicksort(a,q+1,r);
  }
}

void merge(pair<char,int> a[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  pair<char,int> L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++) L[i]=a[left+i];
  for(int i=0;i<n2;i++) R[i]=a[mid+i];
  L[n1].second=INF; R[n2].second=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i].second<=R[j].second){
      a[k]=L[i];
      i++;
    }else{
      a[k]=R[j];
      j++;
    }
  }
}

void mergeSort(pair<char,int> a[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}

int main(){
  int n; cin >> n;
  pair<char,int> a[n],b[n];
  for(int i=0;i<n;i++){
    char c; cin >> c;
    int x; cin >> x;
    a[i]=make_pair(c,x);
    b[i]=make_pair(c,x);
  }
  quicksort(a,0,n-1);
  mergeSort(b,0,n);
  bool isStable=true;
  for(int i=0;i<n;i++){
    if(a[i].first != b[i].first){
      isStable=false;
      break;
    }
  }
  if(isStable) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i=0;i<n;i++)
    cout << a[i].first << " " << a[i].second << endl;
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define sz(x) (x).size()
#define lowbit(x) (x)&(-x)
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))

namespace FastIO {
#define BUF_SIZE 100000
#define OUT_SIZE 100000
	bool IOerror=0;
	inline char nc() {
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if(p1==pend) {
			p1=buf;
			pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if(pend==p1) {
				IOerror=1;
				return -1;
			}
		}
		return *p1++;
	}
	inline bool blank(char ch) {
		return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';
	}
	template<class T> inline bool read(T &x) {
		bool sign=0;
		char ch=nc();
		x=0;
		for(; blank(ch); ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(; ch>='0'&&ch<='9'; ch=nc())x=x*10+ch-'0';
		if(sign)x=-x;
		return true;
	}
	template<class T,class... U>bool read(T& h,U&... t) {
		return read(h)&&read(t...);
	}
#undef OUT_SIZE
#undef BUF_SIZE
};
using namespace std;
using namespace FastIO;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const int N = 1e6+10;

int siz[N],cnt[N],f[N];

int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
} 

int main() {

#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++) f[i]=i,siz[i]=1;
	while(m--){
		int u,v;
		cin>>u>>v;
		int t1=find(u);
		int t2=find(v);
		cnt[u]++;
		cnt[v]++;
		if(t1!=t2){
			f[t2]=t1;
			siz[t1]+=siz[t2];
		}
	}
	while(k--){
		int u,v;
		cin>>u>>v;
		if(find(u)==find(v)) cnt[u]++,cnt[v]++;
	}
	for(int i=1;i<=n;i++) cout<<siz[find(i)]-cnt[i]-1<<" ";
	




	return 0;
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
    }

    int min_cost = n + 1;
    vector<int> vs;
    for (int i = 0; i < n; i++) {
        vector<int> d(n, n);
        vector<int> p(n, -1);
        d[i] = 0;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int cur = q.front();
            q.pop();
            for (int nex : g[cur]) {
                if (d[nex] < n) continue;
                d[nex] = d[cur] + 1;
                p[nex] = cur;
                q.push(nex);
            }
        }

        for (int j = 0; j < n; j++) {
            if (j == i || d[j] >= n) continue;
            for (int k : g[j]) {
                if (k != i) continue;
                if (min_cost > d[j] + 1) {
                    min_cost = d[j] + 1;
                    vs.clear();
                    int tmp = j;
                    while (tmp != -1) {
                        vs.push_back(tmp);
                        tmp = p[tmp];
                    }
                    break;
                }
            }
        }
    }
    reverse(vs.begin(), vs.end());
    
    int sz = vs.size();
    if (sz == 0) {
        cout << -1 << "\n";
        return 0;
    }
    vs.push_back(vs.front());
    vector<int> used(n, false);
    for (int i : vs) used[i] = true;
    bool f = true;
    for (int i = 0; i < sz; i++) {
        for (int nex : g[vs[i]]) {
            if (nex == vs[i + 1]) continue;
            if (!used[nex]) continue;
            f = false;
            break;
        }
        if (!f) break;
    }

    if (f) {
        cout << sz << "\n";
        for (int i = 0; i < sz; i++) {
            cout << vs[i] + 1 << "\n";
        }
    } else {
        cout << -1 << "\n";
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MAX_N = 100;

ll n, x;

int main(int argc, char const *argv[]) {
  cin >> n >> x;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  if (x < a[0]) ans = 0;
  else {
    ll lastidx = 0;
    for (ll i = 0; i < n; i++) {
      lastidx = i;
      if (x<a[i]) {
        lastidx--;
        break;
      }
      else {
        x -= a[i];
        ans++;
      }
    }
    if (lastidx+1 == n && x>0) ans--;
  }
  cout << ans << endl;
  return 0;
}


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

#define MAX 501

int main(){
  int H, W;
  char field[MAX][MAX];
  int area[MAX][MAX];

  while(cin >> H >> W){
    if(H == 0 && W == 0) break;
    
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> field[i][j];
      }
    }

    for(int i = 0 ; i < H ; i++){
      int x = 1;
      for(int j = W-1 ; j >= 0 ; j--){
	if(field[i][j] == '.'){
	  area[i][j] = x;
	  x++;
	}
	else{
	  area[i][j] = 0;
	  x = 1;
	}
      }
    }

    /*for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	printf("%2d ", area[i][j]);
      }
      cout << endl;
      }*/

    int ans = 0;
    
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	if(i < 0 && area[i][j] == area[i-1][j] || area[i][j] == 0) continue;
	int h = 1;
	int tmp = area[i][j];
	ans = max(ans, h*tmp);
	
	while(i+h < H && area[i+h][j] != 0){
	  tmp = min(tmp, area[i+h][j]);
	  h++;
	  ans = max(ans, h*tmp);
	}
      }
    }

    cout << ans << endl;
  }
}

  

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
    string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)

  int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/
//126~
//126-e

int main() {

    ll N, count=0, ans=0;
    string S;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    N= max(a*c,b*d);
    N=max(N,a*d);
    N=max(N,b*c);

    cout << N << endl;
}



Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

//コンビネーションをmodで割った余りを産出
int64_t nCk( int64_t n, int64_t k  )
{
    int64_t ans_x = 1;
    int64_t ans_y = 1;

    for( int i = n; i > n - k; i-- )
    {
        ans_x *= i;
    }

    for( int i = 1; i <= k; i++ )
    {
        ans_y *= i;
    }

    return ans_x / ans_y;
}

int main()
{
    std::string word = "aa";
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;

    std::vector< int64_t > list1( 200003 );
    std::vector< int64_t > list3( 200003 );
    std::vector< int64_t > list2;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> b;
        list1[b] += 1;
        list2.push_back( b );
    }

    c = 0;
    
    for( int i = 0; i < list1.size(); i++ )
    {
        if( list1[i] != 0 )
        {
            list3[i] = nCk( list1[i], 2 );
            c += list3[i];
        }
    }

    for( int i = 0; i < a; i++ )
    {
        d = c;
        d -= list3[list2[i]];
        d += nCk( list1[list2[i]] - 1, 2 );
        std::cout<< d <<"\n";
    }
}


Measured memory_bytes: 7408
package main

import "fmt"

type stack struct {
	data []byte
}

func (s *stack) push(b byte) {
	s.data = append(s.data, b)
}
func (s *stack) pop(b *byte) bool {
	if len(s.data) > 0 {
		*b = s.data[len(s.data)-1]
		s.data = s.data[:len(s.data)-1]
		return true
	}
	return false
}
func (s *stack) peek(b *byte) bool {
	if len(s.data) > 0 {
		*b = s.data[len(s.data)-1]
		return true
	}
	return false
}

func main() {
	var s string
	fmt.Scan(&s)
	var stack stack
	for i := 0; i < len(s); i++ {
		if s[i] == 'S' {
			stack.push(s[i])
		} else { // s[i] == 'T'
			var b, t byte
			if stack.peek(&b) && b == 'S' {
				stack.pop(&t)
			} else {
				stack.push(s[i])
			}
		}
	}
	fmt.Println(len(stack.data))
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b;
    cin >> n >> a >> b;
    VLL x(n);
    rep(i,n) cin >> x[i];

    VLL dist(n-1,0);
    FOR(i,1,n){
      dist[i-1] = (x[i] - x[i-1]) * a;
    }

    ll ans = 0;
    rep(i,dist.size()){
      ans += min(dist[i],b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

priority_queue<ll>ans;
int main() {
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	vector<ll>A,B,C;
	for(ll i=0;i<a;i++){
		ll x;
		cin>>x;
		A.push_back(x);
	}
	for(ll i=0;i<b;i++){
		ll x;
		cin>>x;
		B.push_back(x);
	}
	for(ll i=0;i<c;i++){
		ll x;
		cin>>x;
		C.push_back(x);
	}
	sort(A.begin(),A.end());
	reverse(A.begin(),A.end());
	sort(B.begin(),B.end());
	reverse(B.begin(),B.end());
	sort(C.begin(),C.end());
	reverse(C.begin(),C.end());
	for(ll i=0;i<a;i++){
		for(ll j=0;j<b;j++){
			for(ll k=0;k<c;k++){
				ll sum=A[i]+B[j]+C[k];
				sum*=-1;
				//cout << sum<<endl;
				if(ans.size()>=3000){
					ll ch=ans.top();
					if(sum>ch){
						break;
					}
					ans.pop();
					ans.push(sum);
				}
				else{
					ans.push(sum);
				}
			}
		}
	}
	vector<ll>ans1;
	ll p=ans.size();
	for(ll i=0;i<p;i++){
		ll now=ans.top();
		//cout << now<<endl;
		ans.pop();
		ans1.push_back(now);
	}
	sort(ans1.begin(),ans1.end());
	for(ll i=0;i<k;i++){
		cout << abs(ans1[i])<<endl;
	}
	// your code goes here
	return 0;
}

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

int main(){
  int n = 6,a;
  vector<int> v(4,0);
  while(n--){
    cin >> a;
    v.at(a-1)++;
  }
  sort(v.begin(),v.end());
  if(v.at(0)==1&&v.at(1)==1&&v.at(2)==2&&v.at(3)==2)cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,r,l;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (r == l) {
    cout << "Balanced" << endl;
  } else if (r > l) {
    cout << "Right" << endl;
  } else if (l > r) {
    cout << "Left" << endl;
  }
}

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

int main() {
	string s,ans="Yes";
	cin >> s;
    

    rep(i,s.size()){
        if(i%2==0&&s[i]=='L'){
            ans="No";
            break;
        }
        if(i%2==1&&s[i]=='R'){
            ans="No";
            break;
        }
    }
    
	cout << ans<< endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

// #define int long long

int N, X, Y;


signed main(){
    cin>>N>>X>>Y;

    vector<int> res(N, 0);

    int phase = 0;
    X--;
    Y--;
    int gap = Y - X;

    for(int i=0; i<N; ++i) {
        for(int j=i+1; j<N; ++j) {
            int d;
            if (j <= X) {
                d = j-i;
                // if(d==2){
                //     cout<<i<<", "<<j<<endl;
                // }
            } else if(i <=X && j >= Y) {
                d = j - i - gap +1;
                // if(d==2){
                //     cout<<i<<", "<<j<<endl;
                // }
            } else if (i <=X) {
                int d1 = j - i;
                int d2 = (X - i) + 1 + (Y - j);
                d = min(d1, d2);

            } else if (i > X) {
                int d1 = j - i;
                int d2 = (i - X) + 1 + abs(Y - j);
                d = min(d1, d2);
            } else {
                d = j - i;
                // if(d==2){
                //     cout<<i<<", "<<j<<endl;
                // }
            }
            // cout<<i<<", "<<j<<", "<<d<<endl;
            res[d]++;
        }
    }
    for(int i=1; i<N; ++i) {
        cout<<res[i]<<endl;
    }
    
    return 0;
}

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

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var canMove = new long[5];
        for (int i = 0; i < 5; i++)
        {
            canMove[i] = CRL().ToInt();
        }

        var count = (long)Math.Ceiling(1.0 * n / canMove.Min()) + 4;
        CWL(count);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    //テンプレここまで
}


Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string n;
	cin >> n;
	if (n[0] == n[2]) cout << "Yes\n";
	else cout << "No\n";
	getchar(); getchar();
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, k; cin>>n>>k;
    if(k%2==1){
        cout << (ll)pow(n/k, 3) << endl;
    }
    else{
        int cnt=n/k;
        int cnt2=0;
        for(int i=1; i<=n; i++){
            if(i%k==k/2) cnt2++;
        }
        //cout << cnt2 << endl;
        cout << (ll)pow(cnt, 3)+(ll)pow(cnt2, 3) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
const int p = 1000005;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int now = 0;
	for (auto c : s) now += c - '0';
	cout << (now % 9 == 0 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fin(x) freopen(x,"r",stdin)
#define fout(x) freopen(x,"w",stdout)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll inf=0xc0c0c0c0c0c0c0c0;
const double pi=acos(-1);
const int MAXM=1e5+7;
typedef map<int,int>::iterator IT;
int N,M,cnt;
map<int,int> tool[MAXM];
int odd[MAXM],pir[MAXM];
void solve(int a,int b)
{
	if(odd[a]>odd[b])
	{
		swap(odd[a],odd[b]);
		swap(pir[a],pir[b]);
	}
	int left=odd[b]-odd[a];
	int k=min(left>>1,pir[a]);
	odd[a]+=k<<1;
	pir[a]-=k;
	cnt+=odd[a];
	cnt+=pir[b]+pir[a];
}
void solve(int x)
{
	cnt+=pir[x];
	cnt+=odd[x]>>1;
}

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)
	{
		int x;
		scanf("%d",&x);
		tool[x%M][x]++;
	}
	for(int i=0;i<M;i++)
	{
		for(IT it=tool[i].begin();it!=tool[i].end();it++)
		{
			pir[i]+=it->se>>1;
			if(it->se&1)
			{
				it->se--;
				odd[i]++;
			}
		}
	}
	cnt=0;
	solve(0);
	if((M&1)==0)solve(M>>1);
	for(int i=1;i<=((M-1)>>1);i++)
		solve(i,M-i);
	
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 10368
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] l = na(n);
		Arrays.sort(l);
		//Arrays.stream(l).forEach(v -> System.out.println(v));
		int result = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				for(int k = j + 1; k < n; k++) {
					if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
						result++;
					}else {
						break;
					}
				}
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

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


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

using namespace std;

int main(void) {
    int N, T;
    cin >> N >> T;
    vector<int> A(N+2), B(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i] >> B[i];
    }

    vector< vector<int> > dp1(N+2, vector<int>(T));
    for(int i=1; i<=N; i++) {
        for(int t=0; t<T; t++) {
            if(t-A[i] < 0) {
                dp1[i][t] = dp1[i-1][t];
            } else {
                dp1[i][t] = max(dp1[i-1][t], dp1[i-1][t-A[i]]+B[i]);
            }
        }
    }

    vector< vector<int> > dp2(N+2, vector<int>(T));
    for(int i=N; i; i--) {
        for(int t=0; t<T; t++) {
            if(t-A[i] < 0) {
                dp2[i][t] = dp2[i+1][t];
            } else {
                dp2[i][t] = max(dp2[i+1][t], dp2[i+1][t-A[i]]+B[i]);
            }
        }
    }

    int ans = 0;
    for(int i=1; i<=N; i++) {
        int tmp = 0;
        for(int t=0; t<T; t++) {
            tmp = max(tmp, dp1[i-1][t] + dp2[i+1][T-1-t]);
        }
        ans = max(ans, tmp+B[i]);
    }

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


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


ll cnt[1000006];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        
        ll n;
        cin>>n;
        ll ar[n];
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
            sum^=ar[i];
        }
        for(int i=0;i<n;i++)
        {
            cout<<(sum^ar[i])<<" ";
        }
    }
    
    return 0;
}

Measured memory_bytes: 5204
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a, b, c;
	cin >> a >> b >> c;

	//lim入る
	int lim = a - b;

	if (lim > 0) {
		c -= lim;
	}

	if (c < 0) {
		c = 0;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{

  int A[250];
  int H, i;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2!=0){
      printf("parent key = %d, ",A[i/2]);
    }
    if(i*2<=H){
      printf("left key = %d, ",A[i*2]);
    }
    if(i*2+1<=H){
      printf("right key = %d, ",A[i*2+1]);
    }
    printf("\n");
  }

  return 0;

}




Measured memory_bytes: 2108
N,M = map(int,input().split())
xyz = [tuple(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(2**3):
    sign = [(-1)**((i >> j) & 1) for j in range(3)]
    s,t,u = sign
    xyz.sort(key=lambda x:s*x[0]+t*x[1]+u*x[2], reverse=True)
    s,t,u = 0,0,0
    for x,y,z in xyz[:M]:
        s += x
        t += y
        u += z
    ans = max(ans, abs(s)+abs(t)+abs(u))
print(ans)

Measured memory_bytes: 9348
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A, B;
  rd(A);
  rd(B);
  if(A+B==15){
    wt_L("+");
    putchar_unlocked('\n');
  }
  else if(A*B==15){
    wt_L("*");
    putchar_unlocked('\n');
  }
  else{
    wt_L("x");
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20180707-1 [beta]

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   if(A+B==15){
//     wt("+");
//   } else if(A*B==15){
//     wt("*");
//   } else {
//     wt("x");
//   }
// }


Measured memory_bytes: 764
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5 + 5;
string s;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	int a, b;
	cin >> a >> b;
	string t, s;
	int ans = 0;
	for(int i = a; i <= b; ++i){
		t = to_string(i);
		s = t;
		reverse(t.begin(), t.end());
		if(s == t){
			++ans;
		}
	}
	cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,a[1000],i,j=0;
    scanf("%d",&n);
    for(i=n;i>0;i--){
        scanf("%d",&a[j]);
        j++;
    }
    for(i=j-1;i>0;i--){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[0]);
    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int res=0;
    for(int i=0;i<s.length();i++)
    {
        string str(1,s[i]);
        int a=stoi(str);
        res+=a;
    }
    if(res%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
} 

Measured memory_bytes: 3696
-- Array - Matrix Vector Multiplication

import Control.Applicative

main :: IO ()
main = do
  [n, _] <- map read . words <$> getLine
  (a, b) <- splitAt n . map (map read . words) . lines <$> getContents
  mapM_ (print . (\x -> sum $ zipWith (*) x (concat b))) a



Measured memory_bytes: 7452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_151
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            char c = Read()[0];
            WriteLine((char)(c + 1));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	vector<string> s(n);
	vector<lli> t(n);
	REP(i,0,n)cin>>s[i]>>t[i];

	string u;
	cin>>u;

	lli sum = 0;
	bool state=false;
	REP(i,0,n){
		if(state)sum+=t[i];
		if(s[i]==u)state=true;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
import math
import itertools
import sys

prime_numbers = set()
table = [0 for i in range(10 ** 5 + 1)]
input = lambda: sys.stdin.readline().strip()


def is_primenumber(x):
    if x in prime_numbers:
        return True
    if x == 1:
        return False
    elif x == 2:
        prime_numbers.add(2)
        return True
    else:
        for i in range(2, int(math.sqrt(x)) + 1):
            if x % i == 0:
                return False
        prime_numbers.add(x)
        return True


def is_like_2017(x):
    return is_primenumber(x) and is_primenumber((x + 1) // 2)


def query(l, r):
    print(table[r] - table[l - 1])


if __name__ == "__main__":
    for i in range(1, 10 ** 5 + 1, 2):
        if is_like_2017(i):
            table[i] += 1
    table = [x for x in itertools.accumulate(table)]
    Q = int(input())

    for _ in range(Q):
        l, r = [int(x) for x in input().split(" ")]
        query(l, r)


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	int count=0;
	for(int i=0 ; i<n ; i++){
	   if(a[i]==b[i] && a[i]!=c[i]){c[i]=a[i];count++;}
	   if(a[i]==c[i] && a[i]!=b[i]){b[i]=a[i];count++;}
	   if(b[i]==c[i] && b[i]!=a[i]){a[i]=b[i];count++;}
	   if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i])count+=2;
	}
	cout<<count;
	
	return 0;
}


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

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

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

int main(void)
{
	ll n, m;
	cin >> n >> m;
	priority_queue <ll, vector<ll>, less<ll>> q;

	rep(i, n) {
		ll a; cin >> a;
		q.push(a);
	}
	rep(i, m) {
		auto t = q.top(); q.pop();
		q.push(t / 2);
	}
	ll sum = 0;
	while (!q.empty()) {
		sum += q.top(); q.pop();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/


using namespace std;

const int N=1e5+5;

int n,a[N],mx;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)cin>>a[i];
    a[0]--;
    for (int i=1;i<n-1;i++)
    {
        if (a[i]==a[i-1])continue;
        if (a[i]-a[i+1]==1||(a[i]<=a[i+1]))a[i]--;
    }
    for (int i=1;i<n;i++)
    {
        if (a[i]<a[i-1]){cout << "No\n";return 0;}
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 4000;
const int MAXM = 1e5;
double dp[MAXN][MAXN];//dp[i][j]代表总共i个head,拿j个head 
double p[MAXN]; 
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j>0) dp[i][j]+=dp[i-1][j-1]*p[i];
			if(j<i) dp[i][j]+=dp[i-1][j]*(1-p[i]); 
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++) ans+=dp[n][i];
	printf("%.15lf\n",ans);
	return 0;
}



Measured memory_bytes: 92672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll req=0;
    while( (req*(req+1))/2 < n )req++;
    set<ll , greater<ll> >st;
    for(ll i=1;i<=req;i++)st.insert(i);

    vector<ll> a;
    while(n){
        if(st.count(n)){
            a.push_back(n);
            n=0;
            st.erase(n);
        }
        else{
            n-=(*st.begin());
            a.push_back(*st.begin());
            st.erase(st.begin());
        }
    }
    for(auto &ele:a)cout<<ele<<"\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	int tmp;
	vector<int> V;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	int num_query;
	scanf("%d",&num_query);

	int loc;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&tmp);

		loc = lower_bound(V.begin(),V.end(),tmp)-V.begin();

		if(loc != (int)V.size() && V[loc] == tmp){

			printf("1\n");

		}else{

			printf("0\n");
		}
	}

	return 0;
}



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

int main() {
  int k; std::cin >> k;
  std::string s; std::cin >> s;
  if (s.length() <= k) std::cout << s << std::endl;
  else std::cout << s.substr(0, k) << "..." << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    int ct = 0;
    bool ok = false;
    rep(i,N){
        if(p[i] == i+1){
            if(ok)ok = false;
            else{
                ok = true;
                ct++;
            }
        }
        else{
            ok = false;
        }
    }
    cout << ct << endl;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n, k; cin >> n >> k;
	string s; cin >> s;

	//transform(s.begin(), s.end(), s.begin(), tolower);
	for(int i = 0, i_len = n; i < i_len; ++i){
		if(i == k-1){
			cout << (char)tolower(s[k-1]);
		}
		else
		cout << s[i];
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : a) {
            if (map.containsKey(num)) {
                map.put(num, map.get(num) + 1);
            } else {
                map.put(num, 1);
            }
        }

        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int key : map.keySet()) {
            pq.add(map.get(key));
        }

        int result = 0;
        while (k < pq.size()) {
            result += pq.poll();
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 67164
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct fox {
	ll X, H;
	bool operator < (const fox& b) const {
		return X < b.X;
	}
};
fox F[200010];
int range[200010];
ll damage[200010];
int main()
{
	ll N, D, A;
	cin >> N >> D >> A;
	for (int i = 0; i < N; i++) {
		cin >> F[i].X >> F[i].H;
	}
	sort(F, F + N);
	int j = 0;
	for (int i = 0; i < N; i++) {
		while (F[j].X <= F[i].X + D * 2) {
			if (j == N) break;
			j++;
		}
		//cout << j << endl;
		range[i] = j;
	}
	ll ans = 0;
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += damage[i];
		F[i].H = max(0ll, F[i].H - sum);
		ans += (F[i].H + A - 1) / A;
		sum += (F[i].H + A - 1) / A * A;
		//cout << sum << " " << damage[i + 1] << endl;
		damage[range[i]] -= (F[i].H + A - 1) / A * A;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5760
#include<iostream>



using namespace std;

int main()
{
	
	int A[10000], N, Output = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i <= N; i++) {
		for (int x = 0; x <= N - 1; x++) {
			if (A[i] - A[x] > Output) {
				Output = A[i] - A[x];
			}
			
		}
	}
	cout << Output;

	return 0;

}


Measured memory_bytes: 256
N, M = [int(a) for a in input().split(" ")]
X = sorted([int(a) for a in input().split(" ")])
intervals = sorted([a-b for a, b in zip(X[1:], X[:-1])])[::-1]
if M > N:
    print(sum(intervals) - sum(intervals[:N-1]))
else:
    print(0)

Measured memory_bytes: 60328
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pri 1000000007
#define PB push_back
#define MP make_pair
using namespace std;

void run(){
 ll h,w;
 cin>>h>>w;
 string a[h];
 ll ans[h][w];
 for(ll i=0;i<h;i++){
 	cin>>a[i];
 	for(ll j=0;j<w;j++){
 		ans[i][j]=0;
 	}
 }
 if(a[0][0]!='#')ans[0][0]=1;
 for(ll i=0;i<h;i++){
 	for(ll j=0;j<w;j++){
 	    if(i==0&&j==0)continue;
 		ans[i][j]=((i>=1?ans[i-1][j]:0)+(j>=1?ans[i][j-1]:0))%pri;
        if(a[i][j]=='#')ans[i][j]=0;
     //   cout<<ans[i][j]<<" ";
 	}
 //	cout<<endl;
 }
 cout<<(ans[h-1][w-1])%pri<<endl;
 }
 
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll N, X;
    cin >> N >> X;
    vector<ll>v(N);
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        cin >> v[i];
        ans++;
        X -= v[i];
    }
    sort(v.begin(), v.end());
    while(X >= v[0]){
        X -= v[0];
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

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

const int MAXN = 200005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T& a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T& a, T b){if(b>a)a=b;}


int main(){
    double r;cin>>r;
    cout<<acos(-1.0)*2*r<<endl;

    return 0;
}


Measured memory_bytes: 3788
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
S={SR() for _ in range(N)}

print(len(S))




Measured memory_bytes: 31476
#include<stdio.h>
#include <stdlib.h>

 int main(){
   unsigned short *a, *b;
   int n, i, j,u=0,x,m,p;

   scanf("%d", &n);

   a = malloc(sizeof(short)*n+1);
   for(i=1;i<n+1;i++){
     scanf("%hu",&a[i]);
   }

   x=a[n];
   u = 1;
   /*for( j = 1 ;j< n;j++){
     if( a[j] <= x){
       u++;
       m=a[u];
       a[u]=a[j];
       a[j]=m;
   }
       m=a[u+1];
       a[u+1]=a[n];
       a[n]=m;

       for(i=1;i<n+1;i++){
         if(i>1){
           printf(" ");
         }
       printf("%d",a[i]);
       }
       printf("\n");

     }*/

     for( j = 1 ;j< n+1;j++){
       if(j==n){
         p=u+1;
       }
       if( a[j] <= x){
         m=a[u];
         a[u]=a[j];
         a[j]=m;
         u++;
     }
   }

   for(i=1;i<n+1;i++){
     if(i>1){
       printf(" ");
     }
     if(i==u-1){
       printf("[%d]",a[u-1]);
       continue;
     }
   printf("%d",a[i]);
 }
 printf("\n");
 }



Measured memory_bytes: 2148