akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cassert>
#include<string>

using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2];


struct Puzzle{int f[N2],space,MD;};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0; i<N2; i++){
    if(pz.f[i] == N2) continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}



bool isSolved(){
  for(int i = 0; i<N2;i++)
    if(state.f[i] != i+1) return false;
  return true;
}


bool isTarget(Puzzle p){
  for(int i = 0; i<N2;i++){
    if(p.f[i] != (i+1)) return false;
  }
    return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth+state.MD>limit) return false;
  
  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;
  
  for(int r = 0; r<4;r++){
    int tx = sx+dx[r];
    int ty = sy+dy[r];
    if(tx<0||ty<0||tx>=N||ty>=N) continue;
    if(max(prev,r)-min(prev,r)==2) continue;
    tmp = state;
    state.MD -=MDT[tx*N+ty][state.f[tx*N+ty]-1];
    state.MD +=MDT[sx*N+sy][state.f[tx*N+ty]-1];
    swap(state.f[tx*N+ty],state.f[sx*N+sy]);
    state.space = tx*N+ty;
    if(dfs(depth+1,r)){
      path[depth] = r;
      return true;
    }
    state = tmp;
  }

  return false;
}

string iterative_deepening(Puzzle in){
  in.MD = getAllMD(in);

  for(limit = in.MD; limit<=LIMIT; limit++){
    state = in;
    if(dfs(0,-100)){
      string ans = "";
      for(int i = 0;i<limit;i++)
	ans += dir[path[i]];
      return ans;
    }
  }
  
  return "unsolvable";
}

