akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t arc077_c()
{
  size_t n, k;
  cin >> n >> k;

  vector<size_t> a(n);
  cin >> a;
  {
    const auto x = a.front();
    for(auto & i: a)
      if(i < x)
        i = i + k - x;
      else
        i -= x;
  }

  // rotate(begin(a), begin(a) + 1, end(a));
  // a.pop_back();
  DEBUG(a);

  vector<int64_t> inc(2 * k);

  {
    vector<pair<size_t, size_t>> b;
    for(size_t i = 0; i + 1 < n; ++i)
      b.emplace_back(a[i], a[i + 1] + (a[i + 1] < a[i] ? k : 0));

    sort(begin(b), end(b));
    DEBUG(b);
    const auto comp = [&b](const size_t i, const size_t j) {
      return b[j].second < b[i].second;
    };

    priority_queue<size_t, vector<size_t>, decltype(comp)> heap(comp);
    size_t idx = 0;
    int64_t cnt = 0, acc = 0;

    for(size_t x = 0; x < inc.size(); ++ x)
    {
      inc[x] = acc;
      acc += cnt;

      for(; idx < b.size() && b[idx].first < x + 1; ++ idx)
      {
        ++ cnt;
        heap.push(idx);
      }

      while(!heap.empty())
      {
        const auto i = heap.top();
        if(x < b[i].second) break;
        heap.pop();
        -- cnt;
        acc -= x - b[i].first;
      }
    }
  }

  int64_t acc = 0;
  for(size_t i = 0; i + 1 < n; ++i)
    acc += a[i + 1] < a[i] ? a[i + 1] + k - a[i] : a[i + 1] - a[i];

  size_t idx = 0;
  for(size_t i = 1; i < k; ++i)
    if(inc[idx] + inc[idx + k] < inc[i] + inc[i + k])
      idx = i;

  return acc - inc[idx] - inc[idx + k];
}


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << arc077_c();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y){
	return (x>y ? (x=y,true):false);
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y){
	return (x<y ? (x=y,true):false);
}

template <typename T>
void read(T& x){
	char ch;
	T p=1;x=0;
	do{
		ch=getchar();
	}while(ch<=' ');
	if(ch=='-')p=-1,ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    x*=p;
}

void read(string& x){
	char ch;
	do{
		ch=getchar();
	}while(ch<=' ');
    while(ch>' ')x+=ch,ch=getchar();
}

void read(char& x){
	do{
		x=getchar();
	}while(x<=' ');
}
template<typename T, typename... R>
void read(T& x, R&... y) { read(x); read(y...); }

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=(int)1e6+3;
const int INF=(int)1e9+17;
const ll mod=(ll)1e9+7;
const ll LLINF=(ll)1e18+17;
const ld pi=(ld)acos(-1.0);
int n,m,a[N],b[N];

int main(){
	read(n);
	rep(i,0,n){
		read(a[i]);
		b[i]=a[i];
	}
	int mid=n/2-1;
	sort(b,b+n);
    rep(i,0,n){
    	if(b[mid]>=a[i])printf("%d\n",b[mid+1]);
		else printf("%d\n",b[mid]);
	}
	return 0;
}

Measured memory_bytes: 7168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').ToArray();
            string a = st[0];
            string b = st[1];

            if (a == "H") {
                Console.WriteLine(b);
            } else {
                if (b == "H") {
                    Console.WriteLine("D");
                } else {
                    Console.WriteLine("H");
                }
            }
        }

    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;

//==============================================
#define NIL -2000000050

struct node {
	int key;
	int parent = NIL;
	int left = NIL;
	int right = NIL;
};

node T[500050];

void insert(int z) {
	int y = NIL;
	int x = 0;

	if (z == 0) return;

	while (x != NIL) {
		y = x;
		if (T[z].key < T[x].key) {
			x = T[x].left;
		} else {
			x = T[x].right;
		}
	}

	T[z].parent = y;
	if (T[z].key < T[y].key) {
		T[y].left = z;
	} else {
		T[y].right = z;
	}
}

int find(int x, int k) {
	while (x != NIL && k != T[x].key) {
		if (k < T[x].key) {
			x = T[x].left;
		} else {
			x = T[x].right;
		}
	}

	return x;
}
int getMinimum(int x) {
	while (T[x].left != NIL) {
		x = T[x].left;
	}
	return x;
}


int getSuccessur(int x) {
	if (T[x].left != NIL) {
		return getMinimum(T[x].right);
	}

	int y = T[x].parent;
	while (y != NIL && x == T[y].right) {
		x = y;
		y = T[y].parent;
	}
	return y;
}

