akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int N, M;
constexpr int MAX_N = 710;
bool d[MAX_N][MAX_N];
int check[MAX_N];
bool nibugraph = true;

void dfs(int s, int n, int& m1, int& m2){
    check[s] = n;
    if(n == 1) ++m1;
    else ++m2;
    for(int i = 0; i < N; ++i){
        if(d[s][i]){
            if(check[i] == check[s]){
                nibugraph = false;
            }
            if(check[i] == 0){
                dfs(i, n % 2 + 1, m1, m2);
            }
        }
    }
}

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

    for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j){
        if(i != j) d[i][j] = true;
    }

    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        --A, --B;
        d[A][B] = false;
        d[B][A] = false;
    }

    vector<int> v1;
    vector<int> v2;
    for(int i = 0; i < N; ++i){
        if(check[i] == 0){
            int m1 = 0;
            int m2 = 0;
            dfs(i, 1, m1, m2);
            v1.push_back(m1);
            v2.push_back(m2);
        }
    }
    if(!nibugraph){
        cout << -1 << endl;
        return 0;
    }

    bool dp[3000] = {};
    dp[0] = true;
    for(size_t i = 0; i < v1.size(); ++i){
        for(int j = N-1; j >= 0; --j){
            if(!dp[j]) continue;
            dp[j] = 0;
            dp[j + v1[i]] = true;
            dp[j + v2[i]] = true;
        }
    }

    int64_t a = -1;
    int64_t mid = N;
    for(int i = 0; i <= N; ++i){
        if(!dp[i]) continue;
        if(mid > abs(i - N/2)){
            mid = abs(i - N/2);
            a = i;
        }
    }
    int64_t b = N - a;
    cout << a*(a-1)/2 + b*(b-1)/2 << endl;
}

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

long long requiredNumber(long long H){
    if(H==1){
        return 1;
    }
    return 1 + 2*requiredNumber(H/2);
}

void solve(long long H){
    cout << requiredNumber(H) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;
int p[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != (i + 1))
            ans++;
    }
    if(ans < 3){
        cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}


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

int main(){
  string s;
  int n,k;
  cin>>n>>s>>k;
  char c=s[k-1];
  for(int i=0;i<n;i++)if(s[i]!=c)s[i]='*';
  cout<<s<<endl;
}

Measured memory_bytes: 3516
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
N.times do
  a = gets.split.map(&:to_i)
  num = 0
  M.times do |i|
    num += B[i] * a[i]
  end
  ans += 1 if num + C > 0
end
puts ans

Measured memory_bytes: 1788
import math
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(a,b,h,m):
    hun = 2*math.pi * (m / 60)
    zi = 2*math.pi * ((60*h+m)/(12*60))
    kaku = abs(hun - zi)
    if kaku > math.pi : kaku = 2*math.pi - kaku
    rtn = math.sqrt(a**2+b**2-2*a*b*math.cos(kaku))
    return rtn

def resolve():
    a,b,h,m = mi()
    print(main(a,b,h,m))

if __name__ == "__main__":
    resolve()

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


bool compare(const int &a, const int &b) {
    int a1 = a % 10;
    int b1 = b % 10;
    if (a1 == 0) {
        return true;
    }
    if (b1 == 0) {
        return false;
    }
    return a1 > b1;
}

