akhauriyash/Code-Regression huggingface dataset:
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var NK = o.getArray(0);
    var N = NK[0];
    var K = NK[1];

    var An = o.getArray(1);

    var i = K;
    var result = [];
    while(N > i) {
        result.push(An[i] > An[i - K] ? 'Yes' : 'No');
        i++;
    }

    return result.join('\n');
}

Measured memory_bytes: 59188
using System;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;

namespace ABC104C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] dg = ConsoleInput.IntArray();
            int D = dg[0];
            int G = dg[1];
            int[][] pc = new int[D][];
            for (int i = 0; i < D; i++)
            {
                pc[i] = ConsoleInput.IntArray();
            }

            int ap = Convert.ToInt32(Math.Pow(2, D));
            int[] pat = new int[ap];
            int[] patc = new int[ap];
            for (int i = 0; i < ap; i++)
            {
                pat[i] = 0;
                for (int j = 0; j < D; j++)
                {
                    if ((1 & i >> j) == 0)
                    {
                        continue;
                    }

                    pat[i] += pc[j][0] * (j + 1) * 100 + pc[j][1];
                    patc[i] += pc[j][0];
                }
            }

            int min = patc.Max();
            for (int i = 0; i < ap; i++)
            {
                for (int j = D - 1; j >= 0; j--)
                {
                    if ((1 & i >> j) == 0)
                    {
                        int max = pc[j][0] * (j + 1) * 100 + pat[i];

                        if (G < pat[i])
                        {
                            min = Math.Min(patc[i], min);
                            break;
                        }

                        if (max < G)
                        {
                            break;
                        }

                        int value = patc[i] + (G - pat[i]) / (j + 1) / 100 +
                                    ((G - pat[i]) % ((j + 1) * 100) > 0 ? 1 : 0);
                        min = Math.Min(value, min);
                        break;
                    }
                }
            }

            Console.WriteLine(min);
        }
    }

    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13524
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var c0 = sL - s.Replace("0", "").Length;
        var c1 = sL - c0;
        Console.WriteLine(Min(c0,c1) * 2);
    }
}

Measured memory_bytes: 13664
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
     int a,b,c,count=0;

            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            for (int i = a; i <= b; i++) {
                if (c % i == 0)
                    count++;
            }
            System.out.println(count);



    }
}



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

int main() {
  string s, ans;
  cin >> s;
  for(int bit = 0; bit < (1 << 3); bit++){
    int st = s.at(0) - '0';
    ans = s.at(0);
    for(int i = 0; i < 3; i++){
      if(bit & (1 << i)){
        st += s.at(i + 1) - '0';
        ans = ans + '+' + s.at(i + 1);
      }
      else {
        st -= s.at(i + 1) - '0';
        ans = ans + '-' + s.at(i + 1);
      }
    }
      
      if(st == 7){
        ans = ans + "=7";
        break;
    }
  }
  
  cout << ans << endl;
}

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

#define FOR(i,a,b)      for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b)     for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)        FOR(i,0,n)
#define RREP(i,n)       RFOR(i,n,0)
#define ALL(v)          (v).begin(),(v).end()
#define BIT(n)          (1LL<<(n))
#define IN(x,l,r)       ((l)<=(x)&&(x)<=(r))
#define INCLUDE(s,v)    (s.find(v)!=string::npos)
#define LEN(s)          (string(s)).length()
#define SHOW(x)         cout<<#x<<" = "<<x<<endl
#define SORT(v)         sort(ALL(v))
#define SZ(v)           (ll)(v).size()
#define UNIQ(v)         SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)         for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)           priority_queue<T,vector<T>,greater<T>>
#define REPLACE(s,f,t)  for(auto p=s.find(f);p!=string::npos;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);

