akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int u[2000], v[2000];
ll w[2000];
ll min_w[2000];
ll pow[2001];
P p[2000];
const ll MOD = 1000000007;

void init(){
    pow[0] = 1;
    for(int i = 1; i <= 2000; i++){
        pow[i] = pow[i-1]*2;
        pow[i] %= MOD;
    }
}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, M;
    ll X;
    cin >> N >> M;
    cin >> X;
    init();
    for(int i = 0; i < M; i++){
        cin >> u[i] >> v[i] >> w[i];
        u[i]--; v[i]--;
        p[i] = P(w[i], i);
    }
    sort(p, p+M);
    
    int cntl = 0, cnteq = 0, cnth = 0;
    for(int i = 0; i < M; i++){
        UnionFind uf(N);
        ll sum = w[i];
        uf.unionSet(u[i], v[i]);
        for(int j = 0; j < M; j++){
            ll W = p[j].first;
            int idx = p[j].second;
            if(i == idx)continue;
            if(uf.findSet(u[idx], v[idx])) continue;
            uf.unionSet(u[idx], v[idx]);
            sum += W;
        }
        if(sum == X){
            cnteq++;
        }else if(sum < X){
            cntl++;
        }else{
            cnth++;
        }
    }
    ll ans = 1;
    if(cntl > 0) {
        ans *= 2;
        ans *= (pow[cnteq]-1);
        ans %= MOD;
        ans *= pow[cnth];
        ans %= MOD;
    }else if(cnteq == 0){
        ans = 0;
    }else{
        ans *= (pow[cnteq]-2);
        ans %= MOD;
        ans *= pow[cnth];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	string a, b;
	cin >> a >> b;
	int la = a.size();
	int lb = b.size();
	if (la > lb) {
		cout << "GREATER" << endl;
		
	} else if (la < lb) {
		cout << "LESS" << endl;
	} else {
		rep(i, la) {
			if (a[i] == b[i]) continue;
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			} else {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,c,d,e;
cin>>a>>b;
if(a>0 && b>0&&a!=b)
{c=abs((a+b)/2);
}
d=abs(a-c);
e=abs(b-c);
if(d==e)
    cout<<c<<endl;
else
    cout<<"IMPOSSIBLE"<<endl;
return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
#include<bitset>
#include<list>

#define sz(a) (int)a.size()
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forab(i, a, b) for (int i = a; i <= b; i++)
#define forabd(i, a, b) for (int i = a; i >= b; i--)
#define _(a, b) memset(a, b, sizeof a)
#define pii pair<int, int>
#define pll pair<long long, long long>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 7, MAXN = 100005, MOD = 1000000007, MAXBIT = 30, pHash = 53;
const ll INFL = 1e+18;

void prepare(string s) {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#else
	if (sz(s) != 0) {
		freopen((s + ".in").c_str(), "r", stdin);
		freopen((s + ".out").c_str(), "w", stdout);
	}
#endif
}

string s;

void read() 
{
	cin >> s;
}

bool check(string s) {
	return s[0] == s[1] && s[1] == s[2] ||
		s[1] == s[2] && s[2] == s[3];
}

void solve() 
{
	check(s) ? cout << "Yes" : cout << "No";
}

int main()
{
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	prepare("");

	read();
	solve();

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) scanf("%d", &a[i]);

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        cout << "not coprime";
        return 0;
    }

    //エラトステネスの篩
    int P_MAX = 1000005;
    vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    vi cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                cout << "setwise coprime";
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    cout << "pairwise coprime";
}


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

int main(){
  long long L,R;
  cin >> L >> R;
  if(L+1==R){
    cout << L*R%2019 << endl;
  }
  else{
  for(long long i=L;i<R+1;i++){
    if(i%673==0){
      cout << 0 << endl;
      break;
    }
    if(i==R){
      long long cnt=3000;
      for(long long j=L;j<R+1;j++){
        for(long long k=L;k<R+1;k++){
          if(j<k)
            cnt=min(cnt,j*k%2019);
        }
      }
      cout << cnt << endl;
    }
  }       
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    string s;
    cin>>s;
    int n = s.length();
    deque <char> d;
    rep(i,n){
        d.push_back(s[i]);
    }
    int64_t q;
    cin>>q;
    int fb = 1;//fb=1のとき前から見てる、-1の時反転してる
    rep(i,q){
        int t;
        cin>>t;
        if(t==1){
            fb *= -1;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){//先頭にciを追加
                if(fb==1){
                    d.push_front(c);
                }
                else{
                    d.push_back(c);
                }
            }
            else{//f==2 => 末尾にcを追加    
                if(fb==1){
                    d.push_back(c);
                }
                else{
                    d.push_front(c);
                }
            }
        }
    }
    if(fb==1){
        rep(i,d.size()){
            cout<<d.at(i);
        }
    }
    else{
        for(int i=d.size()-1;i>=0;i--){
            cout<<d.at(i);
        }
    }
    cout<<endl;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>

int connect[100000];

int topreturn(int n){
	while(connect[n]!=n){
		n=connect[n];
	}
	return n;
}

int main(void){
	int n,m,x,y,i,tmp;
	int p[100000];

	scanf("%d %d",&n,&m);

	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		connect[i]=i;
	}

	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		x=topreturn(x-1);
		y=topreturn(y-1);
		if(x>y){tmp=x; x=y; y=tmp;}
		connect[y]=connect[x];
	}

	tmp=0;
	for(i=0;i<n;i++){
		if(topreturn(i)==topreturn(p[i]-1)){
			tmp++;
		}
	}
	printf("%d\n",tmp);

	return 0;
}


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

