akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
using namespace std; void solve();
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
  int main(){solve_dbg();}
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>;
constexpr int MOD = 998244353;
random_device seed_gen; mt19937_64 mtrand(seed_gen());

//////////////////////////////////////////

void solve(){
  ini(M,D);
  int ans = 0;
  for(int m = 1; m <= M;m++){
    for(int d = 10; d <= D; d++){
      int d1 = d % 10 , d10 = d / 10;
      if(d1 < 2) continue;
      if(d10 < 2)continue;
      if(d1 * d10 != m) continue;
      ans++;
    }
  }
  out(ans);
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int n, k=1;
    vector< pair<int,int> > points;
    while( cin >> n, n ){
        points.clear();
        for( int i=0; i<n; i++ ){
            int x, y;
            cin >> x >> y;
            points.push_back( make_pair(x,y) );
        }
        points.push_back( make_pair( points[0].first, points[0].second ) );
        double sum=0;
        for( int i=0; i+1<points.size(); i++ ){
            sum += ((points[i].second+points[i+1].second)*(points[i+1].first-points[i].first))/2.0;
        }
        printf("%d %.1f\n", k++, fabs(sum) );
    }
    return 0;
}

Measured memory_bytes: 1224
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static long[] d = new long[11];
	public static ArrayDeque<Long> que = new ArrayDeque<Long>();
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
		sc.close();
		long ans = 0;
		if(k<10) {
			ans = k;
		} else {
			int cnt = k-9;
			for (long l = 1;  l < 10; l++) {
				que.add(l);
			}
LABEL:		while(true) {
				long l2 = que.remove();
				long l3 = l2 % 10;
				l2*=10;
				for (long l = Math.max(l3-1, 0); l <= Math.min(l3+1, 9); l++) {
					ans = l2 + l;
//					out.println(ans);
					cnt--;
					if(cnt<=0) break LABEL;
					que.add(ans);
				}
			}
		}
		out.println(ans);
	}
}


Measured memory_bytes: 25940
#include <bits/stdc++.h>
// make_tuple emplace_back next_permutation push_back make_pair second first
// setprecision

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
   public:
    LL n;
    vector<LL> a, c;
    Solver(LL n) : n(n), a(n + 1), c(n + 1){};

    void solve() {
        a[0] = -1;
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        for (int i = n + 1 - 1; i >= 1; --i) {
            if (a[i] > a[i - 1] + 1) {
                cout << -1 << "\n";
                return;
            }
        }
        LL ans = 0;
        for (int i = n + 1 - 1; i >= 1; --i) {
            if (!c[i]) ans += a[i];
            if (a[i - 1] == a[i] - 1) c[i - 1] = 1;
        }
        cout << ans << "\n";
    }
};
}  // namespace Problem

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n = 0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
 ll a,b,x; cin >> a >> b >> x;
 ll c = (a+x-1)/x*x, d = b/x*x;
 cout << (d-c)/x + 1 << endl;
 
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

string s;

void solve() {
	cin >> s;


	if (s[0] == s[1]) {
		cout << 1 << " " << 2 << endl;
		return;
	}

	for (int i = 2; i < s.size(); i++) {
		if (s[i - 2] == s[i] || s[i - 1] == s[i]) {
			cout << i - 1 << " " << i + 1 << endl;
			return;
		}
	}

	cout << -1 << " " << -1 << endl;
}

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

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <algorithm>

constexpr int MAX_N=100,INF=(int)1e9;

int n;
int dat[MAX_N];
std::set<int> set[MAX_N];
int a[MAX_N],b[MAX_N],c[MAX_N],d[MAX_N];

