akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)
#define bin(i)		(1<<i)

const int MAXN=5e5+5;
const int oo=0x3f3f3f3f;
const int LIM=5e5;

int N,fullpre=0,suf=0;
map<int,int>d;

namespace solution{
	void Solve(){
		scanf("%d",&N);
		while(N--){
			int o;
			scanf("%d",&o);
			if(d[0]==1){
				puts("No");
				continue;
			}
			if(!d[o]){
				d[o]++;
				cmax(suf,o);
				puts("Yes");
			}else{
				if(o<=fullpre&&suf>o)puts("No");
				else{
					d[o]++;
					while(d[o]>1){
						d[o]%=2;
						if(o==suf)suf--;
						d[--o]++;
					}
					puts("Yes");
				}
			}
			while(d[fullpre+1]==1)fullpre++;
			while(fullpre-1>=1&&d[fullpre]==0)fullpre--;
		}
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Solve();
	return 0;
}

Measured memory_bytes: 14864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, ans = 0;
  cin >> n;
  ll bm = 1e18;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    ans += a;
    if(a > b) bm = min(bm, b);
  }
  ans -= bm;
  if(bm == 1e18) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define cout if (1) cout
 
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back
 
const int N = 3e5+7;
 
ll n, a, b;
int v[N];
 
int main () {
	scanf("%lld %lld %lld", &n, &a, &b);
 
	if (n < a + b - 1 || n > a*b) { printf("-1\n"); return 0; }
 
	bool s = 0;
	if (a < b) { swap(a,b); s = 1; }
	
	int dec = n - a;
 
	ll p = 0;
	for (ll i = 1; i <= n;) {
		ll s = p;
		for (ll j = 0; j < b && p < n; j++, p++) {
			if (j && !dec) break;
			v[p] = j + i;
			if (j) dec--;
		}
		i = v[p-1] + 1;
		reverse(v+s,v+p);
	}
 
	for (int i = 0; i < n; i++) printf("%lld ", s?n-v[i]+1:v[i]);
	printf("\n");
}

Measured memory_bytes: 3328
def insertionSort(a, n, g):
    global cnt
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt = cnt + 1
        a[j+g] = v

def shellSort(a, n):
    global cnt
    global G
    global m
    cnt = 0
    G = [1]
    while 3 * G[0] + 1 <= n:
        G = [ 3*G[0]+1 ] + G
    m = len(G)
    for i in range(0, m):
        insertionSort(a, n, G[i])

n = int(input())
a = [int(input()) for i in range(0, n)]

shellSort(a, n)

print(m)
print(*G)
print(cnt)
for i in range(0, n):
    print(a[i])


Measured memory_bytes: 45516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};
int main() {
  int n;
  cin >> n;
  UnionFind uf(n);
  vector<P> p;
  vector<int> idx(n, -1), idy(n, -1);
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    idx[x] = idy[y] = i;
    p.emplace_back(make_pair(x, y));
  }
  sort(p.begin(), p.end());
  vector<int> ok(n, 0);
  for (int i = 0; i < n; i++) {
    int j = p[i].second;
    int u = idy[j];
    while ((j < n) && !ok[j]) {
      uf.unite(u, idy[j]);
      ok[j] = 1;
      j++;
      //cout << p[i].second << " " << j << endl;
    }
  }
  rep(i,n) ok[i] = 0;

  for (int i = n - 1; i >= 0; i--) {
    int j = p[i].second;
    int u = idy[j];
    while ((j >= 0 && !ok[j])) {
      uf.unite(u, idy[j]);
      ok[j] = 1;
      j--;
    }
  }

  vector<P> t;
  for (int i = 0; i < n; i++) {
    t.emplace_back(make_pair(p[i].second, p[i].first));
  }
  sort(t.begin(), t.end());
  rep(i,n) ok[i] = 0;
  for (int i = 0; i < n; i++) {
    int j = t[i].second;
    int u = idx[j];
    while ((j < n) && !ok[j]) {
      uf.unite(u, idx[j]);
      ok[j] = 1;
      j++;
    }
  }
  rep(i,n) ok[i] = 0;
  for (int i = n - 1; i >= 0; i--) {
    int j = t[i].second;
    int u = idx[j];
    while ((j >= 0 && !ok[j])) {
      uf.unite(u, idx[j]);
      ok[j] = 1;
      j--;
    }
  }


  rep(i,n) {
    cout << uf.size(i) << endl;
  }
  return 0; 
}

