akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vll a(n);
    ll num = n*(n+1)/2;
    vll aa(num);
    ll id = 0;
    vll sum(n+1,0);
    REP(i,n){
        cin >> a[i];
        sum[i+1] = sum[i]+a[i];
    }
    REP(i,n){
        for(int j=i;j<n;++j){
            aa[id] = sum[j+1]-sum[i];
            id++;
        }
    }
    vvll ab(num,vll(40,0));
    REP(i,num){
        ll t = aa[i];
        ll now = 0;
        while(t>0){
            ab[i][now] = (t&1);
            now++;
            t >>= 1;
        }
    }
    ll ans  = 0;
    vvll use(num,vll(40, 1));
    for(ll i = 38;i>=0;--i){
        ans <<= 1;
        ll cnt = 0;
        REP(j,num){
            if(ab[j][i]==1&&use[j][i+1]==1){
                cnt++;
            }
        }
        if(cnt>=k){
            REP(j,num){
                if(ab[j][i]==1&&use[j][i+1]==1){
                    use[j][i]=1;
                }else{
                    use[j][i]=0;
                }
            }
            ans+=1;
        }else{
            REP(j,num){
                use[j][i] = use[j][i+1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 356096
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#pragma GCC optimize ("Ofast")
int main()
{
    start;
    int n,m,j,i;
    cin>>n;
    m=n%1000;
    if(m!=0)
    cout<<1000-m<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int N=205;
int n;
int query(const vector<int>&A)
{
	cout<<"? ";
	for(int u:A)
		cout<<u<<" ";
	cout<<endl;
	string s;
	cin>>s;
	if(s=="Red") return 1;
	else if(s=="Blue") return 0;
	else return -1;
}
vector<int> build(int l,int r)
{
	vector<int>res;
	for(int i=l;i<=r;i++)
		res.push_back(i);
	return res;
}
vector<int> operator+(const vector<int>&a,const vector<int>&b)
{
	vector<int>res;
	for(int u:a)
		res.push_back(u);
	for(int u:b)
		res.push_back(u);
	return res;
}
char ans[N];
int res[N];
int get(int u)
{
	if(res[u]!=-1) return res[u];
	else return res[u]=query(build(u,u+n-1));
}
int main()
{
	cin>>n;
	int l=1,r=n+1;
	memset(res,-1,sizeof(res));
	while(l<r-1)
	{
		int mid=(l+r)/2;
		auto check=[=](int x)->bool{return get(l)==get(x);};
		if(check(mid)) l=mid;
		else r=mid;
	}
	int L=l+1,R=l+n-1;
	vector<int>add=build(L,R);
	vector<int>posr,posb;
	for(int i=1;i<=L-1;i++)
		if(query((vector<int>){i}+add)) ans[i]='R',posr.push_back(i);
		else ans[i]='B',posb.push_back(i);
	for(int i=R+1;i<=n*2;i++)
		if(query(add+(vector<int>){i})) ans[i]='R',posr.push_back(i);
		else ans[i]='B',posb.push_back(i);
	vector<int>q;
	for(int i=0;i<n/2;i++)
		q.push_back(posr[i]),q.push_back(posb[i]);
	for(int i=L;i<=R;i++)
		if(query(q+(vector<int>){i})) ans[i]='R';
		else ans[i]='B';
	cout<<"! ";
	for(int i=1;i<=n*2;i++)
		cout<<ans[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

int main() {
	unsigned long long x, y;
	std::vector<int> num = {};
	cin >> x >> y;
	for (unsigned long long int i = x; i <= y; i *= 2) {
		num.push_back(1);
	}
	cout << num.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n - 1) cin >> c[i];
  int ans = 0;
  ans += b[a[0] - 1];
  for(int i = 1; i < n; ++i){
    ans += b[a[i] - 1];
    if(a[i - 1] == a[i] - 1){
      ans += c[a[i - 1] - 1];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

for i in sys.stdin:
    h,w = map(int,i.split())

    if h==0 and w==0:
        break

    for i in range(h):
        str = ''
        for j in range(w):
            if (i+j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print()

Measured memory_bytes: 7644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            ll m=last[t];
            last[t]=i+1;
            rep(j,26){
                cn-=c[j]*(i-last[j]+1);
            }
            last[t]=m;
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        ans+=ma;
        last[idx]=i+1;
        v[i]=idx+1;
    }
    vector<pair<ll,pll> >q(0);
    rep(i,d){
        rep(j,26){
            q.pb(mp(c[j]*s[i][j],mp(i,j)));
        }
    }
    sort(rall(q));
    ll m=10000;
    rep(o,m){
        vector<ll>vv(d);
        rep(j,d)vv[j]=v[j];
        rep(i,20){
            ll ran=rand()%100;
            ll a=q[ran].second.first,b=q[ran].second.second;
            vv[a]=b+1;
        }
        ll cnt=0;
        vector<ll>la(26);
        rep(i,d){
            ll t=vv[i]-1;
            cnt+=s[i][t];
            la[t]=i+1;
            rep(j,26){
                cnt-=c[j]*(i-la[j]+1);
            }
        }
        if(ans<cnt){
            cnt=ans;
            rep(j,d){
                v[j]=vv[j];
            }
        }
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3988
n, k = map(int, input().split())
a = tuple(map(int, input().split()))
ans = a[n - 1] - a[0] + abs(a[0])
for i in range(n - k + 1):
    r = i + k - 1
    ans = min(ans, abs(a[i]) + a[r] - a[i], abs(a[r]) + a[r] - a[i])
print(ans)


Measured memory_bytes: 14988
line = input()
numbers = line.split(" ")
w, h, x, y = int(numbers[0]), int(numbers[1]), int(numbers[2]), int(numbers[3])
area = float(w*h/2)
print(str(area), end=" ")
if x == w/2 and y == h/2:
  print("1")
else:
  print("0")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, ans = 0;
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] != t[i])
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;++i)
#define fi(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define po pop_back
using namespace std;
#define M 1000000
std::bitset<M+1> bits;
void swap(int *a,int *b){
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
void input(vector<int>& arr,int n){
    fo(i,0,n-1){
        cin>>arr[i];
    }
}
void print(vector<int>& ans,int n){
    fo(i,0,n-1){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}
void solve(){
    int n;
    cin>>n;
    unsigned long long int sum=0;
    fo(i,1,n){
        if(bits[i]==0){
            sum = sum + (unsigned long long int)i;
        }
    }
    cout<<sum<<endl;
}
void generate(){
    int i;
    fo(i,1,M){
        if(i%3==0||i%5==0){
            bits[i] = 1;
        }else{
            bits[i] = 0;
        }
    }
}
int main(){
    generate();
    solve();
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <iterator>
#include <map>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long ll;


ll ans;
ll n;
int k;

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

    cin >> n >> k;
    vector<int> h(n);
    vector<int> dp(n, INT32_MAX);
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
    }
    dp[0] = 0;

    for (int i = 0; i < n-1; i++) {
        for (int j = 1; j <= k; j++) {
            if (i+j < n) {
                int value = abs(h[i + j] - h[i]);
                if (dp[i] + value < dp[i+j]) {
                    dp[i + j] = dp[i] + value;
                }
            }
        }
    }



    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

ll N;
int cnt = 0;

void dfs(ll cur, vector<bool> use) {
    if (cur > N) return;

    if (cur % 10 == 3) use[0] = true;
    if (cur % 10 == 5) use[1] = true;
    if (cur % 10 == 7) use[2] = true;

    if (use[0] && use[1] && use[2]) cnt++;

    dfs(cur * 10 + 3, use);
    dfs(cur * 10 + 5, use);
    dfs(cur * 10 + 7, use);
}

int main() {
    cin >> N;
    vector<bool> use(3, false);
    dfs(0, use);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rr register
const int N=15;
int a[N];
int n;
int ans;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;	
}
void dfs(int i,int maxx){
	if(i>n){
		for(rr int j=1;j<=n;++j){
			putchar(a[j]+'a'-1);
		}
		puts("");
		return;
	}

	for(rr int j=1;j<=maxx;++j){
		a[i]=j;		
		dfs(i+1,maxx);		
	}

	a[i]=maxx+1;
	dfs(i+1,maxx+1);
	return;
}
int main(void){
//	freopen("testdata.out","w",stdout);
	n=read();
	if(n==1){
		printf("a");
		return 0;
	}
	dfs(1,0);
	
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int i;
  cin >> s;
  i = s.size()-1;
  if(s.at(i)=='3'){
    cout << "bon" << endl;
  }else if(s.at(i)=='0'||s.at(i)=='1'||s.at(i)=='6'||s.at(i)=='8'){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}
  

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007


int main(){
  int H,W,K;
  cin >>H>>W>>K;
  int grid[H][W];
  rep(i,H){
    string ss;cin>>ss;
   	rep(j,W){ 
     grid[i][j]=ss[j]-'0';
    }
  }
  
  int memo[10][1000],group[10];  
  int flag=0,mincut=1000000,cutnum;
  
  for(int tmp=0;tmp<(1<<H-1);tmp++){
  	bitset<9>s(tmp);cutnum=0;flag=0;
    rep(i,10){memo[i][0]=0;group[i]=i;}
   	rep(i,H-1){
      if(s.test(i)){
        cutnum++;
      }
      else{group[i+1]=group[i];}
    }
    //ok
    rep(j,W){
      	if(j!=0){rep(k,H){memo[k][j]=memo[k][j-1];}}
    	for(int i=0;i<H;i++){
        	if(grid[i][j]==1){
            	memo[group[i]][j]+=1;
            }
        }
      	for(int i=0;i<H;i++){
        	if(memo[i][j]>K&&j>0){
              	cutnum++;
            	rep(i,H){
                  memo[i][j]=memo[i][j]-memo[i][j-1];
                  if(memo[i][j]>K){flag=1;}
                }              	
            }
          	else if(memo[i][j]>K&&j==0){flag=1;}
        } 	
    }//repiw
    if(flag==0){mincut=min(mincut,cutnum);}
  }//tmp
  cout<<mincut;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const ll mod = 1e9+7;

int main()
{
    ll N;
    scanf("%lld", &N);
    ll A[N+10];
    for(ll i=0; i < N; ++i) scanf("%lld", &A[i]);
    ll res = 0;
    for(ll bits=0; bits < 60; ++bits) {
        ll num0=0, num1=0;
        for(int i = 0; i < N; ++i)
            if(A[i]>>bits & 1) ++num1; else ++num0;
        ll tmp = num0%mod*num1%mod;
        for(int i = 0; i < bits; ++i) tmp = tmp*2LL%mod;
        //printf("tmp%d:%lld\n", bits,tmp);
        res += tmp;
        res %= mod;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n;
    for(i=2;i<=n;i++)
    {
        cin>>l;
        mp[l]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<mp[i]<<"\n";
    }
    return 0;
}



Measured memory_bytes: 13040
#include "bits/stdc++.h"
using namespace std;

int main(){

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

 if(a==b && c!=a)
   cout<<"Yes";

 else if(b==c && c!=a)
   cout<<"Yes";

 else  if(a==c && c!=b)
    cout<<"Yes";

else cout <<"No";


}

Measured memory_bytes: 256
import java.io.*;
class Main {
    public static void main(String args[]) throws IOException {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String s = new String(in.readLine());
      String[] ar = s.split("");
      int a = ar.length;
      int b = a - 2;
      System.out.println(ar[0] + b + ar[a-1]);
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
#define int long long


#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
int MOD = 1000000007;
const int inf = 1001001001;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x; cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty;
    string s;
    cin>>sx>>sy>>tx>>ty;
    int x=abs(sx-tx);
    int y=abs(sy-ty);
    for(int i=0;i<y;i++){
        if(sy>ty) s+="D";
        else s+="U";
    }
    for(int i=0;i<x;i++){
        if(sx>tx) s+="L";
        else s+="R";
    }
    
     for(int i=0;i<y;i++){
        if(sy>ty) s+="U";
        else s+="D";
    }
    for(int i=0;i<x;i++){
        if(sx>tx) s+="R";
        else s+="L";
    }
    
    if(sx>tx) s+="R";
    else s+="L";
    for(int i=0;i<y+1;i++){
        if(sy>ty) s+="D";
        else s+="U";
    }
    for(int i=0;i<x+1;i++){
        if(sx>tx) s+="L";
        else s+="R";
    }
     if(sy>ty) s+="U";
     else s+="D";
     
     if(sx>tx) s+="L";
    else s+="R";
    for(int i=0;i<y+1;i++){
        if(sy>ty) s+="U";
        else s+="D";
    }
    for(int i=0;i<x+1;i++){
        if(sx>tx) s+="R";
        else s+="L";
    }
    if(sy>ty) s+="D";
    else s+="U";
    cout<<s<<endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N, A, B;

//解法
void solve() {

	cout << (double)N / A;

	return;
}

int main() {
	//入力

	cin >> N >> A;

	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

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


int main()
{
	int n, m; cin >> n >> m;
	int s = 0;
	rep(i, m)
	{
		int a; cin >> a;
		s += a;
	}
	if (n < s)cout << -1 << endl;
	else cout << n - s << endl;
}


Measured memory_bytes: 3636
def solve(S,N):
    E,W = [0 for _ in range(N)],[0 for _ in range(N)]
    for i in range(N):
        if S[i] == "E":
            E[i] = 1
        else:
            W[i] = 1

    for i in range(1,N):
        E[i] += E[i-1]
        W[i] += W[i-1]

    ans = N
    for i in range(1,N):
        ans = min(ans,W[i-1]+(E[N-1]-E[i]))
    ans = min(ans,E[N-1]-E[0])

    return ans

def main():
    N = int(input())
    S = input()

    print(solve(S,N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 27296
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;


int l[10];

int get_stand_bit(int N, int bit_set){
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(((bit_set >> i) & 1) == 1){
            ans ++;
        }
    }
    return ans;
}

int get_matsu_length(int N, int bit_set){
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(((bit_set >> i) & 1) == 1){
            ans += l[i];
        }
    }
    return ans;
}

int main(){
    int N;
    int A;
    int B;
    int C;
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){
        cin >> l[i];
    }

    int ans = INT_MAX;
    for(int bit_set_A = 1; bit_set_A < (1 << N); bit_set_A ++){
        for(int bit_set_B = 1; bit_set_B < (1 << N); bit_set_B ++){
            for(int bit_set_C = 1; bit_set_C < (1 << N); bit_set_C++){
                if((bit_set_A & bit_set_B) != 0
                    || (bit_set_A & bit_set_C) != 0 || (bit_set_B & bit_set_C) != 0){
                    continue;
                }
                int tmp_ans = 10 * (get_stand_bit(N, bit_set_A) - 1)
                            + 10 * (get_stand_bit(N, bit_set_B) - 1)
                            + 10 * (get_stand_bit(N, bit_set_C) - 1);
                tmp_ans += abs(A - get_matsu_length(N, bit_set_A));
                tmp_ans += abs(B - get_matsu_length(N, bit_set_B));
                tmp_ans += abs(C - get_matsu_length(N, bit_set_C));
                ans = min(ans, tmp_ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){
  string S;
  int tmp, delta;
  string day[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> S;
  for(int i = 0; i < 7; i++){
    if(S == day[i]){
      tmp = i;
      break;
    }
  }
  delta = 7 - tmp;
  cout << delta << "\n";
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

Pi dp[2][100001];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  while(cin >> n, n) {
    vint p(n);
    rep(i, n) cin >> p[i];
    fill(dp[0], dp[2], Pi(inf, inf));
    Pi* curr = dp[0];
    Pi* next = dp[1];

    curr[0] = Pi(0, 0);
    rep(i, n) {
      rep(j, 100001) next[j] = Pi(inf, inf);
      rep(j, 100001) {
	chmin(next[j], curr[j]);
	Pi d = curr[j];
	int q = p[i]%1000;
	int x = (1000-q)%1000;
	if(j+x >= 500) { // ????????????500?????\???????????????????????°??????????????????????????????
	  if(j+x-500 <= 100000) {
	    d.first--;
	    d.second += p[i];
	    chmin(next[j+x-500], d);
	  }
	} else {
	  if(j+x <= 100000) {
	    d.second += p[i];
	    chmin(next[j+x], d);
	  }
	}
      }
      swap(curr, next);
    }

    Pi ans = Pi(inf, inf);
    rep(i, 100001) chmin(ans, curr[i]);
    cout << -ans.first << " " << ans.second << endl;
  }

  return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;

typedef complex<double> P;

#define EPS (1e-8)

int n;

bool EQ(double a, double b){
  if(fabs(a - b) < EPS){
    return true;
  }
  return false;
}

int main(){
  while(cin >> n){
    vector<P> pol;

    for(int i = 0; i < n; i++){
      P p;
      cin >> p.real() >> p.imag();
      pol.push_back(p);
    }

    if(n % 2 != 0){
      cout << "NA\n";
      continue;
    }

    bool flg = true;

    for(int i = 0; i < n; i++){
      int j = (i + n / 2) % n;

      P va = pol[i] - pol[(i + 1) % n];
      P vb = pol[(j + 1) % n] - pol[j];

      if(!EQ(va.real(), vb.real()) || !EQ(va.imag(), vb.imag())){
        flg = false;
        break;
      }
    }

    if(!flg){
      cout << "NA\n";
    }
    else{
      P ans = (pol[0] + pol[n / 2]) / 2.0;
      printf("%.10f %.10f\n", ans.real(), ans.imag());
    }
  }
}

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

const int MAX = 1010101;
const int MOD = 1e9 + 7;

int N, A, B, C;
int fac[MAX], finv[MAX], inv[MAX];

void CombInit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int nCk(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int mod_pow(int x, int n, int m = MOD) {
  if (n == 0)
    return 1;
  int res = mod_pow(x * x % m, n / 2, m);
  if (n % 2 == 1)
    res = res * x % m;
  return res;
}

signed main() {
  cin >> N >> A >> B >> C;

  CombInit();

  int ans = 0;
  for (int M = N; M < 2 * N; M++) {
    int X = inv[A + B];
    int tmp = (mod_pow(A * X % MOD, N) * mod_pow(B * X % MOD, M - N)) % MOD;
    tmp += (mod_pow(A * X % MOD, M - N) * mod_pow(B * X % MOD, N)) % MOD;
    tmp %= MOD;

    tmp *= nCk(M - 1, N - 1);
    tmp %= MOD;

    int tmp2 = (M * 100 % MOD) * inv[100 - C] % MOD;

    ans += tmp * tmp2;
    ans %= MOD;
  }

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


Measured memory_bytes: 23936
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c;ll ans; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);
	if(a%2==0||b%2==0||c%2==0)ans=0;
	else ans=min((1ll)*a*b,min((1ll)*a*c,(1ll)*b*c));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision

typedef long long ll;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}

int main(){
    omajinai();
    int n;
    cin>>n;
    vector<int> l(2*n);
    for(int i = 0; i<2*n;i++) cin>>l[i];
    sort(l.begin(),l.end());
    long ans = 0;
    for(int i = 0; i<n;i++) ans += min(l[2*i] , l[2*i+1]);
    cout<<ans<<endl;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> v(3*n); cin >> v;
    sort(all(v));
    ll ans = 0;
    rep(i, n) {
        ans += v[2 * i + n];
    }
    cout << ans << endl;
}


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

int main() {
 int K, A, B;
  cin >> K >> A >> B;
 
  if ( K == 1 ) {
    cout << "OK" << endl;
  }
  
  else if ( K > B ) {
      cout << "NG" << endl;
  }    
  
  else if ( A%K == 0 || B%K == 0 ) {
    cout << "OK" << endl;
  }
  
  else if ( A == B ) {
     cout << "NG" << endl;
  }
  
  else if ( B/K - A/K >= 1 ) {
          cout << "OK" << endl;
  }

  else if ( B/K - A/K < 1 ) {
          cout << "NG" << endl;
  }
}


Measured memory_bytes: 3672
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;

    if(a >= 13) {
        std::cout << b << std::endl;
    } else if(6 <= a && a <= 12) {
        std::cout << b / 2 << std::endl;
    } else if(a <= 5) {
        std::cout << 0 << std::endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
int n; char s[20][20];
int solve(int l, int r, int d) {
	if (r - l == 1) return s[l][d] - 48;
	int ret = (s[l][d] == '+' ? 0 : 1);
	int prev = -1;
	for (int i = l + 1; i < r; i++) {
		if (s[i][d + 1] != '.') {
			if (prev != -1) ret = (s[l][d] == '+' ? ret + solve(prev, i, d + 1) : ret * solve(prev, i, d + 1));
			prev = i;
		}
	}
	return (s[l][d] == '+' ? ret + solve(prev, r, d + 1) : ret * solve(prev, r, d + 1));
}
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) scanf("%s", s[i]);
		printf("%d\n", solve(0, n, 0));
	}
}

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

typedef long long ll;

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    
    ll X[N];
    for(int i=0;i<N;i++)cin>>X[i];
    
    ll ans=0;
    for(int i=0;i<N-1;i++){
        ll d=X[i+1]-X[i];
        if(d*A<B)ans+=d*A;
        else ans+=B;
    }
    
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vector<string> ans;
    auto rec = [&](auto &&f, ll i, string now, char mxchar) -> void {
        if (i == n) {
            ans.eb(now);
            return;
        }
        for (char j = 'a'; j <= char(mxchar + 1); ++j) {
            char tmp = 'a';
            each(e, now) {
                tmp = max(tmp, e);
            }
            f(f, i + 1, now + j, max(tmp, j));
        }
    };
    string now = "a";
    rec(rec, 1LL, now, 'a');
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
	
	int n, k;
	cin >> n >> k;
	int ans = 0;
	rep(i, n){
		int x;
		cin >> x;
		ans += min(x, k - x) * 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int res = 0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<= b; j++){
            for(int k=0; k<=c; k++){
                if(500*i+100*j+50*k==x){
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n")[1].split(" ");
  var max, min;
  var count = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  for (val in input) {
    var n = parseInt(input[val], 10);
    var q = Math.min(Math.floor(n / 400), 8);
    count[q]++;
  }
  var nonZero = 0;
  for (var i=0; i<8; i++) {
    if (count[i] != 0) nonZero++;
  }
  min = Math.max(nonZero, 1);
  max = nonZero + count[8];
    
	//出力
	console.log(min + " " + max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{   int t;
   cin>>t;
 
 int a=t%10;
 t/=10;
 int b=t%10;
 
 
    if(a==9||b==9){cout<<"Yes";
  }
 else
 {
 cout<<"No";
 
 }
   }
 
 

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long>H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());
  if (N <= K) {
    cout << 0;
  }
  else {
    long long sum = 0;
    for (int i = 0; i < N - K; i++) {
      sum += H.at(i);
    }
    cout << sum;
  }
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m,k; cin>>n>>m>>k;
    vint a(n); rep(i,n) cin>>a[i];
    vint b(m); rep(i,m) cin>>b[i];

    vint ruia(n+1,0), ruib(m+1,0);

    rep(i,n) ruia[i+1] = ruia[i] + a[i];
    rep(i,m) ruib[i+1] = ruib[i] + b[i];

    ll ans = 0;

    rep(i,n+1){
        ll tmp = 0;
        tmp += ruia[i];
        if(tmp > k) continue;
        ll hoge = i;
        ll res = k - tmp;
        auto it = upper_bound(ALL(ruib), res);
        it--;
        // tmp += *it;
        hoge += (ll)(it - ruib.begin());
        chmax(ans,hoge);
    }
    cout<<ans<<endl;

    return 0;

}

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

int main(void){
  int N;
  bool Y = false;
  cin >> N;
  for(int i = 0; i < N; i++){
    string c;
    cin >> c;
    if (c == "Y") Y = true; 
  }
  if (Y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;    
  }
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int a[1024],b[1024],c[1024],d[1024],cal[1024];
        for(int i = 0;i < n; i++){
            scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
            cal[i] = (4*b[i]) + (9*c[i]) + (4*d[i]);
        }
        int P,Q,R,C;
        scanf("%d%d%d%d",&P,&Q,&R,&C);

        bool f = false;

        for(int i = 0;i < n; i++){
            if(b[i] <= P&&c[i] <= Q&&d[i] <= R&&cal[i] <= C){
                printf("%d\n",a[i]);
                f = true;
            }
        }
        if(f == false)printf("NA\n");
    }
    return 0;
}

Measured memory_bytes: 1056
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000;
//#define PI 3.14159265359

int main() {
    // input
    ll N;
    cin >> N;

    //process
    ll ans = (1000 - N % 1000)%1000;

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


Measured memory_bytes: 3196
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n;
int main(void){
	lli p=1,q=1;
	scanf("%d",&n);
	rep(i,n){
		lli s,t;
		scanf("%lld%lld",&s,&t);
		lli l=0,r=(LINF/2-5)/max(s,t);
		while(r-l>1){
			lli m=(r+l)/2;
			if(p<=s*m && q<=t*m)r=m;
			else l=m;
		}
		//printf("%lld\n",r);
		p=s*r; q=t*r;
	}
	
	printf("%lld\n",p+q);
	return 0;
}






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

int main() {
  int x,y;
  for(int i=1; i<=3000; i++){
    cin >> x >> y;
    if(x==0 && y==0){
      break;
    }
    if(x>y){
      swap(x,y);
    }
    cout << x << ' ' << y << endl;
  }
}



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

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

const long long MOD = 1000000007;

int main(){
  int n,x,y,l;
  cin >> n >> x >> y;
  x--;y--;
  vector<int> d(n,0);
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      l=min(j-i,max(x-i,i-x)+max(y-j,j-y)+1);
      d.at(l) += 1;
    }
  }
  rep(i,n-1){
    cout << d.at(i+1) << endl;
  }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

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

  if(a>b) swap(a,b);
  if(b>c) swap(b,c);
  if(a>b) swap(a,b);

  cout<<a<<" "<<b<<" "<<c<<endl;

  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
ll n,sum=0;
cin>>n;
ll rem,x,y,z;
x=n/500;
y=n%500;
z=y/5;


sum+=x*1000+z*5;
cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int p[100001];
int n;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, n) read(p[i]);
    int ans=0;
    FOR(i, 2, n){
        if(p[i-1]==i-1){
            ans++;
            swap(p[i], p[i-1]);
        }
    }
    ans+=p[n]==n;
    write(ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <string>
#include <climits>
using namespace std;

#define MAX_N 101


int main()
{
    vector<vector<int> > A(MAX_N, vector<int>(MAX_N, 0));
    int i, k, u, v, n;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> u >> k;
        while (k--) {
            cin >> v;
            A[u][v] += 1;
        }
    }
    for (i = 1; i <= n; i++) {
        for (k = 1; k <= n; k++) {
            if (k > 1) cout << " ";
            cout << A[i][k];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int las;
int main(){
	las=1;
	string s;
	cin>>s;
	int len=s.length();
	s='$'+s;
	int res=0;
	rb(i,1,len){
		if(las==1){
			las=0;
//			cout<<i<<endl;
			res++;
		}
		else{
			if(s[i]==s[i-1]){
				if(i!=len){
					i++;
					res++;
					las=1;
				}
			}
			else{
				res++;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for(int i = 0; i < N; i++) cin >> P[i];
  for(int i = 0; i < N; i++) cin >> Q[i];

  int a, b;

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

  int cnt = 0;

  do{

    bool ok1 = true;
    for(int i = 0; i < N; i++){
      if(v[i] != P[i]) ok1 = false;
    }

    bool ok2 = true;
    for(int i = 0; i < N; i++){
      if(v[i] != Q[i]) ok2 = false;
    }

    if(ok1){
      a = cnt;
    }

    if(ok2){
      b = cnt;
    } 

    cnt++;

  }while(next_permutation(v.begin(), v.end()));

  cout << abs(b - a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main()
{
	int a,b;
	int c[101];
	vector<int> d;
	while(1){
		scanf("%d,%d",&a,&b);
		if(a == 0 && b == 0){
			break;
		}
		c[a] = b;
		d.push_back(b);
	}
	sort(d.begin(),d.end(),greater<int>());
	d.erase(unique(d.begin(),d.end()),d.end());
	int e;
	while(scanf("%d",&e) != -1){
		printf("%d\n",(int)(lower_bound(d.begin(),d.end(),c[e],greater<int>()) - d.begin() + 1));	
	}
}

Measured memory_bytes: 1056
import itertools
inf = float('inf')

N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

ans = -inf

for shift in itertools.product([0,1],repeat=10):
    if not any(shift): continue
    res = 0
    for i,line in enumerate(F):
        c = 0
        for s, f in zip(shift, line):
            if s and f:
                c += 1
        res += P[i][c]
    if res > ans:
        ans = res

print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vector<pii> tasks(n);
    REP(i,n){
        int a,b;
        cin>>a>>b;
        tasks[i] = make_pair(b, a);
    }
    sort(ALL(tasks));
    
    int now = 0;
    
    REP(i,n){
        if(tasks[i].first < now + tasks[i].second){
            cout<<"No"<<endl;
            return 0;
        }
        now += tasks[i].second;
    }

    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
# coding: utf-8
import time
import re
import math

def main():
    A,B,K = map(int,input().split())
    ls=[]
    for a in range(K):
        ls.append(A + a)
        ls.append(B - K +1+ a)
    ls=set(ls)
    ls=sorted(ls)
    for a in ls:
        if (a>=A and a<=B):print(a)
main()

Measured memory_bytes: 3184
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
///----------------------------------------------
int main() {

    //freopen ( "xx.in"  , "r" , stdin  );

    //--0 init

    //--1 read
    int pre,now;
    int n,A,B; scanf("%d%d%d%d",&n,&A,&B,&pre);
    ll ans=0;
    for (int i=2; i<=n; i++) {
        scanf("%d",&now);
        ans+=min(((ll)now-pre)*A,(ll)B);
        pre=now;
    }

    //--2 print
    cout << ans;

}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
menseki = x/a
takasa = menseki * 2 / b
if takasa <= a:
    print(90-(math.atan(takasa/b)*180/math.pi))
else:
    nokori = 2*b-(menseki * 2 / a)
    print(math.atan(nokori/a)*180/math.pi)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  
  int maxn = INT_MIN, minn = INT_MAX;
  for(int i = 0; i < N; i++){
    cin >> V[i];
    if(maxn < V[i]) maxn = V[i];
    if(minn > V[i]) minn = V[i];
  }
  
  long long int ans = LLONG_MAX;
  for(int t = minn; t <= maxn; t++){
    long long int tmp = 0LL;
    for(int i = 0; i < N; i++){
      tmp += (V[i] - t)*(V[i] - t);
    }
    if(ans > tmp) ans = tmp;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	ll n,memo = 0,ans = LINF;
	string s;
	cin >> n >> s;
	
	string t = s;
	
	rep(i,0,t.size()) t[i] = '#';
	
	//cout << t << endl;
	
	rep(i,0,s.size()){
		if(t[i] != s[i]) memo++;
	}
	
	ans = memo;
	
	//cout << memo << endl;
	
	rep(i,0,s.size()){
		if(s[i] == '#')memo++;
		else memo--;
		
		t[i] = '.';
		
		ans = min(memo,ans);
		
		//cout << ans <<  " " << t << " " << s << endl;
	}
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 772
#include<iostream>
int main(){
    long a,b,c,d;
    std::cin >> a >> b >> c >> d;
    long ans;
    ans = std::max(a*c, a*d);
    ans = std::max(ans, std::max(b*c, b*d));
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3644