akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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


/* ACL */

//using namespace atcoder;



int main(){
    ll X,K,D;
    cin >> X >> K >> D;
    X = abs(X);

    if(X / D >= K){
        cout << X-K*D << endl;
        return 0;
    }

    K -= X / D;
    X = X % D;

    if(K % 2 == 0){
        cout << X << endl;
    }else{
        cout << D - X << endl;
    }
    return 0;


}

Measured memory_bytes: 3604
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	vector<int> d(n); for (int i = 0; i <= n - 1; i++) cin >> d[i];
	sort(d.begin(), d.end());

	int ans = 0;
	for (int i = 0; i <= 1e5; i++) {
		int j = lower_bound(d.begin(), d.end(), i) - d.begin();
		if ((n - j) == (n / 2)) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3296
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] v = new double[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }

        double ans = 0;
        Arrays.sort(v);
        for (int i = 0; i < n-1; i++) {
            ans = (v[i] + v[i+1]) / 2;
            v[i+1] = ans;
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int D,N;
    cin >> D >> N;
    int inc;
    if(D == 0) inc = 1;
    if(D == 1) inc = 100;
    if(D == 2) inc = 10000;
    if(N < 100) cout << inc * N << endl;
    else cout << inc * 101 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            var t = ReadLine();

            bool f = false;
            if (t.Substring(0, s.Length) == s) f = true;
            IO.WriteLineYes_or_No(f);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 25692
#include <iostream> 
using namespace std;
 
int main(){
  int W, H, x, y, r;
 
  cin >> W >> H >> x >> y >> r;
  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3084
n,m,d=map(int,input().split())
field=[]
for i in range(n):
    field.append(input())
ans=0
for i in field:
    ren=0
    j=i.split("#")
    for k in j:
        if len(k)>=d:ans+=len(k)-d+1
field_r = [list(x) for x in zip(*field)]
for i in range(m):
    field_r[i]="".join(map(str,field_r[i]))
for i in field_r:
    ren=0
    j=i.split("#")
    for k in j:
        if len(k)>=d:ans+=len(k)-d+1
print(ans)


Measured memory_bytes: 5672
//AOJ 0183
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s[3];
	char w;
	while (1) {
		w = 'q';
		for (auto& i : s) {
			cin>>i;
			if(i == "0") return 0;
		}
		bool end = false;
		for (int i = 0; i < 3; i++) {
			char c = s[i][0];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[i][j] != c) {flag = false;break;}
			if(flag && s[i][0] != '+') putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		for (int i = 0; i < 3; i++) {
			char c = s[0][i];
			bool flag = true;
			for (int j = 0; j < 3; j++)
				if(s[j][i] != c) {flag = false;break;}
			if(flag && s[0][i] != '+') putchar(c),putchar('\n'),end = true;
		}
		if(end) goto fin;
		w = s[0][0];
		end = true;
		for (int i = 0; i < 3; i++)
			if(s[i][i] != w){end = false;break;}
		if(end && w != '+') {putchar(w);putchar('\n');goto fin;}
		w = s[0][2];
		end = true;
		for (int i = 0; i < 3; i++) {
			if(s[i][2-i] != w) {end = false;break;}
		}
		if(end && w != '+') putchar(w),putchar('\n');
fin:
		if(!end || w == '+') puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int a[999],n,sum=0,ans=0,f;
bool fff=0,vis[999];

bool dfs(int cnt,int now,int val)
{
	if(cnt==0)
	{
		if(val%10)
		{
			if(ans<val)
				ans=val;
			return true;
		}
		return false;
	}

	for(int i=now+1;i<=n;i++)
		if(dfs(cnt-1,i,val-a[i]))
			return true;
	return false;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
		if(a[i]%10)
			f=1;
	}
	sort(a+1,a+n+1);

	if(!f)
	{
		puts("0");
		return 0;
	}	

	for(int i=0;i<=n;i++)
		if(dfs(i,0,sum))
			break;

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


class Main{
    public static void main(String[] args){
        int n,h = 0;
        int[] a = null;
        int[] b = null;
        Index index = new Index();
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String s = reader.readLine();
            String[] temp = s.split(" ");
            n = Integer.parseInt(temp[0]);
            h = Integer.parseInt(temp[1]);
            a = new int[n];
            b = new int[n];
            for(int i=0;i<n;i++){
                s = reader.readLine();
                temp = s.split(" ");
                a[i] = Integer.parseInt(temp[0]);
                b[i] = Integer.parseInt(temp[1]);
            }
        } catch (IOException e){}
        int c = 0;
        Index value = index.calc(a);
        int aIndex = value.first;
        Arrays.sort(b);
        int i = b.length -1;
        while(true){
            if(i < 0){
                if(h % a[aIndex] == 0){
                    c += h / a[aIndex];
                } else{
                    c += h / a[aIndex] + 1;
                }
                break; 
            }
            if(b[i] > a[aIndex]){
                h -= b[i];
                c++;
                i--;
                if(h <= 0){
                    break;
                }
            }else{
                if(h % a[aIndex] == 0){
                    c += h / a[aIndex];
                } else{
                    c += h / a[aIndex] + 1;
                }
                break;
            }
        }
        System.out.println("" + c);
    }
           
    
}
class Index {
    int first;
    int second;

    public Index calc(int[] a){
        Index index = new Index();
        int max = a[0];
        int second = 0;
        int k = 0;
        int j = 0;
        for(int i=1;i<a.length;i++){
            if(a[i] >= max){
                second = max;
                max = a[i];
                j = k;
                k = i;
            }else{
                if(a[i] > second){
                    second = a[i];
                    j = i;
                }
            }
        }
        if(k == j || a[j] == 0){
            index.first = k;
            index.second = -1;
            return index;
        }
        index.first = k;
        index.second = j;
        return index;
    }
}


Measured memory_bytes: 47608
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	string s;
	cin >> s;
	s[0] = '2';
	s[1] = '0';
	s[2] = '1';
	s[3] = '8';
	cout << s << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE ViewPatterns #-}
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Char

main = replicateM 3 B.getLine >>= B.putStrLn . solve 'a' . edit
    where
        edit (w : x : y : _) = (w, x, y)

solve :: Char -> (B.ByteString, B.ByteString, B.ByteString) -> B.ByteString
solve 'a' (B.uncons -> Just (x, xs), ys, zs) = solve x (xs, ys, zs)
solve 'b' (xs, B.uncons -> Just (y, ys), zs) = solve y (xs, ys, zs)
solve 'c' (xs, ys, B.uncons -> Just (z, zs)) = solve z (xs, ys, zs)
solve w _ = B.singleton $ toUpper w


Measured memory_bytes: 380
#include "bits/stdc++.h"

// マクロ群
#define REP(i,n) for(int i=0;i<n;++i)
#define REP2(i,a,b) for (int i=(a);i<(b);++i)
#define rep(n) REP(i,n)
#define SF(f,v) scanf(f,v)
#define SF_N(v) SF("%d",&v)
#define SF_S(v) SF("%s",v)
#define PF(f,v) printf(f,v)
#define PFS_N(v) PF("%d ",v)
#define PFS_S(v) PF("%s ",v)
#define PFL_N(v) PF("%d\n",v)
#define PFL_S(v) PF("%s\n",v)


using namespace std;

const int ARRMAX = 1024;

void Slove()
{
	int N;
	SF_N(N);
	vector<int> A(N);
	rep(N) SF_N(A[i]);

	bool ans = true;
	rep(N) if (bitset<1>(A[i])[0] != 0) ans = !ans;

	PFL_S( ans ? "YES" : "NO");
}

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=400+10,MAXM=100000+10;
int n,m,ans,imp[MAXN];
std::bitset<MAXN> f[MAXN];
struct node{
	int u,v;
};
node side[MAXM];
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void init()
{
	REP(i,1,n)
	{
		f[i][i]=true;
		DEP(j,m,1)
		{
			if(f[i][side[j].u]&&f[i][side[j].v])
			{
				imp[i]=1;
				break;
			}
			if(f[i][side[j].u]||f[i][side[j].v])f[i][side[j].u]=f[i][side[j].v]=true;
		}
	}
}
int main()
{
	read(n);read(m);
	REP(i,1,m)
	{
		int u,v;read(u);read(v);
		side[i]=(node){u,v};
	}
	init();
	REP(i,1,n)if(!imp[i])REP(j,i+1,n)if(!imp[j])
		if((f[i]&f[j]).any()==0)ans++;
	write(ans,'\n');
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
bool cmp(char *str1, char *str2) {
    int i = 0;
    while (str1[i] != '\0') {
        if (str2[i] == '\0') return false;
        if (isupper(str2[i])) str2[i] = tolower(str2[i]);
        if (str1[i] != str2[i]) return false;
        i++;
    }
    if (str2[i] == '\0') return true;
    else return false;
}
int main(void){
    int cnt = 0;
    char W[11] ;
    char T[1001];
    cin >> W;
    int i = 0;
    while (W[i] != '\0') {
        if (isupper(W[i])) W[i] = tolower(W[i]);
        i++;
    }
    while (1) {
        cin >> T;
        if (!strcmp(T, "END_OF_TEXT")) break;
        if (cmp(W, T)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3068
def kai(t):
    if len(t) > 1:
        c = len(t)//2
        c = int(c)
        u = t[:c]
        w = t[-c:]
        w = w[::-1]
        if u == w:
            return True
        else:
            return False
    elif len(t) == 1:
        return True

s = input()
n = len(s)
a = int((n-1)/2)
b = s[:a]
c = s[-a:]

if (kai(s) == True) and (kai(b) == True) and (kai(c) == True):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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 ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  char tmps = s[0];
  ll lans = 0;
  rep(i, 1, s.size()) {
    if (tmps != s[i]) {
      lans++; tmps=s[i];
    }
  }
  tmps = s[s.size()-1];
  ll rans = 0;
  for (ll i=s.size()-2; i>=0; i--) {
    if (tmps != s[i]) {
      rans++; tmps=s[i];
    }
  }
  cout << min(lans, rans) << endl;
  return 0;
}


Measured memory_bytes: 512
N, K, Q = list(map(int, input().split()))

players = [0 for n in range(N)]
for q in range(Q):
  players[int(input())-1] += 1

for n in range(N):
  if(K - (Q - players[n]) > 0):
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 4672
import bisect


def lis():
    L.append(A[0])
    length = 1
    
    for i in range(1, n):
        if L[length-1] < A[i]:
            L.append(A[i])
            length += 1
        else:
            if L[bisect.bisect_left(L, A[i])] >= A[i]:
                L[bisect.bisect_left(L, A[i])] = A[i]
            else:
                L[bisect.bisect_right(L, A[i])] = A[i]
    return length


n = int(input())
A = []
L = []
for i in range(n):
    A.append(int(input()))

print(lis())















Measured memory_bytes: 10344
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n, x; cin>>n>>x;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin>>l[i];

    vector<int> d(n+10);
    d[1] = 0;
    for(int i=0; i<n; i++){
        d[i+2] = d[i+1] + l[i];
    }

    int ans = 0;
    for(int i=1; i<=n+1; i++){
        if(d[i] <= x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 45-A

int main(void)
{
	int a, b, h;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &h);
	printf("%d", (a+b)*h/2);
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int N,Q;
    string S;
    cin>>N>>Q>>S;
    vector<int>A(N+1,0);
    rep(i,N-1){
        if(S[i]=='A'&&S[i+1]=='C')A[i+1]=A[i]+1;
        else A[i+1]=A[i];
    }
    rep(i,Q){
        int a,b;
        cin>>a>>b;
        a--,b--;
        cout<<A[b]-A[a]<<endl;
    }
    return 0;
}

//a=97,z=122

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

using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i=0; i<N; i++) cin >> L[i];

    sort(L.begin(), L.end());
    long long ans = 0;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            int a = L[i];
            int b = L[j];
            // c < a + b
            // c > a - b
            // c > b - a
            int low = max(a-b, b-a);
            int high = a + b;
            int lowIdx = upper_bound(L.begin(), L.end(), low) - L.begin();
            lowIdx = max(lowIdx, j+1);
            int highIdx = lower_bound(L.begin(), L.end(), high) - L.begin();
            ans += highIdx - lowIdx;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char n[4];
	
	scanf("%s",n);
	
	if(n[1]==n[2]){
		if(n[0]==n[1] || n[2]==n[3]){
			printf("Yes");
		}else printf("No");
	}else printf("No");
	
	return 0;
}


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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for (int i = 0; i < n + 1; i++) {
        if (s == t) {
            cout << "Yes";
            return 0;
        }
        char c = s.back();
        s.pop_back();
        s = c + s;
    }
    cout << "No";
}

Measured memory_bytes: 256
import numpy as np
N = int(input())

U = 55556
is_prime = np.full(U+1, True)
is_prime[:2] = False
for p in range(2, U+1):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p] = False


ans = []
i = 2
while len(ans) < N and i < 55556:
    if i % 5 == 1 and is_prime[i] == True:
        ans.append(i)
    i += 1
print(*ans)


Measured memory_bytes: 26996
#import <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007ll
 
int k;
long long res = 0;
long long fac[2000005];
string s;

long long inv(long long n) {
	long long p = 1000000005ll;
	long long ans = 1; 
    while(p > 0) {
        if(p%2) ans = (ans*n)%MOD; 
        p /= 2; 
        n = (n*n)%MOD;
    } 
   
    return ans; 
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k >> s;
	
	fac[0] = 1;
	long long pow = 1;
	long long pow2 = 1;
	for(int i = 0; i < k; i++) pow = (pow*25)%MOD;
	for(int i = 0; i < k+s.length(); i++) fac[i+1] = (fac[i]*(i+1))%MOD;
	
	for(int i = 0; i < k+1; i++) {
		res = (res+((((((fac[k+s.length()-i-1]*inv(fac[s.length()-1])%MOD)*inv(fac[k-i]))%MOD)*pow)%MOD)*pow2)%MOD)%MOD;
		pow2 = (pow2*26)%MOD;
		pow = (pow*inv(25))%MOD;
	}
	
	cout << res << endl;
}


Measured memory_bytes: 19820
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUIntListFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO ()
main = do

    [aX,aY,aZ] <- getIntList
    let ret = (show aZ) ++ " " ++ (show aX) ++ " " ++ (show aY)
    putStrLn ret



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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int ans = 0;
  REP(i, N-1){
    if(S[i] != S[i+1]) ans++;
  }
  cout << ans << endl;
}

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

bool is(long long n);

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    long long s,a,c;
    cin>>s;
    for(int i=0;i<s;i++){
        cin>>a;
        if(is(a)){
            c++;
        }
    }
    cout<<c<<"\n";
   return(0);
}
bool is(long long n){
    if(n==2) return true;
    if(n<=1 || n%2==0) return false;
    for(long long i=3;i*i<=n;i++){
        if(n%i==0) return false; 
    }
    return true;
}