void deleteNode(int z) {
	int y;
	int x;

	z = find(0, z);

	if (T[z].left == NIL || T[z].right == NIL) {
		y = z;
	} else {
		y = getSuccessur(z);
	}

	if (T[y].left != NIL) {
		x = T[y].left;
	} else {
		x = T[y].right;
	}

	if (x != NIL) {
		T[x].parent = T[y].parent;
	}

	if (y == T[T[y].parent].left) {
		T[T[y].parent].left = x;
	} else {
		T[T[y].parent].right = x;
	}

	if (y != z) {
		T[z].key = T[y].key;
	}
}

void inorder(int x) {
	if (x == NIL) return;
	inorder(T[x].left);
	cout << " " << T[x].key;
	inorder(T[x].right);
}

void preorder(int x) {
	if (x == NIL) return;
	cout << " " << T[x].key;
	preorder(T[x].left);
	preorder(T[x].right);
}


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

	int n;
	cin >> n;

	string s;
	int v;
	REP(i, n) {
		cin >> s;

		if (s == "insert") {
			cin >> v;
			T[i].key = v;
			insert(i);
		} else if (s == "find") {
			cin >> v;
			if (find(0, v) != NIL) {
				cout << "yes" << "\n";
			} else {
				cout << "no" << "\n";
			}
		} else if(s == "delete") { 
			cin >> v;
			deleteNode(v);
		} else {
			inorder(0);
			cout << "\n";
			preorder(0);
			cout << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 10992
from fractions import gcd
def lcm(a,b):
    return (a*b)/gcd(a,b)
n,m = map(int, raw_input().split())
s = raw_input() 
t = raw_input()

L = lcm(n,m)
ss = L/n
ts = L/m
seen = {}
works = True

ind = 0
for char in s:
    if ind in seen:
        if not seen[ind] == char:
            works = False
            break
    else:
        seen[ind] = char
    ind += ss

ind = 0
for char in t:
    if ind in seen:
        if not seen[ind] == char:
            works = False
            break
    else:
        seen[ind] = char
    ind += ts

if works: print L
else: print -1








Measured memory_bytes: 58520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using Vb = V<bool>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVb = V<Vb>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s, t; cin >> s >> t;
  int n = sz(s);
  int m = sz(t);


  int ans = INF;
  rep(i, n-m+1) {
    int cnt = 0;
    rep(j, m) if (s[i+j] != t[j]) ++cnt;
    chmin(ans, cnt);
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3640
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

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

N,K,L = II()
p,q = Line(K)
r,s = Line(L)

class UF(object):
  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]
    self.size = [1 for _ in range(n)]

  def find(self, x):
    """
    x が属するグループを探索
    """
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def union(self, x, y):
    """
    x と y のグループを結合
    """
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
      self.size[x] += self.size[y]

  def is_same(self, x, y):
    """
    x と y が同じグループか否か
    """
    return self.find(x) == self.find(y)

  def get_size(self, x):
    """
    x が属するグループの要素数
    """
    x = self.find(x)
    return self.size[x]
  
uf1 = UF(N)
uf2 = UF(N)
ans = []

for i in range(K):
  uf1.union(p[i]-1,q[i]-1)

for i in range(L):
  uf2.union(r[i]-1,s[i]-1)

x = []
for i in range(N):
  x.append([uf1.find(i), uf2.find(i)])
y = x[:]
y.sort(key=lambda x:(x[0],x[1]))

from bisect import bisect_left, bisect_right
for i in range(N):
  ans.append(bisect_right(y,x[i])- bisect_left(y,x[i]))

print(*ans)

Measured memory_bytes: 124112
N = int(input())
tmp = input().split()
dict = {}

for n in range(N):
    if tmp[n] in dict:
        dict[tmp[n]] += 1
    else:
        dict[tmp[n]] = 1
count = 0
for k,v in dict.items():
    if int(k) ==v:
        continue
    elif int(k) > v:
        count +=v
    else:
        count += (v-int(k))
print(count)

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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<long long> a(3 * n); for (int i = 0; i < 3 * n; i++) cin >> a[i];
  priority_queue<long long, vector<long long>, greater<long long>> fpq;
  for (int i = 0; i < n; i++) fpq.push(a[i]);
  priority_queue<long long> lpq;
  for (int i = 0; i < n; i++) lpq.push(a[i + 2 * n]);
  vector<long long> fsum(n + 1), lsum(n + 1);
  fsum[0] = accumulate(a.begin(), a.begin() + n, 0LL);
  lsum[0] = accumulate(a.begin() + 2 * n, a.end(), 0LL);
  for (int i = 0; i < n; i++) {
    if (fpq.top() < a[n + i]) {
      fsum[i + 1] = fsum[i] + a[n + i] - fpq.top();
      fpq.push(a[n + i]);
      fpq.pop();
    } else fsum[i + 1] = fsum[i];
    if (lpq.top() > a[2 * n - 1 - i]) {
      lsum[i + 1] = lsum[i] + a[2 * n - 1 - i] - lpq.top();
      lpq.push(a[2 * n - 1 - i]);
      lpq.pop();
    } else lsum[i + 1] = lsum[i];
  }
  long long res = fsum[0] - lsum[n];
  for (int i = 1; i <= n; i++) res = max(res, fsum[i] - lsum[n - i]);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n,k;
           cin>>n>>k;
           if(k==1){
            cout<<0<<endl;
             return 0;
           }
           cout<<n-k<<endl;
}

Measured memory_bytes: 3508
#include <stdio.h>

int main(void){
    int h,w;
    while (1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }else{
            for (int i=0; i<h; i++){
                for (int j=0; j<w; j++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2040
# AOJ ITP2_5_C: Permutation
# Python3 2018.6.24 bal4u

def next_permutation(a):
    # if list has less than two elements, has no next permutation.
    if len(a) < 2: return False

    # step 1: find max i for a[i] > a[i+1]
    i = len(a)-2
    while i >= 0 and a[i] >= a[i+1]: i -= 1
    if i < 0: return False
    j = i + 1

    # step 2: find max k for a[k] > a[i]
    k = len(a) - 1
    while a[i] >= a[k]: k -= 1

    # step 3: swap a[i] and a[k]
    (a[i], a[k]) = (a[k], a[i])

    # step 4: reverse a[j:]
    a[j:] = a[:j-1:-1]

    return True

def prev_permutation(a):
    # if list has less than two elements, has no prev permutation.
    if len(a) < 2: return False

    # step 1: find max i for a[i] < a[i+1]
    i = len(a)-2
    while i >= 0 and a[i] <= a[i+1]: i -= 1
    if i < 0: return False
    j = i + 1

    # step 2: find max k for a[k] < a[i]
    k = len(a) - 1
    while a[i] <= a[k]: k -= 1

    # step 3: swap a[i] and a[k]
    (a[i], a[k]) = (a[k], a[i])

    # step 4: reverse a[j:]
    a[j:] = a[:j-1:-1]

    return True
            
n = int(input())
a = list(map(int, input().split()))
n, p = list(a), list(a)
if prev_permutation(p): print(*p)
print(*a)
if next_permutation(n): print(*n)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X-(K-1); i <= X+(K-1); i++)
    cout << i << " ";
    
    
  

}

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

const int N = 1e5L + 11;
bool v[N];
int cnt[N];

int main() {
	ios :: sync_with_stdio(0);
	int n, m; cin >> n >> m;
	v[1] = 1;
	fill(cnt + 1, cnt + n + 1, 1);
	while(m --) {
		int x, y; cin >> x >> y;
		v[y] |= v[x];
		cnt[y] ++;
		cnt[x] --;
		if(cnt[x] == 0)
			v[x] = 0;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i ++)
		if(cnt[i] && v[i]) ans ++;
	cout << ans << '\n';
}

Measured memory_bytes: 768
#include<iostream>
#include<cmath>
using namespace std;
int a[2000];
long long ans = 0;
long long mx;
long long fastpow(int a,int b)
{
    long long ans = 1;
    while(b)
    {
        if(b&1)ans *=a;
        b>>=1;
        a *=a;
    }
    return ans;
}
int main()
{
    int n;
    while(cin >> n)
    {
        mx = -0x3f3f3f3f;
        int flag = 0;
        ans = 0;
        for(int i=0; i<n; i++)
            cin >> a[i];
        for(int i=0; i<n; i++)
        {
            for(int j=i+1; j<n; j++)
            {
                long long temp = a[i]*a[j] ;
                ans = temp;
                int len = 0;
                while(temp)
                {
                    temp /= 10;
                    len ++;
                }
                temp = ans;
                for(int k=0;k<len - 1;k++)
                {
                    int a = temp / fastpow(10,k) % 10;
                    int b = temp / fastpow(10,k+1) % 10;
                    if(a-b!=1)
                    {
                        ans = -1;
                        break;
                    }
                }
                if(ans!=-1)
                {
                    if(ans > mx) mx = ans;
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 0)
          cout << ans <<endl;
        else cout << mx <<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def inv(x):
    return pow(x, MOD-2, MOD)

def nPk(n,k):
    return fac(n) * inv(fac(n-k)) % MOD

def nCk(n,k):
    return nPk(n,k) * inv(fac(k))

MOD = 10**9+7

def fac(N):
    known = { 0: 1, 1000000000: 698611116, 320000000: 30977140, 820000000: 629786193, 740000000: 375297772, 470000000: 909210595, 200000000: 933245637, 940000000: 83868974, 400000000: 429277690, 130000000: 623534362, 870000000: 256473217, 600000000: 724464507, 330000000: 522049725, 60000000: 27368307, 800000000: 203191898, 530000000: 256141983, 260000000: 135498044, 730000000: 663307737, 460000000: 275105629, 190000000: 109838563, 930000000: 778983779, 660000000: 769795511, 390000000: 917084264, 120000000: 661224977, 860000000: 116667533, 10000000: 682498929, 590000000: 131772368, 50000000: 67347853, 790000000: 748510389, 520000000: 608823837, 250000000: 112390913, 990000000: 847549272, 720000000: 852304035, 450000000: 462639908, 180000000: 547665832, 920000000: 193781724, 650000000: 92255682, 380000000: 940567523, 110000000: 281863274, 850000000: 823845496, 580000000: 848924691, 310000000: 128487469, 40000000: 723816384, 780000000: 624500515, 510000000: 97830135, 240000000: 136026497, 980000000: 377329025, 710000000: 435887178, 440000000: 780072518, 170000000: 66404266, 20000000: 491101308, 670000000: 373745190, 910000000: 172114298, 640000000: 903466878, 370000000: 148528617, 100000000: 927880474, 840000000: 814362881, 570000000: 811575797, 300000000: 668123525, 30000000: 76479948, 770000000: 671734977, 500000000: 733333339, 230000000: 268838846, 970000000: 492741665, 700000000: 957939114, 430000000: 568392357, 160000000: 195888993, 900000000: 586445753, 630000000: 456152084, 360000000: 189239124, 90000000: 888050723, 830000000: 672850561, 560000000: 637939935, 290000000: 500780548, 760000000: 624148346, 490000000: 703397904, 220000000: 368925948, 270000000: 217544623, 960000000: 965785236, 690000000: 825871994, 420000000: 358655417, 150000000: 261384175, 890000000: 245795606, 620000000: 326159309, 350000000: 386027524, 80000000: 199888908, 550000000: 696628828, 280000000: 419363534, 750000000: 217598709, 480000000: 99199382, 210000000: 724691727, 950000000: 315103615, 680000000: 606241871, 410000000: 996164327, 140000000: 970055531, 880000000: 627655552, 610000000: 272814771, 340000000: 309058615, 70000000: 625544428, 810000000: 423951674, 540000000: 141827977}

    ans = known[ N - N % int( 1e7 ) ]
    for i in range( N - N % int( 1e7 ) + 1, N + 1, 1 ):
        ans = ans * i % MOD
    return ans

n,a,b = get_nums_l()

nCa = nCk(n,a)
nCb = nCk(n,b)
ans = pow(2, n, MOD) - 1 - nCa - nCb
print(ans % (10**9 + 7))

Measured memory_bytes: 38768
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			int N = in.nextInt();
			int K = in.nextInt();
			int[] h = new int[N];
			for (int i = 0; i < N; i++) {
				h[i] = in.nextInt();
			}
			int[] dp = new int[N];
			Arrays.fill(dp, Integer.MAX_VALUE);
			dp[0] = 0;
			for (int i = 1; i < N; i++) {
				for (int j = Math.max(0, i - K); j < i; j++) {
					if (dp[j] == Integer.MAX_VALUE) continue;
					dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
				}
			}
			System.out.println(dp[N - 1]);
		}
	}
}


Measured memory_bytes: 50548
#include <bits/stdc++.h>
#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() {
  int n;
  cin >> n;
  vector<int> d(3);
  rep(i,3) cin >> d[i];
  vector<P> q;
  rep(i,n) {
    string s;
    cin >> s;
    int a = 0, b = 1;
    if (s == "AB") a = 0, b = 1;
    if (s == "AC") a = 0, b = 2;
    if (s == "BC") a = 1, b = 2;
    q.emplace_back(a,b);
  }
  string ans;
  auto add = [&](int a, int b) {
    d[a]++;
    d[b]--;
    ans += 'A'+a;
  };
  q.emplace_back(0,1);
  rep(i,n) {
    int a = q[i].first;
    int b = q[i].second;
    if (!d[a] && !d[b]) {
      cout << "No" << endl;
      return 0;
    }
    if (!d[a]) {
      add(a,b);
    } else if (!d[b]) {
      add(b,a);
    } else {
      int na = q[i+1].first;
      int nb = q[i+1].second;
      if (a == na || a == nb) {
        add(a,b);
      } else {
        add(b,a);
      }
    }
  }
  cout << "Yes" << endl;
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4328
fn main() {
    const EPS: f64 = 1e-9;

    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let [x, y]: [Vec<f64>; 2] = {
        let mut x = Vec::with_capacity(n);
        let mut y = Vec::with_capacity(n);
        for _ in 0..n {
            let [a, b]: [f64; 2] = {
                let mut buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
                let mut iter = buf.split_whitespace();
                [
                    iter.next().unwrap().parse().unwrap(),
                    iter.next().unwrap().parse().unwrap(),
                ]
            };
            x.push(a);
            y.push(b);
        }
        [x, y]
    };

    let mut ans = std::f64::MAX;

    let d = |x1: f64, y1: f64, x2: f64, y2: f64| {
        (x1 - x2).powi(2) + (y1 - y2).powi(2)
    };

    let mut f = |p: f64, q: f64| {
        let mut res: f64 = 0.0;
        for i in 0..n {
            res = res.max(d(p, q, x[i], y[i]));
        }
        ans = ans.min(res.sqrt());
    };

    for i in 0..n {
        for j in (i + 1)..n {
            {
                let p = (x[i] + x[j]) / 2.0;
                let q = (y[i] + y[j]) / 2.0;
                f(p, q);    
            }
            for k in (j + 1)..n {
                let a = d(x[j], y[j], x[k], y[k]);
                let b = d(x[k], y[k], x[i], y[i]);
                let c = d(x[i], y[i], x[j], y[j]);
                if (b.sqrt() + c.sqrt() - a.sqrt()).abs() < EPS { continue; }
                if (c.sqrt() + a.sqrt() - b.sqrt()).abs() < EPS { continue; }
                if (a.sqrt() + b.sqrt() - c.sqrt()).abs() < EPS { continue; }
                let u = a * (b + c - a);
                let v = b * (c + a - b);
                let w = c * (a + b - c);
                let p = (u * x[i] + v * x[j] + w * x[k]) / (u + v + w);
                let q = (u * y[i] + v * y[j] + w * y[k]) / (u + v + w);
                f(p, q);
            }
        }
    }

    println!("{:.10}", ans);
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
#define INF (lo)(1e9 + 7)
#define MOD (lo)(1e9 + 7)
#define mp make_pair
#define pb push_back
#define pp pop_back
using namespace std;
typedef long long int lo;
typedef pair<lo,lo> pii;
lo a,b,c;
map<lo,lo> mep;

int main(){
    lo n;
    cin >> n;
    for(lo i = 1;i <=n;i++){
        lo x;
        cin >> x;
        if(x % 2 == 0){
            if(x % 3 == 0 or x % 5 == 0) continue;
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int m,n,a,i,j,cnt,cnt2;
	int flg[1001],flg2;
	int k; // 現在のプレイヤー
	int an[1001]; //答え
	string s;
	while(1){
		cin>>m>>n;
		for(i=1;i<=m;i++) flg[i]=0;
		flg[m+1]=0; k=1;
		if(m==0&&n==0) break;
		cnt2=0;
		for(i=1;i<=n;i++){
			//for(j=1;j<=m;j++) printf("%d ",flg[j]);
			//printf("\n");
			cin>>s;
			
			 // 残りのプレイヤーが一人ならばしたの処理をとばす
			if(cnt2==m-1) continue;
			
			  // flgを無視
			if(k>m){
				for(j=1;j<=m;j++){
					if(flg[j]==0){
						k=j; break;
					}
				}
			}
			
			if(i%3==0&&i%5==0){
				if(s[0]!='F'||s[4]!='B'){
					flg[k]=1; cnt2++;
				}
			}
			else if(i%3==0){
				if(s[0]!='F'){
					flg[k]=1; cnt2++;
				}
			}
			else if(i%5==0){
				if(s[0]!='B'){
					flg[k]=1; cnt2++;
				}
			}
			else{
				a=atoi(s.c_str());
				if(i!=a){
					flg[k]=1; cnt2++;
				}
			}
			
			  // flgを無視
			for(j=k+1;j<=m+1;j++){
				if(flg[j]==0){
					k=j; break;
				}
			}
			
		}
		//for(i=1;i<=m;i++) printf("%d ",flg[i]);
		//printf("\n");
		cnt=0;
		for(i=1;i<=m;i++){
			if(flg[i]==0){
				cnt++;
				an[cnt]=i;
			}
		}
		for(i=1;i<cnt;i++) printf("%d ",an[i]);
		printf("%d\n",an[cnt]);
	}
	return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    string s;
    cin >> s;
    int n = s.length();

    int ret = 0;
    for (int i=0; i<n/2; i++)
        ret += s[i] != s[n-i-1];
    cout << ret << "\n";

    return 0;
}

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

typedef long long ll;

const int nlimit=301;
int n;
int a[nlimit][nlimit];//ポテンシャルの計算でlongへのキャストを忘れない
ll b[nlimit][nlimit];//わーシャルフロイド用のDPテーブル

int main(){
  //input
  cin >> n;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      cin >> a[i][j];
      b[i][j] = 1LL * a[i][j];
    }
  }

  //まずワーシャルフロイドで全頂点間の最短距離を確定
  for(int k=1; k<=n; k++){
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        b[i][j] = min(b[i][k]+b[k][j], b[i][j]);
      }
    }
  }

  //次に各頂点間の最短距離について削除できる辺がないか調査
  ll cnt=0;

  //辺i-jを全探索
  for(int i=1; i<=n; i++){
    for(int j=i+1; j<=n; j++){
      //もし最短距離が更新されたなら不適
      if(b[i][j]<a[i][j]){
        cnt = -1;
        break;
      }
      //辺i-jが必要かどうか
      bool necessary=true;

      for(int k=1; k<=n; k++){
        if(i==k || k==j) continue;
        if(b[i][j]<a[i][j]){
          cnt=-1;
          break;
        }
        //このような辺はいらないので削除可能
        if(b[i][j]==b[i][k]+b[k][j]) {
          necessary=false;
          break;
        }
      }

      //削除不可能な辺について加算
      if(necessary) cnt+= a[i][j];
    }
    if(cnt==-1)break;
  }

  cout << cnt << endl;

  return 0;

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(6)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};		
void solve(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	if(n<=k) cout<<s<<endl;
	else{
		string temp=s.substr(0,k);
		temp+="...";
		cout<<temp<<endl;
	}
	
	
	
		
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
    char s[300];
    char t[300];
    
    scanf("%s",s);
    scanf("%s",t);

    //strncat(s,t,100);
    //printf("%s\n",s);

    strncat(t,s,100);
    printf("%s\n",t);

    return 0;

}

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

int main(void){
    int a,b,c,d;
    int h,i,j,k;
    cin >> h >> i >> j >> k >> a >> b >> c >> d;
    int sum1 = (h*a)+(h/10*c)+(i*b)+(i/20*d);
    int sum2 = (j*a)+(j/10*c)+(k*b)+(k/20*d);
    cout << (sum1>sum2?"hiroshi":sum1==sum2?"even":"kenjiro") << endl;
    return 0;
}


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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int n;
pair<int, int> a[8];

int s(int x) {
    return x * x;
}
typedef std::numeric_limits< double > dbl;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;
    sort(a, a+n);
    int p = 0;
    long double x = 0;
    do {
        p++;
        for (int i = 0; i < n - 1; ++i)
            x += sqrt(s(a[i].first - a[i + 1].first) + s(a[i].second - a[i + 1].second));
    } while (next_permutation(a, a+n));
    cout.precision(dbl::max_digits10);
    cout << x / p;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace question3
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run(){
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split(' ').Select(c=>int.Parse(c)).OrderBy(e=>e).ToArray();

            var left = d[d.Length/2-1];
            var right = d[d.Length/2];

            Console.WriteLine(right-left);
        }
    }
}


Measured memory_bytes: 22112
#include <bits/stdc++.h>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> p;
int jyo(int x,int y){//xのｙ乗
	int ans=1;
	for(int i=0;i<y;i++){
		ans*=x;
	}
	return ans;
}
int main() {
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200)cout<<s;
	else cout<<"red";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
def ans(n):
    pow_2 = int(n**(0.5))
    pow_exeption = [32,128,243]
    #print(pow_2)
    ans = pow_2**2
    for i in pow_exeption:
        if i <= n:
            ans = max(i,ans)
    for i in range(1,11):
        if i**3 <= n:
            ans = max((i**3),ans)
        
    return(ans)
n = int(input())
for i in range(n,n+1):
    print(ans(i))

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

using namespace std;

int w, h;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
char rgb[] = "RGB";

struct Grid {
    int cnt;
    string stat;
};

bool check(string s) {
    int p = 1;
    while(s[p] == s[p - 1] && p < s.size()) ++p;
    return p == s.size();
}

void rep(string &stat, char from, char to, int x, int y) {

    stat[y * w + x] = to;

    for(int i = 0; i < 4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if(nx >= 0 && nx < w && ny >= 0 && ny < h && stat[ny * w + nx] == from) {
            rep(stat, from, to, nx, ny);
        }
    }

    return;
}

int main() {

    char graph[10][10];

    while(cin >> w >> h, w | h) {

        string stat = "";

        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                cin >> graph[i][j];
                stat += graph[i][j];
            }
        }

        //queue<int>
        map<string, bool> mp;
        queue<Grid> q;

        q.push((Grid){0, stat});
        mp[stat] = true;

        while(!q.empty()) {

            Grid now = q.front(); q.pop();

            //cout << now.stat << endl;

            if(check(now.stat)) {
                cout << now.cnt << endl;
                break;
            }

            for(int i = 0; i < 3; ++i) {
                Grid next = (Grid){now.cnt + 1, now.stat};
                if(next.stat[0] != rgb[i]) {
                    rep(next.stat, next.stat[0], rgb[i], 0, 0);
                    if(mp.count(next.stat) == 0) {
                        mp[next.stat] = true;
                        q.push(next);
                    }
                }
            }

        }

    }

}

