akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll nums[200009];
ll L[200009][2], R[200009][2];

ll calc(ll x,ll y,ll idx){
    x+=nums[idx];
    y-=nums[idx];
    return abs(x-y);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    
    ll A=nums[0],B=0,md=0;
    rep1(i,N-1){
        B+=nums[i];
        while(abs(A-B)>calc(A,B,md+1)){
            md++,A+=nums[md],B-=nums[md];
        }
        L[i][0]=min(A,B);
        L[i][1]=max(A,B);
    }
    
    A=0,B=nums[N-1],md=N-1;
    rrep(i,N-2){
        A+=nums[i];
        while(abs(A-B)>calc(B,A,md-1)){
            md--,B+=nums[md],A-=nums[md];
        }
        R[i][0]=min(A,B);
        R[i][1]=max(A,B);
    }
    
    ll mn=LLINF;
    rep1(i,N-3){
        ll d=max(L[i][1],R[i+1][1])-min(L[i][0],R[i+1][0]);
        if(mn>d) mn=d;
    }
    cout1(mn)
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  vector<int> copy = v;
  sort(ALL(copy), greater<>());
  int f = copy[0];
  int s = copy[1];
  rep(i,n) {
    if (v[i] == f) cout << s << endl;
    else cout << f << endl;
  }
}

int main() {
  solve();
  return 0;
}

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

int main()
{
	int k;cin>>k;
	char s[1005];
	cin>>s;
	int i;
	int len=strlen(s);
	for(i=0;i<min(k,len);i++)
	cout<<s[i];
	if(k<len)
	cout<<"...";
	cout<<endl;
}




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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

string S, T;

