akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

int main(void) {
    string s;
    cin >> s;
    ll i;
    ll min=(ll)s.size();
    for(i=0; i<s.size()-1; i++) {
        if(s[i]!=s[i+1]) {
            min=min(min, max(i+1, (ll)s.size()-i-1));
        }
    }
    
    if(min==0 && s[0]=='1') {
        prin(s.size());
    }else {
        prin(min);
    }
}


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

const int MAX_N = 55;

int N;
int a[MAX_N];

int main(void){
    // Here your code !
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {scanf("%d", &a[i]);}

    bool alr = true;
    for (int i = 0; i < N - 1; ++i) {alr &= (a[i] <= a[i + 1]);}
    if (alr) {printf("0\n"); return 0;}


    bool p = true;
    bool m = true;
    for (int i = 0; i < N; ++i) {p &= (a[i] >= 0); m &= (a[i] <= 0);}

    if (p) {
      printf("%d\n", N - 1);
      for (int i = 0; i < N - 1; ++i) {
        printf("%d %d\n", i + 1, i + 1 + 1);
      }
      return 0;
    }
    else if (m) {
      printf("%d\n", N - 1);
      for (int i = N - 1; i > 0; --i) {
        printf("%d %d\n", i + 1, i + 1 - 1);
      }
      return 0;
    }
    else {
      int* emax = max_element(a, a + N);
      int* emin = min_element(a, a + N);
      if (abs(*emax) >= abs(*emin)) {
        int num = 0;
        for (int i = 0; i < N; ++i) {
          if (a[i] < 0) num++;
        }
        int argemax = emax - a;
        printf("%d\n", N - 1 + num);
        for (int i = 0; i < N; ++i) {
          if (a[i] < 0) printf("%d %d\n", argemax + 1, i + 1);
        }
        for (int i = 0; i < N - 1; ++i) {
          printf("%d %d\n", i + 1, i + 1 + 1);
        }
        return 0;
      }
      else {
        int num = 0;
        for (int i = 0; i < N; ++i) {
          if (a[i] > 0) num++;
        }
        int argemin = emin - a;
        printf("%d\n", N - 1 + num);
        for (int i = 0; i < N; ++i) {
          if (a[i] > 0) printf("%d %d\n", argemin + 1, i + 1);
        }
        for (int i = N - 1; i > 0; --i) {
          printf("%d %d\n", i + 1, i  + 1 - 1);
        }
        return 0;
      }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int number_x, number_a, number_b;
  scanf("%d %d %d", &number_x, &number_a, &number_b);
  if(number_a >= number_b) {
    printf("delicious\n");
  } else if(number_a + number_x >= number_b) {
    printf("safe\n");
  } else {
    printf("dangerous\n");
  }
  return 0;
}


Measured memory_bytes: 128
#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++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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

bool isGuMojiretsu(string S){
	int n = S.size();
	if(n %2 == 0){
		rep(i,n/2){
			if(S[i]!=S[n/2+i]){
				return false;
			}
		}
		return true;
	}else{
		return false;
	}
}

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

	int len = S.size();
	do{
		S.erase(len-1);
		len--;
	}while(!isGuMojiretsu(S));

	cout << len << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>


using namespace std;

void print(vector<int> &b);


void print(vector<int> &b) {
    for (auto i : b) {
        cout << i << " ";
    }
    cout << endl;
}

bool comp(int a, int b) {
    int l = (a % 10) == 0 ? 10 : a % 10;
    int r = (b % 10) == 0 ? 10 : b % 10;
    return l > r;
}

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

    vector<int> v(5);
    for (int i = 0; i < 5; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), comp);
    int r = 0;
    for (int i = 0; i < v.size() - 1; ++i) {
        r += (v[i] + 9) / 10 * 10;
    }
    cout << r + v[v.size() - 1];
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int countDays(int year, int month, int day)
{
    int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int cnt = day;

    if (month == 1)
    {
        return cnt;
    }

    for (int i = 0; i < month - 1; i++)
    {
        cnt += days[i];
    }

    if (month >= 3 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        cnt++;
    }

    return cnt;
}

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c=map(int,readline().split())

    li=[a,b,c]
    li.sort()
    x=li[0]
    y=li[1]
    z=li[2]

    cnt=0
    cnt+=z-y
    x+=z-y
    y+=z-y
    if (z-x)%2==0:
        cnt+=(z-x)//2
    else:
        cnt+=(z-x+1)//2+1

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

