akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define llint long long int

using namespace std;

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

    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));

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

        for(int j = 0; j < M; j ++){
            cin >> A[i][j];
        }
    }
    vector<int> read(N, 0);

    int ans = -1;

    while(true){
        read[0] ++;

        for(int i = 1; i < N; i ++){
            if(read[i - 1] == 2){
                read[i] ++;
                read[i - 1] = 0;
            }
        }
        if(read[N - 1] == 2){
            break;
        }
        vector<int> rikaido(M, 0);

        for(int i = 0; i < N; i ++){
            if(read[i] == 1){
                for(int j = 0; j < M; j ++){
                    rikaido[j] += A[i][j];
                }
            }
        }
        bool tassei = true;

        for(int i = 0; i < M; i ++){
            if(rikaido[i] < X){
                tassei = false;

                break;
            }
        }
        if(tassei == true){
            int kingaku = 0;

            for(int i = 0; i < N; i ++){
                if(read[i] == 1){
                    kingaku += C[i];
                }
            }
            if(ans == -1 || kingaku < ans){
                ans = kingaku;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1197
gi = lambda : list(map(int,input()))
l = gi()
n = len(l)
print(min(sum([abs(k%2 - l[k]) for k in range(n)]), sum([abs((k + 1)%2 - l[k]) for k in range(n)])))

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

int main(void){
    string a,b; cin >> a >> b;
    int c = stoi(a + b);
    for(int i=0;i<c;i++){
        if(pow(i,2)==c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000

int main(){
	int N,K;
	cin>>N>>K;
	set<int> S;
	for(int i=1;i*i<=N;i++){
		int a = N/i;
		S.insert(a);
		a = N/a;
		S.insert(a);
	}
	vector<int> V;
	int last = 0;
	for(auto a:S){
		V.push_back(a-last);
		last=a;
	}
	
	vector<vector<int>> dp(K,vector<int>(V.size(),0));
	vector<vector<int>> sum(K,vector<int>(V.size(),0));
	
	for(int i=0;i<K;i++){
		for(int j=0;j<V.size();j++){
			dp[i][j] = V[j];
			if(i!=0){
				dp[i][j] = mod(dp[i][j]*sum[i-1][V.size()-1-j]);
			}
			
			
			sum[i][j] = dp[i][j];
			if(j!=0)sum[i][j] = mod(sum[i][j]+sum[i][j-1]);
		}
	}
	/*
	for(int i=0;i<K;i++){
		for(int j=0;j<V.size();j++){
			cout<<dp[i][j]<<',';
		}
		cout<<endl;
	}*/
	
	cout<<sum[K-1][V.size()-1]<<endl;
	
	return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int rec(int n){
	if(n==0) return 1;
	int res=0;
	if(n-1>=0) res+=rec(n-1);
	if(n-2>=0) res+=rec(n-2);
	if(n-3>=0) res+=rec(n-3);
	return res;
}

int main(void){
	int n;
	while(cin >> n,n){
		cout << rec(n)/3650+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cassert>
#include <bits/stdc++.h>

using namespace std;

#define LL long long 

int main(int argc, char const *argv[])
{
	LL H, W;
	scanf("%lld%lld", &H, &W);
	if(H == 1 || W == 1) {printf("1\n"); return 0;}
	LL a, b,c ,d;
	a = H - H/2, b = H/2;
	c = W - W/2, d = W/2;

	printf("%lld\n", a * c + d*b);
	return 0;
}



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

int main()
{int q,p,a,b,c,d;
 while(~scanf("%d%d%d%d",&a,&b,&c,&d))
 {p=a*b;
  q=c*d;
  if(q>=p)
  printf("%d\n",q);
  if(p>q)
  printf("%d\n",p);
 }
    return 0;
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e5+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int x,n,t;
	cin>>x>>n;
	vector<bool> used(201);
	for(int i=0;i<n;i++){
		cin>>t;
		used[x-t+100]=true;
		//cout<<x-t+100<<'\n';
	}
	for(int dx=0;dx<=100;dx++){
		if(!used[dx+100]){
			cout<<x-dx;
			return 0;
		}
		if(!used[100-dx]){
			cout<<x+dx;
			return 0;
		}
	}
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int a, b; cin >> a >> b;
    int sum = 0, tmp = b - a;
    for (int i = 1; i < tmp; i++) sum += i;
    printf("%d\n", sum - a);
}


Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
vector<int> v(26,0);
string s;cin>>s;
for(char x:s){
    v[x-'a']++;
 if(v[x-'a']>1){cout<<"no";return 0;}
}
cout<<"yes";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<a+b;
    }else if(b<a){
        cout<<a*2-1;
    }else{
        cout<<b*2-1;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		char cs[] = fs.next().toCharArray();
		int rsumE[] = new int[n+1];
		int sumW[] = new int[n+1];
		
		for(int i=0;i<n;i++) {
			if(cs[i]=='W') {
				sumW[i+1] = sumW[i] + 1;
			}
			else {
				sumW[i+1] = sumW[i];				
			}
		}
		for(int i=n-1;i>=0;i--) {
			if(cs[i]=='W') {
				rsumE[i] = rsumE[i+1];
			}
			else {
				rsumE[i] = rsumE[i+1] + 1;
			}
		}
		
		int ans = INF;
		for(int i=0;i<n;i++) {
			int res = sumW[i] + rsumE[i+1];//reverseの添字が１つずれるのなんとかできない？
			ans = Math.min(ans,res);
		}
		System.out.println(ans);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

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

Measured memory_bytes: 29672
using System;
using System.Collections.Generic;
using System.Linq;

//AGC006-B-Median Pyramid Easy
//http://agc006.contest.atcoder.jp/tasks/agc006_b
class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 4");
            //Yes
            //1
            //6
            //3
            //7
            //4
            //5
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 1");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("3 2");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];
        int x = wkArr[1];

        if (x == 1 || x == 2 * N - 1) {
            Console.WriteLine("No");
            return;
        }

        int[] TeihenArr = new int[2 * N - 1];
        int UB = TeihenArr.GetUpperBound(0);

        //中央の添字
        int CenterInd = UB / 2;

        int UseNum = 1;
        var sb = new System.Text.StringBuilder();
        sb.AppendLine("Yes");
        for (int I = 0; I <= UB; I++) {
            if (I == CenterInd - 1) {
                sb.Append(x - 1); sb.AppendLine();
            }
            else if (I == CenterInd) {
                sb.Append(x); sb.AppendLine();
            }
            else if (I == CenterInd + 1) {
                sb.Append(x + 1); sb.AppendLine();
            }
            else {
                while (x - 1 <= UseNum && UseNum <= x + 1) UseNum++;
                sb.Append(UseNum++); sb.AppendLine();
            }
        }
        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 16600
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		if(a+b==15) {
			System.out.println("+");
		}else if(a*b==15) {
			System.out.println("*");
		}else {
			System.out.println("x");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
 
main()
{
    int n,x;
    int counter;
    int i,j,k; //i<j<k, i+j+k=9
     
    do{
        counter=0;
        scanf(" %d %d",&n,&x);
        if(n==0 && x == 0){
            break;
        } else {
            for(i=1;i<=n-2;i++){
                if(3*i+3>x){
                    break;
                }
                for(j=i+1;j<=n-1;j++){
                    k = x-i-j;
                    if( k<=j){
                        break;
                    } else if(k<=n){
                        counter++;
                    }
                }
            }
        }
        printf("%d\n",counter);
    }while(1);
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  set<int> st;
  rep(i,k)st.insert(v[i]);
  int res = 1;
  for(int i = k;i < n;i++){
    if(*st.begin() == v[i-k]){
      if(*st.rbegin() > v[i])res++;
    }else{
      res++;
    }
    st.erase(v[i-k]);
    st.insert(v[i]);
  }
  int cnt = 0,s = 0;
  rep(i,n){
    if(i == 0 || v[i-1] < v[i])cnt++;
    else {
      if(cnt >= k)s++;
      cnt = 1;
    }
  }
  if(cnt >= k)s++;
  cout << (s != 0 ? res-s+1 : res) << endl;





  return 0;
}

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

int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S.at(0) == S.at(1)){
        if(S.at(2) == S.at(3)&&S.at(0)!=S.at(2)){
            cout << "Yes" << endl;
        }
        else{
        cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    } 
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

const LL MOD = 1000000007;

LL mod_pow(LL v, LL n){
    if(n < 0) return mod_pow(v, MOD-1 + v);
    if(n == 0) return 1;
    LL res = mod_pow(v, n/2);
    res = res * res % MOD;
    if(n & 1) res = res * v % MOD;
    return res;
}

vector<LL> mod_factorial(LL n){
    vector<LL> res(n);
    res[0] = 1;
    for(LL i = 1; i < n; ++i){
        res[i] = res[i-1] * i % MOD;
    }
    return res;
}

LL permutation(LL n, LL m, vector<LL>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    LL res = factorial.at(n);
    res = res * mod_pow(factorial.at(n-m), MOD-2) % MOD;
    return res;
}

LL combination(LL n, LL m, vector<LL>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    LL res = permutation(n, m, factorial);
    res = res * mod_pow(factorial.at(m), MOD-2) % MOD;
    return res;
}

int main(){
    LL n;
    cin >> n;
    if(n == 2){
        cout << 1 << endl;
        return 0;
    }
    if(n == 3){
        cout << 4 << endl;
        return 0;
    }
    vector<LL> factorial = mod_factorial(n+1);
    vector<LL> equal_or_less(n+1);
    for(LL k = 1; k <= n-1; ++k){
        LL part1 = factorial[k] * factorial[n-1-k] % MOD;
        LL part2 = combination(k-1, n-1-k, factorial);
        equal_or_less[k] = part1 * part2 % MOD;
    }
    LL ans = 0;
    for(LL k = (n+1)/2; k <= n-1; ++k){
        assert(k-1 >= n-k-1);
        LL part1 = (equal_or_less[k] - equal_or_less[k-1] + MOD) % MOD;
        LL part2 = part1 * k % MOD;
        ans = (ans + part2) % MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15872
N,K=gets.split.map(&:to_i)
as=gets.split.map{|e|e.to_i-1}
cus=Array.new(N+1,0)
N.times do |i|
    cus[i+1]=(cus[i]+as[i])%K
end
dat=Hash.new(0)
res=0
(N+1).times do |i|
    if i<K
        res+=dat[cus[i]]
        dat[cus[i]]+=1
    else
        dat[cus[i-K]]-=1
        res+=dat[cus[i]]
        dat[cus[i]]+=1
    end
end
puts res

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

int n,m,p;
int main() {
	cin >> n >> m;
	if(n<m) {
		p = n;
		n = m;
		m = p;
	}
	while(n%m!=0) {
		p = n%m;
		n = m;
		m = p;
	}
	cout << m << endl;
}

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    int nNode;
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = cnrvnPodr[0];
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  static int stnPrt = 0;
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
  if (stnPrt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  vector<StNod> voNod;

  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  voNod.resize(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  int nOCnt = 0;
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 1200
using System;
using System.Linq;
using System.Collections.Generic;


class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] S = new string[N];
        for(int i=0; i<N; i++){
            S[i] = Console.ReadLine();
        }
 
        var myTable = new Dictionary<string, int>();

        for(int i=0; i<N; i++){
            if(myTable.ContainsKey(S[i])){
                myTable[S[i]]++;
            }else{
                myTable.Add(S[i], 1);
            }
        }

        int maxValue = 1;

        foreach(string element in myTable.Keys){
            maxValue = Math.Max(maxValue, myTable[element]);
        }

        var ansList = new List<string>();
        foreach(string element in myTable.Keys){
            if(myTable[element] == maxValue){
                ansList.Add(element);
            }
        }
        
        var ansArray = ansList.ToArray();

        StringComparer cmp = StringComparer.OrdinalIgnoreCase;
        Array.Sort(ansArray, cmp);

        foreach(var element in ansArray){
            Console.WriteLine(element);
        }
    }

}

Measured memory_bytes: 47164
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

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

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<char> S(N);
  rep(i,N)
  {
    cin >> S[i];
  }
  bool ans = false;
  rep(i,N)
  {
    if(S[i]=='Y')
    {
      ans = true;
    }
  }
  if(ans==true)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
		int N, M;
		scanf("%d %d", &N, &M);
		int X[M];
		for ( int i = 0; i < M; i++ ) scanf("%d", &X[i]);
		sort(X, X+M);

		int Y[M-1];
		for ( int i = 0; i < M-1; i++ ) Y[i] = X[i+1] - X[i];

		sort(Y, Y+M-1);
		int ans = 0;
		for ( int i = 0; i < (M-N); i++ ) ans += Y[i];
		
		printf("%d\n", ans);
		return 0;
}


Measured memory_bytes: 896
def main():
    n, yen = map(int,input().split())
    x = 0
    y = 0
    z = 0
    for x in range(n+1):
        for y in range(n+1):
            z = n - x - y
            if z < 0:
                break
            if x * 10000 + y * 5000 + z * 1000 == yen:
                print(x,y,z)
                return

    print(-1,-1,-1)

if __name__ =='__main__':
    main()


Measured memory_bytes: 40432
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int N;
    int A;
    int B;
    int C;
    int X;

    int answer = 0;

    cin >> N >> A >> B >> C >> X;

    if (N == 0) { break; }

    vector<int> table(N);

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

    for (int i = 0; i < N; i++) {
      bool should_break = false;

      while (true) {
        if (X == table[i]) {
          break;
        }

        if (answer >= 10000) {
          answer = -1;
          should_break = true;
          break;
        }

        X = (A * X + B) % C;
        answer++;
      }

    X = (A * X + B) % C;
      answer++;
      if (should_break) { break; }
    }

    cout << answer - 1 << endl;
  }


  return 0;
}

Measured memory_bytes: 1196
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b / a > c)
    cout << c << endl;
  else
    cout << b / a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    cout << fixed << setprecision(10);
    vector<double> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    vector<vector<double>> dp(n+1,vector<double>(n+1));
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
        }
    }
    double ans=0;
    for(int i=(n+1)/2; i<=n; i++){
        ans+=dp[n][i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    bool in = false, de = false;
    int ans = 0;
    rep(i, n-1){
        if(a[i] < a[i+1]){
            if(de){
                de = false;
            }else if(!in){
                ans++;
                in = true;
            }
        }else if(a[i] > a[i+1]){
            if(in){
                in = false;
            }else if(!de){
                ans++;
                de = true;
            }
        }
    }
    if(!in && !de){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
use std::error::Error;
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::str::{self, FromStr};

fn exec() {
    let mut sc = Scanner::new(io::stdin());
    let (n, m): (usize, usize) = (sc.ne(), sc.ne());
    let mut g = vec![Vec::new(); n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (sc.ne(), sc.ne());
        g[a - 1].push(b - 1);
        g[b - 1].push(a - 1);
    }
    let mut dist = vec![100; n];
    let mut que = std::collections::VecDeque::new();
    dist[0] = 0;
    que.push_back(0);
    while let Some(cur) = que.pop_front() {
        if dist[cur] >= 2 {
            break;
        }
        for &nxt in &g[cur] {
            if dist[nxt] == 100 {
                dist[nxt] = dist[cur] + 1;
                que.push_back(nxt);
            }
        }
    }
    if dist[n - 1] == 100 {
        print!("IM");
    }
    println!("POSSIBLE");
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
pub struct Scanner<R> {
    bufread: BufReader<R>,
    id: usize,
    buf: Vec<u8>,
}
impl<R: Read> Scanner<R> {
    pub fn new(resource: R) -> Scanner<R> {
        Scanner {
            bufread: BufReader::new(resource),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.bufread.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    pub fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.is_empty() {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert_ne!(self.buf[l], b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!(
                    "parse error, {:?}",
                    String::from_utf8(self.buf[l..r].to_owned())
                )
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    pub fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 27004
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int ballCount = int.Parse(Reader.ReadLine());
        int robotBPos = int.Parse(Reader.ReadLine());

        int[] balls = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int ans = 0;
        for (int i = 0; i < ballCount; i++) {
            int mv = Math.Min(balls[i], Math.Abs(robotBPos - balls[i]));
            ans += mv * 2;
        }
        Console.WriteLine(ans);
        
    }




    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


5
20
11 12 9 17 12

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

ll rec(ll n) {
	if (n == 1) return 1;
	else return 2 * rec(n / 2) +1 ;
}

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

	ll H; cin >> H;
	cout << rec(H) << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
ll poww(long long a, long long n, long long m)
{
        long long ans = 1;
        long long mul = a;
        while (n != 0)
        {
                if (n % 2)
                {
                        ans = (ans * mul) % m;
                }
                mul = (mul * mul) % m;
                n /= 2;
        }
        return ans;
}
/* 
Fermat's little theorem: 
1) (a/b)%mod= (a*(poww(b,mod-2,mod)))%mod iff a%b==0
2) (a^b)%mod= (a^(b%(mod-1)))%mod iff mod is prime
*/
const int SZ=2e5+100;
ll factorial[SZ];
void precompute()
{
	factorial[0]=1;
	for(int i=1;i<SZ;i++)
	{
		factorial[i]=(factorial[i-1]*i)%MOD;
	}
}
ll InverseEuler(ll n, ll m)
{
    return poww(n, m - 2, m);
}

int C(int n,int r)
{
	int num=1;
	for(int i=n;i>=n-r+1;i--)
	{
		num*=i;
		num%=MOD;
	}
	int den=1;
	for(int i=1;i<=r;i++)
	{
		den*=i;
		den%=MOD;
	}
	num*=InverseEuler(den,MOD);
	num%=MOD;
	return num;
}
int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	int ans=poww(2,n,MOD)-1;
	ans+=MOD;
	ans%=MOD;
	ans-=C(n,a)+C(n,b);
	ans%=MOD;
	ans+=MOD;
	ans%=MOD;
	cout<<ans<<endl;
}


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

int main(){
  long int n,a,b;
  cin >>n>> a>> b;
  /*vector<char>vec(n);
  long int p=0;
  for(int i=0;i<n;++i) cin >>vec[i];
  for(int i=0;i<n;++i){
    
    if(vec.at(i)==) {
    
      cout <<n<<endl;
    else if(n) cout <<n   */
  if(n<=a) cout << n<<endl;
  else if(n<=a+b) cout <<a<<endl;
  else{
    long int s,g ;
    s =n/(a+b);
    g=n%(a+b);
    if(g<=a) cout << s*a+g <<endl;
    else cout <<s*a+a <<endl;
  }
}

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

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

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

  string s; cin >> s;
  int N = s.size();
  vector<int> ans(N, 1);

  rep(i, N-1) {
    if(s[i] == 'R' && s[i+1] == 'R') {
      ans[i+2] += ans[i];
      ans[i] = 0;
    }
    if(s[N-1-i] == 'L' && s[N-1-i-1] == 'L') {
      ans[N-1-i-2] += ans[N-1-i];
      ans[N-1-i] = 0;
    }
  }

  rep(i, N) {
    cout << ans[i] << (i == N-1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 1104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        int[] arr;
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            arr = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        }
        
        if(arr[0] < arr[1] && arr[1] < arr[2]) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 30724
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<utility>
#include<set>
#include<stack>
#include<string>
#include<vector>
#define ll long long
#define llu unsigned long long
using namespace std;
const int maxn = 101000;
int main(void)
{
    int n,k,s;
    scanf("%d%d%d",&n,&k,&s);
    for(int i=0;i<k;i++){
        printf("%d ",s);
    }
    if(s!=1000000000){
        for(int i=k;i<n;i++){
            printf("%d ",s+1);
        }
    }
    else{
        for(int i=k;i<n;i++){
            printf("%d ",s-1);
        }
    }
    return 0;
}


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

# define int long long

int a,b,n;

signed main()
{
    read(a),read(b),read(n);
    int t=min(b-1,n);
    printf("%lld\n",a*t/b-t/b*a);
    return 0;
}

Measured memory_bytes: 3696
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int bin = 0;
		for(int i=0;i<n;i++) {
			bin |= sc.nextInt();
		}
		System.out.println(Integer.numberOfTrailingZeros(bin));
	}

}


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

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

    int i;
    for (i = a; i <= b; i++)
    {
        if(i % k == 0)break;
    }
    
    if(i == b + 1)cout << "NG" << endl;
    else cout << "OK" << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=(a)&&(a)<b)
#define INF 1<<30
using namespace std;
int dy[]={2,1,0,-1,-2,1,0,-1,0},dx[]={1,1,1,1,1,2,2,2,3};
struct S{
	int y,x,f;
	S(int y,int x,int f):y(y),x(x),f(f){}
};
int main(){
	int w,h;
	while(cin>>w>>h,w){
		char cli[64][32]; queue<S> F;
		int cost[64][32][2],ans=INF;
		rep(i,h)rep(j,w){
			cin>>cli[i][j];
			rep(k,2){
				cost[i][j][k]=INF;
				if(cli[i][j]=='S')F.push(S(i,j,k)),cost[i][j][k]=0;
			}
		}
		while(!F.empty()){
			S cs=F.front();F.pop();
			rep(d,9){
				S ns=cs; ns.y+=dy[d],ns.x+=cs.f?dx[d]:-dx[d],ns.f^=1;
				if(!ck(ns.y,h)||!ck(ns.x,w)||cli[ns.y][ns.x]=='X')continue;
				int nc=cost[cs.y][cs.x][cs.f]+(cli[ns.y][ns.x]=='T'?0:cli[ns.y][ns.x]-'0');
				if(cost[ns.y][ns.x][ns.f]>nc)cost[ns.y][ns.x][ns.f]=nc,F.push(S(ns.y,ns.x,ns.f));
				if(cli[ns.y][ns.x]=='T'&&ans>nc)ans=nc;
			}
		}
		cout<<(ans==INF?-1:ans)<<endl;
	}
	return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  lint x,a,b;
  cin>>x;
  a=x/500;
  b=x%500;
  if(b/5>0){
    b=b/5;
  }
  cout<<a*1000+b*5;
}

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

//can use O(1) memory actually

int T, n;
const int maxn = 200000+5;
ll h[maxn];
ll dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n ; i++) cin >> h[i];
	dp[1] = 0LL;
	dp[2] = abs(h[2]-h[1]);

	for(int i = 3; i <= n ; i++)
	{
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n];
	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  deque<char> q;
  for (char c : s)
    q.push_back(c);
  bool flip = false;
  int query;
  cin >> query;
  rep(qi, query)
  {
    int ty;
    cin >> ty;
    if (ty == 1) {
      flip = !flip;
    } else if (ty == 2) {
      int f;
      char c;
      cin >> f >> c;
      if (flip)
        f = 3 - f;
      if (f == 1) {
        q.push_front(c);
      } else if (f == 2) {
        q.push_back(c);
      }
    }
  }
  if (flip)
    reverse(q.begin(), q.end());
  string ans;
  for (char c : q)
    ans += c;
  cout << ans << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

ll sm[MAX_N];

inline ll solve(int st, int ed) //[st,ed)の和
{
    return sm[ed]-sm[st];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        sm[i+1] = sm[i] + a[i];
    }
    ll ans = INF;
    for(int i=2;i<=n-2;i++){
        int l=1,h=i-1;
        while(h-l>1){
            int mid = (l+h)/2;
            if(solve(0,mid) < solve(mid, i)){
                l = mid;
            }else{
                h = mid;
            }
        }
        vector<pll> vec[2];
        ll u = solve(0,l), v = solve(l,i);
        vec[0].pb(pll(min(u,v),max(u,v)));
        u = solve(0,h), v = solve(h,i);
        vec[0].pb(pll(min(u,v),max(u,v)));
        //-------------------------------------------
        l=i+1,h=n-1;
        while(h-l>1){
            int mid = (l+h)/2;
            if(solve(i,mid) < solve(mid, n)){
                l = mid;
            }else{
                h = mid;
            }
        }
        u = solve(i,l), v = solve(l,n);
        vec[1].pb(pll(min(u,v),max(u,v)));
        u = solve(i,h), v = solve(h,n);
        vec[1].pb(pll(min(u,v),max(u,v)));
        rep(j,2){
            rep(k,2){
                cmn(ans,max({vec[0][j].fi,vec[0][j].se,vec[1][k].fi,vec[1][k].se})-min({vec[0][j].fi,vec[0][j].se,vec[1][k].fi,vec[1][k].se}));
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    int k = 1, sum = 0;
    bool ok = false;
    while (sum <= n) {
        sum += k;
        ++k;
        if (n == sum) {
            ok = true;
            break;
        }
    }
    if (!ok) {
        cout << NO << endl;
        return 0;
    }
    vector<vi> s(k);
    vi sums(k);
    rep1(i, k-1) sums[i] = sums[i-1] + i;
    int num = 1;
    rep1(i, k-1) {
        rep(j, i) {
            s[j].pb(num);
            s[i].pb(num);
            ++num;
        }
    }
    cout << YES << endl;
    cout << sz(s) << endl;
    rep(i, k) {
        printf("%d ", sz(s[i]));
        rep(j, sz(s[i])) printf("%d%c", s[i][j], (j<sz(s[i])-1?' ':'\n'));
    }
    return 0;
}


Measured memory_bytes: 4600
#include <iostream>

using namespace std;

string a;
int sum;

int main(int argc,char ** argv)
{
	cin>>a;
	if (a[0]!='A')
	{
		cout<<"WA"<<endl;
		return 0;
	}
	for (int i=2;i<=a.length()-2;i++)
		if (a[i]=='C')
			sum++;
	if (sum!=1)
	{
		cout<<"WA"<<endl;
		return 0;
	}
	for (int i=0;i<a.length();i++)
		if (a[i]>'A'&&a[i]<='Z'&&a[i]!='C')
		{
			cout<<"WA"<<endl;
			return 0;
		}
	cout<<"AC"<<endl;
	return 0;
}

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

int main()
{
	int a, b;
	
	cin>>a>>b;
	
	if(a>b)
	{
		for(int i=1; i<=a; i++)
		{
			cout<<b;
		}
	}
	else if(b>a)
	{
		for(int i=1; i<=b; i++)
		{
			cout<<a;
		}
	}
	else
	{
		for(int i=1; i<=a; i++)
		{
			cout<<b;
		}
	}
	
	return 0;
	
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

/* 小文字を大文字に変換 */
char toupr(char c) {
  if ((c >= 'a') && (c <= 'z')) {
    return (c - 0x20);
  } else {
    return tolower(c);
  }
}

/* 大文字を小文字に変換 */
char tolowr(char c) {
  if ((c >= 'A') && (c <= 'Z')) {
    return (c + 0x20);
  } else {
    return  toupr(c);
}
}



int main(){
    char s;
    cin >> s;
    if (isupper(s))cout << "A" << endl;
    else cout << "a" << endl;

}


Measured memory_bytes: 3616
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll arr[405],prefs[405];
ll dp[405][405];
ll suminrange(ll l,ll r){
    if(l==0) return prefs[r];
    return prefs[r]-prefs[l-1];
}
ll findAns(ll l,ll r){
    if(l==r) return 0;
    if(dp[l][r]>=0) return dp[l][r];
    ll i,ans=LLONG_MAX;
    for(i=l;i<r;i++){
        ll myans = suminrange(l,r) + findAns(l,i) + findAns(i+1,r);
        ans = min(ans,myans);
    }
    return dp[l][r]=ans;
}
void solve(ll caseno){
	ll i,j,n,ans;
    cin>>n;
    mset(dp,-1);
    for(i=0;i<n;i++) cin>>arr[i];
    prefs[0]=arr[0];
    for(i=1;i<n;i++) prefs[i]=arr[i]+prefs[i-1];
    ans = findAns(0,n-1);
    cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 4976
use io::*;
use std::*;

fn solve(S: String) {
    if S == "Sunny" {
        println!("Cloudy");
    } else if S =="Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let s: String;
    s = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(s)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6,MA=pow(2,31)-1;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,c,d,e,f,cmp,cmpp,m,h,w,x,y,sum=0,pos,nn,dat[ohara],q;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  rep(i,2*n-1)dat[i]=MA;
}

void update(ll k,ll a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

ll query(ll a,ll b,ll k,ll l,ll r){
  if(r<=a||b<=l)return MA;
  if(a<=l&&r<=b)return dat[k];
  else{
    ll vl=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>nn>>q;
      init(nn);
      rep(i,q){
        cin>>d>>e>>f;
        if(d==0)update(e,f);
        else Cout(query(e,f+1,0,0,n));
      }
    
       
return 0;
}



Measured memory_bytes: 5288