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

using namespace std;
using ll = long long;
const int N = 200010;

int n;
ll a[N], b[N], c[N], d[N];

int in_range(ll l, ll r) {
    // [l, r)
    auto left = lower_bound(d, d + n, l);
    auto right = lower_bound(d, d + n, r) - 1;
    return right - left + 1;
}

int work(ll T) {
    int tot = 0;
    for (int i = 0; i < n; i++) {
        tot += in_range(T - c[i], 2 * T - c[i]);
        tot += in_range(3 * T - c[i], 4 * T - c[i]);
    }
    return tot & 1;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%lld", a + i);
    for (int i = 0; i < n; i++) scanf("%lld", b + i);
    ll ans = 0;
    for (int k = 0; k <= 30; k++) {
        ll mask = (1ll << (k + 1)) - 1;
        for (int i = 0; i < n; i++) c[i] = a[i] & mask, d[i] = b[i] & mask;
        sort(d, d + n);
        if (work(1ll << k)) ans |= 1ll << k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - b) <= d && abs(b - c) <= d) puts("Yes");
    else if (abs(a - c) <= d) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, T;
    cin >> n >> T;

    int cost = 1001;
    for (int i = 0; i < n; i++) {
        int t, c;
        cin >> c >> t;
        if (t <= T) {
            cost = min(cost, c);
        }
    }

    if(cost == 1001) cout << "TLE" << endl;
    else cout << cost << endl;

    return 0;    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

template<typename T>
class TopologicalSort {
private:
    map<T, bool> is;
    map<T, vector<T>> g;
    vector<T> tsort;
	map<T, long long> inCnt;
    void dfs(T now) {
        if (is[now]) return;
		is[now] = true;
        for (auto &&el : g[now]) {
            dfs(el);
        }
        tsort.emplace_back(now);
    }
public:
    TopologicalSort() {}
	TopologicalSort(const vector<T>& vec) {
		for (auto &&el : vec) {
			g[el].resize(0);
			is[el] = false;
		}
	}
    vector<T> dfsTsort() {
        for (auto &&el : g) {
            dfs(el.first);
        }
        reverse(tsort.begin(), tsort.end());
        return tsort;
    }
	void addEdge(T src, T dst) {
		g[src].emplace_back(dst);
		inCnt[dst]++;
	}
	vector<T> bfsTsort() {
		queue<T> q;
		for (auto &&el : inCnt) {
			if (el.second == 0) {
				q.push(el.first);
			}
		}
		while (!q.empty()) {
			T now = q.front(); q.pop();
			tsort.emplace_back(now);
			for (auto &&el : g[now]) {
				if (--inCnt[el] == 0) q.push(el);
			}
		}
		bool endFlag = true;
		for (auto &&el : inCnt) {
			if (el.second) endFlag = false;
		}
		return (endFlag ? tsort : vector<T>());
	}
};

int main(void) {
	int V, E;
	cin >> V >> E;
	VI v(V);
	iota(ALL(v), 0);
	TopologicalSort<int> t(v);
	REP(_, E) {
		int s, d;
		cin >> s >> d;
		t.addEdge(s, d);
	}
	auto ans = t.dfsTsort();
	FORE(el, ans) cout << el << endl;
}

Measured memory_bytes: 5380
a, b, c, d = map(int,input().split())

count_ta = 0
for i in range(100):
    a = a - d
    count_ta += 1
    if a <= 0:
        break

count_ao = 0
for i in range(100):
    c = c - b
    count_ao += 1
    if c <= 0:
        break

if count_ta >= count_ao:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
MOD = (10 ** 9) + 7

f_list = [1] * 100001
f_r_list = [1] * 100001

for i in range(100000):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

def power(n, x):
	if x == 1:
		return n
	elif x % 2 == 0:
		return power(int((n * n) % MOD), int(x / 2))
	else:
		return int((n * power(n, x - 1)) % MOD)

f_r_list[-1] = power(f_list[-1], MOD - 2)

for i in range(2, 100002):
	f_r_list[-i] = int((f_r_list[-i + 1] * (100003 - i)) % MOD)

def comb(n, r):
	if n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

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


doubled = sum(a) - n * (n + 1) / 2
x = a.index(doubled)
y = a_r.index(doubled)
num = x + y