Measured memory_bytes: 3064
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int a[26] ;
    for(int i = 0; i<26; i++)
    a[i] = 0;

    string s;
    cin>>s;


    for(int i = 0; i<s.size(); i++)
    {
      a[s[i] - 'a']  = 1;
    }

    int flag = -1;
    int i ;
    for(i = 0 ; i<26; i++)
    {
        if(a[i] == 0)
          {flag = i;
          break;}
    }
    // for(int i = 0 ; i<26; i++)
    // cout<<a[i]<<"\t";
    // cout<<endl;

    if(flag != -1)
    {
      cout<<char('a'+flag)<<endl;

    }else
    cout<<"None\n";






    return 0;
}


Measured memory_bytes: 512
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	vector<int> ref(A[N-1], 0);
	for(int i=0; i<N-1; ++i){
		if(ref[A[i]-1]==1) continue;
		int count = 2;
		while(A[i]*count <= A[N-1]){
			ref[A[i]*count-1] = 1;
			++count;
		}
	}
	for(int i=0; i<N-1; ++i) if(A[i]==A[i+1]) ref[A[i]-1] = 1;
	int ans = 0;
	for(int i=0; i<N; ++i) if(ref[A[i]-1]==0) ++ans;
	cout << ans << endl;
}

Measured memory_bytes: 7776
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;

const int mod = 1000000007;