Measured memory_bytes: 11068
import java.util.*;


class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();

        Map<Character, ArrayList<Integer>> idx = new HashMap<>();
        idx.put('R', new ArrayList<Integer>());
        idx.put('G', new ArrayList<Integer>());
        idx.put('B', new ArrayList<Integer>());

        long rcnt = 0;
        long gcnt = 0;
        long bcnt = 0;
        for (int i = 0; i < N; i++) {
            idx.get(S[i]).add(i);

            if(S[i] == 'R') rcnt++;
                        else if(S[i] == 'G') gcnt++;
                        else bcnt++;
        }


        long cnt = 0;
        for (int i = 1; i <= (N - 1) / 2; i++) {
            for (int j = 0; j < N - (i * 2); j++) {
                char ch1 = S[j];
                char ch2 = S[j + i];
                char ch3 = S[j + (i * 2)];
                if (ch1 != ch2 && ch2 != ch3 && ch1 != ch3) cnt++;
            }
        }

        System.out.println(rcnt*gcnt*bcnt-cnt);
    }
}


Measured memory_bytes: 36464
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 801;
int dist[maxn][maxn];
string f[maxn];

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

int nceil(int a, int b) {
    return (a + b - 1) / b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m, k;
    cin >> n >> m >> k;
    forn(i, n) cin >> f[i];
    int sx = -1, sy = -1;
    forn(i, n) forn(j, m) if (f[i][j] == 'S') sx = i, sy = j;
    vector<pii> q;
    forn(i, n) forn(j, m) dist[i][j] = 1e9;
    dist[sx][sy] = 0;
    q.pb({sx, sy});
    forn(cur, q.size()) {
        int x = q[cur].fi, y = q[cur].se;
        int ncur = dist[x][y];
        forn(d, 4) {
            int xx = x + dx[d], yy = y + dy[d];
            if (min(xx, yy) < 0 || min(n - xx, m - yy) <= 0 || dist[xx][yy] < 1e8 || f[xx][yy] == '#') continue;
            dist[xx][yy] = ncur + 1;
            q.pb({xx, yy});
        }
    }

    int ans = 1e9;
    forn(i, n) forn(j, m) {
        if (dist[i][j] > k) continue;
        int res = 1e9;
        uin(res, nceil(i, k));
        uin(res, nceil(j, k));
        uin(res, nceil(n - i - 1, k));
        uin(res, nceil(m - j - 1, k));
        uin(ans, res + 1);
    }

    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

typedef vector<int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define sz(a)  int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define forn(i,n) for(int i=0;i<n;++i)
#define foru(i,n) for(int i=1;i<=n;++i)
#define fortr(i,v) for(auto &i:v)
#define set(n) __builti
#define ll long long

int main()
{
	int n;
	string s;
	cin>>n;
	cin>>s;
	vi A[10];
	forn(i,n)
	{
		A[s[i]-'0'].pb(i);
	}
	int ans=0;
	int first,second,third;
	forn(i,10)
	{
		if(A[i].size())
		{
			first=A[i][0];
			forn(j,10)
			{
				if(lower_bound(A[j].begin(),A[j].end(),first+1)!=A[j].end())
				{
					second=*(lower_bound(A[j].begin(),A[j].end(),first+1));
					forn(m,10)
					{
						if(lower_bound(A[m].begin(),A[m].end(),second+1)!=A[m].end())
						{
							++ans;
						}
						else continue;	
					}
				}
				else continue;
			}
		}
		else continue;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
/**
 *      purpose : AISing Programming Contest 2019 B
 *      author  : kyomukyomupurin
 *      created : 2019-01-12 21:04:47
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, a, b; cin >> n >> a >> b;
    int p[n];
    rep(i, n) cin >> p[i];

    int x = 0, y = 0, z = 0;

    rep(i, n){
        if (p[i] <= a) ++x;
        else if (p[i] >= b + 1) ++z;
        else ++y;
    }

    print(min({x, y, z}));
    
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
 
fn main() {
    let (x, a) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let x: usize = iter.next().unwrap().parse().unwrap();
        let a: usize = iter.next().unwrap().parse().unwrap();
        (x, a)
    };

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}

Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int H=gi();
         int W=gi();
         int M=gi();
         int[] h=new int[M];
         int[] w=new int[M];

         long[] ch=new long[H+1];
         long[] cw=new long[W+1];
         Map<Integer, Map<Integer, Boolean>> G=new HashMap<Integer, Map<Integer,Boolean>>();
         for (int i=0; i<M;i++) {
        	 h[i]=gi();
        	 w[i]=gi();
        	 if(G.containsKey(h[i])) {
        		 Map m=G.get(h[i]);
        		 m.put(w[i], true);
        	 } else {
        	     Map m=new HashMap<Integer, Boolean>();
        	     m.put(w[i], true);
        	     G.put(h[i], m);
        	 }
        	 ch[h[i]]++;
        	 cw[w[i]]++;
         }

         long mh=0;
         long mw=0;
         for (int i=1; i<H+1; i++) {
        	 mh=Math.max(mh, ch[i]);
         }
         for (int i=1; i<W+1; i++) {
        	 mw=Math.max(mw, cw[i]);
         }
         List<Integer> lih=new ArrayList<Integer>();
         for (int i=1; i<H+1; i++) {
        	 if(ch[i]==mh) {
        		 lih.add(i);
        	 }
         }
         List<Integer> liw=new ArrayList<Integer>();
         for (int i=1; i<W+1; i++) {
        	 if(cw[i]==mw) {
        		 liw.add(i);
        	 }
         }

         boolean f=false;
         for (int i=0; i<lih.size();i++) {
        	 for (int j=0; j<liw.size();j++) {
            	 int hi=lih.get(i);
            	 int wi=liw.get(j);
            	 if(G.containsKey(hi) && G.get(hi).containsKey(wi)) {
            		 //nop
            	 } else {
            		 f=true;
            		 break;
            	 }
             }
         }

         if(f) {
        	 System.out.println(mh+mw);
         } else {
        	 System.out.println(mh+mw-1);
         }



     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 178792
fun main() = Thread(null, ::msolutions2020d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    var answer = 1000L

    for (i in 0 until n - 1) {
        if (aList[i] < aList[i + 1]) {
            val buy = answer / aList[i]
            answer += buy * (aList[i + 1] - aList[i])
        }
    }

    println(answer)
}


Measured memory_bytes: 36664
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

ll _count[2000] = {0};
int main() {
  ll X,Y;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<pair<ll, int>> que;
  ll num;
  rep(i, A){
    cin >> num;
    que.push(make_pair(num, 0));
  }
  rep(i, B){
    cin >> num;
    que.push(make_pair(num, 1));
  }  
  rep(i, C){
    cin >> num;
    que.push(make_pair(num, 2));
  }
  ll sum = 0;
  ll _count = 0;
  while(_count != X+Y){
    pair<ll, int> curr = que.top(); que.pop();
    if(curr.second == 0 && X > 0){
      X--;
      sum += curr.first;
    }else if(curr.second == 1 && Y > 0){
      Y--;
      sum += curr.first;
    }else if(curr.second == 2){
      _count++;
      sum += curr.first;
    }
  }
  cout << sum;
} 



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

using namespace std;


int main() {
  int N, P[10];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> P[i];
  int ret = -*max_element(P, P + N) / 2;
  for(int i = 0; i < N; i++) ret += P[i];
  cout << ret << endl;
}

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

int main(void){
	int n;
	cin >> n;
	int ans1, ans2;
	ans1 = ans2 = 0;

	for(int i=0; i<n; i++){
		string taro, hanako;
		cin >> taro >> hanako;
		if(taro > hanako) ans1+=3;
		else if(taro < hanako) ans2+=3;
		else{
			ans1++;
			ans2++;
		}
	}
	printf("%d %d\n", ans1, ans2);

	return 0;
}

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

int main(){
	string s;
	int a;
	cin >> s >> a;
	string ans = "";
	for(int i = 0; i < s.size(); i+=a){
		char c = s[i];
		ans += c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    map<ll,int> mp;
    for(ll x = 1; x <= 100; x++){
        for(ll y = 1; y <= 100; y++){
            for(ll z = 1; z <= 100; z++){
                mp[(x*y + y*z + z*x)+x*x + y*y + z*z]++;
            }
        }
    }
    for(int n = 1; n <= N; n++){
        cout << mp[n] << endl;
    }
}


Measured memory_bytes: 6024
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int gcd(int x,int y)
{
    if(!y)  return x;
    return gcd(y,x%y);
}
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++)  ans=ans+gcd(gcd(i,j),k);
    cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
int n;
ll niz[maxn];
ll sume[maxn];
unordered_map<ll,ll>zb;
ll pomniz[maxn];
int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d", &niz[i]);
        niz[i]-=i;
        pomniz[i]=niz[i];
        if(zb.find(niz[i])==zb.end())
            zb[niz[i]]=1;
        else
            zb[niz[i]]++;
    }
    sort(pomniz+1,pomniz+n+1);
    for(int i=1;i<=n;i++)
        sume[i]=sume[i-1]+pomniz[i];
    ll trenres=-1;
    ll trensum=0;
    for(int i=1;i<=n;i++)
    {

            if(trenres==-1)
                trenres=(i-1)*pomniz[i]-trensum+sume[n]-sume[i]-(n-i)*pomniz[i];
            else
                trenres=min(trenres,(i-1)*pomniz[i]-trensum+sume[n]-sume[i]-(n-i)*pomniz[i]);
        trensum+=pomniz[i];
    }

    cout<<trenres;
    return 0;
}


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

using namespace std;

#define ll long long
#define ar array


int k;
string s;
ll mod = 1000000007;

inline long long mpow(long long b, long long ex){
    if (b==1)return 1;
    if(b == 0) return 1;
    long long r = 1;
    while (ex ){
        if (ex&1)r=(r * b)%mod;
        ex = ex >> 1;
        b = (b * b)%mod;}
    return r;
}

ll choose(ll n, ll m){

    ll ret = 1;
    for (ll i = n; i > n-m; i--)
    {
        ret = ret * i;
        ret = ret % mod;
    }
    
    ll k = 1;
    for (ll i = 1; i <= m; i++)
    {
        k = k*i;
        k = k % mod;
    }
    
    // inverse k since mod is prime
    ll phi = mod-2;
    ll inv = 1;
    while (phi > 0 )
    {
        if(phi & 1) inv = inv * k;
        inv = inv % mod;
        k = k * k;
        k = k % mod;
        phi = phi >> 1;
    }

    ret = ret * inv;
    ret = ret % mod;

    return ret;
}

void solve(){
    
    cin >> k;
    cin >> s;

    int size = s.length();

    
    ll ans = 1;
    ll val = 1;
    ll n = k+size;
    for (int i = 0; i < n; i++)
    {
        ans = ans*26;
        ans = ans % mod;

        val = val*25;
        val = val %mod;
        
    }
    
    ll inv = 280000002;



    ll cur;
    ll choose = 1;
    for (int i = 0; i < size; i++)
    {
        cur = choose * val;
        choose  = choose * (n-i);
        choose = choose % mod;

        choose = choose * mpow(i+1,mod-2);
        choose = choose % mod;
        //cout << "i = " << i << " cho : " << choose << endl;

        cur = cur % mod;
        ans = ans - cur;
        ans = ans % mod;
        if(ans < 0) ans +=mod;
        val = val * inv;
        val = val % mod;
    }
    cout << ans << endl;
}





int main(){

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

    solve();

}

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

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

  ll N, K; cin >> N >> K;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  for (ll i = 0; i < K; i++) {
    ans += A[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 __int128
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	unordered_set<ll> st;
	ll n; cin >> n;
	ll ans = 0;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		ll d = i;
		int128 kek = 1;
		bool f = false;
		while (kek <= n) {
			ll lol = n - kek;
			int128 neww = kek * d;
			if (lol % neww == 0) {
				f = true;
				break;
			} else {
				kek = neww;
			}
		}
		if (f) st.insert(d);
		if (n / i == i) continue;
		ll dd = n / i;
		kek = 1;
		f = false;
		while (kek <= n) {
			ll lol = n - kek;
			int128 neww = kek * dd;
			if (lol % neww == 0) {
				f = true;
				break;
			} else {
				kek = neww;
			}
		}
		if (f) st.insert(dd);
	}
	st.insert(n);
	n--;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		ll d = i;
		st.insert(d);
		ll dd = n / i;
		if (dd == d) continue;
		st.insert(dd);
	}
	st.insert(n);

	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << st.size() << endl;

	return 0;
}

/*


*/

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define PI acos(-1)
typedef long long ll;
// tourist answer
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  FOR(i,0,n) cin >> x[i] >> y[i];
  int num = 250000;
  double r = 1e11;
  double ans[n];
  CLR(ans);
  FOR(i,0,num+1) {
    double theta = i * 2.0 * PI / num;
    double X = r * cos(theta);
    double Y = r * sin(theta);
    double mn = 1e30;
    int best = 0;
    FOR(j,0,n) {
      double dist = pow(x[j]-X,2)+pow(y[j]-Y,2);
      if(dist < mn) {
        mn = dist;
        best = j;
      }
    }
    ans[best] += 1.0 / num;
  }
  FOR(i,0,n) cout << fixed << setprecision(17) << ans[i] << endl;
  return 0;
}

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


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    bool flag = true;
    for(int i = n-2;i>=1;i -= 2){
        if(s.substr(0,i/2) == s.substr(i/2,i/2)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    vector<pii> E;
    rep(i,M) {
        int u,v; cin >> u >> v;
        if (u > v) swap(u,v);
        u--; v--;
        E.emplace_back(u,v);
    }
    sort(all(E));
    E.erase(unique(begin(E), end(E)), end(E));
    M = E.size();
    vector<vector<int>> G(N);
    rep(i,M) {
        int u,v;
        tie(u,v) = E[i];
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    int ans = 0;
    rep(i,N) {
        bool ok = true;
        for (auto nv : G[i]) {
            if (H[nv] >= H[i]) ok = false;
        }
        if (ok) ans++;
    }

    cout << ans << ln;
}

Measured memory_bytes: 9420
n,t = map(int,input().split())
tlist = [0] + list(map(int,input().split()))
tsum = 0
restart = tlist[1]

for i in range(1,n+1):
  if tlist[i] <= t + tlist[i-1]:
    sumtmp = t+tlist[i] - restart
  elif tlist[i]  > t + tlist[i-1]:
    tsum += sumtmp
    restart = tlist[i]
    sumtmp = t
    
print(tsum + sumtmp)
    


Measured memory_bytes: 25200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(void) {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int cnt = 0;
    for(int i=1;i<n-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i]&&p[i]>p[i+1]))
            cnt++;
    }
    cout << cnt;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


int main(void){
  long long sum = 0, here;
  long long N;
  cin >> N;
  
  long long tmp;
  cin >> tmp;
  here = tmp;  
  for(int i =0; i < N - 1; i++){
    cin >> tmp;
    if(here > tmp){
      sum += (here - tmp);
    }else if(here < tmp){
      here = tmp;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ( (a + b) == c || (a + c) == b || (b + c) == a)
        	out.println("Yes");
        else
        	out.println("No");
        
        out.close();
}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        char[] ans = new char[10];
        int len = 0;
        foreach (var c in s)
        {
            if(c == 'B')
            {
                if (len > 0) len--;
            }
            else
            {
                ans[len++] = c;
            }
        }

        var ar = new char[len];
        for (int i = 0; i <len ; i++)
        {
            ar[i] = ans[i];
        }
        Console.WriteLine(new string(ar));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    scanInt(K);
    int count = 1;
    for (int n = min(A, B); 1 <= n; n--){
        if (A % n != 0 || B % n != 0) continue;
        if (count == K){
            cout << n << endl;
            return 0;
        }
        count++;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define value( x ) cout<< "value of "<< #x << " is "<< x<<endl;
using namespace std;
int main()
{
	
    int x, a, b;
    cin>>x>>a>>b;
    string sol="safe";
    if(a>=b) sol="delicious";
    else if((b-a)>x) sol="dangerous";
    cout<<sol;
    
return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vi P(N);
    P[0] = -1;
    vector<set<int> > C(N), Ccp;
    for (int n=1; n<N; ++n) {
        cin >> P[n]; --P[n];
        C[P[n]].insert(n);
    }
    Ccp = C;
    vi X(N);
    for (int n=0; n<N; ++n) {
        cin >> X[n];
    }
    
    vi Y(N, INF);
    queue<int> Q;
    for (int n=0; n<N; ++n) {
        if (C[n].empty()) Q.push(n);
    }
    while (1) {
        int tmp = Q.front(); Q.pop();
        vector<vi> MinW(C[tmp].size()+1, vi(X[tmp]+1, INF));
        auto it = C[tmp].begin();
        MinW[0][0] = 0;
        for (int s=1; s<=C[tmp].size(); ++s) {
            int child = *(it++);
            for (int x=0; x <= X[tmp]; ++x) {
                if (X[child] <= x) MinW[s][x] = min(MinW[s][x], MinW[s-1][x-X[child]]+Y[child]);
                if (Y[child] <= x) MinW[s][x] = min(MinW[s][x], MinW[s-1][x-Y[child]]+X[child]);
            }
        }
        for (int x = 0; x <= X[tmp]; ++x) {
            Y[tmp] = min(Y[tmp], MinW[C[tmp].size()][x]);
        }
        
        if (tmp == 0) break;
        int Ptmp = P[tmp];
        Ccp[Ptmp].erase(tmp);
        if (Ccp[Ptmp].empty()) Q.push(Ptmp);
    }
    if (Y[0]<INF) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";

    return 0;
}


Measured memory_bytes: 1448
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m,x;
  int ans[4096];
  int arr[13][13];
  cin>>n>>m>>x;
  for(int i=1;i<=n;i++)for(int j=0;j<=m;j++)cin>>arr[i][j];
  int ind=0;
  int kl=1;
  for(int i=0;i<n;i++)kl=kl*2;
  kl=kl-1;
  for(int i=kl;i>=0;i--){
  	int a[13];
  	for(int j=0;j<13;j++)a[j]=0;
  	int cur=1;
  	int num=i;
  	int cost=0;
  	bool ok=true;
  	while(num>0){
  		if(num&1){
  			for(int j=1;j<=m;j++){
  				a[j]+=arr[cur][j];
  			}
  			cost+=arr[cur][0];
  		}
  		num=num>>1;
  		cur++;
  	}
  	for(int j=1;j<=m;j++){
  		if(a[j]<x){
  			ok=false;
  			break;
  		}
  	}
  	if(ok){
  		ans[ind]=cost;
  		ind++;
  	}
  }
  if(ind==0){
  	cout<<-1<<endl;
  	return 0;
  }
  int an=ans[0];
  for(int i=1;i<ind;i++){
  	an=min(ans[i],an);
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll k=n;
	ll d=0;
	while(k!=0){
		k=k/10;
		d++;
	}
//	cout<<"d="<<d;
	ll a[6]={0};
	for(ll i=0;i<=5;i++){
		
		if(i%2==1)
		a[i]=9*pow(10,i-1);
//		cout<<a[i]<<endl;
	}
	ll pre[6]={0};
	for(ll i=0;i<=5;i++){
		if(i>0)
		pre[i]=pre[i-1]+a[i];
	}
	ll m=pow(10,d-1)-1;
	ll h=0;
//	cout<<"m="<<m<<endl;
	if(d%2==1 && d>1)h=n-m;
	if(d==1)h=n;
//	if(d==2)h=9;
	cout<<pre[d-1]+h;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int n, m, p, ac_count = 0, wa_count = 0;
  vector<bool> ac(100000, false);
  vector<int> wa(100000, 0);
  string s;

  cin >> n >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> p >> s;
    if (s == "AC")
    {
      if (!ac[p - 1])
      {
        ac_count++;
        ac[p - 1] = true;
      }
    }
    else
    {
      if (!ac[p - 1])
        wa[p - 1]++;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (ac[i])
      wa_count += wa[i];
  }
  cout << ac_count << " " << wa_count << endl;
}

Measured memory_bytes: 3632
import itertools
import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))


INF=10**20
def main():
    N=ii()
    S=list(input())

    R,G,B=[],[],[]
    Rset,Gset,Bset = set(),set(),set()
    
    for i in range(N):
        s = S[i]
        if s == "R":
            R.append(i)
            Rset.add(i)

        elif s == "G":
            G.append(i)
            Gset.add(i)
        
        else:
            B.append(i)
            Bset.add(i)

    ans = 0
    dic = {"R":(R,Rset),"G":(G,Gset),"B":(B,Bset)}
    for comb in itertools.permutations(["R","G","B"]):
        X,Y,Z = dic[comb[0]][0], dic[comb[1]][0], dic[comb[2]][0]
        Xset,Yset,Zset = dic[comb[0]][1], dic[comb[1]][1], dic[comb[2]][1]

        # print(X,Y,Z)
        for x in X:
            for y in Y:
                if not x < y: continue
                ignore_z = 2*y - x
                has_ignore_target = ignore_z in Zset

                iz = bisect.bisect_left(Z,y+1)
                if not 0<=iz<len(Z): continue
                z_count = len(Z)-iz

                if has_ignore_target:
                    z_count -= 1
                
                assert z_count >= 0
                ans += z_count
                # print(ans)


    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 74568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll f(map<char, vector<ll>> &idx, map<char, set<ll>> &ext, char a, char b, char c) {
    ll ans = 0;
    for(auto x : idx[a]) {
        for(auto ity = upper_bound(all(idx[b]), x); ity != idx[b].end(); ity++) {
            ll d = abs(x - *ity);
            ll cnt = sz(idx[c]) - (upper_bound(all(idx[c]), *ity) - idx[c].begin());
            if (ext[c].count(*ity + d) > 0) cnt--;
            ans += cnt;
        }
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<char, vector<ll>> idx;
    map<char, set<ll>> ext;
    rep(i, len(s)) {
        idx[s[i]].push_back(i);
        ext[s[i]].insert(i);
    }
    ll ans = 0;
    for(auto x : idx) {
        for(auto y : idx) {
            if (x.first == y.first) continue;
            for(auto z : idx) {
                if ((z.first == x.first) || (z.first == y.first)) continue;
                ans += f(idx, ext, x.first, y.first, z.first);
                // printf("%c, %c, %c, ans=%lld\n", x.first, y.first, z.first, ans);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3868
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <cctype>
#include <functional>
#include <climits>
 
using namespace std;
#define pr(...) do { _ost << #__VA_ARGS__ << " = "; ~(_ost,__VA_ARGS__); } while(0);
ostream & _ost = cout;
template <class T>
ostream &operator,(ostream& ost, const T& value) { return ost << value << ","; }
ostream &operator~(ostream& ost) { return ost << endl; }
template <class T>
string tos(const T& var){ ostringstream ss; ss << var; return ss.str(); }
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
 
typedef vector<int> vi;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;
 
const int mod = 1000000007;
const int INF = 1000000;
const double EPS = 1e-10;

int m,n;
int dp[1][1];

int main(){
    cin >> n;
    FOR(i,0,n){
        int x,y,b,p;cin>>x>>y>>b>>p;
        int s = x*b+y*p;
        b=max(b,5);
        p=max(p,2);
        int t=(x*b+y*p)*4/5;
        cout<<min(s,t)<<endl;
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define LL long long
#define Max 2005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL C[Max][Max];
void Compare_C(){
    C[0][0]=1;
    for(int i=1;i<Max;i++){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<=i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
}
int main()
{
    Compare_C();
    int b,r,c;
    scanf("%d%d",&c,&b);
    r=c-b+1;
    for(int i=1;i<=b;i++){
        printf("%lld\n",(C[b-1][i-1]*C[r][i])%mod);
    }
    return 0;
}


Measured memory_bytes: 30844
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		int answer = 0;
		
		for(int i = a; i <= b; i ++){			
			if(c % i == 0){
				answer ++;
			}
		}
		System.out.println(answer);		
	}
}

Measured memory_bytes: 26308
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A; cin >> A;
  cout << A + A * A + A * A * A << endl;


  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,count=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n-2;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            count++;
        }
    }
    cout<<count;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

ll N;
int ANS = 0;
int sft[] = {7, 5, 3};

void dfs(ll sum, map<int, int> m1){
    if(sum <= N){
        if(m1[3] && m1[5] && m1[7]) ANS++;

        for(auto n : sft){
            map<int, int> m2;
            m2 = m1;
            m2[n] = 1;
            dfs(sum * 10 + n, m2);
        }
    }
}

int main() {
    cin >> N;
    map<int, int> m;
    dfs(0, m);
    cout << ANS << endl;
}



Measured memory_bytes: 256