int main() {

    std::cin>>n;

    for(int i=0;i<n;++i)
        std::cin>>a[i]>>b[i];

    for(int i=0;i<n;++i)
        std::cin>>c[i]>>d[i];

    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            if(a[i]<c[j]&&b[i]<d[j]){
                set[j].emplace(i);
                ++dat[i];
            }
        }
    }

    std::sort(set,set+n,[](auto&& lhs,auto&& rhs){
        return lhs.size()<rhs.size();
    });

    std::set<int> res;

    int ans=0;

    for(int i=0;i<n;++i){
        std::set<int> tmp;
        for(auto x : set[i]){
            if(!res.count(x))
                tmp.emplace(x);
        }
        if(tmp.empty())
            continue;
        int min=INF,minv;
        for(auto x : tmp){
            if(min>dat[x]){
                min=dat[x];
                minv=x;
            }
        }
        res.emplace(minv);
        ++ans;
    }

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main() {

	int n, a[100000];
	cin >> n;
	rep(i,0,n) cin >> a[i];

	int ans = 0;
	rep(i,0,n) {
		if(i+1 == a[a[i]-1]) ans++;
	}

	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x,i,j,k=1;string s;cin>>x;
  while(k*(k+1)/2<x) k++;
  for(j=0;j<2;j++) for(i=0;i<k;i++) s+=')'-j;
  for(i=0;i<k*(k+1)/2-x;i++) swap(s[k-i-1],s[k-i]);
  cout << s << endl;
  return 0;
}

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

int main() {
    //
    int num;
    int cnt = 0;

    cin >> num;

    vector<int> vec(num);

    for (int i = 0; i < num; i++) cin >> vec.at(i);

    sort(vec.begin(), vec.end());

    for (int i = 0; i < num; i++) {
        for (int j = i + 1; j < num; j++) {
            int k = lower_bound(vec.begin(), vec.end(), vec.at(i) + vec.at(j)) - vec.begin();

            cnt += max(k - (j + 1), 0);
        }
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3612
// Problem : B - FizzBuzz Sum
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	ll sum = 0;
	RI(i, n) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;
	return 0;
}
 


Measured memory_bytes: 3656
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)

typedef long long ll;

using namespace std;

int N;

//i:  1 2 3 4 5
//P:  2 3 4 5 1
//i%P:1 2 3 4 0

// 1 2 3 4 5 6 7 8  9 10 11 12 13
// 2 3 4 5 6 7 8 9 10 11 12 13  1
// 1 2 3 4 5 6 7 8  9 10 11 12

int main(void) {
    scanf("%d", &N);
    ll ans = 0;
    REP(i, 1, N) ans += i;
    
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 1000000007
#define MAX 100005
using namespace std;

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

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);

    string g;
    cin >> g;
    if(g[2] == g[3] and g[4] == g[5]) cout << "Yes";
    else cout << "No";

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

using ll = long long int;

ll a[1000001];

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

    int index = 2;
    a[1] = 1;
    //generate fizzbuzz
    for (int i = 2; i <= 1000000; i++)
    {
        if (!(i % 3 == 0 || i % 5 == 0))
        {
            a[index] += a[index-1] + i;
        }
        else
        {
            a[index] = a[index-1];
        }
        index++;
    }

    int n;
    cin >> n;
    cout << a[n] << '\n';
    return 0;
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int mod = 1e9 + 7;
int n;
int m;
ll a[200000 + 10] = {};


int main() {
	cin >> n;
	forn(i) {
		cin >> a[i];
	}
	ll ans = 0;
	ll temp = 0LL;
	int r = -1;
	for (int l = 0; l < n; l++) {
		if (r < l) {
			r = l;
			temp = a[l];
			ans++;
		}else if (l != 0 )temp -= a[l - 1];

		while( (!(temp&a[r + 1])) &&(r<n-1) ) {
			r++;
			ans += r - l + 1;
			temp += a[r];
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  string s;
  int q;
  cin >> s >> q;

  bool flag = true;
  string ff = "", bb = "";
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      flag = !flag;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (flag)
          ff += c;
        else
          bb += c;
      } else {
        if (flag)
          bb += c;
        else
          ff += c;
      }
    }
  }

  if (flag) {
    reverse(ff.begin(), ff.end());
    cout << ff + s + bb << endl;
  } else {
    reverse(s.begin(), s.end());
    reverse(bb.begin(), bb.end());
    cout << bb + s + ff << endl;
  }

  return 0;
}