int main()
{
    int X[5];
    rep (i, 5) {
        cin >> X[i];
    }
    sort(X, X + 5, compare);
    int time = 0;
    rep(i, 5) {
        if (time % 10 > 0) {
            time = (time / 10 + 1) * 10;
        }
        int t = X[i];
        time += t;
    }
    cout << time << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;

vint par;
vint ra;
void init(int n) {
	rep(i, n) {
		par[i] = i;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (ra[x] < ra[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
	}
}

int main(void) {
	int n, m, k; cin >> n >> m >> k;
	vint fr(n), bl(n);
	par.resize(n);
	ra.resize(n);
	init(n);
	rep(i, m) {
		int a, b; cin >>a >> b;
		a--; b--;
		fr[a]++; fr[b]++;
		unite(a, b);
	}

	rep(i, n) {
		find(i);
	}
	map<int, int> mp;
	rep(i, n) {
		mp[par[i]]++;
	}
	
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (par[a]==par[b]) {
			bl[a]++;
			bl[b]++;
		}
	}
	rep(i, n) {
		cout << mp[par[i]] - fr[i] - bl[i]-1 << ' ';
	}
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m; cin >> n >> m;
    vector<P> B(m); 
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        B[i] = {b, a};
    }
    sort(all(B));

    //rep(i, m) cout << B[i].se << " " << B[i].fi << endl;
    
    set<int> rem;
    rep(i, m){
        int a = B[i].se, b = B[i].fi;
        if(rem.empty()){
            rem.insert(b-1);
            //cout << i << " " << b-1 << endl;
        }else{
            auto it = rem.lower_bound(a);
            if(it == rem.end() || *it >= b) {
                rem.insert(b-1);
                //cout << i << " " << b-1 << endl;
            }
        }
    }
    cout << rem.size() << endl;
    return;
}

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

Measured memory_bytes: 3996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

/* Union-Find木 */
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = 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につける
	}

	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;
	vector<int> P(N);
	rep(i, N) cin >> P[i];

	UnionFind tree(N);

	rep(i, M) {
		int x, y;
		cin >> x >> y;
		tree.unite(x - 1, y - 1);
	}

	int cnt = 0;
	rep(i, N) {
		if (tree.same(i, P[i] - 1)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main()
{
	int n;
	while(cin>>n){
		if(n==0) break;
		int a[n], S[n], sum=0;
		for(int i=0;i<n;++i){
			cin>>a[i];
			sum+=a[i];
			S[i]=sum;
		}

		long max=S[0];
		for(int i=1;i<n;++i){
			if(S[i]>max) max=S[i];
			for(int j=0;j<i;++j){
				if(S[i]-S[j]>max) max=S[i]-S[j];
			}
		}

		cout<<max<<endl;
	}

	return 0;
}

Measured memory_bytes: 3112
V=0;
o=input().rstrip().split(' ')
n=int(o[0])
k=int(o[1])
if(n%k==0):
    print(0);
elif(k%n==0):
    print(n)
elif(n>k):
    a=(n//k)*k;
    b=n-a;
    print(k-b);
else:
    print(min(n,k-n))

Measured memory_bytes: 3064
n, m = (int(i) for i in input().split())  
e = [[int(i) for i in input().split()] for i in range(n)] 

count_list = []
for x in e:
    count_list += x[1:]

result = 0
for i in range(m):
    if count_list.count(i+1) == n:
        result += 1

print(result)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <array>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int n;
int a[200000],b[200000];

int main() {
	//freopen("test.in","r",stdin);
	scanf("%d",&n);
	REP (i,n) scanf("%d",&a[i]);
	REP (i,n) scanf("%d",&b[i]);
	reverse(b,b+n);
	int f=0,t=n-1;
	REP (i,n) {
		if (a[i]==b[i] && a[f]!=a[i] && b[f]!=b[i]) { swap(b[i],b[f]); f++; }
		if (a[i]==b[i] && a[t]!=a[i] && b[t]!=b[i]) { swap(b[i],b[t]); t--; }
		if (a[i]==b[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	REP (i,n) {
		if (i!=0) printf(" ");
		printf("%d",b[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 5380
import collections
N = int(input())
graph = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append([b-1,i])
    graph[b-1].append([a-1,i])

q = collections.deque()
ans = [-1]*(N-1)
q.append([0,-1])
while len(q) != 0:
    tmp = 1
    v, v2 = q.popleft()
    for w, i in graph[v]:
        if ans[i] != -1:
            continue
        if ans[v2] == tmp:
            tmp += 1
        ans[i] = tmp
        tmp += 1
        q.append([w,i])

print(len(set(ans)))
for i in ans:
    print(i)

Measured memory_bytes: 46780
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int H,W;
char t[700][700],ch;

string dp[700][700],maxm;

string strmax(string x,string y){
  if(x=="-"&&y=="-")return "-";
  if(x=="-")return y;
  if(y=="-")return x;
  while(x[0]=='0'&&x.size()>=2)x=x.substr(1,x.size()-1);
  while(y[0]=='0'&&y.size()>=2)y=y.substr(1,y.size()-1);
  if(x.size()==y.size()){
    for(int i=0;i<(int)x.size();i++){
      if(x[i]>y[i]){
	return x;
      }else if(x[i]<y[i]){
	return y;
      }
    }
    return x;
  }else if(x.size()>y.size()){
    return x;
  }else{
    return y;
  }
}

char judge(char ch){
  if('0'<=ch&&ch<='9')return ch;
  else return '-';
}
int main(){
  int flg;
  while(cin>>W>>H && W&& H){
    scanf("%c",&t[0][0]);
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	dp[i][j]="";
	scanf("%c",&t[i][j]);
	if(judge(t[i][j])=='-')flg++;
      }
      scanf("%c",&ch);
    }
    //if(flg==H*W){cout<<"0"<<endl;continue;}
    dp[0][0].push_back(judge(t[0][0])); 
    
    for(int i=1;i<W;i++){
      if(judge(t[0][i])=='-'){
	dp[0][i]="-";
	continue;
      }
      if(dp[0][i-1]!="-")dp[0][i]=dp[0][i-1];      
      dp[0][i].push_back(judge(t[0][i]));
    }
    for(int i=1;i<H;i++){
      if(judge(t[i][0])=='-'){
	dp[i][0]="-";
	continue;
      }
      if(dp[i-1][0]!="-")dp[i][0]=dp[i-1][0];      
      dp[i][0].push_back(judge(t[i][0]));
    }

    maxm="0";
    for(int i=1;i<H;i++){
      for(int j=1;j<W;j++){
	if(judge(t[i][j])=='-'){
	  dp[i][j]="-";
	  continue;
	}
	
	dp[i][j]=strmax(dp[i-1][j],dp[i][j-1]);
	if(dp[i][j]!="-")dp[i][j].push_back(t[i][j]);
	else{
	  	  dp[i][j]="";
	  dp[i][j].push_back(t[i][j]);
	}
	

      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	//cout<<t[i][j];
	maxm=strmax(dp[i][j],maxm);
      }
      // cout<<endl;
    }
    //cout<<dp[2][0]<<endl;
    cout<<strmax(maxm,maxm)<<endl;
    
  }
  return 0;
  
}

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

#define MAXN (100010)

int n;
int X;

int main() {
    scanf("%d%d", &n, &X);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        ans = std::__gcd(ans, std::abs(x - X));
    }
    printf("%d\n", ans);
    return 0;
}

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

int const N = 2e5 + 7;
int n, k;
int bit[N];
int ar[N];

void add(int x, int val)
{
	while (x < N)
		bit[x] += val, x += (x & -x);
}

int sum(int x)
{
	int res = 0;
	while (x)
		res += bit[x], x -= (x & -x);
	return res;
}

//Lamps with N radius
int getMax()
{
	int res = 0;
	for (int i = 1; i <= n; ++i)
		res += (ar[i] == n);
	return res;
}

void update()
{
	memset(bit, 0, sizeof(bit));
	for (int i = 1; i <= n; ++i)
	{
		add(max(1, i - ar[i]), 1);
		add(min(n+1, i + ar[i] + 1), -1);
	}

	for (int i = 1; i <= n; ++i)
		ar[i] = sum(i);
}

int main()
{
	cin >> n >> k;

	for (int i = 1; i <= n; ++i)
		cin >> ar[i];
	

	for (int i = 0; i < k; ++i)
	{
		update();
		if (getMax() == n)
			break;
	}
	for (int i = 1; i <= n; ++i)
	{
		if (i != 1) cout << " ";
		cout << ar[i];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 5180
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

void edit(string s1, string s2){
    vector<vector<int> > dp(s1.size()+1, vector<int>(s2.size()+1,0));
    for(int i = 0; i<= s1.size();i++){
        for(int j = 0; j <= s2.size(); j++){
            if(i == 0 || j == 0){
                dp[i][j] = abs(i-j);
                continue;
            }
            int tmp = 1;
            if(s1[i-1] == s2[j-1])
                tmp = 0;
            dp[i][j] = min(min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+tmp);
        }
    }

    // for(int i = 0; i<= s1.size();i++){
    //     for(int j = 0; j <= s2.size(); j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[s1.size()][s2.size()] << endl;
    return;
}

int main() {
    string s1,s2; cin >> s1 >> s2;
    edit(s1,s2);
    return 0;
}



Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

ll gcd( ll a, ll b )
{
	ll r, tmp;
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
 
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    ll a,b,c,d;
    REP(i,t){
        cin >> a >> b >> c >> d;
        bool ans = true;
        if(a<b){
            cout << "No\n";
            continue;
        }
        if(b>d){
            cout << "No\n";
            continue;
        }
        if(c>=b){
            cout << "Yes\n";
            continue;
        }
        //a>=b,b<=d,c<b
        ll g = gcd(b,d);
        if(b-g+(a%g)>c) ans = false;
        if(ans) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}

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

int main() {
  int N; cin >> N;
  bool ok = true;
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    if(a % 2 == 0) {
      if(a % 5 != 0 && a % 3 != 0) ok = false;
    }
  }
  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, m,ans=0;
	cin >> n >> m;
	vector<pair<int, int>>vec(n);
	rep(i, n) {
		cin >> vec[i].first >> vec[i].second;
	}
	sort(all(vec));
	rep(i, n) {
		if (m < vec[i].second) {
			ans += m * vec[i].first;
			break;
		}
		ans += vec[i].first * vec[i].second;
		m -= vec[i].second;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    ll l,r;
    cin>>l>>r;
    if(r-l>2019){
        fin(0);
    }
    else{
        ll ans=LLINF;
        for(ll i=l;i<r;i++){
            for(ll j=l+1;j<=r;j++){
                ans=min(ans,i*j%2019);
            }
        }
        fin(ans);
    }
    
//////////////////////////////////////////////////////
return 0;}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  vector<pair<int, int>> CB;
  for (int i = 0; i < M; i++){
    int c, b;
    cin >> b >> c;
    CB.push_back({c, b});
  }
  
  sort(CB.begin(), CB.end());
  
  int pos = 0, Cpos = M - 1;
  while (pos < N && Cpos >= 0){
    int num = 0;
    while (num < CB.at(Cpos).second && pos < N){
      if (A.at(pos) < CB.at(Cpos).first){
        A.at(pos) = CB.at(Cpos).first;
        num++;
        pos++;
      }
      else{
        break;
      }
    }
    
    Cpos--;
  }
  
  
  long long int ans = 0;
  for (int i = 0; i < N; i++){
    ans += A.at(i);
  }
  
  cout << ans << endl;
}

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

signed main(void)
{
	int n, h, m;
	cin >> n >> h >> m;
	cout << (n - h + 1) * (n - m + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    N = read_int()
    A = read_int_list()
    for i in range(N):
      if A[i] % 2 == 0:
        if not (A[i] % 3 == 0 or A[i] % 5 == 0):
          return 'DENIED'
    return 'APPROVED'


def main():
    res = solve()  
    print(res)


main()


Measured memory_bytes: 3572
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = collections.Counter(l)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


a,b,c,d =MI()
while(1):
	c -= b
	if c<1:
		print('Yes')
		break
	a -= d
	if a<1:
		print('No')
		break











Measured memory_bytes: 67928
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    int n,k;cin>>n>>k;
    k=min(k,n-1);
    int a[n];clr(a);
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    int dp[n];clr(dp);
    dp[0]=0;
    for(int i=1;i<k;i++){
		dp[i]=abs(a[i]-a[0]);
	}
    for(int i=k;i<n;i++){
    	int temp=2e18;
    	for(int j=1;j<=k;j++){
    		temp=min(temp,dp[i-j]+abs(a[i]-a[i-j]));
    	}
    	dp[i]=temp;
    }
    cout<<dp[n-1];
}

signed main() { 
    IO();
    // #ifndef ONLINE_JUDGE
    // freopen(input, "r", stdin);
    // freopen(output, "w", stdout);
    // freopen(error, "w", stderr);
    // #endif

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 1792
<?php
// Here your code !
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
 
$ans = min($b, $d) - max($a, $c);

if ($ans < 0) {
    echo "0\n";
} else {
    echo $ans . PHP_EOL;
}


Measured memory_bytes: 5112
#include <iostream>
#include <vector>
using namespace std;
const int mod = 998244353;

int main() {
    int n; cin >> n;
    int d; cin >> d;
    if (d != 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> dist(n);
    dist[0] = 1;
    for (int i=0; i<n-1; ++i) {
        cin >> d;
        dist[d]++;
    }
    if (dist[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for (int i=1; i<n-1; ++i) {
        if (dist[i] == 0 && dist[i+1] != 0) ans = 0;
        else {
            for (int j=0; j<dist[i+1]; ++j) {
                ans *= dist[i];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int n, m;
  int A[101][101];
  int b[101][1];
  int c[101][1];
  for (int i = 0; i < 101; i++)
  {
    c[i][1] = 0;
  }
  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++)
  {
    cin >> b[i][1];
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      c[i][1] += A[i][j] * b[j][1];
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << c[i][1] << endl;
  }
}


Measured memory_bytes: 3124
#include<stdio.h>
#define N 100
void InsertionSort(int array[], int n) {
	int i, j;
	for (i = 0; i < n; i++) {
		if (i != 0) 
			printf(" ");
		printf("%d", array[i]);
	}
	printf("\n");
	for (i = 1; i < n; i++) {
		int v = array[i];
		j = i - 1;
		while (j >= 0 && array[j] > v) {
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = v;
		int k;
		for (k = 0; k < n; k++) {
			if (k != 0) 
				printf(" ");
			printf("%d", array[k]);
		}
		printf("\n");
	}
}
int main() {
	int n, array[N];
	
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		scanf("%d", &array[i]);
	}
	InsertionSort(array, n);
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define ll long long
#define maxn 100001
using namespace std;

int main()
{
	int n, k;
	ll s;
	cin >> n >> k >> s;
	for (int i = 0; i < k; i++)
	{
		cout << s << " ";
	}
	if (s == 2 || s == 1)
	{
		for (int i = k; i < n; i++)
		{
			cout << "3" << " ";
		}
		return 0;
	}
	for (int i = k; i < n; i++)
	{
		cout << s/2+1 << " ";
	}
	
}

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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int d = min(a*x + b*y,c*max(x,y)*2);
  int e;
  if(x<y){
    e = c*x*2 + b*(y-x);
  }
  else if(x>y){
    e = c*y*2 + a*(x-y); 
  }
  else{
    e = c*(x+y);
  }
  cout << min(d,e) << endl;
  return 0;
}


Measured memory_bytes: 256
#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 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() >> 3)*rand()
#define int ll

int n, p, x, k, ans, dp[2][200005], lft[200005], rit[200050];
vector<int> v[200005];
vector<p3i> r[200005];
p3i t1, t2, t3;
int mrg(int A, int B){
    if (r[A].size()<r[B].size()){
        return mrg(B, A);
    }
    fox(l, r[B].size()){
        t1=r[A][r[A].size()-1-l];
        t2=r[B][r[B].size()-1-l];
        t3.y=(1LL*t1.y*(t2.x.x+t2.x.y+t2.y)%MN+1LL*t1.x.y*(t2.x.y+t2.y)%MN+
              1LL*t1.x.x*t2.y)%MN;
        t3.x.y=(1LL*t1.x.x*t2.x.y+1LL*t1.x.y*t2.x.x)%MN;
        t3.x.x=(1LL*t1.x.x*t2.x.x)%MN;
        r[A][r[A].size()-1-l]=t3;
    }
    return A;
}
int dfs(int N){
    int k=N, hi=0;
    fox(l, v[N].size()){
        x=dfs(v[N][l]);
        hi=max(hi, (ll)(min(r[x].size(), r[k].size())));
        k=mrg(k, x);
    }
    fox(l, hi){
        r[k][r[k].size()-1-l].x.x+=r[k][r[k].size()-1-l].y;
        r[k][r[k].size()-1-l].x.x%=MN;
        r[k][r[k].size()-1-l].y=0;
    }
    r[k].pb(mp(mp(1, 1), 0));
    //cout << "*" << N << ' ' << r[k].size() << endl;
    return k;
}
int32_t main(){
    scanf("%i", &n);
    fox1(l, n){
        scanf("%i", &p);
        v[p].pb(l);
    }
    x=dfs(0);
    n=r[x].size();
    lft[0]=1; rit[n-1]=1;
    fox(l, n){
        //cout << r[x][l].x.x << ' ' << r[x][l].x.y << endl;
        if (l>0) lft[l]=1LL*lft[l-1]*(r[x][l-1].x.x+r[x][l-1].x.y)%MN;
    }
    foxr(l, n){
        if (l<n-1) rit[l]=1LL*rit[l+1]*(r[x][l+1].x.x+r[x][l+1].x.y)%MN;
    }
    fox(l, n){
        ans=((1LL*lft[l]*rit[l]%MN)*1LL*r[x][l].x.y+ans)%MN;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 45036
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;



int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {

        int n;
        cin >> n;

        map<pair<int, int>, int> cnt;
        for (int rep = 0; rep < n; ++rep) {
            double x;
            cin >> x;
            int i = llround(x * 1e9);
            int two = 0, five = 0;
            while (i % 2 == 0) {
                two++;
                i /= 2;
            }
            while (i % 5 == 0) {
                five++;
                i /= 5;
            }
            cnt[ mp(two, five)]++;
        }
        int ans = 0;
        for (auto p1 : cnt) {
            for (auto p2 : cnt) {
                if (p1.F.F + p2.F.F >= 18 && p1.F.S + p2.F.S >= 18) {
                    if (p1 < p2) {
                        ans += (int) p1.S * p2.S;
                    }
                    else if (p1 == p2) {
                        ans += (int) p1.S * (p1.S - 1) / 2;
                    }
                }
            }
        }
        cout << ans << endl;

    }
    return 0;

}



Measured memory_bytes: 3768
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include "bits/stdc++.h"
using i64 = long long;
using namespace std;

i64 n, x, m;

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

    vector<vector<i64>> a(64, vector<i64>(m + 1));
    vector<vector<i64>> sum(64, vector<i64>(m + 1));

    repeat(i, m + 1) {
        a[0][i] = i * i % m;
    }
    repeat(k, 1, 64) {
        repeat(i, m + 1) {
            a[k][i] = a[k - 1][a[k - 1][i]];
        }
    }

    repeat(i, m + 1) {
        sum[0][i] = i * i % m;
    }
    repeat(k, 1, 64) {
        repeat(i, m + 1) {
            sum[k][i] = sum[k - 1][i] + sum[k - 1][a[k - 1][i]];
        }
    }

    n--;
    i64 ans = x;
    i64 cnt = 0;
    while (n) {
        if (n & 1) {
            ans += sum[cnt][x];
            x = a[cnt][x];
        }
        cnt++;
        n >>= 1;
    }

    cout << ans << endl;

    return 0;
};

Measured memory_bytes: 104268
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

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

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  ll h, n, sum = 0;
  cin >> h >> n;
  ll a[n];
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  if(h-sum<=0) {
    yes();
  }else {
    no();
  }

  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		int Q = Integer.parseInt(sc.get());
		long[] S = new long[A];
		Arrays.setAll(S, $ -> Long.parseLong(sc.get()));
		long[] T = new long[B];
		Arrays.setAll(T, $ -> Long.parseLong(sc.get()));

		long[] X = new long[Q];
		Arrays.setAll(X, $ -> Long.parseLong(sc.get()));

		for (long x : X) {
			var s_exact_idx = Arrays.binarySearch(S, x);
			var t_exact_idx = Arrays.binarySearch(T, x);
			var s_ceil_index = -s_exact_idx - 1;
			var t_ceil_index = -t_exact_idx - 1;
			var s_floor_index = s_ceil_index - 1;
			var t_floor_index = t_ceil_index - 1;

			long minDistance = Long.MAX_VALUE;
			if (s_exact_idx >= 0) {
				minDistance = nearestLength(T, s_ceil_index, x);
			}
			if (t_exact_idx >= 0) {
				minDistance = nearestLength(T, t_ceil_index, x);
			}
			if (s_ceil_index < S.length) {
				var s_ceil_distance = Math.abs(x - S[s_ceil_index]);
				if (t_ceil_index < T.length) {
					minDistance = Math.min(minDistance, Math.max(s_ceil_distance, Math.abs(x - T[t_ceil_index])));
				}
				if (t_floor_index >= 0) {
					var t_floor_distance = Math.abs(x - T[t_floor_index]);
					minDistance = Math.min(minDistance, 2 * Math.min(s_ceil_distance, t_floor_distance) + Math.max(s_ceil_distance, t_floor_distance));
				}
			}
			if (s_floor_index >= 0) {
				var s_floor_distance = Math.abs(x - S[s_floor_index]);
				if (t_floor_index >= 0) {
					minDistance = Math.min(minDistance, Math.max(s_floor_distance, Math.abs(x - T[t_floor_index])));
				}
				if (t_ceil_index < T.length) {
					var t_ceil_distance = Math.abs(x - T[t_ceil_index]);
					minDistance = Math.min(minDistance, 2 * Math.min(s_floor_distance, t_ceil_distance) + Math.max(s_floor_distance, t_ceil_distance));
				}
			}
			System.out.println(minDistance);
		}
	}

	long nearestLength(long[] array, int ceilIndex, long from) {
		long min = Integer.MAX_VALUE;
		if (ceilIndex - 1 >= 0) min = Math.abs(from - array[ceilIndex - 1]);
		if (ceilIndex < array.length) min = Math.abs(from - Math.min(min, array[ceilIndex]));
		return min;
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

int n, cntr=0, ans=0;
string s;

int main(){
	cin >> n >> s;
	for (char c : s){
		if (c=='R') cntr++;
	}
//	sort(s.begin(),s.end());
	for (int i=0;i<cntr;i++){
		if (s[i]=='W') ans++;
	}
	cout << ans << "\n";
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[";
    REP(i, vec.size()) {
        if (i > 0) cout << ", ";
        os << vec[i];
    }
    os << "]";

    return os;
}

struct Node {
        Node() : id_(-1), children_({}), parent_(nullptr){};
        ~Node(){};

        void set_id(int id){
            id_ = id;
        };
        void set_children(vector<int> children) {
            children_ = children;
        }
        void set_parent(Node *parent){parent_ = parent;};
        int get_parent_id() {
            if (!parent_) return -1;

            return parent_->id_;
        }
        int get_depth() {
            if (!parent_) return 0;

            return parent_->get_depth() + 1;
        }

        void show() {
            cout << "node " << id_ << ": ";
            cout << "parent = " << get_parent_id() << ", ";
            cout << "depth = " << get_depth() << ", ";
            cout << type() << ", ";
            cout << children_ << endl;
        }

        string type() {
          if(!parent_) return "root";

          if(children_.size() == 0) return "leaf";

          return "internal node";
        };

        int id_;
        Node *parent_;
        vector<int> children_;
    };

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

    int n;
    cin >> n;

    Node T[n];

    REP(i, n) {
        int id; cin >> id;
        T[id].set_id(id);

        int k; cin >> k;
        if (k > 0) {
            vector<int> c(k);
            REP(j, k) {
                cin >> c[j];
                T[c[j]].set_parent(T + id);
            }
            T[id].set_children(c);
        }

    }

    REP(i, n) {
        T[i].show();
    }

}



Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int X,Y;
	cin>>X>>Y;
	rep(i,0,X+1){
		int sum;
		sum=i*2+(X-i)*4;
		if(sum==Y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
#define MAXQ 100000

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

  vector<bool> prime(MAXQ, true);
  for (int i = 2; i < MAXQ; i++) {
    if (prime[i]) for (int j = i*2; j < MAXQ; j += i) {
      prime[j] = false;
    }
  }

  vector<int> cs(MAXQ+1);
  for (int n = 3; n < MAXQ; n += 2) {
    cs[n] = cs[n-1];
    if (prime[n] && prime[(n + 1) / 2]) cs[n]++;
    cs[n+1] = cs[n];
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r; cin >> l >> r;
    cout << cs[r] - cs[l-1] << "\n";
  }
}

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

using namespace std;

int main() 
{
    int n, m, i;
    scanf("%d", &n);
    
    set<int> A;
    set<int> B;
    set<int> C;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &m);
        A.insert(m);
    }
    
    scanf("%d", &m);
    
    for(i = 0; i < m; i++)
    {
        scanf("%d", &n);
        B.insert(n);
    }
    
    set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(C, C.begin()));
    
    for(auto x : C)
        printf("%d\n", x);
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Vsort(v) sort(All(v))
#define VsortR(v) sort(All(v), std::greater<__typeof(v[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

template <typename T>
class UnionFind {
private:
	vector<T> p;
public:
	UnionFind(T size) {
	    p = vector<T>(size, -1);
	}

	T find(T x) {
	    if (p[x] < 0) return x;
		
		return p[x] = find(p[x]);
	}

	T size(T x) {
		return -p[find(x)];
	}

	void unite(T x, T y) {
		x = find(x);
		y = find(y);

		if (x == y) return;

	    if (size(x) < size(y)) swap(x, y);

		p[x] += p[y];
		p[y] = x;
	}

	bool isSame(T x, T y) {
		return find(x) == find(y);
	}
};

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll n, m;

	cin >> n >> m;

	long a[m];
	long b[m];
	UnionFind<long> uf(n);
	ll ans[m];

	Mem0(ans);

	ans[m - 1] = (n * (n - 1LL)) / 2LL;

	long i;

	rep(i, m) {
		cin >> a[i] >> b[i];

		a[i]--;
		b[i]--;
	}

	nepi(i, m, 1) {
		ans[i - 1] = ans[i];

		if (!uf.isSame(a[i], b[i])) {
			ans[i - 1] -= (ll)uf.size(a[i]) * (ll)uf.size(b[i]);
		    
			uf.unite(a[i], b[i]);
		}
	}

	rep(i, m) Out(ans[i]);
	
	return 0;
}


Measured memory_bytes: 4480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static String S;
    static long K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        S = sc.next();
        K = sc.nextLong();

        System.out.println(solve());
    }

    static int solve() {
        for (int i = 0; i < Math.min(K, S.length()); i++) {
            if( S.charAt(i) != '1' ) {
                return Integer.parseInt("" + S.charAt(i));
            }
        }
        return 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204
import sys
input = sys.stdin.readline

def costs(a):
    prev = 0
    for x in a:
        yield abs(x - prev)
        prev = x

def main():
    input()
    A = [0] + [int(c) for c in input().split()] + [0]
    total = sum(costs(A))
    for i, x in enumerate(A):
        if i == 0 or i == len(A)-1: continue
        prev_cost = abs(x - A[i-1])
        succ_cost = abs(A[i+1] - x)
        print(total - (prev_cost+succ_cost) + abs(A[i+1]-A[i-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14044
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;



int main(){
    int k,n;
    cin >> n >> k;
    if(k==1)printf("0\n");
    else printf("%d\n",n-k);



    return 0;
}

Measured memory_bytes: 256