print(n)

for i in range(2, n + 2):
	if num >= i - 1:
		print(int((comb(n + 1, i) - comb(num, i - 1)) % MOD))
	else:
		print(comb(n + 1, i))

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

int main(){

    int A,B;
    cin >> A >> B;

    if((A+B)%2==0)cout << (A+B)/2 << endl;
    else {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	int L, A, B, C, D, j, m;
	std::cin >> L >> A >> B >> C >> D;
	j = A / C + (A % C > 0);
	m = B / D + (B % D > 0);
	std::cout << L - std::max(j, m) << std::endl;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ATwoCoins {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.nextInt() + in.nextInt() >= in.nextInt() ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 24020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string a, b;
	cin >> a >> b;

	string c = "";
	for(int i = 0; i + 1 < b.size(); i++)
		c += b[i];

	if(a == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    ll res = 0;
    rep(i, N) {
        cin >> A[i];
        res += (A[i] - 1);
    }

    cout << res << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

int A, B, C, D, E, F;
double per;
int ans1, ans2;
int dp[4000][4000];

int dfs(int water, int suger) {
    if(dp[water][suger] != 0) { return 0; }
    dp[water][suger] = 1;
    if(water + suger > 0) {
        double cand = (100 * (double)suger) / ((double)water + (double)suger);
        if(per <= cand) {
            per = cand;
            ans1 = water + suger;
            ans2 = suger;
        }
    }
    if(water + 100 * A + suger <= F) {
        dfs(water + 100 * A, suger);
    }
    if(water + 100 * B + suger <= F) {
        dfs(water + 100 * B, suger);
    }
    int cap = E * water / 100;
    if(water + suger + C <= F &&
       suger + C <= cap) {
        dfs(water, suger + C);
    }
    if(water + suger + D <= F &
       suger + D <= cap) {
        dfs(water, suger + D);
    }
    return 0;
}

int main()
{
    ZERO(dp);
    cin >> A >> B >> C >> D >> E >> F;
    ans1 = 0; ans2 = 0;
    per = 0;
    dfs(0, 0);
    printf("%d %d\n", ans1, ans2);
    return 0;
}


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


typedef long long ll;
using namespace std;
const int maxn = 1e6+5;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k) cout << a-k << " " << b << endl;
    else if(b >= k-a) cout << 0 << " " << b-k+a << endl;
    else cout << 0 << " " << 0 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,l,r,result=-1;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld %lld",&l,&r);
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      if(result==-1) result = (i*j)%2019;
      else result = min(result, (i*j)%2019);
      
      if(result==0) break;
    }
    if(result==0) break;
  }
  printf("%lld", result);

  return 0;
}

Measured memory_bytes: 128
#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, std::string A, std::string B, std::string C) {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == B[i] && B[i] == C[i]) {
      ans += 0;
      continue;
    }
    if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
      ans += 1;
      continue;
    }
    ans += 2;
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::string A;
  std::cin >> A;
  std::string B;
  std::cin >> B;
  std::string C;
  std::cin >> C;
  solve(N, A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int ai;
    vector<int> a(n-1);
    for(int i=0; i<n-1; i++){
        cin >> ai;
        a[i] = ai;
    }

    vector<int> j(n,0);
    for(int i=n-1; i>0; i--){
        j[a[i-1]-1] += 1;
    }

    for(int i=0; i<n; i++){
        cout << j[i] << endl;
    }
}

