akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N;
  cin >> N;
  ll ans = 1e8;
  vector<ll> six(0), nine(0);
  int tmp = 1;
  while (true) {
    six.push_back(tmp);
    tmp *= 6;
    if (N < tmp) break;
  }
  tmp = 1;
  while (true) {
    nine.push_back(tmp);
    tmp *= 9;
    if (N < tmp) break;
  }
  reverse(six.begin(), six.end());
  reverse(nine.begin(), nine.end());
  for (int i = 0; i <= N; i++) {
    // i==6^nで支払う金額
    ll cnt = 0;
    ll a = i, b = N - i;
    int j = 0;
    while (a > 0) {
      while (six[j] <= a) {
        cnt++;
        a -= six[j];
      }
      j++;
    }
    j = 0;
    while (b > 0) {
      while (nine[j] <= b) {
        cnt++;
        b -= nine[j];
      }
      j++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

void solve()
{
    int n;
    cin>>n;
    vector<int >a(n);
    int c1=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k])
                {
                    vector <int>b(3);
                    b[0]=a[i];
                    b[1]=a[j];
                    b[2]=a[k];
                    sort(b.begin(),b.end());
                    if(b[0]+b[1]>b[2])c1++;
                }
            }
        }
    }
    /*if(c1==0)
        cout<<-1<<endl;
    else*/
        cout<<c1<<endl;

}

int main()
{
    solve();
    /*int t;
    cin>>t;

    while(t--)
    {

    }*/
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, M, K;
    cin >> N >> M >> K;

    bool ok = false;
    for(int i=0;i<=N;i++){
    	for(int j=0;j<=M;j++){
    		if(K == i*(M-j) + (N-i)*j) ok = true;
    	}
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int vis[101];
int s[333333];
void gao(int l,int r,int A,int B)
{
	int i,pl,pl2;
	int mid=l+r>>1;
	if(l==r)
		return;
	for(i=0;i<n;i++)
	{
		if(vis[i])
			continue;
		if(((1<<i)&A)!=((1<<i)&B))
			break;
	}
	pl=i;
	vis[pl]=1;
	if((1<<i)&B)
	{ 
		for(i=mid+1;i<=r;i++)
			s[i]^=(1<<pl);
	}
	else
	{
		for(i=l;i<=mid;i++)
			s[i]^=(1<<pl);
	}
	for(i=0;i<n;i++)
		if(!vis[i])
			break;
	pl2=i;
	gao(l,mid,A,A^(1<<pl2));
	gao(mid+1,r,A^(1<<pl2),B);
	vis[pl]=0;
}
int main()
{
	int A,B,i;
	scanf("%d",&n);
	scanf("%d%d",&A,&B);
	if(__builtin_popcount(A^B)%2==0)
	{
		puts("NO");
		return 0;
	}
	gao(1,1<<n,A,B);
	puts("YES");
	for(i=1;i<=(1<<n);i++)
	{
		printf("%d ",s[i]);
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H==0 && W==0){
        break;
      }else{
        for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
            if(i==0 || i==H-1 || j==0 || j==W-1){
              System.out.print("#");
            }else{
              System.out.print(".");
            }
          }
          System.out.println();
        }
        System.out.println();
      }
    }
  }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B >  C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
def f(h):
    th = [i-1 for i in h]
    ret = 1
    spl = []
    for i in range(len(th)):
        if i == 0 and th[i] != 0:
            spl.append(i)
        elif i != 0 and th[i-1] == 0 and th[i] != 0:
            spl.append(i)
        if i == len(th)-1 and th[i] != 0:
            spl.append(i+1)
        elif i != 0 and th[i-1] != 0 and th[i] == 0:
            spl.append(i)
    for i in range(0,len(spl),2):
        ret += f(th[spl[i]:spl[i+1]])
            
    return ret
    


n = int(input())
h = [int(x)+1 for x in input().split()]

print(f(h)-1)

Measured memory_bytes: 3188
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<stdlib.h>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long LL;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define mxN (int) 2e5 + 2
#define MP make_pair