Measured memory_bytes: 3168
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let t = V.sum as
        bs = V.scanl1 (+) as
        cs = V.map (\x -> t - x) bs
        ds = V.zipWith (\x y -> abs (x - y)) bs cs
    print $ V.minimum $ V.init ds


Measured memory_bytes: 10876
# coding: utf-8
# Your code here!
h,w = [int(i) for i in input().split()]
b = [input() for _ in range(h)]
MOD = 10**9+7
dp=[0]*w
dp[0]=1
for i in range(h):
    for j in range(w):
#        print(i,j)
        if b[i][j] == "#":
            dp[j] = 0
        elif j > 0:
            dp[j] += dp[j-1]
            dp[j] %= MOD
#    print(dp)
print(dp[w-1])



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

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<pair<int, int>> V;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    V.emplace_back(x, y);
  }
  int ans = n;
  for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) {
    auto C = V;
    int dx = V[i].first - V[j].first, dy = V[i].second - V[j].second;
    auto dot = [=](pair<int, int> A, pair<int, int> B) {
      return A.first * B.first + B.second * A.second;
    };
    sort(C.begin(), C.end(), [&](pair<int, int> A, pair<int, int> B) {
      return
      dot(A, {-dy, dx}) == dot(B, {-dy, dx}) ? dot(A, {dx, dy}) < dot(B, {dx, dy}) :
      dot(A, {-dy, dx}) < dot(B, {-dy, dx}) ; 
    });
    int cur = 1;
    for (int i = 1; i < n; ++i) {
      cur += pair<int, int>{C[i].first - dx, C[i].second - dy} != C[i - 1];
    }
    ans = min(cur, ans);
  }
  cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int dp[MAX_N][62];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n),y(n-1);
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n-1){
        y[i] = x[i+1] - x[i];
    }
    vector<int> vec(n-1);
    rep(i,n-1){
        vec[i] = i;
    }
    int m;
    ll K;
    cin >> m >> K;
    rep(i,m){
        int a;
        cin >> a;
        swap(vec[a-2],vec[a-1]);
    }
    rep(i,n-1){
        dp[i][0] = vec[i];
    }
    rep(i,60){
        rep(j,n-1){
            dp[j][i+1] = dp[dp[j][i]][i];
        }
    }
    rep(i,n-1){
        vec[i] = i;
    }
    vector<int> tmp(n-1);
    rep(keta,60){
        if(K & (1LL<<keta)){
            rep(i,n-1){
                tmp[i] = dp[vec[i]][keta];
            }
            rep(i,n-1){
                vec[i] = tmp[i];
            }
        }
    }
    ll val = x[0];
    rep(i,n){
        cout << val << "\n";
        if(i < n-1){
            val += y[vec[i]];
        }
    }
    return 0;
}