Measured memory_bytes: 1348
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if((a*b)%2==0){
            System.out.println("Even");
        }
        else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21972
import sys
input = sys.stdin.readline

def main():
    N,M,P = map(int,input().split())
    edges = []


    for _ in range(M):
        A,B,C = map(int,input().split())
        edges.append([A-1,B-1,P-C])

    inf = 10000*(10**5)
    dist = [inf for _ in range(N)]
    dist[0] = 0

    for i in range(N-1):
        for edge in edges:
            if dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]]+edge[2]
    ans = -1*dist[N-1]
    
    for i in range(N-1):
        for edge in edges:
            if dist[edge[1]] > dist[edge[0]]+edge[2]:
                dist[edge[1]] = dist[edge[0]]+edge[2]
    ans2 = -1*dist[N-1]

    if ans2<=ans: 
        print(max(0,ans))         
    else:
        print(-1)

if __name__ == "__main__":
    main()


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

using namespace std;

int n,l,dp[100005],a[100005];

int func(int i){

  if(i>n)return 0;
  if(dp[i]>0)return dp[i];
  if(a[i]>a[i-1] && a[i]>a[i+1])return l-a[i];

  int res=0;
  if(a[i]<a[i-1])res=max(res,func(i-1));
  if(a[i]<a[i+1])res=max(res,func(i+1));

  return dp[i]=l-a[i]+res;
}

