akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)


int H, i, A[MAX + 1];

int parent(int i) 
{
	return i / 2;
}

int left(int i)
{
	return i * 2;
}

int right(int i)
{
	return i * 2 + 1;
}

void maxHeapify(int i) {
	int l, r, largest;
	l = left(i);
	r = right(i);

	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}

	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}

}

int extract()
{
	int maxv;

	if (H < 1) {
		return -INFTY;
	}
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;

}

void increaseKey(int i, int key) 
{
	if (key < A[i]) {
		return;
	}
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]) 
	{
		swap(A[i],A[i/2]);
		i = i / 2;
	}
}

void insert(int key) {
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(void)
{
	int key;
	string command;

	while (1) {
		cin >> command;

		if (command == "insert") {
			cin >> key;
			insert(key);
		}
		else if (command == "extract") {
			cout << extract() << endl;
		}
		else if (command == "end") {
			break;
		}

	}


	return 0;
}

Measured memory_bytes: 6920
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    Rep(i, N) {
        string s;
        cin >> s;
        Sort(s);
        S[i] = s;
    }
    Sort(S);
    ll cnt = 0, ans = 0;
    string now = "";
    Rep(i, N) {
        if (now == "") {
            now = S[i];
            cnt++;
            continue;
        }
        if (S[i] == now) {
            cnt++;
        }
        else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            now = S[i];
        }
    }
    ans += cnt * (cnt - 1) / 2;
    cout << ans << endl;
    return 0;
}


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

// グラフ
using Graph = vector<vector<int> >;
 
// 探索
vector<bool> seen, finished;
 
// サイクル復元のための情報
int pos = -1; // サイクル中に含まれる頂点 pos
vector<int> hist; // 訪問履歴
 
void dfs(const Graph &G, int v) {
    seen[v] = true;
    hist.push_back(v);
    for (auto nv : G[v]) {
        // 完全終了した頂点はスルー
        if (finished[nv]) continue;
 
        // サイクルを検出
        if (seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }
 
        // 再帰的に探索
        dfs(G, nv);
 
        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) return;
    }
    hist.pop_back();
    finished[v] = true;
}

