akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000 
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
int *s, f; inline bool cmps(int i, int j){return s[i]<s[j];}
struct Prog
{
	vector<int> e[MAXN+5]; int n, r, _, d[MAXN+5], s[MAXN+5], c[MAXN+5], Ans[MAXN+5];
	void Find(int p, int fa){(d[p]=d[fa]+1)>d[r]?r=p:0; for(auto v:e[p]) v^fa ? Find(v,p),0 : 0;}
	void DFS_s(int p, int fa){s[p] = 1; for(auto &v:e[p])if(v==fa){swap(v,e[p].back()),e[p].pop_back();break;} for(auto v:e[p]) DFS_s(v,p), s[p] += s[v];}
	void DFS_p(int p){sort(e[p].begin(),e[p].end(),cmps); for(auto v:e[p])if(v^e[p].back()&&s[v]>1) puts("-1"), exit(0); c[p] = ++_; for(auto v:e[p])if(v^e[p].back()) DFS_p(v); if(e[p].size()) DFS_p(e[p].back());}
	void Print(int p){for(auto v:e[p])if(v^e[p].back()) Print(v); Ans[++_] = c[p]; if(!e[p].size()) return; Print(e[p].back());}
}T[2];
int main()
{
	T[0].n = read(); for(rint i = 2, a, b; i <= T[0].n; a = read(), b = read(), T[0].e[a].push_back(b), T[0].e[b].push_back(a), i++); T[1] = T[0];
	s = T[0].s, T[0].Find(1,0), T[0].DFS_s(T[0].r,0), T[0].DFS_p(T[0].r), T[0]._ = 0, T[0].Print(T[0].r), s = T[1].s, T[1].Find(T[0].r,0), T[1].DFS_s(T[1].r,0), T[1].DFS_p(T[1].r), T[1]._ = 0, T[1].Print(T[1].r);
	for(rint i = 1; i <= T[0].n; i++) if(T[0].Ans[i]^T[1].Ans[i]) f = T[0].Ans[i]>T[1].Ans[i]; for(rint i = 1; i <= T[f].n; printf("%d ",T[f].Ans[i]), i++); return 0;
}

Measured memory_bytes: 18048
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	l := 0
	r := strings.Count(s, ".")
	ans := r + l
	for i := 0; i < n; i++ {
		if s[i] == '#' {
			l++
		} else {
			r--
		}
		if v := r + l; v < ans {
			ans = v
		}
	}
	fmt.Println(ans)
}


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

const int MAXN = 300001;
int X[MAXN];
int Y[MAXN];
int XS[MAXN];
int YS[MAXN];

int main()
{
    int W, H, M;
    cin >> W >> H >> M;

    int xmax = 0, ymax = 0;
    for (int i=0;i<M;++i)
    {
        cin >> X[i] >> Y[i];
        xmax = max(xmax, ++XS[X[i]]);
        ymax = max(ymax, ++YS[Y[i]]);
    }

    int xn = 0, yn = 0;
    for (int x=0;x<=W;++x) { if (XS[x] == xmax) { ++xn; } }
    for (int y=0;y<=H;++y) { if (YS[y] == ymax) { ++yn; } }

    int zn = 0;
    for (int i=0;i<M;++i) { if (XS[X[i]] == xmax && YS[Y[i]] == ymax) { ++zn; } }

    cout << xmax + ymax - (zn == xn * yn ? 1 : 0) << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll x;
	cin >> x;

	ll y = 100;
	ll cnt = 0;
	while (y < x) {
		y *= 1.01;
		cnt++;
		if (y >= x) {
			break;
		}
	}

	out(cnt);

	return 0;
}

Measured memory_bytes: 3656
from math import gcd
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        ab = gcd(i,j)
        if ab == 0:
            continue
        for k in range(1,K+1):
            ans += gcd(ab,k)

print(ans)

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

  
// Function to print Excel column name for a given column number 