int main(void){
  
  while(cin >> n >> l){
    
    for(int i=0;i<n+2;i++)dp[i]=0;

    for(int i=1;i<n+1;i++)
      cin >> a[i];

    a[0]=a[n+1]=0;

    int res=0;
    for(int i=1;i<n+1;i++)
      res=max(res,func(i));

    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3120
import math

for list in range(100):
  a, op, b = map(str, input().split())

  if op == "+":
    output = int(a) + int(b)
    print(output)
  elif op == "-":
    output = int(a) - int(b)
    print(output)
  elif op == "*":
    output = int(a) * int(b)
    print(output)
  elif op == "/":
    output = float(a) / float(b)
    print(math.floor(output))
  elif op == "?":
    break


Measured memory_bytes: 5672
n=input()
a = list(map(int, input().split()))
ans=1
az=a.count(0)

if az>0:
    print(0)
else:
    for i in range(len(a)):
        ans*= a[i]
    
        if ans>=1000000000000000001:
            ans=-1
            break
    print(ans)


Measured memory_bytes: 21572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    vector<int> v(5);
   vector<int> c(5);
    int k;
    for(int i=0;i<5;i++){
      cin>>v[i];
      if(v[i]%10==0)c[i]=10;
      else c[i]=v[i]%10;
    }
    sort(v.begin(),v.end());
  sort(c.begin(),c.end());
    int count=0;
   for(int i=0;i<5;i++){
       if(v[i]%10!=0){
           count=count+(v[i]/10+1)*10;
       }
       else count=count+v[i];
     //cout<<count<<endl;
   }
 // cout<<count<<endl;
  //for(int i=0;i<5;i++)cout<<c[i]<<" ";
    cout<<count-10+c[0]<<endl;
}

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = 1.01e9;

int solve(string s) {
    int n = s.length();
    const int K = 4;
    vector<vector<int>> dp(n + 1, vector<int>(K, -1));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < K; j++) {
            if (dp[i][j] == -1) continue;

            string old = "";
            if (i - j + 1 >= 0 && j > 0) {
                old = s.substr(i - j, j);
            }

            for (int k = 1; k < K; k++) {
                if (i + k <= n) {
                    string nw = s.substr(i, k);
                    if (old != nw) {
                        dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
                    }
                }
            }
//            cout << dp[i][j] << " ";
        }
//        cout << endl;
    }
    return *max_element(dp[n].begin(), dp[n].end());
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    string s;
    while (cin >> s) {
        cout << solve(s) << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


Measured memory_bytes: 11396
#include<stdio.h>
#include<stdlib.h>
#define  N 100

main(){
  int A[N],n,a,i,j,count=0;

  scanf("%d",&n);
  if(n>N)
    exit(1);

  for( i= 0 ; i< n ; i++)
    scanf("%d",&A[i]);

  for (i = 0;i < n-1; i++){
    for (j = n - 1; j > i; j--){
      if (A[j - 1] > A[j]){
	a = A[j];
	A[j] = A[j - 1];
	A[j - 1] = a;
	count++;
      }
    }
  }
  for( i=0 ; i<n ;i++){
    printf("%d",A[i]);
    if ( i != n - 1)
      printf(" ");
  }
 
  printf("\n%d\n",count);
   
  return 0;
  
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int countT = 0, countA = 0;

    while (A > 0) {
        A -= D;
        countA++;
    }

    while (C > 0) {
        C -= B;
        countT++;
    }

    if (countT <= countA) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main (void)
{
	int i=0;
	int flag=1;
	int n,A[100];
	int j;
	int tmp;
	int cou=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	while(flag){
		flag=0;
		for(j=n-1;j>=1;j--){
			if(A[j] < A[j-1]){
				tmp=A[j];
				A[j]=A[j-1];
				A[j-1]=tmp;
				cou++;
				flag=1;
			}
		}
	}
	for(i=0;i<n-1;i++){
		printf("%d ",A[i]);
	}
	printf("%d\n%d\n",A[n-1],cou);

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  set<int> s;
  REP(i,N){
    int A;
    cin>>A;
    s.insert(A);
  }
  if(s.size()==N)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 9728
// 8 puzzle
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#define N  3
#define N2 9
using namespace std;
struct Puzzle{
    int f[N2];
    int space;
    string path;
    bool operator < (const Puzzle &p) const
    {
        for (int i = 0; i < N2; ++i)
        {
            if (f[i] == p.f[i]) continue;
            return f[i] < p.f[i];            
        }
        return false;
    }
};
 
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u','l','d','r'};
 
bool isTarget(Puzzle p)
{
    for (int i = 0; i < N2; ++i)
    {
        if (p.f[i] != (i+1)) return false;
    }
    return true;
}
 
string bfs(Puzzle s)
{
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u,v;
    s.path = "";
    Q.push(s);
    V[s] = true;
    while(!Q.empty())
    {
        u = Q.front(); Q.pop();
        if (isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for (int r = 0; r < 4; ++r)
        {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if( tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if (!V[v])
            {
 
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}
 
int main()
{
    Puzzle in;
    for (int i = 0; i < N2; ++i)
    {
        cin>>in.f[i];
        if (in.f[i]==0) {
            in.space = i;
                in.f[i] = 9;
        }
    }
    string ans = bfs(in);
    cout<<ans.size()<<endl;
    return 0;
}


Measured memory_bytes: 30604
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

int main()
{
	ios::sync_with_stdio(false);
	string s, p = "";
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; i++)
		if (s[i] != 'x')
			p += s[i];
	string rp = p;
	reverse (rp.begin(), rp.end());
	if (p != rp)
		return (cout << -1 << endl), 0;
	vector <int> v;
	int d = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'x')
			d++;
		else {
			v.pb(d);
			d = 0;
		}
	}
	v.pb(d);
	int m = v.size(), ans = 0;
	for (int i = 0; i < m-i-1; i++)
		ans += abs(v[i] - v[m-i-1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<utility>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int  unsigned long long
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define sp setprecision(9)
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
int32_t main()
{
	//CHECK IF NEGATIVE INPUT UNSIGNED->SIGNED
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	vector<pair<int,int> >v;
	for(int i=0;i<n;i++)
	{
		//cout<<"Enter"<<endl;
		int cnt1=0,cnt2=0;
		if(i!=0){
			for(int j=0;j<=i-1;j++)
			{
				if(arr[j]<arr[i])
					cnt1++;
			}
		}
		//cout<<"Enter"<<endl;
		if(i!=n){
			for(int j=i+1;j<n;j++)
			{
				if(arr[j]<arr[i])
					cnt2++;
			}
		}
		//cout<<cnt1<<" "<<cnt2<<endl;
		v.pb({cnt1,cnt2});
	}
	int ans=0;
	//fr(i,v.size())
	//cout<<v[i].F<<" "<<v[i].S<<endl;
	for(int i=0;i<n;i++)
	{
		int ans1=((k%ccM)*(v[i].S%ccM))%ccM;
		int j=k-1;
		int l=k;
		if((j)%2==0)
		{
			j/=2;
		}
		if((l)%2==0)
		{
			l/=2;
		}
		//cout<<j<<" "<<l<<endl;
		int ans2=(((v[i].S+v[i].F)%ccM)*((k*(k-1)/2)%ccM))%ccM;
		//cout<<ans1<<" "<<ans2<<endl;
		ans=(ans%ccM+ans1%ccM+ans2%ccM)%ccM;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 256
A, B, C = gets.split.map(&:to_i)
K = gets.to_i
k = 0
b = B
while b <= A
    k += 1
    b *= 2
end
c = C
while c <= b
    k += 1
    c *= 2
end
if k <= K
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 14312
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
void solve()
{

    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    return;
}

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


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

#define fi first
#define se second
#define amen exit(0)

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 100007;
const ll Inf = 1000000007;

int main()
{
    ll n, x;
    ll res = 0;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        cin >> x;
        while (x % 2 == 0)
        {
            res++;
            x /= 2;
        }
    }
    cout << res << endl;
    amen;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    string ans=(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])?"YES":"NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int ADD = A+B;
  int SUB = A-B;
  int MUL = A*B;
  if(ADD < SUB){
    if(SUB < MUL){
      cout << MUL << endl; return 0;
    }else{
      cout << SUB << endl; return 0;
    }
  }else{
    if(ADD < MUL){ cout << MUL << endl; return 0;}
    else{ cout << ADD << endl; return 0;}
  }
}

Measured memory_bytes: 256
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
  tmp = [int(j) for j in input().split()]
  s.append(tmp)
  
sat = 0
lst = [0 for i in range(26)]

for i in range(D):
  satlst = [0 for j in range(26)]
  for j in range(26):
    sattmp = sat + s[i][j]
    for k in range(26):
      if j != k:
        sattmp -= c[k] * ((i + 1) - lst[k])
    satlst[j] = sattmp
  sat = max(satlst)
  lst[satlst.index(sat)] = (i + 1)
  print(satlst.index(sat) + 1)


Measured memory_bytes: 9532
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {  
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int flag = 0;
		for(int i=1;i<=9;i++) {
			for(int j=1;j<=9;j++) {
				if(i*j==n) {
					flag = 1;
				}
			}
		}
		if(flag==1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int MAX = 1000000;
//flagを用いたバブルソート
int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j] < A[j - 1]){
                //隣接要素を交換する
                swap(A[j], A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i = 0;i < N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

	return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

void printPoint(P p) {
    cout << fixed << setprecision(10) << p.real() << " " << p.imag() << endl;
}

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

P projection(P p, P a, P b) {
    p -= a; b -= a;
    return dot(p, b) * b / abs(b) / abs(b) + a;
}

P reflection(P p, P a, P b) {
    P t = projection(p, a, b);
    return 2. * t - p;
}

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

    P a = readP(), b = readP();
    int n;
    cin >> n;
    rep(i, n) {
        P p = readP();
        printPoint(projection(p, a, b));
    }
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double

const int N=3005;

int n;
double p[N];
bool vis[N][N];
double cache[N][N];

double dp(int idx, int heads)
{
	if(idx==n+1)
		return (heads*2>=n);
	double &ans=cache[idx][heads];
	if(vis[idx][heads])
		return ans;
	vis[idx][heads]=1;
	ans=p[idx]*dp(idx+1, heads+1) + (1-p[idx])*dp(idx+1, heads);
	return ans;
}

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	double ans=dp(1, 0);
	cout<<fixed<<setprecision(12)<<ans;
	return 0;
}

Measured memory_bytes: 148608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    ll n;
    cin >> n;
    vector<ll> m(5);
    for(ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(s[0] == 'M') m[0]++;
        else if(s[0] == 'A') m[1]++;
        else if(s[0] == 'R') m[2]++;
        else if(s[0] == 'C') m[3]++;
        else if(s[0] == 'H') m[4]++;
    }

    ll ans = 0;
    for(ll i = 0; i < 5; i++)
    {
        for(ll j = i+1; j < 5; j++)
        {
            for(ll k = j + 1; k < 5; k++)
            {
                ans += m[i] * m[j] * m[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<set>
#include<string.h>
using namespace std;
const int MAX = 100;
int main() {
	long double a, b;
	cin >> a >> b;
	cout << (long long)(a * b);
	return 0;
}

Measured memory_bytes: 3784
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n: usize = get_input().parse().unwrap();
    let mut rx: Vec<(String, i64, usize)> = Vec::new();

    for i in 0..n {
        let line = get_input();
        let mut split = line.split_whitespace();
        let s = split.next().unwrap().chars().collect();
        let p:i64 = split.next().unwrap().parse().unwrap();
        rx.push((s, -p, i + 1));
    }

    rx.sort();

    for r in rx {
        println!("{}", r.2);
    }
}

Measured memory_bytes: 4352
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

const int mod = 2019;

int main()
{

  ll l, r;
  cin >> l >> r;
  ll mi = 2000000010;

  for (int i = l; i < r&&i<l+2020;i++){
    for (int j = i + 1; j <= r&&j<=l+2020;j++){
      ll r1 = i % mod;
      ll r2 = j % mod;
      // cout << r1 << " " <<r2<< endl;
      mi = min(mi, r1 * r2 % mod);
    }
  }

  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int c = sc.nextInt();
    long k = sc.nextLong();
    long[] t = new long[n];
    for(int i = 0; i < n; i++) {
      t[i] = sc.nextLong();
    }
    Arrays.sort(t);
    int ans = 0;
    int bus = 0;
    while(bus < n) {
      ans++;
      int left = bus;
      int right = n;
      int bus2 = bus;
      while(left < right) {
        int med = (left + right) / 2;
        if((t[med] - t[bus]) <= k) {
          bus2 = med;
          left = med + 1;
        } else {
          right = med;
        }
      }
      bus2 = Math.min(bus2, bus + c - 1);
      bus = bus2 + 1;
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main() {
	int a, b, k, num = 0;
	int order = 1;
	cin >> a >> b >> k;

	for (int i = min(a, b); i > 0; i--) {
		if (a % i == 0 && b % i == 0) {
			if (order == k) {
				num = i;
				break;
			}
			else order++;
		}
	}

	cout << num << endl;

	return 0;
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let m = {}
    while(hasNext()){
        let tmp = next().split("").sort().join("")
        if(!m[tmp]) m[tmp] = 1
        else m[tmp]++
    }
    let ans = 0
    for(let key of Object.keys(m)){
        let tmp = m[key]
        if(tmp >1) ans += tmp*(tmp-1)/2
    }
    console.log(ans)
}
Main()


Measured memory_bytes: 61324
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int N;
    cin >> N;
    
    FOR(h, 1, 3500)FOR(n, 1, 3500){
        double w = -N*n*h*1./(N*n+N*h-4*h*n);
        if((int)w == w && w > 0){
            cout << setprecision(15) << h << " " << n << " " << w << endl;
            return 0;
        }
    }

    return 0;
}

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

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int n;
    cin>>n;
    ll ans=1;
    rep(i,n){
        ans*=10;
        ans%=mod;
    }
    ll a=1;
    rep(i,n){
        a*=9;
        a%=mod;
    }
    ll b=1;
    rep(i,n){
        b*=8;
        b%=mod;
    }
    ans=ans-a-a+b;
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// http://drken1215.hatenablog.com/entry/2019/03/24/091900
int main() {
    int N;
    cin >> N;
    string a = to_string(N);
    int res = 0;
    REP(i, a.length()) { res += a[i] - '0'; }
    if(res == 1) {
        res = 10;
    }
    cout << res << endl;
    return 0;
}

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

long long pow(int a, int b){
    long long i=1;
    for(int j=0; j<b;j++){
        i *= a;
    }
    return i;
}

int main(){
    long long N, p;
    cin >> N;
    p=1;

    for (int i=1; i<=N; i++){
        p *= i;
        p %= (pow(10,9)+7);
    }

    cout << p << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

template <class T>
class SegTree{
public:
    vector<T> arr;
    function<T(T,T)> f;
    T ini;
    uint n;
    SegTree(int N, function<T(T,T)> func, T ini_){
        f=func;
        ini=ini_;
        n=1;
        while(n<N)n<<=1u;
        arr.assign(2*n-1, ini);
    }

    void update(uint i, T val){
        i+=n-1;
        arr[i]=val;
        while(i>0){
            i=(i-1)/2;
            arr[i]=f(arr[2*i+1],arr[2*i+2]);
        }
    }

    T find(uint s, uint t){
        return __find(s,t,0,0,n);
    }
private:
    T __find(uint s, uint t, uint k, uint l, uint r){
        if(t<=l || s>=r)return ini;
        if(s<=l && t>=r)return arr[k];
        T vl=__find(s,t,2*k+1,l,(l+r)/2);
        T vr=__find(s,t,2*k+2, (l+r)/2, r);
        return f(vl,vr);
    }
};

void solve(long long N, std::vector<long long> A){
    vector<LL> B(A);
    sort(all(B));
    rep(i,N)A[i]=(lower_bound(all(B),A[i])-B.begin());
    LL ans=0;
    rep(i,N)if(i%2 != A[i]%2)ans++;

    cout << ans/2 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  string s;
  cin >> s;

  if(s[0] == '?'){
    s[0] = 'D';
  }

  rep(i, 1, s.length()){
    if(s[i] == '?'){
      s[i] = 'D';
    }
  }

  cout << s << endl;


  return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    pair< ll,ll> p[N];
    ll i;
    ll a,b;
    for(i=0;i<N;i++){
        cin >> a >> b;
        p[i]=make_pair(b,a);
    }
    sort(p,p+N);
    ll sum=0;
    for(i=0;i<N;i++){
        sum+=p[i].second;
        if(p[i].first<sum){
            cout << "No";
            return 0;
        }
    }
            cout << "Yes";
    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;

    if (U == S){
        cout << A - 1 << " " << B << endl;
    } else {
        cout << A << " " << B - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,v[300002];
bool check2(int a,int b)
{
	int l=1,r=a;
	while(l<=r)
	{
		if((v[l]+v[r])%m>b)return 0;
		l++,r--;
	}
	return 1;
}
bool check(int mid)
{
	int lb=1,rb=n,as=1;
	while(lb<=rb)
	{
		int md=(lb+rb)>>1;
		if(check2(md,mid))as=md,lb=md+1;
		else rb=md-1;
	}
	if(as==n)return 1;
	if(as&1)as--;
	int mnl=0,mxr=as;
	for(int i=n;i>n/2;i--)
	{
		int lb=0,rb=i,as=i;
		while(lb<=rb)
		{
			int mid1=(lb+rb)>>1;
			if(v[mid1]+v[i]>=m)as=mid1,rb=mid1-1;
			else lb=mid1+1;
		}
		if(mnl<as-(n-i+1))mnl=as-(n-i+1);
		lb=as,rb=i;
		if(v[as]+v[i]>m+mid)return 0;
		while(lb<=rb)
		{
			int mid1=(lb+rb)>>1;
			if(v[mid1]+v[i]<=m+mid)as=mid1,lb=mid1+1;
			else rb=mid1-1;
		}
		if(mxr>as-(n-i+1))mxr=as-(n-i+1);
		if(mnl&1)mnl++;
		if(as*2+i>=n&&mnl<=i*2-n-2&&mxr>=i*2-n-2)return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&m);n*=2;
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	sort(v+1,v+n+1);
	int lb=0,rb=m-1,as=m-1;
	while(lb<=rb)
	{
		int mid=(lb+rb)>>1;
		if(check(mid))as=mid,rb=mid-1;
		else lb=mid+1;
	}
	printf("%d\n",as);
}//

Measured memory_bytes: 896
using System;

class Program
{
    class Heap
    {
        private int[] hp = new int[150000];
        private int size = 0;
        private void Swap(int _x, int _y)
        {
            int tt;
            tt = hp[_x];
            hp[_x] = hp[_y];
            hp[_y] = tt;
        }
        private void Mtup(int _x)
        {
            if (_x == 1) return;
            if (hp[_x] < hp[_x / 2])
            {
                Swap(_x, _x / 2);
                Mtup(_x / 2);
            }
        }
        private void Mtdn(int _x)
        {
            int tt;
            if (_x * 2 > size) return;
            if (_x * 2 + 1 > size) tt = _x * 2;
            else if (hp[_x * 2] < hp[_x * 2 + 1]) tt = _x * 2;
            else tt = _x * 2 + 1;
            if (hp[_x] > hp[tt])
            {
                Swap(_x, tt);
                Mtdn(tt);
            }
        }
        public void Add(int _n)
        {
            size++;
            hp[size] = _n;
            Mtup(size);
        }
        public int Popup()
        {
            Swap(1, size);
            size--;
            Mtdn(1);
            return hp[size + 1];
        }
    }
    static void Main(string[] args)
    {
        Heap P = new Heap();
        Heap Q = new Heap();
        int[] _P = new int[150000];
        int[] _Q = new int[150000];
        long[] sumP = new long[150000];
        long[] sumQ = new long[150000];
        string[] str = Console.ReadLine().Split(' ');
        int w = int.Parse(str[0]);
        int h = int.Parse(str[1]);
        int i;
        long ans = 0;
        for (i = 0; i < w; i++) P.Add(int.Parse(Console.ReadLine()));
        for (i = 0; i < h; i++) Q.Add(int.Parse(Console.ReadLine()));
        for (i = 0; i < w; i++)
        {
            _P[i] = P.Popup();
            if (i == 0) sumP[i] = _P[i];
            else sumP[i] = sumP[i - 1] + _P[i];
        }
        for (i = 0; i < h; i++)
        {
            _Q[i] = Q.Popup();
            if (i == 0) sumQ[i] = _Q[i];
            else sumQ[i] = sumQ[i - 1] + _Q[i];
        }
        int _pw = w - 1;
        int _ph = h - 1;
        while ((_pw >= 0) && (_ph >= 0))
        {
            if (_P[_pw] > _Q[_ph])
            {
                ans = ans + sumQ[_ph] + _P[_pw];
                _pw--;
            }
            else
            {
                ans = ans + sumP[_pw] + _Q[_ph];
                _ph--;
            }
        }
        if (_pw == -1) ans = ans + sumQ[_ph];
        else ans = ans + sumP[_pw];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 10712
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    ll n;
    cin >> n;
    ll ans = (n - 1) * n / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256