bool bin_search(vector<ll>& a, ll v) {
	int l = 0, r = a.size() - 1;
	while (l <= r) {
		int m = (l + r) / 2;
		if (a[m] == v)  return true;
		if (a[m] < v) l = m + 1;
		else r = m - 1;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = 'a' + (s[k - 1] - 'A');
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int n,a[N];
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
inline bool check(int l,int r){
	int mx=0,mn=n+1;
	for(int i=l;i<=r;++i)mx=max(mx,a[i]),mn=min(mn,a[i]);
	if(mx!=r||mn!=l)return false;
	int mx1=0,mx2=0;
	for(int i=l;i<=r;i+=2){
		if(mx1<a[i]&&mx2<a[i])mx1=a[i];
		else if(mx2<a[i])mx2=a[i];
		else return false;
	}
	return true;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i){
		if(a[i]==i)continue;
		int p=i;
		while(p<=n-2){
			if(a[p+1]!=p+1||a[p+2]==p+2)break;
			p+=2;
		}
		if(!check(i,p)){puts("No");return 0;}
		i=p;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
ll n;
ll a[3005];
ll dp[3005][3005][2];
ll sharingan(ll i,ll j,ll ch){
  if(i==j){
    if(ch==0)
      return a[i];
    else 
    return (-1*a[i]);
  }
  if(dp[i][j][ch]!=-1)
  return dp[i][j][ch];
  
  if(ch==0)
  return dp[i][j][ch]=max(a[i]+sharingan(i+1,j,1ll),a[j]+sharingan(i,j-1,1ll));
  else 
   return dp[i][j][ch]=min(sharingan(i+1,j,0ll)-a[i],sharingan(i,j-1,0ll)-a[j]);
}
int main(){
  IOS;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  memset(dp,-1,sizeof(dp));
  cout<<sharingan(0,n-1,0ll);
}

Measured memory_bytes: 141568
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    val cntMap = mutableMapOf<Int, Int>()
    
    val aList = readInputLine().split(" ").map { it.toInt() % M }
    
    aList.fold(0) { acc, num -> 
        val newAcc = (acc + num) % M
        val cnt = cntMap.get(newAcc) ?: 0
        cntMap.put(newAcc, cnt + 1)
        newAcc
    }

    var ans = 0L
    var acc = 0
    
    for (a in aList) {
        val cnt = cntMap.get(acc) ?: 0
        ans += cnt.toLong()
        acc = (acc + a) % M
        val newCnt = cntMap.get(acc) ?: 0
        cntMap.put(acc, newCnt - 1)
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 57196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll gA, sA, bA, gB, sB, bB;
    cin >> gA >> sA >> bA >> gB >> sB >> bB;
    ll ans = 0;
    ll vg = gB - gA, vs = sB - sA, vb = bB - bA;
    if(vg >= 0 && vs < 0 && vb < 0){
        ll tt = N % gA + (N / gA) * gB;
        rep(i,0,tt+1){
            ll i2 = tt - i;
            ans = max(ans, (i/sB) * sA + (i2/bB) * bA + i%sB + i2%bB);
        }
    }else if(vg < 0 && vs >= 0 && vb < 0){
        ll tt = N % sA + (N / sA) * sB;
        rep(i,0,tt+1){
            ll i2 = tt - i;
            ans = max(ans, (i/gB) * gA + (i2/bB) * bA + i%gB + i2%bB);
        }

    }else if(vg < 0 && vs < 0 && vb >= 0){
        ll tt = N % bA + (N / bA) * bB;
        rep(i,0,tt+1){
            ll i2 = tt - i;
            ans = max(ans, (i/gB) * gA + (i2/sB) * sA + i%gB + i2%sB);
        }

    }else if(vg >= 0 && vs >= 0 && vb < 0){
        ll tt = 0;
        rep(i,0,N+1){
            ll i2 = N - i;
            tt = max(tt, (i/gA) * gB + i % gA + (i2/sA) * sB + i2 % sA);
        }
        ans = (tt / bB) * bA + tt % bB;
    }else if(vg >= 0 && vs < 0 && vb >= 0){
        ll tt = 0;
        rep(i,0,N+1){
            ll i2 = N - i;
            tt = max(tt, (i/gA) * gB + i % gA + (i2/bA) * bB + i2 % bA);
        }
        ans = (tt / sB) * sA + tt % sB;
    }else if(vg < 0 && vs >= 0 && vb >= 0){
        ll tt = 0;
        rep(i,0,N+1){
            ll i2 = N - i;
            tt = max(tt, (i/sA) * sB + i % sA + (i2/bA) * bB + i2 % bA);
        }
        ans = (tt / gB) * gA + tt % gB;      
    }else if(vg >= 0 && vs >= 0 && vb >= 0){
        rep(i,0,N+1){
            rep(j,0,N+1){
                ll k = N - i - j;
                if(k < 0) continue;
                ans = max(ans, (i / gA) * gB + i % gA + (j / sA) * sB + j % sA + (k / bA) * bB + k % bA);
            }
        }
    }else{
        rep(i,0,N+1){
            rep(j,0,N+1){
                ll k = N - i - j;
                if(k < 0) continue;
                ans = max(ans, (i / gB) * gA + i % gB + (j / sB) * sA + j % sB + (k / bB) * bA + k % bB);
            }
        }
    }
    print(ans);



}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            string s = ReadLine();
            if(s=="Sunny"){
                WriteLine("Cloudy");
            }
            if(s=="Cloudy"){
                WriteLine("Rainy");
            }
            if(s=="Rainy"){
                WriteLine("Sunny");
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 11092
n=int(input())
d=int((1+8*n)**(1/2))
if d**2!=(1+8*n) or d%2==0:
    print("No");exit()
k=(1+d)//2
print("Yes")
print(k)
haba=1
cnt=1
ret=[[] for i in range(k)]
while cnt<=n:
    for s in range(k-haba):
        ret[s].append(cnt)
        ret[s+haba].append(cnt)
        cnt+=1
    haba+=1
for i in ret:
    print(len(i),*i)

Measured memory_bytes: 9592
a,b = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
s.each_with_index do |c,i|
  if i == a
    if c != "-"
      puts "No"
      exit
    end
  else
    if c == "-"
      puts "No"
      exit
    end
  end
end

puts "Yes"

Measured memory_bytes: 1788
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto p1 = 0, p2 = 0;

  foreach (_; 0..n) {
    auto rd = readln.split, s1 = rd[0], s2 = rd[1];
    if (s1 == s2) {
      ++p1;
      ++p2;
    } else {
      p1 += (s1 > s2 ? 3 : 0);
      p2 += (s1 < s2 ? 3 : 0);
    }
  }

  writefln("%d %d", p1, p2);
}

Measured memory_bytes: 2500
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	if(a<1000){cout<<"ABC";}
	else{cout<<"ABD";}
	





	cout<<endl;
} 


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

const int MAX = 200005;
// Calculate COM(MAX, k) for k<=MAX by O(1) after COMinit() by O(MAX)
// {{{
ll fac[MAX], finv[MAX], inv[MAX];

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

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

int solve(){
  int n,a,b,c;cin>>n>>a>>b>>c;
  COMinit();

  int res = 0;
  int x = 100 * inv[a+b] % MOD;

  vector<int> A(2*n+1, 1);
  rep(i, 1, 2*n+1) A[i] = A[i-1]*a%MOD;
  vector<int> B(2*n+1, 1);
  rep(i, 1, 2*n+1) B[i] = B[i-1]*b%MOD;
  vector<int> ApBinv(2*n+1, 1);
  rep(i, 1, 2*n+1) ApBinv[i] = ApBinv[i-1]*inv[a+b]%MOD;

  rep(k, n, 2*n){
    res += k * COM(k-1, n-1) % MOD * ApBinv[k] % MOD * (A[n]*B[k-n]%MOD + B[n]*A[k-n]%MOD) % MOD;
    res %= MOD;
  }
  cout << res * x % MOD << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

class Program
{
    static string InputPattern = "InputX";

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

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

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int C11 = wkArr[0], C12 = wkArr[1], C13 = wkArr[2];

        SplitAct(InputList[1]);
        int C21 = wkArr[0], C22 = wkArr[1], C23 = wkArr[2];

        SplitAct(InputList[2]);
        int C31 = wkArr[0], C32 = wkArr[1], C33 = wkArr[2];

        bool IsOK = true;

        int A1 = 0;
        int B1 = C11 - A1;
        int A2 = C12 - B1;
        int A3 = C13 - B1;

        int B2 = C21 - A1;
        int B3 = C31 - A1;

        if (A1 + B1 != C11) IsOK = false;
        if (A2 + B1 != C12) IsOK = false;
        if (A3 + B1 != C13) IsOK = false;

        if (A1 + B2 != C21) IsOK = false;
        if (A2 + B2 != C22) IsOK = false;
        if (A3 + B2 != C23) IsOK = false;

        if (A1 + B3 != C31) IsOK = false;
        if (A2 + B3 != C32) IsOK = false;
        if (A3 + B3 != C33) IsOK = false;

        Console.WriteLine(IsOK ? "Yes" : "No");
    }
}


Measured memory_bytes: 13396
n=int(input())
s1=list(input())
s2=list(input())

if s1[0]==s2[0]:
    ass = 3
    i = 0
else:
    ass = 6
    i = 1
    
while i <= n-2:
    if s1[i]==s2[i]:
        if s1[i+1]==s2[i+1]:
            ass = ass*2
            if ass >= 1000000007:
                ass = ass%1000000007
            i = i+1
        else:
            ass = ass*2
            if ass >= 1000000007:
                ass = ass%1000000007
            i = i+2
    else:
        if s1[i+1]==s2[i+1]:
            ass = ass
            if ass >= 1000000007:
                ass = ass%1000000007
            i = i+1
        else:
            ass = ass*3
            if ass >= 1000000007:
                ass = ass%1000000007
            i = i+2
print(ass)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int popcnt(int x) {
  return __builtin_popcountll(x);
}

int f(int x) {
  if (x == 0) return 0;
  return f(x % popcnt(x)) + 1;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  rep(i, n) x[i] = s[i] - '0';

  vector<int> ans(n);
  int pc = 0;
  rep(i, n) pc += x[i];

  rep(b, 2) {
    int npc = pc;
    if (b == 0) npc++;
    else npc--;
    if (npc <= 0) continue;
    int sum = 0;

    rep(i, n) {
      sum = (sum * 2) % npc;
      sum += x[i];
    }
    
    int base = 1;

    for (int i = n - 1; i >= 0; --i) {
      if (x[i] == b) {
        int cur = sum;

        if (x[i] == 0) cur = (sum + base) % npc;
        else cur = (sum - base + npc) % npc;
        ans[i] = f(cur) + 1;
      }

      (base *= 2) %= npc;
    }
  }

  rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 5244
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll a, b, c, k;

	cin >> a >> b >> c >> k;

	vector<ll> v;

	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	sort(v.begin(), v.end(), greater<ll>());

	REP(i, k) {
		v[0] = v[0] * 2;
	}

	cout << v[0] + v[1] + v[2] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace Internship
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            
            if (a < b)
            {
                Console.WriteLine("a < b"); 
            }
            if(a > b)
            {
                Console.WriteLine("a > b");
            }
            if (a == b)
            {
                Console.WriteLine("a == b");
            }


        }

    }
}