int main()
{
	ll n;
	cin >> n;
	string a;// To store result (Excel column name) 
    ll i = 0; // To store current index in str which is result 
  
    while (n > 0) { 
        // Find remainder 
        ll rem = n % 26; 
  
        // If remainder is 0, then a 'Z' must be there in output 
        if (rem == 0LL) { 
            a+= 'z';
            n = (n / 26LL) - 1LL; 
        } 
        else // If remainder is non-zero 
        { 
            a+= (rem - 1LL) + 'a'; 
            n = n / 26LL; 
        } 
    } 
    
  
    // Reverse the string and print result 
    reverse(a.begin(),a.end()); 
    cout << a;
	
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
#define X first
#define Y second

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Union-Find **/
const int MAX_N = 1000;
const int MAX_E = 50000;

class UnionFind {
public:
	int par[MAX_N];
	int rank[MAX_N];
	
	void init(int n)
	{
		rep(i, n) {
			par[i]=i;
			rank[i]=0;
		}
	}
	
	int find(int x)
	{
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y) return;
		
		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

/** 最小全域木 kruskal法 O(|E|log|V|) **/
struct edge {int u, v, cost;};

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

edge es[MAX_E];
vector<int> tmp;
int V, E;

int kruskal(int notuse)
{
	UnionFind UF;
	UF.init(V);
	int res=0;
	for (int i=0; i<E; i++) {
		if (i == notuse) continue;
		
		edge e = es[i];
		if (!UF.same(e.u, e.v)) {
			UF.unite (e.u, e.v);
			
			if (notuse==-1)
				tmp.push_back(i);
			
			res += e.cost;
		}
	}
	return res;
}

int main()
{
	
	cin>>V>>E;
	rep(i, E) {
		cin>>es[i].u>>es[i].v>>es[i].cost;
		es[i].u--, es[i].v--;
	}
	
	sort(es, es+E, comp);
	int mst_cost = kruskal(-1);
	
	int ans=0, sum=0;
	rep(i, tmp.size()) {
		if (mst_cost != kruskal(tmp[i])) {ans++, sum+=es[tmp[i]].cost;}
	}
	
	cout << ans << " " << sum << endl;
}

Measured memory_bytes: 1820
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

#define INF (1 << 24)

int d(int n) {
	return n * n;
}

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

int v_to_int(vector<bool> v) {
	int ret = 0;
	for (int i = 0; i < v.size(); ++i) {
		ret <<= 1;
		ret |= v[i];
	}
	return ret;
}

double EPS = 1e-9;

int main() {
	int L;
	while ( scanf("%d", &L) != EOF ) {
		vector<int> v;

		char c;
		while ( c = getchar(), c != '\n' && c != '\r' && c != EOF ) {
			int a; scanf("%d", &a);
			v.push_back(a);
		}

/*
		sort( v.begin(), v.end() );

		int n = v.size();
		vector<int> v1, v2;
		for (int i = 0; i < n/2; ++i)
			v1.push_back(v[i]);

		for (int i = n/2; i < n; ++i)
			v2.push_back(v[i]);
*/

		int n = v.size();
		vector< vector<double> > len(n, vector<double>(n, INF));
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				len[i][j] = sqrt( d(v[i]+v[j]) - d( abs(v[i]-v[j]) ) );

		priority_queue<P, vector<P>, greater<P> > Q;
		for (int i = 0, k = 1; i < n; ++i, k *= 2) {
			Q.push( P( v[i], make_pair(i, k) ) );
		}

		double ans = INF;
		double cost[1<<12][12]; fill(&cost[0][0], &cost[0][0]+(1<<12)*12, INF);
		while ( !Q.empty() ) {
			P p = Q.top(); Q.pop();

			double length = p.first;
			int head = p.second.first;
			int prev = p.second.second;

			int sz = 0;
			for (int i = 0, k = 1; i < n; ++i, k *= 2)
				sz += !!(prev & k);

			if (sz >= n) {
				if (length + v[head] < ans)
					ans = length + v[head];

				continue;
			}

			for (int i = 0, k = 1; i < n; ++i, k *= 2) {
				if (prev & k) continue;

				int new_prev = prev | k;

				if (length + len[head][i] + v[i] > cost[new_prev][head] - EPS) continue;
				cost[new_prev][head] = length + len[head][i] + v[i];

				Q.push( P( length + len[head][i], make_pair(i, new_prev) ) );
			}
		}

//		cout << ans << endl;
		if (ans <= L) cout << "OK" << endl;
		else cout << "NA" << endl;


	}
}

Measured memory_bytes: 2248
import java.util.*;
import java.util.Arrays;

public class Main{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                String src = scan.next();
                String Array[] = src.split("");
                List<String> list = Arrays.asList(Array);

                int count0 = Collections.frequency(list, "0");
                int count1 = Collections.frequency(list, "1");

                if(count0 > count1){
                        System.out.println(count1*2);
                }else{
                        System.out.println(count0*2);
                }
        }
}

Measured memory_bytes: 34756
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;

int ans = 0;

void solve(){
	//一回あたりに引き出せる額を全部ここに格納
	vector<int> money_list;
	money_list.push_back(1);
	for(int i=6;i<=N;i*=6) money_list.push_back(i);
	for(int i=9;i<=N;i*=9) money_list.push_back(i);
	//i円引き出すのに必要な最小回数
	vector<int> dp(N+1,INF_INT);
	dp[0] = 0;
	//ばらまくイメージ
	for(int i=0;i<N;i++){
		for(int money : money_list){
			if(i+money<=N){
				dp[i+money] = min(dp[i+money],dp[i] + 1);
			}
		}
	}
	ans = dp[N];
}
 
int main(){
    cin >> N;
 
    solve();

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

Measured memory_bytes: 640
from collections import Counter

N = int(input())
A = Counter(map(int, input().split()))
MOD = 10 ** 9 + 7

if N % 2:
    if A == Counter((i + 1) // 2 * 2 for i in range(N)):
        print(pow(2, (N - 1) // 2, MOD))
    else:
        print(0)
else:
    if A == Counter(i // 2 * 2 + 1 for i in range(N)):
        print(pow(2, N // 2, MOD))
    else:
        print(0)


Measured memory_bytes: 16624
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    long a,b,c,k;
    cin >>a>>b>>c>>k;
    long ans;
    
    if(k<=a) {
        ans = k;
    } else if(k<=a+b) ans = a;
    else ans = a-(k-a-b);

    cout<< ans;


    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<int> ret(n + 1);
    for (int x = 1; x <= 100; ++x) {
        for (int y = 1; y <= 100; ++y) {
            for (int z = 1; z <= 100; ++z) {
                lint f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f <= n)
                    ret[f]++;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

int h, w; 

void solve() {
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	vector<vector<int>> b(h, vector<int>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }
    rep(i, h) {
        rep(j, w) {
            cin >> b[i][j];
        }
    }
	vector<vector<bitset<300000>>> dp(h, vector<bitset<300000>>(w, 0));
	//bitset<300000> dp[85][85];
	int x = a[0][0] - b[0][0] + 80;
	int y = b[0][0] - a[0][0] + 80;
	dp[0][0][x] = 1;
	dp[0][0][y] = 1;
	rep(i, h) {
		rep(j, w) {
			if(i - 1 >= 0) dp[i][j] |= (dp[i - 1][j] << (a[i][j] - b[i][j] + 80));
			if(i - 1 >= 0) dp[i][j] |= (dp[i - 1][j] << (b[i][j] - a[i][j] + 80));
			if(j - 1 >= 0) dp[i][j] |= (dp[i][j - 1] << (a[i][j] - b[i][j] + 80));
			if(j - 1 >= 0) dp[i][j] |= (dp[i][j - 1] << (b[i][j] - a[i][j] + 80));
		}
	}
	int ans = inf;
	rep(k, 300000) {
		if(dp[h - 1][w - 1][k]) {
			chmin(ans, abs(k - (h + w - 1) * 80));
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 237824
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> c(N);
  vector<vector<int>> a(N);
  rep(i, N) {
    cin >> c[i];

    a[i].resize(M);
    rep(j, M) {
      cin >> a[i][j];
    }
  }

  int mn = -1;
  rep(i, 1<<N) {
    int yen = 0;
    vector<int> m(M, 0);

    for (int j = 0; j < N; j++) {
      if (i & 1<<j) {
        yen += c[j];
        rep(k, M) {
          m[k] += a[j][k];
        }
      }
    }

    bool success = true;
    rep(k, M) {
      if (X > m[k]) {
        success = false;
        break;
      }
    }

    if (success && (mn == -1 || mn > yen)) {
      mn = yen;
    }
  }

  cout << mn << endl;

  return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      
      	if(a == b + c){
		        System.out.println("Yes");          
        }else if(b == a + c){
        		System.out.println("Yes");
        }else if(c == a + b){
          		System.out.println("Yes");
        }else{
          		System.out.println("No");
        }
    }
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<P> island(M);

    rep(i, M) {
        cin >> island[i].second >> island[i].first;
    }

    sort(all(island));

    int t = 0;
    int ans = 0;
    rep(i, M) {
        if (t <= island[i].second) {
            t = island[i].first;
            ans++;
        }
    }

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

Measured memory_bytes: 1152
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
a=0
for i in range(n):
    if i%2==0:
        a+=A[i]
    else:
        a-=A[i]
ans=[a]
for i in range(n-1):
    ans.append((A[i]-ans[-1]//2)*2)
print(*ans, sep=' ')

Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,t;
  cin >> n;
  deque<ll> q;
  for(ll i = 0; i < n; ++i){
    cin >> t;
    auto it = lower_bound(begin(q),end(q),t);
    if(it == begin(q)) q.push_front(t);
    else{
      ll idx = it-begin(q);
      q[idx-1] = t;
    }
  }
  cout << q.size();
  return 0;
}

Measured memory_bytes: 1024
# use faster method than input()
import sys
input = sys.stdin.readline

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

l = [0]*(H*W)
prev = 0
for i, a in enumerate(A):
    color = i+1
    cnt = 0
    while cnt < a:
        l[cnt+prev] = color
        cnt += 1
    prev = prev+a

for i in range(H):
    sub_l = l[W*i:W*(i+1)]
    if i % 2 == 0:
        print(" ".join(map(str, sub_l)))
    else:
        sub_l = sub_l[::-1]
        print(" ".join(map(str, sub_l)))


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long int ll;
typedef long double ld;


int main(){
    ll a,ans;
    cin >> a;
    for (ll i=1;i<a+1;++i){
        ans+=i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        vector<int> a(n * 2);
        REP(i, n) {
                cin >> a[i];
                a[i + n] = a[i] + k;
        }

        int ans = numeric_limits<int>::max();
        REP(i, n) {
                ans = min(ans, a[n + i] - a[i + 1]);
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long int ans = 0;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            int num = N - R * i - G * j;
            if(num >= 0 && num % B == 0){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <iomanip>

using namespace std;

const int OKU7 = 1000000007;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	string str;

	cin >> n >> k;
	cin >> str;

	str[k - 1] = str[k - 1] + ('a' - 'A');

	cout << str;
	
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

i = 0
min = 10000000000

def get_num(i, j, a)
  if i == 0
    l = 0
  else
    l = a[i - 1]
  end
  num = a[j] - l
  return num
end


b_a = Array.new(n, 0)
w_a = Array.new(n, 0)

s.each_char.with_index do |c, i|
  if c == '#'
    b_a[i] = b_a[i - 1] + 1
  else
    b_a[i] = b_a[i - 1]
  end
end

s.each_char.with_index do |c, i|
  if c == '.'
    w_a[i] = w_a[i - 1] + 1
  else
    w_a[i] = w_a[i - 1]
  end
end

s.each_char.each_cons(2) do |c1, c2|
  i = i + 1
  #l_w = s[0..i - 1].count('.')
  #l_b = s[0..i - 1].count('#')
  #r_w = s[i..-1].count('.')
  #r_b = s[i..-1].count('#')
  l_w = get_num(0, i - 1, w_a)
  l_b = get_num(0, i - 1, b_a)
  r_w = get_num(i, -1, w_a)
  r_b = get_num(i, -1, b_a)
  co = [l_b + r_w, l_b + r_b, l_w + r_w].min
  if co < min
    min = co
  end
end

if min == 10000000000
  puts 0
else
  puts min
end


























Measured memory_bytes: 5372
#include <stdio.h>
const int N=31;
int main(){
    int n,dp[N];
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for(int i=3;i<N;i++)dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        printf("%d\n",(dp[n]+3649)/3650);
    }
}


Measured memory_bytes: 2748
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Maybe (fromJust)


data Point = Point { x::Int, y::Int } deriving Show
type Student = Point
data CheckPoint = CheckPoint { identifier :: Int, point :: Point }

pointX :: CheckPoint -> Int
pointX = x . point

pointY :: CheckPoint -> Int
pointY = y . point


readIntLine :: IO [Int]
readIntLine = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


toStudent :: [Int] -> Student
toStudent (x:y:_) = Point { x=x, y=y }


toPoint :: Int -> [Int] -> CheckPoint
toPoint idx (x:y:_) = CheckPoint { identifier=idx, point=Point{x=x,y=y} }


toPointList :: Int -> [[Int]] -> [CheckPoint]
toPointList _ [] = []
toPointList idx (x:xs) = (toPoint idx x):(toPointList (idx + 1) xs)


getNearestPoint :: [CheckPoint] -> Student -> Int -> Int -> Int
getNearestPoint [] _ _ minIdx = minIdx
getNearestPoint (p:ps) student minDistance minIdx = getNearestPoint ps student nextValue nextIdx
    where
        d = abs((pointX p) - (x student)) + abs((pointY p) - (y student))
        nextValue = min d minDistance
        nextIdx = if (d < minDistance) then (identifier p) else minIdx


solve :: [CheckPoint] -> [Student] -> [Int]
solve _ [] = []
solve points (s:ss)
    = (getNearestPoint points s  1000000000 0):(solve points ss)

main :: IO ()
main = do
    (n:m:_) <- readIntLine
    ab <- replicateM n readIntLine
    c <- replicateM m readIntLine
    let students = map toStudent ab
        points = toPointList 1 c
        ans = solve points students
    forM_ ans print


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string test;
	cin >> test;
	string re = "CODEFESTIVAL2016";
	int ans = 0;
	for (int i = 0; i < 16; i++) {
		if (test[i] != re[i])
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    string s;
    cin>>s;
    int n=s.size();
    int cnt,cen=n/2;
    if(n%2==1){
        cnt=1;
        for(int i=1;i<=n/2;i++){
            if(s[cen]==s[cen-i]&&s[cen-i]==s[cen+i])
                cnt+=2;
            else
                break;
        }
    }else{
        cnt=0;
        for(int i=0;i<n/2;i++){
            if(s[cen]==s[cen+i]&&s[cen+i]==s[cen-1-i])
                cnt+=2;
            else
                break;
        }
    }
    cout<<(n+cnt)/2<<endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=3010,O=1000000007;
int f[N][N][2];
int main(){
	int n=ni,m=ni;
	memset(f,0,sizeof(f));
	for(int i=0;i<=n;i++){
		f[0][i][i==0]=1;
	}
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<2;k++){
				int F=f[i-1][j][k];
				if(F==0)continue;
				int cnt1=j,cnt2=n-j;
				for(int a=0;a<=1;a++){
					if(cnt1-a<0)continue;
					if(cnt2-(!a)<0)continue;
					for(int b=0;b<=1;b++){
						(f[i][cnt1-a+1-b][k||cnt1-a==0||cnt1-a+1-b==0]+=F)%=O;
					}
				}
			}
		}
	}
	lint ans=0;
	for(int i=0;i<=n;i++){
		ans+=f[m][i][1];
	}
	printf("%lld\n",ans%O);
	return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int a, b, c;
    cin >> a >> b >> c;
    
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =       100'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    if(N > M) swap(N, M);
    COMinit();
    if(N+1 == M) {
        cout << (fac[N] * fac[M]) % MOD << endl;
    } else if(N == M) {
        cout << ((fac[N] * fac[M]) % MOD * 2) % MOD << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

#define ll long long  
#define endl "\n"

const ll int MOD=1e9+7;

//Learn : Jab bhi upper to lower karo
// toh round use karloo

void solve()
{
	ll a; float b;
	cin >> a >> b;
	int c = round(b*100);
	cout << (a*c)/100<< endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}

Measured memory_bytes: 3672
n,m=map(int,input().split(" "))
lis2=map(int,input().split(" "))

lis2=sorted(lis2,reverse=True)
sum1=sum(lis2)
count=0
for i in range(0,m):
  if(lis2[i]>=((1/(4*m))*sum1)):
    count=0
  else:
    count=1
    break
if(count==1):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

const int mod = 1e9 + 7;
const int N = 2e5;
int f[N], inv[N];
int pow_mod(int a, int b) {
    if(b == 0) {
        return 1;
    }
    int mid = pow_mod(a, b / 2);
    if(b % 2 == 0) {
        return (mid * mid) % mod;
    }else {
        return (((a * mid) % mod) * mid) % mod;
    }
}

int ent(int n, int k) {
    if(k > n) {
        return 0;
    }
    return (((f[n] * inv[n - k]) % mod) * inv[k]) % mod; 
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    f[0] = 1;
    for(int i = 1; i < N; i++) {
        f[i] = i * f[i - 1];
        f[i] %= mod;
    }
    for(int i = 0; i < N; i++) {
        inv[i] = pow_mod(f[i], mod - 2);
    }

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int ans = ent(w - b - 1 + h - 1, w - b - 1);
    ans %= mod;
    for(int i = 1; i <= h - a - 1; i++) {
        ans += (((ent(i + b, i) - ent(i - 1 + b, i - 1) + mod) % mod) * (ent(h + w - 2 - i - b, w - b - 1))) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
}

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

#define ll long long int
#define pi pair<int,int>
const int N=1e5+5;

vector<vector<pi> > graph;
vector<int> colour,visited;
int n;

void dfs(int node,int par=0,int col=1){
    visited[node] = 1;
    colour[node] = col;
    for(auto it:graph[node]){
        if(it.first==par)
            continue;
        else if(it.second%2==1)
            dfs(it.first,node,1-col);
        else 
            dfs(it.first,node,col);
    }
}

int main(){
    cin >> n;
    graph.resize(n+1);
    colour.resize(n+1);
    visited.resize(n+1,0);
    fill(visited.begin(),visited.end(),0);
    for(int i=1;i<n;i++){
        int u,v,w;
        cin >> u >> v >> w;
        graph[u].push_back(make_pair(v,w));
        graph[v].push_back(make_pair(u,w));
    }

    for(int i=1;i<=n;i++){
        if(visited[i]==0)
            dfs(i);
    }

    for(int i=1;i<=n;i++)
        cout << colour[i] << '\n';

    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
  string S;
  cin>>S;
  ll x=0,N=0,M=0;
  rep(i,S.size()){
    if(S[i]=='W'){
      N+=x++;
      M+=i;
    }
  }
  cout<<M-N<<endl;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if sum(A) > sum(B):
    print("No")
else:
    cnt = 0
    b = 0
    for i in range(N):
        if A[i] < B[i]:
            cnt += (B[i] - A[i]) // 2
        elif A[i] > B[i]:
            b -= A[i] - B[i]

    if b + cnt >= 0:
        print("Yes")
    else:
        print("No")    

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

int main()
{
	int x, n;
	cin >> x >> n;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int e;
		cin >> e;
		s.insert(e);
	}
	int temp = 0;
	while(true)
	{
		if(s.find(x-temp) == s.end())
		{
			cout << x-temp << endl;
			return 0;
		}
		if(s.find(x+temp) == s.end())
		{
			cout << x+temp << endl;
			return 0;
		}
		temp++;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

deque<int> S;
int N;

int main() {
	string s;
	cin >> s;
	N = s.size();
	S.push_back(1);
	for (int n = 1; n < N; n++) {
		if (s[n] != s[n - 1])S.push_back(1);
		else S.back()++;
	}
	int ans = N;
	while (S.size() != 1) {
		if (S.front() < S.back()) {
			ans = min(ans, N - S.front());
			int temp = S.front();
			S.pop_front();
			S.front() += temp;
		}
		else {
			ans = min(ans, N - S.back());
			int temp = S.back();
			S.pop_back();
			S.back() += temp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
let N = Int(readLine()!)!

let A = Array(readLine()!).map { $0 == "R" ? 0 : 1 }
let S = A.sorted(by: <)

var c = 0
for i in 0..<N {
    if A[i] != S[i] { c += 1 }
}

print(c/2)


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

int main(void) {
	char c;
	cin >> c;
    if(c == 'a' ||
			c == 'i' ||
			c == 'u' ||
			c == 'e' ||
			c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}


Measured memory_bytes: 3600
/**
 *   author  : The San Cao (caothesan@gmail.com)
 *   created : 2020.07.24 08:31:51 +07
 */

#include <bits/stdc++.h>

using namespace std;

#define cube(k) (1ll * (k) * (k) * (k))

int main() {
  int n, k; cin >> n >> k;
  cout << cube(n / k) + (!(k % 2) & (n >= k / 2)) * cube((n - k / 2) / k + 1) << "\n";
  return 0;
}



Measured memory_bytes: 3588
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)


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


void solve(long long N, long long R){
    if(N >= 10){
        cout << R << endl;
    }else{
        cout << R + 100*(10-N) << endl;
    }
}

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


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<ll> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    ll can = 0;
    ll need = 0;
    rep(i,N){
        if(a[i] > b[i]){
            need += a[i] - b[i];
        }else if(a[i] < b[i]){
            can += ((b[i] - a[i])/2);
        }
        
    }
    if(can >= need) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}



Measured memory_bytes: 384
A, B, K = map(int, input().split())
if (B - A) > 2*(K-1):
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)
else:
    for i in range(A, B+1):
        if A <= i < A + K or B - K < i <= B:
            print(i)

Measured memory_bytes: 3060
# Dice I
class Dice:
    def __init__(self, default_surface):
        self.dice = default_surface  # [T, B, U, D, L, R]
        self.rotation_count = 0

    def move(self, new_face: int) -> None:
        for i, face in enumerate(self.dice):  # move new_face to dice[0]
            if face != new_face:
                continue
            elif i == 1:
                self.roll_up(), self.roll_up()
            elif i == 2:
                self.roll_left()
            elif i == 3:
                self.roll_right()
            elif i == 4:
                self.roll_up()
            elif i == 5:
                self.roll_down()

    def roll_left(self) -> None:
        self.dice[0], self.dice[3], self.dice[1], self.dice[2] = self.dice[2], self.dice[0], self.dice[3], self.dice[1]
        self.rotation_count += 1

    def roll_right(self) -> None:
        self.dice[0], self.dice[2], self.dice[1], self.dice[3] = self.dice[3], self.dice[0], self.dice[2], self.dice[1]
        self.rotation_count += 1

    def roll_up(self) -> None:
        self.dice[0], self.dice[5], self.dice[1], self.dice[4] = self.dice[4], self.dice[0], self.dice[5], self.dice[1]
        self.rotation_count += 1

    def roll_down(self) -> None:
        self.dice[0], self.dice[4], self.dice[1], self.dice[5] = self.dice[5], self.dice[0], self.dice[4], self.dice[1]
        self.rotation_count += 1

    def roll_clockwise(self) -> None:
        self.dice[2], self.dice[4], self.dice[3], self.dice[5] = self.dice[5], self.dice[2], self.dice[4], self.dice[3]
        self.rotation_count += 1

    def roll_counterclockwise(self) -> None:
        self.dice[2], self.dice[5], self.dice[3], self.dice[4] = self.dice[4], self.dice[2], self.dice[5], self.dice[3]
        self.rotation_count += 1


def main():
    T, L, U, D, R, B = map(int, input().split())
    order = input().rstrip()
    dice = Dice([T, B, U, D, L, R])
    for c in order:
        if c == "E":
            dice.roll_right()
        if c == "W":
            dice.roll_left()
        if c == "N":
            dice.roll_up()
        if c == "S":
            dice.roll_down()
    print(dice.dice[0])


if __name__ == "__main__":
    main()



Measured memory_bytes: 5616
def main():
    N = int(input())
    a = list(map(int, input().split()))
    xor = 0
    for i in range(0, len(a)):
        xor = xor ^ a[i]
    for i in range(0, len(a)):
        if i != 0:
            print(' ', end='')
        print(xor ^ a[i], end='')


if __name__ == '__main__':
    main()


Measured memory_bytes: 31336
import java.util.*;

public class Main {
    public static int solve() {
        return 0;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        long k;
        n = sc.nextInt();
        k = sc.nextLong();

        HashMap<Integer, Long> counts = new HashMap<>();

        int a;
        long b;
        for (int i = 0; i < n; i++) {
            a = sc.nextInt();
            b = sc.nextLong();

            if (!counts.containsKey(a)) {
                 counts.put(a, b);
            } else {
                counts.put(a, counts.get(a)+b);
            }
        }

        long sum = 0;
        Integer[] sortedKeys = counts.keySet().toArray(new Integer[counts.size()]);
        Arrays.sort(sortedKeys);

        for (Integer key: sortedKeys) {
            if (sum + counts.get(key) >= k) {
                System.out.println(key);
                return;
            } else {
                sum += counts.get(key);
            }
        }

    }
}


Measured memory_bytes: 95340
package main

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

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	h := make([]int, N+200) // 多めに確保
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
	}
	const inf = int(1e10)
	dp := make([]int, N+200) // 多めに確保
	for i := 0; i < len(dp); i++ {
		dp[i] = inf
	}
	dp[0] = 0
	for i := 0; i < N; i++ {
		for j := 1; j <= K; j++ {
			// dp[i+1] = min(dp[i+1], abs(h[i+1]-h[i]))
			// ...
			// dp[i+K] = min(dp[i+K], abs(h[i+K]-h[i]))
			dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
		}
	}
	fmt.Println(dp[N-1])
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


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

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

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;
}

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

  vector<int> s;
  vector<int> visit(n + 1, -1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (visit[v] == -1) {
      visit[v] = s.size();
      s.push_back(v);
      v = a[v - 1];
    }
    c = s.size() - visit[v];
    l = visit[v];
  }

  if (k < l)
    cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l + k] << endl;
  }
  return 0;
}

Measured memory_bytes: 5840
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

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

  ll k = 1;
  bool ok = false;
  while (k <= n + 1) {
    ll tst = k * (k - 1) / 2;
    if (tst == n) {
      ok = true;
      break;
    }
    k++;
  }

  if (!ok) {
    puts("No");
    return 0;
  }

  puts("Yes");
  cout << k << endl;
  vvll ans(k);
  ll cnt = 1;
  for (ll i = 0; i < k - 1; i++) {
    for (ll j = i + 1; j < k; j++) {
      ans[i].push_back(cnt);
      ans[j].push_back(cnt);
      cnt++;
    }
  }
  rep(i, k) {
    cout << ans[i].size() << " ";
    ll sizi = (ll)ans[i].size();
    rep(j, sizi) cout << ans[i][j] << (j == sizi - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, change;
  scanf("%d", &n);
  int left = n % 1000;
  if(left > 0){
    change = 1000 - left;
  }
  else{
    change = 0;
  }
  printf("%d\n", change);
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int main() {
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); ++i) {
	if (str[i] == ',') str[i] = ' ';
  }
  cout << str << endl;
}










Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    DArray = [LI() for _ in range(N)]

    ans = "No"

    for i in range(0, N-2, 1):
        if DArray[i][0] == DArray[i][1]:
            if DArray[i+1][0] == DArray[i+1][1]:
                if DArray[i+2][0] == DArray[i+2][1]:
                    ans = "Yes"
                    break

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    int result = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j!=i){
                result += d[j] * d[i];
            }
        }
    }
    cout << result / 2 << endl;
}

Measured memory_bytes: 384
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

count = 0
for ai in a:
	if x >= 0 and x < ai:
		break
	else:
		x -= ai
		count += 1
else:
	if x > 0:
		count -= 1

print(count)

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

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

    set<int> st{0,1,2,3,4,5,6,7,8,9};

    int k;
    cin>> k;

    while(k--)
    {
        int input;
        cin>> input;
        st.erase(input);
    }

    long int ans = 0;
    while(1)
    {
        bool check = true;
        long int temp = n;
        vector<int>vec;
        while(temp)
        {
            vec.push_back(temp % 10);
            temp/= 10;
        }

        for(int i = 0; i < vec.size(); i++)
        {
            if(st.find(vec[i]) == st.end())
            {
                check = false;
                break;
            }
        }

        if(check)
        {
            ans = n;
            break;
        }
        else
            n++;
    }

    cout<< ans;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int k, s, ans = 0;
  	cin >> k >> s;
  	for (int a = 0; a <= k; a++){
    	for (int b = 0; b <= k; b++){
    		int c; c = s - a - b;
          	if (c >= 0 && c <= k){
            	ans++;
            }
    	}
    }
  	cout << ans;
}

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

int main() {
  bool card[4][13] = {false};
  int n, o, p;
  string x;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> o;
    if (x == "S") {
      card[0][o - 1] = true;
    } else if (x == "H") {
      card[1][o - 1] = true;
    } else if (x == "C") {
      card[2][o - 1] = true;
    } else if (x == "D") {
      card[3][o - 1] = true;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == false) {
        if (i == 0) {
          cout << "S " << j + 1 << endl;
        } else if (i == 1) {
          cout << "H " << j + 1 << endl;
        } else if (i == 2) {
          cout << "C " << j + 1 << endl;
        } else if (i == 3) {
          cout << "D " << j + 1 << endl;
        }
      }
    }
  }
}


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

const int MOD = 1000000007;

ll binary_pow(ll n, ll p)
{
    return p ? binary_pow(n * n % MOD, p >> 1) * (p & 1 ? n : 1) % MOD : 1;
}

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

    ll ans = (binary_pow(10, n) - binary_pow(9, n) - binary_pow(9, n) + binary_pow(8, n)) % MOD;
    while (ans < 0)
        ans += MOD;
    cout << ans % MOD << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(){
	int i;
	int sum=0;
	char ch[1001];

	while(1){
		scanf("%s",ch);
		if(ch[0]=='0')
			break;
		for(i=0; i<strlen(ch);i++){
			sum += ch[i] - '0';
		}
		printf("%d\n",sum);
		sum = 0;
	}

	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> l(n);
    cin >> l;
    sort(l.begin(), l.end());
    ll ans = 0;
    for(int a = 0; a < n; a++) {
        for(int b = a + 1; b < n; b++) {
            ans += max(0, int(lower_bound(l.begin(), l.end(), l[a] + l[b]) - (l.begin() + b)) - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
A=[]
def f(b,a,i):
  if i==0:x=a+b
  elif i==1:x=a-b
  elif i==2:x=a*b
  else:x=a/b
  return x
for s in sys.stdin:
  for e in s.split():
    try:A+=[float(e)]
    except:A+=[f(A.pop(),A.pop(),"+-*/".index(e))]
  print A.pop()

Measured memory_bytes: 4224