akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Double> list = new ArrayList<>();
		ArrayList<String> checkList = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Double.parseDouble(sc.next()));
			checkList.add(sc.next());
		}
		sc.close();

		double money = 0;
		for(int i = 0; i < N; i++) {
			if(checkList.get(i).equals("JPY")) {
				money += list.get(i);
			}else {
				money += list.get(i) * 380000.0;
			}
		}
		System.out.println(String.format("%13.4f", money));
	}

}

Measured memory_bytes: 21204
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: Chars,
        b: Chars,
        c: Chars,
    }

    let mut res = 0;
    for i in 0..n {
        if a[i] == b[i] && b[i] == c[i] {
        } else if a[i] != b[i] && b[i] != c[i] && c[i] != a[i] {
            res += 2;
        } else {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int l, r, d;
  scan(l, r, d);
  int cnt = 0;
  FOR (i, l, r + 1) {
    if (i % d == 0) {
      cnt += 1;
    }
  }
  print(cnt);
}

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


Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
using namespace std;

map<string,int> dict;
map<int,string> rdict;
int dic(string s){
	if( dict.count(s) ) return dict[s];
	else{
		int k = dict.size();
		rdict[k] = s;
		return dict[s] = k;
	}
}

int info[210][210];

int same[210][210];
int muki[210];

vector<int> g[210];
vector<int> ag[210];

int dfs(int x,int t){
	if( muki[x] != -1 ){
		return 0;
	}
	muki[x] = t;
	for(int i = 0 ; i < g[x].size() ; i++)
		dfs(g[x][i],t^1);
}

int main(){
	int n;
	while(cin >> n && n){
		memset(same,0,sizeof(same));
		memset(info,0,sizeof(info));
		dict.clear();
		rdict.clear();
		for(int i = 0 ; i < 210 ; i++) g[i].clear() , ag[i].clear();
		vector< pair<int,int> > v;
		for(int i = 0 ; i < n ; i++){
			string l; cin >> l;
			for(int j = 0 ; j < l.size() ; j++) if( l[j] == '-' ) l[j] = ' ';
			stringstream ss(l);
			string a,b;
			ss >> a >> b;
			v.push_back( make_pair( dic(a) , dic(b) ) );
			g[dic(a)].push_back(dic(b));
			g[dic(b)].push_back(dic(a));
			ag[dic(a)].push_back(dic(b));	
			info[dic(a)][dic(b)] = 1;
		}
		int N = dict.size();
		
		memset(muki,-1,sizeof(muki));
		for(int i = 0 ; i < N ; i++){
			if( muki[i] == -1 ) dfs(i,0);
		}
		
		for(int i = 0 ; i < N ; i++){
			for(int j = 0 ; j < N ; j++){
				int fl1 = 0 , fl2 = 1;
				for(int k = 0 ; k < N ; k++){
					if( (info[j][k]&&info[i][k])||(info[k][i]&&info[k][j]) ){
						fl1 = 1; // onajiyatudousi is same
					}
				}
				for(int k = 0 ; k < N ; k++){
					if( info[k][i] && info[j][k] ) fl2 = 0;
					if( info[i][k] && info[k][j] ) fl2 = 0;
				}
				
				if( fl1 && fl2 ){
					//cout << rdict[i] << " " << rdict[j] << " " << "SAME" << endl;
					same[i][j] = 1;
				}
			}
		}
		int m;
		cin >> m;
		cout << N << endl;
		for(int x = 0 ; x < m ; x++){
			string l; cin >> l;
			for(int j = 0 ; j < l.size() ; j++) if( l[j] == '-' ) l[j] = ' ';
			stringstream ss(l);
			string a,b;
			ss >> a >> b;
			if( !dict.count(a) || !dict.count(b) || muki[dic(a)] == muki[dic(b)] ){
				cout << "NO" << endl;
				continue;
			}
			queue<int> Q;
			Q.push(dic(a));
			int dn[210];
			memset(dn,-1,sizeof(dn));
			dn[dic(a)] = 1;
			while(Q.size()){
				int q = Q.front(); Q.pop();
				//cout << rdict[q] << endl;
				for(int i = 0 ; i < ag[q].size() ; i++){
					if( dn[ag[q][i]] == -1 ) Q.push(ag[q][i]) , dn[ag[q][i]] = 1;
				}
				for(int i = 0 ; i < N ; i++){
					if( same[q][i] ){
						if( dn[i] == -1 ) Q.push(i) , dn[i] = 1;
					}
				}
			}
			
			if( dn[dic(b)] == 1){
				cout << "YES" << endl;
			}else{
				cout << "NO" << endl;
			}
		}
	}
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < n; ++i) cout << a[i] << b[i];
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int a,b,c;
  while(input(a,b,c)) {
    cout << max(0,c-(a-b)) << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int x,y;
float c,t;

int main() {

    scanf("%d %d", &x, &y);
    c = (x*4.0-y) / 2.0;
    t = x - c;
    //printf("%f-%f", c, t);
    if (int(c)==c && int(t)==t && c>=0 && t>=0) {
        printf("Yes");
    }
    else {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  ll n;cin>>n;
  ll p=n/100;
  ll q=n%100;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  bool x = p<=12&&p>=1;
  bool y = q<=12&&q>=1;
  if(x&y)cout<<"AMBIGUOUS"<<endl;
  else if(x)cout<<"MMYY"<<endl;
  else if(y)cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
  



  return 0;
}

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

int main() {
    int cnt[100005] = {};
    int N;
    int A;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A;
        cnt[A]++, cnt[A + 1]++, cnt[A + 2]++;
    }
    cout << *max_element(cnt, cnt + 100005) << endl;
    return (0);
}

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

int main(){
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;

  return 0;
}

Measured memory_bytes: 3588
k, n, *a_n = map(int, open(0).read().split())

dif = [0] * n

for i in range(n - 1):
    dif[i] = a_n[i + 1] - a_n[i]

dif[n - 1] = k - a_n[n - 1] + a_n[0]

dif.pop(dif.index(max(dif)))

print(sum(dif))

Measured memory_bytes: 25124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int N=s.size();
  string ans="Yes";
  for(int i=0;i<N/2;i++) {
    if(s[i]!=s[N-1-i]){
      ans="No";
      break;
    }
  }
    for(int i=0;i<(N-1)/2;i++) {
      if(s[i]!=s[(N-3)/2-i]||s[(N+1)/2+i]!=s[N-1-i]) {
        ans="No";
        break;
      }
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int X,N,val;
    cin >> X >> N;
    if (N==0) {
        cout << X;
        return 0;
    }
    set<int> P;
    for (int i = 0; i<N; ++i) {
        cin >> val;
        P.insert(val);
    }
    vector<int> A;
    for(int i = 0; i<104; ++i){
        if (P.count(i)) continue;
        A.push_back(i);
    }
    int best = 10000,ans;
    for (int i = 0; i<A.size(); ++i) {
        if (best > abs(A[i]-X)) {
            best = abs(A[i]-X);
            ans = A[i];
        };
    }
    cout << ans;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353
#define kbr break
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(ll i=0;i<n;i++)
#define bf(i,n)    for(ll i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < ll ,ll ,ll > > ;
// #define vector< ll ,ll > pv;
// vector< pair <ll,ll> > vect;


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

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

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

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

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

// ll n;cin>>n;ll a[n];for(ll i=0;i<n;i++)cin>>a[i];    
// for(ll i=0;i<n;i++)cout<<a[i];
// ll a,b;cin>>a>>b;   

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

// vector< tuple < ll ,ll ,ll > > tv;
// vector< ll ,ll > pv;


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


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll tt=1;
   // cin>>tt;
	while(tt--)
	{
	    ll g=1e18;
	      ll p = 1;
    ll n; cin>>n; bool flag=1;
    ll a[n]; f(i,n){ cin>>a[i]; if(a[i]==0) flag=0; }
    if(!flag){ p1(0); return 0; }
    f(i,n)
    {
        ll kk = a[i];
        if( g/kk < p ){ flag=0; p = 0; kbr; }
        p = p*kk; 
        if( p > g ){ flag=0; p = 0; kbr; }
        //cout<<p<<":"<<i<<endl;
    }
	if(flag) p1(p);
	else p1(-1);
	   
	   
	    
	}
	
	return 0;
}


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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;

/////////////////////////////////////////////////////////////////////

const int N = 1e3 + 20;

int ps[N];

int32_t main() {

	sync;
	
	int n, all = 0; cin >> n;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		all ^= x;
	}
	cout << (all == 0 ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 256
tmp = [0] * 10
def rec(i):
  for j in range(len(w)):
    if(i >= w[j] and dp[0][ i - w[j] ] != -1):
      if(dp[0][ i - w[j] ] + 1 > dp[0][i]):
        dp[0][i] = dp[0][ i - w[j] ] + 1
        for k in range(10):
          dp[1][i][k] = dp[1][ i - w[j] ][k]
        dp[1][i][v[j]] += 1

      elif(dp[0][ i - w[j] ] + 1 == dp[0][i]):
        for k in range(10):
          tmp[k] = dp[1][ i - w[j] ][k]
        tmp[v[j]] += 1
        for k in range(9,0,-1):
          if(tmp[k] > dp[1][i][k]):
            dp[0][i] = dp[0][ i - w[j] ] + 1
            for k in range(10):
              dp[1][i][k] = dp[1][ i - w[j] ][k]
            dp[1][i][v[j]] += 1
            break
          elif(tmp[k] < dp[1][i][k]):
            break

n, k = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
ww = [2,5,5,4,5,6,3,7,6]
z =  [1,7,4,5,3,2,9,6,8]

dp = [0]*2
dp[0] = [-1] * (n+1)
dp[0][0] = 0
dp[1] = [ [0 for i in range(10)] for j in range(n+1)]
w = []
v = []
for i in z:
  if(i in a):
    if(not ww[i-1] in w):
      v.append(i)
      w.append(ww[i-1])

for i in range(min(w), n+1):
  rec(i)

for i in range(9,0,-1):
  print("{}".format(i)*dp[1][n][i], end='')


Measured memory_bytes: 5860
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s;
	cin >> s;

	int cnt=0, l=0, r=s.length()-1;
	while(l<r){
		if(s[l]==s[r]){
			l++; r--;
		}else if(s[l]=='x' && s[r]!='x'){
			l++; cnt++;
		}else if(s[l]!='x' && s[r]=='x'){
			r--; cnt++;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
N=int(input())
P=list(map(int,input().split()))

ans=0
for i in range(N-1):
    if P[i]==i+1:
        P[i],P[i+1]=P[i+1],P[i]
        ans+=1
        
if P[-1]==N:
    ans+=1

print(ans)

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

vector<int> G[250001];
int h[250001];
int e[250001];

void visit(int v){
    int i;

    h[v]--;
    
    for(i=0; i<G[v].size(); i++){
        if(h[v]+e[v]<h[G[v][i]]){
            visit(G[v][i]);
        }
    }
}

void search(int v){
    int i;
    for(i=0; i<G[v].size(); i++){
        if(h[v]<h[G[v][i]]){
            visit(G[v][i]);
        }
    }
}

int main(){
    //input
    int N;
    cin >> N;
    int P[N*N+1];
    int i,j;
    for(i=1; i<=N*N; i++){
        cin >> P[i];
    }

    //calc
    for(i=0; i<=N-1; i++){
        for(j=1; j<=N-1; j++){
            G[i*N+j].push_back(i*N+j+1);
            G[i*N+j+1].push_back(i*N+j);
        }
    }
    for(j=1; j<=N; j++){
        for(i=0; i<=N-2; i++){
            G[i*N+j].push_back((i+1)*N+j);
            G[(i+1)*N+j].push_back(i*N+j);
        }
    }
    for(i=0; i<=N-1; i++){
        for(j=1; j<=N; j++){
            h[i*N+j]=i;
            h[i*N+j]=min(h[i*N+j],N-1-i);
            h[i*N+j]=min(h[i*N+j],j-1);
            h[i*N+j]=min(h[i*N+j],N-j);
        }
    }
    for(i=1; i<=N*N; i++){
        e[i]=1;
    }
    int ans=0;
    for(i=1; i<=N*N; i++){
        ans += h[P[i]];
        e[P[i]]=0;
        search(P[i]);
    }

    //answer
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 31664
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
std::vector<std::vector<T>> mk2d(size_t s1, size_t s2, T const& val) {
  std::vector<T> tmp(s2, val);
  return std::vector<std::vector<T>>(s1, tmp);
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  auto reduce = [&](int x, int y) {
    x %= K+K; y %= K+K;
    if(y >= K) {
      y -= K;
      (x += K) %= K+K;
    }
    return std::make_pair(x, y);
  };
  auto w = mk2d<int>(K+K+1, K+1, 0);
  auto b = mk2d<int>(K+K+1, K+1, 0);
  for(int i = 0; i < N; ++i) {
    int x, y; char c; std::cin >> x >> y >> c;
    auto p = reduce(x, y);
    if(c == 'B') ++b[p.first+1][p.second+1];
    else         ++w[p.first+1][p.second+1];
  }
  // sumup
  for(int x = 1; x <= K+K; ++x) for(int y = 0; y < K; ++y) {
    w[x][y+1] += w[x][y];
    b[x][y+1] += b[x][y];
  }
  for(int y = 1; y <= K; ++y) for(int x = 0; x < K+K; ++x) {
    w[x+1][y] += w[x][y];
    b[x+1][y] += b[x][y];
  }

  int ans = 0;
  for(int x = 0; x < K; ++x) for(int y = 0; y < K; ++y) {
    // [0,x)x[0,y) + [x,x+K)x[y,K) + [x+K,K+K)x[0,y)
    int b1 = b[x+K][K] + b[K+K][y] - b[x][K] - 2*b[x+K][y] + 2*b[x][y];
    int b2 = b[K+K][K] - b1;
    int w1 = w[x+K][K] + w[K+K][y] - w[x][K] - 2*w[x+K][y] + 2*w[x][y];
    int w2 = w[K+K][K] - w1;
    ans = std::max(ans, std::max(b1+w2, b2+w1));
  }
  fin(ans);
  return 0;
}


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

const int MAXN = 100005;
ll mod;
ll up[MAXN];
ll down[MAXN];
vector<ll> g[MAXN];
ll pr[MAXN];

void dfs_down(int v, int p)
{
    down[v] = 1;
    for (auto to : g[v])
    {
        if (to == p) continue;
        dfs_down(to, v);
        down[v] *= down[to] + 1;
        down[v] %= mod;
    }
}

void dfs_up(int v, int p, ll val)
{
    up[v] = val;
    ll pref = 1;
    for (int i = 0; i < g[v].size(); i++)
    {
        ll to = g[v][i];
        if (to == p) continue;
        pr[to] = pref; pr[to] %= mod;
        pref *= down[to] + 1; pref %= mod;
    }
    ll suf = 1;
    for (int i = g[v].size()-1; i >= 0; i--)
    {
        ll to = g[v][i];
        if (to == p) continue;
        ll nval = val;
        nval *= pr[to]; nval %= mod;
        nval *= suf; nval++; nval %= mod;
        dfs_up(to, v, nval);
        suf *= down[to] + 1; suf %= mod;
    }
}

int main()
{
    int n;
    cin >> n >> mod;
    for (int i = 0; i < n-1; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs_down(1, 0);
    dfs_up(1, 0, 1);

    for (int i = 1; i <= n; i++)
        cout << (down[i] * up[i]) % mod << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

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

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

int main()
{
    ll N, M;
    cin >> N >> M;
    vec a(N);
    REP(i,0,N) {
        cin >> a[i];
        a[i] /= 2;
    }

    vec C(N, 0);
    ll c, d = 0;
    bool f, g;
    while(true) {
        f = true;
        REP(i,0,N) {
            if(a[i] % 2 == 0) {
                f = false;
                a[i] /= 2;
                ++C[i];
            }
        }
        g = true;
        c = C[0];
        REP(i,0,N) {
            if(c != C[i]) g = false;
        }
        if(f) break;
    }

    if(f && g) {
        ll L = 1;
        REP(i,0,N) L = lcm(L, a[i]);
        L *= (1 << c);
        PR((M/L+1)/2);
    }
    else PR(0);
    

    return 0;
}

/*



*/

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

using namespace std;

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

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

  int N;
  cin >> N;

  queue<int> q;
  rep (i, N) {
    int H;
    cin >> H;

    q.push(H);
  }

  int current = q.front();
  q.pop();

  int max = current;

  bool result = true;
  while (!q.empty()) {
    int next = q.front();
    q.pop();

    if (next == current) {
      continue;
    }

    if (next < current) {
      int tmp = current - 1;

      if (next != tmp || tmp < max) {
        result = false;
        break;
      }

      current = tmp;
      max = tmp;
    } else {
      current = next;
    }
  }

  cout << (result ? "Yes" : "No") << '\n';

  return 0;
}

Measured memory_bytes: 3764
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
int n, ind;
int arr[maxn];
 
int main() {
	migmig;
	
	cin >> n;
 
	for (int i = 0; i < n; i++){
		cin >> arr[i];
	}
	if (n == 1) {
		if (arr[0] % 2 == 1)
			return cout << "Second" , 0;
		else
			return cout << "First" , 0; 
	}
	
	sort(arr, arr + n , greater<int>());
	
	if (arr[0] == 1) {
		if (n % 2 == 1)
			return cout << "Second" , 0;
		else
			return cout << "First" , 0; 
			
		return 0;
	}
	
	ind = n;
	int h = arr[0];
	for (int i = 1; i < n; i++) {
		if (arr[i - 1] >= i && arr[i] <= i) {
			ind = i;
			break;
		}
	}
	
	ind--;
 
	if ((arr[ind] - ind) % 2 == 0) {
		cout << "First";
		return 0;
	}
	
	int cnt = 0;
	int tmp = ind + 1;
	while (tmp < n && arr[tmp] == ind + 1) {
		tmp++;
		cnt++;
	}
	if (cnt % 2 == 1) {
		cout << "First";
		return 0;
	}
	cout << "Second";
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int v[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2,
     1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << v[k-1] << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;



int main(){
    int n;
    cin>>n;
    vector<vector<int>> ame(2);
    ame[0].resize(1000);
    ame[1].resize(1000);
    for(int i=0;i<2;i++){
        for(int t=0;t<n;t++){
            cin>>ame[i][t];
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=ame[0][i];
        ame[0][i]=sum;
    }
    sum=0;
    for(int i=n-1;i>=0;i--){
        sum+=ame[1][i];
        ame[1][i]=sum;
    }
    int mx=0;
    for(int i=0;i<n;i++){
        mx=max(mx,ame[0][i]+ame[1][i]);
    }
    cout<<mx<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    while(n--){
        string com;
        cin >> com;
        if(com=="replace"){
            int ini,lst;
            string re;
            cin >> ini >> lst >> re;
            for(int i=0; i<(lst-ini)+1; i++){
                s[ini+i]=re[i];
            }
        }
        else if(com=="reverse"){
            int ini,lst;
            cin >> ini >> lst;
            for(int i=1; i<=(lst-ini+1)/2; i++){
                swap(s[ini+i-1],s[lst-i+1]);
            }
        }
        else if(com=="print"){
            int ini,lst;
            cin >> ini >> lst;
            for(int i=ini; i<=lst; i++)
                cout << s[i];
            cout << endl;
        }
    }
    return 0;
}


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

int main(){
    string s;cin>>s;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='p')count++;
    }
    cout<<s.size()/2-count<<endl;
    return 0;
}

Measured memory_bytes: 512
from operator import mul
from functools import reduce
# from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(10**6)


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


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


def dfs(visit, a, v_b, v_color):
    visit[a] = True

    # t_list = [t for t in tmp_list[a] if t != v_b]
    # t_color = [c for c in range(ans) if v_color != c]
    # print(t_list, t_color)
    flag = True
    i = 0
    for b in tmp_list[a]:
        if b == v_b:
            continue
        # print(a, b, c)
        # color[a][c] = True
        # color[b][c] = True
        if flag is True and i >= v_color:
            flag = False
            i += 1
        c = i
        ans_c[min(a, b), max(a, b)] = c
        dfs(visit, b, a, c)
        i += 1

    return


N = int(input())
AB = [inpl() for i in range(N - 1)]

ans_c = {}
tmp_list = [[] for i in range(N + 1)]
for a, b in AB:
    tmp_list[a].append(b)
    tmp_list[b].append(a)

ans = max(len(a) for a in tmp_list)
# print(ans, "ans")
# color = [[False for j in range(ans)] for i in range(N + 1)]
visit = [False for i in range(N + 1)]
dfs(visit, 1, N + 1, ans + 1)

print(ans)
for a, b in AB:
    print(ans_c[a, b] + 1)


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

using namespace std;

int N;
vector<vector<int>> G;
vector<int> dist0, dist1;

void DFS(int v, int parent, int d, vector<int>& dist) {
  dist[v] = d;
  for (int v2 : G[v]) {
    if (v2 == parent) continue;
    DFS(v2, v, d + 1, dist);
  }
}

int main() {
  cin >> N;
  G.resize(N);
  dist0 = vector<int>(N, 0);
  dist1 = vector<int>(N, 0);

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

  DFS(0, -1, 0, dist0);
  DFS(N - 1, -1, 0, dist1);

  int count0 = 0, count1 = 0;
  for (int i = 0; i < N; i++) {
    if (dist0[i] <= dist1[i]) {
      count0++;
    } else {
      count1++;
    }
  }

  if (count0 > count1) {
    printf("Fennec\n");
  } else {
    printf("Snuke\n");
  }

  return 0;
}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld N;
    map<string,int> m;
    cin >> N;
    lld ans = 0;
    for (int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if(m.find(s) == m.end()){
            m.insert(make_pair(s,1));
            ans++;
        } 
    }
    cout << ans << endl;
}

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

const long long INF = 1LL<<60;


int main(){
    int n;
    cin >> n;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    
    vector<long long> dp(n+1, INF);
    
    
    for (int i = 0; i < n; i++){
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    
    int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    
    cout << ans << endl;
}


Measured memory_bytes: 4384
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>




using namespace std;



using ll = long long;
const ll INF = 1e18L + 5;
ll dp[500][500];
ll n;
ll tab[500];

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    //dp[i][j] - cost to connect interval i to j
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> tab[i];
    }
    auto sum = [&](int L, int R){
        ll s = 0;
        for(int i = L; i <= R; i++){
            s += tab[i];
        }
        return s;
    };
    for(int L = n - 1; L >= 0 ; L--){
        for(int R = L; R < n; R++){
            if(L == R){
                dp[L][R] = 0;
            }
            else{
                dp[L][R] = INF;
                ll s = sum(L, R);
                for(int i = L; i < R; i++){
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s);
                }
            }
        }
    }
    
    
    cout << dp[0][n - 1];
}



Measured memory_bytes: 1792
n, m = map(int,input().split())
def divisor(m): 
    i = 1
    table = []
    while i * i <= m:
        if m%i == 0:
            table.append(i)
            table.append(m//i)
        i += 1
    table = list(set(table))
    return table
L = divisor(m)
ans = 0
for l in L:
  if l <= m/n:
    ans = max(ans, l)
print(ans)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int A[H][W];
  pair<int, int> p[H * W + 1];
  rep (i, H) rep (j, W) {
    cin >> A[i][j];
    p[A[i][j]] = mp(i, j);
  }

  int power[H * W + 1];
  memset(power, 0, sizeof(power));
  REP (i, 1, H * W - D + 1) {
    power[i + D] = power[i] + abs(p[i].F - p[i + D].F) + abs(p[i].S - p[i + D].S);
  }

  int Q;
  cin >> Q;
  rep (i, Q) {
    int L, R;
    cin >> L >> R;
    cout << power[R] - power[L] << endl;
  }
}


Measured memory_bytes: 2560
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int a,b;
	cin >> a >> b;
	cout << max(max(a+b,a-b),a * b) << endl;
}

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

int main(void)
{
  int sx, sy,tx, ty ;
  cin >> sx >> sy >> tx >> ty ;
  int dx = tx-sx ;
  int dy = ty-sy ;
  
  cout << string(dx,'R') << string(dy,'U')  ;
  cout << string(dx,'L') << string(dy,'D')  ;
  cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D'  ;
  cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U' ;
  cout << endl ;
    
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"

using namespace std;

#define f(i,n) for(int i=0; i<n;i++) 
#define rf(i, n) for(int i=n-1;i>=0;i--)
#define forn(i, j, n) for(int i=j; i<n; i++)
#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) (x) * (x)
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

const int sze = 3e5 + 50, INF = 1e18 + 500, mod = 998244353;
const double eps = 5e-10, PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi vertices[sze];
vc visit(sze, false);
vi arr(sze, 0);
int n, m, k, t;
int d = 0;
int cnt = 0;
string s;
vi col(sze, 0);
vi sum(sze, INF);
int x, y;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	
	cin >> n;

	k = sqrt(2 * n);

	bool b = false;
	for (int j = max(k - 10, 2ll); j <= k + 10; j++)
	{
		if (j*(j - 1) == 2 * n)
		{
			b = true;
			k = j;
			break;
		}
	}

	if (!b)
	{
		cout << "No";
		return 0;
	}

	int cnt = 1;

	for(int i = 0; i < k; i ++)
	{
		forn(j, i + 1, k)
		{
			vertices[i].pb(cnt);
			vertices[j].pb(cnt);
			cnt++;
		}
	}

	cout << "Yes" << endl;
	cout << k << endl;
	f(i, k)
	{
		cout << vertices[i].size() << " ";
		for (auto to : vertices[i])
		{
			cout << to << " ";
		}
		cout << endl;
	}
	return 0;
}



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

#define MAX 100000
#define INFTY (1<<30)

class Edge{
    public:
    int t,w;
    Edge(){}
    Edge(int t,int w): t(t),w(w){}
};

vector<Edge> G[MAX];
int n,d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
    for(int i=0;i<n;i++){
        d[i] = INFTY;
    }
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    int u;
    while(!Q.empty()){
        u = Q.front();Q.pop();
        for(int i=0;i<G[u].size();i++){
            Edge e = G[u][i];
            if(d[e.t]==INFTY){
                d[e.t] = d[u]+e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve(){
    //適当な視点sから最も遠い接点tgtを求める
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for(int i=0;i<n;i++){
        if(d[i]==INFTY) continue;
        if(maxv<d[i]){
            maxv = d[i];
            tgt = i;
        }
    }
    bfs(tgt);
    maxv = 0;
    for(int i=0;i<n;i++){
        if(d[i]==INFTY) continue;
        maxv = max(maxv,d[i]);
    }
    cout << maxv << endl;
}

int main(){
    int s,t,w;
    cin >> n;
    for(int i=0;i<n-1;i++){
        cin >> s >> t >> w;
        G[s].push_back(Edge(t,w));
        G[t].push_back(Edge(s,w));
    }
    solve();
}


Measured memory_bytes: 9924
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
ll n,m;
ll a[305][305];
ll tmp[305];
const ll mod = 998244353;
ll ME(ll x,ll nn,ll M)
{
    ll result=1;
    while(nn>0)
    {
        if(nn % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        nn=nn/2;
    }
    return result;
}
void swaps(ll x, ll y)
{
        for(ll i=0;i<m;i++) tmp[i] = a[x][i];
        for(ll i=0;i<m;i++) a[x][i] = a[y][i];
        for(ll i=0;i<m;i++) a[y][i] = tmp[i];
}
int main()
{
        cin >> n >> m;
        for(ll i=0;i<n;i++) {
                for(ll j=0;j<m;j++) {
                        cin >> a[i][j];
                }
        }
        ll sz=0;
        for(ll i=0; i < m && sz < n; i++) {
                bool ok = false;
                for(ll j=sz; j<n;j++) {
                        if(a[j][i] == 1) {
                                swaps(sz , j);
                                ok = true;
                                break;
                        }
                }
                if(!ok) continue;
                for(ll j=0;j<n;j++) {
                        if(j==sz) continue;
                        if(a[j][i] == 1) {

                                for(ll k=0;k<m;k++) {
                                        a[j][k] ^= a[sz][k];
                                }
                        }
                }
                sz++;
        }
        ll r = 0;
        for(ll i=0;i<n;i++) {
                ll yo=0;
                for(ll j=0;j<m;j++) yo += a[i][j];
                if(yo>0) r++;
        }
        ll ans = ME(2LL,n+m-1,mod);
        ans = (ans - ME(2LL,n+m-r-1, mod) + mod)%mod;
        ans %= mod;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

bool check(VI& pp, VI& f, int k, int del = -1) {
  dump(pp, f, del);
  int i_f = (int)f.size() - k;
  if (del >= i_f) i_f--;
  REP (i, k) {
    if (i_f < 0 | i_f >= f.size()) return false;
    while (i_f == del) i_f++;
    if (i_f < 0 | i_f >= f.size()) return false;
    if (pp[i] >= f[i_f]) return false;
    i_f++;
  }
  return true;
}
signed main() {
  int n; cin >> n;
  VI p(n), f(n);
  REP (i, n) cin >> p[i];
  REP (i, n) cin >> f[i];
  sort(ALL(f));
  int acc = 0;
  {
    VI pp = p; sort(ALL(pp));
    REP (i, n) {
      if (check(pp, f, i + 1)) {
        acc = max(acc, i + 1);
      }
    }
  }
  VI ans;
  REP (i, n) {
    dump(i);
    const int op = p.front();
    p.erase(p.begin());
    VI pp = p; sort(ALL(pp));
    int l = 0, r = f.size();
    bool win = f.back() > op;
    if (win) {
      l = upper_bound(ALL(f), op) - f.begin();
    }
    dump(f, l);
    while (r - l > 1) {
      int m = (l + r) / 2;
      dump(m);
      bool ok = check(pp, f, (win ? acc - 1 : acc), m);
      dump(ok)
      (ok ? l : r) = m;
    }
    if (win) acc--;
    ans.push_back(f[l]);
    f.erase(f.begin() + l);
  }
  REP (i, n) {
    cout << ans[i] << (i == n - 1 ? "\n" : " ");
  }
}



Measured memory_bytes: 3300
import sys
sys.setrecursionlimit(400000)
n,q=map(int,input().split())
ans=[0]*(n+1) #答え
score=[0]*(n+1) #xの総和
g=[[] for _ in range(n+1)] #グラフ
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for j in range(q):
    p,x=map(int,input().split())
    score[p]+=x

visited=[0]*(n+1)
def dfs(v):
    visited[v] += 1
    global ans
    ans[v]+=score[v]
    for i in range(len(g[v])):
        if visited[g[v][i]] == 0:
            ans[g[v][i]]+=ans[v]
            dfs(g[v][i])
dfs(1)
print(" ".join(map(str, ans[1:])))


Measured memory_bytes: 230572
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N,K;
    cin >> N >> K;
    long long ans;
    if(N%K==0){
        ans=0;
    }else{
        ans=min(K-(N%K),N%K);
    }
    cout << ans;
    return 0;
}

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

int X;
int main() {
    cin >> X;
    int t = 1;
    while (true) {
        int target = t * (t + 1) / 2;
        if (target >= X) break;
        t++;
    }

    cout << t << endl;
}

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

using namespace std;

const int Maxn=100005;

struct cake
{
	int a, b;
	cake(int A, int B) : a(A), b(B) { }
	cake() { }
	bool operator < (const cake& B) const
	{
		return a + b > B.a + B.b;
	}
};

cake a[Maxn];
long long sum = 0;
int n;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
		scanf("%d %d", &a[i].a, &a[i].b);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++ i)
		if (i & 1) sum += a[i].a;
		else sum -= a[i].b;
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
	string tenki;
    cin >> tenki;
  
  if(tenki == "Sunny")
    cout << "Cloudy" << endl;
    if(tenki == "Cloudy")
    cout << "Rainy" << endl;
  if(tenki == "Rainy")
    cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256