Measured memory_bytes: 4844
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($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:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i32; n]
    }
    let mut ans = 10000000;
    for i in -100..101 {
        let mut cost = 0;
        for j in &a {
            cost += (j - i)*(j - i);
        }
        ans = min(ans,cost);
    }
    puts!("{}\n",ans);
}

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: 2272
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int main(){
	int n;
	while (cin >> n && n){
		VI p(n+1), t(n+1);
		REP(i,n) cin >> p[i+1] >> t[i+1];
		VVI dp(n+1,VI(4, INF));
		dp[0][0] = 0;
		REP(i,n) REP(j,4){
			int x = p[i+1] + p[i] * (j+1);
			if (x <= t[i+1] - t[i]) dp[i+1][1] = min(dp[i+1][1], dp[i][j] + p[i+1] + p[i]);
			x = abs(p[i+1]-p[i]) * (j+1);
			if (x <= t[i+1] - t[i] && j < 3) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + abs(p[i+1]-p[i]));
		}
		int fail = -1;
		FOR(i,1,n){
			bool ok = 0;
			REP(j,4) if (dp[i][j] < INF) ok = 1;
			if (!ok){
				fail = i;
				break;
			}
		}
		if (fail > 0){
			cout << "NG " << fail << endl;
			continue;
		}
		int ans = INF;
		REP(j,4) ans = min(ans, dp[n][j]+p[n]);
		cout << "OK " << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 3052
n  = int(input())
A = list(map(int,input().split()))
pal = [-1,1]
cnt = 10**18
for p in pal:
    s = 0
    tmp = 0
    prev = p
    for a in A:
        s+=a
        if s==0:
            tmp+=1
            s = prev
            prev*=-1
            continue
        if a==0:
            tmp +=abs(s)+1
            s = prev
            prev*=-1
            continue
        if s//abs(s) != prev:
            tmp+=abs(s)+1
            s = prev
        else:
            pass
        prev*=-1
    cnt = min(cnt,tmp)
print(cnt)


Measured memory_bytes: 14468
#include <iostream>
#include <stack>
#include<algorithm>
using namespace std;
int main() {
	stack<int> pos;
	stack< pair<int, int> > area;
	int sum = 0;
	char ch;
	for (int i = 0; cin >> ch; i++) {
		if (ch == '\\') {
			pos.push(i);
		}
		else if (ch == '/' && pos.size()>0) {
			int left = pos.top();
			pos.pop();
			int val = i - left;
			sum += val;
			pair<int, int> p(left, val);
			while (area.size() > 0 && area.top().first > p.first) {
				pair<int, int> child = area.top(); area.pop();
				p.second += child.second;
			}
			area.push(p);
		}
	}
	cout << sum << endl;
	int len = area.size();
	if (len == 0)
		cout << len;
	else
		cout << len << " ";
	int* arr = new int[len];
	for (int i = 0; area.size()>0; area.pop(), i++)
		arr[i] = area.top().second;
	for (int i = len - 1; i >= 0; i--) {
		if (i != len - 1)
			cout << " " << arr[i];
		else
			cout << arr[i];
	}
	cout << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  set<int> c;
  rep(i, N) {
    int _c;
    cin >> _c;
    c.insert(_c);
  }

  cout << c.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const double eps = 1e-8;
const int mod = 998244353;

map<int,int> vis;

bool check(string now){
  for(int i = 0;i < now.size();i++){
    if(vis[now[i]-'0']) return false;
  }
  return true;
}

int n,k,d;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>k;
  for(int i = 1;i <= k;i++){
    cin>>d;
    vis[d] = 1;
  }
  for(int i = n;i <= 100000;i++){
    if(check(to_string(i))) {cout<<i<<endl;break;}
  }
  return 0;
}


Measured memory_bytes: 256
n,mw=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[float('inf') for _ in range(10**5+10)]for _ in range(n+1)]
#dp[i][j]=i個目までの品物を選んだとき、価値をjにする最小の重さ
dp[0][0]=0
for i in range(n):
    w,v=l[i]
    for j in range(10**5+10):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        if j+v<10**5+10:
            dp[i+1][j+v]=min(dp[i+1][j+v],dp[i][j]+w)
    for j in range(10**5+9):
        dp[i+1][-2-j]=min(dp[i+1][-2-j],dp[i+1][-1-j])
for i in range(10**5+10):
    if dp[-1][i]>mw:
        print(i-1)
        break

Measured memory_bytes: 342744
import java.util.Scanner;
class Main{
 
    public void solve(){
        Scanner sc = new Scanner(System.in);
		int ninzu, k;
		int ban;
       for(int i = 0; i < 4; i++){
	   	ban = sc.nextInt();
		if(ban == 1){
			k = 6000;
		}else if(ban == 2){
			k = 4000;
		}else if(ban == 3){
			k = 3000;
		}else{
			k = 2000;
		}
		
		ninzu = sc.nextInt();
		int uriage = k * ninzu;
		System.out.println(uriage);
       }
	   	
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17280
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll v=i;
        ll sum=0;
        while(v){
            sum+=(v%10);
            v/=10;
        }
        if(a<=sum && sum<=b){
            ans+=i;
        }
    }
    
    
    cout << ans << endl;
}