int main()
{
    LL a, b;
    cin >> a >> b;
    cout << (a * (a - 1) / 2) + (b * (b - 1) / 2) << endl;

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    vector<string> s({"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"});
    string t;
    cin >> t;
    rep(i, sz(s)) {
        if (s[i] == t) {
            cout << 7 - i << endl;
            return;
        }
    }
}


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

using namespace std;

class UnionFind {
  vector<int> graph_;
  vector<int> sizes_;

 public:
  UnionFind(int n) : sizes_(n, 1), graph_(n) {
    for (int i = 0; i < n; ++i) {
      graph_[i] = i;
    }
  };

  int Root(int key) {
    if (graph_[key] == key) {
      return key;
    } else {
      return graph_[key] = Root(graph_[key]);
    }
  }

  bool Same(int key1, int key2) { return Root(key1) == Root(key2); }

  void Unite(int key1, int key2) {
    if (Same(key1, key2)) {
      return;
    }

    int root1 = Root(key1);
    int root2 = Root(key2);
    int size = Size(root1) + Size(root2);
    graph_[root1] = root2;
    sizes_[root2] = size;
  }

  int Size(int key) {
    int root = Root(key);
    return sizes_[root];
  }
};

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  UnionFind uf(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.Unite(a, b);
  }

  int sz = 0;
  for (int i = 0; i < n; ++i) {
    if (uf.Root(i) == i) {
      sz++;
    }
  }

  cout << sz - 1 << '\n';
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

int pref[maxn], suf[maxn];

void solve() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n ;i++){
        cin >> v[i];
    }

    for(int i = 0; i < n; i++)pref[i + 1] = __gcd(v[i], pref[i]); 
    for(int i = n; i > 0; i--)suf[i] = __gcd(v[i - 1], suf[i + 1]); 

    int mx = pref[n];
    for(int i = 1; i <= n; i++){
        if(mx < __gcd(pref[i - 1], suf[i + 1]))
            mx = __gcd(pref[i - 1], suf[i + 1]);
    }
    cout << mx << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 2560
from collections import deque
n, k = map(int, input().split())
inf = pow(10, 9)+7

