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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double d, t, s;
    cin >> d >> t >> s;
    if(d/s <= t) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double dp[n+1][n+1];
    memset(dp,0, sizeof(dp));
    vector<double> data;
    double input;
    for(int i=0;i<n;i++)
    {
        cin>>input;
        data.push_back(input);
    }
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-data[i-1]);
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=i;k++)
        {
            dp[i][k]=dp[i-1][k-1]*data[i-1]+dp[i-1][k]*(1-data[i-1]);
        }
    }
    /*
    for(int i=0;i<=n;i++,cout<<endl)
    for(int k=0;k<=n;k++)
    cout<<dp[i][k]<<' ';
     */
    double answer=0;
    for(int i=n;i>=ceil(float(n)/float(2));i--)
    answer+=dp[n][i];
    cout<<setprecision(10)<<answer;
}

Measured memory_bytes: 74140
#include <iostream>

#define N 55555

using namespace std;

int main(){
    bool isprime[55556];
    int n;
    cin >> n;
    for(int i = 1; i <= N; i++){
        isprime[i] = true;
    }
    isprime[1] = false;
    for(int i = 2; i*i < N; i++){
        if(isprime[i]){
            for(int j = 2; j*i <= N; j++){
                isprime[j*i] = false;
            }
        }
    }
    int cnt = 0;
    for(int i = 1; i <= N; i++){
        if(isprime[i] && i%5 == 1){
            cnt++;
            cout << i << ' ';
        }
        if(cnt >= n)break;
    }
    cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var uf = new UnionFind(N);
        for (int i = 0; i < M; i++)
        {
            var XYZ = ReadLine().Split().Select(int.Parse).ToArray();
            uf.Unite(XYZ[0] - 1, XYZ[1] - 1);
        }
        WriteLine(uf.Count);

    }
}

public class UnionFind
{
    int[] parent;
    int count;
    public int Count => count;

    public UnionFind(int size)
    {
        parent = new int[size];
        for (int i = 0; i < parent.Length; i++)
        {
            parent[i] = -1;
        }
        count = size;
    }

    int Root(int x) => parent[x] < 0 ? x : parent[x] = Root(parent[x]);

    public bool Same(int x, int y) => Root(x) == Root(y);

    public void Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x == y) return;
        count--;
        if (parent[x] < parent[y])
        {
            parent[x] += parent[y];
            parent[y] = x;
        }
        else
        {
            parent[y] += parent[x];
            parent[x] = y;
        }
    }

    public int Size(int x) => -parent[Root(x)];
}

Measured memory_bytes: 17460
#include<stdio.h>
int calculation(int n,int m);
int main(){
int n,m;
scanf("%d %d",&n,&m);
if((n>=2 && n<=100) && (m>=2&&m<=100)){
    calculation(n,m);
    printf("%d",calculation(n,m));
}
return 0;
}
int calculation(int n,int m)
{
    return((n-1)*(m-1));
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

string s;
ll abc[100010], ab[100010], a[100010], q[100010];
int main() {
    cin >> s;

    q[0] = 1;
    if (s[0] == 'A') a[0]++;
    if (s[0] == '?') {
        a[0]++;
        q[0] *= 3;
    }
    for (int i=1;i<s.size();i++) {
        q[i] += q[i-1];
        abc[i] += abc[i-1];
        ab[i] += ab[i-1];
        a[i] += a[i-1];
        if (s[i] == 'C') {
            abc[i] += ab[i-1];
        }
        if (s[i] == 'B') {
            ab[i] += a[i-1];
        }
        if (s[i] == 'A') {
            a[i] += q[i-1];           
        }
        if (s[i] == '?') {
            abc[i] *= 3;
            ab[i] *= 3;
            a[i] *= 3;
            q[i] *= 3;
            abc[i] += ab[i-1];
            ab[i] += a[i-1];
            a[i] += q[i-1];
        }
        /*
        if (s[i] == '?') {
            // order
            abc[i] = abc[i-1] + ab[i-1];
            ab[i] = ab[i-1] + a[i-1];
            a[i] = a[i-1] + 1;
        }
        */

        q[i] %= mod;
        a[i] %= mod;
        ab[i] %= mod;
        abc[i] %= mod;
        // cout << a[i] << " " << ab[i] << " " << abc[i] << endl;
    }
    cout << abc[s.size()-1] << endl;
}

Measured memory_bytes: 3584
/*Jai Bhole Nath */
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#define int long long int
#define f(i,a,n)    for(int i = a; i < (n); ++i)
#define fe(i, a, n)  for(int i = a; i <= (n); ++i)
#define fr(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define input(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
        int ans1 = a * d;
        int ans2 = b * c;
    	int ans3 = a * c;
        int ans4 = b * d;
        cout << max(max(ans1, ans2),max(ans3,ans4)) << endl;
    }