int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
    }

    // 探索
    seen.assign(N, false), finished.assign(N, false);
    pos = -1;
    for (int v = 0; v < N; ++v) {
        pos = -1;
        dfs(G, v);
        if (pos != -1) break;
    }

    // 有向サイクルなし
    if (pos == -1) {
        cout << -1 << endl;
        return 0;
    }

    // 有向サイクルを復元
    vector<int> cycle;
    while (!hist.empty()) {
        int t = hist.back();
        cycle.push_back(t);
        hist.pop_back();
        if (t == pos) break;
    }
    reverse(cycle.begin(), cycle.end());
    
    // サイクル中に「弦」があったら、小さくする
    while (true) {
        int from = -1, to = -1;
        vector<int> ord(N, -1);
        for (int i = 0; i < cycle.size(); ++i) ord[cycle[i]] = i;
        for (int i = 0; i < cycle.size(); ++i) {
            for (auto nv : G[cycle[i]]) {
                if (nv != cycle[(i+1)%cycle.size()] && ord[nv] != -1) {
                    from = i, to = ord[nv];
                }
            }
        }
        if (from == -1) break; // 弦がなくなって終了

        vector<int> ncycle;
        ncycle.push_back(cycle[from]);
        int id = to;
        while (id != from) {
            ncycle.push_back(cycle[id]);
            id = (id + 1) % cycle.size();
        }
        cycle = ncycle;
        
        //COUT(from); COUT(to); COUT(cycle);
    }
    
    cout << cycle.size() << endl;
    for (auto v : cycle) cout << v + 1 << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	int ans = 0;
	ll n = 0;
	cin >> n;
	vector<ll> a((ll)n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector < ll > b((ll)n);
	for (int i = 0; i < n; ++i) cin >> b[i];

	vector<ll> p;
	ll m = 0;
	for (int i = 0; i < n; ++i)
	{
		ll sa = a[i] - b[i];
		if (sa < 0)
		{
			++ans;
			m += sa;
		}
		else
		{
			p.emplace_back(sa);
		}
	}

	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());

	int i = 0;
	while (1)
	{
		if (m < 0)
		{
			m += p[i];
			++ans;
			++i;
			if (i > p.size() && m < 0)
			{
				cout << -1 << endl;
				return 0;
			}
		}
		else
		{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a, b;
	string op;
	for(int i; ;i++){
		cin >> a >> op >> b;
		if(op=="+"){
			cout<< a+b << endl;
		}else if(op=="-"){
			cout << a-b << endl;
		}else if(op=="*"){
			cout << a*b << endl;
		}else if (op=="/"){
			cout << a/b << endl;
		}else if (op=="?"){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3164
fn main(){
    let n: usize = read();
    let mut v: Vec<usize> = vec![0; n + 1];

    let ls: Vec<usize> = (1..).take_while(|i| i * i < n).collect();

    for x in &ls {
        for y in &ls {
            for z in &ls {
                let m = x * x + y * y + z * z + x * y + y * z + z * x;
                if m <= n {
                    v[m] += 1;
                }
            }
        }
    }
    
    (1 ..= n).for_each(|i| println!("{}", v[i]))
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;

using ll = long long;

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

	ll a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;


	ll dis;

	if (a < 0) {
		if (b < 0) {
			dis = abs(a - b);
		}
		else {
			dis = abs(a) + b;
		}
	}
	else {
		if (b < 0) {
			dis = a + abs(b);
		}
		else {
			dis = abs(a - b);
		}
	}

	ll as = v * t - w * t;

	if (as >= dis) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // ll n;
    string n;
    cin >> n;
    if(n[2] == n[3] && n[4]==n[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}   

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

int main () {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  int m;
  cin >> m;
  string t[m];
  for (int i = 0; i < m; i++) cin >> t[i];
  
  map<string, int> x;
  for (string i : s) {
    if (x.count(i)) {
      x[i] += 1;
    }
    else {
      x[i] = 1;
    }
  }
  for (string i : t) {
    if (x.count(i)) {
      x[i] -= 1;
    }
    else {
      x[i] = -1;
    }
  }
  
  int ans = 0;
  for (string i : s) ans = max(ans, x[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
 
for a in range(N+1):
    for b in range(N+1-a):
        c = N-a-b
        num = a*10000 + b*5000 + c*1000
        if num == Y:
            print("{} {} {}".format(a, b, c))
            exit()
 
print('-1 -1 -1')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,L; cin>>N>>L;
    vector<string> v(N);
    REP(i,N)
        cin>>v[i];
    sort(ALL(v));

    REP(i,N) cout<<v[i];
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
template<class T> struct Fenwick {
    int n;
    T* d;
    Fenwick() : n(0), d(NULL) {}
    Fenwick(int n_) : n(n_) {
	d = new T[n_]();
    }
    Fenwick(const Fenwick &y) : n(y.n) {
	d = new T[n];
	memcpy(d, y.d, sizeof (T) * n);
    }
    ~Fenwick() {
	delete[] d; d = NULL;
	n = 0;
    }
    friend void swap(Fenwick &x, Fenwick &y) {
	swap(x.n, y.n); swap(x.d, y.d);
    }
    Fenwick& operator=(Fenwick y) {
	swap(*this, y);
	return *this;
    }
    inline void add(int i, const T &x) {
	for (; i<n; i|=i+1) d[i] += x;
    }
    inline T sum(int r) {
	T s = T();
	for (; r; r&=r-1) s += d[r-1];
	return s;
    }
    T sum(int l, int r) {
	return sum(r) - sum(l);
    }
};

int N;
int A[3][100011];
bool use[100011];

int calc(const VI &v) {
    int inv = 0;
    Fenwick<int> F(N);
    EACH (e, v) {
	inv ^= F.sum(*e, N);
	F.add(*e, 1);
    }
    return inv&1;
}

void MAIN() {
    scanf("%d", &N);
    REP (t, 3) REP (i, N) {
	scanf("%d", A[t]+i);
	A[t][i]--;
    }

    vector<pair<int, int> > X;
    REP (i, N) {
	int a = A[0][i], b = A[1][i], c = A[2][i];
	if (a % 3 == 0 && b == a+1 && c == a+2) {
	    int x = a/3;
	    use[x] = true;
	    X.emplace_back(x, 1);
	} else if (c % 3 == 0 && b == c+1 && a == c+2) {
	    int x = c/3;
	    use[x] = true;
	    X.emplace_back(x, -1);
	}
    }

    int cnt = 0;
    REP (i, N) if (use[i]) cnt++;

    bool yes = (cnt == N);
    if (yes) {
	int neg[2] = {};
	VI E, O;
	REP (i, N) {
	    if (i%2 != X[i].first%2) yes = false;

	    int sgn = X[i].second;
//	    if (i % 4 >= 2) sgn = -sgn;
//	    if (X[i].first % 4 >= 2) sgn = -sgn;
	    if (sgn == -1) neg[i&1] ^= 1;
	    
	    if (i%2) O.push_back(X[i].first);
	    else E.push_back(X[i].first);
	}

	int inv[2] = {};
	inv[0] = calc(E);
	inv[1] = calc(O);

	if (yes) {
	    yes = (neg[0] == inv[1] && neg[1] == inv[0]);
	}
    }

    puts(yes? "Yes": "No");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3444
#include <iostream>
#include <cstring>
using namespace std;
int n, m, k;
char mat[10][10];
int tmp[10][10], _mat[10][10];
int check(int sr, int sc){
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j) tmp[i][j] = _mat[i][j];
    }
    for(int i = 0; i < n; ++ i){
        if((sr >> i) & 1){
            for(int j = 1; j <= m; ++j) tmp[i + 1][j] = 0;
        }
    }
    for(int j = 0; j < m; ++j){
        if((sc >> j) & 1){
            for(int i = 1; i <= n; ++i) tmp[i][j + 1] = 0;
        }
    }
    int rec = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j) rec += tmp[i][j];
    }
    return rec;
}
int main(){
    memset(_mat, 0, sizeof(_mat));
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> mat[i][j];
            if(mat[i][j] == '#') _mat[i][j] = 1;
        }
    }
    int ans = 0;
    for(int sr = 0; sr < (1 << n); ++sr){
        for(int sc = 0; sc < (1 << m); ++sc){
            if(check(sr, sc) == k) ans ++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<pair<int,int>>pi;
    for(int i=0;i<n;i++){
        pi.push_back(make_pair(arr[i]*2,(k-arr[i])*2));
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=min(pi[i].first,pi[i].second);
    }
    cout<<sum<<endl;
    return 0;
    }


Measured memory_bytes: 256
if __name__ == "__main__":
    H, W = list(map(int, input().split()))
    A = []
    for _ in range(H):
        s = input()
        A.append(s)

    cost = [[float("inf") for i in range(W)] for i in range(H)]

    cost[0][0] = 1 if A[0][0] == '#' else 0

    for i in range(H)[1:]:
        if A[i-1][0] == '.' and A[i][0] == '#':
            cost[i][0] = cost[i-1][0] + 1
        else:
            cost[i][0] = cost[i-1][0]

    for j in range(W)[1:]:
        if A[0][j-1] == '.' and A[0][j] == '#':
            cost[0][j] = cost[0][j-1] + 1
        else:
            cost[0][j] = cost[0][j-1]

    for i in range(H)[1:]:
        for j in range(W)[1:]:

            # right
            if A[i][j-1] == '.' and A[i][j] == '#':
                cost_right = cost[i][j-1] + 1
            else:
                cost_right = cost[i][j-1]

            # down
            if A[i-1][j] == '.' and A[i][j] == '#':
                cost_down = cost[i-1][j] + 1
            else:
                cost_down = cost[i-1][j]

            cost[i][j] = min(cost_down, cost_right)

    # print(cost)
    print(cost[H-1][W-1])


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    ll x, a, b;
    cin >> x >> a >> b;

    if (-a + b <= 0)
        cout << "delicious" << endl;
    else if (-a + b <= x)
        cout << "safe" << endl;
    else
    {
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main()
{

    int k,s;
    while(scanf("%d%d",&k,&s)!=EOF)
    {
        int cnt=0;
        for(int i=0; i<=k; i++)
            for(int j=0; j<=k; j++)
            {
                int z=s-i-j;
                if(z>=0&&z<=k)
                    cnt++;
            }
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input()
# N = int(input())
# K, N = [int(x) for x in input().split()]

S = input()

T = input()

if T[0:len(S)] == S and len(S) + 1 == len(T):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9020
n = int(input())
s = input()
slime = list()
for val in s:
    slime.append(val)
sel = 0
while sel+1 != len(slime):
    if slime[sel] == slime[sel+1]:
        slime.pop(sel+1)
    else:
        sel += 1
print(len(slime))

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  int min,mid,max;
  vector<int> li;
  
  cin >> a >> b >> c;
  li.push_back(a);
  li.push_back(b);
  li.push_back(c);

  sort(li.begin(), li.end());
  
  cout << li.at(0) << " " << li.at(1) << " " << li.at(2) << endl;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define M2 100000007
#define F first
#define S second
#define PB push_back
#define INFL 1000000000000000000
#define INF 1000000000
bool ok[500],tmp[500];
int ans;
string s;
int main(void){
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
		for(int j='a';j<='z';j++)ok[j]=true;
		for(int j=0;j<n-i;j++){
			for(int k='a';k<='z';k++)tmp[k]=false;
			for(int k=j;k<=j+i;k++)tmp[s[k]]=true;
			for(int k='a';k<='z';k++)ok[k]&=tmp[k];
		}
		bool p=false;
		for(int j='a';j<='z';j++)p|=ok[j];
		if(p){
			printf("%d\n",i);
			return 0;
		}
	}
}


Measured memory_bytes: 256
l=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=list(input())
A=set(A)
for i in range(26):
    if l[i] in A:
        pass
    else:
        print(l[i])
        exit()
print("None")

Measured memory_bytes: 3956
#include<cstdio>

const int N=8;
int h,w,cnt,fac;
char s[N+5][N+5];

int main()
{
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cnt += (s[i][j] == '#');
	
	int x,y;
	x=y=1; fac += (s[1][1] == '#');
	while(x<=h && y<=w)
	{
		if(s[x+1][y] == '#')
			x++,fac++;
		else if(s[x][y+1] == '#')
			y++,fac++;
		else
			break;
	}
	puts(cnt == fac? "Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  double K,n=0;
  cin >> S >> K;
  for (int i = 0; i < 100; i++) {
    n += pow((S[i] -'0'),5000000000000000);
    if (n >= K) {
      cout << (S[i] -'0');
      break;
    }
  }
}

Measured memory_bytes: 384
n=int(input())
count1=0
count2=0
count3=0
count4=0
for i in range(n):
    s=input()
    if s=='AC':
        count1+=1
    elif s=='WA':
        count2+=1
    elif s=='TLE':
        count3+=1
    else:
        count4+=1
print('AC x '+str(count1))
print('WA x '+str(count2))
print('TLE x '+str(count3))
print('RE x '+str(count4))

Measured memory_bytes: 9184
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    
    int n = scan.nextInt();
    
    String s = scan.next();
    String t = scan.next();
    
    for(int i = 0; i < n; i ++){
      System.out.print(s.charAt(i));
      System.out.print(t.charAt(i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        auto it = mp.lower_bound(a[i]);
        if(it != mp.begin()){
            it--;
            it -> second--;
            if(it -> second == 0) mp.erase(it);
        }
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto i : mp) ans += i.second;
    cout << ans << endl;
}

Measured memory_bytes: 5248
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
const int mod = (int)1e9 + 7;


int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		int t;
		scanf("%d", &t);
		a[t]++;
	}
	int d;
	if(n % 2){
		d = 1;
	} else{
		d = 0;
	}
	bool f = true;
	for(int i = 0; i < n; i++){
		if(d == 1 && i == 0){
			if(a[i] != 1){
				f = false;
				break;
			}
		}else if((i + d) % 2){
			if(a[i] != 2){
				f = false;
				break;
			}
		}else{
			if(a[i] != 0){
				f = false;
				break;
			}
		}
	}
	if(f){
		int ans = 1;
		for(int i = 0; i < n / 2; i++){
			ans *= 2;
			ans %= mod;
		}
		printf("%d\n", ans);
	}else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for(ll i=1;i*i<=n;i++) {
    if(n%i==0) {
      res.push_back(i);
      if(i!=n/i) {
        res.push_back(n/i);
      }
    }
  }
  return res;
}

int main() {
  ll n,m;
  cin >> n >> m;
  vec div=divisor(m);
  ll ans=1;
  for(ll t:div) {
    if(t*n<=m) ans=max(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
int digit(int a)
{
int r;
r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
return r + 1;
}
int main(){
    quickie;
    //txt;
    int a,b,c,d; cin>>a>>b>>c>>d;
    int a1 = a*b;
    int a2 = c*d;
    cout<<max(a1,a2);
    
    
    return 0;
}

Measured memory_bytes: 3652
(n,),*xy = [list(map(int, s.split())) for s in open(0)]

from collections import Counter
from itertools import combinations
from sys import exit

if n == 1:
    print(1)
    exit()

c = Counter()

for (xa,ya),(xb,yb) in combinations(xy,2):
    c[(xa-xb, ya-yb)] += 1
    c[(xb-xa, yb-ya)] += 1

print(n - max(c.values()))

Measured memory_bytes: 68208
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  string n;
  int k;
  cin >> n >> k;
  int sz =n.size();
  vector<vector<vll>> dp(sz + 1, vector<vll>(2, vll(k+1, 0)));
  dp[0][0][0] = 1;
  REP(i, sz) {
    if (n[i] == '0'){
      REP(l,k+1) dp[i + 1][0][l] = dp[i][0][l];
    } else {
      REP(l, k) dp[i + 1][0][l+1] = dp[i][0][l];
      REP(l, k + 1) dp[i + 1][1][l] += dp[i][0][l];
      int num = n[i] - '0' - 1;
      REP(l, k) dp[i + 1][1][l+1] += num*dp[i][0][l];
    }
    REP(l, k) dp[i + 1][1][l + 1] += 9 * dp[i][1][l];
    REP(l, k + 1) dp[i + 1][1][l] += dp[i][1][l];
  }
  ll ans = 0;
  REP(i,2){
     ans += dp[sz][i][k];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!

var hit = 0

var ans = "No"

for _ in 0..<n {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  if inp[0] == inp[1] {
    hit += 1
  } else {
    hit = 0
  }
  if hit == 3 {
    ans = "Yes"
    break
  }
}
print(ans)

Measured memory_bytes: 8204
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	int h, w;
	cin >> h >> w;
	vector<vector<string>> s(h, vector<string>(w));
	rep(i, h){
		rep(j, w){
			cin >> s[i][j];
		}
	}

	rep(i, h){
		rep(j, w){
			if(s[i][j] == "snuke"){
				cout << (char)('A'+j) << i+1;
			}
		}
	}


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
using namespace std;

int main(void){
    long long N;
    scanf("%lld", &N);

    long long sum;
    for(int i = 1; i < sqrt((long double)N); i++){
        if(N % i != 0){
            continue;
        }

        long long a = i;
        long long m = N / a - 1;
        if(a < m){
            sum += m;
        }

        a = N / i;
        m = N / a - 1;
        if(a < m){
            sum += m;
        }
    }

    printf("%lld\n", sum);
}



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

int msprime[MAX];
int msnum[MAX];

int init(){
  for(int i = 0; i < MAX; i++){
    msprime[i] = false;
    msnum[i] = false;
    if(i % 7 == 1 || i % 7 == 6){
      msnum[i] = true;
      msprime[i] = true;
    }
  }
  msprime[1] = false;
  for(int i = 6; i*i < MAX; i++){
    if(msnum[i] == false) continue;
    if(msprime[i] == true){
      for(int j = i+i; j < MAX; j += i){
        msprime[j] = false;
      }
    }
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  init();
  while(cin >> n, n != 1){
    set<int> ans;
    for(int i = 6; i < MAX; i++){
      if(msprime[i] == false) continue;
      if(n % i == 0) ans.insert(i);
    }
    cout << n << ":";
    for(auto it = ans.begin(); it != ans.end(); it++){
      cout << " " << *it;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5436
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
#define N 105
int n,x[N],y[N],h[N],t,a,b,c,H;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&y[i],&h[i]),t=h[i]>0?i:t;
    for(int i=0;i<=100;i++)
        for(int j=0;j<=100;j++)
        {
            bool f=true;
            a=i; b=j; c=h[t]+abs(i-x[t])+abs(j-y[t]);
            for(int k=1;k<=n;k++)
            {
                H=max(0,c-abs(i-x[k])-abs(j-y[k]));
                if(H!=h[k]) {f=false;break;}
            }
            if(f==true)
            {
                printf("%d %d %d\n",a,b,c);
                return 0;
            }
        }
    puts("error");
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println(a>8||b>8?":(":"Yay!");
	}
}


Measured memory_bytes: 21716
#include <stdio.h>

double func(double a ,double b,double c,double d,double e,double f){
	return (c*d-a*f)/(b*d-a*e);
}

int main(void){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
		y=func(a,b,c,d,e,f);
		x=(c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
typedef long long LL;
int main() {
	LL a = 0, b = 0, x = 0;
	LL calc(LL n, LL x);
	std::cin >> a >> b >> x;
	if (a == 0) {
		std::cout << calc(b, x) - calc(-1, x) << std::endl;
	}
	else {
		std::cout << calc(b, x) - calc(a - 1, x) << std::endl;
	}
	return 0;
}
LL calc(LL n, LL x) {
	if (n == -1) {
		return 0;
	}
	return n/x+1;
}

Measured memory_bytes: 256
#include <iostream>
int main()
{
   int a;
   std::cin >> a;
   int ans = 0;
   for (int i=1; i<=a; i+=2) {
      int count = 0;
      for (int x=1; x<=i; x++) {
         if (i%x == 0) count++;
      }
      if (count == 8) ans++;
   }
   std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	int a,b,c;
	scanf("%d%d%d", &a, &b, &c);
	if(a+b+c>=22) printf("bust\n");
	else printf("win\n");
	
	//printf("%ld\n", min);

	return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10)
            ans++;
    }
    c(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		double odd = 0;
		for(int i = 1; i <= a; i++)
			if(i % 2 == 0)
				odd++;
		System.out.printf("%.10f", (1 - (odd / a)));
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(int argc, char **argv){
	int i,j;
	int h,w;

	for(;;){
		// Input
		scanf("%d %d",&h, &w);
		// Finish Check
		if( h == 0 && w == 0 ){
			break;
		}
		// Output
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main() {
  int ary[3];

  for (int i=0; i<3; i++) cin >> ary[i];

  sort(ary, ary+3);

  // for (int i=0; i<3; i++) cout << ary[i] << " ";
  // cout << endl;
  cout << ary[0] << " " << ary[1] << " " << ary[2] << endl;
  
  return 0;
}



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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;


class DSU{
   public:
   vector <int> id , sz;
   DSU(int n){
      id.resize(n+1);
      sz.resize(n+1);
      for(int i=0 ; i<=n ; i++){
         id[i] = i;
         sz[i] = 1;
      }
   }

   int root(int i){
      while(i != id[i])   id[i] = id[id[i]] , i = id[i];
      return i;
   }

   void uni(int a, int b){
      int ra = root(a);
      int rb = root(b);
      if(ra == rb)   return;
      if(sz[ra] < sz[rb]) swap(ra,rb);
      id[rb] = ra , sz[ra] += sz[rb];
   }
};

int32_t main() {
   fast;
   int n,m;
   cin >> n >> m;

   DSU ds(n+1);

   f(i,0,m){
      int u,v;
      cin >> u >> v;
      ds.uni(u,v);
   }

   set<int> s;
   f(i,1,n+1)  s.insert(ds.root(i));
   int ans = sz(s) - 1;

   cout << ans << "\n";
}

Measured memory_bytes: 8476
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);

        int[] anntena = new int[5];
        for (int i = 0; i < 5; i++) {
            anntena[i] = sc.nextInt();
        }
        int k = sc.nextInt();

        String ans = "Yay!"; 
        for (int i = 0; i < 5; i++) {
            for (int j = i; j < 5; j++) {
                int distance = anntena[j] - anntena[i];
        
                if (distance > k) {
                    ans = ":(";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
def main():
    N = int(input())
    S = input()
    count = [0 for _ in range(N)]

    for i in range(1,N):
        s1 = S[:i]
        s2 = S[i:]
        a = ""
        for s in s1:
            if (s in a)==False:
                a += s
                if s in s2:
                    count[i] += 1
    return max(count)

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


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

using namespace std;

#define MAX 200
#define INF 1000002
typedef pair<int, int> pii;

int H, W, N;
int X1[MAX], X2[MAX], Y1[MAX], Y2[MAX];
bool fld[MAX*6][MAX*6];

int compress(int *x1, int *x2)
{
    vector<int> xs;
    for (int i = 0; i < N; i++) {
        for (int d = -1; d <= 1; d++) {
            int tx1 = x1[i] + d, tx2 = x2[i] + d;
            xs.push_back(tx1);
            xs.push_back(tx2);
        }
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());

    for (int i = 0; i < N; i++) {
        x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
        x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
    }
    return xs.size();
}

int solve()
{
    W = compress(X1, X2);
    H = compress(Y1, Y2);
    
    memset(fld, 0, sizeof(fld));
    for (int i = 0; i < N; i++) {
        for (int y = Y1[i]; y <= Y2[i]; y++) {
            for (int x = X1[i]; x <= X2[i]; x++) {
                fld[y][x] = 1;
            }
        }
    }
    
    const int dx[] = {-1, 0, 1, 0};
    const int dy[] = {0, -1, 0, 1};
    
    int res = 0;
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (fld[y][x]) continue;            
            res++;

            queue<pii> Q;
            Q.push(pii(x, y));
            while (!Q.empty()) {
                pii p = Q.front(); Q.pop();
                int sx = p.first, sy = p.second;

                for (int i = 0; i < 4; i++) {
                    int tx = sx + dx[i], ty = sy + dy[i];
                    if (tx < 0 || W <= tx || ty < 0 || H <= ty || fld[ty][tx]) {
                        continue;
                    }

                    Q.push(pii(tx, ty));
                    fld[ty][tx] = 1;
                }

            }
        }

    }
    return res;
}

int main()
{
    while (cin >> N, N) {
        H = W = INF;
        int x[2], y[2];
        for (int i = 0; i < N; i++) {
            cin >> x[0] >> y[0] >> x[1] >> y[1];
            for (int j = 0; j < 2; j++) {
                x[j] = x[j] * 2 + 1;
                y[j] = y[j] * 2 + 1;
            }
            int dj[] = {1, 0, 0, -1}, dk[] = {0, -1, 1, 0};
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    int l = j * 2 + k, m = i * 4 + l;
                    int nj = j + dj[l];
                    int nk = k + dk[l];
                    X1[m] = x[j];  Y1[m] = y[k];
                    X2[m] = x[nj]; Y2[m] = y[nk];
                    if (X1[m] > X2[m]) swap(X1[m], X2[m]);
                    if (Y1[m] > Y2[m]) swap(Y1[m], Y2[m]);
                }
            }                        
        }
        N *= 4;
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 4512
n = int(input())
l = [[0 for _ in range(10)] for __ in range(10)]
for i in range(1, n+1):
    a, b = int(str(i)[0]), int(str(i)[-1])
    l[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += l[i][j]*l[j][i]
print(ans)

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

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

    int left = max(-1000000, X - K + 1);
    int right = min(1000000, X + K - 1);

    for (int i = left; i <= right; i++)
        cout << i << " ";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n;
	vector <lli> ar(5);
	cin >> n;
	for(lli &x: ar) cin >> x;
	lli mn = *min_element(ALL(ar));
	cout << fixed << ((n-1) / mn) + 5;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string S;
	bool check[26]={};
	cin >> S;
	
	for(int i=0;i<S.size();i++){
		if(check[S[i]-'a']){
			cout << "no" << endl;
			return 0;
		}else{
			check[S[i]-'a'] = true;
		}
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    int m = 0;
    REPF(i, 1, N * 2 + 1) {
        if (i * (i - 1) / 2 == N) {
            m = i;
            break;
        }
        if (i * (i - 1) / 2 > N) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (m == 0) {
        cout << "No" << endl;
        return 0;
    }
 
    vector<vector<int>> g(m);
    int edge = 0;
    REP(i, m) {
        REPF(j, i + 1, m) {
            g[i].pb(edge);
            g[j].pb(edge);
            edge++;
        }
    }
    
    cout << "Yes" << endl;
    cout << SZ(g) << endl;
    REP(i, m) {
        cout << SZ(g[i]) << " ";
        REP(j, SZ(g[i])) {
            cout << g[i][j] + 1;
            if (j != SZ(g[i]) - 1) cout << " ";
            else cout << endl;
        }
    }
    return (0^_^0);
}



Measured memory_bytes: 3200
ans = 0
A, B, C = map(int, input().split())
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0 and ans < 1000:
        A, B, C = B/2+C/2, C/2+A/2, A/2+B/2
        ans += 1
if ans == 1000:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 9144
#include <stdio.h>
int main(){
	int P[3];
	scanf("%d %d %d",&P[0],&P[1],&P[2]);
  	int min = 300;
  	for (int i=0;i<3;i++){
      for (int j=0;j<3;j++){
        if (i!=j){
          int a = P[i]+P[j];
          if (a<min){
            min = a;
          }
        }
      }
    }
  	printf("%d",min);
  	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

static const int N = 100;
int c=0;

void SelectionSort(int A[],int n){
  int i,j,k,temp,mini;

  for(i=0;i<n-1;i++){
    mini=i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[mini]){
	mini=j;
      }
    }
    if(A[i]!=A[mini]){
        /*swap*/
	temp=A[i];
	A[i]=A[mini];
	A[mini]=temp;
	c++;
    }
  }
}

main(){
  int i,j,n;
  int A[N+1];

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  SelectionSort(A,n);

  for(j=1;j<=n;j++){
    if(j>1) printf(" ");
    printf("%d",A[j-1]);
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 604
s = input()
t = input()

s_len = len(s)
t_len = len(t)

out = t_len

for i in range(0, s_len - t_len + 1):
    diff = 0
    for j in range(0, t_len):
        if t[j] != s[i + j]:
            diff += 1
    out = min(out, diff)

print(out)


Measured memory_bytes: 8996
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<0.5*w*h<<" "<<(2*x==w && 2*y==h)<<"\n";
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:Chars
    }
    let c = n.iter().filter(|&&x| x == 'R').count();
    if c == 3 {
        println!("{}", 3);
    } else if c == 2 {
        if n[1] == 'R' {
            println!("{}", 2);
        } else {
            println!("{}", 1);
        }
    } else if c >= 1 {
        println!("{}", 1);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 2172
#!/usr/bin/env python3
a = [0]*9
bit = [[0]*3 for _ in range(3)]
for i in range(3):
    a[i*3],a[i*3+1],a[i*3+2] = map(int,input().split())
#print(a)
n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        k = a.index(b)
        bit[k//3][k%3] = 1
#print(bit)
for i in range(3):
    if bit[i][0]*bit[i][1]*bit[i][2] == 1:
        print("Yes")
        exit()
    if bit[0][i]*bit[1][i]*bit[2][i] == 1:
        print("Yes")
        exit()
if bit[0][0]*bit[1][1]*bit[2][2] == 1 or bit[2][0]*bit[1][1]*bit[0][2] == 1:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define int64 long long int
int d[99],ld;
int calc(int64 x){
	while(x){
		d[ld++] = x%10;
		x/=10;
	}
	int w = d[ld-1]-1;
	for(int i=ld-2; i>=0; i--)
		w += 9;
	return w;
}
int main(){
	int64 n;
	cin >> n;
	cout << calc(n+1) << endl;
	return 0;
}

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

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x;}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a,b);
    ll ans = 1;

    for(ll i=2; i*i <= g; i++){
        if(!(g%i)) {
            ans++;
            g /= i;
            while(!(g%i)){
                g /= i;
            }
        }
    }

    if(g != 1) ans++;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3520
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
using namespace std;

int main() {
      int N;
    cin >> N;
  vector<int> A(N);
    for(int i = 0;i< N;i++) cin >> A[i];
  int ans = 0;
  ans += abs(A[0]) + abs(A[N-1]);
  for (int i = 0;i<N-1;i++){
  ans += abs(A[i+1]-A[i]);}
  int kota = 0;
  for(int i = 0;i<N;i++){
  kota = ans - abs(A[i] - A[i-1]) + abs(A[i+1] - A[i-1]) - abs(A[i+1] - A[i]);
  cout << kota << '\n';}
}
  

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    char a,b; cin >> a >> b;
    if (a == b) cout << 'H' << endl;
    else cout << 'D' << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;


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

	int N;
	cin >> N;

	map<int,int> m;
	rep(i,N){
		int a;
		cin >> a;
		m[a]++;
		m[a-1]++;
		m[a+1]++;
	}

	for(auto p:m){
		ans = max(ans,p.second);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4736