Measured memory_bytes: 8900
food_number = int(input())
food_history = list(map(int, input().split()))
point_b = list(map(int, input().split()))
point_c = list(map(int, input().split()))
total_point = 0
for x in range(food_number):
  total_point += point_b[food_history[x] - 1]
  if(x >= 1 and food_history[x] - 1 == food_history[x - 1]):
    total_point += point_c[food_history[x - 1] - 1]
print("{}".format(total_point))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>a(n+1);
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int num=0;
    for(int i=0;i<n;i++){
        num+=abs(a[i+1]-a[i]);
    }
    num+=abs(a[n]);
    vector<int>ans(n);
    for(int i=0;i<n-1;i++){
        ans[i]=num-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]);
    }
    ans[n-1]=num-abs(a[n])-abs(a[n]-a[n-1])+abs(a[n-1]);
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4056
#include<stdio.h>
#include<math.h>
int main(void){
	int H,W,i,j,p;
	for(;;){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=1;i<=H;i++){
			if(i%2==0){
					printf(".");
					p=2;
				}else{
					printf("#");
					p=1;
				}
			for(j=1;j<W;j++){
				if(p==2){
					if(j%2==0){
						printf(".");
					}else{
						printf("#");
					}
				}else if(p==1){
					if(j%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1724
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata.Ecma335;

namespace AtCoder.D
{
    public class Program
    {
        private static long[] _allCount;
        private static long[] _patyCount;

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, X) = Read2Longs();

            _allCount = new long[51];
            _patyCount = new long[51];
            for (int i = 0; i < 51; i++)
            {
                if (i == 0)
                {
                    _allCount[i] = 1;
                    _patyCount[i] = 1;
                    continue;
                }
                _allCount[i] = _allCount[i - 1] * 2 + 3;
                _patyCount[i] = _patyCount[i - 1] * 2 + 1;
            }

            // 前半に存在する場合
            var count = GetPatyCount(N, X);
            return count;
        }

        private static long GetPatyCount(long level, long x)
        {
            if (level == 0)
            {
                return 1;
            }
            if (level == 1)
            {
                switch (x)
                {
                    case 1: return 0;
                    case 2: return 1;
                    case 3: return 2;
                    case 4: return 3;
                    case 5: return 3;
                }
            }
            // バンしかない
            if (x <= level)
            {
                return 0;
            }
            // 中央だったら
            if (_allCount[level] / 2 + 1 == x)
            {
                return _patyCount[level - 1] + 1;
            }
            // 中央より右だったら
            else if (_allCount[level] / 2 < x)
            {
                // 逆から数えて全体から引く
                return _patyCount[level] - GetPatyCount(level, _allCount[level] - x);
            }
            // 中央より左だったら
            else
            {
                return GetPatyCount(level - 1, x - 1);
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28236
#include <iostream>
#include <vector>
#include <unordered_map>
#include <bitset>
using namespace std;
typedef bitset<128> bit;

int M, N;
vector<string> v;

unordered_map<bit, int> memo;
int dfs(bit t){
	if(memo.find(t) != memo.end())return memo[t];
	if(t.count() == 1)return 0;

	int r = 1 << 30;
	for(int j=0;j<M;j++){
		bit a, b;
		for(int i=0;i<N;i++){
			if(t[i]){
				if(v[i][j] == '0'){
					a.set(i);
				} else {
					b.set(i);
				}
			}
		}
		if(a.any() && b.any()){
			r = min(r, max(dfs(a), dfs(b)) + 1);
		}
	}
	return memo[t] = r;
}

int main(){
	for(;cin>>M>>N,M;){
		v.resize(N);
		for(int i=0;i<N;i++)cin >> v[i];

		bit t;
		for(int i=0;i<N;i++)t.set(i);

		memo.clear();
		cout << dfs(t) << endl;
	}
	return 0;
}

Measured memory_bytes: 2324
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
string s,t;
int ans;
int main()
{
    cin>>s>>t;
    int lens=s.length();
    int lent=t.length();
    for(int i=0;i<lens;i++){
        int tmp=0;
        for(int j=0;j<lent;j++){
            if(i+j<lens&&s[i+j]==t[j]){
                tmp++;
            }
            if(i+j>=lens)
                tmp=0;
        }
        ans=max(ans,tmp);
    }
    printf("%d",lent-ans);
    return 0;
}


Measured memory_bytes: 3760
from collections import Counter

n=int(input())
s=[]
for _ in range(n):
    s.append(input())
m=int(input())
t=[]
for _ in range(m):
    t.append(input())
sc=Counter(s)-Counter(t)
ans=0

for ss in sc.values():
    ans=max(ans,ss)
print(ans)



Measured memory_bytes: 3444
#include <stdio.h>

int main() {
  int a, b, ans;
  scanf("%d %d", &a, &b);
  if (a >= 13) {
    ans = b;
  }else if (a >= 6) {
    ans = b / 2;
  }else {
    ans = 0;
  }
  printf("%d\n", ans);
  return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    int res = 0;
    int dir = 0;
    bool magic = true;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'R') {
            if (dir == 3 and magic) {
                res++;
            }
            dir = (dir + 1) % 4;
        }
        else {
            if (dir == 0) {
                magic = false;
            }
            dir = (dir - 1 + 4) % 4;
        }
        if (dir == 0) {
            magic = true;
        }
    }
    dump(res);
    return 0;
}



Measured memory_bytes: 3208
from math import sqrt
def dist(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        ans += dist(data[i],data[j])

print(ans/n)

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

typedef long long ll;

const int mod = 1000000007;
const int INF = 101234567;

int main() {
    int N;
    ll ans = 0;
    cin >> N;
    vector<ll>L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }


    sort(L.begin(), L.end());
    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            ans += lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin()-j-1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int,input().split())

ans = 0
s = sum(range(K-1))
for i in range(K, N+2):
    s += i - 1
    max_add = N * i - s
    min_add = s
    ans += max_add - min_add + 1

print(ans % (1000000007))

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

int main(void){
    char c[4][4];
    char tmp ;

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%c", &c[i][j]);
        }
        // ダミー
        scanf("%c", &tmp);
    }

    printf("%c%c%c\n", c[0][0], c[1][1], c[2][2]);
    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2503, M = 5003;
const long long INF = 1000000000012;
struct ban
{
    int x, y, d;
};

int n, m, p;
vector<int> a[N];
ban b[M];

long long d[N];

bool cc[N];

bool c[N];
void dfs(int x)
{
    c[x] = true;
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (!c[h])
            dfs(h);
    }
}

int main()
{
    scanf("%d%d%d", &n, &m, &p);
    for (int i = 0; i < m; ++i)
    {
        scanf("%d%d%d", &b[i].x, &b[i].y, &b[i].d);
        a[b[i].x].push_back(b[i].y);
        b[i].d -= p;
    }
    for (int i = 2; i <= n; ++i)
        d[i] = -INF;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (d[b[j].x] != -INF && d[b[j].x] + b[j].d > d[b[j].y])
            {
                d[b[j].y] = d[b[j].x] + b[j].d;
                if (i == n - 1)
                    cc[b[j].y] = true;
            }
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (cc[i])
        {
            if (!c[i])
                dfs(i);
        }
    }
    if (c[n])
        cout << "-1" << endl;
    else
        cout << max(0LL, d[n]) << endl;
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

ll dfs(ll x) {
  if (x == 1) {
    return 1;
  }
  return 1 + 2 * dfs(x / 2);
}

int main() {
  CIN(ll, H);
  COUT(dfs(H));
}


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

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

long long dp[110][100010] = {0}; //DP配列
int w[110];    //質量
int v[110];     //価値
int N, W;

int main(){
  cin >> N >> W;

  int wt, vt;
  for(int i = 1; i <= N; i++){cin >> wt >> vt; w[i] = wt; v[i] = vt;}

  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= W; j++){
      if(j-w[i] >= 0) chmax(dp[i][j], dp[i-1][j-w[i]]+v[i]);
      chmax(dp[i][j], dp[i-1][j]);
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}
  







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

ll INF=100000000000000000;
map<ll, ll> tree;

//BIT：tree[得点*n+(n-チーム)]=間接的な順位
// n-チームはチーム番号が小さいやつが上の順位になるように?!
ll sum(ll k){
    ll s=0;
    while(k>=1){
        s+=tree[k];
        k-=k&-k;
    }
    return s;
}

void add(ll k, ll a){
    while(k<=INF){
        tree[k]+=a;
        k+=k&-k;
    }
}

//二分探索的な
ll lower_bound(ll w){
    if(w<=0) return 0;
    ll x=0, r=1;
    while(r<INF){
        r=r<<1;
    }
    for(ll i=r; i>0; i=i>>1){
        if(x+i<=INF&&tree[x+i]<w){
            w-=tree[x+i];
            x+=i;
        }
    }
    return x+1;
}


int main(void){
    ll n, c;
    cin >> n >> c;
    ll s[100010];
    fill(s, s+100010, 1);//BITは1から始まる
    for(ll i=0; i<n; i++){
        add(s[i]*n+(n-(i+1)), 1);
    }
    for(ll i=0; i<c; i++){
        ll a, b, d;
        cin >> a >> b;
        if(a==0){
            cin >> d;
            b--;
            add(s[b]*n+(n-(b+1)), -1);
            s[b]+=d;
            add(s[b]*n+(n-(b+1)), 1);
        }
        else{
            ll k=lower_bound(n-b+1);//下の順位→上の順位で並んでる
            cout << n-k%n << " " << s[n-k%n-1]-1 << "\n";
        }
    }
}



Measured memory_bytes: 69684
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        //Solve();
        WriteLine(Solve());
    }
    static string Solve()
    {
        var num = Input.num;
        var a = (1 + (int)Floor(Sqrt(1 + 8 * num))) / 2;
        if ((a - 1) * a / 2 != num) return "No";
        var res = $"Yes\n{a}\n";
        var list = Enumerable.Repeat(0, a - 1).Select(v => new List<int>()).ToArray();
        var q = 2;
        list[0].Add(1);
        for(var i=1;i<a-1;i++)
            while (list[i - 1].Count + 1 != list[i].Count)
            {
                list[i].Add(q);
                q++;
            }
        var cc = Enumerable.Repeat(0, a).Select(v => new int[a]).ToArray();
        for(var i = 0; i < a-1; i++)
        {
            cc[i][0] = a - 1;
            var ct = 1;
            for (var j = 0; j <= i; j++) {
                cc[i][ct] = list[i][j];
                ct++;
            }
            for (var j = i + 1; j < a - 1; j++)
            {
                cc[i][ct] = list[j][i];
                ct++;
            }
        }
        cc[a - 1][0] = a - 1;
        for (var i = 1; i <= a - 1; i++)
            cc[a - 1][i] = list[i-1].Last();
        return res+string.Join("\n", cc.Select(ar => string.Join(" ", ar)));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

const int M = 1000003;
const int ATCG2INT[] = {0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3};

class Dict {
private:
    vector<string> hash;
    int getkey(const string& s) {
        int key = 0;
        for (auto c : s) {
            key = key * 4 + ATCG2INT[c - 'A'];
        }
        return key;
    }
    int h1(int key) {
        return key % M;
    }
    int h2(int key) {
        return 1 + (key % (M - 1));
    }
public:
    Dict() {
        hash.resize(M);
    }
    void insert(const string& s) {
        int key = getkey(s);
        for (int i = 0; i < M; i++) {
            int h = (h1(key) + i * h2(key)) % M;
            if (hash[h].size() == 0) {
                hash[h] = s;
                return;
            }
        }
    }
    bool find(const string& s) {
        int key = getkey(s);
        for (int i = 0; i < M; i++) {
            int h = (h1(key) + i * h2(key)) % M;
            if (hash[h].size() == 0) {
                return false;
            } else if (hash[h] == s) {
                return true;
            }
        }
        return false;
    }
};

int main()
{
    Dict d;

    int n;
    cin >> n;
    string s, t;
    for (int i = 0; i < n; i++) {
        cin >> s >> t;
        if (s == "insert") {
            d.insert(t);
        } else if (s == "find") {
            if (d.find(t)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
}



Measured memory_bytes: 42192
#include <iostream>
#define MAXN 500
#define for_neighbors(BLK) for(int d=0; d<4; d++){int ii=i+(d==0)-(d==1), jj=j+(d==2)-(d==3); BLK}
using namespace std;
int table[MAXN+2][MAXN+2] = {0};
bool seat[MAXN+2][MAXN+2] = {0};
int N;
void update(int i, int j){
	if(min(i, j) < 0 || max(i, j) >= N)
		return; 
	int n = table[i][j];
	for_neighbors(
		n = min(n, table[ii][jj]+!seat[ii][jj]);
	)
	if(n == table[i][j])
		return ;
	table[i][j] = n;
	for_neighbors(
		update(ii, jj);
	)
}

int main(){
	int P, ans = 0;
	cin >> N;
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			table[i][j] = min(min(i, N-1-i), min(j, N-1-j));

	for(int p=0; p<N*N; p++){
		cin >> P; P--;
		int i = P/N, j = P%N;
		ans += table[i][j];
		seat[i][j] = 1;
		for_neighbors(
			update(ii, jj);
		)
	}
	cout << ans << endl;
}


Measured memory_bytes: 12336
n=int(input())
j=[]
for i in range(n):
    j.append(str(input()))
print("AC x "+str(j.count("AC")))
print("WA x "+str(j.count("WA")))
print("TLE x "+str(j.count("TLE")))
print("RE x "+str(j.count("RE")))

Measured memory_bytes: 16296
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).ending()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
int h,w;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vvi dp(400,vi(400,0));
int touf(int y,int x){
  return y*w+x;
}
pii fromuf(int a){
  pii res;
  res.second = a%w;
  res.first = a/w;
  return res;
}
struct union_find{//rank,経路圧縮で高速化
  vector<int> par;//parは添字の親（または自分が根の時自身）を示す。
  vector<int> rank;//rankは木の高さ（根についてのみ実装,0-indexed）
  union_find(int n){//コンストラクタ,n個のノードを作成し、自分を親につける
    par.assign(n,0);
    rank.assign(n,0);
    for(int i = 0;i < n;++i) par[i]=i;
  }
  void init(int n){//初期化,n個のノードを作成し、自分を親につける
    par.assign(n,0);
    rank.assign(n,0);
    for(int i = 0;i < n;++i) par[i] = i;
  }
  int find(int a){//根を探す
    if(par[a]==a) return a; //親が自身を指す時、根である
    else return par[a] = find(par[a]);//根に直接つける
  }
  void unite(int a,int b){//小さい方の木の根に大きい方の根を上書きする
    int roota,rootb;
    roota = find(a),rootb = find(b);
    if(roota==rootb) return;
    if(rank[roota]>rank[rootb]){ //rankの高い方の根に低い方の根をつける
      par[rootb] = roota;
    }else if(rank[roota]<rank[rootb]){
      par[roota] = rootb;
    }else{ //rankが同じ時、適当な方につけ、つけられた方のrankを1増やす
      rank[roota]++;
      par[rootb] = roota;
    }
  }
};
union_find uf(160000);
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
bool used[400][400];
bool in_range(int y,int x){
  return 0<=y&&y<h&&0<=x&&x<w;
}
int ending;
int u,t;
int dfs(int y,int x,char c,vector<string>& s){
  if(ending) return ending;
  if(dp[y][x]){
    return ending = dp[y][x];
  }
  used[y][x]=true;
  int res = 0;
  REP(i,4){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(in_range(ny,nx)&&s[ny][nx]!=c&&!used[ny][nx]) res += dfs(ny,nx,s[ny][nx],s);
  }
  if(ending) return ending;
  if(c=='.') return res+1;
  else {
    uf.unite(touf(y,x),touf(u,t));
    return res;
  }
}
signed main(){
  int ans = 0;
  cioacc();
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h) cin >> s[i];
  REP(i,h) REP(j,w){
    if(i!=h-1&&s[i][j]!=s[i+1][j]) uf.unite(touf(i,j),touf(i+1,j));
    if(j!=w-1&&s[i][j]!=s[i][j+1]) uf.unite(touf(i,j),touf(i,j+1));
  }
  vector<pii> vec(160000,make_pair(0,0));
  REP(i,h)REP(j,w){
    if(s[i][j]=='#') vec[uf.find(touf(i,j))].first++;
    else vec[uf.find(touf(i,j))].second++;
  }
  REP(i,h*w){
    if(vec[i].first&&vec[i].second){
      ans+=vec[i].first*vec[i].second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6144