akhauriyash/Code-Regression huggingface dataset:
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
	int N, a[100];

	cin >> N;
	rep(i, N) cin >> a[i];

	sort( a, a+N );

	cout << a[N-1] - a[0] << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

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

	int n = s.size();
	vector<int> map(26, -1);
	REP(i, n) {
		if(map[s[i] - 'a'] == -1) {
			map[s[i] - 'a'] = t[i] - 'a';
		} else if(map[s[i] - 'a'] != t[i] - 'a') {
			cout << "No" << endl;
			return 0;
		}
	}
	map = vector<int>(26, -1);
	REP(i, n) {
		if(map[t[i] - 'a'] == -1) {
			map[t[i] - 'a'] = s[i] - 'a';
		} else if(map[t[i] - 'a'] != s[i] - 'a') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    VI a(m);
    REP(i,0,m) cin >> a[i];
    int sum = 0;
    REP(i,0,m) sum += a[i];
    cout << max(-1, n - sum) << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3668
import java.util.*;
import java.math.*;

public class Main {

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

    if (s.equals("ABC")) {
      System.out.println("ARC");
    } else {
      System.out.println("ABC");
    }

  }

}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
#define MOD 1000000007l
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N, M, K;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}
 
// 逆元を求める
ll moddiv(ll n){
	return modpow( n, MOD-2 );
}
 
// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	const int MAX_NUM = 1000006; // 最大のn
	vector<ll> fact;
	vector<ll> inv;
	FACTORIAL(): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modpow( fact[i], MOD-2 );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact;
 
 
// 組み合わせ(Combinationを求める) O(1)
ll Cmb(unsigned int n, unsigned int r){
    if (n==r)return 1;
    if (r==0)return 1;
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}

int input(){
  cin >> N >> M >> K;
}

int main()
{
  input();
  
  ll s = 0;
  FOR(d,1,N+1){
    ll s2 = 1;
    s2=(s2*d)%MOD;
    s2=(s2*M)%MOD;
    s2=(s2*M)%MOD;
    s2=(s2*(N-d))%MOD;
    s2=(s2*Cmb(N*M-2,K-2))%MOD;
    s=(s+s2)%MOD;
  }
  FOR(d,1,M+1){
    ll s2 = 1;
    s2=(s2*d)%MOD;
    s2=(s2*N)%MOD;
    s2=(s2*N)%MOD;
    s2=(s2*(M-d))%MOD;
    s2=(s2*Cmb(N*M-2,K-2))%MOD;
    s=(s+s2)%MOD;
  }
  
  cout << s << endl;
  
  
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 302;
double dp[maxn][maxn][maxn];
int n;

double solve(int a, int b, int c)
{
    if(a + b + c == 0)
        return 0;
    double &res = dp[a][b][c];
    if(res >= 0)
        return res;
    double s = a + b + c;
    double t = (double) (n - s) / s;
    res = t;
    if(a)
        res += (solve(a - 1, b, c) + 1) * a / s;
    if(b)
        res += (solve(a + 1, b - 1, c) + 1) * b / s;
    if(c)
        res += (solve(a, b + 1, c - 1) + 1) * c / s;
    return res;
}

int32_t main()
{
    IOS
    int a;
    cin >> n;
    int cnt[4] = {0};
    for(int i = 0; i < n; i++)
        cin >> a, cnt[a]++;
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                dp[i][j][k] = -1;
    cout << setprecision(12) << fixed;
    cout << solve(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}

Measured memory_bytes: 215296
using System;

namespace _177
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solution());
        }

        static public string solution()
        {
            string[] input = Console.ReadLine().Split(' ');
            int D = int.Parse(input[0]);    //Distance m           
            int T = int.Parse(input[1]);    // Time min
            int S = int.Parse(input[2]);    //Speed m/min

            if (D / T <= S && S * T >= D)
                return "Yes";
            else
            { return "No"; }
        }
    }
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n;
    cin >> n;
    cout << (ll)ceil(n/1000.0)*1000 - n << endl;
    return 0;
}


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