int main(){
  for(int i = 0; i<N2;i++)
    for(int j = 0; j<N2;j++)
      MDT[i][j] = abs(i/N-j/N)+abs(i%N-j%N);

  Puzzle in;
  
  for(int i = 0; i<N2;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterative_deepening(in);
  cout<<ans.size()<<endl;

  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

int main() {
	cout.precision(20);
	ll N, K;
	cin >> N >> K;
	vector<ll>H(N);
	rep(N)cin >> H[i];
	sort(H.begin(), H.end());
	if(N<=K)
	{
		cout << 0;
		return 0;
	}
	ll c = 0;
	rep(N - K) {
		c += H[i];
	}
	cout << c;
}




Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
ll lcm(ll a,ll b)
{return a/gcd(a,b)*b;}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=1e18;
//------------------------------------------------------------
int X,N,ans;

void solve() {

  cin >> X >> N;

  vector<int> V(N);
  vector<int> V2(N);

  rep(i,0,N)
  {
    cin >> V[i];
    V2[i] = V[i]-X;
  }

  // find 0
  // if(find(all(V2), 0) == V2.end())
  // {
  //   print(X); return;
  // }

  int index = 0;
  while(true)
  {
    if(find(all(V2), -1*index) == V2.end())
    {
      print(X-index); return;
    }

    if(find(all(V2), index) == V2.end())
    {
      print(X+index); return;
    }
    ++index;
  }

  return;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int S;
ll dp[1005][2005], sum[1005][2005];

inline void solve()
{
    cin >> S;
    dp[0][0] = 1;
    for (int j = 0; j <= S; ++j)
        sum[0][j] = 1;
    // sum[0][0] = 1;
    for (int i = 1; i <= 670; ++i)
    {
        for (int j = 3 * i; j <= S; ++j)
        {
            dp[i][j] = sum[i - 1][j - 3];
            dp[i][j] %= MOD;
            // for (int k = 3; k <= j; ++k)
            // {
            //     dp[i][j] += dp[i - 1][j - k];
            //     dp[i][j] %= MOD;
            // }
        }
        for (int j = 1; j <= S; ++j)
            sum[i][j] = sum[i][j - 1] + dp[i][j] % MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= 670; ++i)
        ans += dp[i][S], ans %= MOD;
    cout << ans << '\n';
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 21660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    ll W;
    cin>>n>>W;
    vector<ll>w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    vector<vector<ll>>dp(n+1,vector<ll>(200005,INF));
    dp[0][0]=0;
    rep(i,n){
        rep(j,100001){
            if(j-v[i]<0)dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    for(int j=100000;j>=0;--j){
        if(dp[n][j]<=W){
            cout<<j<<"\n";
            return;
        }
    }
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 159744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0)continue;
		int tmp = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j==0)tmp++;
		}
		if (tmp == 8)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from math import sqrt, floor
from collections import deque
from functools import reduce
from operator import mul


def divide(p):
    global n, a, limit
    while not (n % p):
        a.add(p)
        n = n // p
        limit = floor(sqrt(n))


n, p = int(input()), 3
n0 = n
limit = floor(sqrt(n))
a, i = set(), 3

divide(2)

while p <= limit:
    divide(p)
    p += 2

if n > 1:
    a.add(n)

print(reduce(lambda prev, now: prev * (now - 1) // now, a, n0))

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N; cin>>N;
	vector<ll> A(N+1);
	map<ll,ll> m;
	rep1(i,N){
		cin>>A[i];
		m[A[i]]=0;
	}
	ll i=1;
	for(auto itr=m.bg;itr!=m.ed;itr++){
		itr->b=i++;
	}
	ll cnt=0;
	rep1(i,N){
		if(abs(m.find(A[i])->b-i)%2==1) cnt++;
	}
	cout<<(cnt+1)/2;
}

Measured memory_bytes: 7296
#include <cstdio>

const int N = 500 + 10;

int n, m, x, y, a[N][N];

int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  if (n % x == 0 && m % y == 0) {
    puts("No");
    return 0;
  }
  puts("Yes");
  a[0][0] = 999999999;
  a[x - 1][y - 1] = -1000000000;
  for (int i = 0; i < n; ++i, putchar('\n'))
    for (int j = 0; j < m; ++j)
      printf("%d ", a[i % x][j % y]);
  return 0;
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size; // size[i]:iがrootの時のメンバ数

    UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) size[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    int get_size(int x) {
        return size[root(par[x])];
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
  int N,M;
  cin >> N >> M;
  UnionFind uf(N);
  REP(i,M) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
  }
  int ans = 0;
  REP(i,N) {
    ans = max( ans, uf.get_size(i) );
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 11020
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;
struct edge { ll to, cost; };
std::vector<edge>v[100010], w[100010];
typedef std::vector<std::vector<int>>ma;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	std::string s;
	std::cin >> s;
	int flag = 0;
	for (int i = s.size() - 1;i > 5;) {
		if (s[i] == 'm') {
			if (s[i - 1] == 'a'&&s[i - 2] == 'e'&&s[i - 3] == 'r'&&s[i - 4] == 'd') {
				i -= 5;
			}
			else {
				flag = 1;
				break;
			}
		}
		else if (s[i] == 'e') {
			if (s[i - 1] == 's'&&s[i - 2] == 'a'&&s[i - 3] == 'r'&&s[i - 4] == 'e') {
				i -= 5;
			}
			else {
				flag = 1;
				break;
			}
		}
		else if (s[i] == 'r') {
			if (s[i - 1] == 'e'&&s[i - 2] == 'm'&&s[i - 3] == 'a'&&s[i - 4] == 'e'&&s[i - 5] == 'r'&&s[i - 6] == 'd') {
				i -= 7;
			}
			else if (s[i - 1] == 'e'&&s[i - 2] == 's'&&s[i - 3] == 'a'&&s[i - 4] == 'r'&&s[i - 5] == 'e') {
				i -= 6;
			}
			else {
				flag = 1;
				break;
			}
		}
		else {
			flag = 1;
			break;
		}
	}
	if (flag == 1) {
		std::cout << "NO" << std::endl;
	}
	else {
		std::cout << "YES" << std::endl;
	}
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), c(m, 0);
    REP(i, 0, m) {
        int b;
        cin >> a[i] >> b;
        REP(j, 0, b) {
            int t;
            cin >> t;
            c[i] |= (1 << (t - 1));
        }
    }

    const ll inf = 1LL << 60;
    auto dp = make_v(m + 1, 1 << n, inf);
    dp[0][0] = 0;
    REP(i, 0, m) {
        REP(j, 0, 1 << n) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    ll ans = dp[m][(1 << n) - 1];

    if (ans == inf) {
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);
    ll ans = 0;
    int pre = a[0];
    for (int i = 1; i < n; i++) {
        int dif = max(a[i-1] - a[i], 0);
        a[i] += dif;
        ans += dif;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,i,j,k,c=0;
        cin>>n;

        for(i=1;i<n;i++)
        {
            for(j=1;j<n;j++)
            {
                if(i*j<n)
                    c++;
                else
                    break;
            }

        }
        cout<<c<<endl;
    }

}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,P,ans=0;
  string s;
  cin>>s;
  set<char> se;
  rep(i,3)se.insert(s[i]);
  if(se.size()==1)printno;
  else printyes;
}

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

using namespace std;

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cout << fixed << setprecision(1);

    



      int a, p;
      cin >> a >> p;
      int total = a * 3 + p;
      cout << (total / 2) << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	a := stdin.ReadInt()
	b := stdin.ReadInt()

	for i := 0; i < 2000; i++ {
		if i*8/100 == a && i/10 == b {
			stdout.Println(i)
			return
		}
	}
	stdout.Println(-1)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <regex>
using namespace std;
typedef basic_regex<char>    regex;
int main(int argc,char const* argv[])
{
  int n;
  int index;
  double T,A;
  double H[1005];
  double ans=1000000.0;
  cin >> n;
  cin >> T >> A;
  for(int i=0;i<n;i++)
    {
      cin >> H[i];
    }
  for(int i=0;i<n;i++)
    {
      double tmp=T-H[i]*0.006;
      if(ans>fabs(A-tmp))
	{
	  ans=fabs(A-tmp);
	  index=i+1;
	}
    }
  cout << index <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    int rem,sum;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        int sum=a+b;
        int count=0;
        while(sum!=0)
        {
            rem=sum%10;
            count++;
            sum/=10;
        }
        printf("%d\n",count);
    }
return 0;
}

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

int main() {
	int q;cin>>q;
	bitset<64> bs(0);
	
	while(q--){
		int query,i;cin>>query;
		switch(query){
		case 0:
			// test(i)
			// iビット目が立っているか否かを判定する
			cin>>i;
			cout<<(bs.test(i)?1:0)<<endl;
			break;
		case 1:
			// set(i)
			// iビット目を立てる
			cin>>i;
			bs.set(i);
			break;
		case 2:
			// reset(i)
			// iビット目を0にする
			cin>>i;
			bs.reset(i);
			break;
		case 3:
			// flip(i)
			// iビット目を反転する
			cin>>i;
			bs.flip(i);
			break;
		case 4:
			// all(for all)
			// 任意のビットが立っているかを確認する
			cout<<(bs.all()?1:0)<<endl;
			break;
		case 5:
			// any(exists)
			// 立っているビットが存在するかを確認する
			cout<<(bs.any()?1:0)<<endl;
			break;
		case 6:
			// none
			// 任意のビットが0になっているかを確認する
			cout<<(bs.none()?1:0)<<endl;
			break;
		case 7:
			// count
			// 立っているビット数を出力する
			cout<<(bs.count())<<endl;
			break;
		case 8:
			// val
			cout<<(bs.to_ulong())<<endl;
			break;
		}
	}
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ans = K;
    rep(i, N) {
        if (i + 1 < N) {
            ans = min(ans, K - (A[i+1] - A[i]));
        } else {
            ans = min(ans, K - (K - A[i] + A[0]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1 << 30;
using Edges = vector<vector<pair<int, int>>>;


vector<int> bellman_ford(int r, const Edges &Es){
    vector<int> dist(Es.size(), INF);
    dist[r] = 0;
    for (int i = 0; i < Es.size(); ++i){
        for (int u = 0; u < Es.size(); ++u){
            if (dist[u] == INF) continue;
            for (const auto & edge : Es[u]){
                int v = edge.first;
                int cost = edge.second;
                if (dist[v] == INF or dist[u] + cost < dist[v]){
                    dist[v] = dist[u] + cost;
                }
            }
        }
    }
    for (int u = 0; u < Es.size(); ++u){
        if (dist[u] == INF) continue;
        for (const auto & edge : Es[u]){
            int v = edge.first;
            int cost = edge.second;
            if (dist[u] + cost < dist[v]){
                dist[r] = -1;
                return dist;
            }
        }
    }
    return dist;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E, r;
    cin >> V >> E >> r;
    Edges Es(V);
    while (E--){
        int s, t, d;
        cin >> s >> t >> d;
        Es[s].emplace_back(t, d);
    }
    auto dist = bellman_ford(r, Es);
    if (dist[r] == -1){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        for (auto d : dist) {
            if (d == INF){
                cout << "INF" << '\n';
            }else{
                cout << d << '\n';
            }
        }
    }
    return 0;
}

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

#define N 110
int n, d, x[N][N];

int dis(int i, int j) {
	int res = 0;
	for (int o = 1; o <= d; ++o) {
		res += (x[i][o] - x[j][o]) * (x[i][o] - x[j][o]);
	}
	return res;
}

int main() {
	set <int> se; se.insert(0);
	for (int i = 1; i <= 30000; ++i) {
		se.insert(i * i);
	}
	while (scanf("%d%d", &n, &d) != EOF) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= d; ++j) {
				scanf("%d", x[i] + j);
			}
		}
		int res = 0;
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j < i; ++j) {
				int Dis = dis(i, j);
				if (se.count(Dis)) {
					++res;
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

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

	ll def = b - a;

	ll i = 0;
	for (ll k = 1; k <= def; k++) {
		i += k;
	}

	cout << i - b << endl;
}

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

int main() {
	LL a,b,c,d;
	int T; cin>>T;
	while (T--) {
		cin>>a>>b>>c>>d;
		if (a<b) {
			puts("No");
			continue;
		}
		if (d<b) {
			puts("No");
			continue;
		}
		if (c+1>=b) {
			puts("Yes");
			continue;
		}
		LL g=__gcd(b,d);
		LL t1=(a-b)/g,t2=(a-c-1)/g;
		if (t1!=t2) puts("No");
		else puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 256
/*written by iPhone*/
#include <iostream>

using namespace std;

int main(){
    int c = 0;
    string smp; cin >> smp;
    int N; cin >> N;
    for(int i = 0; i < N; i++){
        string s; cin >> s;
        s += s;
        if(s.find(smp) != string::npos) c++;
    }
    cout << c << endl;
    return 0;
}

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

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

    fenwick_tree<long long> fw(N);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        fw.add(i, a);
    }

    for (int i = 0; i < Q; ++i) {
        int t;
        cin >> t;

        if (t == 0) {
            int p, x;
            cin >> p >> x;
            fw.add(p, x);
        }
        else {
            int l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
}

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

int main() {
	string s; cin >> s;
	int n = s.size();
	int p = 2019;
	int64_t cnt[p] = {};
	cnt[0] = 1;
	int now = 0;
	int mul = 1;
	int64_t ans = 0;
	for(int i = n - 1; i >= 0; --i) {
		now += (s[i] - '0') * mul;
		now %= p;
		mul *= 10;
		mul %= p;
		ans += cnt[now];
		cnt[now]++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize(2)
#include<iostream> 
#include<cstdio> 
#include<cstring> 
#include<algorithm> 
#include<map> 
#define File(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
#define re register
#define ri re int
#define gtch() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#define For(i,a,b) for(ri i=a;i<=b;++i) 
#define iFor(i,a,b) for(ri i=a;i>=b;--i) 
using namespace std;
typedef long long ll;
char buf[1<<21],*p1=buf,*p2=buf;
inline ll fr()
{
	re char ch=getchar();re ll res=0;int bl=0;
	while(!isdigit(ch)) bl=(ch=='-'),ch=getchar();
	while(isdigit(ch)) res=(res<<1)+(res<<3)+ch-'0',ch=getchar();
	return bl?-res:res;
}
const int MAXN=1e7;
int mf[MAXN];
ll prime[MAXN],tot;
ll d[MAXN],cnt[MAXN]; 
int n;
inline void sieve()
{
	d[1]=1;
	for(ri i=2;i<=n;++i)
	{
		if(!mf[i]){mf[i]=i,prime[++tot]=i,d[i]=2,cnt[i]=1;}
//		cout<<i<<" "<<d[i]<<" "<<cnt[i]<<"\n";
		for(ri j=1;j<=tot;++j)
		{
			ri p=prime[j],t=i*p;
			if(t>n) break;
			mf[t]=p;
			if(p==mf[i]){cnt[t]=cnt[i]+1,d[t]=d[i]/(cnt[i]+1)*(cnt[i]+2);break;}
			cnt[t]=1,d[t]=d[i]*2;
		}
	}
}
signed main()
{
//	File("temp")
	n=fr();
	sieve();
	ll ans=0;
	for(ri i=1;i<n;++i) ans+=d[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 23716
import heapq

N = int(input())
A = list(map(int, input().split()))

heapq.heapify(A)
flag = True

while flag:
    minA = heapq.heappop(A) # 最小値を取り出す
    if len(A) == 0: # 要素がなかったら終わり
        break
    if minA == 0: # 0だったら除外したまま続ける
        continue
    A = list(map(lambda x: x % minA, A))
    heapq.heappush(A, minA)

print(minA)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e18;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	string s,t;
	cin >> s >> t;
	cout << t+s ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.length(),sum=0,c=0;
    for(ll i=0;i<n;i++){
        ll j=i;
        while(j<n&&s[j]==s[i])
        j++;
        if(s[i]=='<'){
            c=j-i;
            sum+=(j-i)*(j-i+1)/2;
        }
        else{
            if(c<j-i)
            sum+=(j-i)*(j-i+1)/2-c;
            else
            sum+=(j-i)*(j-i-1)/2;
        }
        i=j-1;
    }
    cout<<sum;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    bool ok = true;
    rep(i,s.size()) {
        if (i == a) {
            if (s[i] != '-') ok = false;
        }
        else {
            if (s[i] == '-') ok = false;
        }
    }
    printf(ok?"Yes\n":"No\n");
}

Measured memory_bytes: 256
def solve():
  query = 'abcdefghijklmnopqrstuvwxyz'
  squery = [0]*26
  tquery = [0]*26
  s = input()
  t = input()
  for i in range(26):
    tp = query[i]
    squery[i] = s.count(tp)
    tquery[i] = t.count(tp)
  squery.sort()
  tquery.sort()
  
  if squery == tquery : return 'Yes'
  else: return 'No'
    
  
print(solve())

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec A(N);
  llvec S1(N), S2(N);
  cin >> A[0];
  rep(i, N-1){
    cin >> A[i+1];
  }
  sort(ALL(A));
  S1[0] = A[0];
  S2[0] = -A[0];
  for(int i=1; i<N;i++){
    S1[i] = S1[i-1]+A[i];
    S2[i] = S2[i-1]-A[i];
  }
  ll ans = -1e16;
  ll ansind=0;
  for(int i=1;i<N;i++){
    ll tmp = S2[i-1]+(S1[N-1]-S1[i-1]);
    if(tmp >= ans){
      ans = tmp;
      ansind=i;
    }
  }
  cout << ans << endl;
  ll a = A[0];
  rep(i, N-ansind-1){
    cout << a << " " << A[ansind+i] << endl;
    a = a - A[ansind+i];
  }
  
  cout << A[N-1] << " "<< a << endl;
  a = A[N-1] - a;
  for(int i=1;i<ansind;i++){
    cout << a << " " << A[i] << endl;
    a = a - A[i];
  }

 
  //cout << ans << " " << ansind;
    
  return 0;
}


Measured memory_bytes: 4224
N,M = map(int,input().split())
Ans = {}
for i in range(N+1):
    Ans[i] = 0
for _ in range(M):
    a,b = map(int,input().split())
    Ans[a] += 1
    Ans[b] += 1
for i in range(1,N+1):
    print(Ans[i])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, c; cin >> n;
  vector<pair<int, int>> ai(n);
  for(int i = 0; i < n; i++) {
    cin >> c;
    ai.at(i).first = c;
    ai.at(i).second = i+1;
  }
  sort(ai.begin(), ai.end());
  for(pair<int, int> b : ai) {
    cout << b.second << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 4020
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
import string


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  H, A = inputIntList()
  ans = math.ceil(H / A)

  return ans


if __name__ == "__main__":
  print(main())


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int a[200005];
long long ans;
int n;
 
int main() {
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
  }
  for(int i=1;i<=n;i++) {
    if(a[i]<a[i-1]) {
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 4536
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
for i in range(k):
    x=q.get()
    if x%10!=0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+(x%10))
    if x%10 !=9:
        q.put(10*x+(x%10)+1)
print(x)

Measured memory_bytes: 12452
#include <iostream>
#include <algorithm>

using namespace std;

inline int cubic(int x){
    return x*x*x;
}

inline int square(int x){
    return x*x;
}

int main(){
    int n;
    while(cin >> n && n){
        int ret = 1 << 29;
        for(int i=0;cubic(i)<=n;i++){
            int tmp = n - cubic(i);
            for(int j=0;square(j)<=tmp;j++){
                ret = min(ret, i+j+tmp-square(j));
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 864
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define For(i,n) for(ll i=0; i<n; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define deb(x) cout<<"For debug : "<<x<<endl;
typedef long long ll;
#define ld long double

void solve()
{
    string s,t;
    cin>>s>>t;
    int n=s.length(),ans=0;
    For(i,n)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
}

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if(A == 1) A += 13;
  if(B == 1) B += 13;
  
  if(A > B){
    cout << "Alice" << endl;
  }else if(A < B){
    cout << "Bob" << endl;
  }else{
  	cout << "Draw" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ++ans;
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll X, Y, Z, K;

  cin >> X >> Y >> Z >> K;
  ll as[X];
  ll bs[Y];
  ll cs[Z];

  for(int i = 0; i < X; ++i){
    cin >> as[i];
  }
  sort(as, as+X, greater<ll>());

  for(int i = 0; i < Y; ++i){
    cin >> bs[i];
  }
  sort(bs, bs+Y, greater<ll>());  

  for(int i = 0; i < Z; ++i){
    cin >> cs[i];
  }
  sort(cs, cs+Z, greater<ll>());    

  vector<ll> buf;
  for(int i = 0; i < X; ++i){
    for(int j = 0; j < Y; ++j){
      if((i+1)*(j+1) > K) break;
      for(int k = 0; k < Z; ++k){
	if((i+1)*(j+1)*(k+1) > K) break;
	
	buf.emplace_back(as[i]+bs[j]+cs[k]);
      }
    }
  }

  sort(buf.begin(), buf.end(), greater<ll>());

#ifdef DEBUG
  cout << "bufSize=" << buf.size() << endl;
#endif

  for(int i = 0; i < K; ++i){
    cout << buf[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1400
/* Author rumoisen */
/* created 2018/10/10 */

#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <iostream>

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int n,k;
    int x[110];
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>x[i];
    int tmp=0;
    for(int i=0;i<n;i++){
        tmp+=2*min(x[i],k-x[i]);
    }
    cout<<tmp<<endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind:

    def __init__(self, n):
        self.p, self.d = [-1] * n, [0] * n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        if self.isSame(x, y):
            return
        x, y = self.find(x), self.find(y)

        if self.d[x] > self.d[y]:
            self.p[x] += self.p[y]
            self.p[y] = x
        else:
            self.p[y] += self.p[x]
            self.p[x] = y
            if self.d[x] == self.d[y]:
                self.d[y] += 1

    def size(self, x):
        return - self.p[self.find(x)]


N, M, K = map(int, input().split())
n, u = {i: set() for i in range(N)}, UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    u.unite(A - 1, B - 1)
    n[A - 1].add(B - 1)
    n[B - 1].add(A - 1)
for _ in range(K):
    C, D = map(int, input().split())
    if u.isSame(C - 1, D - 1):
        n[C - 1].add(D - 1)
        n[D - 1].add(C - 1)

print(' '.join([str(u.size(i) - len(n[i]) - 1) for i in range(N)]))


Measured memory_bytes: 77160
#include <bits/stdc++.h>
using namespace std;
  
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 
int main()
{
    generatePrimeFactors(); 
    int n;
    cin>>n;
    int ans=0;
    vector<int>v;
    for(int i=1;i<n;i++)v.push_back(n-i);
    for(int i=0;i<v.size();i++)
    {
        int k=v[i];
        int res=calculateNoOFactors(k);
        ans+=res;
    }
    cout<<ans;
        
}

 


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
int main()
{
    FAST
int n;
cin>>n;
int arr[n];
ll mx=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
mx+=(arr[i]-1);
}
cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
int h[N];
for(int i = 0; i < N; i++){
    cin >> h[i];
}

//dpをします
int dp[N];
dp[0] = 0;
dp[1] = abs(h[0] - h[1]);
for(int i = 2; i < N; i++){
    if(dp[i-1] + abs(h[i]-h[i-1]) <= dp[i-2] + abs(h[i]-h[i-2])){
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    } else if(dp[i-1] + abs(h[i]-h[i-1]) > dp[i-2] + abs(h[i]-h[i-2])){
        dp[i] = dp[i-2] + abs(h[i]-h[i-2]);
    }
}

cout << dp[N-1] << endl;
return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  sort(a.begin(),a.end());
  
  int ans=n;
  vector<int> res(1000005);
  rep(i,n){
    if(res[a[i]]==-1){
      ans--;
      continue;
    }
    if(res[a[i]]==1){
      ans-=2;
      res[a[i]]=-1;
      continue;
    }    
    res[a[i]]=1;
    int p=2;
    while(a[i]*p<=1000000){
      res[a[i]*p]=-1;
      p++;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 8012
# N switches, M bulbs
N,M = map(int,input().split())
K = []
for i in range(M):
  lst = list(map(int,input().split()))
  K.append([i-1 for i in lst[1:] ])

P = list(map(int,input().split()))
res = 0

for i in range(1<<N):
  on = []
  for j in range(N):
    if (i>>j)&1:
      on.append(j)

  flg = True
  for m in range(M):
    k = K[m]
    tmp = 0
    for s in k:
      if s in on:
        tmp += 1
    p = P[m]
    if tmp % 2 != p:
      flg = False
      break

  if flg:
    res += 1

print(res)

Measured memory_bytes: 9184
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

k = []
for i in range(1, 10):
    for j in range(1, 10):
        k.append(i * j)

if N in k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060