Measured memory_bytes: 27904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll>ans(N);
    rep(i,M){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        ans[a]++;
        ans[b]++;
    }

    rep(i,N){
        cout<<ans[i]<<endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//
// Union-Find tree
//
// verified:
//   AOJ Course DSL_1_A Set - Disjoint Set: Union Find Tree
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
//


/*
    ・併合時の工夫: union by size
    par[x]: x が根のときは x を含むグループのサイズ (の -1 倍)、そうでないときは親ノード
    issame(x, y): x と y が同じグループにいるか, 計算量はならし O(α(n))
    merge(x, y): x と y を同じグループにする, 計算量はならし O(α(n))
    size(x): x を含むグループの所属メンバー数
*/

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, Q; cin >> N >> Q;
    UnionFind uf(N);
    for (int q = 0; q < Q; ++q) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) uf.merge(x, y);
        else {
            if (uf.issame(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main() {
	int a, b, n;
	int amari;
	int sum;
	int kari;
	while (cin >> a >> b >> n) {
		amari = a % b;
		sum = 0;
		for (int i = 0; i < n; i++) {
			amari *= 10;
			sum += amari / b;
			amari = amari % b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    
    int K;
    int A, B;
    cin >> K;
    cin >> A >> B;
    
    int K_bai = (B / K) * K;
    
    if(K_bai >= A){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }


}


Measured memory_bytes: 3112
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto nq = readInts();
		auto n = nq[0];
		auto q = nq[1];
		if((n|q) == 0) return;

		alias data = Tuple!(int, "w", int, "b", string, "n");
		data[] list;
		for(int i; i < n; ++i) {
			auto l = readln().chomp().split();
			list ~= data(l[2].to!int - l[1].to!int + 1, l[1].to!int, l[0]);
		}
		list.sort();
		for(int i; i < q; ++i) {
			auto w = readInt();
			auto e = list.assumeSorted.lowerBound(data(w+1, 0, ""));
			if(e.empty || e.back.w + e.back.b - 1 < w) {
				writeln("Unknown");
			} else {
				writeln(e.back.n, " ", w - e.back.w + 1);
			}
		}
	}
}

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

namespace ABC127
{
    class P
    {
        public int B;
        public long C;
        public P(int a, long b)
        {
            B = a;
            C = b;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            long[] A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();
            P[] BC = new P[M];

            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                int B = int.Parse(s[0]);
                long C = long.Parse(s[1]);
                BC[i] = new P(B, C);
            }

            BC = BC.OrderByDescending(x => x.C).ToArray();

            long res = 0;
            int Acount = 0;
            int Bcount = 0;

            for (int i = 0; i < N; i++)
            {
                if (Acount < N && Bcount < M)
                {
                    if (A[Acount] < BC[Bcount].C)
                    {
                        res += BC[Bcount].C;
                        BC[Bcount].B--;
                        if (BC[Bcount].B == 0)
                        {
                            Bcount++;
                        }
                    }
                    else
                    {
                        res += A[Acount];
                        Acount++;
                    }
                }
                else if (Acount < N)
                {
                    res += A[Acount];
                    Acount++;
                }
                else if (Bcount < M)
                {
                    res += BC[Bcount].C;
                    BC[Bcount].B--;
                    if (BC[Bcount].B == 0)
                    {
                        Bcount++;
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 35292
import sys
H,W = input().split()
H,W = int(H),int(W)
board = [["0" for w in range(W+2)] for h in range(H+2)]

for h in range(H):
    tmp = list(input())
    for w in range(W):
        board[h+1][w+1] = tmp[w]

ansboard = [["." for w in range(W+2)] for h in range(H+2)]

for h in range(H+2):
    for w in range(W+2):
        if board[h][w] == 0:
            pass
        elif board[h][w] == ".":
            counter = 0
            for j in range(3):
                for i in range(3):
                    if board[h-(j-1)][w-(i-1)] == "#":
                        counter += 1
            ansboard[h][w] = counter
        else:
            ansboard[h][w] = "#"

for h in range(H):
    for w in range(W):
        sys.stdout.write(str(ansboard[h+1][w+1]))
    sys.stdout.write("\n")




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

int c[27], s[366][27], t[366], last[27];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365);
    auto bestscore=calc_score();

    for(int A=10000; A--; ) {
        int d=rndD(engine);
        int q=rndT(engine);
        int x=t[d];
        t[d]=q;
        auto score=calc_score();
        if (bestscore<score) {
            bestscore=score;
        }
        else {
            t[d]=x;
        }
    }
}


Measured memory_bytes: 3692
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
string s;
int t,num[150],cnt;
int main(){
    while(cin>>t){
        map<int,int> m;
        cnt=0;
        for(int i=0;i<t;i++){
            cin>>num[i];
            if(m[num[i]]!=1){
                m[num[i]]=1;
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sc scanf
#define pr printf
using namespace std;
int ans[2005];
int main()
{
	int n, a, b;
	sc("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			int t = min(abs(j - b) + abs(i - a) + 1, j - i);
			ans[t]++;
		}
	}
	for (int i = 1; i < n; i++)
		pr("%d\n", ans[i]);
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;
    int x = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        } else {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef pair <int, int> ii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

string s;
int cnt[30];
vector <int> ind[30];
int res[(int)2e5 + 5];

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

	cin >> s;
	int n = s.size();
	s = ' ' + s;
	for (int i = 1; i <= n; ++i) {
		cnt[s[i] - 'a']++;
		ind[s[i] - 'a'].push_back(i);
	}
	int r = -1;
	for (int i = 0; i < 26; ++i) if (cnt[i] & 1) {
		if (~r) {
			cout << -1 << endl;
			return 0;
		}
		r = i;
	}
	vector <ii> p; p.clear();
	for (int c = 0; c < 26; ++c) {
		int sz = ind[c].size();
		vector <int> T = ind[c];
		for (int i = 1; i <= sz / 2; ++i) if (T[i - 1] != T[sz - i]) {
			p.push_back({T[i - 1], T[sz - i]});
		}
	}
	sort(p.begin(), p.end());
	int cnt = 0;
	for (ii v : p) {
		// cerr << v.first << ' ' << v.second << endl;
		cnt++;
		res[cnt] = v.first;
		res[n - cnt + 1] = v.second;
	}
	if (~r) {
		res[n / 2 + 1] = ind[r][ind[r].size() / 2];
	}
	ordered_set S; S.clear(); S.insert(res[1]);
	int ans = 0;
	for (int i = 2; i <= n; ++i) {
		ans += i - 1 - S.order_of_key(res[i]);
		S.insert(res[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17756
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
  int key;
  struct Node* prev;
  struct Node* next;
};
typedef struct Node* NodePointer;
NodePointer head;
void init();
NodePointer search(int); 
void insert(int); 
void delete(int);
void deleteFirst(); 
void deleteLast();
int main()
{
  int i,n,m;
  NodePointer j;
  char str[17];
  init();
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&m);
      insert(m);
    }
    else if(!strcmp(str,"delete")){
      scanf("%d",&m);
      delete(m);
    }
    else if(!strcmp(str,"deleteFirst")) deleteFirst();   
    else if(!strcmp(str,"deleteLast")) deleteLast();   
  }   
  for(j = head->next; j!=head;){
    printf("%d",j->key);
    if((j=j->next) != head) printf(" ");
  }
  printf("\n");   
  return 0;
}
void init(){
  head = (NodePointer)malloc(sizeof(struct Node));
  head->prev = head;
  head->next = head;
}
NodePointer search(int s){
  NodePointer x = head->next;
  while(x!=head && x->key != s) x = x->next;
  return x;
}
void insert(int m){
  NodePointer x;
  x=(NodePointer)malloc(sizeof(struct Node));
  x->key = m;
  x->next = head->next;
  head->next->prev = x;
  head->next = x;
  x->prev = head;
}
void delete(int del){
  NodePointer x = search(del);
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
void deleteFirst(){
  NodePointer x = head->next;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}
void deleteLast(){
  NodePointer x = head->prev;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}

Measured memory_bytes: 34972
#include <stdio.h>
#include <stdint.h>

int64_t totalYokin(int64_t yokin){
  return yokin * 1.01;
}

int main()
{
  int64_t yokin = 100;
  int64_t x;
  int year = 0;

  scanf("%ld",&x);

  while (yokin < x) {
    yokin = totalYokin(yokin);
    year++;
  }
  printf("%d\n", year);
  return 0;
}



Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const long INF=1e9;
int N;long K;
long A[size],F[size];
long sum(long temp){
	long sum=0;
	rep(i,0,N) sum+=min(A[i],temp/F[i]);
	return sum;
}
long binary(long k){
	long a=0,b=1e12;
	while(b-a>1){
		if(sum((a+b)/2)<k) a=(a+b)/2;
		else b=(a+b)/2;
	}
    return b;
}
int main(){
	cin>>N>>K;
    long sum=0;
	rep(i,0,N){ cin>>A[i]; sum+=A[i]; }
	rep(i,0,N) cin>>F[i];
    sort(A,A+N,greater<long>());
    sort(F,F+N);
    if(sum<=K){ cout<<0<<endl; return 0; }
	cout<<binary(sum-K)<<endl;
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* https://ncode.syosetu.com/n2267be/ */
#define RIZERO return 0

int kitaeri(const void* x, const void* y) {
	return strcmp((const char*)x, (const char*)y);
}

char s[8192];
int K;

int mareitaso = 0;
char asumikana[8192 * 5][8];

int main(void) {
	int i, j;

	if (scanf("%8191s", s) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;

	for (i = 0; s[i] != '\0'; i++) {
		for (j = 0; j < K && s[i + j] != '\0'; j++) {
			memcpy(asumikana[mareitaso], s + i, j + 1);
			asumikana[mareitaso][j + 1] = '\0';
			mareitaso++;
		}
	}

	qsort(asumikana, mareitaso, sizeof(*asumikana), kitaeri);

	if (K == 1) {
		puts(asumikana[0]);
	} else {
		int mimorinn = 1;
		for (i = 1; i < mareitaso; i++) {
			if (strcmp(asumikana[i - 1], asumikana[i]) != 0) mimorinn++;
			if (mimorinn >= K) {
				puts(asumikana[i]);
				break;
			}
		}
	}

	RIZERO;
}


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

    int a, b, k;
    cin >> a >> b >> k;
    int f = min(a, k);
    k -= f;
    int s = min(b, k);
    cout << a - f << ' ' << b - s << endl;
}   


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a>>b;
    if(a>b) cout<<"a > b"<<endl;
    else if(a<b) cout<<"a < b"<<endl;
    else cout<<"a == b"<<endl;
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> c;
	rep(i, n) {
		bool ok = false;
		int p = lower_bound(all(c), a[i]) - c.begin() - 1;
		if(p >= 0) {
			ok = true;
			c[p] = a[i];
		} 
		if(!ok) {
			auto it = c.begin();
			it = c.insert(it, a[i]);
		}
		// rep(i, c.size()) cout << c[i] << " ";
		// cout << endl;
	}
	cout << c.size() << endl;
	return 0;
}


Measured memory_bytes: 1276