struct UnionFind{
  vector<int> par;
  UnionFind(int n):par(n,-1){}
  
  int root(int x){
    if(par[x]<0) return x;
    return par[x] = root(par[x]);
  }
  
  void unite(int x, int y){
    x = root(x); y =root(y);
    if(x==y) return;
    if(-par[x]>-par[y]) swap(x,y);
    par[y] += par[x]; 
    par[x] = y;
  }
  
  bool same(int x, int y){
    return root(x)==root(y);
  }
  
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  vector<int> fri(n);
  vector<set<int>> blo(n);
  
  UnionFind tree(n);
  
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    tree.unite(a,b);
    fri[a]++;
    fri[b]++;
  }
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--; d--;
    blo[c].insert(d);
    blo[d].insert(c);
  }
  
  rep(i,n){
    int ans = tree.size(i) - 1 -fri[i];
    for(int j : blo[i]){
      if(tree.same(i,j)) ans--;
    }
    cout << ans << " ";
  }
  cout  << endl;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin >> n>> k;
  vector<ll> a(n);
  vector<ll> f(n);
  ll asum = 0;
  rep(i,n){
    cin >> a[i];
    asum += a[i];
  }
  rep(i,n){
    cin >> f[i];
  }
  sort(all(a));
  sort(all(f));
  reverse(all(f));
  ll ng = -1;
  ll ok = 1000000000000000000;
  while(ok-ng>1){
    ll m = (ok+ng)/2;
    ll cost=0;
    rep(i,n){
      cost += max(0ll , a[i] - m/f[i]);
    }
    if(cost<=k)ok = m;
    else ng = m;
  }
  cout << ok << endl;
  
}

Measured memory_bytes: 3456
n, m = map(int, input().split())
P = list(map(int, input().split()))
P = [p-1 for p in P]

def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)

  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1

def Same(x, y, par):
  return Find(x, par) == Find(y, par)

def Size(x, par):
  return -par[Find(x, par)]

par = [-1]* n
rank = [0]*n

for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    Unite(x, y, par, rank)

ans = 0
for i in range(n):
    if Same(i, P[i], par):
        ans += 1
print(ans)

Measured memory_bytes: 93676
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> n;
  rep(i, n) {
    cin >> a;
    sum += a;
  }
  h -= sum;
  if (h > 0)
    Cout("No");
  else
    Cout("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
int x,y;
 while(1){
scanf("%d%d",&x,&y);
  if(x==0&&y==0) break; 
 else if(y>x) printf("%d %d\n",x,y);
 else  if(x>=y) printf("%d %d\n",y,x);
 }

 return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cstdio>

using namespace std;

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

static const double eps = 1e-8;

bool cards[300001];

int main(){
  int total_cards;
  int total_questions;

  while(~scanf("%d %d",
               &total_cards,
               &total_questions)){

    memset(cards,false,sizeof(cards));
    
    int tmp_max = 0;
    for(int card_i = 0; card_i < total_cards; card_i++){
      int card;
      scanf("%d",&card);
      cards[card] = true;
    }

    for(int question_i = 0; question_i < total_questions; question_i++){
      int divisor;
      scanf("%d",&divisor);
      int res = 0;
      for(int target = divisor - 1; target >= 0; target--){
        for(int i = target; i <= 300000; i+= divisor){
          if(cards[i]){
            res = target;
            goto found;
          }
        }
      }
    found:;
      printf("%d\n",res);
    }
  }
}

Measured memory_bytes: 1492
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define GRAYCODE(i) ((i) ^ ((i) >> 1))

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    int N, X, D; cin >> N >> X >> D;
    if(!D){
        cout << (X ? N+1 : 1) << "\n";
        return 0;
    }
    // modD, lt, rt(exclusive)
    if(D < 0){
        D *= -1; X *= -1;
    }
    vector<pair<ll, pair<ll, ll>>> p(1 + N);
    ll XmodD = (ll(X) % D + D) % D;
    REPS(i, N){// i個の時
        ll SmodD = (XmodD * i) % D;
        ll iX = ((ll)X * i - SmodD) / D;//X<0の時のため
        p[i] = MP(SmodD, MP(iX + (ll)i * (i-1) / 2,
                            iX + (ll)i * (2*N - i - 1 ) / 2 + 1));
    }
    SORT(p);
    ll prv = -1, ans = 0;
    vector<pair<ll, ll>> q;
    REPS(i, N){
        if(prv != p[i].first){
            q.PB(p[i].second);
            prv = p[i].first;
        }else{
            if(q.back().second >= p[i].second.first)
                chmax(q.back().second, p[i].second.second);
            else q.PB(p[i].second);
        }
    }
    for(auto &a: q) ans += a.second - a.first;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 10864
//exawiz2019_a.cpp
//Sat Mar 30 20:42:52 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if (a==b && b==c){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	int num=0,i,j=0,math[1000]={0};
	char mozi[1000]={0};
	
	while(scanf("%s",mozi)!=EOF){
		num=0;
		for(i=0;i<strlen(mozi);i++){
			if(mozi[i]=='I')math[i]=1;
			else if(mozi[i]=='V')math[i]=5;
			else if(mozi[i]=='X')math[i]=10;
			else if(mozi[i]=='L')math[i]=50;
			else if(mozi[i]=='C')math[i]=100;
			else if(mozi[i]=='D')math[i]=500;
			else if(mozi[i]=='M')math[i]=1000;
		}
		
		for(i=(strlen(mozi)-1);i>=0;i--){
			if(mozi[i]!=mozi[i-1] && math[i]>math[i-1] && i!=0)math[i-1]=math[i]-math[i-1];
			else if(mozi[i]!=mozi[i-1] && math[i]<math[i-1] && i!=0)math[i-1]=math[i]+math[i-1];
			else if(mozi[i]==mozi[i-1] || math[i]==math[i-1] || i==0)num+=math[i];
		}
		
		printf("%d\n",num);
	}
	
return 0;
}