signed main()
{
    FIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll a; cin >> a;
    string s; cin >> s;
    if (a >= 3200){cout << s << endl;}else{cout << "red" << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  map<char, int> mp;
  for (char c : s) {
    if (mp[c]) {
      cout << "no" << endl;
      return 0;
    }
    mp[c]++;
  }
  cout << "yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){
  string n;

  cin >> n;

  int hashad_num = 0;
  for(int i=0; i<n.size(); i++){
    char temp = n.at(i);
    hashad_num += atoi(&temp);
  }

  int temp = stoi(n);
  if( temp%hashad_num == 0 ){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,k;cin>>n>>k;
    V<ll>a(n);
    bool abc=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==k)abc=1;
    }
    if(abc==1){
        cout<<"POSSIBLE"<<endl;
        return 0;
    }
    sort(all(a));
    if(a[n-1]<k){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    ll minc=INF;
    for(ll i=1;i<n;i++){
        if(a[i]==a[i-1])continue;
        chmin(minc,a[i]-a[i-1]);
    }
    if(minc==1){
        cout<<"POSSIBLE"<<endl;
        return 0;
    }
    else{
        for(ll i=0;i<n;i++){
            if(a[i]>k){
                if((a[i]-k)%minc==0){
                    cout<<"POSSIBLE"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 1024
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(defun f(n m)
  (format t "~A~%" (if (= n m) "Yes" "No")))

(let ((line (mapcar #'parse-integer (splitat #\space (read-line nil nil)))))
  (f (car line) (cadr line)))


Measured memory_bytes: 12256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li h, w, d;
    cin >> h >> w >> d;
    if (d % 2 == 1) {
        for (int r = 0; r < h; ++r) {
            for (int c = 0; c < w; ++c) {
                if ((r + c) % 2 == 1) {
                    cout << 'R';
                } else {
                    cout << 'B';
                }
            }
            cout << endl;
        }
    } else {
        string cs = "RGBY";
        const li dd = d / 2;
        for (int r = 0; r < h; ++r) {
            for (int c = 0; c < w; ++c) {
                const li rr = r - ((r + c) % 2 + 2) % 2;
                const li cc = c;
                const li p = (rr + cc + 2000) / 2;
                const li q = (rr - cc + 2000) / 2;

//                cout << r << " " << c << " " << p << " " << q << endl;
                const li ind = (p / dd) % 2 + ((q / dd) % 2) * 2;
                cout << cs[ind];

            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3572
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N, X := nextInt(), nextInt()
	bounds := []int{0}

	for i := 0; i < N; i++ {
		s := bounds[len(bounds) - 1] + nextInt()
		bounds = append(bounds, s)
	}

	c := 0
	for i:= 0; i <= N; i++ {
		if bounds[i] <= X {
			c++
		} else {
			break
		}
	}

	fmt.Println(c)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

    int AC=0,WA=0,TLE=0,RE=0;
    string s;

    while(N--)
    {
        cin>>s;

        if(s.compare("AC")==0)
            AC++;

        if(s.compare("WA")==0)
            WA++;

        if(s.compare("TLE")==0)
            TLE++;

        if(s.compare( "RE")==0)
            RE++;


    }

    cout<<"AC x "<<AC<<"\n";
    cout<<"WA x "<<WA<<"\n";
    cout<<"TLE x "<<TLE<<"\n";
    cout<<"RE x "<<RE<<"\n";
}


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

using namespace std;

template<typename T>
void Print(const T* pArray, int size)
{
	for (int i = 0; i < size; ++i)
		cout << pArray[i] << (i != size - 1 ? " " : "\n");
}

template<typename T>
void Merge(T* pArray, int left, int middle, int right, T* pLeftArray, T* pRightArray, const T& max, int& count)
{
	int ll = middle - left;
	int rl = right - middle;
	for (int i = 0; i < ll; ++i) pLeftArray[i] = pArray[left + i];
	for (int i = 0; i < rl; ++i) pRightArray[i] = pArray[middle + i];
	pLeftArray[ll] = max;
	pRightArray[rl] = max;

	int i = 0, j = 0;
	for (int k = left; k < right; ++k)
	{
		++count;
		if (pLeftArray[i] < pRightArray[j])
		{
			pArray[k] = pLeftArray[i];
			++i;
		}
		else
		{
			pArray[k] = pRightArray[j];
			++j;
		}
	}
}

/**
 * first range
 * left = 0, right = size : range from 0 to (size - 1)
 */
template<typename T>
void MergeSort(T* pArray, int left, int right, T* pLeftArray, T* pRightArray, const T& max, int& count)
{
	if (left + 1 < right)// have two number at least: left, left + 1
	{
		int middle = (left + right) >> 1;
		MergeSort(pArray, left, middle, pLeftArray, pRightArray, max, count);
		MergeSort(pArray, middle, right, pLeftArray, pRightArray, max, count);
		Merge(pArray, left, middle, right, pLeftArray, pRightArray, max, count);
	}
}

#define MAX 500000
int main()
{
	int n;
	cin >> n;
	int* A = new int[MAX];
	for (int i = 0; i < n; ++i) cin >> A[i];
	int* leftArray = new int[MAX + 1];
	int* rightArray = new int[MAX + 1];
	int count = 0;
	MergeSort(A, 0, n, leftArray, rightArray, 2000000000, count);
	Print(A, n);
	cout << count << endl;
	delete[] A;
	delete[] leftArray;
	delete[] rightArray;

	return 0;
}


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

int main() {

    int n;
    while(cin >> n && n) {
        int nextpage;
        int nowpage;
        cin >> nowpage;
        if (n == 1) {
            cout << nowpage << endl;
            continue;
        }
        bool first = true;

        for(int i = 1; i < n; i++) {
            if (first) {
                cout << nowpage;
            }
            cin >> nextpage;        
            if (nextpage != nowpage + 1) {
                if (!first) {
                    cout << "-" << nowpage;
                }
                first = true;
                cout << " ";
            } else {
                first = false;
            }
            nowpage = nextpage;
            if (i == n - 1) {
                if(!first)  cout << "-";
                cout << nowpage << endl;
            }
        }

    }
     
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <random>
#include <complex>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << '\n';
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

b = len(s)
a = len(t)

min_cnt = 100000000

for i in range(b - a + 1):
    cnt = 0
    for j in range(a):
        if s[j+i] != t[j]:
            cnt += 1
    
    if min_cnt > cnt:
        min_cnt = cnt

print(min_cnt)


Measured memory_bytes: 9044
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  queue<pair<string, int> > queue;
  rep(i,n){
    string name; int time;
    cin >> name >> time;
    queue.push(mp(name,time));
  }
  int now = 0;
  while(true){
    if(queue.empty()) break;
    if(queue.front().second <= q){
      now += queue.front().second;
      cout << queue.front().first << " " << now << endl;
      queue.pop();
    }else{
      queue.push(mp(queue.front().first, queue.front().second-q));
      now += q;
      queue.pop();
    }
  }
	return 0;
}

Measured memory_bytes: 6280
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    combination c(n);
    for(int i=0;i<=k;i++){
        mint cnow = c(n-1,i);
        mint pnow = modpow(m-1,n-1-i);
        mint now = m;
        now *= cnow;
        now *= pnow;
        ans += now;
    }
    cout << ans << endl;
    return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans;
  int X;
  cin >> X;

  ans = 1;

  while (1) {
    if (ans * (ans + 1) / 2 >= X) {
      break;
    }

    ans++;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n, a = 0, b = 0, c = 0, d = 0;
	long long int maxx;
	long long int w, A[110][5], B[110][5], C[110][5], D[110][5];
	long long int swa[110], swb[110], swc[110], swd[110];
	long long int sva[110], svb[110], svc[110], svd[110];
	scanf("%d %lld", &n, &w);
	for(int i = 0; i < n; i++)
	{
		scanf("%lld %lld", &A[i][0], &A[i][1]);
		if(A[i][0] == A[0][0])
		{
			A[a][0] = A[i][0];
			A[a][1] = A[i][1];
			a++;
		}
		if(A[i][0] == A[0][0] + 1)
		{
			B[b][0] = A[i][0];
			B[b][1] = A[i][1];
			b++;
		}
		if(A[i][0] == A[0][0] + 2)
		{
			C[c][0] = A[i][0];
			C[c][1] = A[i][1];
			c++;
		}
		if(A[i][0] == A[0][0] + 3)
		{
			D[d][0] = A[i][0];
			D[d][1] = A[i][1];
			d++;
		}
	}
	for(int i = 0; i < a - 1; i++)
	{
		maxx = A[i][1];
		for(int j = i + 1; j < a; j++)
		{
			if(A[j][1] > maxx)
			{
				maxx = A[j][1];
				A[j][1] = A[i][1];
				A[i][1] = maxx;
			}
		}
	}
	for(int i = 0; i < b - 1; i++)
	{
		maxx = B[i][1];
		for(int j = i + 1; j < b; j++)
		{
			if(B[j][1] > maxx)
			{
				maxx = B[j][1];
				B[j][1] = B[i][1];
				B[i][1] = maxx;
			}
		}
	}
	for(int i = 0; i < c - 1; i++)
	{
		maxx = C[i][1];
		for(int j = i + 1; j < c; j++)
		{
			if(C[j][1] > maxx)
			{
				maxx = C[j][1];
				C[j][1] = C[i][1];
				C[i][1] = maxx;
			}
		}
	}
	for(int i = 0; i < d - 1; i++)
	{
		maxx = D[i][1];
		for(int j = i + 1; j < d; j++)
		{
			if(D[j][1] > maxx)
			{
				maxx = D[j][1];
				D[j][1] = D[i][1];
				D[i][1] = maxx;
			}
		}
	}
	swa[0] = swb[0] = swc[0] = swd[0] = 0;
	sva[0] = svb[0] = svc[0] = svd[0] = 0;
	for(int i = 1; i <= a; i++)
	{
		swa[i] = swa[i - 1] + A[i - 1][0];
		sva[i] = sva[i - 1] + A[i - 1][1];
	}
	for(int i = 1; i <= b; i++)
	{
		swb[i] = swb[i - 1] + B[i - 1][0];
		svb[i] = svb[i - 1] + B[i - 1][1];
	}
	for(int i = 1; i <= c; i++)
	{
		swc[i] = swc[i - 1] + C[i - 1][0];
		svc[i] = svc[i - 1] + C[i - 1][1];
	}
	for(int i = 1; i <= d; i++)
	{
		swd[i] = swd[i - 1] + D[i - 1][0];
		svd[i] = svd[i - 1] + D[i - 1][1];
	}
	long long int sum = 0;
	long long int ans = 0;
	for(int i = 0; i <= a; i++)
	{
		for(int j = 0; j <= b; j++)
		{
			for(int k = 0; k <= c; k++)
			{
				for(int l = 0; l <= d; l++)
				{
					sum = swa[i] + swb[j] + swc[k] + swd[l];
					if(sum <= w)
					{
						ans = max(ans, sva[i] + svb[j] + svc[k] + svd[l]);
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  std::vector<int> hills;
  int hight;
  for (int i = 0; i < 10; ++i) {
    std::cin >> hight;
    hills.push_back(hight);
  }
  std::sort(hills.begin(), hills.end(), std::greater<int>());
  for (int i = 0; i < 3; ++i) {
    std::cout << hills[i] << std::endl;
  }

  return 0;
}

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

int a,b;
int x,y,z;
int ans;
int main() {
	cin>>a>>b;
	x=a+a-1;
	y=b+b-1;
	z=a+b;
	ans=max(max(x,y),z);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
import sys

N, M = map(int,input().split())

if M < N-1:
  print(0)
  sys.exit()

p = [i for i in range(N)] #点の数
root = []
for i in range(M):
  a,b = map(int,input().split())
  root.append((a-1,b-1))

#たどる点の順番の全探索
pattern = list(itertools.permutations(p))
#print(pattern)

ans = 0
for i in range(len(pattern)):
  if pattern[i][0] != 0:
    break
  Flag = True
  for j in range(N-1):
    if (pattern[i][j], pattern[i][j+1]) in root:
      continue
    elif (pattern[i][j+1], pattern[i][j]) in root:
      continue
    else:
      Flag = False
      break
  if Flag:
    ans += 1
print(ans)      

Measured memory_bytes: 46316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
using namespace std;
using llong = long long;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;

const llong INF = (1ll << 60ll);
llong min_cost[3000][55];

llong n, m, s;

// 0:A_i, 1:B_i, 2:destination
vector<tuple<llong, llong, llong>> g[55];

// 0:cost, 1:coin, 2:pos
MinHeap<tuple<llong, llong, llong>> que;

int main() {
    for (int i = 0; i < 3000; i++) {
        for (int j = 0; j < 55; j++) {
            min_cost[i][j] = INF;
        }
    }
    
    cin >> n >> m >> s;
    s = min(s, 2999ll);
    for (int i = 0; i < m; i++) {
        llong u, v, a, b;
        cin >> u >> v >> a >> b;

        g[u].emplace_back(-a, b, v);
        g[v].emplace_back(-a, b, u);
    }

    for (int i = 1; i <= n; i++) {
        llong c, d;
        cin >> c >> d;
        g[i].emplace_back(c, d, i);
    }


    que.emplace(0, s, 1);

    while (!que.empty()) {
        auto dat = que.top();
        que.pop();

        llong cost, coin, pos;
        tie(cost, coin, pos) = dat;

        if (min_cost[coin][pos] != INF) continue;
        min_cost[coin][pos] = cost;
                
        for (auto e:g[pos]) {
            llong ncoin = coin + get<0>(e);
            llong ncost = cost + get<1>(e);
            llong npos = get<2>(e);

            if (ncoin >= 3000 || ncoin < 0) continue;
            if (min_cost[ncoin][npos] <= ncost) continue;
            que.emplace(ncost, ncoin, npos);
        }
    }

    for (int i = 2; i <= n; i++) {
        llong ans = INF;
        for (int j = 0; j < 3000; j++) {
            //cout << j << ';' << i << endl;
            //cout << min_cost[j][i] << endl;
            ans = min(ans, min_cost[j][i]);
        }

        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        if (!data[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    sort(all(data));
    vi yui;
    yui.pb(0);
    yui.pb(24);
    rep(i, data.size()) {
        if (i % 2) {
            yui.pb(data[i]);
        } else {
            yui.pb(24 - data[i]);
        }
    }
    sort(all(yui));
    //rep(i, yui.size()) cout << yui[i] << endl;

    int ans = INF;
    Rep(i, yui.size()) {
        ans = min(ans, yui[i] - yui[i-1]);
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	string s,o,e;
	s="";
	cin>>o;
	cin>>e;
	int len=e.length();
	for(int i=0;i<len;i++)
	cout<<o[i]<<e[i];
	if(o.length()>len)
	cout<<o[o.length()-1];
	return 0;
}

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

#define ff first
#define ss second
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define endl "\n"      // Comment in INTERACTIVE(there just use endl which flushes output , no need of fflush(sdtout)).
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)
#define fastio() ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

const int mod = 1000000007;
const int inf = 1000000009;
 const int N = (1e5) + 2;
 int arr[N][4];
 int dp[N][4];
 int memo[N][3];
 int memonew[N][3];


 int profit(int i,int next ){
// memoized BUT DIFFICULT to do from recursion AS IN STATE VAR next -> DEPEND ON next STATE
    // Better if DEPENDENT ON OWN , THEN MORE CLEAR.
    if(i <= 0)
        return 0;
    if(memo[i][next] != -1)
        return memo[i][next];

    int c1 = (next +1)%3;
    int c2 = (next  +2)%3;
    return memo[i][next] = max(profit(i-1,c1) + arr[i][c1+ 1] , profit(i-1,c2) + arr[i][c2 + 1]);
 }

 int profitnew(int i,int cur){    // here represent cur value (out of 3) , which can take next based on it.

    if(i <= 0)
        return 0;
    if(memonew[i][cur] != -1)
        return memonew[i][cur];
    int c1 = (cur +1)%3;
    int c2 = (cur + 2)% 3;

    // have cur , assign diff from it.
    return memonew[i][cur] = max(profitnew(i-1, c1) + arr[i][c1 + 1] , profitnew(i-1, c2) + arr[i][c2 + 1]);
 }

int32_t main(){
    fastio();

    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    // #endif

     memset(memo, - 1, sizeof(memo));
     memset(memonew, - 1, sizeof(memonew));
     

     // ***** AC_chahiye EK BAR MEIN

     // BEGIN CODE HERE
    int n ;
    cin>>n;
    for(int i = 1;i <= n; ++i){
        cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
    }
    dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = 0;
    for(int i = 1;i <= n; ++i){
        for(int j = 1;j <= 3 ; ++j){
            int mx = 0;
            for(int k = 1;k <= 3; ++k){
                if(j != k)
                    mx = max(mx,dp[i - 1][k]);
            }
            dp[i][j] = mx + arr[i][j];
        }
    }
    // cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;

    // cout<<max({profit(n,0) , profit(n,1) , profit(n,2) })<<endl;

    cout<<max({profitnew(n,0) , profitnew(n,1)  , profitnew(n, 2)})<<endl;
    //getch();
}


Measured memory_bytes: 12032
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
mod = 10 ** 9 + 7

dp = [1] + [1] + [0] * (n - 1)
for i in range(1, n + 1):
    if i >= 2:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    if i in a:
        dp[i] = 0

print(dp[-1] % mod)


Measured memory_bytes: 83832
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

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

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    double S = 1. * a * b / 3.305785;
    printf("%.6lf\n", S);
    return 0;
}

Measured memory_bytes: 1064
[N,M]=[int(x) for x in raw_input().split()]
pricelist=[]
buylist=[]
for i in range(1,N+1):
    pricelist.append((int(raw_input()),i))
for j in range(M):
    buylist.append(int(raw_input()))
pricelist.sort()
buylist.sort()
finalwinner=[99999,0]
winner=[99999,0]
ind=0
for b in buylist:
    localwinner=winner[0]
    while(pricelist[ind][0]<=b and ind<N-1):
        localwinner=min(localwinner,pricelist[ind][1])
        ind+=1
    if winner[0]==localwinner:
        winner[1]+=1
    else:
        finalwinner=max([finalwinner,winner], key=lambda x: x[1])
        winner=[localwinner,1]
    #print winner
finalwinner=max([finalwinner,winner], key=lambda x: x[1])
print finalwinner[0]

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;cin>>n;
	int a[n+1]={0};
	for(int i=1;i<n;i++)
	{
		cin>>m;
		a[m-1]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4384
#!/usr/bin/python

# AtCoder Beginner Contest 084
# C: Special Trains

import sys

# the time when a person at station i arrive the station N,
# with the current time t
def solve(data, i, t):
  if i == N: return t
  (c, s, f) = data[i - 1]
  # we can start here at s, s+f, s+2f, ...
  # we have to find k >= 0 such that s+(k-1)f < t <= s+kf.
  # k-1 < (t-s)/f <= k
  k = 0 if t <= s else (t - s + f - 1) // f
  return solve(data, i + 1, s + k * f + c)

N = int(sys.stdin.readline())
data = []
for i in range(N - 1):
  c, s, f = [int(w) for w in sys.stdin.readline().split()]
  data.append((c, s, f))

for i in range(N):
  print(solve(data, i + 1, 0))


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
int main(){
    int n;
    cin>>n;
    long long dp[n+1][4][4][4]={};
    dp[0][3][3][3]=1;//TTT(仮)
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                for(int l=0;l<4;l++){
                    for(int m=0;m<4;m++){
                        if(m==2){
                            if(k==0 && l==1)dp[i+1][k][l][m]=0;
                            else if(j==0 && l==1)dp[i+1][k][l][m]=0;
                            else if(j==0 && k==1)dp[i+1][k][l][m]=0;
                            else if(k==1 && l==0)dp[i+1][k][l][m]=0;
                            else dp[i+1][k][l][m]+=dp[i][j][k][l]%mod;
                        }
                        else if(m==1 && k==0 && l==2)dp[i+1][k][l][m]=0;
                        else dp[i+1][k][l][m]+=dp[i][j][k][l]%mod;
                    }
                }
            }
        }
    }
    long long ans=0;
    for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++)ans+=dp[n][i][j][k];
    cout<<ans%mod<<endl;
    return 0;
}

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

const int NOT_FOUND = -1;

int binarySearch(int key, int A[], int n){
  int left = 0;
  int right = n;

  while(left<right){
    int mid = (left+right)/2;

    if(A[mid]==key){
      return mid;
    }
    else if(key<A[mid]){
      right = mid;
    }
    else{
      left = mid+1;
    }
  }

  return NOT_FOUND;
}

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

  int S[100000];
  for(int i=0; i<n; i++){
    cin >> S[i];
  }

  int q;
  cin >> q;

  int T[50000];
  for(int i=0; i<q; i++){
    cin >> T[i];
  }

  int C = 0;

  for(int i=0; i<q; i++){
    if(binarySearch(T[i], S, n)!=NOT_FOUND){
      C++;
    }
  }

  cout << C << endl;

  return 0;
}



Measured memory_bytes: 3664
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n",MAX(MAX(a+b,a-b),a*b));
}

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

typedef long long lint;
typedef long double louble;

#define lf ('\n')

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,fa[_]={0},mxv[_]={0},sz[_]={0},pwd[_]={0},chaf[_]={0};

void dfspwd(int x,int ff,int lim)
{
	pwd[x]=1;
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		if(b<lim)dfspwd(b,x,lim),pwd[x]+=pwd[b];
	}
}

void dfs(int x,int ff)
{
	fa[x]=ff,mxv[x]=max(x,mxv[ff]),sz[x]=1;
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		dfs(b,x),sz[x]+=sz[b],chaf[x]+=chaf[b];		
	}
	if(mxv[x]==x)dfspwd(x,ff,mxv[ff]),chaf[x]=-sz[x];
	if(mxv[ff]==ff)chaf[x]+=sz[x];
}

int ans[_]={0};

void dfs2(int x,int ff)
{
	if(ff)
	{
		ans[x]=ans[ff];
		if(mxv[x]==x)ans[x]+=pwd[x];
		else if(mxv[ff]==ff)ans[x]+=chaf[x]-pwd[x];
	}
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		dfs2(b,x);
	}
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	
	dfs(1,0),dfs2(1,0);
	for(int i=2;i<=n;i++)cout<<ans[i]<<" \n"[i==n];
	
	return 0;
}


Measured memory_bytes: 22272
#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
int main(int argc, char *argv[]) {
  int N;
  std::cin >> N;
  int n3 = 3 * N;
  int a[100001 * 3];
  for (int i = 0; i < n3; ++i)
    std::cin >> a[i];

  std::sort(a, a + n3, std::greater<int>());
  long sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += a[i * 2 + 1];
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 1408
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int main() {   
    int n,k;
    cin>>n>>k;
    ll a[5001];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ll s;
    int ans=n;
    int ng=0;
    int ok=n+1;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        s=a[mid];
        a[mid]=0;
        bool dp[5001][5001]={false};
        dp[0][0]=true;
        bool f=false;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=k;j++){
                dp[i][j]|=dp[i-1][j];
                if(j>=a[i]){
                    dp[i][j]|=dp[i-1][j-a[i]];
                }
                if(i==n&&j>=k-s&&j<k&&dp[i][j]){
                    f=true;
                }
            }
        }
        if(f){
            ok=mid;
        }else{
            ng=mid;
        }
        a[mid]=s;
    }
    cout<<ng<<endl;
    getchar();
    getchar();
}

                           


Measured memory_bytes: 24704
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(N,M);
    if(abs(N-M)>1){
        print(0);
        return 0;
    }
    ll ans=1;
    FORIN(i,1,N+1){
        ans=ans*i%MOD;
    }
    FORIN(i,1,M+1){
        ans=ans*i%MOD;
    }
    if(N==M)ans=ans*2%MOD;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import re
Sd = input()
T = input()
Sdls = list(Sd)
Sdls.reverse()
Sdre = ''.join(Sdls)
Tls = list(T)
Tls.reverse()
Tre = ''.join(Tls)
st = -1
for i in range(0,len(Sd)-len(T)+1):
    f = 1
    for j in range(len(T)):
        if Tre[j] == Sdre[i+j] or Sdre[i+j] == '?':
            continue
        else:
            f = 0
            break
    if f == 1:
        st = i
        break
if st == -1:
    print('UNRESTORABLE')
else:
    Sdrels = list(Sdre)
    for j in range(len(T)):
        Sdrels[j+st] = Tre[j]
    for j in range(len(Sd)):
        if Sdrels[j] == '?':
            Sdrels[j] = 'a'
    ans = ''.join(reversed(Sdrels))
    print(ans)

Measured memory_bytes: 9808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}



int main()
{
	ll i,j,k;
	ll mod = 1000000007;
	ll N,K;
	vector<ll> mp;
	ll total[100000] = {0};
	ll tot_next[100000] = {0};
	cin >> N >> K;
	ll target = 1;
	while(target <= N/2)
	{
		ll next = (ll)(N/target);
		if(next == 1)
			break;
		ll top  = target;
		ll bot  = N;
		ll mid = (top+bot)/2;
		while(bot-top > 1)
		{
			if(next>(ll)(N/mid))
			{
				bot = mid;
			}
			else
			{
				top = mid;
			}
			mid = (top+bot)/2;
		}
		total[mp.size()] = mid;
		mp.push_back(mid);
		target = mid + 1;
	}
	total[mp.size()] = N;
	mp.push_back(N);
	int mp_size = mp.size();
	for(i=1;i<K;++i)
	{
		tot_next[0] = total[mp_size-1];
		tot_next[0] %= mod;
		for(j=1;j<mp_size;++j)
		{

			tot_next[j] = tot_next[j-1] + total[mp_size-j-1]*(mp[j]-mp[j-1]);
			tot_next[j] %= mod;
		}
		swap(total, tot_next);
	}
	cout << total[mp_size-1] << endl;
	return 0;
}



























Measured memory_bytes: 2428
a=str(input())
if (a[-1] == '2') or (a[-1] == '4') or (a[-1] == '5') or (a[-1] == '7') or (a[-1] == '9'):
  print('hon')
elif (a[-1] == '0') or (a[-1] == '1') or (a[-1] == '6') or (a[-1] == '8'):
  print('pon')
elif (a[-1] == '3'):
  print('bon')

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

int main() {
 string S, T;
 string A = "Yes";
 cin >> S >> T;
 for(int i = 0; i < S.size(); i++){
 	if(S.at(i) != T.at(i)){
 	A = "No";
    break;
 	}
 }
  cout << A << endl;
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int p[20];

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

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

	int count = 0;
	for(int i = 1; i < n-1; ++i){
		int judge = (p[i] - p[i-1]) * (p[i+1] - p[i]);

		if(judge > 0){
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (to_string(i).size() % 2 == 1) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
class flowers:
    def __init__(self, str_h):
        self.str = str_h.split()
        self.int = []
        self.min = 0
        self.water = 0
        
        self.update_int()
        self.update_min()
    
    def update_str(self):
        self.str = list(map(str, self.int))
        return

    def update_int(self):
        self.int = list(map(int, self.str))
        return
    
    def update_min(self):
        self.min = min(self.int)
        return
    
    def minimize(self):
        self.int = [n-self.min for n in self.int]
        self.water += self.min
        self.update_str()
        self.min = 0
        return
    
    def str_split0(self):
        idxs = [-1] + [i for i,n in enumerate(self.int) if n==0]
        if len(idxs)==1:
            return [self.str]
        else:
            temp_ls = []
            for i in range(len(idxs)-1):
                s = self.str[idxs[i]+1:idxs[i+1]]
                if len(s)>0: temp_ls.append(s)
            if self.int[-1]!=0:
                temp_ls.append(self.str[idxs[-1]+1:])
        return temp_ls

N = input()
str_h = input()

fls = flowers(str_h)
ls_fls = fls.str_split0()
water = 0

while(len(ls_fls)>0):
    #print(f'ls_fls = {ls_fls}')
    temp_ls_fls = []
    for fls in ls_fls:
        if len(fls)<=2:
            water += max([int(s) for s in fls])
            continue
        else:
            _fls = flowers(' '.join(fls))
            _fls.minimize()
            _ls_fls = _fls.str_split0()
            water += _fls.water
            temp_ls_fls += _ls_fls
            flg=1
    ls_fls = temp_ls_fls
print(water)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  
  int A,B;
  cin >> A >> B;
  int ans =0;
  int cnt =1;
  
  while (cnt < B){
    ans +=1;
    cnt +=(A-1);
  }
  
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256