int main() {
    cout << fixed << setprecision(15);
    cin >> S >> T;
    int ans = 0;
    REP (i, S.size()) if (S[i] != T[i])
        ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3896
#include <string.h>
#include <stdio.h>
int main(void) {
    char s[100001];
    scanf("%s",s);
    for (int i = 0; i < strlen(s); i++) {
        if ((i + 1) % 2 != 0) {
            putchar(s[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').ToList();
        if (input[0] == "H")
        {
            Console.WriteLine(input[1]);
        }
        else
        {
            if (input[1] == "H")
            {
                Console.WriteLine("D");
            }
            else
            {
                Console.WriteLine("H");
            }
        }
    }
}

Measured memory_bytes: 13268
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
	for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=1005,P=1e9+7;
inline void Add(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
bool vis[N],nt[N];int a[N],q[N],f[605][305][305];
int n,m,t,cnt,ans;
int main(){
//	freopen("testdata.in","r",stdin);
	n=read();
	fp(i,1,n<<1){
		a[i]=read(),a[i]!=-1?vis[a[i]]=1:0;
		if(i&1^1){
			a[i]==-1&&a[i-1]==-1?++cnt:0;
			a[i]!=-1&&a[i-1]!=-1?nt[a[i]]=nt[a[i-1]]=1:0;
		}
	}
	fp(i,1,n<<1)!nt[i]?(vis[i]?q[++t]=1:q[++t]=0):0;
	n=t;
	f[n][0][0]=1;
	fd(i,n,1){
		fp(j,0,n>>1)fp(k,0,n>>1)if(f[i][j][k]){
			R int v=f[i][j][k];
			if(q[i]){
				Add(f[i-1][j+1][k],v);
				k?(Add(f[i-1][j][k-1],v),0):0;
			}else{
				Add(f[i-1][j][k+1],v);
				k?(Add(f[i-1][j][k-1],v),0):0;
				j?(Add(f[i-1][j-1][k],mul(v,j)),0):0;
			}
		}
	}
	ans=f[0][0][0];
	fp(i,2,cnt)ans=mul(ans,i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 221440
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if(S.length() == 3)
        reverse(S.begin(), S.end());
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

need_left = 0
need_right = 0

sp = 0

S.chars.each do |s|
  if s == '('
    sp += 1
  else
    if sp == 0
      need_left += 1
    else
      sp -= 1
    end
  end
end

puts '(' * need_left + S + ')' * sp


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


class Program
{
   
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var d = new Dictionary<string,long>();
        var n = Read();
        
        for(int i = 0; i < n; i++)
        {
            string s=Console.ReadLine();
            if (!d.ContainsKey(s))
                d.Add(s, 1);
            else
                d[s]++;
        }
        
        long max = 0;
        max = d.Values.Max();
        var answer = d.Where(x => x.Value == max).Select(x => x.Key).ToList();
        answer.Sort(StringComparer.Ordinal);
         foreach(string item in answer)
        {         
             Console.WriteLine(item);
        }


      
        Console.Out.Flush();

    }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int64_t L=0,R=0;
	for(int i=0;i<n;++i){
		int64_t t,a; cin>>t>>a;
		if(L<=t&&R<=a){
			L=t,R=a;
		}
		else if(L<=t){
			int64_t mul=(a+R-1)/a;
			L=t*mul,R=a*mul;
		}
		else if(R<=a){
			int64_t mul=(t+L-1)/t;
			L=t*mul,R=a*mul;
		}
		else{
			int64_t mul=max((L+t-1)/t,(R+a-1)/a);
			L=t*mul,R=a*mul;
		}
	}
	cout<<L+R<<"\n"s;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,aa[110000],cnt=1,ma=0;
string s;
signed main()
{
	cin>>a>>s;
	if(a%2==1){
		cout<<"No";
		return 0;
	}
	rep(i,a/2){
		if(s[i]!=s[i+a/2]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S;
	int h, m, s;

	scanf("%d", &S);

	s = S;
	h = s / 3600;	s = s % 3600;
	m = s / 60;		s = s % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

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

using namespace std;

typedef long long ll;

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

int f[2020200];
int fa[2020020];

int find(int x){
	if(x==fa[x]) return x;
	else return fa[x]=find(fa[x]);
}

void merge(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx==fy) return;
	fa[fx]=fy;
}

int main(){
	int n=read();
	int m=read();
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		merge(x,y);
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		if(f[find(i)]==0){
			f[find(i)]=1;
			sum++;
		}
	}
	printf("%d\n",sum-1);
	return 0;
}


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

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
#define fr first
#define sc second

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);
    ll a , b; cin >> a >> b;
    a %= b;
    a = min (a , b - a);
    cout << a << '\n';

    return 0;
}


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

using namespace std;

int area, N, M, a[200009], ap[200009], f[200009];

void add (int i)
{
    if (i <= 0) return ;
    if (++ap[i] == 1)
        area ++;
}

void del (int i)
{
    if (i <= 0) return ;
    if (--ap[i] == 0)
        area --;
}

void increaseF (int x)
{
    f[x] ++;
    add (x - f[x] + 1);
}

void decreaseF (int x)
{
    del (x - f[x] + 1);
    f[x] --;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), increaseF (a[i]);
while (M --)
{
    int pos, val;
    scanf ("%d %d", &pos, &val);
    decreaseF (a[pos]);
    a[pos] = val;
    increaseF (val);
    printf ("%d\n", N - area);
}
return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll N;

	cin >> N;

	vector<ll> A(N+1),B(N);

	fi(N + 1) {
		cin >> A[i];
	}

	fi(N) {
		cin >> B[i];
	}

	ll res = 0;

	fi(N) {
		if (B[i] >= A[i]) {
			res += A[i];
			B[i] -= A[i];
			A[i] = 0;
		}
		else {
			res += B[i];
			A[i] -= B[i];
			B[i] = 0;
		}

		if (B[i] >= A[i+1]) {
			res += A[i + 1];
			B[i] -= A[i+1];
			A[i+1] = 0;
		}
		else {
			res += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}

	}

	ce(res)
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	vector<pair<int,int>> so;
	vector<int> a;
	long long ans=0;
	int n,m,count=0;
	cin >> n >> m;
	a.resize(n);
	so.resize(m);
	REP(i,n){
		cin >> a[i];
	}
	REP(i,m){
		cin >> so[i].second >> so[i].first;
	}
	sort(a.begin(),a.end(),greater<int>());
	sort(so.begin(),so.end(),greater<pair<int,int>>());
	int j=0;
	int su=0;
	while(su < n){
		REP(i,so[j].second){
			a.push_back(so[j].first);
		}
		su += so[j].second;
		j++;
		if(j >= m)break;
	}	
	sort(a.begin(),a.end(),greater<int>());
	REP(i,n){
		ans += a[i];
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 2552
# -*- coding:utf-8 -*-

def solve():
    N, A, B = list(map(int, input().split()))

    ans = 0
    for i in range(1, N+1):
        keta_sum = 0
        num = i
        while True:
            if num == 0:
                break
            keta_sum += num%10
            num = num//10

        if keta_sum >= A and keta_sum <= B:
            ans += i
    
    print(ans)

if __name__ == "__main__":
    solve()


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

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

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

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

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

N=II()
L=LLI(N)

itr = list(itertools.permutations(L))

su=0
for i in itr:
    for x in range(0, N-1):
        su+=math.sqrt((i[x][0]-i[x+1][0])**2 + (i[x][1]-i[x+1][1])**2)
print(su/len(itr))




Measured memory_bytes: 8288
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=987654321;
int a,b;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a>>b;
	if (a>8 || b>8) cout<<":(";
	else cout<<"Yay!";
	return 0;
}


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

int main(){
  ll N, P = 0, Q = 0, p, q, count = 0, ans, i, x;
  cin >> N;
  rep(i, N){
    cin >> x;
    P *= 10;
    P += x;
  }
  rep(i, N){
    cin >> x;
    Q *= 10;
    Q += x;
  }
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
  do {
    int t = 0;
    for(auto x : v){
      t *= 10;
      t += x;
    }
    if(t == P) p = count;
    if(t == Q) q = count;
    count++;
  } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

  ans = p - q;
  if(ans < 0) ans *= -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
const int maxn=500000;
const int INF=2e9;
const int mod=10007;
class Point
{
public:
    double x,y;
    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (double a) {return Point(a*x,a*y);}
    Point operator / (double a) {return Point(x/a,y/a);}
    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}
    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }
    bool operator == (const Point &p) const{
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;
double dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b)
{
    return a.x*b.y-a.y*b.x;
}
bool isOrthogonal(Vector a,Vector b)
{
    return equals(dot(a,b),0.0);
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2)
{
    return isOrthogonal(a1-a2,b1-b2);
}
bool isParallel(Vector a,Vector b)
{
    return equals(cross(a,b),0.0);
}
bool isParallel(Point a1,Point a2,Point b1,Point b2)
{
    return isParallel(a1-a2,b1-b2);
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        Point a1,a2,b1,b2;
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a1.x,&a1.y,&a2.x,&a2.y,&b1.x,&b1.y,&b2.x,&b2.y);
        if(isParallel(a1,a2,b1,b2))
        {
            printf("2\n");
            continue;
        }
        if(isOrthogonal(a1,a2,b1,b2))
        {
            printf("1\n");
            continue;
        }
        printf("0\n");
    }
    return 0;
}



Measured memory_bytes: 3252
import java.util.*;


/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if(a <= c){
            if(b >= c){
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");


    } // mainMethod


} // MainClass


Measured memory_bytes: 24148
#include<stdio.h>

int main(void){
  int n,m,i;
  int p[100001],o[100001],x[100001];
  char a[100001],b[100001];
  scanf("%d %d\n",&n,&m);
  for(i=1;i<=m;i++){
    scanf("%d %c%c\n",&p[i],&a[i],&b[i]);
  }
  
  if(m==0){
    printf("0 0");
    return 0;
  }
  
  for(i=1;i<=n;i++){
    o[i]=0;
    x[i]=0;
  }
  
  for(i=1;i<=m;i++){
    if(a[i]=='A'){
      o[p[i]]=1;
    }else{
      x[p[i]]=x[p[i]]+1-o[p[i]];
    }
  }
  
  int j,O,X;
  O=0;
  X=0;
  for(j=1;j<=n;j++){
    O=O+o[j];
    X=X+x[j]*o[j];
  }
  printf("%d %d",O,X);
  
  return 0;
}

Measured memory_bytes: 1536
H, W, K = map(int, input().split())
table = []
ans = 0
for _ in range(H):
    li = input()
    table.append(li)
for i in range(2**H):
    for j in range(2**W):
        counter = 0
        for k in range(H):
            for l in range(W):
                if (i>>k)&1 and (j>>l)&1 and table[k][l] == "#":
                    counter += 1
        if counter == K:
            ans += 1
print(ans)


Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#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 ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////

int main() {
	double v;
	while (scanf("%lf", &v) != EOF) {
		int N = ceil((4.9 * (v / 9.8) * (v / 9.8) + 5) / 5);
		PRINT(N);
	}
	return 0;
}

// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<functional>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 1000000000
#define ll long long


int main()
{
	string S;
	while (cin >> S, S != ".") {
		int cnt = 0, idx = 0;
		char ans[101];
		stack<int> stk;

		REP(i, 0, S.size()) {
			if (S[i] == '+') cnt++;
			else if (S[i] == '-') cnt--;
			else if (S[i] == '?') {
				ans[idx] = 'A';
				idx++;
				cnt = 0;
			}
			else if (S[i] == '[') {
				stk.push(idx);
			}
			else if (S[i] == ']') {
				int begin = stk.top(), end = idx - 1;
				stk.pop();
				while(end - begin > 0) {
					swap(ans[begin], ans[end]);
					begin++;
					end--;
				}
			}
			else {
				cnt %= 26;
				char tmp = S[i] + cnt;
				if (tmp > 'Z') {
					tmp = tmp - 26;
				}
				if (tmp < 'A') {
					tmp = tmp + 26;
				}
				ans[idx] = tmp;
				idx++;
				cnt = 0;
			}
		}

		ans[idx] = '\0';
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}






int main(){
  int x;
  cin >> x;
  if (x >= 400 && x <= 599) cout << 8 << endl;
  if (x >= 600 && x <= 799) cout << 7 << endl;
  if (x >=800 && x <=999) cout << 6 << endl;
  if (x >= 1000 && x <=1199) cout << 5 << endl;
  if (x >= 1200&& x <= 1399) cout << 4 << endl;
  if (x >= 1400 && x <= 1599) cout << 3 << endl;
  if (x >= 1600 && x <= 1799) cout << 2 << endl;
  if (x >= 1800 && x <= 1999) cout << 1 << endl;
  
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

string s;
map <string,long long> m;
map <string,long long>::iterator it;
int N;
long long sum;

int main() {
    cin.tie(0),ios_base::sync_with_stdio(0);
    cin >> N;
    for(; N; --N) {
        cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(it = m.begin(); it != m.end(); ++it)
        sum += (it -> second) * (it -> second - 1) / 2;
    cout << sum;
    return 0;
}


Measured memory_bytes: 11264
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

isgood = [True] * N
for i, (Ai, Bi) in enumerate(AB):
    if H[Ai - 1] == H[Bi - 1]:
        isgood[Ai - 1] = False
        isgood[Bi - 1] = False
    elif H[Ai - 1] < H[Bi - 1]:
        isgood[Ai - 1] = False
    else:
        isgood[Bi - 1] = False

ans = sum([int(flag) for flag in isgood])

print(ans)

Measured memory_bytes: 32744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n=s.size(),cnt=0;
	rep(i,n) if(s.at(i)=='9') cnt++;
	if(n==cnt || (n-cnt==1 && s.at(0)!='9')){
		int sum=0;
		rep(i,n) sum+=s.at(i)-'0';
		cout << sum << endl;
	}
	else if(n==1){
		cout << n << endl;
	}
	else{
		int sum=0;
		sum+=s.at(0)-'1';
		sum+=(n-1)*9;
		cout << sum << endl;
	}
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		ArrayList array = new ArrayList();
		for(int i= 0;i<a;i++){
			array.add(sc.next());
		}
		for(int i= 0;i<b+2;i++){
			System.out.print("#");
		}
		System.out.println("");
		for(int i= 0;i<a;i++){
			System.out.println("#"+array.get(i)+"#");
		}
		for(int i= 0;i<b+2;i++){
			System.out.print("#");
		}
		System.out.println("");
	}

}

Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
main(){
  int n;
  while(1){
    int sub;
    int sum[105]={0};
    cin >> n;
    if(!n) break;
    for(int i=0;i<n;i++){
      for(int j=0;j<5;j++){
	cin >> sub;
	sum[i]+=sub;
      }
    }
    sort(sum,sum+n);
    printf("%d %d\n",sum[n-1],sum[0]);
  }
}

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

int main(){
  long long N,A,B,result=0;
  cin>>N>>A>>B;
  if(A>B){
    long long tmp;
    tmp=A;
    A=B;
    B=tmp;
  }
  if((B-A)%2==0){
    result=(B-A)/2;
  }else if(A<=N-B){
    result+=A;
    B-=A;
    A=1;
    if(A!=B){
      result+=(B-A)/2;
    }
  }else{
    result+=N-B+1;
    A+=N-B+1;
    B=N;
    if(A!=B){
      result+=(B-A)/2;
    }
  }
  cout<<result;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d",&a,&b);
	if(a<b)printf("a < b\n");
	else if(a==b)printf("a == b\n");
	else printf("a > b\n");
	
	return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1<<29;
using Graph = vector<vector<int>>;
int main() {
    string S; cin >> S;
    if (S=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
    using namespace std;
    #include <boost/multiprecision/cpp_int.hpp> 
    using namespace boost::multiprecision; 
    #define int int128_t

     
    int32_t main(){
        
    	int x;
    	cin>>x;
    	int a = 100;
    	int t = 0;
    	while(a<x){
    		a = a*101;
    		a = a/100;
    		t++;
    	}
    	cout<<t;
    }

Measured memory_bytes: 3652
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int X;
	cin >> X;

	int n500 = X / 500;
	int n5 = (X - 500 * n500) / 5;

	cout << 1000 * n500 + 5 * n5 << endl;

	
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	scanf("%d",&n);
	vector<int>count(100004);
	rep(i, n) {
		int a;
		scanf("%d",&a);
		FOR(j, a, a + 3) {
			count[j]++;
		}
	}
	int ans = *max_element(all(count));
	printf("%d\n",ans);
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	double taiju;
	double sincho;
	int bango;
	char d;
	double BMI;

	while (cin >> bango >> d >> taiju >> d >> sincho) {
		BMI = taiju / (sincho * sincho);
		if (BMI >= 25) {
			cout << bango << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];

    map<string, int> dic;
    rep(i,N) dic[S[i]]++;
    int cnt = 0;
    for (auto s : dic) {
        chmax(cnt,s.second);
    }
    vector<string> ans;
    for (auto s : dic) {
        if (cnt==s.second) ans.emplace_back(s.first);
    }
    sort(all(ans));
    for (auto i : ans) cout << i << ln;
}

Measured memory_bytes: 27120
#include <iostream>
#include <sstream>
#include <string>

#if defined SUBLIME
#  define ISTREAM ss
#else
#  define ISTREAM cin
#endif


using namespace std;
int main()
{
	#if defined SUBLIME
		string str = "23 2";
		stringstream ss;
		ss << str;
	#endif
	int a, b;
	int cnt = 0;
	ISTREAM >> a >> b;
	cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,i;
    while(scanf("%d",&n)!=EOF){
            printf("%d: ",n);
        for(i=2; i<=sqrt(n); i++){
            while(n%i==0){
                printf("%d",i);
                n/=i;
                if(n!=1)printf(" ");
            }
        }
        if(n!=1)printf("%d\n",n);
        else printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2100
import java.util.Scanner;

public class Main {
	static long[] calcLoopNum(long X , long M){
		long sum = 0;
		int vis[] = new int[(int)M + 1];
		int ln = 0;
		while(vis[(int)X] != 1){
			++ln;
			sum += X;
			vis[(int)X] = 1;
			X = (X * X) % M;
		}
		return new long[]{ln, sum};
	}
	static long solve(long N , long X , long M){
		if(N <= 2 * M){
			long ret = 0;
			for(int i = 0 ; i < N ; ++i){
				ret += X;
				X = (X * X) % M;
			}
			return ret;
		}
		long ret = 0;
		int vis[] = new int[(int)M + 1];
		long n = 0;
		while(vis[(int)X] != 1){
			++n;
			ret += X;
			vis[(int)X] = 1;
			X = (X * X) % M;
		}
		N -= n;
		long loop[] = calcLoopNum(X, M);
//		System.out.println(N+" "+ret+" "+X+" "+loop[0]+" "+loop[1]);
		ret += loop[1] * (N / loop[0]);
		N -= loop[0] * (N / loop[0]);
//		System.out.println(N+" "+ret+" "+X+" "+loop[0]+" "+loop[1]);
		ret += solve(N , X , M);
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long X = sc.nextLong();
		long M = sc.nextLong();
		long r = solve(N , X , M);
		System.out.println(r);
	}
}


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


int main(){

   int a,b;
   cin >> a >> b;
   if(a<=2*b) cout << 0 << endl;
   else{
      cout << a - 2*b << endl;
    }
  return 0;
}


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

using namespace std;

int main(void) {
	int N, M;
	int K;
	cin >> N >> M >> K;

	//読書時間の合計時間表
	int A[200050], B[200050];
	//読まないときは0
	A[0] = 0;
	B[0] = 0;
	//考慮する意味のある範囲
	int A_max = N;
    bool A_check = false; 
	int B_max = M;
    bool B_check = false; 
	for (int i = 1; i <= N; i++) {
		int Ai;
		cin >> Ai;
		A[i] = Ai + A[i - 1];
		if (A[i] > K&&(!A_check)) {
			//i冊目を考える必要は皆無
			A_max = i-1;
          A_check =true;
		}
	}
	for (int i = 1; i <= M; i++) {
		int Bi;
		cin >> Bi;
		B[i] = Bi + B[i - 1];
		if (B[i] > K&&(!B_check)) {
			//i冊目を考える必要は皆無
          B_max = i-1;
          B_check =true;
		}
	}


	//Aの読む本数を増やして走査
	int ans = 0;
	int Screen_Index[200050]; //Bの操作位置に関する関する情報
	Screen_Index[0] = B_max; //A=0のとき、Bは一番大きいところから走査する。
	for (int i = 0; i <= A_max; i++) {
		for (int j = Screen_Index[i]; j>=0; j--) {
			//オーバーしなくなったら抜け出す
			if (A[i] <= K - B[j]) {
              if(i+1<=N) Screen_Index[i + 1] = j;
				ans = max(ans, i + j);
				break;
			}
		}
	}

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

Measured memory_bytes: 5428
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    ll n = s.size();
    ll ans = 0;
    rep(i,n-1){
        if(s[i] != s[i+1])ans++;
    }

    cout << ans << endl;
}

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

int binarySearch(int *,int *, int, int);


int main() {
  int i, n, q, *S, *T;

  scanf( "%d" , &n );
  S = (int *)malloc((n+1) * sizeof(int));
  for( i=0; i<n; i++ ) scanf( "%d" , &S[i] );
  scanf( "%d" , &q );
  T = (int *)malloc(q * sizeof(int));
  for( i=0; i<q; i++ ) scanf( "%d" , &T[i] );

  printf( "%d\n" , binarySearch(S, T, n, q) );

  return 0;
}

int binarySearch(int *S, int *T, int n, int q) {
  int j, left, right, mid, count=0;

  for ( j=0; j<q; j++ ) {
    left = 0;
    right = n;
    while ( left < right ) {
      mid = (left + right) / 2;
      if ( S[mid] == T[j] ) {
	count++;
	break;
      }
      else if ( T[j] < S[mid] ) right = mid;
      else left = mid + 1;
    }
  }

  return count;
}



Measured memory_bytes: 2308
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  bool same(int x, int y) {
    return (find(x) == find(y));
  }

};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m, ng = 0;
  cin >> n >> m;

  UnionFind uf(n+1);
  vector<int> a(m), b(m);
  ng = n * (n-1) / 2;

  rep(i, m){
    cin >> a[i] >> b[i];
  }

  vector<int> ans(m);

  for(int i = m-1; i >= 0; --i){
    ans[i] = ng;
    if(!uf.same(a[i], b[i])){
      ng -= uf.size(a[i]) * uf.size(b[i]);
    }
    uf.unite(a[i], b[i]);
  }

  for(auto e : ans){
    cout << e << '\n';
  }

  return 0;
}

Measured memory_bytes: 4480
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MOD = 1000000007;
    int N;
    cin >> N;
    ll res = 1;
    REP(i, N) {
        res *= i + 1;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  [itmo] enot.1.10
 *    created: 21.08.2016 15:12:43       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */

const int N = 1e5 + 10;

pi a[N];

int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    int n;
    scanf("%d", &n);
    forn(i, n) scanf("%d", &a[i].F);
    forn(i, n) a[i].S = i;
    sort(a, a + n);
    int res = 0;
    forn(i, n) if (i % 2 != a[i].S % 2) res++;
    res /= 2;
    printf("%d\n", res);
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	X := NextInt()
	T := NextInt()

	ans := (N / X) * T
	if N%X != 0 {
		ans += T
	}

	fmt.Println(ans)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}


Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>

#include<bits/stdc++.h>

using namespace std;

struct UnionFind{
    vector<int> par,sz;

    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }

    int find(int x){
        if(par[x]==x){return x;}
        else {
            return par[x]=find(par[x]);
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y){return;}

        if(sz[x]<sz[y]){
            sz[y]+=sz[x];
            par[x]=y;            
        }else{
            sz[x]+=sz[y];
            par[y]=x;
        }
    }

    int size(int x){
        return sz[find(x)];
    }
};

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

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

        A[i]--;
        B[i]--;
    }

    UnionFind uf;
    uf.init(N);

    vector<long long> ans(M);
    ans[M-1]=(1ll*(N-1)*N)/2;

    for(int i=1;i<M;i++){
        if(!uf.same(A[M-i],B[M-i])){
            ans[M-1-i]=ans[M-i]-1ll*uf.size(A[M-i])*uf.size(B[M-i]);
            uf.unite(A[M-i],B[M-i]);
        }else{
            ans[M-1-i]=ans[M-i];
        }
    }

    for(int i=0;i<M;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  if(s == "Cloudy")cout << "Rainy" << endl;
  if(s == "Rainy")cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE(x) ((x).size())
#define PB push_back
#define FI first
#define SE second
#define _ << " " <<

using namespace std;

typedef pair<int, int> Vec;

int xa, xb, ya, yb;

bool read() {
    if (!(cin >> xa >> ya >> xb >> yb)) {
        return false;
    }
    return true;
}

void solve() {
    int xc, yc, xd, yd;
    Vec ba  = Vec(xa-xb, ya-yb);
    Vec iba = Vec(ba.SE, -ba.FI);
    Vec ab  = Vec(xb-xa, yb-ya);
    Vec iab = Vec(ab.SE, -ab.FI);

    xc = xb + iba.FI;
    yc = yb + iba.SE;
    Vec cb  = Vec(xb-xc, yb-yc);
    Vec icb = Vec(cb.SE, -cb.FI);

//  xd = xa + iab.FI;
//  yd = ya + iab.SE;
//  cout << xc _ yc _ xd _ yd << '\n';

    xd = xc + icb.FI;
    yd = yc + icb.SE;
    cout << xc _ yc _ xd _ yd << '\n';
}

int main(void) {
    while (read())
        solve();
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll i, n, least = LL_INF;
	cin >> n;
	for (i = 0; i <= n; i++){
		ll a = i, b = n - i, ac = 0, bc = 0;
		while (a != 0){
			ac += a % 6;
			a /= 6;
		}
		while (b != 0){
			bc += b % 9;
			b /= 9;
		}
		least = min(least, ac + bc);
	}
	cout << least << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

// 約数記録
#define divi_size 1000001
ll divi[divi_size]={};
ll makedivi(ll n){
    while(n%2==0){
        n/=2;
        divi[2]++;
    }
    repp(i,3,divi_size,2){
        if(n<i) break;
        while(n%i==0){
            n/=i;
            divi[i]++;
        }
    }
    // printf("%lld ",n);
    if(n>1) return 2;
    return 1;
    // return n;
}

int main(void){
    // char ;
    ll a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    if(gcd(a,b)==1){
        printf("1\n");
        return 0;
    }
    // printf("%lld ",gcd(a,b));
    ans+=makedivi(gcd(a,b));
    // printf("%lld ",ans);
    rep(i,0,divi_size){
        if(divi[i]){ 
            ans++;
            // printf("%lld %lld ",i,divi[i]);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const int mod=1e9+7;
const int N=2e5+5;
int n,a[N],b[N],ans;
vector<int>v;

int main()
{
   cin>>n;
   for(int i=1;i<=n;i++){ 
       cin>>a[i];
   } 
   for(int i=n;i>=1;i--){ 
       int sum=0;
       for(int j=i;j<=n;j+=i){ 
           sum+=b[j];
       }
       if(sum%2!=a[i]){ 
           b[i]++;
           v.push_back(i);
       }
   }
   reverse(v.begin(),v.end());
   cout<<v.size()<<'\n';
   for(int i=0;i<v.size();i++){ 
       cout<<v[i]<<" ";
   }
 

     
    return 0;
}

Measured memory_bytes: 2936
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-7
#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 lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+7;
const long long Maxx=2e18;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
int a[10];
void solve(){
	int ans=inf;
	For(i,1,3) cin>>a[i];
	sort(a+1,a+4);
	ans=a[2]-a[1]+a[3]-a[2];
	cout<<ans<<endl;
}
int main(){
//  fre("in.txt","r",stdin);
    int t=0;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	int n; cin >> n;
	int ans = 0;
	rep(i, 1, n + 1) {
		string s = to_string(i);
		ans += (int)s.size() % 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3736