akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long M)
{
  LL val = N * (N - 1);
  val += M * (M - 1);
  val /= 2;
  cout << val << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int MAXN=55;
char s[MAXN];

int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	n-=8;
	for(int i=1;i<=n;++i)
		putchar(s[i]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#define DEBUG(d,n) {for (int i = 0; i < n; i++) {\
						if (i != n-1)	printf("%d ", d[i]);\
						else 			printf("%d", d[i]);\
					}	printf("\n");}
static int MAX = 100;

int main() {
	int n, d[MAX];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &d[i]);
	
	// select a value form 1 to n-1
	for (int i = 1; i < n; i++) {
		DEBUG(d,n);	// display every step
		int key = d[i];	// wait for insert
		int j = i - 1;
		// compare form i to 0 <- find a position to insert
		while (j >= 0 && d[j] > key) {
			d[j+1] = d[j];	// copy i-th to i+1-th
			j--;
		}
		d[j+1] = key;	// insert
	}
	
	DEBUG(d,n);	// display final step <- fixed PE
	return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    int N , A;
    cin >> N;
    int T[N] , X[N] , Y[N];
    for(int i = 0; i < N; i++){
        cin >> T[i] >> X[i] >> Y[i];
    }
    for(int i = 0; i < N; i++){
        A = T[i] - X[i] - Y[i];
        if(A < 0 || A % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

const int Maxn = 20;
int n, a[Maxn];
long long work(int lt, int rt, int val1, int val2)
{
	if (lt + 1 == rt) return 0;
	long long tmp = 0x3f3f3f3f3f3f3f3fLL;
	for (int i = lt + 1; i < rt; i++)
		tmp = min(tmp, work(lt, i, val1, val1 + val2) + work(i, rt, val1 + val2, val2) + a[i] * (long long) (val1 + val2));
	return tmp;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	printf("%lld\n", work(1, n, 1, 1) + a[1] + a[n]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define M 1046527
#define L 14
char H[M][L];
int getChar(char gc){
  if (gc=='A') return 1;
  else if (gc=='C') return 2;
  else if (gc=='G') return 3;
  else if (gc=='T') return 4;
}
long long getKey(char str[]){
  long long sum=0,p=1,i;
  for (i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + (key % (M-1));
}
int find(char str[]){
  long long key, i, h;
  key=getKey(str);
  for (i=0;;i++){
    h =(h1(key)+i*h2(key))%M;
    if( strcmp(H[h],str)==0){
      return 1;}
    else if ( strlen(H[h])==0) {
      return 0;}
  }
  return 0;
}
int insert(char str[]){
  long long key, i, h;
  key=getKey(str);
  for(i=0; ;i++ ){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) {
      return 1;}
    else if ( strlen(H[h])==0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  int a[M];
  for (i=0;i<=M;i++){
    H[i][0] = '\0';
      }
  scanf("%d", &n);
  for (i=0;i<n;i++){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      if (insert(str)){}
    }
    else {
      if (find(str) ){
        a[i]=1;  }
      else {
        a[i]=2;  }
    }
  }
  for (i=0;i<n;i++){
    if(a[i]==1){
      printf("yes\n");
    }
    if(a[i]==2){
      printf("no\n");
    }

}
  return 0;
}


Measured memory_bytes: 19960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
//    if((c)>(b+a)){
//        cout<<((c)-(b+a) + b)<<endl;
//    }
//    else{
//        cout<<(b+c)<<endl;
//    }

    if( (c-1)>(a+b) ){
        cout<<(a+b+1+b)<<endl;
    }
    else{
        cout<<(b+c)<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0)cout<<"Positive"<<endl;
    else if(a<0&&b<0){
        if(abs(a-b)%2==0)cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    else cout<<"Zero"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;
struct edge { LL to, cost; };
 
const LL inf = 1123456789012;
std::vector<std::vector<LL>>G;
std::vector<LL>memo;
 
LL dp(LL i)
{
	if (memo[i] != -1) return memo[i];
	LL res = 0;
	for (auto v : G[i]) res = std::max(res, dp(v) + 1);
	return memo[i] = res;
}
 
int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>x(M), y(M);
	rep(i, M) in >> x[i] >> y[i];
 
	G.resize(N + 1);
	rep(i, M) G[x[i]].push_back(y[i]);
 
	memo.resize(N + 1, -1);
	LL ans = 0;
	for (LL i = 1; i <= N; ++i) ans = std::max(ans, dp(i));
	out << ans << std::endl;
}

Measured memory_bytes: 10112
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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 main() {
    input! {
        H: usize,
        W: usize,
        K: usize,
    }
    let MOD = 1_000_000_007;
    let mut dp = vec![vec![0i64; 10]; 110];
    dp[0][0] = 1;
    for h in 0..H {
        for i in 0..(1 << (W - 1)) {
            if !is_ok(i) {
                //dbg!(format!("{:b}", i));
                continue;
            }
            for w in 0..W {
                if w + 1 <= W - 1 && (1 << w) & i != 0 {
                    dp[h + 1][w] += dp[h][w + 1] % MOD;
                } else if w >= 1 && (1 << (w - 1)) & i != 0 {
                    dp[h + 1][w] += dp[h][w - 1] % MOD;
                } else {
                    dp[h + 1][w] += dp[h][w] % MOD;
                }
            }
        }
    }
    println!("{}", dp[H][K - 1] % MOD);
}

fn is_ok(x: usize) -> bool {
    for w in format!("{:b}", x).chars().collect::<Vec<_>>().windows(2) {
        if w[0] == '1' && w[0] == w[1] {
            return false;
        }
    }
    true
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
      Scanner l = new Scanner(System.in);
      int length = l.nextInt();
      String word = l.next();
      
      if(word.length() > length){
          String newS = word.substring(0, length);
          System.out.println(newS+"...");
        }
        else{
            System.out.println(word);
        }
}
}


Measured memory_bytes: 38520
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = 0;
        String s = "red";
        a = Integer.parseInt(sc.nextLine());
        if(a >= 3200){
            s = sc.nextLine();
        }
        System.out.println(s);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll k; cin >> k;
    V<vvll> dp(s.size() + 1, vvll(k + 1, vll(2, 0)));
    dp[0][0][1] = 1;
    for (ll i = 0; i < s.size(); i++) {
        for (ll j = 0; j < 10; j++) {
            if (j < s[i] - '0') {  // less than
                if (j == 0) {
                    for (ll tk = 0; tk < k + 1; tk++) dp[i + 1][tk][0] += dp[i][tk][0] + dp[i][tk][1];
                } else {
                    for (ll tk = 1; tk < k + 1; tk++) dp[i + 1][tk][0] += dp[i][tk - 1][0] + dp[i][tk - 1][1];
                }
            } else if (j == s[i] - '0') {
                if (j == 0) {
                    for (ll tk = 0; tk < k + 1; tk++) {
                        dp[i + 1][tk][1] += dp[i][tk][1];
                        dp[i + 1][tk][0] += dp[i][tk][0];
                    }
                } else {
                    for (ll tk = 1; tk < k + 1; tk++) {
                        dp[i + 1][tk][1] += dp[i][tk - 1][1];
                        dp[i + 1][tk][0] += dp[i][tk - 1][0];
                    }
                }
            } else {
                if (j == 0) {
                    for (ll tk = 0; tk < k + 1; tk++) dp[i + 1][tk][0] += dp[i][tk][0];
                } else {
                    for (ll tk = 1; tk < k + 1; tk++) dp[i + 1][tk][0] += dp[i][tk - 1][0];
                }
            }
        }
    }

    cout << dp[s.size()][k][0] + dp[s.size()][k][1] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if(A+B>C+D)cout<<"Left"<<endl;
  else if(A+B==C+D)cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
}

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

int main() {
  lint X, N;
  cin >> X >> N;

  vector<lint> p(N);
  for(auto& elem : p) cin >> elem;
  set<lint> st(p.begin(), p.end());

  lint ans = 1e18;
  for(lint x=-200; x<=200; x++) {
    if(st.count(x)) continue;
    if(abs(x - X) < abs(ans - X)) ans = x;
  }

  if(ans == 1e18) ans = X;
  cout << ans << endl;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return map(int, input().split())
N, M = inpl()
G = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = inpl()
    G[a].append(b)
    G[b].append(a)

visited = [False] * (N+1)
color = [0] * (N+1)

Q = deque()
Q.append(1)

bipartite = True
while Q:
    p = Q.popleft()
    if visited[p]:
        continue
    visited[p] = True
    for q in G[p]:
        if visited[q]:
            if color[p] == color[q]:
                bipartite = False
                break
        else:
            color[q] = color[p]^1
            Q.append(q)

if bipartite:
    B = sum(color)
    W = N - B
    print(B*W-M)
else:
    print(N*(N-1)//2 - M)

Measured memory_bytes: 23292
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define MOD 1000000007

int32_t main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(((double)d/(double)s) <= t)
      cout << "Yes";
    else
      cout << "No";
}

Measured memory_bytes: 3636
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define		 endl			"\n"


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



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



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}






int main()
{
 fast;
    ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll>v;
  v.pb(a*c);
  v.pb(a*d);
  v.pb(b*c);
  v.pb(b*d);
  sort(v.begin(),v.end());
  cout<<v[v.size()-1]<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    string s;
    map<string, int> count;
    int cmax = 0;
    for(int i = 0; i < n; ++i) {
        cin >> s;
        count[s]++;
        cmax = max(cmax, count[s]);
    }
    for(pair<string, int> p: count) {
        if(p.second == cmax) cout << p.first << "\n";
    }

    return 0;
}

Measured memory_bytes: 19272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println(48 - in.nextInt());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import sys
import itertools

def main():
    n, k = [int(i) for i in sys.stdin.readline().strip().split()]
    max_k = (n-1) * (n-2) // 2
    if max_k < k:
        print('-1')
        return
    
    pairs = [(1, i) for i in range(2, n+1)]
    l = max_k
    for c in itertools.combinations(list(range(2, n+1)), 2):
        if l == k:
            break
        pairs.append(c)
        l -= 1
    print(len(pairs))
    for p in pairs:
        print(p[0], p[1])
    return


main()

Measured memory_bytes: 3992
#include <stdio.h>
#include <ctype.h>
int main(void)
{
	char ch,chp;
	while(1){
	    scanf("%c",&ch);
		if(ch=='\n') break;
		else if(islower(ch)){
			chp=toupper(ch);
		}
		else{
			chp=tolower(ch);
		}
		printf("%c",chp);
	}
	printf("\n");
    return 0;
}

Measured memory_bytes: 524
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
typedef pair<ll, pair<ll, ll > > iip;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll N, A, B; cin >> N >> A >> B;
    vector<ll > d(N, 0);
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        cin >> d[i];
        if(i != 0){
            ans += min(B, (d[i]-d[i-1]) * A);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e-a <= k) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}

	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
  int n;
  cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll ans =0;
  rep(i,60){
    ll x =0;
    rep(j,n)if(a[j]>>i&1)x++;
    ll now = x*(n-x)%mod;
    rep(j,i)now =now*2%mod;
    ans+=now;
    ans%=mod;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,k,d,a[110],b[110],ans;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>d;
		for(int i=1;i<=d;i++)
		{
			cin>>a[i];
			b[a[i]]++;
		}
	}
	for(int i=1;i<=n;i++)
	if(b[i]==0)ans++;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int dp[1010][210];
int land[210][210];
int sea[210][210];
int Z[1005];
int N,M,x,y,t,R;
char sl;
int main () {
	
	cin >> N >> M;
	while (N) {
		for (int i = 0; i < 1010; i++) {
			for (int j = 0; j < 201; j++) {
				dp[i][j] = 300000000;
				if (i > 201) continue;
				land[i][j] = 10000000;
				sea[i][j] = 10000000;
				if (i == j) {
					land[i][j] = 0;
					sea[i][j] = 0;
				}
			}
		}
		for (int m = 0; m < M; m++) {
			cin >> x >> y >> t >> sl;
			if (sl == 'L') {
				land[x][y] = min(land[x][y], t);
				land[y][x] = min(land[y][x], t);
			} else {
				sea[x][y] = min(sea[x][y], t);
				sea[y][x] = min(sea[y][x], t);
			}
		}
		for (int k = 1; k <= N; k++) {
			for (int i = 1; i <= N; i++) {
				for (int j = 1; j <= N; j ++) {
					sea[i][j] = min(sea[i][j], sea[i][k] + sea[k][j]);
					land[i][j] = min(land[i][j], land[i][k] + land[k][j]);
				}
			}
		}
		cin >> R;
		for(int r = 0; r < R; r++) cin >> Z[r];
		dp[0][Z[0]] = 0;
		
		for (int i = 0 ; i < R - 1; i++) {
			for (int n = 1; n <= N; n++) {
				for (int n2 = 1; n2 <= N; n2++) {
					dp[i + 1][n2] = min(dp[i + 1][n2], dp[i][n] + land[Z[i]][n] + sea[n][n2] + land[n2][Z[i + 1]]);
					if(n == n2) dp[i + 1][n] = min(dp[i + 1][n], dp[i][n] + land[Z[i]][Z[i + 1]]);
				}
			}
		}
		int ans = 10000000;
		for (int n = 1; n <= N; n++) {
			ans = min(ans, dp[R - 1][n]);
		}
		cout << ans << endl;
		cin >> N >> M;
	}
}
				
			
		
		
	


Measured memory_bytes: 4252
fn solve(aa: Vec<usize>) -> Vec<usize> {
    let n = aa.len();

    let mut cc = vec![0; n + 1];
    for a in aa {
        cc[a] += 1;
    }

    let mut dd = vec![0; n + 1];
    for c in cc {
        dd[c] += 1;
    }

    let mut d_acc = dd.iter().skip(1).fold(0, |sum, i| sum + i);
    let mut kd_sum = 0;
    let mut ff = vec![0; n + 1];
    for i in (1..(n + 1)) {
        d_acc -= dd[i];
        kd_sum += i * dd[i];
        ff[i] = (kd_sum + i * d_acc) / i;
    }

    let mut ans = vec![0; n + 1];
    for (i, f) in ff.iter().enumerate().rev() {
        for j in (0..(f + 1)).rev() {
            if ans[j] > 0 {
                break;
            }
            ans[j] = i;
        }
    }

    ans[1..].to_vec()
}

#[test]
fn test_solve() {
    assert_eq!(solve(vec![2, 1, 2]), vec![3, 1, 0]);
    assert_eq!(solve(vec![1, 2, 3, 4, 5]), vec![5, 2, 1, 1, 1]);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let aa = parse_vec!(usize);
    for ans in solve(aa) {
        println!("{}", ans);
    }
}


Measured memory_bytes: 20208
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    string s;
    int ans = 0;
    cin >> s;
    int sz = s.size();
    for(int i=1;i<s.size();i++){
        for(int j=0;j<sz;j++){
            string l = s.substr(j,i);
            for(int k=0;k<l.size();k++){
                if(!(l[k] == 'A' || l[k] == 'C' || l[k] == 'G' || l[k] == 'T')) break;
                if(k == l.size()-1){
                    if(ans < l.size()){
                        ans = l.size();
                    }
                }
            }
        }
        sz--;
    }
    for(int i=0;i<s.size();i++){
        if(!(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')) break;
        if(i == s.size()-1){
            if(ans < s.size()){
                ans = s.size();
            }
        }
    }
    cout << ans << endl;
}

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

int main(){

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }

    int flg = 1;

    for (int i=0; i<N; i++){
        if ((A.at(i))%2 == 0){
            if ((A.at(i))%3 == 0){
                flg = 1;
            }
            else if ((A.at(i))%5 == 0){
                flg = 1;
            }
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    if (flg == 1){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = list(map(lambda x: min(int(x), k+1), input().split()))
a.sort()
mask = (1<<(k+1)) - 1
def sub(ii):
    dp = 1
    for i in range(n):
        if i==ii:
            continue
        dp |= (dp<<a[i]) & mask
#         for j in range(k-1, a[i]-1, -1):
#             dp[j] += dp[j-a[i]]
    val = max(i for i in range(k) if (dp>>i)&1)
    return val+a[ii]>=k
if sub(0):
    ans = 0
elif not sub(n-1):
    ans = n
else:
    l = 0
    r = n-1
    while l<r-1:
        m = (l+r)//2
        if sub(m):
            r = m
        else:
            l = m
    ans = l+1
print(ans)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int N, K, i;
  int h[100010];
  int ans = 0;

  cin >> N >> K;

  REP(i, N){
    cin >> h[i];
  }

  REP(i, N){
    if( h[i] >= K ){
      ans++;
    }
  }

  cout << ans << endl;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	long n;
	cin >> n;
	long a[150000];
	for (long i = 0; i < n; i++) {
		cin >> a[i];
	}
	int big = a[0], small = a[0];
	for (long k = 0; k < n; k++) {
		if (a[k] > big) {
			big = a[k];
		}
		else if (a[k] < small) {
			small = a[k];
		}
	}
	long s;
	for (long k = 0; k < n; k++) {
		s += a[k];
	}
	cout << small <<" "<< big <<" "<<s<< endl;
}

Measured memory_bytes: 1248
// Cursor jump numbers
// main @ 39
// global @ 35
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int l;
  cin >> l;
  cout << fixed << setprecision(12) << ((double)(l*l*l)) / 27 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<hash_map>
#include<algorithm>
using namespace std;
using namespace __gnu_cxx;
int main()
{
    int n;
    cin>>n;
    hash_map<int,int>mp;
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        int x;
        cin>>x;
        hash_map<int,int>::iterator it;
        it=mp.find(x);
        if(it!=mp.end())
        {
            mp[x]++;
        }
        else
        {
            mp[x]=1;
        }
    }
    /*map<int,int>::iterator iter;
    iter=mp.begin();
    int cnt=0;
    while(iter!=mp.end())
    {
        if((iter->second)==1)
            ++cnt;
        ++iter;
    }*/
    hash_map<int,int>::iterator it;
    it=mp.begin();
    while(it!=mp.end())
    {
        if((it->second)%2!=0)
            ++cnt;
        ++it;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 5560
import sys
sys.setrecursionlimit(10**8)

def add_edge(frm,to):
    g[frm].append(to)
    rg[to].append(frm)

def dfs(now,used,back_track):
    used[now]=True
    for nx in g[now]:
        if not used[nx]:dfs(nx,used,back_track)
    back_track.append(now)

def rdfs(now,num_cmp,used,cmp):
    used[now]=True
    cmp[now]=num_cmp
    for nx in rg[now]:
        if not used[nx]:rdfs(nx,num_cmp,used,cmp)

def scc(n):
    used=[False]*n
    back_track=[]
    cmp=[-1]*n
    for v in xrange(n):
        if not used[v]:dfs(v,used,back_track)
    used=[False]*n
    num_cmp=0
    for v in back_track[::-1]:
        if not used[v]:
            rdfs(v,num_cmp,used,cmp)
            num_cmp+=1
    return num_cmp,cmp

n,m=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
rg=[[] for _ in xrange(n)]

for i in xrange(m):
    s,t=map(int,raw_input().split())
    add_edge(s,t)

num,cmp=scc(n)
q=int(raw_input())
for i in xrange(q):
    u,v=map(int,raw_input().split())
    if cmp[u]==cmp[v]:
        print(1)
    else:
        print(0)

Measured memory_bytes: 18328
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>


using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> xs(n);

    li negs = 0;
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
        if (xs[i] < 0) {
            negs += 1;
        }
    }

    li to_negate = max(min(negs, n - 1), 1LL);
    sort(xs.begin(), xs.end());

    if (to_negate == n - 1) {
        li acc = xs[to_negate];
        vector<li> lh, rh;
        for (int i = 0; i < n - 1; ++i) {
            lh.push_back(acc);
            rh.push_back(xs[i]);
            acc -= xs[i];
        }
        cout << acc << endl;
        for (int i = 0; i < n - 1; ++i) {
            cout << lh[i] << " " << rh[i] << endl;
        }
    } else {
        li ans = 0;
        for (int i = 0; i < n; ++i) {
            if (i < to_negate) {
                ans -= xs[i];
            } else {
                ans += xs[i];
            }
        }
        cout << ans << endl;
        li neg_group = xs[n - 1];
        for (int i = 0; i < to_negate - 1; ++i) {
            cout << neg_group << " " << xs[i] << endl;
            neg_group -= xs[i];
        }
        li pos_group = xs[to_negate - 1];
        for (int i = to_negate; i < n - 1; ++i) {
            cout << pos_group << " " << xs[i] << endl;
            pos_group -= xs[i];
        }
        cout << neg_group << " " << pos_group << endl;
    }
    return 0;
}


Measured memory_bytes: 4460
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vi pc(n);
  vi cable(n);
  for(int i=0;i<n;i++)cin>>pc[i];
  for(int j=0;j<n;j++)cin>>cable[j];
  ll ans=1;
  sort(ALL(pc));
  sort(ALL(cable));
  int pccnt=0;
  int cacnt=0;
  vi p;vi c;
  while(pccnt!=n||cacnt!=n){
    if(pccnt==n){
      if(p.size()>0){
	ans*=p.size();
	p.pop_back();
	cacnt++;
      }
    }else if(cacnt==n){
      if(c.size()>0){
	ans*=c.size();
	c.pop_back();
	pccnt++;
      }
    }else{
      if(pc[pccnt]>cable[cacnt]){
	if(p.size()>0){
	  ans*=p.size();
	  p.pop_back();
	}else{
	  c.pb(1);
	}
	cacnt++;
      }else{
	if(c.size()>0){
	  ans*=c.size();
	  c.pop_back();
	}else{
	  p.pb(1);
	}
	pccnt++;
      }
    }
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int D; //365
    cin >> D;

    int c[26];
    rep(i, 0, 26) {
        cin >> c[i];
    }

    int s[D][26];
    rep(i, 0, D) {
        rep(j, 0, 26) {
            cin >> s[i][j];
        }
    }

    int t[D] = {};
    rep(i, 0, D) {
        srand(time(NULL));
        t[i] = rand() % 26;
    }

    ll mx_score = -1;
    int cnt = 10000;
    while (cnt--) {
        srand(time(NULL));
        int d = rand() % 365;
        int q = rand() % 26;
        int old = t[d];
        t[d] = q;

        ll score[D] = {};
        vector<int> last_day(26, -1);
        rep(i, 0, D) {
            if (i != 0) score[i] = score[i - 1];
            score[i] += s[i][t[i]];
            last_day[t[i]] = i;
            int decrease = 0;
            rep(j, 0, 26) {
                decrease += c[j] * (i - last_day[j]);
            }
            score[i] -= decrease;
        }
        if (mx_score > score[D - 1]) {
            t[d] = old;
        } else {
            mx_score = score[D - 1];
        }
    }

    rep(i, 0, D) cout << t[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

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

  vector<vector<ll>> dp(N + 1, vector<ll>(A * N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < (int)N; ++i) for (int j = N; j >= 0; --j) for (int k = A * N; k >= 0; --k) {
    if (j + 1 <= N && k + x[i] <= A * N) dp[j + 1][k + x[i]] += dp[j][k];
  }

  ll ans = 0;
  for (int n = 1; n <= N; ++n) ans += dp[n][n * A];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if((C>A && B>C) || (A>C && C>B)){
           System.out.println("Yes"); 
        }else{
            System.out.println("No");
        }
    }
}


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

int main() {

    string s, t; cin >> s >> t;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    int index=- 1;
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        bool can = true;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] == '?') continue;
            if (s[i + j] != t[j]) can = false;
        }
        if (can) {
            index = i;
            break;
        }
    }
    if (index != -1) {
        for (int j = 0; j < t.size(); j++) {
            s[index + j] = t[j];
        }
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '?') s[i] = 'a';
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    else {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,ll> iil;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

vvi G(100005);
ll n,k;
int visited[100005] = {0};
ll dp[100005] = {0};
int depth[100005] = {0};

ll dfs(int u, int p)
{
	visited[u] = 1;
	if(depth[u] == 1)
	{
		dp[u] = (dp[u]*(max(p-1,0)))%mod;
	}
	else if(depth[u] >= 2)
	{
		dp[u] = (dp[u]*max(p-2,0))%mod;
	}
	else
	{
		dp[u] = (dp[u]*max(0,p))%mod;
	}
	int o = k;
	for(int i=0;i<G[u].size();i++)
	{
		int v = G[u][i];
		if(visited[v] == 0)
		{
			depth[v] = depth[u] + 1;
			ll val = dfs(v,o--);
			dp[u] = (dp[u]*dp[v])%mod;
		}
	}

	return dp[u];
}

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	cin>>n>>k;
	for(int i=1;i<=n-1;i++)
	{
		ll x,y;
		cin>>x>>y;

		G[x].pb(y);
		G[y].pb(x);
	}

	for(int i=1;i<=n;i++)dp[i]=1;

	ll ans = dfs(1,k);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 12032
n = int(input())
l = []
flag = 0

for x in range(-10, 11):
    l.append(int(n // 1.08) + x)

for x in l:
    if int(x * 1.08) == n:
        flag = 1
        print(x)
        break

if flag == 0:
    print(":(")

Measured memory_bytes: 3060
import bisect
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))
As.sort()
Bs.sort()
Cs.sort()
#print(As)
#print(Bs)
#print(Cs)
NsB = []
for i in range(N):
  B = Bs[i]
  j = bisect.bisect_left(Cs, B+1)#Cs>B
  NsB.append(N-j)
#print(NsB)
CSNsB = []
r = 0
for i in reversed(range(N)):
  r += NsB[i]
  CSNsB.append(r)
CSNsB.reverse()
#print(CSNsB)
r = 0
for i in range(N):
  A = As[i]
  j = bisect.bisect_left(Bs, A+1)
  if j < N:
    r += CSNsB[j]
print(r)


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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

LL n,i;

cin>>n;

vector <LL> v(n),u(n);

map <LL,LL> pos;

for(i=0;i<n;i++)
	{
	cin>>v[i];	
	u[i] = v[i];
	}

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

for(i=0;i<n;i++)
	pos[v[i]] = i;

LL ans = 0;

for(i=0;i<n;i++)
	{
	if((pos[u[i]]%2) != (i%2))
		ans++;
	}
	

ans /= 2;

cout<<ans<<endl;
}

Measured memory_bytes: 8064
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))
num = 10**9
for i in range(n):
    c = t - h[i]*0.006
    if abs(c-a) < num:
        num = abs(c-a)
        j = i