Measured memory_bytes: 3604
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let mut v = Vec::new();
    for _ in 0..5 {
        let tmp = get!(i32);
        v.push(tmp);
    }
    let mut time = 0;
    let mut rest = Vec::new();
    let mut hitoketa = 9;
    let mut min = -1;
    for i in 0..5 {
        if v[i] % 10 == 0 {
            time += v[i];
        } else {
            let t_hitoketa = v[i] % 10;
            if t_hitoketa < hitoketa {
                hitoketa = t_hitoketa;
                min = v[i];
            }
            rest.push(v[i]);
        }
    }
    if rest.len() == 0 {
        println!("{}", time);
        return;
    }
    time += min;
    for i in 0..rest.len() {
        if rest[i] == min {
            rest.remove(i);
            break;
        }
    }
    for i in 0..rest.len() {
        time += ((rest[i] + 9) / 10) * 10;
    }
    println!("{}", time);
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    //区間の最小値(左側から考える右側関係ない！！！)
    int mini = p[0];
    vector<int> mins(n + 1);
    mins[0] = p[0];
    
    for (int j = 0; j < n; j++)
    {
        if (p[j] <= mini)
            mini = p[j];
        mins[j] = mini;
       
    }

    int count = 0;

    rep(i, n)
    {
        if (p[i] <= mins[i])
            count++;
    }
    c(count);

    return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [usize; n]);
    let mut curm = 1000;
    let mut curx = 0;
    for i in 0..(n - 1) {
        if a[i] < a[i + 1] {
            let k = curm / a[i];
            curx += k;
            curm -= a[i] * k;
        } else {
            curm += curx * a[i];
            curx = 0;
        }
    }
    curm += curx * a[n - 1];
    println!("{}", curm);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N = 5;
	vector<int> A(N);
	int res = 0;
	set<int> st;
	for (int i = 0; i <= 5; i++) {
		st.insert(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		st.erase(A[i]);
	}

	cout << (*st.begin()) << endl;
}

Measured memory_bytes: 3644
n, k = map(int, input().split())
a = []
for i in range(k):
    d = int(input())
    a.append(list(map(int, input().split())))

x = list(range(1, n+1))
for i in range(k):
    for b in a[i]:
        if b in x:
            x.remove(b)
print(len(x))


Measured memory_bytes: 9132
s=input()
l=len(s)-1
ans=0
for i in range(2**l):
  op=['']*(l+1)
  for j in range(l):
    if ((i>>j)&1):
      op[l-1-j]='+'
  op[l]=''
  f=''
  for i in range(l+1):
    f+=s[i]+op[i]
  ans+=eval(f)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