tree = [[] for _ in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

not_yet = deque(tree[0])
already = [False]*n
already[0] = True
ans = k
key = k-1
for v in tree[0]:
  already[v] = True
  ans *= key
  ans %= inf
  key -= 1

while not_yet:
  key = not_yet.popleft()
  for v in range(k-2, k-1-len(tree[key]), -1):
    ans *= v
    ans %= inf
  
  for value in tree[key]:
    if already[value]:
      continue
    not_yet.append(value)
    already[value] = True

print(ans)

Measured memory_bytes: 24024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

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

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

int main(void) {


	int N,K;
	INPUT(N);
	INPUT(K);
	vector<ll> h(N);
	vector<ll> dp(N,INF);
	REPEAT(i,N)INPUT(h[i]);

	for(int i=0;i<min(K,N);i++){
		dp[i] = abs(h[0]-h[i]);
//		OUTPUT(dp[i]);
	}
	
	if( K < N ){
		for(int i=K;i<N;i++){
			for(int j=1;j<=K;j++)ChangeMinimum( dp[i], dp[i-j] + abs(h[i-j]-h[i]) );
//		OUTPUT(dp[i]);
		}
	}
	int ans = dp[N-1];

	OUTPUT(ans);
		
}

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

int main (){
    int x;
    cin >> x;
    int a = x/100;
    int b = x-100*a;
    int c = (b+4)/5;
    if(c <= a){
        cout << 1;
        return 0;
    }
    cout << 0;
    return 0;
}


Measured memory_bytes: 256
_n,_k = map(int,input().split())
_s = input()
_w=[]
if _s[0]=='0':
    _w.append(0)
ps=''
for s in _s:
    if ps==s:
        _w[-1]+=1
    else:
        _w.append(1)
        ps=s
if ps=='0':
    _w.append(0)
lw=len(_w)
wsum=sum(_w[0:(2*_k+1)])
wsum_max=wsum
for j in range(0,lw,2):
    if j+2*_k+1>=lw:
        break
    wsum-=_w[j]
    wsum-=_w[j+1]
    wsum+=_w[j+2*_k+1]
    wsum+=_w[j+2*_k+2]
    if wsum_max<wsum:
        wsum_max=wsum
print(wsum_max)


Measured memory_bytes: 4596
use std::io::*;
use std::str::FromStr;
use std::char::*;
use std::cmp::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;

fn main(){
    let n:u32 = read();
    let s:Vec<char> = read::<String>().chars().collect();
    for i in 0..n {
        let i = i as usize;
        if s[..i] == s[i..] {
            println!("Yes");
            return ();
        }
    }

    println!("No");
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  vector<int>a(5);
  int mini=9;
  int k=0,sum=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(a[i]%10){
      if(a[i]%10<=mini){
        mini=a[i]%10;
        k=i;
      }
    }
  }
  for(int i=0;i<5;i++){
    if(i==k)
      sum=sum+a[i];
    else
      sum=sum+((9+a[i])/10)*10;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef pair<pint, int> ppint;
typedef pair<int, pint> pintp;
typedef unsigned int uint;
typedef long long llint;
typedef unsigned long long int ullint;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const int INF = 100000000;

//clear memory
#define clear(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main() {
	static int n;
	while(true) {
		cin >> n;
		if(n == 0)
			break;
		int ans = 0;
		for(int i = 0; i < n / 4; i++) {
			static int t;
			cin >> t;
			ans += t;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

string line;

inline bool isOp(char c) {
  return c == '+' || c == '-' || c == '*' || c == '/';
}

set<int> rec(int l, int r) {
  vector<int> v;
  for(int i = l, j = 0; i < r; ++i) {
    if(line[i] == '(') ++j;
    if(line[i] == ')') --j;
    if(j == 0 && isOp(line[i])) v.push_back(i);
  }

  if(v.size() == 0) {
    if(line[l] == '(') return rec(l+1, r-1);
    set<int> res;
    res.insert(atoi(line.substr(l,r-l).c_str()));
    return res;
  }

  set<int> res;
  for(int i = 0; i < v.size(); ++i) {
    set<int> a, b;
    a = rec(l, v[i]);
    b = rec(v[i]+1, r);
    for(set<int>::iterator p = a.begin();
        p != a.end(); ++p) {
      for(set<int>::iterator q = b.begin();
          q != b.end(); ++q) {
        if(line[v[i]] == '+') {
          res.insert(*p + *q);
        } else if(line[v[i]] == '-') {
          res.insert(*p - *q);
        } else if(line[v[i]] == '*') {
          res.insert(*p * *q);
        } else if(line[v[i]] == '/') {
          if(*q != 0) res.insert(*p / *q);
        }
      }
    }
  }
  return res;
}

int main() {
  while(getline(cin, line) && line != "#") {
    cout << rec(0, line.size()).size() << endl;
  }
  return 0;
}

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

using namespace std;

int mod = 1e9 + 7;

int find(int a, vector<int>& group) {
    while (a != group[a]) {
        a = group[a];
    }
    return a;
}

void unite(int group_a, int group_b, vector<int>& group, vector<int>& rank) {
    if (rank[group_a] < rank[group_b]) swap(group_a, group_b);
    group[group_b] = group_a;
    rank[group_a] += rank[group_b];
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // N-1 -(built edges)
    int N, M, a, b;
    cin >> N >> M;
    vector<int> group(N + 1);
    for (int i = 0; i <= N; i++) {
        group[i] = i;
    }
    vector<int> rank(N + 1, 0);
    int ans = N - 1;
    for (int j = 0; j < M; j++) {
        cin >> a >> b;
        int group_a = find(a, group), group_b = find(b, group);
        if (group_a != group_b) {
            ans--;
            if (ans == 0) {
                cout << 0;
                return 0;
            }
            unite(group_a, group_b, group, rank);
        }
    }
    cout << ans;

    return 0;
}

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


namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
            
        }
    }
}

Measured memory_bytes: 17372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e3 + 5, mod = 1e9 + 7;

ll a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    for(int i = 0; i < N; i++){
        a[i] = pow(i, 5);
    }
    int n;
    cin >> n;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(a[i] - a[j] == n){
                return cout << i << ' ' << j, 0;
            }
            else if(a[i] + a[j] == n){
                return cout << i << ' ' << -j, 0;
            }
        }
    }

    return 0;

}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {

	int n, a, b;
	cin >> n >> a >> b;

	if (a + b > n + 1) {
		cout << -1 << endl;
		return 0;
	}


	VI v;

	int m = n;

	int k = n - a;
	REP(i, a) {
		int x = min(b - 1, k) + 1;
		REP(j, x)v.push_back(m - x + 1+j);
		k -= x - 1;
		m -= x;
	}

	reverse(ALL(v));

	if (v.size() < n) {
		cout << -1 << endl;
		return 0;
	}

	REP(i, n)cout << v[i] << ' ';

	

}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<string,int> map;
    int mx=0;
    while(n--)
    {
        string s;
        cin>>s;
        map[s]++;
        if(map[s]> mx)
            mx=map[s];
    }
    for(auto x : map)
    if(mx==x.second)
        cout << x.first <<  endl;
    return 0;
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int s, t ;
  t  =( H2 * 60 + M2 ) -  (H1 * 60 + M1);
  s = t - K;
  cout << s << endl;
  return 0;
}

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

