akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int n, k, cnt = 0;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) {
		cin >> h[i];
		if (h[i] >= k) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;
int tate[4] = {0,0,1,-1};
int yoko[4] = {1,-1,0,0};
int main(){
    int h,w;cin >> h >> w;
    vector<string> st(h);
    vector<vector<int>> ans;
    ans.assign(h,vector<int>(w,0));
    rep(i,h){
        st[i].resize(w);
        cin >> st[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(st[i][j]=='.') continue;
            for(int k=0;k<4;k++){
                int nh=i+tate[k];
                int nw=j+yoko[k];
                if(nh>=h||nw>=w||nh<0||nw<0) continue;
                if(st[nh][nw]=='#'){
                    ans[nh][nw] = 1;
                    ans[i][j] = 1;
                }
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(st[i][j]=='#'){
                if(ans[i][j]==0){
                    cout << "No" << endl;
                    return 0;
                }
            }else{
                if(ans[i][j]==1){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define pri(n) printf("%d",n)
#define lpri(n) printf("%lld",n)
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define F first
#define S second
const ll mod=998244353;

int main()
{
    int t=1;
    //cin>>t;

    while(t--)
    {
        ll n,w;
        cin>>n>>w;

        ll wt[n+1];
        ll val[n+1];

        ll sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>wt[i];
            cin>>val[i];
            sum+=val[i];
        }

        ll m=sum;
        ll dp[n+5][m+5];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            dp[i][j]=INT_MAX;
        }

        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(j-val[i]==0 and dp[i-1][j-val[i]]==INT_MAX)
                dp[i][j]=min(wt[i],dp[i-1][j]);

                else if(j-val[i]>=0)
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]]+wt[i]);

                else
                dp[i][j]=min(dp[i-1][j],dp[i][j]);

            }
        }
        for(int i=m;i>0;i--)
        {
           if(dp[n][i]<=w)
           {
               cout<<i;
               return 0;
           }
        }
        cout<<0;
    }
}

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

#define ll long long
#define T int t, q=0; cin>>t; while(q++<t)

int main()
{
    int x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    vector<pair<int, int> > v;
    for(int i=0; i<a; i++)
    {
        int x; cin>>x;
        v.push_back({x, 1});
    }
    for(int i=0; i<b; i++)
    {
        int x; cin>>x;
        v.push_back({x, 2});
    }
    for(int i=0; i<c; i++)
    {
        int x; cin>>x;
        v.push_back({x, 3});
    }
    sort(v.begin(), v.end());

    ll sum=0, tot=x+y;
    for(int i=a+b+c-1; i>=0 && tot; i--)
    {
        if(v[i].second==1)
        {
            if(x==0) continue;
            sum+=v[i].first;
            x--;
        }
        else if(v[i].second==2)
        {
            if(y==0) continue;
            sum+=v[i].first;
            y--;
        }
        else sum+=v[i].first;
        tot--;
    }
    cout<<sum;
}


Measured memory_bytes: 6128
import java.util.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);

		long a=s.nextLong(),b=s.nextLong(),k=s.nextLong();
		if(a>=k)
			System.out.println(a-k+" "+b);
		else
			System.out.println("0 "+Math.max(0,b-k+a));
	}
}


Measured memory_bytes: 23124
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL x;
    LL t;
    cin >> n >> x >> t;
    LL ans;
    if(n%x==0){
        ans=n/x;
    }else{
        ans=n/x+1;
    }
    ans*=t;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
a,b = gets.split.map(&:to_i)

chk = 4
ans = (a/2 % 2 + (b+1)/2 %2) % 2
40.times do
  x = a%chk
  y = (b+1)%chk
  x = x > chk/2 ? x-chk/2 : 0
  y = y > chk/2 ? y-chk/2 : 0
  ans += ((x-y) % 2 )*(chk/2)
  #p [x,y, ((x-y) % 2 )*chk ]
  chk *= 2
end
p ans


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;


int d,a,b,c,n,m,k,l[200110],o[210100],i,j[200010];


//A 65 a 97
//z 122 Z 90
/*struct P
{
    int x,y;
    bool operator<(const P &a)const
    {
        //printf("#%d %d\n",o[x],o[y]);
        return min(o[x],o[y])>min(o[a.x],o[a.y]);
    }
};*/
queue<int> q;