print(j+1)

Measured memory_bytes: 9204
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstring>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
int main(){
	int x,y;cin >> x >> y;
	if(x * 2 <= y && y <= x * 4 && y % 2 == 0) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
 #define int long long    // %d=>%lld
#define pb push_back
#define INF (1e9+7)
#define llINF 1e17
#define EPS 1e-9
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

const int MAX_n = 100000;
int n,a[MAX_n* 3];

int sum_b_tmp, sum_s_tmp;
int sum_big[MAX_n+1], sum_small[MAX_n+1],ans=-llINF;

signed main(){

    cin >> n;
    for(int i = 0;i < 3* n;i++){
        cin >> a[i];
    }

    priority_queue<int,vector<int>,greater<int>> big_que;
    priority_queue<int> small_que;

    for(int i = 0;i < n;i++){
        big_que.push(a[i]);
        sum_b_tmp+=a[i];

        small_que.push(a[2*n+i]);
        sum_s_tmp+=a[2*n+i];
    }

    sum_big[0]=sum_b_tmp;
    sum_small[n]=sum_s_tmp;

    for(int i = 0;i < n;i++){
        big_que.push(a[n+i]);
        sum_b_tmp+=a[n+i];
        sum_b_tmp-= big_que.top();
        sum_big[1+i]=sum_b_tmp;
        big_que.pop();

        small_que.push(a[2*n-1-i]);
        sum_s_tmp+=a[2*n-1-i];
        sum_s_tmp-=small_que.top();
        sum_small[n-1-i]=sum_s_tmp;
        small_que.pop();
    }

    for(int i = 0;i < n+1;i++){
        ans=max(ans,sum_big[i]-sum_small[i]);
    }

    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 5996
# ただの典型いもす

n, m = map(int, input().split())
arr = [0 for _ in range(n+1)]
for _ in range(m):
    l, r = map(int, input().split())
    arr[l - 1] += 1
    arr[r] -= 1

for i in range(1, n):
    arr[i] += arr[i - 1]

count = 0
for i in range(n):
    if arr[i] == m:
        count += 1

print(count)


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

using namespace std;

long long x,y;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> x >> y;
	
	if(x<y){
		swap(x,y);
	}
	
	if((x-y)%3==0){
		if(x-y==0){
			cout << "Brown" << endl;
		}
		else{
			cout << "Alice" << endl;
		}
	}
	else if((x-y)%3==1){
		if(x-y==1){
			cout << "Brown" << endl;
		}
		else{
			cout << "Alice" << endl;
		}
	}
	else{
		cout << "Alice" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
	int N;
	cin >> N;

	vector<int> a(N);
	rep(i, N) cin >> a.at(i);
	int cnt = 0;
	rep(i, N){
		if (a.at(a.at(i) - 1) == i + 1) cnt++;
	}
	cout << cnt / 2 << endl;
}

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

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


// Write From This Line
int main()
{
	long long n;
	cin >> n;
	ll ans = (n) * (n+1) / 2 ;
	rep(i,n+1){
		if(i % 3 == 0 || i % 5 == 0){
			ans -= i;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 3636
n,m=map(int,input().split())
a=[[int(i) for i in input().split()]for i in range(m)]
b=[False]*n
for i in a:
    if i[1]==n:
        b[i[0]-1]=True
for i in a:
    if i[0]==1 and b[i[1]-1]==True :
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 42252
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
int main(void){
  int n,k;
  cin>>n>>k;
  int r,s,p;
  cin>>r>>s>>p;
  vi scores = vi(3,0);
  scores[0]=p;
  scores[1]=r;
  scores[2]=s;
  string t;
  cin>>t;
  vll dp =vll(k,vl(n/k+100,-1));
  rep(i,n){
    int tmp;
    if(t[i]=='r'){
      tmp=0;
    }else if(t[i]=='s'){
      tmp=1;
    }else{
      tmp=2;
    }
    ll premax=0;
    dp[i%k][i/k]=tmp;
  }
  ll ans=0;
  rep(i,k){
    vl tmps;
    int size=0;
    for(int j=0;dp[i][j]!=-1;j++){
      size++;
      tmps.pb(dp[i][j]);
    }
    vll dp2=vll(3,vl(size+1,0));
    rep(k,size){
      rep(j,3){
        if(j==tmps[k]){
          dp2[j][k+1]=max(dp2[(j+1)%3][k],dp2[(j+2)%3][k])+scores[tmps[k]];
        }else{
          dp2[j][k+1]=max(dp2[(j+1)%3][k],dp2[(j+2)%3][k]);
        }
      }
    }
    ll tmpans=0;
    rep(j,3){
      tmpans=max(tmpans,dp2[j][size]);
    }
    ans+=tmpans;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 72704
def calc(a, op, b):
    if op == '+':
        return(a + b)
    if op == '-':
        return(a - b)
    if op == '*':
        return(a * b)
    if op == '/':
        return(a / b)
while True:
    a, op, b = raw_input().split()
    if op == '?':
        break
    print(calc(int(a), op, int(b)))

Measured memory_bytes: 4212