int main() {
	int setN;
	int gx,gy;
	int mN;
	int mX1[200],mY1[200],mX2[200],mY2[200];
	long long int ans;

	cin >> setN;

	for (int i=0;i<setN;i++) {
		cin >> gx >> gy;
		cin >> mN;
		if(mN == 0) {
			ans = 1;
			for(int j=1;j<gx+1;j++) {
				ans = ans*(gx+gy-j+1)/j;
				//cout << ans <<endl;
			}
			cout << ans <<endl;

		} else {
			for (int j=0; j<mN; j++) {
			cin >> mX1[j] >> mY1[j];
			cin >> mX2[j] >> mY2[j];
		}
			int Vert[30][30] = {};
			int Horiz[30][30] = {};
			int T[30][30] = {};
			for (int j=0;j<mN;j++) {
				if(mX1[j] == mX2[j]) {
					Horiz[mX1[j]][max(mY1[j],mY2[j])] = 1;
				} else if(mY1[j] == mY2[j]) {
					Vert[max(mX1[j],mX2[j])][mY1[j]] = 1;
				}
			}
			for (int j=0;j<30;j++){
				T[0][j] = 0;
				T[j][0] = 0;
				T[1][1] = 1;
			}
			for (int j=1;j<30;j++) {
				for (int l=1;l<30;l++) {
					if ((j != 1) || (l!= 1)) {
						if ((Vert[j-1][l-1] == 0) && (Horiz[j-1][l-1] == 0)) {
							T[j][l] = T[j][l-1] + T[j-1][l];
						}
						if ((Vert[j-1][l-1] == 0) && (Horiz[j-1][l-1] == 1)) {
							T[j][l] = T[j-1][l];
						}
						if ((Vert[j-1][l-1] == 1) && (Horiz[j-1][l-1] == 0)) {
							T[j][l] = T[j][l-1];
						}
						if ((Vert[j-1][l-1] == 1) && (Horiz[j-1][l-1] == 1)) {
							T[j][l] = 0;
						}
					}

				}
			}
			
			/*
			for (int j=0;j<15;j++) {
				cout << endl;
				for (int k =0;k<15;k++) {
					cout << Vert[j][k] << " ";
				}
			}
			cout << endl;
			for (int j=0;j<16;j++) {
				cout << endl;
				for (int k =0;k<16;k++) {
					cout <<Horiz[j][k] << " ";
				}
			}
			cout << endl;
			

			for (int j=0;j<16;j++) {
				cout << endl;
				for (int k =0;k<16;k++) {
					cout << T[j][k] << " ";
				}
			}
			*/

			if(T[gx-1][gy-1] == 0) {
				cout << "Miserable Hokusai!" << endl;
			} else {
				cout << T[gx+1][gy+1] << endl;
			}



		}


	}
}

/*
???????????????1??????????????????????????????????????????????????¨????????????????????£??????
?????????????´???°????¶???§??°?????£????????????????????£????????§?¬???\?????????????°????????£?????????¨?????¨?????????
*/

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