template<class T>string join(const vector<T>& v,string d=" ") {stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}
template<class T>ostream& operator<<(ostream& o,const vector<T>& v) {o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}
template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p) {o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll a, b; cin >> a >> b;
    
    vector<ll> h(1000, 0);
    REP(i, 1000) h[i+1] = h[i] + (i + 1);
    
    cout << h[b - a] - b << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

from collections import defaultdict
lis1=defaultdict(int)
lis2=defaultdict(int)
for i in range(1,n+1):
    lis1[-a[i-1]-i] += 1
    lis2[i-a[i-1]] += 1

ans=0
for i in range(1,n+1):
    ans+=lis1[a[i-1]-i]
    ans+=lis2[a[i-1]+i]

print(ans//2)

Measured memory_bytes: 171696
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
   
    public static void main(String args[])throws IOException
    {
     Scanner in=new Scanner(System.in);
     int a=in.nextInt();
     int b=in.nextInt();
     int c=in.nextInt();
     System.out.println(c+" "+a+" "+b);
     
    }
}


Measured memory_bytes: 20820
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (b < 10 && b != 100) {
		for (int i = 1; i <= 400; i++) {
			if ((a * 10 + b) == i*i) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	else {
		if (b != 100) {
			for (int i = 0; i <= 400; i++) {
				if ((a * 100 + b) == i*i) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
		else {
			for (int i = 0; i <= 400; i++) {
				if (1000 * a + b == i*i) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  string S;
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2]){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long a, b, c, k;
    scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &k);
    if(k%2)
        printf("%I64d", b-a);
    else
        printf("%I64d", a-b);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
    int a,b,c,h,count=0 ;
    scanf("%d %d %d", &a,&b,&c);
    for(h = a;h <= b; h++){
        if(c % h == 0) count++;
    }
    printf("%d\n",count);
    return 0;
}



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

int main() {

  int N, K, X,Y;
  cin >> N >> K >> X >> Y;
  if(N <= K){
    cout << N*X << endl;
  }
  if(N > K){
  cout <<  K*X + (N-K)*Y << endl;
  }
  
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def generate_adj_table(_edges):
    for edge in _edges:
        vx, vy = map(int, edge)
        init_adj_table[vx].append(vy)

    return init_adj_table


def graph_dfs(current, matching, visited):
    for adj in range(y_num):
        if adj in adj_table[current] and not visited[adj]:
            visited[adj] = True
            if matching[adj] == -1 or graph_dfs(matching[adj], matching, visited):
                matching[adj] = current
                return True
    return False


def mbm():
    matching = [-1] * v_num
    res = 0
    for v in range(x_num):
        visited = [False] * y_num
        if graph_dfs(v, matching, visited):
            res += 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    v_num = x_num + y_num
    init_adj_table = [[] for _ in range(x_num)]
    adj_table = generate_adj_table(edges)
    print(mbm())

Measured memory_bytes: 8464
pattern='#.'
add=''
while 1:
    H,W=map(int,input().split())
    if H==W==0:break

    for i in range(H):
        if i%2==0:
            if W%2==1:add=pattern[0]
            print(pattern*(W//2)+add)
        if i%2==1:
            if W%2==1:add=pattern[-1]
            print(pattern[::-1]*(W//2)+add)
    add=''
    print()



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll solve(ll x){
    ll lo = 0;
    ll hi = 1e9;
    ll ans = 0;
    while(lo <= hi){
        ll mid = hi - (hi-lo)/2;
        if (mid*(mid+1)/2 <= x){
            ans = mid;
            lo = mid+1;
        }
        else hi = mid-1;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    unordered_map<ll, ll> factorized;
    for (ll i = 2; i*i <= n; i++){
        while(n%i == 0){
            n/=i;
            factorized[i]++;
        }
    }
    if (n > 1) factorized[n]++;

    ll ans = 0;
    for (auto it = factorized.begin(); it != factorized.end(); it++){
        ans += solve(it->second);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3660
def caliculate(num_str):
    s=0
    for digit_str in num_str:
        s+=int(digit_str)

    return s

def run():
    num_str_list=[]
    
    while True:
        num_str=input()
        
        if num_str == "0":
            break
        
        num_str_list.append(num_str)
    
    for num_str in num_str_list:
        result=caliculate(num_str)
        print(result)

run()


Measured memory_bytes: 5616
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int u, v, w;
vector<pair<int, int>> g[101010];
int d[101010];
int ans[101010];

int main(){
    cin >> n;
    REP(i, n - 1){
        cin >> u >> v >> w;
        u--, v--;
        g[u].emplace_back(make_pair(v, w));
        g[v].emplace_back(make_pair(u, w));
    }
    queue<pair<int, int>> q;
    q.push(make_pair(0, -1));

    while(q.size()){
        auto p = q.front();
        q.pop();
        REP(i, (int)g[p.first].size()){
            if(g[p.first][i].first == p.second)continue;
            d[g[p.first][i].first] = d[p.first] + g[p.first][i].second;
            if(d[g[p.first][i].first] % 2)ans[g[p.first][i].first] = 1;
            q.push(make_pair(g[p.first][i].first, p.first));
        }
    }
    REP(i, n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7296
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		Integer[] c = new Integer[a];
		
		for(int i=0 ; i<c.length ; i++) {
			c[i] = sc.nextInt();
		}
		
		Arrays.sort(c, Collections.reverseOrder());
		
		int d = 0;
		
		for(int i=0 ; i<b ; i++) {
			d += c[i];
		}
		System.out.println(d);
	}
}

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

int sumof(int N) {
  int sum = 0;
  while(N > 0){
    sum += N % 10;
    N /= 10;
  }
  return sum;
}

int main() {
  int N;
  int minsum = 9*10;
  scanf("%d", &N);
  for (int i = 1; i<=N/2; i++) {
    int sum = sumof(i) + sumof(N - i);
    minsum = min(minsum, sum);
  }
  printf("%d\n",minsum);
} 
  

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

int main(){
    int a,b;
    cin >>a>>b;
    int s;
    int d;
    int f;
    s=a+b;
    d=a-b;
    f=a*b;
    if((s<=f)&&(d<=f)){
        cout << f << endl;
    }
    else if((d<=s)&&(f<=s)){
        cout << s << endl;
    }
    else if((s<=d)&&(f<=d)){
        cout << d << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<vector<bool>> card(4, vector<bool>(13, true));

int main() {
  cin >>N;
  rep(i, N){
    char c; int x; cin >>c >>x; x--;
    int k = c == 'S' ? 0 : c == 'H' ? 1 : c == 'C' ? 2 : 3;
    card[k][x] = false;
  }
  rep(k, 4){
    rep(x, 13){
      if (card[k][x]){
        char c = k == 0 ? 'S' : k == 1 ? 'H' : k == 2 ? 'C' : 'D';
        cout <<c <<" " <<x+1 <<endl;
      }
    }
  }
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  int xmin = max(0, s - 2 * k);
  int xmax = min(k, s);
  for (int i = xmin; i <= xmax; i++) {
    int ymin = max(0, s - i - k);
    int ymax = min(k, s - i);
    for (int j = ymin; j <= ymax; j++) {
      int rest = s - i - j;
      if (rest >= 0 && rest <= k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> xx[100001];
    vector<pair<int,int>> yy[100001];
    int x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        xx[x[i]].push_back({y[i],i});
        yy[y[i]].push_back({x[i],i});
    }
    bool v[n];
    fill(v,v+n,false);
    ll ans=0;
    for(int i=0;i<n;i++){
        if(v[i]==false){
            ll cnt=0;
            queue<pair<int,int>> q;
            set<int> sx;
            set<int> sy;
            q.push({x[i],y[i]});
            v[i]=true;
            while(q.size()){
                auto p=q.front();
                q.pop();
                sx.insert(p.first);
                sy.insert(p.second);
                cnt++;
                for(auto n:xx[p.first]){
                    if(!v[n.second]){
                        q.push({p.first,n.first});
                        v[n.second]=true;
                    }
                }
                for(auto n:yy[p.second]){
                    if(!v[n.second]){
                        q.push({n.first,p.second});
                        v[n.second]=true;
                    }
                }
            }
            
            ans+=(ll)sx.size()*(ll)sy.size()-cnt;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 14208
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		long ans = 1;
		for(int i = n; i > 0; i--) {
			ans *= i;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 17156
#include <stdio.h>

int main(int argc, char *argv[]) {
    int n, k;
    int l[50];

    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &l[i]);
    }

    for (int j = 0; j <= n - 2; j++) {
        for (int i = 0; i < n - 1 - j; i++) {
            int tmp;
            if (l[i] < l[i + 1]) {
                tmp = l[i];
                l[i] = l[i + 1];
                l[i + 1] = tmp;
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += l[i];
    }

    printf("%d\n", sum);

    return 0;
}


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

const int mo=1e9+7;
const int maxn=23333;

int n,k,m,d[maxn],dp[maxn],Ans;

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&k);
	for (i=1;i*i<=n;i++)
		if (n%i==0)
		{
			d[++m]=i;
			if (i*i!=n) d[++m]=n/i;
		}
	sort(d+1,d+1+m);
	for (i=1;i<=m;i++)
	{
		dp[i]=power(k,(d[i]+1)/2);
		for (j=1;j<i;j++)
			if (d[i]%d[j]==0)
				(dp[i]+=mo-dp[j])%=mo;
		if (d[i]&1)
			(Ans+=(LL)dp[i]*d[i]%mo)%=mo;
		else
			(Ans+=(LL)dp[i]*(d[i]/2)%mo)%=mo;
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 256
#include <cstdio>
    #include <iostream>
    using namespace std;
     
    int main() {
    double a,b,c,d,e,f,x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
    if(a==0){
    y=(c+0.0000001)/b;
    x=(f-e*y+0.0000000001)/d;
    }
    else{
    y=(a*f-d*c+0.00000000000001)/(a*e-d*b);
    x=(c-b*y+0.0000000001)/a;
    }
    printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
    }

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

const int N = 1e5+7;
bool pos[N];
int cnt[N];


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

    int n, m;
    cin>>n>>m;

    fill(cnt+1, cnt+n+1, 1);
    pos[1] = true;

    for (int i=1; i<=m; i++) {
        int x, y;
        cin>>x>>y;

        if (pos[x]) pos[y] = 1;
        cnt[x]--; cnt[y]++;
        if (cnt[x] == 0)    pos[x] = false;
    }

    int ans = 0;
    for (int i=1; i<=n; i++)    ans += pos[i];

    cout<<ans<<endl;
}


Measured memory_bytes: 4092
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.ByteString.Char8 as BS8

cntfw :: T.Text -> Int
cntfw s
    | T.length s <= 1 = 1
    | hs /= ss      = 1
    | otherwise     = 1 + (cntfw $ T.tail s)
    where
        hs = T.head s
        ss = T.head $ T.tail s

sol :: T.Text -> Int
sol s
    | T.length s <= 0 = 0
    | otherwise = 1 + (sol ds)
    where
        cnt = cntfw s
        ds  = T.drop cnt s

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInt <$> BS8.getLine
    s <- T.getLine

    print $ sol s 


Measured memory_bytes: 2044
n = int(input())
monster = list(map(int, input().split()))
brave = list(map(int, input().split()))
res = 0
for i in range(n):
  temp = min(monster[i], brave[i])
  brave[i] -= temp
  res += temp
  temp = min(monster[i + 1], brave[i])
  monster[i + 1] -= temp
  res += temp
print(res)

Measured memory_bytes: 24196
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll x=sqrt(n);
	while(1)
	{
		if(n%x==0)
		break;
		x--;
	}
	ll y=n/x;
	ll ans=x+y-2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys

num = raw_input().strip().split()
N = int(num[0])
Y = int(num[1])
for x in range(N + 1):
    for y in range(N + 1 - x):
        if 0 <= N - x - y  and 10000*x + 5000*y + 1000*(N - x - y) == Y:
            print(str(x)+ " "+ str(y) + " " + str(N-x-y))
            sys.exit()

print("-1 -1 -1")

Measured memory_bytes: 2692
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
        int N;
        cin >> N;
        vector<pair<int,int> > vp;
        for (int i = 1; i <= N; ++i) {
                int A;
                cin >> A;
                vp.push_back(make_pair(A, i));
        }
        sort(vp.begin(), vp.end());
        for (auto p : vp) {
                cout << p.second << " ";
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 1780
#include <unistd.h>
#include <stdio.h>
 
int	main(void)
{
  char	str[27] = {0};
  int	i = 0;
  int	j = 0;
  
  read(0, str, 26);
  while (str[i])
  {
    j = i + 1;
    while (str[j])
    {
      if (str[i] == str[j])
      {
        printf("no");
        return (0);
      }
      j++;
    }
    i++;
  }
  printf("yes");
  return (0);
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

typedef pair<int,int> p; 

int n;
vector<p> e[100005];
int g[100005];
int c[100005];

void dfs(int f,int w){
	if(c[f]==1) return;
	c[f]=1;
	for(int i=0; i<e[f].size(); i++){
		int to=e[f][i].first;
		int ct=e[f][i].second;
		if(ct%2==0){
			g[to]=w%2;
			dfs(to,g[to]);
		}else{
			g[to]=(w+1)%2;
			dfs(to,g[to]);
		}
	}
	return;
}

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>n;

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

dfs(1,1); g[1]=1;
for(int i=1; i<=n; i++){
	cout<<g[i]<<endl;
}

}



Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++)
	{
		if (i%2==0)
		{
			A /= 2;
			B += A;
		}
		else
		{
			B /= 2;
			A += B;
		}
	}
	cout << A << " " << B << endl;
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

string fld[12];

bool vis[12][12];
void dfs(int y,int x){
    vis[y][x]=true;
    rep(i,4){
        int ny=y+dy[i],nx=x+dx[i];
        if(ny<0||ny>=12||nx<0||nx>=12||fld[ny][nx]!='1'||vis[ny][nx])continue;
        dfs(ny,nx);
    }
}
signed main(){
    while(cin>>fld[0]){
        for(int i=1;i<12;i++)cin>>fld[i];
        memset(vis,0,sizeof(vis));

        int ans=0;
        rep(i,12)rep(j,12){
            if(fld[i][j]!='1'||vis[i][j])continue;
            dfs(i,j);
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <iostream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
//#define min(A,B) ((A>B)?B:A)
//#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N];
  scanf("%d", &n);

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

  trace(A, n);
  int key;
  for (int i = 1; i < n; ++i) {
	  key = A[i];
//	  println(key);
	  j = i-1;
	  while(j>=0 && A[j] > key){
//		  print("A[j+1] : ");
//		  println(A[j+1]);
//		  print("A[j] : ");
//		  println(A[j]);
		  A[j+1]=A[j];
		  j--;
	  }
	  A[j+1] = key;
	  trace(A,n);
  }

  return 0;
}



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

int main() {
    long long x;
    while (cin >> x, x) {
        long long n_max = (-1 + sqrt(1 + 8 * x)) / 2;
        for (int n = n_max; n > 0; n--) if (2 * x % n == 0) {
            long long a2 = 2 * x / n - n + 1;
            if (a2 > 0 && a2 % 2 == 0) {
                cout << a2 / 2 << " " << n << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3068
X, N = map(int, input().split())
p = list(map(int, input().split()))

P = []

for i in range(101):
    P.append(i)

for j in range(len(P)):
    if P[j] in p:
        P[j] = 101

l = []

for i in range(len(P)):
    y= abs(P[i] - X)
    l.append(y)

min = l[0]
ans = 0
sub = 101

for j in range(1, 101):
    if min > l[j]:
        min = l[j]
        ans = j
    elif min == l[j]:
        sub = j

if sub != 101:
    if P[ans] >P[sub]:
        print(P[sub])
    else:
        print(P[ans])
else:
    print(P[ans])

Measured memory_bytes: 9244
/*	
TELL YOUR CODE TO START BELIEVING IN GOD!!
THEY HATE US BECAUSE THEY AIN'T US
	ARIJIT SUR 
	@duke_knight
	@surcode
	IIT ISM 
 WORK SO HARD THAT YOUR IDOL BECOMES YOUR COMPETITOR 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define pb push_back
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i=0;i<a.size();i++) cin>>a[i];}
#define display(a) {for(int i=0;i<a.size();i++) cout<<a[i]<<""; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
string add(string s, int x){
    reverse(s);
    int carry = x,y;
    for(int i=0;i<s.size();i++){
        y = s[i] - '0' + carry;
        carry = y/10;
        y = y%10;
        s[i] = (char)(y+'0');
        if(!carry) break;
    }
    if(carry) s.pb((char)(carry+'0'));
    reverse(s);
    return s;
}
bool multiple(string s){
    ll n = 0;
    reverse(s);
    for(int i=0;i<s.size();i++){
        n = n*10+ (s[i]-'0');
    }
    return (n%9==0);
}
bool work(string s){
    string str = "";
    for(int i=0;i<s.size();i++) str = add(str,s[i]-'0');
    if(str.size()<=5) return multiple(str);
    return work(str);

}
void solve(){
	string n;
    cin>>n;
    if(!work(n)) printf("No\n");
    else printf("Yes\n");

}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3752
# coding: utf-8

n, m, x = map(int,input().split())

op_cnt = n  # 本の数

C = []
L = []
for i in range(n):
    l = list(map(int,input().split()))
    C.append(l[0])
    L.append(l[1:])

ans = float('inf')
Flg = False
for i in range(2 ** op_cnt):
    money = 0
    A = [0] * m
    op = [True] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = False  
    for j in range(n):#買う買わない
        if op[j]:
            money += C[j]
            for k in range(m):#買う場合の経験値上昇
                A[k] += L[j][k]
    flg = True
    #print(money,A)
    for a in A:
        if a < x:
            flg = False
    if flg:
        ans = min(ans,money)
        Flg = True

if Flg:
    print(ans)
else:
    print('-1')

Measured memory_bytes: 68892
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    ll n, m, i, j, k, l;
    cin>>n;
    set<string>s;
    string ss;
    for(i=0; i<n; i++)
    {
        cin>>ss;
        s.insert(ss);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19120
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int, input().split()))

cnt = dict()
for k in d:
    if k in cnt:
        cnt[k] += 1
    else:
        cnt[k] = 1

mod = 998244353

keys = cnt.keys()
pre = -1
rst = 1

if d[0] != 0:
    print(0)
    exit(0)


if cnt[0] != 1:
    print(0)
    exit(0)


for k in sorted(keys):
    if (pre + 1) != k:
        rst = 0
        break
    pre = k

    if k == 0:
        continue

    rst = (rst * (cnt[k-1] ** cnt[k])) % mod
    
print(rst)


Measured memory_bytes: 19552
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int r, b;
  r = b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') r++;
    else b++;
  }
  cout << (r > b ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3620
line1 = [int(x) for x in input().strip().split()]
a = line1[0]
b = line1[1]

s = input().strip()

if s.count('-') != 1:
	print('No')
	exit(0)

components = s.split('-')
part1 = components[0]
part2 = components[1]

if len(part1) != a or len(part2) != b:
	print('No')
	exit(0)

for c in part1:
	if c < '0' or c > '9':
		print('No')
		exit(0)

for d in part2:
	if d < '0' or d > '9':
		print('No')
		exit(0)

print('Yes')

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

#define ll long long

using namespace std;

map<ll, bool>mp;

int main()
{
    bool f = false;
    int n;
    cin >> n;
    ll arr[n];
    cin >> arr[0];
    mp[ arr[0] ] = true;
    for(int i = 1; i < n; i++)
    {
        cin >> arr[i];
        if( mp[ arr[i] ] )
            f = true;
        mp [ arr[i] ] = true;
    }
    if( f )
        cout << "NO" << endl;
    else cout << "YES" << endl;

   return 0;

}


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

int main() {
  int n, m, l, q;
  cin >> n >> m >> l;
  long long distance[n][n];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      distance[i][j] = numeric_limits<int>::max();
    }
    distance[i][i] = 0;
  }
  for (int i = 0, a, b, c; i < m; ++i) {
    cin >> a >> b >> c;
    distance[a - 1][b - 1] = c;
    distance[b - 1][a - 1] = c;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (distance[i][j] > distance[i][k] + distance[k][j]) {
          distance[i][j] = distance[i][k] + distance[k][j];
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (distance[i][j] <= l) {
        distance[i][j] = 1;
      } else {
        distance[i][j] = numeric_limits<int>::max();
      }
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (distance[i][j] > distance[i][k] + distance[k][j]) {
          distance[i][j] = distance[i][k] + distance[k][j];
        }
      }
    }
  }
  cin >> q;
  for (int s, t; cin >> s >> t; cout << '\n') {
    if (distance[s - 1][t - 1] != numeric_limits<int>::max()) {
      cout << distance[s - 1][t - 1] - 1;
    } else {
      cout << -1;
    }
  }
  return 0;
}

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

char school(int m, int e, int j)
{
if( m == 100 || e == 100 || j == 100 )
        return 'A';
    if( (m+e)>=180 || (m+e+j)>=240)
        return 'A';
    if( (m+e+j)>=210 || ( (m+e+j)>=150 && (m>=80||e>=80) ) )
		return 'B';
	else
    return 'C';
}
int main()
{
	int x, m, e, j;
	while(cin>>x)
	{
		for(int i=0; i<x; i++)
		{
			cin>>m>>e>>j;
			
		
		cout<<school(m,e,j)<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

int main(){
    int n;cin >> n;
    vector<int> x(n),a(n);
    for(auto &i:x) cin >> i;
    a = x;
    sort(a.begin(),a.end());
    rep(i,n){
        if(a[n/2]>x[i]) cout << a[n/2] << endl;
        else cout << a[n/2-1] << endl;
    }
}

Measured memory_bytes: 3712
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
for lis in s:
  tmp_list = lis ** 2 / c**0.01
  max_idx = np.argmax(tmp_list)
  print(max_idx + 1)


Measured memory_bytes: 27308
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b==c || b+c==a || a+c==b)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
(N, M) = gets.split.map(&:to_i)

bridge = []

M.times do
  bridge << gets.split.map(&:to_i)
end

class UnionFind
  attr_reader :count

  def initialize(n)
    @root = Array.new(n + 1)
    @root[0] = nil
    @root_count = Hash.new { |h, k| h[k] = 1 }
    @count = n * (n -1) / 2
  end

  def union(a, b)
    unite(find(a), find(b))
  end

  def find(a)
    @root[a] == nil ? a : @root[a] = find(@root[a])
  end

  def unite(a, b)
    return 0 if a == b
    a, b = b, a if b < a
    @count -= @root_count[a] * @root_count[b]
    @root[b] = a
    @root_count[a] += @root_count[b]
    @root_count.delete(b)
  end
end

uf = UnionFind.new(N)

ans = bridge.reverse_each.map do |a, b|
  c = uf.count
  uf.union(a, b)
  c
end

puts ans.reverse


Measured memory_bytes: 14588
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, raw_input().split(" "))
uf = UnionFind(n)

for i in range(0, m):
    x, y, z = map(int, raw_input().split(" "))
    uf.union(x - 1, y - 1)

counter = set()
for i in range(0, n):
    a = uf.find(i)
    # print("%d-%d" % (i, a))
    counter.add(uf.find(i))

print(len(counter))


Measured memory_bytes: 16616
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB"){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 

 	int h,w,n;
 	cin>>h>>w>>n;
 	int aa=n/h;
 	if(n%h) aa++;
 	int bb=n/w;
 	if(n%w) bb++;
 	cout<<min(aa,bb)<<endl;
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

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

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,grid[3000][3000];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

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

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    ll tate=0,yoko=0;
   rrep(i,2,100000){
        pos=i*(i-1);
        if(pos/2==n){
            tate=i;
            yoko=i-1;
            break;
        }
    }
    if(pos/2!=n)Cout("No");
    else{
        Cout("Yes");
        Cout(tate);
        rep(i,yoko)grid[0][i]=i+1;
        ll gen=yoko;
        rrep(i,1,tate){
            rep(j,yoko){
                if(j<i){
                        grid[i][j]=grid[j][i-1];
                }
                else{
                    gen++;
                    grid[i][j]=gen;
                   // gen++;
                }
            }
        }
        rep(i,tate){
            cout<<yoko<<" ";
            rep(j,yoko){
                if(j!=yoko-1){
                cout<<grid[i][j]<<" ";
                }
                else cout<<grid[i][j]<<"\n";
            }
            //cout<<"\n";
        }
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int count = 0;
  vector<int> D(N);
  for(int i = 0;i < N;i++){
    cin >> D.at(i);
  }
  sort(D.begin(),D.end());
  for(int k = 0;k < N - 1;k++){
    if(D.at(k + 1) - D.at(k) != 0){
      count++;
    }
  }
    cout << count + 1<< endl;
}
      
    

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

void solve(vector<long long> a, vector<long long> nums, vector<long long> list) {
    long long whole = 0;
    int i;

    for(i = 0;i < list.size();i++){
        whole += nums[list[i]] * (nums[list[i]]-1) / 2;
    }
    for(i = 0;i < a.size();i++){
        cout << whole - nums[a[i]] + 1 << "\n";
    }
}

int main(void){
    int N, i, x;
    vector<long long> a,nums, num_list;

    cin >> N;
    a.resize(N);
    nums.resize(N+1);
    for(i = 0;i < N;i++){
        cin >> x;
        a[i] = x;
        nums[x]++;
        if(nums[x] == 1){
            num_list.push_back(x);
        }
    }

    solve(a, nums, num_list);

    return 0;
}

Measured memory_bytes: 9972
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);


        var input = Reads();
        var a = input[0];
        var b = input[1];

        if (a > b)
        {
            Console.WriteLine(2 * a - 1);
        }
        else if(a==b)
        {
           Console.WriteLine(2*a);
        }
        else
        {
            Console.WriteLine(2 * b - 1);
        }





        Console.Out.Flush();
    }
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(){
  long int a[10000],i=1;
  while(1){
    cin>>a[i];
    if(a[i]==0){
      break;
    }
    cout<<"Case "<<i<<": "<<a[i]<<endl;
    i++;
  }
  return 0;
}

Measured memory_bytes: 3192
n = int(input())
hlis = list(map(int, input().split()))
dp = [0] + [float('inf')]*n
dp[1] = dp[0] + abs(hlis[0])
for i in range(1, n):
    one = abs(hlis[i]-hlis[i-1])
    two = abs(hlis[i]-hlis[i-2])
    dp[i] = min(dp[i-1]+one, dp[i-2]+two)
print(dp[n-1])

Measured memory_bytes: 13980
#include<stdio.h>
#include<string.h>
int main(){
  char s[100],m[100],p[][2]={"iI","wW","()",")(","{}","}{","[]","]["};
  int i,j,k,max=0,r,l;
  scanf("%s",s);
  l=strlen(s);
  for(i=0;i<(1<<l);i++){
    for(j=r=0;j<l;j++){
      if(i&(1<<j))m[r++]=s[j];
    }
    m[r]=0;
    if(r%2==0||r<2)goto END;//printf("%s\n",m);
    for(j=0;j<r/2-1;j++){
      for(k=0;m[j]-p[k][0];k++);
      if(m[r-1-j]-p[k][1])goto END;
    }
    if(m[j]=='i'&&m[j+1]=='w'&&m[j+2]=='i'&&max<r)max=r;
  END:;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAX_N = 101;
const int INF   = 9999999;
int n;
int w[MAX_N][MAX_N];
bool used[MAX_N];

int main()
{
    while(cin >> n && n) {
        memset(used, false, sizeof(used));
        for(int i = 0; i < MAX_N; i++)
            for(int j = 0; j < MAX_N; j++)
                w[i][j] = INF;

        int a,b,c;
        for(int i = 0; i < n; i++) {
            cin >> a >> b >> c;
            used[a] = used[b] = true;
            w[a][b] = w[b][a] = c;
        }

        for(int i = 0; i < MAX_N; i++)
            w[i][i] = 0;
        
        for(int k = 0; k < MAX_N; k++) {
            for(int i = 0; i < MAX_N; i++) {
                for(int j = 0; j < MAX_N; j++) {
                    if(used[i] && used[j] && used[k]) 
                        w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
                }
            }
        }

        
        int idx, min = INF;
        
        for(int i = 0; i < MAX_N; i++) {
            if(!used[i]) continue;
            
            int tmp = 0;
            for(int j = 0; j < MAX_N; j++) 
                if(used[i] && used[j])
                    tmp += w[i][j];
            
            if(tmp < min) {
                min = tmp;
                idx = i;
            }
        }

        cout << idx << " " << min << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;


int main() {
	int N, P; cin >> N >> P;
	string S; cin >> S;
	
	if (P == 2 || P == 5) {
		ll ans = 0;
		rep(i, N) {
			int x = S[i] - '0';
			if (x % P == 0) ans += i+1;
		}
		cout << ans << endl;
		return 0;
	}

	V a(N+1);
	ll b = 1;
	rep(i, N) {
		ll x = (S[N-i-1] - '0');
		a[i+1] = (a[i] + b * x) % P;
		b = (b * 10) % P;
	}

	map<ll, ll> cnt;
	ll ans = 0;
	rep(i, N+1) {
		ans += cnt[a[i]];
		cnt[a[i]]++;
	}
	cout << ans << endl;
	return 0;
}


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






ll mod=1e9 +7;

int main(){

  int s;
  cin>>s;
vector<vector<ll> > dp(2001,vector<ll> (2001,0));
for(int i=3;i<=s;i++)
    dp[1][i]=1;
ll ans=dp[1][s];
for(int i=2;i<=s;i++){
    for(int j=2;j<=s;j++){
        dp[i-1][j]+=dp[i-1][j-1];
        dp[i][j]=dp[i][j]%mod;
    }
    for(int j=3;j<=s;j++){
        dp[i][j]=dp[i-1][j-3];
        dp[i][j]=dp[i][j]%mod;
    }
    ans+=dp[i][s];
    ans=ans%mod;
}
cout<<ans<<endl;

}


Measured memory_bytes: 34660