akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-9

using namespace std;

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

double calc_dis (double x1, double y1, double x2, double y2 )
{
	return sqrt ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2 ) );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.CI", "r", stdin );
	int n;
	scanf ("%d", &n );
	rep (i, n ){
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = calc_dis (xa, ya, xb, yb );
//		cerr << "d: " << d << endl;
		int res = -1;
		if (ra + rb + EPS < d ){	// A and B do not overlap
			res = 0;
		}else
		if (fabs (ra + rb - d ) < EPS || fabs (fabs(ra - rb ) - d ) < EPS || (ra + rb + EPS > d  && fabs (ra - rb ) < d ) ){ // if circumference of A and B intersect
			res = 1;
		}else
		if (ra > rb ){	// if B is in A, 
			res = 2;
		}else
		if (ra < rb ){	// if A is in B,
			res = -2;
		}else{
			res = 1;		// if A and B is same
		} // end if
		cout << res << endl;
	} // end rep
		
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MN = 1e5+100;
ll t[MN];
int main() {
    int n;
    cin>>n;
    for(int i = 0; i < n; ++i) {
        cin>>t[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += t[i]/2;
        t[i] -= (t[i]/2)*2;
        if(t[i+1] && t[i]) {
            --t[i], --t[i+1];
            ++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

vector<int> createPrime ( int num )
{
	vector<int> vp;
	vector<bool> vb(num+1, true);
	vb[0] = vb[1] = false;
	for (int i = 2; i <= num; ++i) {
		if (!vb[i]) { continue; }
		vp.push_back(i);
		for (int j = i+i; j <= num; j+=i) { vb[j] = false; }
	}
	return vp;
}

const int MAX = 1299709;

int main() {
	int k;
	vector<int> vp = createPrime(MAX);

	while (cin >> k, k) {
		vector<int>::iterator it = lower_bound(vp.begin(), vp.end(), k);
		if (*it == k || k == 1) {
			cout << 0 << endl;
		}
		else {
			vector<int>::iterator it2 = it - 1;
			cout << *it - *it2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1752
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
const int MAXN=100005;

struct Point
{
	int x,y,id;
	Point(int _x=0,int _y=0,int _id=0)
	{x=_x;y=_y;id=_id;}
};
struct Node
{
	int v,id;
	Node(int _v=0,int _id=0)
	{v=_v;id=_id;}
	bool operator < (const Node &t)const
	{return v<t.v;}
};
int Dis(Point A,Point B)
{return max(abs(A.x-B.x),abs(A.y-B.y));}

long long ans;
int N,A,B,R;
map<int,set<Node>> sX,sY;
map<int,vector<Node>> vX,vY;
vector<int> ansP;
Point P[MAXN];

queue<int> Q;

int main()
{
	cin>>N>>A>>B;
	for(int i=1;i<=N;i++)
	{
		int x,y,nx,ny;
		cin>>x>>y;
		nx=x-y;
		ny=x+y;
		P[i]=Point(nx,ny,i);
		if(i!=A&&i!=B)
		{
			sX[nx].insert(Node(ny,i));
			sY[ny].insert(Node(nx,i));
		}
		vX[nx].push_back(Node(ny,i));
		vY[ny].push_back(Node(nx,i));
	}
	R=Dis(P[A],P[B]);
	for(auto &it:vX)
		sort(it.second.begin(),it.second.end());
	for(auto &it:vY)
		sort(it.second.begin(),it.second.end());
	
	Q.push(A);
	Q.push(B);
	
	while(!Q.empty())
	{
		int u=Q.front();
		ansP.push_back(u);
		Q.pop();
		if(sX.count(P[u].x+R))
		{
			auto &vec=sX[P[u].x+R];
			auto l=vec.lower_bound(Node(P[u].y-R,0));
			for(auto it=l;it->v<=P[u].y+R&&it!=vec.end();)
			{
				Q.push(it->id);
				sY[P[it->id].y].erase(Node(P[it->id].x,it->id));
				vec.erase(it++);
			}
		}
		if(sX.count(P[u].x-R))
		{
			auto &vec=sX[P[u].x-R];
			auto l=vec.lower_bound(Node(P[u].y-R,0));
			for(auto it=l;it->v<=P[u].y+R&&it!=vec.end();)
			{
				Q.push(it->id);
				sY[P[it->id].y].erase(Node(P[it->id].x,it->id));
				vec.erase(it++);
			}
		}
		if(sY.count(P[u].y+R))
		{
			auto &vec=sY[P[u].y+R];
			auto l=vec.lower_bound(Node(P[u].x-R,0));
			for(auto it=l;it->v<=P[u].x+R&&it!=vec.end();)
			{
				Q.push(it->id);
				sX[P[it->id].x].erase(Node(P[it->id].y,it->id));
				vec.erase(it++);
			}
		}
		if(sY.count(P[u].y-R))
		{
			auto &vec=sY[P[u].y-R];
			auto l=vec.lower_bound(Node(P[u].x-R,0));
			for(auto it=l;it->v<=P[u].x+R&&it!=vec.end();)
			{
				Q.push(it->id);
				sX[P[it->id].x].erase(Node(P[it->id].y,it->id));
				vec.erase(it++);
			}
		}
	}
	
	for(auto u:ansP)
	{
		if(vX.count(P[u].x+R))
		{
			auto &vec=vX[P[u].x+R];
			auto l=lower_bound(vec.begin(),vec.end(),Node(P[u].y-R,0));
			auto r=upper_bound(vec.begin(),vec.end(),Node(P[u].y+R,0));
			ans+=r-l;
		}
		if(vX.count(P[u].x-R))
		{
			auto &vec=vX[P[u].x-R];
			auto l=lower_bound(vec.begin(),vec.end(),Node(P[u].y-R,0));
			auto r=upper_bound(vec.begin(),vec.end(),Node(P[u].y+R,0));
			ans+=r-l;
		}
		if(vY.count(P[u].y+R))
		{
			auto &vec=vY[P[u].y+R];
			auto l=lower_bound(vec.begin(),vec.end(),Node(P[u].x-R+1,0));
			auto r=upper_bound(vec.begin(),vec.end(),Node(P[u].x+R-1,0));
			ans+=r-l;
		}
		if(vY.count(P[u].y-R))
		{
			auto &vec=vY[P[u].y-R];
			auto l=lower_bound(vec.begin(),vec.end(),Node(P[u].x-R+1,0));
			auto r=upper_bound(vec.begin(),vec.end(),Node(P[u].x+R-1,0));
			ans+=r-l;
		}
	}
	
	ans/=2;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 46588
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1000000007;
int main(){
    int x,y,z;
    cin >> x >> y >> z;

    swap(x,y);
    swap(x,z);

    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] s = new char[h + 2][w + 2];
    for (int i = 1; i <= h; i++) {
      char[] tmp = sc.next().toCharArray();
      for (int j = 1; j <= w; j++) {
        s[i][j] = tmp[j - 1];
      }
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        int count = 0;
        if (s[i - 1][j - 1] == '#') {
          count++;
        }
        if (s[i - 1][j] == '#') {
          count++;
        }
        if (s[i - 1][j + 1] == '#') {
          count++;
        }
        if (s[i][j - 1] == '#') {
          count++;
        }
        if (s[i][j + 1] == '#') {
          count++;
        }
        if (s[i + 1][j - 1] == '#') {
          count++;
        }
        if (s[i + 1][j] == '#') {
          count++;
        }
        if (s[i + 1][j + 1] == '#') {
          count++;
        }
        if (s[i][j] == '.') {
          s[i][j] = (char)('0' + count);
        }
      }
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        System.out.print(s[i][j]);
        if (j == w) {
          System.out.println();
        }
      }
    }
  }
}

Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int V,E;
  cin >> V >> E;
  vector<int>a(E);
  vector<int>b(E);
  vector<int>c(E);
  vector<vector<int>>d(V, vector<int>(V,100000000));
  for (int i=0;i<E;i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
    d[a[i]-1][b[i]-1]=c[i];
    d[b[i]-1][a[i]-1]=c[i];
  }
  for (int i=0;i<V;i++) {
    d[i][i]=0; 
  }
  for(int k=0;k<V;k++) {
    for (int i=0;i<V;i++) {
      for (int j=0;j<V;j++) {
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        d[j][i]=d[i][j];
      }
    }
  }
  int ans=E;
  for (int i=0;i<E;i++) {
    for (int j=0;j<V;j++) {
      if(d[j][a[i]-1]+c[i]==d[j][b[i]-1]){
        ans--;
        break;
      }      
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n,m; cin >> n >> m;
    int l = m / n;
    int res = 0;
    for (int i = l; i > 0; i--){
        if(m % i == 0){
            res = i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn calc_comb(n: usize, r: usize) -> usize {
    let mut num = 1;
    for i in 1..r + 1 {
        num = num * (n - i + 1) / i;
    }
    num
}

fn main() {
    input! {
    n: chars,
    k: usize,
    }
    let n = n.iter().map(|x| x.to_digit(10).unwrap() as usize).collect::<Vec<usize>>();
    let mut l = n.len();
    if l < k {println!("{}", 0); return}
    let mut k = k;
    let mut ans: i64 = 0;
    for i in n {
        l -= 1;
        if i != 0 && l >= k {
            ans += (9usize.pow(k as u32) * calc_comb(l, k)) as i64;
        }
        if i != 0 {
            k -= 1;
            ans += (9usize.pow(k as u32) * calc_comb(l, k) * (i - 1)) as i64;
        }
        if k == 0 {
            if i != 0 { ans += 1}
            break;
        }
        if l < k {break}
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        int a = M/N;
        int ans = 1;
        for(int i = a; i >= 1; i--){
            if(M%i == 0){
                ans = i;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    K = Scanner.int()
    d = deque()
    for i in range(1, 10):
        d.append(i)
    MAX = 10 ** 5 + 100
    for i in range(MAX):
        n = d[i]
        a = int(str(n)[-1])
        if a != 0:
            d.append(n * 10 + (a - 1))
        d.append(n * 10 + a)
        if a != 9:
            d.append(n * 10 + (a + 1))
        if len(d) >= K:
            print(d[K - 1])
            return


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 14860
from collections import Counter, defaultdict

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ca = Counter(a)
cb = Counter(b)

for ka, va in ca.items():
    vb = cb[ka]
    if va + vb > n:
        print("No")
        exit()

print("Yes")
end = defaultdict(int)
for i, e in enumerate(a):
    end[e] = i

mx = 0
for i, e in enumerate(b):
    diff = end[e] - i + 1
    mx = max(mx, diff)

ans = b[-mx:] + b[:-mx]
print(*ans)


Measured memory_bytes: 73028
n,m;i,j;s;k,l;f;
char a[50][55],b[50][55];
main(){
	scanf("%d%d\n",&n,&m);
	for(i=0;i<n;i++)gets(a[i]);
	for(i=0;i<m;i++)gets(b[i]);
	for(i=0;i<=n-m;i++)for(j=0;j<=n-m;j++)
	{
		f=1;
		for(k=0;k<m;k++)for(l=0;l<m;l++)f&=a[i+k][j+l]==b[k][l];
		s+=f;
	}
	puts(s?"Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S;
  cin >> T;
  for (int i = 0; i < size(S); i++) {
  	if (S[i] != T[i]) {
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3628
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n

for i in range(n):
  if i == 0:
    dp[i] = 0
  elif i == 1:
    dp[i] = abs(h[i]-h[i-1])
  else:
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])


Measured memory_bytes: 13980
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] a = new int[r+1][c+1];
        for(int i=0; i<r; i++) {
        		int x = 0;
        		for(int j=0; j<c; j++) {
        			a[i][j] = sc.nextInt();
        			x += a[i][j];
        			a[r][j] += a[i][j];
        			if(j==c-1) {
        				a[i][c] = x; 
        				a[r][c] += x;
        			}
        		}
        }
        for(int i=0; i<r+1; i++) {
        		for(int j=0; j<c+1; j++) {
        			if(j==c) {
        				System.out.println(a[i][j]);
        			} else {
        				System.out.print(a[i][j] + " ");
        			}
        		}
        }
    }
}


Measured memory_bytes: 41872
//wait for sh
    #pragma GCC optimize("Ofast")
    #include <bits/stdc++.h>
    using namespace std;

    #define int long long int
    #define pb push_back
    #define mp make_pair
    #define loop(i,st,end) for(int i=st;i<end;i++)
    #define itr(it,v)  for(auto it=v.begin();it!=v.end();++it)
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl ;
    #define mod (int)(1e9+7)
    const int maxn=5001;


    void solve()
      {
        int n;
        cin>>n;

        int mx=(1<<n)-1;
        //cout<<mx<<endl;
        int dp[mx+1];
        
        loop(j,0,mx+1)
            dp[j]=0;
        

        int a[n+1][n+1];
        loop(i,1,n+1)
        {
          loop(j,1,n+1)
           cin>>a[i][j];
        }

        dp[0]=1;
 

     
          loop(mask,0,mx+1)
          {
            int i=__builtin_popcount(mask);
            loop(k,1,n+1)
            {
              if(a[i][k] and (mask & (1<<(k-1))))
                dp[mask]+=dp[mask^(1<<(k-1))];

              dp[mask]%=mod;
            }
          }
        

        cout<<dp[mx];
      }

    int32_t main()
    { IOS
    //   #ifndef ONLINE_JUDGE
    //   freopen("input.txt","r",stdin);
    //   freopen("output.txt","w",stdout);
    //   #endif

      int t;
      t=1;
      //cin>>t;

      loop(i,0,t)
      {  //cout<<"Case #"<<(i+1)<<": ";
          solve();
      }

      return 0;
    }


Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int a,b,c,k;
int ans=0;
int main(){
	cin >> a >> b >> c >> k;
	if(a>=k)ans+=k;
	else ans+=a;
	k-=a;
	if(k<=0) {cout << ans << endl;return 0;}
	k-=b;
	if(k<=0) {cout << ans << endl;return 0;}

	if(c>=k)ans-=k;
	else ans-=c;
	cout << ans << endl;return 0;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
int main(){
  int r,c,total=0;
  std::vector<int> sumr,sumc;
  std::vector<std::vector<int> > M;
  std::cin >> r >> c;
  sumr.resize(r);
  sumc.resize(c);
  M.resize(r);
  for(int i=0; i<r; i++){
    M[i].resize(c);
  }
  for(int i=0; (r<c ? i<c : i<r) ; i++){
    if(i < r) sumr[i] = 0;
    if(i < c) sumc[i] = 0;
  }
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      std::cin >> M[i][j];
      sumr[i] += M[i][j];
      sumc[j] += M[i][j];
      total += M[i][j];
    }
  }
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      std::cout << M[i][j] << " ";
    }
    std::cout << sumr[i] << "\n";
  }
  for(int i=0; i<c; i++){
    std::cout << sumc[i] << " ";
  }
  std::cout << total << "\n";
  return 0;
}

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

long long pow2(long long n){
    if(n == 0){
        return 1;
    }
    long long x = pow2(n / 2);
    if(n % 2 == 1){
        return x * x * 2;
    }
    return x * x;
}

long long comb(long long n,long long m){
    if(n == 0){
        return 1;
    }
    else{
        long long ans = 1;
        for(long long i = 1;i <= m;i++){
            ans *= n - i + 1;
            ans /= i;
        }
        return ans;
    }
}

int main(){
    int n,p;
    std::cin >> n >> p;
    int a[n];
    long long odd = 0;
    for(int i = 0;i < n;i++){
        std::cin >> a[i];
        if(a[i] % 2 == 1){
            odd++;
        }
    }
    long long ans = 0;
    for(int i = p;i <= odd;i += 2){
        ans += comb(odd,i);
        //std::cout << ans << std::endl;
    }
    ans *= pow2(n - odd);
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 256
import collections

N = int(input())
S = []

for i in range(N):
    s = input()
    if (s[0] in 'MARCH'):
        S.append(s[0])

CNT = collections.Counter(S).most_common()
ans = 0

if (len(CNT) >= 3):

    for i in range(len(CNT)):

        for j in range(i + 1, len(CNT)):

            for k in range(j + 1, len(CNT)):

                ans += CNT[i][1] * CNT[j][1] * CNT[k][1]

print(ans)

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  string S;
  cin >> S;
  S += 'T';
  ll N = S.size();
  ll X, Y;
  cin >> X >> Y;

  vector<ll> A, B;
  ll cnt = 0;
  bool isA = true;
  bool first = true;
  for (ll i = 0; i < N; i++)
  {
    if (S.at(i) == 'T')
    {
      if (first)
      {
        first = false;
        X -= cnt;
      }
      else
      {
        if (isA)
          A.push_back(cnt);
        else
          B.push_back(cnt);
      }

      cnt = 0;
      isA = !isA;
    }
    else
    {
      cnt++;
    }
  }

  X = abs(X), Y = abs(Y);
  ll sumA = accumulate(A.begin(), A.end(), 0LL);
  ll sumB = accumulate(B.begin(), B.end(), 0LL);
  if (sumA < X || sumB < Y)
    FINALANS("No");
  if ((sumA + X) % 2 != 0 || (sumB + Y) % 2 != 0)
    FINALANS("No");
  ll P = (sumA + X) / 2, Q = (sumB + Y) / 2;

  cerr << "A" << endl;

  vector<vector<int>> dpx(A.size() + 1, vector<int>(sumA + 1, 0));
  dpx.at(0).at(0) = 1;
  for (ll i = 0; i < A.size(); i++)
  {
    for (ll j = 0; j <= sumA; j++)
    {
      if (j + A.at(i) <= sumA)
        dpx.at(i + 1).at(j + A.at(i)) |= dpx.at(i).at(j);
      dpx.at(i + 1).at(j) |= dpx.at(i).at(j);
    }
  }
  if (!dpx.at(A.size()).at(P))
    FINALANS("No");
  
  vector<vector<int>> dpy(B.size() + 1, vector<int>(sumB + 1, 0));
  dpy.at(0).at(0) = 1;
  for (ll i = 0; i < B.size(); i++)
  {
    for (ll j = 0; j <= sumB; j++)
    {
      if (j + B.at(i) <= sumB)
        dpy.at(i + 1).at(j + B.at(i)) |= dpy.at(i).at(j);
      dpy.at(i + 1).at(j) |= dpy.at(i).at(j);
    }
  }
  if (!dpy.at(B.size()).at(Q))
    FINALANS("No");

  FINALANS("Yes");
}

Measured memory_bytes: 31744
/*  union_find_tree_size.cpp
    素集合系を union-find tree で管理するライブラリ
    併合時の工夫：union by size

    verified: AtCoder ABC157 D - Friend Suggestions
        https://atcoder.jp/contests/abc157/tasks/abc157_d
*/

#include <bits/stdc++.h>
using namespace std;

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);  // Union-Find Tree で考える
    vector<int> X(M), Y(M);
    for (int i = 0; i < M; i++) {
        int z;
        cin >> X.at(i) >> Y.at(i) >> z;
        X[i]--, Y[i]--;
        uf.unite(X[i], Y[i]);
    }

    set<int> se;
    for (int i = 0; i < N; i++) {
        se.insert(uf.findRoot(i));
    }
    cout << (int)se.size() << endl;
    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int m[1111];

int main() {
   int n, x;
   cin >> n >> x;
   rep (i, n) {
      cin >> m[i];
      x -= m[i];
   }

   sort(m, m+n);
   ll ans = n;
   cout << ans + x / m[0] << endl;

   return 0;
}

Measured memory_bytes: 256
//Optimise
#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;

// #define MULTI_TEST
#ifdef LOCAL
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.first << ", " << p.second << ']';
    return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
    while (*name == ',' || *name == ' ')
        name++;
    std::cerr << name << " { ";
    for (const auto &v : arg)
        cerr << v << ' ';
    cerr << " }\n";
}
template <typename Arg1, typename... Args>
void PC(const char *names, Arg1 &&arg1, Args &&... args)
{
    while (*names == ',' || *names == ' ')
        names++;
    const char *comma = strchr(names, ',');
    std::cerr.write(names, comma - names) << " { ";
    for (const auto &v : arg1)
        cerr << v << ' ';
    cerr << " }\n";
    PC(comma, args...);
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define f first
#define s second
#define pb push_back
auto TimeStart = chrono::steady_clock::now();

const int NAX = 2e5 + 10, MOD = 1000000007;

void solveCase(int caseNo)
{
    int n;
    cin >> n;
    int x = floor(n / 1.08);
    if (floor(x * 1.08) == n)
        cout << x << '\n';
    else if (floor((x-1) * 1.08) == n)
        cout << x-1 << '\n';
    else if (floor((x+1) * 1.08) == n)
        cout << x+1 << '\n';
    else cout << ":(";
}

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int i = 1; i <= t; ++i)
    {
        solveCase(i);
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n); i > 0; i--)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = int64_t;

bool check_string(int ss, int se, string s, string t){
    int ti = 0;
    loop(si, ss, se){
        if(t[ti] != s[si] && s[si] != '?') return false;
        ti++;
    }
    return true;
}

int main(){
    string s, t; cin >> s >> t;

    if(s.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    vector<string> cand;
    int ssize = s.size(), tsize = t.size();
    rep(si, ssize - tsize + 1){
        string stmp = s;
        if(check_string(si, si+tsize, stmp, t)) {
            stmp.replace(si, tsize, t);
            replace(all(stmp), '?', 'a');
            cand.push_back(stmp);
        }
    }
    if(cand.empty()) cout << "UNRESTORABLE" << endl;
    else {
        sort(all(cand));
        cout << cand[0] << endl;
    }
    return 0;
}

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

int main()
{
  int a, b, c, x, y;
  int ab, n, m, sum = 0;

  cin >> a >> b >> c >> x >> y;

  ab = min(a + b, c * 2);
  n = min(a, c * 2);
  m = min(b, c * 2);

  while(x > 0 && y > 0){
    x--; y--;
    sum += ab;
  }

  sum += x * n;
  sum += y * m;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    double ar[n],br[n],ans;
    int i,j;
    for(i=0; i<n; i++)
      cin>>ar[i];
    for(i=0; i<n; i++)
      {
      ans=a-ar[i]*0.006;
      ar[i]=fabs(b-ans);
      br[i]=ar[i];
    }
    sort(br,br+n);
    for(i=0; i<n; i++)
    {
        if(ar[i]==br[0]) break;
    }
    cout<<i+1<<endl;
     return 0;



}




Measured memory_bytes: 256
import sys
a=int(input())
b=list(input())
c=0
if a%2==1:
  print('No')
  sys.exit()
for i in range(a//2):
  if  b[i]==b[i+(a//2)]:
    c+=1
  else:
    pass
  if c>=a//2:
    break
  
if c==a//2:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("Draw", A, A) :- !.
f("Alice", 1, _) :- !.
f("Bob", _, 1) :- !.
f("Alice", A, B) :- A > B.
f("Bob", A, B) :- A < B.

main :-
    get_number(A, B),
    f(X, A, B),
    writeln(X).


Measured memory_bytes: 8080
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn = 2e5 + 10;
bool flag[maxn];
int a[maxn] , f[maxn];
int mx = 1;
int n;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> a[i];
	for(int i = 1 ; i <= n ; ++ i){
		if(flag[a[i] - 1]){
			f[a[i]] = f[a[i] - 1] + 1;
			mx = max(mx , f[a[i]]);
		}
		else
			f[a[i]] = 1;
		flag[a[i]] = 1;
	}
	cout << n - mx << endl;
	return 0;
}

Measured memory_bytes: 2048
#!/usr/bin/env python3
import sys


def solve(N: int):
    x = 1
    y = ""
    z = N
    while(z > 26):
        z -= 26 ** x
        if z > 0 :
            x += 1
    for i in range(x):
        N -= 1
        y += chr(ord('a') + N % 26)
        N //= 26
    print(y[::-1])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MAX_V = 1e6+1;

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

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

int main() {
  int a, b, c, ans;
  cin >> a >> b;
  c = b - a;
  for(int i=1; i<=c; i++) {
    ans += i;
  }
  ans -= b;
  cout << ans << endl;
}


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


def binary_search(l, value):
    low = 0
    high = len(l) - 1
    while low <= high:
        mid = (low + high) // 2
        if l[mid] == value:
            return True
        elif l[mid] < value:
            low = mid + 1
        else:
            high = mid - 1
    return False


N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

A.append(10**6)
A.append(10**6)
B = [0] * (N + 1)
B[0] = 1
if binary_search(A, 1) is True:
    B[1] = 0
else:
    B[1] = 1
mod = 10**9 + 7

for i in range(2, N + 1):
    if i != 2 and binary_search(A, i - 1) is True and binary_search(
            A, i - 2) is True:
        print(0)
        exit()
    elif binary_search(A, i - 2) is True:
        B[i] = B[i - 1]
    elif binary_search(A, i - 1) is True:
        B[i] = B[i - 2]
    else:
        B[i] = B[i - 1] + B[i - 2]
    B[i] %= mod
print(B[N] % mod)


Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
ll mod=1000000007;

int main() {
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ar[n],br[n+1]={0};
    forn(i,n){
        cin>>ar[i];
        br[ar[i]]=i;
    }
    for(int i=1;i<n+1;i++)cout<<br[i]+1<<" ";

	return 0;
}


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

struct SCC {
    // T: adjacency list of topological graph
    // C: lists (scc id : the same scc nodes vec)
    vector<vector<int>> G, rG, T, C;
    vector<int> vs, cmp; // vs: order of nodes just before back track
    vector<bool> used;
    SCC() {}
    SCC(int n) : G(n), rG(n), used(n), cmp(n){};
    void add_edge(int u, int v) { // every vertex is from 0 to n-1
        G[u].emplace_back(v);
        rG[v].emplace_back(u);
    }
    void dfs(int v) {
        used[v] = true;
        for (int u : G[v]) {
            if (!used[u]) {
                dfs(u);
            }
        }
        vs.emplace_back(v);
    }
    void rdfs(int v, int k) { // v is node. k is the order of topological
        used[v] = true;
        cmp[v] = k;
        C[k].emplace_back(v);
        for (int u : rG[v]) {
            if (!used[u]) {
                rdfs(u, k);
            }
        }
    }
    int scc() {
        fill(used.begin(), used.end(), 0);
        int n = G.size();
        for (int v = 0; v < n; v++) {
            if (!used[v]) {
                dfs(v);
            }
        }
        fill(used.begin(), used.end(), 0);
        int k = 0;
        for (int i = n - 1; i >= 0; i--) { // reversed order
            if (!used[vs[i]]) {
                T.emplace_back();
                C.emplace_back();
                rdfs(vs[i], k);
                k++;
            }
        }
        for (int v = 0; v < n; v++)
            for (int u : G[v])
                if (cmp[v] != cmp[u])
                    T[cmp[v]].push_back(cmp[u]);
        for (int i = 0; i < k; i++) {
            sort(T[i].begin(), T[i].end());
            T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end()); // erase duplicated node;
        }
        return k;
    }
    int operator[](int k) const { return cmp[k]; }
};

int main() {
    int V, E;
    cin >> V >> E;
    SCC G(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G.add_edge(s, t);
    }

    int Q;
    cin >> Q;
    vector<int> u(Q), v(Q);
    for (int i = 0; i < Q; i++) {
        cin >> u.at(i) >> v.at(i);
    }

    G.scc();
    /*
    cout << "\nC: " << endl;
    for (auto vec : G.C) {
        for (auto v : vec) {
            cout << v << " ";
        }
        cout << endl;
    }

    cout << "\nT: " << endl;
    for (auto vec : G.T) {
        for (auto v : vec) {
            cout << v << " ";
        }
        cout << endl;
    }
    cout << endl;
    */
    for (int i = 0; i < Q; i++) {
        if (G[u[i]] == G[v[i]]) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4928
#include <stdio.h>

int main(void){
int a,b;
scanf("%d %d",&a,&b);
if (a <  b){
printf("a < b\n");
}
if (a > b){
printf("a > b\n");
}
if (a == b){
printf("a == b\n");
}
 return 0;
}

Measured memory_bytes: 1008
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,t;cin>>x>>t;
  cout<<max(0,x-t)<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll len(ll l,ll s){
  ll ret=0;
  ret+=(l/s)*s*2;
  if(l%s==0){
    return ret-s;
  }
  ret+=len(s,l%s);
  return ret;
}
int main(){
  ll n,x;cin>>n>>x;
  ll ans=0;
  ans+=n;
  ans+=len(x,n-x);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
ans = float('inf')
for i in range(-100, 101):
    v = 0
    for aa in a:
        v += pow(aa - i, 2)
    ans = min(ans, v)
print(ans)


Measured memory_bytes: 3060
#include <iostream>

typedef long long ll;
using namespace std;

ll dp[1001][1001];

ll solve(ll n, ll k, ll m) {
  for(int i=1;i<=n;++i) {
    for(int j=1;j<=i;++j) {
      if (i==1 || j==1) {
        dp[i][j] = 1;
      } else {
        dp[i][j] = (dp[i-1][j-1] + (j*dp[i-1][j] % m)) % m;
      }
    }
  }
  ll ans = 0;
  for(int i=1;i<=min(n,k);++i) {
    ans = (ans + dp[n][i]) % m;
  }
  return ans;
}

int main() {
  ll n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<solve(n,k,mod)<<endl;
  return 0;
}


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

N = int(input())
A = list(map(int, input().split()))


def calc(monsters):
    if len(monsters) == 1:
        return monsters[0]

    min_monster = min(monsters)
    min_index = monsters.index(min_monster)
    new_monsters = []
    for i in range(len(monsters)):
        if i == min_index:
            new_monsters.append(monsters[i])

        remndr = monsters[i] % min_monster
        if remndr != 0:
            new_monsters.append(remndr)

    return calc(new_monsters)


ans = calc(A)
print(ans)

Measured memory_bytes: 14224
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

const int MAXN = 1e5 + 10;
int n, m;
vector<pair<int, int> > vc;
multiset<int> S;
long long ans;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		S.insert(a);
	}
	for (int i = 0; i < m; i++) {
		int b, c;
		cin >> b >> c;
		vc.push_back({ c, b });
	}
	sort(vc.begin(), vc.end());
	reverse(vc.begin(), vc.end());
	for (int i = 0; i < vc.size(); i++) {
		int cnt = vc[i].second;
		long long c = vc[i].first;
		while (cnt && !S.empty()) {
			int a = *S.begin();
			if (a > c)
				break;
			ans += c;
			S.erase(S.begin());
			cnt--;
		}
	}
	for (int a : S)
		ans += a;
	cout << ans;
}

Measured memory_bytes: 6136
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

int N, M;
double board[20][20], dp[20][1 << 16];
void chmax(double &A, double B) { A = max(A, B); }

double solve(int idx, int bit) {
    if(dp[idx][bit] >= 0.0) return dp[idx][bit];

    double ret = 0.0;
    for(int i=0; i<N; i++) {
        if(!(bit >> i & 1)) continue;
        int nbit = bit ^ (1 << i);

        double alive = 1.0, tmp = 0.0;
        for(int k=idx; k<M; k++) {
            double dead = alive * (1.0 - board[i][k]);
            tmp += dead * solve(k, nbit);
            alive *= board[i][k];
        }
        tmp += alive * solve(M, bit);

        chmax(ret, tmp);
    }
    return dp[idx][bit] = ret;
}

int main() {
    scanf("%d%d", &N, &M);

    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            scanf("%lf", &board[i][j]);
        }
    }

    fill(dp[0], dp[M], -1);
    fill(dp[M], dp[M+1], 1);
    printf("%.12f\n", solve( 0, (1<<N)-1 ));
    return 0;
}


Measured memory_bytes: 11440
n = int(input())
all_li = []
for _ in range(n):
    tmp = list(map(int,input().split()))
    all_li.append(tmp)
if len(all_li) == 1:
    print(1)
    exit()
lee = len(all_li)
vector_map = {}
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        a = all_li[i][0]
        b = all_li[i][1]
        c = all_li[j][0]
        d = all_li[j][1]
        if (c-a,d-b) in vector_map:
            vector_map[(c-a,d-b)] += 1
        else:
            vector_map[(c-a,d-b)] = 1
m = max(vector_map.values())
print(n-m)

Measured memory_bytes: 39280
#include <stdio.h>

void merge_sort(int x[], int n)
{
	static int y[200001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{	
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &(A[i]));
	merge_sort(A, N);
	
	int j, k, count[200001] = {0};
	for (i = 0, k = 0; i < N; i++) {
		for (j = i + 1; j < N && A[j] == A[i]; j++);
		count[k] = j - i;
		A[k++] = A[i];
		i = j - 1;
	}
	N = k;
	
	int l, r, ans = 0, bit[31], tmp;
	for (i = 1, bit[0] = 1; i <= 30; i++) bit[i] = bit[i-1] * 2;
	for (i = N - 1, k = 30; i >= 0; i--) {
		for (; bit[k-1] > A[i]; k--);
		tmp = bit[k] - A[i];
		if (A[0] > tmp || A[i] < tmp) continue;
		l = 0;
		r = i;
		while (l < r) {
			if (A[(l+r)/2] < tmp) l = (l + r) / 2 + 1;
			else r = (l + r) / 2;
		}
		if (A[l] == tmp && count[l] > 0) {
			if (l < i) {
				tmp = (count[i] < count[l])? count[i]: count[l];
				count[l] -= tmp;
				ans += tmp;
			} else ans += count[i] / 2;
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<set>
using namespace std;
int d;
set<int> st;
int main(void)
{
    int n;
    cin >> n;
    d=n;
    st.insert(d);
    int i;
    for(i=2;;i++)
    {
        d=(d%2 ? d*3+1 : d/2);
        if(st.count(d)) break;
        st.insert(d);
    }
    cout << i;
    return 0;
}

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

using ll = long long;

int main() {
    int N; cin >> N;
    vector<ll> A(N), cnt(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i]; A[i]--;
        cnt[A[i]]++;
    }
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += cnt[i]*(cnt[i]-1)/2;
    }
    for (int i = 0; i < N; ++i) {
        cout << sum - (cnt[A[i]]-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int[] a = new int[n];
        double sum = 0;
        for (int i = 0; i < n ; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        double av = sum / (double) n;

        double max = 100000;
        int ans = 0;
        for (int i = 0; i < n ; i++) {
                if (Math.abs(av - a[i]) < max) {
                    max = Math.abs(av - a[i]);
                    ans = i;
                }
        }




        System.out.println(ans);
    }

}

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

int main() {
	long long x, y;
	cin>>x>>y;
	long long lmaoooo = y/x;
	lmaoooo = lmaoooo * x;
	long long sum = 0;
	while(x<= lmaoooo){
		x*=2;
		sum++;
	}
	cout<<sum;
	return 0;
}

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

#define int long long

auto main() -> signed {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0; i<n; ++i) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    for(int i=0; i<k; ++i) ans += l[i];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;

int ans,ans2;
int n,m;
P p[111111];

signed main(){

    cin>>n>>m;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        p[i]=P(a,b);
    }
    sort(p,p+n);
    priority_queue<int> que;
    int j=0;
    rep(i,m){
        while(p[j].first<=i+1 && j<n){
            que.push(p[j].second);
            j++;
        }
        if(que.size()){
            ans+=que.top();
            que.pop();
        }
    }
    cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll a,b;
    cin>>a>>b;
    if(b>=a)
    {
        cout<<"unsafe\n";
    }
    else
    {
        cout<<"safe\n";
    }
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}


Measured memory_bytes: 3640