akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    priority_queue<pair<ll, int>> order;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        order.push(make_pair(a[i] + b[i], i));
    }
    ll ans = 0;
    int i = 0;
    while (!order.empty()) {
        int idx = order.top().second;
        order.pop();
        if (i % 2 == 0) {
            ans += a[idx];
        } else {
            ans -= b[idx];
        }
        ++i;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n; cin >> n; vll t(n); rep(i, n) cin >> t[i]; ll m; cin >> m; vll p(m), x(m); rep(i, m) cin >> p[i] >> x[i];
  ll ans = accumulate(all(t), 0);
  for(ll i = 0;i < m;i++)
  {
    fin(ans - t[p[i]-1] + x[i])
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

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

	vector<ll> A(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<int>());

	ll comfort = A[0];
	int i = 2;
	int j = 1;
	while (i < N) {
		for (int k = 0; k < 2; k++) {
			if (i < N) {
				comfort += A[j];
				i++;
			} else {
				break;
			}
		}
		j++;
	}

	cout << comfort << endl;

	return 0;
}

Measured memory_bytes: 4796
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E=1e18+7;
const ll MOD=1000000007;
#define IOS cin.tie(0); ios::sync_with_stdio(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class... A> void prints()      { cout << endl; }
template<class... A> void prints_rest() { cout << endl; }
template<class T, class... A> void prints_rest(const T& first, const A&... rest) { cout << " " << first; prints_rest(rest...); }
template<class T, class... A> void prints(const T& first, const A&... rest)      { cout << first; prints_rest(rest...); }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
int main() {
    int n,x; cin >> n >> x;
    int L[n];
    int d = 0;
    rep(i,n) {
        cin >> L[i];
        d += L[i];
        if (d > x) { prints(i+1); return 0; }
    }
    prints(n+1);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ans = new int[1000];
            int count = 0;
            string str=Console.ReadLine();
            do
            {
                int n = int.Parse(str);
                int a, b, c, d;
                ans[count]=0;
                for (a = 0; a < 10; a++)
                {
                    for (b = 0; b < 10; b++)
                    {
                        for (c = 0; c < 10; c++)
                        {
                            for (d = 0; d < 10; d++)
                            {
                                if (a + b + c + d == n)
                                {
                                    ans[count]++;
                                }
                            }
                        }
                    }
                }
                count++;
                str = Console.ReadLine();
            } while (string.IsNullOrEmpty(str) == false);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(ans[n]);
            }
        }
    }
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int M, K;
    cin >> M >> K;
    if (M == 1) {
        if (K == 0) {
            cout << "0 0 1 1" << endl;
            return 0;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (M == 0) {
        if (K == 0) {
            cout << "0 0" << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    int p = 1;
    rep(i, M) {
        p *= 2;
    }
    if (K >= p) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = p - 1; i >= 0; --i) {
        if (i == K)continue;
        cout << i << " ";
    }
    cout << K;
    for (int i = 0; i < p; ++i) {
        if (i == K)continue;
        cout << " " << i;
    }
    cout << " " << K << endl;
    cout << endl;
    return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 1000000007;
const ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    if(k > abs(x)/d)
    {
        x = abs(x);
        if(k%2 == 0)
        {
            cout << min(x%(2*d), 2*d-x%(2*d));
        }
        else
        {
            x += d;
            cout << min(x%(2*d), 2*d-x%(2*d));
        }
    }
    else
    {
        cout << min(abs(x+k*d), abs(x-k*d));
    }
    return 0;
}


Measured memory_bytes: 3648
from collections import Counter
import math

n = int(input())
aa = list(map(int, input().split()))

ctr = Counter(aa)

cmb2 = [0] * 200001
for n in range(2, 200001):
    r = 2
    num = 1
    for i in range(1, r + 1):
        num = num * (n - i + 1) // i
    cmb2[n] = num

x = 0
for k, v in ctr.items():
    x += cmb2[v]

for a in aa:
    k = ctr[a] - 1
    print(x - k)

Measured memory_bytes: 26856
s = input()
n = len(s)

s = list(map(int, list(s)))
dp1 = [0] * (n + 1)
dp2 = [0] * (n + 1)
dp2[0] = 1

for k in range(n):
    dp1[k + 1] = min([dp1[k] + s[k]       , dp2[k] + 10 - s[k]])
    dp2[k + 1] = min([dp1[k] + s[k] + 1, dp2[k] + 10 - s[k] - 1])

print(dp1[-1])

Measured memory_bytes: 89908
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef vector <int> lnum;
typedef pair <int, int> pii;

const int N = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int m, k;
  cin >> m >> k;
  if (k == 0) {
    for (int i = 0; i < (1 << m); ++i)
      cout << i << " " << i << " ";
    return 0;
  }
  if (k > (1 << m) - 1 || (m == 1 && k == 1)) {
    cout << -1;
    return 0;
  }
  cout << 0 << " " << k << " " << 0 << " ";
  for (int i = 1; i < (1 << m); ++i) {
    if (i != k)
      cout << i << " ";
  }
  cout << k << " ";
  for (int i = (1 << m) - 1; i >= 1; i--) {
    if (i != k)
      cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
const int maxn = 101;
const int maxw = 100001;
const int inf = 1000000001;
ll dp[maxw];
int n, lim;
					
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> lim;
	fill(dp + 1, dp + maxw, inf);	
	for(int w, v, i = 0;i < n;++i){
		cin >> w >> v;
		for(int j = maxw-1;j >= v;--j)dp[j] = min(dp[j], dp[j-v] + w);
	}
	for(int i = maxw-1;i >= 0;--i)if(dp[i] <= lim)return cout << i << '\n', 0;

}

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

int main() {
  // Not so Diverse
  int n, k; cin >> n >> k;
  int ans = 0;
  map<int,int> m;
  rep(i,n) {
    int ai; cin >> ai;
    m[ai]++;
  }
  priority_queue<P> pq;
  for (auto mi : m) {
    pq.push(make_pair(mi.second, mi.first));
  }
  int cnt = 0, sum = 0;
  while (!pq.empty() && cnt < k) {
    sum += pq.top().first; pq.pop();
    cnt++;
  }
  cout << n - sum << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  map<int, int> m;
  REP(i, N) m[A[i]]++;
  int res = 0;
  for(auto x : m) {
    if(x.second % 2 == 0) res++;
  }
  if(res % 2 == 0) cout << m.size() << endl;
  else cout << m.size() - 1 << endl;
}

Measured memory_bytes: 8104
n=int(input())
c = [[0]*10 for i in range(10)]
n_len = len(str(n))
for k in range(1,n+1):
  k_str = str(k)
  l,r=int(k_str[0]),int(k_str[-1])
  c[l][r]+=1

cnt = 0
for i in range(10):
  for j in range(10):
    cnt += c[i][j]*c[j][i]
print(cnt)

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

long long l, t[100];
long long gcd(int n) {
  long long a, b, temp;
  a = t[n];
  b = l;
  while (b != 0) {
    temp = a % b;
    a = b;
    b = temp;
  }
  return a;
}
int lcm(int n) {
  l = t[n - 1];
  for (int i = n - 1; i >= 0; --i) {
    l = (l / gcd(i)) * t[i];
  }
}
int main() {
  int n;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  lcm(n);
  cout << l << endl;
}

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

vector<int> v[1000];


vector<int> nxt(1000, -1);
int dfs(int i, int parent=-1) {
	if (nxt[i] >= 0) return i; // found loop
	for(int j: v[i]) {
		if (j == parent) continue;
		nxt[i] = j;
		int res = dfs(j, i);
		if (res >= 0) return res;
	}
	nxt[i] = -1;
	return -1;
}

vector<int> level(1000, -1);

int shortest(int s) {
	level[s] = 0;
	for(int i = nxt[s], l = 1; i != s; i = nxt[i], l++) {
		level[i] = l;
	}
	for(int i = s;; i = nxt[i]) {
		pair<int, int> mn(-1, i), mx = mn;
		for(int j: v[i]) {
			if (level[j] < 0) continue;
			if (level[j] < level[i]) {
				if (level[j] > mn.first) mn = {level[j], j};
			} else {
				if (level[j] > mx.first) mx = {level[j], j};
			}
		}
		if (mn.first >= 0) {
			for(int j = nxt[i]; j != mn.second; j = nxt[j]) {
				level[j] = -1;
			}
			nxt[i] = mn.second;
			return i;
		}
		for(int j = nxt[i]; j != mx.second; j = nxt[j]) {
			level[j] = -1;
		}
		nxt[i] = mx.second;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		v[a-1].push_back(b-1);
	}
	int s = -1;
	rep(i, n) {
		s = dfs(i);
		if (s >= 0) break;
	}
	if (s == -1) {
		cout << -1 << endl;
		return 0;
	}
	shortest(s);
	int cnt = 0;
	rep(i, n) if (level[i] >= 0) cnt += 1;
	cout << cnt << endl;
	rep(i, n) if (level[i] >= 0) cout << i + 1 << endl;
}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// 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 solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        n: usize,
        xyh: [(i64, i64, i64); n],
    }
    let mut x = -1;
    let mut y = -1;
    let mut h = -1;
    for &(xx, yy, hh) in xyh.iter() {
        if hh > 0 {
            x = xx;
            y = yy;
            h = hh;
            break;
        }
    }
    for cx in 0 .. 101 {
        for cy in 0 .. 101 {
            let ch = h + (x - cx).abs() + (y - cy).abs();
            let mut ok = xyh.iter().all(
                |&(xx, yy, hh)|
                hh == max(ch - (xx - cx).abs() - (yy - cy).abs(), 0)
            );
            if ok {
                puts!("{} {} {}\n", cx, cy, ch);
                return;
            }
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n, k;
	cin>>n>>k;
	if(n%2==0){
		if(k>n/2){
			cout<<-1<<endl;
			return 0;
		}
		for(int i=0; i<n/2; i++){
			cout<<k+n/2-1-i<<" "<<k+n+2*i<<" "<<k+2*n+i<<endl;
		}
		for(int i=0; i<n/2; i++){
			cout<<k+n-1-i<<" "<<k+n+1+2*i<<" "<<k+2*n+n/2+i<<endl;
		}
	}else{
		if(k>(n+1)/2){
			cout<<-1<<endl;
			return 0;
		}
		for(int i=0; i<n/2; i++){
			cout<<k+n/2-1-i<<" "<<k+n+1+2*i<<" "<<k+2*n+i<<endl;
		}
		for(int i=0; i<n/2+1; i++){
			cout<<k+n-1-i<<" "<<k+n+2*i<<" "<<k+2*n+n/2+i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            MyInputStream cin = new MyInputStream();

            var a = cin.ReadLong();
            var b = cin.ReadLong();
            var x = cin.ReadLong();

            var ans = b / x - Max(a - 1, 0) / x;
            if (a == 0) ans++;

            WriteLine(ans);
        }
    }

    public static class MyExtensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(100);
    vector<int> x(100);

    for(int i = 1 ; i <= N ; ++i){
        for(int j = 0 ; j < M * 2 ; ++j){
            cin >> x.at(j);
            if(i == x.at(j)) ++vec.at(i);
        }
    }
     for(int i = 1 ; i <= N ; ++i){
        cout << vec.at(i) << endl;
    } 
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	set<pair<int, int>> poss;
	cin >> N;

	REP(h, N)REP(w, N) {
		if (h % 3 != 0)continue;
		if ((h + w) % 2 == 1)poss.insert({ h,w });
	}
	REP(h, N)if (h % 2 == 1)poss.insert({ h,0 });
	REP(w, N)if ((N - 1 + w) % 2 == 1)poss.insert({ N - 1,w });

	cout << poss.size() << endl;
	for (auto pos : poss) {
		cout << pos.second << " " << pos.first << endl;
	}

	return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  int a, b;
  pair<long long, long long>enegy[100005];
  long long ans = 0;
  int cnt = 0;
  cin >> n >> m;

  for(int i = 0;i < n;i++){
    cin >> a >> b;
    enegy[i] = make_pair(a, b);
  }

  sort(enegy, enegy + n);

  for(int i = 0;i < n && cnt < m;i++){
    if(enegy[i].second + cnt > m){
      ans += (m - cnt) * enegy[i].first;
    }else{
      ans += enegy[i].second * enegy[i].first;
    }
    cnt += enegy[i].second;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())

ans = [[K+i] for i in range(N)]

m = (N+1)//2
n = K+N
for i in range(m,N):
    ans[i].append(n)
    n += 1
for i in range(m):
    ans[i].append(n)
    n += 1

ans.sort(key=lambda x: x[0]+x[1])
for i in range(N):
    if sum(ans[i]) > n:
        print(-1)
        exit()
    ans[i].append(n)
    n += 1

for row in ans:
    print(*row)

Measured memory_bytes: 26652
#include <stdio.h>
unsigned long long mi(unsigned long long a, unsigned long long b){
	return a < b ? a: b;
}
int main(){
	unsigned long long int bars[200005], sum[200005], min;
	int n;
	scanf("%d", &n);
	//scanf("%llu", &bars[1]);
	sum[0] = 0;
	//sum[1] = bars[1];
	for(int i = 1; i <= n; ++i){
		scanf("%llu", &bars[i]);
		sum[i] = sum[i-1] + bars[i];
		//printf("%llu ", sum[i]);
	}
	min = sum[n];
	unsigned long long u, dif, j;
	for(int i = 1; i < n; ++i){
		j = sum[i];//<-
		u = sum[n] > j ? sum[n] - j : j - sum[n]; //positive//->
		dif = u > j ? u - j: j - u;//positive
		//printf("%d %llu %llu %llu\n", i, u, j, dif);
		min = mi(min, dif);
	}
	printf("%llu\n", min);
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[3005][3005];
ll sum[3005];

int main() {
	int n; cin >> n;
	string s; cin >> s;
	s = "@@" + s;
	for (int i = 0; i < n; i++) dp[1][i] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= n; j++) sum[j] = ((j > 0 ? sum[j - 1] : 0) + dp[i - 1][j])%mod;
		if (s[i] == '<') for (int j = 0; j <= n - i; j++) dp[i][j] = (sum[n] - sum[j] + mod)%mod;
		else for (int j = 0; j <= n - i; j++) dp[i][j] = sum[j];
	}
	cout << dp[n][0] << endl;
	return 0;
}

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

namespace AOJ.Volume1
{
    public class BookIndex
    {
        public static void Main()
        {
            var index = new Dictionary<string, List<int>>();
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var line = input.Split(' ');
                if (index.ContainsKey(line[0])) { index[line[0]].Add(int.Parse(line[1])); }
                else { index.Add(line[0], new List<int> { int.Parse(line[1]) }); }
            }

            foreach (var i in index.OrderBy(x => x.Key))
            {
                Console.WriteLine(i.Key);
                string pages = "";
                foreach (var p in i.Value.OrderBy(x => x))
                {
                    pages += p + " ";
                }
                pages = pages.Trim();
                Console.WriteLine(pages);
            }
        }
    }
}

Measured memory_bytes: 10632
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

s = readline().rstrip().decode('utf-8')
n = len(s)
count = 0
lst1 = [0]*(n+1)
lst2 = [0]*(n+1)

for i in range(n):
	if s[i] == "<":
		lst1[i+1] = lst1[i]+1
for i in range(n-1,-1,-1):
	if s[i] == ">":
		lst2[i] = lst2[i+1]+1

ans = 0
for i in range(n+1):
	ans += max(lst1[i],lst2[i])

print(ans)

Measured memory_bytes: 27180
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=2*1e5+5;
ll ans;
char s[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	scanf("%s",s);
	int n=strlen(s); int tt=0;
	go(i,n,0){
		if(s[i] == 'W') ans+=tt;
		else tt++;
	}
	printf("%lld",ans);
	return 0;
}//Faze


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAXN 1000000
#define INF 2000000000
using namespace std;
int n,V,x[MAXN+5];
int cnt[25];
int l[25][MAXN+5],r[25][MAXN+5];
int f1[MAXN*5+5],f2[MAXN*5+5];//如思路中的定义
bool ans[MAXN+5];//ans记录的是对于某一条线段的答案，不是某个绿洲的答案
void Init()
{
	for(int i=0;i<=MAXN*5+3;i++)
		f1[i]=0,f2[i]=INF;
}
int UpFind(int id,int pos)//找l在pos+1的左边的线段，也就是能够向右扩展的最靠右的线段
{
	pos++;
	int p=upper_bound(l[id]+1,l[id]+cnt[id]+1,pos)-l[id];
	p--;
	if(p<=0)
		return pos;
	return max(r[id][p],pos-1);
}
int LowFind(int id,int pos)//找r在pos-1的右边的线段，也就是能够向左扩展的最靠左的线段
{
	pos--;
	int p=lower_bound(r[id]+1,r[id]+cnt[id]+1,pos)-r[id];
	if(p>=cnt[id]+1)
		return pos;
	return min(l[id][p],pos+1);
}
int main()
{
	Init();
	scanf("%d %d",&n,&V);
	int logV=0;
	for(logV=0;(1<<logV)<=V;logV++);//求出来的实际上是logV+1
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	x[n+1]=INF;
	x[0]=-INF;//便于操作
	for(int LG=0;LG<=logV;LG++)
	{
		int d=V/(1<<LG);
		cnt[LG]=1;
		l[LG][1]=1;
		//求线段
		for(int i=1;i<=n;i++)
		{
			r[LG][cnt[LG]]=i;
			if(x[i+1]-x[i]>d)
			{
				cnt[LG]++;
				l[LG][cnt[LG]]=i+1;
			}
		}
		cnt[LG]--;
	}
	if(cnt[0]>logV+1)//特判
	{
		for(int i=1;i<=n;i++)
			printf("Impossible\n");
		return 0;
	}
	int all=(1<<(logV+1));
	f1[0]=0,f2[0]=n+1;//预处理两个f数组
	for(int s=0;s<all;s+=2)
		for(int i=0;i<=logV;i++)
		{
			if(!(s&(1<<i)))
				continue;
			f1[s]=max(f1[s],UpFind(i,f1[s-(1<<i)]));
			f2[s]=min(f2[s],LowFind(i,f2[s-(1<<i)]));
		}
	for(int i=1;i<=cnt[0];i++)
	{
		int ln=l[0][i],rn=r[0][i];
		for(int s1=0;s1<all;s1+=2)
		{
			int s2=all-1-s1-1;
			int lpos=f1[s1];
			int rpos=f2[s2];
			if(lpos>=ln-1&&rpos<=rn+1)
			{
				ans[i]=true;
				break;
			}
		}
	}
	int pos=1;
	for(int i=1;i<=n;i++)
	{
		if(ans[pos]==true)
			printf("Possible\n");
		else
			printf("Impossible\n");
		if(x[i+1]-x[i]>V)
			pos++;
	}
	return 0;
}

Measured memory_bytes: 128384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int a[6] = {6, 36, 216, 1296, 7776, 46656}, b[5] = {9, 81, 729, 6561, 59049};  

int main() {
    ios::sync_with_stdio(false);
    int a[12] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049}, d[100005] = {};  
    int n;
    cin >> n;
    for (int i = 1 ; i <= n ; i++) d[i] = 100005;
    for (int i = 1 ; i <= n ; i++) {
    	for (int j = 0 ; j < 12 ; j++) if (i >= a[j]) d[i] = min(d[i], d[i - a[j]] + 1);
	}
	cout << d[n];
    
}