int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;l[o[t]]++,t++)
        scanf("%d",&o[t]);

    for(int t=a;t>=1;t--)
    for(int w=0;w<l[t];w++)
    if(t-w>=1)  j[t-w]++;
    else j[1]++;

    for(int t=1;t<=a;t++)
    {
        //printf("%d ",j[t]);
    if(j[t]==0) k++;
    }
    for(int t=1;t<=b;t++)
    {
        scanf("%d %d",&n,&m);
        if(o[n]-l[o[n]]+1>=1)
        {
        j[o[n]-l[o[n]]+1]--;
        if(j[o[n]-l[o[n]]+1]==0) k++;
        }
        else
        {
            j[1]--;
            if(j[1]==0) k++;
        }
        l[o[n]]--;
        if(m-l[m]>=1)
        {
        j[m-l[m]]++;
        if(j[m-l[m]]==1) k--;
        }
        else
        {
            j[1]++;
            if(j[1]==1) k--;
        }
        l[m]++;
        o[n]=m;
        //for(int t=1;t<=a;t++)
          //  printf("%d ",j[t]);
        printf("%d\n",k);
    }
}




Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
  string s;
  cin >> s;
  map<char,int> m;
  rep(i,s.sz){
    ++m[s.at(i)];
  }
  rep(i,26){

    if(m['a' + i] == 0){
      cout << char('a'+ i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;    
  return 0;
}


Measured memory_bytes: 3756
#define REP(i,n) for (int i=0;i<(n);i++)
#include <bits/stdc++.h>
using namespace std;
int tmp,n,a[300][300],wf[300][300];

int main(){
	scanf("%d", &n);
	long long ret = 0;
	REP(i,n){ REP(j,n){
		scanf("%d", &tmp);
		a[i][j] = tmp;
		wf[i][j] = tmp;
	} }

	REP(k,n){ REP(i,n){ REP(j,n){
		if(wf[i][j] > wf[i][k] + wf[k][j]){
			wf[i][j] = wf[i][k] + wf[k][j];
		}
	} } }

	REP(i,n){ REP(j,n){ REP(k,n){
		if (wf[i][j] < a[i][j]) { printf("%s","-1\n"); return 0;}
		if ( i!=k & j!=k ){
			if (wf[i][j] == wf[i][k] + wf[k][j]) {break;}
		}
		if (k==n-1){ret += wf[i][j];}
	} } }
	ret /= 2;
	printf("%lld\n",ret);
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cstdio>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n;
ll W[4001];
ll dp[4001][4001];
ll sum[4001];
int at[4001][4001];

int main(int argc, char const* argv[])
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
			scanf("%lld", W + i);
			if(i == 0)sum[i] = W[i];
			else sum[i] = sum[i-1] + W[i];
	}
	for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
					at[i][j] = i;
					dp[i][j] = linf;
			}
			dp[i][i] = 0;
	}
	for(int w = 1; w < n; w++){
			for(int i = 0; i + w < n; i++){
					for(int k = max(at[i][i+w-1], i); k <= min(i + w - 1, at[i+1][i+w]); k++){
							if(dp[i][i+w] > dp[i][k] + dp[k+1][i+w]){
									dp[i][i+w] = dp[i][k] + dp[k+1][i+w];
									at[i][i+w] = k;
							}else if(dp[i][i+w] < dp[i][k] + dp[k+1][i+w]){
									//break;
							}
					}
					if(i != 0)dp[i][i+w] += sum[i+w] - sum[i - 1];
					else dp[i][i+w] += sum[i+w];
			}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> P(N);
    
    ll mi = 1e10, ma = 0, mi_index, ma_index; 
    for (int i = 0; i < N; i++) {
        ll X, Y;
        scanf("%lld %lld", &X, &Y);
        if (X > Y) swap(X, Y);
        P[i] = {X, Y};
    }
    sort(P.begin(), P.end());
    mi = P[0].first;
    mi_index = 0;
    
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (N == 2) {
        cout << min(abs((P[0].first-P[1].first)*(P[0].second-P[1].second)), abs((P[0].first-P[1].second)*(P[0].second-P[1].first)));
        return 0;
    }
    
    for (int i = 0; i < N; i++) {
        if (ma <= P[i].second) {
            ma = P[i].second;
            ma_index = i;
        }
    }
    if (mi == ma) {
        cout << 0 << endl;
        return 0;
    }
    
    ll cand1, cand2;
    ll rmin = mi, rmax = mi, bmax = ma, bmin = ma;
    for (int i = 0; i < N; i++) {
        rmax = max(rmax, P[i].first);
        bmin = min(bmin, P[i].second);
    }
    cand1 = (rmax-rmin)*(bmax-bmin);
    
    if (mi_index == ma_index) {
        cout << cand1 << endl;
        return 0;
    }
    
    rmin = mi; rmax = ma;
    bmin = min(P[mi_index].second, P[ma_index].first);
    bmax = max(P[mi_index].second, P[ma_index].first);
    if ((bmax-bmin)*(rmax-rmin) > cand1) {
        cout << cand1 << endl;
        return 0;
    }
    
    multiset<pair<ll, int>> mst;
    mst.insert({bmin, mi_index});
    mst.insert({bmax, ma_index});
    for (int i = 0; i < N; i++) {
        if (i == mi_index || i == ma_index) continue;
        mst.insert({P[i].first, i});
    }
    cand2 = (rmax-rmin)*((*mst.rbegin()).first - (*mst.begin()).first);
    for (int i = 0; i < N; i++) {
        if (i == mi_index || i == ma_index) continue;
        mst.erase(mst.find({P[i].first, i}));
        mst.insert({P[i].second, i});
        cand2 = min(cand2, (rmax-rmin)*((*mst.rbegin()).first - (*mst.begin()).first));
    }
    
    cout << min(cand1, cand2) << endl;
    return 0;
}


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