int main(int argc, char *argv[]) {
  std::string s;
  
  std::cin >> s;

  // 見つからない。または複数個ある場合はNo
  if (s.find('a') == std::string::npos || s.find('a') != s.rfind('a') ||
      s.find('b') == std::string::npos || s.find('b') != s.rfind('b') ||
      s.find('c') == std::string::npos || s.find('c') != s.rfind('c')) {
    std::cout << "No" << std::endl;
    return 0;
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + 11)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        s += i * dp[Y][i]
    print(int(s))

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = list(map(int, input().split()))
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

Measured memory_bytes: 10984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n;
ll ans, ansl2, ansr2, ansl, ansr, cnt, c2, c, a[100006], b[100005], v[100005], w[100005],
    dp[100005], dp2[100005];
int32_t main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> c;
    fox(l, n){
        cin >> a[l] >> v[l];
        b[n-1-l]=c-a[l];
        w[n-1-l]=v[l];
    }
    fox(l, n){
        cnt+=v[l];
        ansl=max(ansl, cnt-a[l]);
        ansl2=max(ansl2, cnt-a[l]-a[l]);
        if (l==n-1) continue;
        dp[n-1-l-1]=ansl;
        dp2[n-1-l-1]=ansl2;
    }
    ans=max(ans, ansl);
    fox(l, n){
        c2+=w[l];
        ansr=max(ansr, c2-b[l]);
        ansr2=max(ansr2, c2-b[l]-b[l]);
        ans=max(ans, max(ansr+dp2[l], ansr2+dp[l]));
    }
    cout << ans;
    return 0;
}


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


int main(){
  int D,G;
  int sum = 0;
  int count = 0;
  int minm = 10000;

  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);

  for(int i=0;i<D;++i){
    cin >> p.at(i) >> c.at(i);
  }

  for(int tmp=0;tmp <(1 << 10);++tmp){
    bitset<10> s(tmp);
    for(int i=0;i<D;++i){
      if(s.test(i)){
        sum += 100 *(i+1) * p.at(i) + c.at(i);
        count += p.at(i);
      }
    }
    if(sum < G){
      int j = D-1;
      while(j >= 0){
        if(! s.test(j)){
          for(int i=0;i<p.at(j);++i){
            sum += 100 *(j+1);
            count += 1;
            if(sum >= G) break;
          }
          break;
        }
        j -= 1;
      }
    }

    if(sum >= G){
      if(count < minm) minm = count;
    }
    sum = 0;
    count = 0;
  }