int main(){
  
    int N, a, S;
  
  	cin >> N;
  	
  	int x = N;
      
  	S = 0;
  
    for (int i = 1000000000; i >= 1; i/=10){
    	
      a = N / i;
      N = N % i;
      S += a;
    
	}
 
  
    if (x % S == 0){
    
    cout << "Yes" << endl;
  
  	} 
  
  else{
    
    cout << "No" << endl;
  
  	}
    
}    

Measured memory_bytes: 384
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes";
		else cout<<"No";	


	return 0;
} 

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for q in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

sam = sum(A)
baketu = [0]*(100001)
for a in A:
    baketu[a] += 1

for q in range(Q):
    sam = sam + baketu[B[q]] * (C[q] - B[q])
    baketu[C[q]] += baketu[B[q]]
    baketu[B[q]] = 0
    #print(baketu)
    print(sam)

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

using namespace std;

long long inf=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	vector<long long> dis(n);
	vector<long long> wea(m);

	for(int i=0;i<n;i++) cin>>dis.at(i);
	for(int i=0;i<m;i++) cin>>wea.at(i);

	vector<vector<long long>> dp(n+1,vector<long long>(m+1,inf));
	dp.at(0).at(0)=0;

	long long ans=inf;

	queue<pair<long long,long long>> que;
	que.push(make_pair(0,0));

	while(!que.empty()){
		long long here=que.front().first;
		long long date=que.front().second;
		que.pop();

		if(here==n){
			ans=min(ans,dp.at(here).at(date));
			continue;
		}

		if(date<m){
			if(here<n){
				if(dp.at(here+1).at(date+1)>dp.at(here).at(date)+dis.at(here)*wea.at(date)){
					que.push(make_pair(here+1,date+1));
					dp.at(here+1).at(date+1)=dp.at(here).at(date)+dis.at(here)*wea.at(date);
				}
			}

			if(dp.at(here).at(date+1)>dp.at(here).at(date)){
				que.push(make_pair(here,date+1));
				dp.at(here).at(date+1)=dp.at(here).at(date);
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 9204
n = int(input())
side = 0
for _ in range(n-1):
    u,v = map(int, input().split())
    if v > u:
        side += u*(n-v+1)
    else:
        side += v*(n-u+1)

ans = 0
vertex = 0
for i in range(n):
    vertex += (i+1)*(n-i)

ans= vertex -side
print(ans)

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;

    ll N, X, M;
    cin >> N >> X >> M;

    ll ans = 0;
    ll p = 0;
    ll x = X;
    vll E(M + 1, 0);
    bool f = false;
    while(1) {
        p++;
        if(p > N) {
            cout << ans << endl;
            return 0;
        }
        if(!f && E[x] > 0) {
            ll r_init = x;
            ll r_sum = 0;
            ll r_cnt = 0;
            while(1) {
                r_sum += x;
                r_cnt++;
                ans += x;
                if(x * x % M == r_init)
                    break;
                p++;
                if(p > N) {
                    cout << ans << endl;
                    return 0;
                }
                x = x * x % M;
            }
            ll num_r = (N - p) / r_cnt;
            ans += num_r * r_sum;
            p += num_r * r_cnt;
            f = true;
            for(i = p + 1; i <= N; i++) {
                x = x * x % M;
                ans += x;
            }
            cout << ans << endl;
            return 0;
        }
        ans += x;
        E[x] = 1;
        x = x * x % M;
    }

    return 0;
}


Measured memory_bytes: 3980
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int p = sc.nextInt();
    
    int kakera = 3*a + p;
    int ap = kakera/2;
    System.out.println(ap);
  }
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int>> num(h, vector<int>(w, 0));
    for(int i = 0; i < h; ++i) cin >> s[i];
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j] == '#') {
                for(int dy = -1; dy <= 1; ++dy) {
                    for(int dx = -1; dx <= 1; ++dx) {
                        if(i+dy >= 0 && i+dy < h && j+dx >= 0 && j+dx < w) {
                            num[i+dy][j+dx]++;
                        }
                    }
                }
            }
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j] == '#') cout << '#';
            else cout << num[i][j];
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-30 08:38:50
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int X1, Y1, X2, Y2;
  cin >> X1 >> Y1 >> X2 >> Y2;
  int V1 = X2 - X1;
  int V2 = Y2 - Y1;
  int X3 = X2 - V2;
  int Y3 = Y2 + V1;
  int X4 = X3 - V1;
  int Y4 = Y3 - V2;
  cout << X3 << " " << Y3 << " " << X4 << " " << Y4 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll a, b;
  cin >> a >> b;
  ll ans = max(max(a + b, a * b), a - b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for (int i = 1; i < (n); ++i)

int main(){
    int n;
    long mod = 1000000007;
    cin >> n;
    long long ans,a9,a8,a10;
    a9=a8=a10=1;
    rep(i,n+1) {
        a9 *= 9;
        a9 %= mod;
    }
    rep(i,n+1) {
        a8 *= 8;
        a8 %= mod;
    }
    rep(i,n+1) {
        a10 *= 10;
        a10 %= mod;
    }
    ans = a8-2*a9+a10;
    // cout << ans << endl;
    if(ans<0) ans +=mod;
    if(ans<0) ans +=mod;
    if(ans<0) ans +=mod;
    if(ans>=mod) ans %=mod;
    // cout << a9 << endl;
    cout << ans << endl;
    // cout << ans%mod << endl;
}

Measured memory_bytes: 3636
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		StringBuilder sb = new StringBuilder();
		
		s = br.readLine();
		
		for(int i=0; i<s.length(); i++){
			char c = s.charAt(i);
			if(Character.isLetter(c)){
				if(Character.isUpperCase(c)){
					sb.append(Character.toLowerCase(c));
				}else{
					sb.append(Character.toUpperCase(c));
				}
			}else{
				sb.append(c);
			}	
		}
		
		System.out.println(sb);
		
	}
}