using namespace std;
long long k;
int main(){
cin>>k;
long long credit=100;
for(int i=1;i<=3760;i++){
credit+=credit/100LL;
if(credit>=k){
  cout<<i;
  return 0;
  }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];

    double ans;
    sort(v.begin(),v.end());
    ans=v[0];

    for(int i=0;i<n-1;i++)
    {
        ans=(ans+v[i+1])/2.0;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll h,n;
  cin >> h >> n;
  ll a=0;
  rep(i,n){
    int b; cin >> b;
    a+=b;
  }
  if(a>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int adj_matrix[51][51] = {0};

int main()
{
    int N, M;

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        adj_matrix[x][y] = 1;
        adj_matrix[y][x] = 1;
    }

    int ans = 0;
    for (int i = 1; i <= N - 1; i++)
    {
        for (int j = i + 1; j <= N; j++)
        {
            if (adj_matrix[i][j] == 1)
            {
                adj_matrix[i][j] = 0;
                adj_matrix[j][i] = 0;

                int visit[51] = {0};
                int dsit_from_start[51] = {0};
                queue<int> q;

                visit[1] = 1;
                q.push(1);
                while (!q.empty())
                {
                    int node = q.front();
                    q.pop();
                    for (int k = 1; k <= N; k++)
                    {
                        if (adj_matrix[node][k] == 1 && visit[k] == 0)
                        {
                            visit[k] = 1;
                            q.push(k);
                        }
                    }
                }

                for (int k = 2; k <= N; k++)
                {
                    if (visit[k] == 0)
                    {
                        ans++;
                        break;
                    }
                }

                adj_matrix[i][j] = 1;
                adj_matrix[j][i] = 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  ll n,x,ans=0;
  cin >> n;
  for(ll i=1;i<=n;i++){
    cin >> x;
    if(i+x<n) cntl[i+x]++;
    if(i-x>1) cntr[i-x]++;
  }
  for(int i=2;i<n;i++) ans += cntl[i]*cntr[i];
  cout << ans << endl;
}


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

int main() {
	string S;
	int K,N;
	cin >>N>>S>>K;
	for(int i = 0 ; i < N ; i++){
		if(S[i] != S[K-1]){
			S[i] = '*';
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<int> b(n-1);
    int M = 1000000;
    rep(i,n-1) {
        cin >> b[i];
        M = min(M,b[i]);
    }
    int ans = b[0] + b[n-2];
    for (int i = n-2; i >= 1; i--)
    {
        ans += min(b[i-1],b[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;


int main()
{
    int a, b, c, d;
    cin >>a >> b >> c >> d;

    
    int i = 1;
    while (a>0 && c>0) {
        if (i%2 == 1) c-=b;
        else a-=d;
        
        i++;
    }

    if (a>0 && c<=0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



Measured memory_bytes: 3612
n=int(input())
s={}
for _ in range(n):
  si=input()
  if si in s:
    s[si]+=1
  else:
    s[si]=1
m=int(input())
t={}
for _ in range(m):
  ti=input()
  if ti in t:
    t[ti]+=1
  else:
    t[ti]=1

ans=0
for i in s:
  p=s[i]-t.get(i, 0)
  if p>ans:
    ans=p
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
using namespace std;

int main()
{
    int m;
    cin>>m;
    int fl=0,n=1;
    bool f;
    while(fl<m)
    {
        f=true;
        for(int r=2;r*r<=10*n+1&&f;r++)
        {
            if((10*n+1)%r!=0){}
            else {f=false;}
        }
        if(f&&fl<m-1)
        {
            cout<<10*n+1<<" ";
            fl++;
        }
        else if(f&&fl==m-1)
        {
            cout<<10*n+1<<endl;
            fl++;
        }
        else{}
        n++;
    }
    return 0;
}

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

using namespace std;

typedef pair<int,int> P;
const int inf = 999999;

struct St{
	P p;
	int c;
};

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};
bool bfs(char a[20][20], int d[11][11], vector<P> vec, int w, int h, P srt)
{
	bool vis[20][20], f = true;
	int c = 1, num[20][20];
	queue<St> que;
	St s, t;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(a[i][j] == '*'){
				num[i][j] = c++;
			} else {
				num[i][j] = 0;
			}
		}
	}
	s.p = srt;
	s.c = c = 0;
	que.push(s);
	fill(&vis[0][0], &vis[19][19], true);
	vis[s.p.first][s.p.second] = false;
	while(!que.empty()){
		s = que.front();
		que.pop();
		if(a[s.p.first][s.p.second] == '*'){
			c++;
			d[0][num[s.p.first][s.p.second]] = s.c;
			if(c == vec.size()){
				f = false;
				break;
			}
		}
		
		for(int i = 0; i < 4; i++){
			int dy = s.p.first+ydir[i], dx = s.p.second+xdir[i];
			if(0 <= dy && dy < h && 0 <= dx && dx < w && vis[dy][dx] && a[dy][dx] != 'x'){
				vis[dy][dx] = false;
				t.p = P(dy, dx);
				t.c = s.c+1;
				que.push(t);
			}
		}
	}
	if(f){
		return false;
	}
	
	for(int i = 0; i < vec.size(); i++){
		queue<St> qu;
		fill(&vis[0][0], &vis[19][19], true);
		s.p = vec[i];
		s.c = c = 0;
		qu.push(s);
		vis[s.p.first][s.p.second] = false;
		
		while(!qu.empty()){
			s = qu.front();
			qu.pop();
			
			if(a[s.p.first][s.p.second] == '*'){
				c++;
				d[num[vec[i].first][vec[i].second]][num[s.p.first][s.p.second]] = s.c;
				if(c == vec.size()){
					break;
				}
			}
			
			for(int i = 0; i < 4; i++){
				int dy = s.p.first+ydir[i], dx = s.p.second+xdir[i];
				if(0 <= dy && dy < h && 0 <= dx && dx < w && vis[dy][dx] && a[dy][dx] != 'x'){
					vis[dy][dx] = false;
					t.p = P(dy, dx);
					t.c = s.c+1;
					qu.push(t);
				}
			}
		}
	}
	
	return true;
}

int main()
{
	int w, h, d[11][11], num[11];
	char a[20][20];
	P s;
	
	while(cin>>w>>h && (w+h)){
		vector<P> vec;
		s = P(-1,-1);
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> a[i][j];
				if(a[i][j] == 'o'){
					s = P(i, j);
				} else if(a[i][j] == '*'){
					vec.push_back(P(i, j));
				}
			}
		}
		
		if(s.first == -1 && s.second == -1){
			cout << -1 << endl;
			continue;
		} else if(vec.size() == 0){
			cout << 0 << endl;
			continue;
		}
		fill(&d[0][0], &d[10][10], inf);
		for(int i = 0; i < 11; i++){
			d[i][i] = 0;
		}
		if(bfs(a, d, vec, w, h, s)){
			int n = vec.size()+1, t = inf, u;
			for(int i = 0; i < n; i++){
				num[i] = i;
			}
			do{
				u = 0;
				for(int i = 0; i < n-1; i++){
					u += d[num[i]][num[i+1]];
				}
				t = min(t, u);
			} while(next_permutation(num, num+n));
			cout << t << endl;
		} else {
			cout << -1 << endl;
		}
	}
	
	return 0;
}

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

// struct Edge{
//     int v;
//     int cap;
//     int flow;
//     int rev;
// };

// class Graph{
//     public:
//         int V;
//         int *level;
//         vector<Edge> *adj;

//         Graph(int V)
//         {
//             this->V=V;
//             level=new int[V+1];
//             adj=new vector<Edge>[V+1];
//         }

//         void addEdge(int u,int v,int cap)
//         {
//             Edge a{v,cap,0,adj[v].size()};
//             Edge b{u,0,0,adj[u].size()};
//             adj[u].push_back(a);
//             adj[v].push_back(b);
//         }

//         bool bfs(int s,int t)
//         {
//             for(int i=0;i<=V;i++)
//             {
//                 level[i]=-1;
//             }
//             queue<int> q;
//             q.push(s);
//             level[s]=0;
//             while(!q.empty())
//             {
//                 int y=q.front();
//                 q.pop();
//                 for(auto it=adj[y].begin();it!=adj[y].end();it++)
//                 {
//                     Edge &e=(*it);
//                     if(e.flow<e.cap && level[e.v]==-1)
//                     {
//                         level[e.v]=level[y]+1;
//                         q.push(e.v);
//                     }
//                 }
//             }
//             return (level[t]!=-1);
//         }

//         int gflow(int cur,int t,int flow,int *start)
//         {
//             if(cur==t)
//             {
//                 return flow;
//             }
//             for(;start[cur]<adj[cur].size();start[cur]++)
//             {
//                 Edge &e=adj[cur][start[cur]];

//                 if(e.flow<e.cap && level[e.v]==level[cur]+1)
//                 {
//                     int cflow=min(flow,e.cap-e.flow);
//                     int tflow=gflow(e.v,t,cflow,start);
//                     if(tflow>0)
//                     {
//                         e.flow+=tflow;
//                         adj[e.v][e.rev].flow-=tflow;
//                         return tflow;
//                     }
//                 }
//             }
//             return 0;
//         }

//         int dinic(int s,int t)
//         {
//             if(s==t)
//             {
//                 return -1;

//             }
//             int tflow=0;
            
//             while(bfs(s,t))
//             {
//                 int *start=new int[V+1];
            
//                 while(int flow=gflow(s,t,INT_MAX,start))
//                 {
//                     tflow+=flow;
//                 }
//             }
//             return tflow;
//         }


// };


int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i+t.length()-1<s.length();i++)
    {
        string h=s.substr(i,t.length());
        int cost=0;

        for(int j=0;j<t.length();j++)
        {
            if(t[j]==h[j])
            {
                cost++;
            }
        }
        ans=max(ans,cost);
    }
    cout<<t.length()-ans<<endl;
}


       
    
    
    

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int nax=1e5+5;
pair<int,int> arr[nax];
vector<vector<pair<int,pair<int,ll>>>> v(nax);
int vis[nax]={0};
int level[nax];
int parent[nax];
int dp[nax][20];
struct s{
	int a,b,c,d;
};
vector<vector
> pre(nax);
int ans[nax]={0};
int find(int x, int d){
	for(int i=19;i>=0;i--){
		if(d < (1<<i)) continue;
		x=dp[x][i];
		d-=(1<<i);
	}
	return x;
}
void dfs(int ci, int l){
	vis[ci]=1;
	level[ci]=l;
	if(l==0) parent[ci]=ci;
	for(auto x : v[ci]){
		if(vis[x.first]==1) continue;
		parent[x.first]=ci;
		dfs(x.first,l+1);
	}
}
int lca(int a, int b){
	int p=a; int q=b;
	if(level[a] > level[b]){
		p=b; q=a;
	}
	q=find(q,abs(level[a]-level[b]));
	if(p==q) return p;
	for(int i=19;i>=0;i--){
		if(dp[p][i]==dp[q][i]) continue;
		p=dp[p][i];
		q=dp[q][i];
	}
	return dp[p][0];
}
void dfs1(int ci, int sum, int col, int val){
	vis[ci]=1;
	for(auto x : pre[ci]){
		if(x.b==0) ans[x.a]+=sum-arr[x.c].second+arr[x.c].first*x.d;
		else ans[x.a]-=2*(sum-arr[x.c].second+arr[x.c].first*x.d);
	}
	for(auto x : v[ci]){
		if(vis[x.first]==1) continue;
		arr[x.second.first].first++;
		arr[x.second.first].second+=x.second.second;
		dfs1(x.first,sum+x.second.second,x.second.first,x.second.second);
	}
	if(ci != 0){
		arr[col].first--;
		arr[col].second-=val;
	}
}
int main(){
  /*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
    */
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--; b--; c--;
		v[a].push_back({b,{c,d}});
		v[b].push_back({a,{c,d}});
		arr[i]={0,0};
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		vis[i]=0;
		dp[i][0]=parent[i];
	}
	for(int j=1;j<20;j++){
		for(int i=0;i<n;i++) dp[i][j]=dp[dp[i][j-1]][j-1];
	}
	vector
 query;
	for(int i=0;i<q;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--; c--; d--;
		pre[c].push_back({i,0,a,b});
		pre[d].push_back({i,0,a,b});
		pre[lca(c,d)].push_back({i,1,a,b});
	}
	dfs1(0,0,-1,-1);
	for(int i=0;i<q;i++) cout<<ans[i]<<"\n";
}

Measured memory_bytes: 33780
#include<cstdio>
#include<algorithm>
int a[100000+10];
int main()
{
	int t,ans=0;
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
		scanf("%d",&a[i]);
	}
	std::sort(a,a+t);
	for(int o=0;o<t;o++)
	{
		if(a[o]==a[o+1])
		{
			a[o]=0;
			a[o+1]=0;
			o++;	
		}
		else
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b;
 	cin >> a>>b;
 	if(a<=b){
 		cout << a << endl;
 	}else{
 		cout << a-1 << endl;
 	}
 }

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

int main(){
  int N;
  cin >> N;
  int d = 0;
  int p[N][3];
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> p[i][j];
    }
      for(int a=0;a<i;a++){
            if((p[i][0]==p[a][0]||p[i][0]==p[a][1]||p[i][0]==p[a][2])&&
               (p[i][1]==p[a][0]||p[i][1]==p[a][1]||p[i][1]==p[a][2])&&
               (p[i][2]==p[a][0]||p[i][2]==p[a][1]||p[i][2]==p[a][2])){
               d++;
               p[i][0]=0; p[i][1]=0; p[i][2]=0;
               break;
            }
       }
  }
   cout << d << endl;

 return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout << #x << " " << x << endl
#define fast ios_base::sync_with_stdio(false);
#define iscan1(x) scanf("%d",&x);
#define lscan1(x) scanf("%lld",&x);
#define iscan2(x,y) scanf("d",&x,&y);
#define lscan2(x,y) scanf("lld",&x,&y);
#define csprint(x) printf("Case %d: ",x);
#define iprint(x) printf("%d",x);
#define lprint(x) printf("%lld",x);
#define pnl printf("\n");
#define pg printf(" ");
int counter[26];
ll mod = 1000000007;
int main()
{
    int n;
    char c;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> c;
        int y = c-'a';
        counter[y]++;
    }
    ll ans = 1;
    for(int i=0;i<26;i++)ans=(ans%mod*(counter[i]+1)%mod)%mod;
    cout <<(ans-1+mod)%mod<<endl;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    ll res = 0;
    FOR(i,1,n) {
        cin >> a[i];
        if (i > 1) {
            if (a[i] < a[i-1]) {
                res += a[i-1] - a[i];
                a[i] = a[i-1];
            }
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 4348
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int N;
long long B[100010];
long long res;


int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; ++i) {
        cin >> B[i];
    }
    
    res += B[0];
    res += B[N - 2];

    for (int i = 1; i < N - 1; ++i) {
        res += min(B[i -1], B[i]);
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    double n; cin >> n;
    cout << int(ceil(n/2.0)) << endl;
    return 0;
}


Measured memory_bytes: 3680
H,W = map(int,input().split())
C = []
for _ in range(10):
  List = list(map(int,input().split()))
  C.append(List)
Wall = []
for _ in range(H):
  List = list(map(int,input().split()))
  Wall.append(List)
for k in range(10):
  for i in range(10):
    for j in range(10):
      if i != j:
        C[i][j] = min(C[i][j],C[i][k]+C[k][j])
      else:
        C[i][j] = 0
Answer = 0
for line in Wall:
  for item in line:
    if item!= -1:
      Answer += C[item][1]
print(Answer)


Measured memory_bytes: 3444
MOD = 1000000007
L='0'+input()

pat1 = 1
pat2 = 0
for i in range(1, len(L)):
    if L[i] == '1':
        pat1, pat2 = pat1*2%MOD, (pat1+pat2*3)%MOD
    else:
        pat1, pat2 = pat1, pat2*3%MOD

print((pat1+pat2)%MOD)


Measured memory_bytes: 39920
m,n = map(int,input().split())
BIGNUM = 10**9+7

def power(m,n):
    if n == 0:
        return 1
    elif n % 2 == 1:
        return (m * power(m**2 % BIGNUM,n//2)) % BIGNUM
    else:
        return power(m**2 % BIGNUM,n//2) % BIGNUM

print(power(m,n))



Measured memory_bytes: 5600
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

#define N_MAX 50
#define MOD 1000000007

int N, K;
pair<int,int> table[N_MAX];

bool check(int a, int b)
{
	int left = min(table[a].first, table[b].first), right = max(table[a].first, table[b].first);
	int bottom = min(table[a].second, table[b].second), top = max(table[a].second, table[b].second);
	int cnt = 0;
	for (int i = 0; i < N; i++){
		if (left <= table[i].first && table[i].first <= right && bottom <= table[i].second && table[i].second <= top){
			cnt++;
		}
	}

	return cnt >= K;
}

lli rect(int a, int b)
{
	int left = min(table[a].first, table[b].first), right = max(table[a].first, table[b].first);
	int bottom = min(table[a].second, table[b].second), top = max(table[a].second, table[b].second);
	return (lli)(right - left)*(lli)(top - bottom);
}

void solv()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++){
		int x, y; scanf("%d%d", &x, &y);
		table[i] = make_pair(x, y);
	}

	lli ret = numeric_limits<lli>::max();
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			for (int k = 0; k < N; k++){
				for (int l = k + 1; l < N; l++){
					int left = min(table[i].first, table[j].first), right = max(table[i].first, table[j].first);
					int bottom = min(table[k].second, table[l].second), top = max(table[k].second, table[l].second);
					int cnt = 0;
					for (int i = 0; i < N; i++){
						if (left <= table[i].first && table[i].first <= right && bottom <= table[i].second && table[i].second <= top){
							cnt++;
						}
					}
					if (cnt >= K){
						ret = min(ret, (lli)(right - left)*(lli)(top - bottom));
					}
				}
			}
		}
	}

	printf("%lld\n", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
char a[100005];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",a);
	int len=strlen(a),s=0;
	for(int i=1;i<len;i++){
		if(a[i]!=a[i-1])s++;
	}
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#define LL long long
#define INF 0x3f3f3f3f3f
int cards[200005];
int n;
LL sum_all;
LL sum;

LL abs(LL x){
  if(x < 0) x = -x;
  return x;
}
int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &(cards[i]));
  }
  
  sum_all = 0;
  for(int i = 0 ; i < n; i++){
    sum_all += cards[i];
  }
  sum = 0;
  LL take = 0; LL min = INF; LL min_take;
  for(int i = 0; i < n-1; i++){
    sum += cards[i];
    take ++;
    LL diff = abs( sum_all - sum - sum);
    if( min > diff ){
      min = diff;
      min_take = take;
    }
 }
  printf("%lld\n", min);
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

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

	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] == k) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	
	}
	
	sort(a.begin(), a.end());
	if (a[n - 1] < k) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int g = gcd(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		g = gcd(g, a[i]);
	}
	
	if (k % g == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[100009];
map<int, int> mp;
vector<int> vec;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int sz = mp.size();

    if (sz > 3) {
        cout << "No" << E;
    }
    else {
        if (n%3 == 0) {
            for (auto x : mp) {
                while (x.se >= n/3) {
                    vec.pb(x.fi);
                    x.se -= n/3;
                }
                if (x.se) break;
            }
            if (vec.size() == 3) {
                int tmp = vec[0]^vec[1];
                tmp = tmp^vec[2];
                if (tmp) cout << "No" << E;
                else cout << "Yes" << E;
            }
            else {
                cout << "No" << E;
            }
        }
        else {
            if (mp.size() == 1 && a[0] == 0) cout << "Yes" << E;
            else cout << "No" << E;
        }
        
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 4224
import numpy as np
from sys import argv
import time


def input_from_file():
    with open(argv[1], "r") as f:
        D = int(f.readline())
        C = np.array(f.readline().split(), dtype=int)
        S = tuple(tuple(map(int, f.readline().split())) for _ in range(D))
    return D, C, S


def input_from_console():
    D = int(input())
    C = np.array(input().split(), dtype=int)
    #S = tuple(tuple(map(int, input().split())) for _ in range(D))
    S = np.array([input().split() for _ in range(D)], dtype=int)
    cand = np.argsort(C * S)[:, 16:] + 1
    return D, C, S, cand.tolist()


def greed(D, C, S):
    last = np.ones(26, dtype=int)
    ans = []
    for s in S:
        s = np.array(s)
        tmp = s + C * last
        i = np.argmax(tmp)
        last[i] = 0
        last += 1
        ans.append(i + 1)
    return ans


def calc_score(D, C, S, T):
    res = 0
    last = np.ones(26, dtype=int)
    for d, t in enumerate(T):
        t -= 1
        last[t] = 0
        score = S[d][t]
        score -= (C * last).sum()
        res += score
        last += 1
    return res


def output_to_file(ans):
    with open("output.txt", "w", newline="") as f:
        for a in ans:
            f.write("{}\n".format(a))


def main():
    start = time.time()
    lim = 1.800
    D, C, S, cand = input_from_console()
    #D, C, S = input_from_file()
    #初期解, 貪欲法
    sol = greed(D, C, S)
    score = calc_score(D, C, S, sol)
    while True:
        d = np.random.randint(0, D)
        q = np.random.choice(cand[d])
        old = sol[d]
        sol[d] = q
        new_score = calc_score(D, C, S, sol)
        if new_score > score:
            score = new_score
        else:
            sol[d] = old
        if time.time() - start >= lim:
            break
    print(*sol, sep="\n")
    # output_to_file(sol)


if __name__ == "__main__":
    main()

Measured memory_bytes: 28040
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, d[100000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> d[i];
	sort(d, d + n);
	cout << d[n / 2] - d[n / 2 - 1] << "\n";
	return 0;
}

Measured memory_bytes: 640
a, b, c = map(int, input().split())
cnt = 0

while cnt <= 10**6:
    if a%2 != 0 or b%2 != 0 or c%2 != 0:
        print(cnt)
        exit()
    
    a_ = b//2 + c//2
    b_ = a//2 + c//2
    c_ = a//2 + b//2

    a = a_
    b = b_
    c = c_

    cnt += 1
print(-1)

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

int main() {
	int a, b;
	cin >> a >> b;
	if (((a*10) + (b*10))% 20 > 4) {
		cout << (a + b) / 2 + 1 << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
B = [[int(input()), i] for i in range(N)]
B.sort()
A = [0] * N
c = 0
for _, i in B:
  A[i] = c
  c += 1

ans = 0
for i, a in enumerate(A):
  diff = abs(i - a)
  if diff % 2:
    ans += 1

print(ans // 2)

Measured memory_bytes: 23644
#include<stdio.h>
int main(){
  int gyou,retu,i,j,A[100][100],B[100],C[100],sum=0;

  scanf("%d %d",&gyou,&retu);
  for(i=0;i<gyou;i++){
    for(j=0;j<retu;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<retu;i++){
    scanf("%d",&B[i]);
  }

  for(i=0;i<gyou;i++){
    for(j=0;j<retu;j++){
      sum+=A[i][j] * B[j];
    }
    printf("%d\n",sum);
    sum = 0;
  }
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int k;
    scanf("%d",&k);
    int ans=(k/2)*((k+1)/2);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		int cnt = 1;
		int bus = 1;
		int tmp = t[0];
		for (int i = 1; i < n; i++) {
			if (cnt < c && (tmp <= t[i] && tmp + k >= t[i])) {
				cnt++;
			} else {
				tmp = t[i];
				cnt = 1;
				bus++;
			}
		}
		System.out.println(bus);
	}
}


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

int main() {
  int a,b,c;
  bool flag = false;
  cin >> a >> b >> c;
  if(a == 5) {
    if(b == 5 || c == 5) {
      if(b == 7 || c == 7) flag = true;
    }
  }
  if(b == 5) {
    if(a == 5 || c == 5) {
      if(a == 7 || c == 7) flag = true;
    }
  }
  if(c == 5) {
    if(b == 5 || a == 5) {
      if(b == 7 || a == 7) flag = true;
    }
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define MAX 1000000005

typedef struct {
char mark;
int number;
} Card;

Card L[N/2+1],R[N/2+1];
void merge(Card A[],int left,int mid, int right){
int i,j,k,n1,n2;

n1 = mid - left;
n2 = right - mid;
for(i=0; i<n1; i++) L[i] = A[left + i];
for(i=0; i<n2; i++) R[i] = A[mid + i];
L[n1].number = MAX;
R[n2].number = MAX;
i = 0;
j = 0;
for(k=left; k<right; k++){
if(L[i].number <= R[j].number){
A[k] = L[i];
i = i + 1;
}
else{
A[k] = R[j];
j = j + 1;
}
}
}


void mergeSort(Card A[],int left,int right){
int mid;
if(left+1 < right){
mid = (left + right) / 2;
mergeSort(A,left,mid);
mergeSort(A,mid,right);
merge(A,left,mid,right);
}
}

int partition(Card A[],int p, int r){
int i,j;
Card x,kari;
x = A[r];
i = p - 1;
for(j=p; j<r; j++){
if(A[j].number <= x.number){
i++;
kari = A[i];
A[i] = A[j];
A[j] = kari;
}
}
kari = A[i+1];
A[i+1] = A[r];
A[r] = kari;

return i+1;
}

void quickSort(Card A[],int p, int r){
int q;
if(p < r){
q = partition(A,p,r);
quickSort(A,p,q-1);
quickSort(A,q+1,r);
}
}

int main(){
int i,num,check=0,suji;
char moji[5];
Card M[N],Q[N];
scanf("%d",&num);
for(i=0; i<num; i++){
scanf("%s""%d",moji,&suji);
M[i].mark = moji[0];
Q[i].mark = moji[0];
M[i].number = suji;
Q[i].number = suji;
}

mergeSort(M,0,num);
quickSort(Q,0,num-1);

for(i=0; i<num; i++){
if(M[i].mark != Q[i].mark) check=1;
}
if(check == 0) printf("Stable\n");
else printf("Not stable\n");
for(i=0; i<num; i++) printf("%c %d\n",Q[i].mark,Q[i].number);

return 0;
}

Measured memory_bytes: 2956
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	static List<String> z;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[][] arr = new int[N][2];
		z = new ArrayList<>();
		String defaultNum="";
		for(int i=0;i<N;i++){
			arr[i][0] =Integer.parseInt(sc.next()); 
			arr[i][1] =Integer.parseInt(sc.next()); 
			defaultNum += i+1;
		}
		permutation(defaultNum, "");
		List<Double> totalList = new ArrayList<>();
		for(String aa : z){
			double distance = 0;
			for(int i=0;i<aa.length()-1;i++){
				int start = Integer.parseInt(aa.substring(i,i+1))-1;
				int goal = Integer.parseInt(aa.substring(i+1,i+2))-1;
				distance += Math.sqrt(Math.pow(arr[start][0]-arr[goal][0], 2) + Math.pow(arr[start][1]-arr[goal][1], 2));
			}
			totalList.add(distance);
		}
		double total = 0;
		for(Double a:totalList) total+=a;
		System.out.println(total/totalList.size());
	}

	private static void permutation(String q, String ans){
		if(q.length() <=1){
			z.add(ans+q);
		} else {
			for(int i=0;i<q.length();i++){
				permutation(q.substring(0,i) + q.substring(i+ 1), ans+ q.charAt(i));
			}
		}
	}
}


Measured memory_bytes: 61020
N = int(input())
L = list(map(int,input().split()))



ans = 0

for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            #print("L[i]:",L[i],"L[j]:",L[j],"L[k]:",L[k])
            if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j] \
            and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                #print("L[i]:",L[i],"L[j]:",L[j],"L[k]:",L[k])
                ans += 1

print(ans)

Measured memory_bytes: 9088
import sys
for line in sys.stdin.readlines():
    t1,t2 = list(map(float, line.split()))

    if t1 < 35.5 and t2 < 71.0:   print("AAA")
    elif t1 < 37.5 and t2 < 77.0: print("AA")
    elif t1 < 40.0 and t2 < 83.0: print("A")
    elif t1 < 43.0 and t2 < 89.0: print("B")
    elif t1 < 50.0 and t2 < 105.0: print("C")
    elif t1 < 55.0 and t2 < 116.0: print("D")
    elif t1 < 70.0 and t2 < 148.0: print("E")
    else: print("NA")


Measured memory_bytes: 5580
#include <iostream>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int n,i;
long long int a,b,ans;

int main(){
  scanf("%d",&n);
  
  a=2;
  b=1;
  for(i=1;i<n;i++){
    ans=a+b;
    a=b;
    b=ans;
  }

  if(n==1){
    printf("%d\n",1);
  }else{
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1000000007;

int main(){
    ll A,B;cin>>A>>B;
    ll C=A,D=B;
    while(D){
        swap(C,D);
        D%=C;
    }
    ll ans=A/C*B;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256