cout << minm << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N_MAX=300000;
int M_MAX=60;
int p=1000000007;
int main()
{
  int n,i,j;
  long long u,res=0;
  long long a[N_MAX],s[M_MAX],t1[M_MAX],t0[M_MAX];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  fill(s,s+M_MAX,0);
  fill(t1,t1+M_MAX,0);
  fill(t0,t0+M_MAX,0);
  for(i=n-2;i>=0;i--){
    u=a[i+1];
    for(j=0;j<M_MAX;j++){
      if(u%2==0) t0[j]++;
      else t1[j]++;
      u>>=1;
    }
    u=a[i];
    for(j=0;j<M_MAX;j++){
      if(u%2==0) s[j]+=t1[j];
      else s[j]+=t0[j];
      u>>=1;
    }
  }
  u=1;
  for(j=0;j<M_MAX;j++){
    res+=(u*(s[j]%p))%p;
    res%=p;
    u<<=1;
    u%=p;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

vector<int> values(100);

void go(int start, int end, int div) {
    for (int i = start; i < end; ++i) {
        ++values[i / div * 10 + i % 10];
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i *= 10) {
        go(i, min(n + 1, i * 10), i);
    }
    ll res = 0;
    for (int i = 11; i < 100; ++i) {
        int a = i / 10;
        int b = i % 10;
        res += values[b * 10 + a] * values[i];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

constexpr int mod = 1000000007;
struct ModInt {
    ll x;
    ModInt (ll a) : x((a % mod + mod) % mod) {}
    ModInt operator-() const {
        return ModInt(-x);
    }
    ModInt &operator+=(const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(ll t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/=(const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator<<(ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

constexpr int c_max = 200010;

int main() {
    int N;
    cin >> N;
    vector<int> C;
    rep(i, N) {
        int c;
        cin >> c;
        if (i) {
            if (c != C.back()) {
                C.push_back(c);
            }
        } else {
            C.push_back(c);
        }
    }
    vector<ModInt> dp;
    dp.push_back(ModInt{1});
    vector<int> MX(c_max, -1);
    MX[C[0]] = 0;
    REP(i, SZ(C)) {
        ModInt res = dp.back();
        if (MX[C[i]] != -1) res += dp[MX[C[i]]];
        dp.push_back(res);
        MX[C[i]] = i;
    }
    cout << dp.back() << "\n";
    return 0;
}


Measured memory_bytes: 6920
import sys
sys.setrecursionlimit(1<<30)
mod = 10**9+7
def inv(x):
    return pow(x,mod-2,mod)
def dfs_size(x):
    sizex = 1
    for y in edges[x]:
        if y != parent[x]:
            parent[y] = x
            sizex += dfs_size(y)
    size[x] = sizex
    return sizex
def dfs_dp(x):
    dpx = 1
    for y in edges[x]:
        if y != parent[x]:
            dpx *= dfs_dp(y)
            dpx *= inv_fac[size[y]]
            dpx %= mod
    dpx *= fac[size[x]-1]
    dpx %= mod
    dp[x] = dpx
    return dpx

def dfs_ans(x):
    ansx = 1
    if x != 1:
        for y in edges[x]:
            if y != parent[x]:
                ansx *= dp[y]
                ansx *= inv_fac[size[y]]
                ansx %= mod
            else:
                dpy = ans[y]
                dpy *= inv_fac[N-1]
                dpy *= fac[size[x]]
                dpy *= fac[N-size[x]-1]
                dpy *= inv(dp[x])
                dpy %= mod
                ansx *= dpy
                ansx *= inv_fac[N-size[x]]
                ansx %= mod
        ansx *= fac[N-1]
        ansx %= mod
        ans[x] = ansx
    for y in edges[x]:
        if y != parent[x]:
            dfs_ans(y)
N = int(input())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)
size = [0]*(N+1)
parent = [0]*(N+1)
dfs_size(1)
fac = [1]
for i in range(1,N+1):
    fac.append(fac[-1]*i % mod)
inv_fac = [inv(fac[N])]
for i in range(1,N+1)[::-1]:
    inv_fac.append(inv_fac[-1]*i % mod)
inv_fac = inv_fac[::-1]
dp = [0]*(N+1)
dfs_dp(1)
ans = [0]*(N+1)
ans[1] = dp[1]
dfs_ans(1)
for i in ans[1:]:
    print(i)

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

int main() {
  long N, M;
  cin >> N >> M;
  pair<long, long> pair[N];
  for(long i=0; i<N; i++){
    cin >> pair[i].first >> pair[i].second;
  }

  long money = 0;
  sort(pair, pair+N);

  for(long i=0; i<N; i++){
    long count = min(M, pair[i].second);
    money += pair[i].first*count;
    M -= count;
    if(M == 0) break;
  }

  cout << money << endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.Scanner;

public class Main {

   public static void main(String args[]) {

    Scanner scan = new Scanner(System.in);

     String l = scan.next();
	 String m =scan.next();     
	 String n = scan.next(); 
	     
    int a = Integer.parseInt(l);
    int b = Integer.parseInt(m);
    int h = Integer.parseInt(n);

    
          	   	 System.out.println(((a+b)*h)/2);
   
   }
   }
   

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, m, k;
  cin >> n >> m >> k;
  if(k == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  REP(row, n+1) {
    REP(col, m+1) {
      int black = n * col + m * row - (2 * col * row);
      if(black == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans=1e18;
int arr[200005];
long long pre[200005];
long long maxn(long long a,long long b)
{
	return a>b?a:b;
}
long long minx(long long a,long long b)
{
	return a<b?a:b;
}
int main()
{
	scanf("%d",&n);
	pre[0]=0;
	for(int i=1;i<=n;i++)
	    {
	    	scanf("%d",&arr[i]);
            pre[i]=pre[i-1]+(long long)arr[i];	    	
	    }    
	int L=0,R=2;    
	for(int i=2;i<=n-2;i++)
	    {
	    	while(pre[L]<pre[i]-pre[L])
	    	      L++;
	    	if(2*pre[L]-pre[i]>pre[i]-2*pre[L-1])
			   L--;
			while(pre[R]-pre[i]<pre[n]-pre[R])
	    	      R++;
	    	if(2*pre[R]-pre[i]-pre[n]>pre[n]+pre[i]-2*pre[R-1])
			   R--;
			long long s1=maxn(pre[L],pre[i]-pre[L]);
			long long s2=maxn(pre[n]-pre[R],pre[R]-pre[i]);
			long long s3=minx(pre[L],pre[i]-pre[L]);
			long long s4=minx(pre[n]-pre[R],pre[R]-pre[i]);
			long long mx=maxn(s1,s2);
			long long mn=minx(s3,s4);
			ans=minx(ans,mx-mn);            
	    }
	printf("%lld",ans);	    
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1510, mod = 998244353;
int n,pw[N*N],id[N],cnt[2];
char s[N][N];

inline void GG(){
	puts("0");exit(0);
}

struct Graph{
	int n,cnt,d[N];
	vector<int>e[N];
	inline void init(int _n){
		n=_n;
	}
	inline void Add(int x,int y,char z){
		if (z=='?') ++cnt,e[x].pb(y),e[y].pb(x);
		else if (z=='o') d[x]^=1,d[y]^=1;
	}
	poly v;
	bool vis[N];
	inline void dfs(int u){
		v.pb(u),vis[u]=1;
		for (auto v:e[u]) if (!vis[v]) dfs(v);
	}
	inline int solve(){
		if (n%2==0) return pw[cnt];
		int ans=1;
		For(i,1,n) if (!vis[i]){
			v.clear(),dfs(i);
			int cnt1=0,m=0;
			for (auto j:v) cnt1+=d[j],m+=siz(e[j]);
			if (cnt1&1) GG();
			ans=1ll*ans*pw[m/2-(siz(v)-1)]%mod;
		}
		return ans;
	}
}G[2];

int main(){
	n=read()-1;
	For(i,1,n) scanf("%s",s[i]+1);
	For(i,1,n)
		For(j,1,n) if (s[i][j]!='?'){
			if (s[j][i]=='?') s[j][i]=s[i][j];
			else if (s[j][i]!=s[i][j]) GG();
			if (s[n-i+1][n-j+1]=='?') s[n-i+1][n-j+1]=s[i][j];
			else if (s[n-i+1][n-j+1]!=s[i][j]) GG();
			if (s[n-j+1][n-i+1]=='?') s[n-j+1][n-i+1]=s[i][j];
			else if (s[n-j+1][n-i+1]!=s[i][j]) GG();
		}
	For(i,0,n+1) id[i]=++cnt[i&1];
	For(i,0,1) G[i].init(cnt[i]);
	For(i,1,(n+1)/2)
		For(j,i,n-i+1){
			G[(j-i)&1].Add(id[j-i],id[j+i],s[i][j]);
		//	printf("Add %d %d %d %c\n",(j-i)&1,id[j-i],id[j+i],s[i][j]);
		}
	pw[0]=1;
	For(i,1,max(G[0].cnt,G[1].cnt)) pw[i]=2ll*pw[i-1]%mod;
	printf("%d\n",1ll*G[0].solve()*G[1].solve()%mod);
}

Measured memory_bytes: 13736
#include <bits/stdc++.h>
 
#ifndef LOCAL
#define cerr dolor_sit_amet
#endif
 
#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
 
template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }
 
// ========================================================================= //
 
int main() {
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<vector<int>> sets(n - 1);
    vector<vector<int>> v2s(n);
    for (int i = 0; i < n - 1; ++i) {
        int s;
        cin >> s;
        sets[i].resize(s);
        for (int j = 0; j < s; ++j) {
            int x;
            cin >> x;
            --x;
            sets[i][j] = x;
            v2s[x].push_back(i);
        }
    }
 
    vector<int> pv(n, 0), ps(n - 1, -1);
    vector<char> visv(n, 0);
 
    function<bool(int)> dfs1 = [&](int v) {
        if (visv[v])
            return 0;
        visv[v] = 1;
        for (int nv : v2s[v])
            if (ps[nv] == -1 || dfs1(ps[nv])) {
                ps[nv] = v;
                return 1;
            }
        return 0;
    };
 
    while (true) {
        bool was = false;
        for (int i = 0; i < n; ++i)
            if (!pv[i]) {
                if (dfs1(i)) {
                    was = 1; pv[i] = 1; }
            }
        memset(visv.data(), 0, sizeof(char) * n);
        if (!was)
            break;
    }
 
    int root = -1;
    for (int i = 0; i < n; ++i)
        if (pv[i] == 0)
            root = i;
 
    vector<ipair> es(n - 1);
    int cnt = 0;
    function<void(int)> dfs = [&](int v) {
        visv[v] = true;
        for (int s : v2s[v]) {
            int nv = ps[s];
            if (nv == -1 || visv[nv])
                continue;
            es[s] = {v, nv};
            ++cnt;
            dfs(nv);
        }
    };
    dfs(root);
 
    if (cnt != n - 1) {
        cout << "-1\n";
        return 0;
    }
    for (ipair a : es)
        cout << a.X + 1 << " " << a.Y + 1 << "\n";
 
    return 0;
}


Measured memory_bytes: 20224
// new day,new strength,new thougts

#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=3e5+10;
const ll mod=998244353;

#pragma GCC Optimize("Ofast")

ll fac[maxn],ifac[maxn];

ll tavan(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2)	ans=(ans*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return ans;
}

void pre(){
	fac[0]=1;
	FOR(i,1,maxn-1)
		fac[i]=(fac[i-1]*i)%mod;
	ifac[maxn-1]=tavan(fac[maxn-1],mod-2);
	FORD(i,maxn-2,0)
		ifac[i]=(ifac[i+1]*(i+1))%mod;
}

inline ll C(ll n,ll k){
	if(n<k) return 0;
	return (((fac[n]*ifac[k])%mod)*ifac[n-k])%mod;
}

int main(){
	pre();
	ll n,a,b,k;cin>>n>>a>>b>>k;
	ll ans=0;
	FOR(i,0,n){
		ll num=k-(i*a);
		if(num<0)continue;
		if(num%b!=0)continue;
		ll j=num/b;
		ans=(ans+(C(n,i)*C(n,j)))%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 4992
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    int N,K;cin>>N>>K;
    vector<int> A(N+1,0);
    for (int i = 0; i < K; ++i) {
        int d;cin>>d;
        for (int j = 0; j < d; ++j) {
            int tmp; cin>>tmp;
            A[tmp]++;
        }
    }
    
    int ans = 0;

    for (int i = 1; i <= N; ++i) {
        if(A[i]==0) ans++;
    }

    cout<<ans<<endl;
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int maxn=31234;
char s[maxn];
int n;
int main()
{
    scanf("%d%s",&n,s);
    int res=0;
    for (char c1='0';c1<='9';++c1)
        for (char c2='0';c2<='9';++c2)
            for (char c3='0';c3<='9';++c3) {
                int now=0;
                for (int i=0;i<n;++i) {
                    if (now==0&&s[i]==c1) {
                        ++now;
                        continue;
                    }
                    if (now==1&&s[i]==c2) {
                        ++now;
                        continue;
                    }
                    if (now==2&&s[i]==c3) {
                        ++res;
                        break;
                    }
                }
            }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

template<class T>
T min(T a, T b) {
    return (a < b) ? a : b;
}

template<class T>
T max(T a, T b) {
    return (a > b) ? a : b;
}

int main() {
    int N, D;

    cin >> N >> D;

    cout << ceil((double)N/(2*D + 1));

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t,u;
int a,b; 
int main(){
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s){
		a--;
	}
	 else if(u==t){
		b--;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}



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

int eratos(int n) {
	int cnt = 0;
	vector<bool> is_prime(n+1,true);
	is_prime[0] = is_prime[1] = false;
	for (auto i = 2; i <= n; i++) {
		if (is_prime[i]) {
			++cnt;
			for (auto j = 2*i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	return cnt;
}

int main() {
	for (int n; cin>>n; cout<<eratos(n)<<endl);
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  map<int, int> mp;
  rep(i,n) mp[a[i]]++;

  int ans = 0;
  for (auto p : mp) {
    int x = p.first;
    int n = p.second;
    if (n > x) ans += n-x;
    else if (n < x) ans += n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8184