Measured memory_bytes: 4004
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	llint ans = 1;
	rep(i, n) {
		llint x;
		cin >> x;
		ans = x * ans / GCD(x, ans);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int nowmin = 10000;
  int count;
  
  for (int i = 0; i < S.length() - T.length() + 1; i++){
    count = 0;
    for (int j = 0; j < T.length(); j++){
      if (S.at(j + i) != T.at(j)){
        count++;
      }
    }
    nowmin = min(count, nowmin);
  }
  
  cout << nowmin << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdbool.h>

typedef struct Data
{
    int a;
    int b;
    int c;
} str_data;

static void Read(str_data* target);
static void Calc(str_data target, bool* response);
static void Write(bool target);
static bool RangeCheck(str_data target);

int main()
{
    str_data data;
    bool ans;

    Read(&data);

    if (!RangeCheck(data)) {
        return 1;
    }

    Calc(data, &ans);

    Write(ans);

    return 0;
}

void Read(str_data* target)
{
    scanf("%d %d %d", &target->a, &target->b, &target->c);
}

void Calc(str_data target, bool* response)
{
    bool ret = false;

    if (target.a < target.b) {
        if (target.b < target.c) {
            ret = true;
        }
    }

    *response = ret;
}

void Write(bool target)
{
    target ? printf("Yes\n") : printf("No\n");
}

bool RangeCheck(str_data target)
{
    if (target.a < 0 || target.a > 100) return false;
    if (target.b < 0 || target.b > 100) return false;
    if (target.c < 0 || target.c > 100) return false;

    return true;
}



Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1010;
bool flag = 1, vis[maxn], edge[maxn][maxn], dp[maxn][maxn];
int col[maxn], n, m, cnt[2], tot, x[maxn], y[maxn];

void dfs(int u) {
	vis[u] = 1;
	cnt[col[u]]++;
	for(int i=1; i<=n; i++)
		if(!edge[u][i]) {
			if(!vis[i]) {
				col[i] = !col[u];
				dfs(i);
				if(!flag) return;
			}
			else if(col[i] == col[u] && i != u) {
				flag = 0;
				return;
			}
		}
}

int main()
{
	scanf("%d%d", &n, &m);
	for(int i=1; i<=m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u][v] = edge[v][u] = 1;
	}
	for(int i=1; i<=n; i++)
		if(!vis[i]) {
			cnt[0] = cnt[1] = 0;
			dfs(i);
			if(!flag) {
				printf("-1\n");
				return 0;
			}
			x[++tot] = cnt[0], y[tot] = cnt[1];
		}
	dp[0][0] = 1;
	for(int i=1; i<=tot; i++)
		for(int j=0; j<=n; j++)
			if(dp[i-1][j]) dp[i][j+x[i]] = dp[i][j+y[i]] = 1;
	int ans = 1e8;
	for(int i=1; i<=n; i++)
		if(dp[tot][i]) ans = min(ans, i * (i-1) / 2 + (n-i) * (n-i-1) / 2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

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

int n, m;
int a[200000];
int b[200000];
set<int> s, t;

bool solve(){
    rep(i, n){
        if(s.count(i + 1) && t.count(i + 1)){
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n >> m;
    rep(i, m){
        cin >> a[i] >> b[i];
        if(a[i] == 1){
            s.insert(b[i]);
        }
        if(b[i] == n){
            t.insert(a[i]);
        }
    }
    cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void){
	uint16_t N;
	int16_t *C, *V;
	cin >> N;
	uint32_t res = 0;

	C = new int16_t[N];
	V = new int16_t[N];
	for(uint16_t i = 0;i < N;++i)
		cin >> V[i];
	for(uint16_t i = 0;i < N;++i)
		cin >> C[i];
	int16_t tmp;
	for(uint16_t i = 0;i < N;++i){
		tmp = V[i] - C[i];
		if(tmp > 0)
			res += tmp;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}NUM;
NUM Adj[101];
  
int main(){
  int n,i,j,k,flag;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&Adj[i].u);
    scanf("%d",&Adj[i].k);
    for(j=0;j<Adj[i].k;j++){
      scanf("%d",&Adj[i].v[j]);
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      flag=0;
      for(k=0;k<n;k++){
	if(Adj[j].u==Adj[i].v[k]){
	  flag++;
	}
      }
      if(flag!=0){
	printf("1");
      }
    else{
      printf("0");
    }
      if(j!=n-1){
      printf(" ");
      }
  }
   printf("\n"); 
  }

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
#define MAXNUM 211111
int num[MAXNUM],res[MAXNUM];
int dp[MAXNUM][4];
pii getit(int pos,int l)
{
    return pii(l-1,num[pos]-(num[pos-1]-l+1));
}
int main()
{
    int n;scanf("%d",&n);
    rep(i,1,n+1)scanf("%d",&num[i]);
    rep(i,0,n+2)dp[i][0]=num[i],dp[i][1]=dp[i][2]=dp[i][3]=-1;
    rep(i,1,n+2)
    {
        int tmp[4];
        rep(j,0,4)tmp[j]=1e9+7;
        rep(j,0,3){
            pii xx=getit(i,dp[i-1][j+1]+1);
            xx={max(xx.first,xx.second),min(xx.first,xx.second)};
            tmp[j]=min(tmp[j],xx.first);
            tmp[j+1]=min(tmp[j+1],xx.second);
        }
        int k=0;
        while(tmp[k]>=num[i])k++;
        res[i]=res[i-1]+k;
        rep(j,1,3)dp[i][j]=max(-1,tmp[j+k-1]);
    }
    printf("%d\n",res[n+1]);
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll t = 1ll * n * (n + 1) / 2;
  if (sum % t) {
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum / t;
  REP(i, n) {
    ll d = a[i] - (i == 0 ? a[n - 1] : a[i - 1]);
    d -= k;
    if (0 < d) {
      cout << "NO" << endl;
      return 0;
    }
    d = -d;
    if (d % n) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

    int A = 0;
    int B = 0;
    int C = 0;
    int K = 0;
    int count = 0;
    int sum = 0;
    scanf("%d %d %d %d", &A, &B, &C, &K);

    count = K - A;
    if (count < 0){
        sum += K;

    } else {
        sum += A;
        count -= B;
        if (count > 0){
            sum -= K - A - B;    
        }
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1736
a, b, k = map(int,input().split())
if a+k+1 <= b:
    for i in range(a, k+a):
        print(i)
    if a+k+1 <= b+1-k:
        for i in range(b+1-k, b+1):
            print(i)
    else:
        for i in range(a+k, b+1):
            print(i)
else:
    for i in range(a, b+1):
        print(i)

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

int main(){ 
  int N;
  vector<int64_t> A(100010,0), B(100010,0), C(100010,0);

  cin >> N;
  for(int i=1; i<=N; i++) cin >> A[i]; A[N+1] = 1e10;
  for(int i=1; i<=N; i++) cin >> B[i]; B[N+1] = 1e10;
  for(int i=1; i<=N; i++) cin >> C[i]; C[N+1] = 1e10;

  sort(A.begin(), A.begin()+N+1);
  sort(B.begin(), B.begin()+N+1);
  sort(C.begin(), C.begin()+N+1);

  int64_t ans = 0;
  for(int b=1; b<=N; b++){
    int64_t a = lower_bound(A.begin(), A.begin()+N+1, B[b]) - A.begin()-1;
    int64_t c = upper_bound(C.begin(), C.begin()+N+1, B[b]) - C.begin();
    //cout << a << " " << c << endl;
    ans += a * (N-c+1);
  }

  cout << ans << endl;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b,v,w,t; cin >> a >> v >> b >> w >> t;
    if(abs(a-b) <= v*t - w*t) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3640
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

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

  vector<int> R(M);
  REP(i, N) {
    int k;
    cin >> k;

    REP(j, k) {
      int a;
      cin >> a;
      R[a - 1]++;
    }
  }

  int count = 0;
  REP(i, M) {
    if (R[i] == N) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

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

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

  int ans = 0;
  vector<int> d(3);
  for(d[0]=0; d[0]<=9; d[0]++){
    for(d[1]=0; d[1]<=9; d[1]++){
      for(d[2]=0; d[2]<=9; d[2]++){
        int cur = 0;
        for(int i=0; i<N; i++){
          if(S[i] - '0' == d[cur]) cur++;
          if(cur == 3) {
            ans++; break;
          }
        }
      }
    }
  }

  cout << ans << endl;
}


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL a, b, x;
    cin >> a >> b >> x;

    cout << b / x - a / x + (a % x == 0)<< '\n';

    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);

    // 100個の入力を受け取る
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    int X = 0;
    for (int i = 0; i < K; i++) {
        X += vec.at(i);
        
    }
    cout << X << endl;


}

Measured memory_bytes: 3632
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long D;
    D = input.front.to!long;
    input.popFront;

    long[] X = new long[](cast(size_t)(N));
    long[] Y = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        X[i] = input.front.to!long;
        input.popFront;
        Y[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, D, X, Y);
}

void solve(long N, long D, long[] X, long[] Y)
{
    long ans;
    foreach (i; 0 .. N)
    {
        ans += (X[i] ^^ 2 + Y[i] ^^ 2) <= D ^^ 2;
    }
    writeln(ans);
}


Measured memory_bytes: 15148
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s = input()

    ans = 10 ** 5
    for i in range(len(s)-3+1):
        ans = min(ans, abs(int(s[i:i+3])-753))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
// AOJ 0573: Night Market
// 2017.11.1 bal4u@uu

#include <stdio.h>
#include <string.h>

#define max(a,b) ((a)>=(b)?(a):(b))

int a[3001], b[3001];
int dp[3001][3001];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, t, s, i, j, k, ans;

	fgets(p=buf, 30, stdin);
	n = getint(), p++, t = getint(), p++, s = getint();
	for (i = 1; i <= n; i++) {
		fgets(p=buf, 30, stdin);
		a[i] = getint(), p++, b[i] = getint();
	}
	ans = 0;
	for (i = 1; i <= n; i++) for (j = 1; j <= t; j++) {
		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		k = j-b[i];
		if (k >= 0 && (s <= k || j <= s))
			dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i]);
		ans = max(ans, dp[i][j]);
    }
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int getDigits(ll n) {
  int sum = 0;
  while (n > 0) {  // n が 0 になるまで
    sum++;
    n /= 10;
  }
  return sum;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 1;
  ll limit = 1e18;
  ll prev = 1;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (int i = 0; i < N; i++) {
    ll tmp = A[i];
    ans = ans * tmp;
    if (ans > limit) {
      cout << -1 << endl;
      return 0;
    }
    if (tmp == 1) {
      continue;
    }
    if (ans <= prev) {
      cout << -1 << endl;
      return 0;
    }
    prev = ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048