Measured memory_bytes: 17024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] s_char = sc.next().toCharArray();
    String ans = "";
    for (int i = 0; i < s_char.length; i++) {
      if (s_char[i] == '0') {
        ans += "0";
      } else if (s_char[i] == '1') {
        ans += "1";
      } else if (s_char[i] == 'B' && ans.length() > 0) {
        ans = ans.substring(0, ans.length() - 1);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22992
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	vector<int>b(N);
	int n = (N + 2 - 1) / 2;
	for (int i = N; i >= 1; i--) {
		int sum = 0;
		for (int j = i + i; j <= N; j += i) {
			sum ^= b[j - 1];
		}
		b[i - 1] = sum ^ a[i - 1];
	}
	int M = 0;
	rep(i, N)M += b[i];
	cout << M << endl;
	rep(i, N) {
		if (b[i])cout << i + 1 << " ";
	}
}

Measured memory_bytes: 3968
S = list(input())
K = int(input())

count = 0

for i in range(len(S)):
    if S[i] == '1':
        count += 1
    else:
        break

if count >= K:
    print(1)
else:
    for i in range(K):
        if S[i] != '1':
            print(S[i])
            break
        elif S[i] == '1' and i == (K-1):
            print(1)

Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    ll l=-1;
    for(ll i=2;;i++){
        if(i*(i-1)/2==n){l=i; break;}
        if(n<i*(i-1)/2){break;}
    }
    if(l==-1){cout<<"No"<<endl; return 0;}
    vector<vector<ll>> a(l);
    ll w=0;
    for(int i=0;i<l;i++){
        for(int t=i+1;t<l;t++){
            a[i].push_back(++w);
            a[t].push_back(w);
        }
    }
    cout<<"Yes"<<endl;
    cout<<l<<endl;
    for(int i=0;i<l;i++){
        cout<<a[i].size();
        for(int t=0;t<a[i].size();t++){
            cout<<" "<<a[i][t];
        }
        cout<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 3200
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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 Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k; cin >> n >> k;
    vector<int> S(n);
    
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int a; cin >> a;a--;
            S[a]++;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(S[i]==0) ans++;
    }
    
    cout << ans << endl;
}





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