Measured memory_bytes: 544
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, m = map(int, input().split())

data =[]
for i in range(m):
    tmp = [int(n) for n in input().split()]
    data.append(tmp)

for i in range(1000):
    st = str(i)
    if len(st) != n:
        continue
    flg = True
    for j in range(m):
        if int(st[data[j][0]-1]) != data[j][1]:
            flg = False

    if flg:
        print(i)
        exit(0)

print(-1)


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

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;
}
const long long INF=1LL<<60;

int N;
long long h[100010];

long long dp[100010];

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

  for(int i=0;i<100010;++i) dp[i]=INF;

  dp[0]=0;
  for(int i=1;i<N;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N-1] << endl;
}

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

using static Input;
using static Util;
class Program
{
    static string S;
//    static int[] A;
//    static int[] B;
//    static int[] C;
    static void INPUT()
    {
        S = NextString();
        //A = LineInt();
        //B = LineInt();
        //C = LineInt();
    }
    static void OUTPUT()
    {
        var idx = 0;
        foreach(var c in S)
        {
            idx++;
            if (c == 'U' || c == 'D')
                continue;
            if (idx % 2 == 0 && c == 'R')
            {
                Console.WriteLine("No");
                return;
            }
            if (idx % 2 == 1 && c == 'L')
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");

    }

    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 11220
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        mod = 4 * h * n - N * (h + n)
        if mod > 0:
            w, r = divmod(N * h * n, mod)
            if r == 0:
                print(h, n, w)
                exit()

Measured memory_bytes: 3060
import bisect
sn, tn, qn = map(int, input().split())

LARGE = -100000000
sa = []
ta = []
qa = []
for i in range(sn):
    sa.append(int(input()))
for i in range(tn):
    ta.append(int(input()))
for i in range(qn):
    qa.append(int(input()))

def find_nearest(q, al, s, e):
    idx = bisect.bisect_right(al, q)
    if idx == 0:
        return [al[0], al[0]]
    if idx == len(al):
        return [al[idx - 1], al[idx - 1]]
    return [al[idx - 1], al[idx]]

def move_cost(q, al, bl):
    a1, a2 = find_nearest(q, al, 0, len(al) - 1)
    b1, b2 = find_nearest(q, bl, 0, len(bl) - 1)

    def calc(x1, x2, x3):
        y1 = min(x1, x2)
        y2 = max(x1, x2)
        if x3 >= y1 and x3 <= y2:
            return abs(x1 - x2)
        return abs(x1 - x2) + abs(x2 - x3)
    return min(
        calc(q, a1, b1),
        calc(q, a1, b2),
        calc(q, a2, b1),
        calc(q, a2, b2),
        calc(q, b1, a1),
        calc(q, b1, a2),
        calc(q, b2, a1),
        calc(q, b2, a2),
    )

for q in qa:
    print(move_cost(q, sa, ta))

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

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

set<char> st={'A','C','G','T'};

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size(), ret=0;
	for (int i=0; i<n; i++) {
		for (int j=i; j<n; j++) {
			int cur=0;
			for (int k=i; k<=j; k++) {
				if(!st.count(s[k])) {
					cur=-1; break;
				}
				cur++;
			}
			ret=max(ret,cur);
		}
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
N, M = gets.split(' ').map(&:to_i)
ab = Hash.new()
M.times do
  a, b = gets.split(' ').map(&:to_i)
  ab[a] ||= []
  ab[a] << b
end

ans = 'IMPOSSIBLE'
ab[1].each do |to|
  if to == N
    ans = 'POSSIBLE'
    break
  end

  next if ab[to] == nil

  ab[to].each do |t|
    if t == N
      ans = 'POSSIBLE'
      break
    end
  end
end

print ans

Measured memory_bytes: 19452
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    vector<char> chrs={'M','A','R','C','H'};
    ll n;
    cin>>n;
    vector<ll> v(5, 0); // index -> num'of element
    rep(i,0,n){
        string s;
        cin>>s;
        rep(j,0,5) if(s[0]==chrs[j]) v[j]++;
    }

    // v:
    //      1 1 1 1
    //      2 2 2
    //      3 3
    //      4 4 4
    //      5 5

    ll ans=0;
    rep(i,0,5) rep(j,i+1,5) rep(k,j+1,5) ans += v[i]*v[j]*v[k];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = ["."*(W+2)]
for _ in range(H):
    a = input().strip()
    a = "."+a+"."
    S.append(a)
S.append("."*(W+2))
flag = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=="#":
            if S[i][j+1]=="." and S[i-1][j]=="." and S[i][j-1]=="." and S[i+1][j]==".":
                flag = 1
                break
    if flag==1:break
if flag==0:
    print("Yes")
else:
    print("No")

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

int main () {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> vec(N);
  for (int i; i < N; i++) cin >> vec.at(i);
  int mindiff = 100000000;
  int minindex;
  for (int i; i < N; i++) {
    int tempdiff = abs(T * 1000 - vec.at(i) * 6 - A * 1000);
    if (tempdiff <= mindiff) {
      mindiff = tempdiff;
      minindex = i;
    }
  }
  cout << minindex + 1 << endl;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
ans=0
a=X[0]
for i in range(1,N):
  if (X[i]-a)*A<B:
    ans+=(X[i]-a)*A
  else:
    ans+=B
  a=X[i]
print(ans)

Measured memory_bytes: 20060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

void Pfact(lint num, vector<int> &divisor) {
	vector<pair<lint, int>> res;
	for (lint i = 2; i * i <= num; i++) {
		int cnt = 0;
		while (num % i == 0) {
			cnt++;
			num /= i;
		}
		if (cnt) divisor[i] +=cnt;
	}
	if (num != 1) divisor[num]++;
}

class Combi {
private:
	vector<lint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

public:
	Combi(int N = 10000) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	lint Cmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	lint Pmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n - k] % MOD;
	}
};

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> divisor(101);
	for (int i = 2; i <= N; i++) Pfact(i, divisor);

	int rng1_2 = 0, rng2_4 = 0, rng4_14 = 0, rng14_24 = 0, rng24_74 = 0, rng74_ = 0;

	for (const auto &elem : divisor) {

		if ( 2 <= elem && elem <  4) rng2_4++;
		if ( 4 <= elem && elem < 14) rng4_14++;
		if (14 <= elem && elem < 24) rng14_24++;
		if (24 <= elem && elem < 74) rng24_74++;
		if (74 <= elem             ) rng74_++;

	}

	int ans = 0;
	Combi C;
	int rng4_ = rng4_14 + rng14_24 + rng24_74 + rng74_;
	int rng14_ = rng4_ - rng4_14;
	
	ans += rng2_4 * C.Cmod(rng4_, 2) + C.Cmod(rng4_, 3) * 3;
	ans += rng4_14 * rng14_ + C.Pmod(rng14_, 2);
	ans += (rng2_4 + rng4_14 + rng14_24) * (rng24_74 + rng74_) + C.Pmod(rng24_74 + rng74_, 2);
	ans += rng74_;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;

  int l[n];
  for(int i = 0; i < n; i++) cin >> l[i];

  int ans = 1, d = 0;
  for(int i = 2; i <= n+1; i++) {
    if(d + l[i-2] <= x) ans++;
    d = d + l[i-2];
  }

  cout << ans << endl;
}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (ll)1e12
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n,k;
	cin>>n>>k;
	int h[n];
	fr(i,0,n)
	cin>>h[i];
	ll dp[n];
	fr(i,0,n)
	dp[i]=INF;
	dp[0]=0;
	fr(i,0,n-1)
	fr(j,i+1,min(i+k+1,n))
	dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
	cout<<dp[n-1]<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 4772
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const long long INF = -1e18;


int a[200010];
long long f[200010], g[200010];
long long s[200010][2];
int n;

long long dfs1(int x) {
    if(x > n) return 0;
    if(g[x] > INF) return g[x];
    long long r1, r2;
    r1 = a[x] + dfs1(x + 2);
    r2 = s[x + 1][(x + 1) % 2];
    g[x] = max(r1, r2);
    return g[x];
}

long long dfs(int x) {
    if(x > n) return 0;
    if(f[x] > INF) return f[x];
    long long r1, r2, r3;
    r1 = a[x] + dfs(x + 2);
    r2 = a[x + 1] + dfs1(x + 3);
    r3 = s[x + 2][x % 2];
    f[x] = max(f[x], r1);
    f[x] = max(f[x], r2);
    f[x] = max(f[x], r3);
    return f[x];
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        f[i] = g[i] = -1e18;
    }
    for(int i = n; i >= 1; i--) {
        s[i][0] = s[i + 1][0];
        s[i][1] = s[i + 1][1];
        s[i][i % 2] = s[i + 1][i % 2] + a[i];
    }
    if(n % 2 == 0) {
        printf("%lld\n", dfs1(1));
    } else {
        printf("%lld\n", dfs(1));
    }

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 700;
    rep(i,s.size()) {
        if (s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}


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

int main() {
    int N, W, H;
    cin >> N >> W >> H;
    vector<int> v(W+1, 0);
    vector<int> v2(H+1, 0);
    for(int i=0; i<N; ++i) {
        int x, y, w;
        cin >> x >> y >> w;
        v2[max(0, y-w)] += 1;
        v[max(0, x-w)] += 1;
        if(x+w < W) {
            v[x+w]--;
        }
        if(y+w < H) {
            v2[y+w]--;
        }
    }

    bool ok1 = true;
    for(int i=0; i<v.size(); ++i) {
        if(i > 0) {
            v[i] += v[i-1];
        }
        ok1 &= (v[i] > 0);
    }
    bool ok2 = true;
    for(int i=0; i<v2.size(); ++i) {
        if(i > 0) {
            v2[i] += v2[i-1];
        }
        ok2 &= (v2[i] > 0);
    }

    cout << (ok1 || ok2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))


list = [0] * (n-1)

ans = 0

for i in range(n):
    if a[i] + n - 1 - i > 0 and a[i] + n - 1 - i < n-1:
        ans += list[a[i] + n - 1 - i ]
    if a[i] < n - 1 - i: 
        list[n - 1 - a[i] - i] += 1

print(ans)

Measured memory_bytes: 92840
package main

import (
	"fmt"
)

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

func solve(s, t string) int {
	ans := len(t)
	
	for i := 0; i <= len(s) - len(t); i++ {
		diff := 0
		for j := 0; j < len(t); j++ {
			if t[j] != s[i+j] {
				diff++
			}
		}
		
		ans = min(ans, diff)
	}
	
	return ans
}

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	result := solve(s, t)
	fmt.Println(result)
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll fact[50];
#define eps 1e-9
#define INF 1e18
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=ans*a%c;
    }
    a=a*a%c;
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll z=fact[n];
    z=z*power(fact[r],mod-2,mod)%mod;
    z=z*power(fact[n-r],mod-2,mod)%mod;
    return z;
}
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n; cin>>n;
   long long sum=0;
   for(int i=1;i<=n;++i){
    if(i%3==0||i%5==0)continue;
    sum+=(ll)i;
   }
   cout<<sum;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    vector<pair<ll,ll>> p;
    sort(a,a+n);
    ll c=1;
    for (ll i=1;i<n;i++){
        if (a[i-1]==a[i]){
            c++;
        }else{
            p.push_back(make_pair(c,a[i-1]));
            c=1;
        }
    }
    p.push_back(make_pair(c,a[n-1]));
    sort(p.begin(),p.end(),pairCompare);
    if (p.size()<=k){
        cout << 0 << endl;
        return 0;
    }
    for (ll i=0;i<p.size()-k;i++){
        ans+=p[i].first;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7792
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int array[] = new int [q];
		for(int i = 0;i < q;i++){
			array[i] = sc.nextInt() - 1;
		}
		int countarray[] = new int [n];

		for(int i = 0;i < q;i++){
				countarray[array[i]]++;
		}
		for(int i = 0;i < n;i++){
			if((k - q + countarray[i]) > 0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 61552
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[n],sum=0,max=0;
    for(int i = 0; i<n ; i++)
    {
        cin >> p[i];

        if(max < p[i])
        {   sum += max;
            max = p[i];
            continue;
        } 
        sum += p[i];

    }
    max /= 2;
    printf("%d\n",max+sum);
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define testcase int t;cin>>t;while(t--)
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define P pair<int,int>
/*bool isprime(lli n)
{
    if(n==1) return 0;
    for(lli i=2;i<=n/2;i++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}
bool issemiprime(lli n)
{
    for(int i=2;i<n;i++)
    {
        if(isprime(i)&&isprime(n/i)&&n%i==0&&i!=n/i){
            return 1;
        }
    }
    return 0;
}
lli extendedgcd(lli q,lli r1,lli r2,lli r,lli s1,lli s2,lli s,lli t1,lli t2,lli t)
{
if(r2==0) return r1;
	r1=r2;
        r2=r;
        s1=s2;
        s2=s;
        t1=t2;
        t2=t;
        q=r1/r2;
        r=r1%r2;
        s=s1-(s2*q);
        t=t1-(t2*q);
return extendedgcd(q,r1,r2,r,s1,s2,s,t1,t2,t);
}
lli gcd(lli a,lli b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
void SOE()
{
    for(lli i=2;i<=100000;i++)
    {
        if(sieve[i]) continue;
        for(lli x=i;x<=100000;x+=i)
        {
            sieve[x]+=1;
        }
    }
}*/
/*bool func(pair<int,int> a,pair<int,int> b)
{
    return a.first<b.first;
}*/
int n,a[1000000][3];
int dp[1000000][3];
int func(int i,int j)
{
    if(i==n) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if(i==0){
        dp[i][0]=a[i][0]+max(func(i+1,1),func(i+1,2));
        dp[i][1]=a[i][1]+max(func(i+1,0),func(i+1,2));
        dp[i][2]=a[i][2]+max(func(i+1,0),func(i+1,1));
    }
    else if(j==0)
    {
        dp[i][j]=a[i][j]+max(func(i+1,1),func(i+1,2));
    }
    else if(j==1)
    {
        dp[i][j]=a[i][j]+max(func(i+1,0),func(i+1,2));
    }
    else if(j==2)
    {
        dp[i][j]=a[i][j]+max(func(i+1,0),func(i+1,1));
    }
    return dp[i][j];
}
void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    int maxi=func(0,0);
    maxi=max(maxi,dp[0][1]);
    maxi=max(maxi,dp[0][2]);
    cout<<maxi;
}
int main()
{
    fast_io;
    solve();
}


Measured memory_bytes: 24272
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>

//const ll modd = 998244353;
const ll inf = 1e18;

int n;
ll arr[3002];
ll dp[3002][3002][2];

double solve(int l, int r, int ch){
    if(l>r) return 0;
    //if(l==r) return arr[l];

    if(dp[l][r][ch]!=-1) return dp[l][r][ch];

    if(ch == 0){
        ll ans = arr[l]+solve(l+1, r, ch^1);
        ll ans1 = arr[r]+solve(l, r-1, ch^1);
        return dp[l][r][ch] = max(ans, ans1);

    }

    ll ans = solve(l+1, r, ch^1)-arr[l];
    ll ans1 = solve(l, r-1, ch^1)-arr[r];
    return dp[l][r][ch] = min(ans, ans1);

}

int main(){
	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    cin>>n;

    for(int i=0;i<3002;i++){
        for(int j=0;j<3002;j++){
            dp[i][j][0] = dp[i][j][1] = -1;
        }
    }
    for(int i = 0;i < n; i++){
        cin>>arr[i];
    }

    ll ans = solve(0,n-1,0);

    cout<<ans<<'\n';

	return 0;
}



Measured memory_bytes: 141440
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;

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

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0, temp;

	for (int i = 1; i <= n; i++) {
		temp = (i/10000) + ((i%10000) / 1000) + ((i % 1000) / 100) + ((i % 100) / 10) + ((i % 10));
		//cout << "temp" << temp << endl;
		if (a <= temp && temp <= b) ans += i;
	}

	cout << ans << endl;
	//system("pause");

	return 0;
}

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

int main(){
string S;
  cin>>S;
  
  int count0=0, count1=0;
  for(int i=0; i<S.size(); i++){
   if(S[i]=='0'){count0++;}
   if(S[i]=='1'){count1++;} 
  }// 0と1をどんな順序で並べても、最終的には0か1の小さい方の個数分キューブが取り除かれる事になる
  // 一度に取り除かれるキューブは2個のため、答えはansの式になる
  int ans=2*min(count0, count1);
  
  cout<<ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}

int main(){
    int n; cin >> n;
    ll INF = INT_MAX;
    vector<vector<ll>> cood(101, vector<ll>(101,INF));
    vector<pair<ll,pair<int,int>>> hxy(n);
    rep(i,n){
        int x,y; cin >> x >> y;
        ll h; cin >> h;
        hxy[i] = make_pair(h, make_pair(x,y));
    }
    sort(hxy.begin(), hxy.end(),
    [](auto const &a, auto const &b) -> bool{
        return a.first > b.first; 
    }
    );
    rep(i,n){
        int x = hxy[i].second.first, y = hxy[i].second.second;
        ll h = hxy[i].first;
        if(h == 0){
            rep(jx,101)rep(jy,101){
                if(cood[jx][jy] == -1)continue;
                if(cood[jx][jy] == INF)continue;
                else if(cood[jx][jy] - abs(jx - x) - abs(jy - y) > 0){
                    cood[jx][jy] = -1;
                }
            }  
        }
        else{
            rep(jx,101)rep(jy,101){
                if(cood[jx][jy] == -1)continue;
                ll temp = h + abs(jx - x) + abs(jy - y);
                if(cood[jx][jy] == INF)cood[jx][jy] = temp;
                else if(cood[jx][jy] != temp)cood[jx][jy] = -1;
            }
        }
    }
    // vector<ll> res;
    rep(ix,101)rep(iy,101){
        if(cood[ix][iy] != -1 && cood[ix][iy] != INF){
            print(ix,iy,cood[ix][iy]);
        }
    }
    // for(auto i : res)cout << i << endl;
    return 0;
}

Measured memory_bytes: 384