#define int ll
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	//freopen("in.txt","r", stdin);
    int n,m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m); for(ll& v : a) cin >> v; for(ll& v : b) cin >> v;
    vector<ll> psaa(n), psab(m);
    ll cur = 0;
    for(int i = 0; i < n; i++){
        cur += a[i];
        psaa[i] = (i == 0 ? 0 : psaa[i-1]) + a[i];
    }
    cur = 0;
    for(int i = 0; i < m; i++){
        cur += b[i];
        psab[i] = (i == 0 ? 0 : psab[i-1]) + b[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        // fix A
        int diff = k-psaa[i];
        if(diff < 0) continue;
        if(diff == 0){ ans = max(ans,i+1); continue; }
        //cerr << "current diff: " << diff << "\n";
        //cerr << "psa: " << psaa[i] << "\n";
        auto itr = upper_bound(psab.rbegin(), psab.rend(), diff,
                       [](ll a, ll b){return a>=b;});
        if(itr == psab.rend()){
            ans = max(ans,i+1);
        }else{
            //cerr << "found: " << *itr << " " << distance(psab.begin(),itr.base()) << "\n";
            ans = max(ans,(i+1)+(int)distance(psab.begin(),itr.base()));
        }
    }
    for(int i = 0; i < m; i++){
        // fix B
        int diff = k-psab[i];
        if(diff < 0) continue;
        if(diff == 0){ ans = max(ans,i+1); continue; }
        //cerr << "current diff: " << diff << "\n";
        //cerr << "psa: " << psaa[i] << "\n";
        auto itr = upper_bound(psaa.rbegin(), psaa.rend(), diff,
                       [](ll a, ll b){return a>=b;});
        if(itr == psaa.rend()){
            ans = max(ans,i+1);
        }else{
            //cerr << "found: " << *itr << " " << distance(psab.begin(),itr.base()) << "\n";
            ans = max(ans,(i+1)+(int)distance(psaa.begin(),itr.base()));
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 9536
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

struct UnionFind{
    int size;
    std::vector<int> par;
    std::vector<int> rank;
    UnionFind(int x){
        size=x;
        par=std::vector<int> (x);
        rank=std::vector<int> (x,1);
        for (int i=0;i<x;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        else return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;rank[i]=1;
        }
    }
};

using namespace std;

int main() {
    int n,m; cin >> n >> m;
    UnionFind uf(n);
    rip(i,m,0) {
        int a, b; cin >> a >> b;
        --a;--b;
        uf.unite(a, b);
    }
    map<int,int> mp;
    rip(i,n,0) {
        int now = uf.root(i);
        if(mp.count(now)) mp[now] ++;
        else mp[now] += 1;
    }
    int ans =0;
    for(auto i:mp) chmax(ans, i.second);
    cout << ans << endl;
}


Measured memory_bytes: 14356
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===



def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    def disLR(a, idx):
        small = a[max(0, idx - 1)]
        large = a[min(len(a) - 1, idx)]
        return [small, large]

    for _ in range(q):
        ans = INF

        x = ni()

        idxs = bisect.bisect_left(s, x)
        a1 = disLR(s, idxs)

        idxt = bisect.bisect_left(t, x)
        a2 = disLR(t, idxt)

        for ta1 in a1:
            for ta2 in a2:
                tmp1 = abs(x - ta1) + abs(ta2 - ta1)
                tmp2 = abs(x - ta2) + abs(ta1 - ta2)
                ans = min(ans, tmp1, tmp2)

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19164
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 998244353
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
        cout<<1;
    if(b==0)
        cout<<2;
    if(c==0)
        cout<<3;
    if(d==0)
        cout<<4;
    if(e==0)
        cout<<5;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    ll ans = 0, cnt = 1;
    REP(i, n-1){
        if(s[i] == s[i-1])cnt++;
        else{
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }
    cout << ans+cnt*(cnt-1)/2 << endl;
}
    

Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

const int sz = 2600;
ll dp[sz][51][51];
ll cop[sz][51][51];
void solve() {
	int n, x; cin >> n >> x;
	if (x % 2) {
		cout << 0 << endl; return;
	}
	dp[sz/2][0][0] = 1;
	rep(i, n) {
		rep(j, sz)rep(k, n + 1)rep(l,n+1)cop[j][k][l] = 0;
		rep(j, sz) {
			rep(k, i+1) {
				rep(l, i + 1) {
					if (dp[j][k][l] == 0)continue;
					//
					(cop[j][k][l] += dp[j][k][l]) %= mod;
					//
					(cop[j][k][l] += dp[j][k][l]*k) %= mod;
					//
					if (k > 0&&l>0) {
						(cop[j + i][k - 1][l - 1] += dp[j][k][l] * k*l) %= mod;
					}
					//
					(cop[j - i][k + 1][l + 1] += dp[j][k][l]) %= mod;
					//
					(cop[j][k][l] += dp[j][k][l] * l) %= mod;
				}
			}
		}
		rep(j, sz)rep(k, n + 1)rep(l,n+1)dp[j][k][l] = cop[j][k][l];
	
	}
	if (x / 2 + sz / 2 >= sz) {
		cout << 0 << endl; return;
	}
	//cout << "hello" << endl;
	cout << dp[x / 2 + sz / 2][0][0] << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 105984
#include<bits/stdc++.h>
#define ll long long
#define re register
#define gc get_char
#define cs const

namespace IO{
	inline char get_char(){
		static cs int Rlen=1<<22|1;
		static char buf[Rlen],*p1,*p2;
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,Rlen,stdin),p1==p2)?EOF:*p1++;
	}
	
	template<typename T>
	inline T get(){
		char c;T num;
		while(!isdigit(c=gc()));num=c^48;
		while(isdigit(c=gc()))num=(num+(num<<2)<<1)+(c^48);
		return num;
	}
	inline int gi(){return get<int>();}
}
using namespace IO;

using std::cerr;
using std::cout;

cs int N=1e5+7;

int n,m;
int fa[N],vis[N];
int a[N],ta[N],b[N],tb[N];

inline int gf(int u){return u==fa[u]?u:(fa[u]=gf(fa[u]));}

signed main(){
#ifdef zxyoi
	freopen("xor.in","r",stdin);
#endif
	n=gi();
	for(int re i=1;i<=n;++i)*a^=a[i]=ta[i]=gi();
	for(int re i=1;i<=n;++i)*b^=b[i]=tb[i]=gi();
	ta[0]=a[0];std::sort(ta,ta+n+1);
	tb[0]=b[0];std::sort(tb,tb+n+1);
	for(int re i=0;i<=n;++i)if(ta[i]!=tb[i])cout<<"-1",exit(0);
	m=std::unique(ta,ta+n+1)-ta;
	for(int re i=0;i<m;++i)fa[i]=i;
	for(int re i=0;i<=n;++i){
		a[i]=std::lower_bound(ta,ta+m,a[i])-ta;
		b[i]=std::lower_bound(ta,ta+m,b[i])-ta;
	}
	int ans=0;
	for(int re i=0;i<=n;++i)fa[gf(a[i])]=gf(b[i]),ans+=a[i]!=b[i]&&i;
	for(int re i=0;i<m;++i)if(gf(i)^i)vis[fa[i]]=1;int t=gf(a[0]);
	for(int re i=0;i<m;++i)if(gf(i)==i)ans+=vis[i]&&i!=t;
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N);
  REP(i, N) cin >> X[i];
  vector<int> Y(N);
  Y = X;
  int half = N / 2;
  sort(Y.begin(), Y.end());
  //まんなかひとつ前の要素
  int before = Y[half - 1];
  for(int i = 0; i < N; i++) {
    if(X[i] <= before) {
      cout << Y[half] << endl;
    } else {
      cout << Y[half - 1] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main(void)
{
  int i,N[101],E[101],W[101],S[101],U[101],D[101];
  char com[101];

  scanf("%d %d %d %d %d %d", &U[0], &S[0], &E[0], &W[0], &N[0], &D[0]);
  scanf("%s", com);
    
  for(i=1;i<strlen(com)+1;i++){
    if(com[i-1]=='N'){
      U[i]=S[i-1],N[i]=U[i-1],S[i]=D[i-1],D[i]=N[i-1],E[i]=E[i-1],W[i]=W[i-1];
    } else if(com[i-1]=='E'){
      U[i]=W[i-1],E[i]=U[i-1],W[i]=D[i-1],D[i]=E[i-1],N[i]=N[i-1],S[i]=S[i-1];
    } else if(com[i-1]=='W'){
      U[i]=E[i-1],E[i]=D[i-1],W[i]=U[i-1],D[i]=W[i-1],N[i]=N[i-1],S[i]=S[i-1];
    } else if(com[i-1]=='S'){
      U[i]=N[i-1],N[i]=D[i-1],S[i]=U[i-1],D[i]=S[i-1],E[i]=E[i-1],W[i]=W[i-1];
    }
  }
  cout<<U[strlen(com)]<<endl;
}


Measured memory_bytes: 1212
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007



int main(int argc, char const *argv[]) {
  ll n,m=1,ans=0,a[3100];
  std::cin >> n;
  for(int i=0; i<n; i++)std::cin >> a[i];

  for(int i=0; i<n; i++){
     ans+=a[i]-1;
   }
   std::cout << ans << '\n';

  return 0;
}


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

int a[10005],n;
int dp[2][5005][2];

int main(){
    scanf("%d",&n);
    for (int i=0; i<n-1; i++) {
        scanf("%d",&a[i]);
    }
    for (int j=1; j<=n/2; j++) {
        dp[0][j][0] = 1e9;
        dp[0][j][1] = 1e9;
    }
    for (int i=1; i<=n-1; i++) {
        for (int j=0; j<=n/2-1; j++) {
            dp[i%2][j][0] = min((j?dp[(i-1)%2][j-1][0]:987654321),dp[(i-1)%2][j][1] + a[i-1]);
            dp[i%2][j][1] = min(dp[(i-1)%2][j][1],(j?dp[(i-1)%2][j-1][0]:987654321) + a[i-1]);
        }
    }
    printf("%d\n",dp[(n-1)%2][n/2-1][0]);
}

Measured memory_bytes: 1140
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

const ll M = 1e6;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(M + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        if (B[A[i]] != 0) {
            B[A[i]] = 2;
            continue;
        }
        for (ll j = A[i]; j <= M; j += A[i]) {
            B[j]++;
        }
    }
    int count = 0;
    for (ll a : A) {
        if (B[a] == 1) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    while(x >= b) {
        x -= b;
    }
    printf("%lld\n", x);
    return 0;
}


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

signed main() {
  int N; cin >> N;
  vector<int> W(N);
  for(int i=0; i<N; i++) cin >> W[i];

  int sum = 0;
  for(int i=0; i<N; i++) sum += W[i];

  int ans = 1e9;
  for(int t=0; t<N; t++) {
    int s1=0;
    for(int i=0; i<t; i++) s1 += W[i];
    int s2 = sum - s1;
    ans = min(ans, abs(s1-s2));    
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var mod [2020]int
	var input string
	tmp := 0
	ans := 0
	c := 1
	fmt.Scanf("%s", &input)
	s := make([]int, len(input))

	for i := 0; i < len(input); i++ {
		s[i], _ = strconv.Atoi(string(input[i]))
	}

	mod[0]++

	for i := len(s) - 1; i >= 0; i-- {
		tmp += s[i] * c
		mod[tmp%2019]++
		c *= 10
		c %= 2019
	}

	for i := 0; i < 2019; i++ {
		if mod[i] > 1 {
			ans += mod[i] * (mod[i] - 1) / 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4916
import heapq
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
x=[1 for i in range(m)]
ans=0
q=[]
cnt=0
for i in range(1,m+1):
    for j in range(cnt,n):
        if a[j][0]==i:
            heapq.heappush(q,-a[j][1])
            cnt+=1
        else:
            break
 
    if len(q)!=0:
        ans+=-heapq.heappop(q)
        
            

print(ans)

        


        
        
    
    
        



Measured memory_bytes: 76504
/**
 * HowManyWays.cpp
 * Create:20180424
 * Description:1からnまでの数の中から、
 * 重複なしで3つの数を選びそれらの合計が
 * xとなる組み合わせの数を求めるプログラム。
 */
#include <iostream>
#include <vector>

/**
 * 組み合わせ数カウント関数
 * @param  max    最大値
 * @param  target 加算目標値
 * @return        組み合わせの数
 */
int sum_target_count(int max, int target){
  int result = 0;
  for (int i = 1; i <= max - 2; i++){
    for (int j = i + 1; j <= max - 1; j++){
      for (int k = j + 1; k <= max; k++){
        if (target == (i + j + k))
          result++;
      }
    }
  }
  return result;
}

int main(int argc, char* argv[]){
  int n, x;
  std::vector<int> vec;

  while (true){
    std::cin >> n >> x;
    if (0 == n && 0 == x)
      break;
    vec.push_back(sum_target_count(n, x));
  }

  for (int count:vec){
    std::cout << count << std::endl;
  }

  return 0;
}


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

int main(){
  set<int> s;
  int A,B,K;
  cin >> A >> B >> K;
  for(int i=A;i<A+K;i++){
    if(i>B){
      break;
    }
    s.insert(i);
  }
  for(int i=B;i>B-K;i--){
    if(i<A){
      break;
    }
    s.insert(i);
  }
  for(auto p:s){
    cout << p << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d, i;
    cin >> a >> b >> c >> d;
    int answer = 0;
    for(i = 0; i < 101; i++){
        if(a <= i && i <= b && c <= i && i <= d){
            answer++;
        }
    }
    if(answer){
        answer--;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int ans = 0;
    for(int i = 0;i < n;i++)cin >> s[i];
    for(int i = 0;i < n;i++){
        if(s[i] == i+1){
            int temp = s[i];
            if(i != n-1){
                s[i] = s[i+1];
                s[i+1] = temp;
            }else{
                s[i] = s[i-1];
                s[i-1] = temp;
            }
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640