Measured memory_bytes: 3652
n=int(input())
l=list(map(int,input().split()))
d=True


for i in range(n-1):
  if l[i]>l[i+1]:
    l[i+1]+=1

  if l[i]>l[i+1]:
    d=False
    
if d:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20584
n=int(input())
nums=list(map(int,input().split()))

def show(nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')

        else:
            print(nums[i])

def bubble_sort(nums,n):
    count=0
    flag=1
    while flag:
        flag=0
        for j in range(n-1,0,-1):
            
            if nums[j-1]>nums[j]:
                flag=1
                nums[j-1],nums[j]=nums[j],nums[j-1]
                count+=1
            

    return count,nums

count,nums=bubble_sort(nums,n)
show(nums)
print(count)


Measured memory_bytes: 5608
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;

int a[200006];
int flg1[1000006];
int flg2[1000006];
signed main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i];
		flg1[a[i]]++;
	}

	for (int i = 1; i <= 1000000; i++) {
		for (int j = i; j <= 1000000; j += i) {
			flg2[j] += flg1[i];
		}
	}
	int cnt = 0;
	rep(i, n) {
		if (flg2[a[i]] == 1)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 20620
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;
typedef pair<P,int>P2;

#define fi first
#define se second

int ans[222222];
bool used[222222];

int Q=1e15,flag=0;

vector<P2>x[100009];

main(){

  for(int i=0;i<222222;i++)ans[i]=Q;

  int n,m;
  cin>>n>>m;
  vector<int>v;
  for(int i=0;i<m;i++)
  {
    int a,b,c;
    cin>>a>>b>>c;
    x[a].push_back(P2(P(b,c),0));
    x[b].push_back(P2(P(a,c),1));
    v.push_back(a);
    v.push_back(b);
  }
  sort(v.begin(),v.end());
  r(o,v.size()){
    if(!used[v[o]]){
      used[v[o]]=1;
      int X=v[o];
      vector<int>V;
      ans[X]=0;
      V.push_back(X);
      while((int)V.size()){
        int p=V[0];
        V.erase(V.begin());
        r(i,x[p].size()){
          int l=p;
          int r=x[p][i].first.fi;
          int cost=x[p][i].fi.se;//cout<<l<<r<<endl;
          int C=x[p][i].se;
          if(!used[r]){//cout<<l<<' '<<r<<' '<<ans[l]<<' '<<ans[r]<<endl;
            used[r]=1;
            V.push_back(r);
          }
          if(C)swap(l,r);
          if(ans[l]==Q&&ans[r]!=Q){//cout<<l<<' '<<r<<' '<<ans[l]<<' '<<ans[r]<<endl;
            ans[l]=ans[r]-cost;
          }
          else if(ans[l]!=Q&&ans[r]==Q){//cout<<l<<' '<<r<<' '<<ans[l]<<' '<<ans[r]<<endl;
            ans[r]=ans[l]+cost;//cout<<l<<' '<<r<<' '<<ans[l]<<' '<<ans[r]<<endl;
          }
          else{//cout<<l<<' '<<r<<' '<<ans[l]<<' '<<ans[r]<<endl;
            if(ans[l]+cost!=ans[r])flag++;
          }
        }
      }
    }
  }
  int l=1e16;
  int r=-1e16,F=0;
  r(i,n+1){
    if(ans[i]!=Q){
      l=min(l,ans[i]);
      r=max(r,ans[i]);
      F++;
    }
  }

  if(flag||(F&&abs(r-l)>1000000001))cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 25120
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(void){
  int n;  cin >> n;
  int t[MAX], x[MAX], y[MAX];
  bool flag = true;
  t[0] = 0; x[0] = 0; y[0] = 0;
  rep(i, 1, n+1){
    cin >> t[i] >> x[i] >> y[i];
  }
  rep(i, 1, n+1){
    if(!flag) break;
    int dTime = t[i]-t[i-1];
    int dis = abs(x[i]+y[i]-x[i-1]-y[i-1]);
    if(dTime%2==0){
      if(dis%2!=0 || dTime < dis){
        flag = false;
      }
    }else{
      if(dis%2!=1 || dTime < dis){
        flag = false;
      }
    }
  }
  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  string s;
  cin >> s;
  REP(i, SZ(s)-1) {
    if (s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return;
    }
  }
  cout << "Good" << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // SOLUTION A
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int a = scanner.nextInt();
//        int b = scanner.nextInt();
//        int answer = solutionA(n, a, b);
//        System.out.println(answer);
//    }
//
//    public static int solutionA (int n, int a, int b) {
//        if ((n * a) < b) {
//            return (n * a);
//        } else {
//            return b;
//        }
//    }

        // SOLUTION B
        Scanner scanner = new Scanner(System.in);
        long i = scanner.nextLong();
        long j = scanner.nextLong();
        System.out.println(solutionB(i, j));
    }

    // james wuz here lul
    public static long solutionB(long l, long r) {
        if (l + 2019 <= r) {
            return 0;
        } else {
            long min = 2019;
            for (long i = l; i <= r; i++) {
                for (long j = i + 1; j <= r; j++) {
                    // this nested for loop is brute forcing it by comparing two integers
                    // ex: 2020, 2025 would look like
                    // i = 2020, j = 2021, 2022, 2023, 2024, 2025
                    // i = 2021, j = 2022, 2023, 2024, 2025
                    // ...
                    // until i = 2025, and j is nothing because 2026 is not less than r (which is 2025)
                    long x = (i * j) % 2019;
                    if (x < min) {
                        min = x;
                    }
                }
            }
            return min;
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    double r, are, circ;
    
    cin >> r;
    are = 1.0 * r * r * 3.141592653589;
    circ = 1.0 * 2 * r * 3.141592653589;
    
    printf("%.10f %.10f\n", are, circ);
    
    return 0;
}


Measured memory_bytes: 3200
n = int(input())
values = [int(input()) for i in range(n)]
all_max = max(values)
count = 0

max_count = 0
is_include_two_max = False
for val in values:
    if val == all_max:
        max_count += 1
    if max_count == 2:
        is_include_two_max = True
        break

if is_include_two_max:
    print('\n'.join([str(all_max) for i in range(n)]))
else:
    for i, val in enumerate(values):
        if val != all_max:
            print(all_max)
        else:
            print(max(values[0:i] + values[i+1:]))


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

using namespace std;

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

int main() {
  int R;
  
  cin >> R;
  cout << (double)R * 2 * 3.14159265358979;
  
  return 0;
}

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

using namespace std;

//#define MULTITEST
//#define _DEBUG

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 + 13;

char s[N], t[N];

bool read() {
	if (scanf("%s", s) != 1)
		return false;
	scanf("%s", t);
	return true;
}

void solve() {
	int ans = INF;
	int n = strlen(s);
	int m = strlen(t);
	forn(i, n - m + 1) {
		int cur = 0;
		forn(j, m) {
			cur += (s[i + j] != t[j]);
		}
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef MULTITEST
	int tc;
	scanf("%d", &tc);
	while (tc--) {
		read();
#else
	while (read()) {
#endif
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif

	}
	}

Measured memory_bytes: 3816
// 4/29
// Greedyな過去問攻略

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

const long long MAX_V = 1000000010;

int main() {
    long long X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    long long p[A], q[B], r[C];
    for (long long i = 0; i < A; i++) cin >> p[i];
    for (long long i = 0; i < B; i++) cin >> q[i];
    for (long long i = 0; i < C; i++) cin >> r[i];

    sort(p, p + A);
    sort(q, q + B);
    sort(r, r + C);

    vector<long long> red, green, white, white2;

    // 最終的に食べるベクトルred, greenに、美味しい方から入れていく。
    for (long long i = 0; i < X; i++) red.push_back(p[A - 1 - i]);
    for (long long i = 0; i < Y; i++) green.push_back(q[B - 1 - i]);

    // whiteだけ、お尻が一番美味しいようにする。
    for (long long i = 0; i < C; i++) white.push_back(r[i]);

    while (true) {
        long long r, g, w;
        r = g = w = MAX_V;

        // 無色が残っていない、または、赤と青が両方残っていなければbreak。
        if (white.size() == 0) break;
        if (red.size() == 0 && green.size() == 0) break;

        // 交換候補
        if (red.size() > 0) r = red.back();
        if (green.size() > 0) g = green.back();
        w = white.back();

        // どちらも色付きの方が美味しい場合はブレイク。
        if (w <= r && w <= g) break;

        // そうでない場合。
        // 赤の方が緑よりおいしくない時は、赤を無色と入れ替える。
        if (r < g) {
            red.pop_back();
            white2.push_back(w);
        } else {
            green.pop_back();
            white2.push_back(w);
        }

        white.pop_back();

        // // まず、まだ無色が残っているかを見る。
        // if (white.size() != 0) w = white.back();
        // else break;  // もう交換しようがないので。

        // // 交換候補の美味しさを見るを見る。
        // if (red.size()) 
    }

    long long ans = 0;

    for (int r : red) ans += r;
    for (int g : green) ans += g;
    for (int w : white2) ans += w;

    cout << ans << endl;
}


Measured memory_bytes: 6260
import itertools

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

count = 0

for triple in itertools.combinations(ary_L, 3):
    l = list(triple)
    l.sort()
    a, b, c = l
    if a != b and a != c and b != c and (a + b > c):
        count += 1

print(count)

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

int main() {
    ll N,M;
    cin >> N>>M;
    vector<ll> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    vector<vector<ll>> tree(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >>b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    ll ans =0;
    for(int i=0;i<N;i++){
        bool highest = true;
        for(int child:tree[i]){
            if(H[child] >= H[i]){
                highest =false;
            }
        }
        if(highest){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9860
N,M = list(map(int,input().split()))

e_list = [[] for i in range(N)]

for i in range(M):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    e_list[a].append(b)
    e_list[b].append(a)

from collections import deque


color_list = [-1]*N
def BFS(vi,c):
    Q = deque([vi])
    color_list[vi] = c

    while len(Q)>0:
        v = Q.pop()
        for v1 in e_list[v]:
            if color_list[v1]==-1:
                color_list[v1]=c
                Q.appendleft(v1)

c = 0

for i in range(N):
    if color_list[i]==-1:
        BFS(i,c)
        c+=1

from collections import Counter
C = Counter(color_list)

max_n = 0

for key in C:
    max_n = max(C[key],max_n)

print(max_n)

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

int main()
{
  string a;
  cin >> a;
  string b;
  cin >> b;
  
  int ans = 0;
  
  for( int i = 0 ; i < a.length() ; ++i ){
    if( a[i] != b[i] ) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int q = in();
  set<int> s;
  rep(_,q){
    int kind = in();
    if(kind==0){
      int add = in();
      s.emplace(add);
      cout << s.size() << endl;
    }else{
      int x = in();
      cout << s.count(x) << endl;
    }
  }
}



Measured memory_bytes: 12632
#include<iostream>

using namespace std;

typedef long long ll;

int N;
ll a[2 * 100000 + 10];

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

	int l = 0, r = 0;
	ll Sum = 0, Xor = 0;
	ll ans = 0;
	for (; l < N; l++) {
		//[l, r)
		while (r < N && (Sum + a[r]) == (Xor ^ a[r])) {
			Sum += a[r], Xor ^= a[r];
			r++;
			ans += (r - l);
		}

		if (l == r)r++;
		else Sum -= a[l], Xor ^= a[l];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N, K;
    cin >> N >> K;
    map<int, int> nums_count;
    int nums[N];
    for(int i = 0; i < N; i++){
        cin >> nums[i];
    }
    int left_pointer = 0, right_pointer = 0; // [left, right)
    int ans = 1e9;
    while(right_pointer < N){
        if(nums_count.size() < K){
            if(nums[right_pointer] <= K){
                nums_count[nums[right_pointer]]++;
            }
            right_pointer++;
        }else if(left_pointer != right_pointer){
            if(nums[left_pointer] <= K){
                nums_count[nums[left_pointer]]--;
                if(!nums_count[nums[left_pointer]]){
                    nums_count.erase(nums[left_pointer]);
                }
            }
            left_pointer++;
        }else{
            left_pointer++;
            right_pointer++;
        }
        if(nums_count.size() == K){
            ans = min(ans, right_pointer - left_pointer);
        }
    }
    while(nums_count.size() == K && left_pointer < N){
        if(nums[left_pointer] <= K){
            nums_count[nums[left_pointer]]--;
            if(!nums_count[nums[left_pointer]]){
                break;
            }
        }
        left_pointer++;
        ans = min(ans, right_pointer - left_pointer);
    }
    if(ans == 1e9){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
}




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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#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 mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vll x(n),y(m);
    rep(i,n) cin>>x[i];
    rep(i,m) cin>>y[i];
    mint sumx=0,sumy=0;
    rep(i,n-1){
        mint dx = x[i+1]-x[i];
        sumx+=dx*(i+1)*(n-i-1);
    }
    rep(i,m-1){
        mint dy = y[i+1]-y[i];
        sumy+=dy*(i+1)*(m-i-1);
    }
    cout<<sumx*sumy<<"\n";
    return 0;
}


Measured memory_bytes: 1792
import sys
n,m=map(int,input().split())
vertex=[[int(i) for i in l.split()] for l in sys.stdin]
def find(x):
  if root[x]==x:
    return x
  root[x]=find(root[x])
  return root[x]
def check(x,y):
  return find(x)==find(y)
def union(x,y):
  x=find(x)
  y=find(y)
  if size[x]>=size[y]:
    root[y]=x
  else:
    root[x]=y
  if size[x]==size[y]:
    size[x]+=1
ans=0
for i in range(m):
  root=[i for i in range(n+1)]
  size=[0]*(n+1)
  for j in range(m):
    if j!=i:
      if check(vertex[j][0],vertex[j][1]):
        pass
      else:
        union(vertex[j][0],vertex[j][1])
  for j in range(1,n):
    if check(j,j+1)==True:
      pass
    else:
      ans+=1
      break
print(ans)



Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	int n, cnt;		
	while(cin >> n){
		//??????????????????1???????????\??±??????
		bool prime[n+1] = {false};
		prime[1] = true;
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(!prime[j]){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		//false?????¨????´???°
		for(int i = 1; i <= n; i++){
			if(!prime[i]) cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3964