Measured memory_bytes: 2724
(defun cal-divisor (num)
  (loop for i from 1 to num
        count (zerop (mod num i))))


(let* ((n (read))
       (l (loop for i from 1 to n by 2
                collect i)))

  (format t "~A~%"
          (count 8 (mapcar #'cal-divisor l))))


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 N, M, T;
	cin >> N >> M >> T;
	vector<int64> a(N);
	REP(i, N) cin >> a[i];
	a.push_back(T+M);
	int64 res = 0;
	res += a[0]-M;
	REP(i, N) {
		res += max(a[i+1]-a[i]-2*M, (int64)0);
	}

	cout << res << endl;
}



Measured memory_bytes: 3140
n, m = map(int, input().split())
disputes = []
for i in range(m):
    a, b = map(int, input().split())
    disputes.append((b, a))

disputes.sort()

ans=0
flag=0
for b,a in disputes:
    if flag<=a:
        ans+=1
        flag=b

print(ans)

        


Measured memory_bytes: 17016
import heapq
N, M = map(int, input().split())

L = [[int(i) for i in input().split()] for i in range(N)]
L = sorted(L, key=lambda x: -x[0])

h = []
ans = 0
j = N-1
for i in range(M-1, -1, -1):
    while j >= 0 and L[j][0] <= M - i:
        heapq.heappush(h, -L[j][1])
        j -= 1
    if len(h) == 0:
        continue
    ans += -heapq.heappop(h)
print(ans)


Measured memory_bytes: 26856
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;


int main()
{
	fast;
	cin>>n;
	int a=0;
	int b=0;
	int q=0;
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		int t,l,r;
		cin>>t>>l>>r;
		int x=fabs(l-a);
		int y=fabs(r-b);
		if(x+y>t-q || (t-q-x-y)%2==1)
			flag=1;
		a=l;
		b=r;
		q=t;
	}
	if(flag)
	{
		return cout<<"No",0;
	}
	cout<<"Yes";

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    if(n % 10 == 7 || (n %100) / 10 == 7 || n / 100 == 7) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    unordered_map<unsigned long, unsigned long> mp;
    unsigned long mask{random_device{}()};
    for(auto&& i : A){
        cin >> i;
        ++mp[i ^ mask];
    }
    unsigned long ans{0};
    for(const auto& i : A)[&]{
        unsigned long cnt{0};
        for(unsigned long j{1}; j * j <= i; ++j)if(i % j == 0){
            if(mp.count(j ^ mask))cnt += mp[j ^ mask];
            if(j * j < i && mp.count((i / j) ^ mask))cnt += mp[(i / j) ^ mask];
            if(cnt > 1)return;
        }
        ++ans;
    }();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12836
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1e9+7)
#define mset(a,k) memset(a,k,sizeof(a))
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define pqueue priority_queue<ll>
#define piqueue priority_queue<ll,vll ,greater<ll>>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
#define vvi vector<vi>
#define vvii vector<vii>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS-------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void out(vi a)							{for (int i = 0; i < (ll)a.S; i++) { cout << a[i] << " "; } cout << endl;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << '\n';}
void out1(vi v)							{fr(i, 0, (ll)v.S) {cout << v[i] << " ";} cout << endl;}
const ll MAXN = (ll)(1 * 1e6 + 5 ), level = 22;
void solve()
{
ll a,b;
char ch;
cin>>a>>ch>>b;
if(ch=='+')cout<<a+b<<'\n';
else cout<<a-b<<'\n';
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen ("inp4.txt", "r", stdin);
	freopen ("out4.txt", "w", stdout);
#endif
	fast();

	ll t = 1;
	//cin >> t;
	//sieve(1e7 + 5);
	fr(i, 0, t)
	{
		solve();
	}
}



Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
  int a, b; cin >> a >> b;
  for (int i = 0; i <= 10000; i++) {
    if ( i*8/100 == a && i*10/100 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()
num = copy.deepcopy(A)

for i in range(1, N):
    num[i] += num[i - 1]

# + - + -
margin_1 = 0
num_1 = copy.deepcopy(num)
cnt_1 = 0
for i in range(N):
    num_1[i] += margin_1
    if i % 2 == 0:
        plus = max(1 - num_1[i], 0)
        num_1[i] += plus
        margin_1 += plus
        cnt_1 += plus
    else:
        minus = max(num_1[i] - (-1), 0)
        num_1[i] -= minus
        margin_1 -= minus
        cnt_1 += minus

margin_2 = 0
num_2 = copy.deepcopy(num)
cnt_2 = 0
for i in range(N):
    num_2[i] += margin_2
    if i % 2 != 0:
        plus = max(1 - num_2[i], 0)
        num_2[i] += plus
        margin_2 += plus
        cnt_2 += plus
    else:
        minus = max(num_2[i] - (-1), 0)
        num_2[i] -= minus
        margin_2 -= minus
        cnt_2 += minus

print(min(cnt_1, cnt_2))

Measured memory_bytes: 100956
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 200200;

int bit[ms];

int qry(int x) {
	int ans = 0;
	for(; x > 0; x -= x & -x) ans += bit[x];
	return ans;
}

void upd(int x) {
	for(; x < ms; x += x & -x) bit[x]++;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::vector<std::pair<int, int>> wtf;
	std::vector<int> a[26];
	std::string str;
	std::cin >> str;
	int n = (int) str.size();
	std::vector<int> center;
	for(int i = 0; i < n; i++) {
		a[str[i] - 'a'].push_back(i);
	}
	for(int i = 0; i < 26; i++) {
		int l = 0, r = (int) a[i].size() - 1;
		while(l < r) {
			wtf.emplace_back(a[i][l++], a[i][r--]);
		}
		if(l == r) {
			center.push_back(a[i][l]);
		}
	}
	if((int) center.size() > 1) {
		std::cout << "-1\n";
		return 0;
	}
	long long ans = 0;
	if((int) center.size() == 1) {
		for(auto c : center) {
			for(auto p : wtf) {
				int l = p.first;
				int r = p.second;
				if(l > c) ans++;
				if(r < c) ans++;
			}
		}
	}
	std::sort(wtf.begin(), wtf.end());
	for(auto p : wtf) {
		ans += qry(p.second) + qry(p.first);
		upd(p.second+1);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int N, a[100000], t[100000] = { 0 }, ans, tmp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		t[a[i]]++;
	}

	ans = t[0] + t[1];
	for (int i = 1; i < N - 1; i++) {
		tmp = t[i - 1] + t[i] + t[i + 1];
		if (ans < tmp)	ans = tmp;
	}
	tmp = t[N - 2] + t[N - 1];
	if (ans < tmp)	ans = tmp;
	if (N == 1)	ans = 1;

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    ull c[64][2], a, n, k, r = 0;
    memset(c, 0, sizeof(ull[64][2]));
    cin >> n >> k;
    for (ull i = 0; i < n; i++) {
        cin >> a;
        for (ull j = 0; j < 64; j++) {
            c[j][(a & ((ull) 1 << j)) ? 1 : 0]++;
        }
    }
    bool u10 = false;
    for (ll i = 63; i >= 0; i--) {
        if (k & ((ull) 1 << (ull) i) || u10) {
            if(c[i][0] < c[i][1]) {
                r = r * 2 + c[i][1];
                u10 = true;
            } else r = r * 2 + c[i][0];
        }
        else r = r * 2 + c[i][1];
    }
    cout << r << endl;
}


Measured memory_bytes: 384