akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string s;
  cin>>s;
  ll n;
  n=s.size();
  ll ans[n];
  for(ll i=0;i<n;i++)ans[i]=0;
  ll r=0,l=0,memo=-1;
  bool rl=false;
  for(ll i=0;i<n;i++){
    if(!rl){
      if(s[i]==s[i+1])r++;
      else {
        r++;
        rl=true;
      }
    }
    else {
      if(s[i]==s[i+1])l++;
      else {
        l++;
        rl=false;
        ans[memo+r]+=r-r/2+l/2;
        ans[memo+r+1]+=r/2+l-l/2;
        memo=i;
        r=0;
        l=0;
      }
    }
  }
  for(ll i=0;i<n-1;i++)cout<<ans[i]<<" ";
  cout<<ans[n-1]<<endl;
}

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        long A, B, C;
        A = cin.nextInt();
        B = cin.nextInt();
        C = cin.nextInt();
        long K = cin.nextLong();

        if(K%2 == 1)
        {
            long NA = B + C;
            long NB = A + C;
            long NC = A + B;
            A = NA;
            B = NB;
            C = NC;
        }

        long ans = A - B;
        Console.WriteLine(ans);
    }
}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


void func()
{
	string S,T;
	bool ans(true);
	cin >> S;
	cin >> T;

	size_t len = S.length();
	ans = (S == T);
	for (size_t i = 1; i < len && !ans; i++)
	{
		char c = T[0];
		T.erase(T.begin());
		T.push_back(c);
		ans = (S == T);
	}
	if(ans)
		cout << "Yes\n";
	else
		cout << "No\n";

}

int main() {

//	while(1)
		func();
	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <set>
#include <stdlib.h>
#include <string.h>
#define int long long
using namespace std;
int a[80][80];
int b[80][80];
bool dp[80][80][13800];
signed main()
{
	int N,M;
	cin >> N>>M;
	int i,j;
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			cin >> a[i][j];
		}
	}
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			cin >> b[i][j];
		}
	}
	dp[0][0][abs(a[0][0] - b[0][0])] = true;
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			int k;
			if (i)
			{
				for (k = 0; k < 13800; k++)
				{
					if (dp[i - 1][j][k])
					{
						dp[i][j][abs(k + a[i][j] - b[i][j])] = true;
						dp[i][j][abs(k + b[i][j] - a[i][j])] = true;
					}
				}
			}
			if (j)
			{
				for (k = 0; k < 13800; k++)
				{
					if (dp[i][j-1][k])
					{
						dp[i][j][abs(k + a[i][j] - b[i][j])] = true;
						dp[i][j][abs(k + b[i][j] - a[i][j])] = true;
					}
				}
			}
		}
	}
	for (i = 0; i < 13800; i++)
	{
		if (dp[N - 1][M - 1][i])
		{
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 85632
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll ans=INT_MAX;
    for(i=1;i<n;i++)
    {
        ll sum1=0,sum2=0;
        for(j=0;j<i;j++) sum1+=arr[j];
        for(j=i;j<n;j++) sum2+=arr[j];
        ans=min(ans,abs(sum1-sum2));
    }
    cout<<ans;
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	cnt := 0
	for i := 1; i <= n; i += 2 {
		cntt, _ := getDivlist(i)
		if cntt == 8 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// 約数列挙リストを作成(愚直)
func getDivlist(a int) (cnt int, divlist []int) {
	for i := 1; i*i <= a; i++ {
		if a%i == 0 {
			cnt++
			divlist = append(divlist, i)
			if i*i != a {
				cnt++
				divlist = append(divlist, a/i)
			}
		}
	}
	sort.Ints(divlist) // 昇順ソート
	return cnt, divlist
}

// 約数の数をカウントする(愚直)
func numDivSlow(a int) int {
	cnt := 1
	for i := 1; i <= a/2; i++ {
		if a%i == 0 {
			cnt++
		}
	}
	return cnt
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 3000;
int dp[N][N], n, m;
string x, y;
int solve(int i = 0, int j = 0)
{
  if (i == n || j == m)return 0;
  int &ret = dp[i][j];
  if (~ret)return ret;
  ret = max(solve(i+1, j) , solve(i, j+1));
  if (x[i] == y[j])ret = max(2 + solve(i+1, j+1) , ret);
  return ret;
}
void build(int i = 0, int j = 0)
{
  if (i == n || j == m)return;
  int ret = dp[i][j];
  int p1 = solve(i+1, j);
  int p2 = solve(i, j+1);
  int p3 = 0;
  if (x[i] == x[j])
  p3 = 2 + solve(i+1, j+1);
  if (ret == p1)
  {
    build(i+1, j);
  }else if (ret == p2)
  {
    build(i, j+1);
  }else
  {
    cout << x[i];
    build(i+1, j+1);
  }
}
int main()
{
  cin >> x >> y;
  n = SZ(x);
  m = SZ(y);
  memset(dp, -1, sizeof dp);
  solve();
  build();
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    string s; cin >> s;
    set<ll> se;
    rep(i, s.size()) se.insert(s[i]);
    if(se.size() == s.size()) cout << "yes" << endl;
    else cout << "no" << endl;
}


Measured memory_bytes: 3632
A, B = list(map(int, input().split()))

large = A if A > B else B
small = A if A < B else B

def gcd(large, small):
    r = large % small
    while r != 0:
        large = small
        small = r
        r = large % small
    return small

print(large*small//gcd(large, small))


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






int main(){
    int N, a; std::cin >> N;
    //dp[i][j] := i-4(0-order)文字まで見て j=(取らない)-(取った)+1
    std::vector<std::vector<long long>> dp(N+4, std::vector<long long>(3, 0));
    for(int i(4), i_len(N+4); i < i_len; ++i){
        std::cin >> a;
        if(i & 1)
            dp[i][1] = std::max(dp[i-1][0], std::max(dp[i-2][1], dp[i-3][0]) + a);
        else{
            dp[i][0] = dp[i-2][0] + a;
            if(i > 4)
                dp[i][2] = std::max(dp[i-1][1], std::max({dp[i-2][2], dp[i-3][1], dp[i-4][0]}) + a);
        }
    }
    std::cout << dp[N+3][(N & 1) + 1] << std::endl;
    return 0;
}


Measured memory_bytes: 14356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC056
{
    static class HonestOrDishonest
    {
        public static void Main()
        {
            var refer = ReadLine().Trim().Split(' ').Select(r => Read(r)).ToArray();
            switch (refer[0])
            {
            case Honesty.Honest: WriteLine(refer[1].ToChar()); break;
            default: WriteLine(refer[1].Inverse().ToChar()); break;
            }
        }
        static Honesty Read(string refer)
        {
            switch (refer)
            {
            case "H": return Honesty.Honest;
            default: return Honesty.DisHonest;
            }
        }
        static char ToChar(this Honesty honest)
        {
            switch (honest)
            {
            case Honesty.Honest: return 'H';
            default: return 'D';
            }
        }
        static Honesty Inverse(this Honesty honest)
        {
            switch(honest){
            case Honesty.Honest: return Honesty.DisHonest;
            default: return Honesty.Honest;
            }
        }
        enum Honesty { 
            Honest, DisHonest
        }
    }
}


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

int main() {
  string s; cin >> s;
  string t; cin >> t;
  
  string result = "Yes";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      result = "No";
      cout << result << endl;
      return 0;
    }
  }
  if (t.size() != s.size() + 1) {
    result = "No";
    cout << result << endl;
    return 0;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3632
def I(): return int(input())
##################################################
X = I()
dp = [0]*(X+1)    #IndexとXを合わせた。dpのIndex範囲:0~X
dp[0] = 1
for i in range(X+1):
    if dp[i]:
        for j in range(100,106):
            if i+j<=X:    #「out of lange」対策。
                dp[i+j] = 1
print(dp[-1])

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

ll mpow(ll a,ll b){
    ll res=1;
    a%=mod;
    while(b){
    	if(b%2) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res;
}

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

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

void solve(){
	//code
	ll n,m,L=1;
  	cin>>n>>m;
  	ll a[n];
  	
	for(int i=0;i<n;i++){
    	cin>>a[i];
    	a[i]/=2;
    	L=lcm(L,a[i]);
  	}
  
  	for(int i=0;i<n;i++) 
	  	if(L/a[i]%2==0){
		  	cout<<0<<endl;
			return;
		}
  	cout<<m/(2*L)+(m%(2*L)>=L ? 1 : 0)<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 4416
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

struct mint {
	int x;
	mint(int 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(int 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 {
		mint res(*this);
		return res /= a;
	}
};
ostream& operator<<(ostream & os, const mint & m) {
	os << m.x;
	return os;
}

struct combination {
	vector<mint>fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		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];
	}
};

signed main() {
	int N, K;
	cin >> N >> K;
	mint ans = 0;
	vector<int>v(N + 2);
	v[0] = 0;
	rep(i, N + 1)v[i + 1] = i + v[i];
	for(int k = K; k <= N + 1; k++) {
		int mn = v[k];
		int mx = v[N + 1] - v[N + 1 - k];
		ans += mx - mn + 1;
	}
	cout << ans;
}

Measured memory_bytes: 4840
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

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

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
namespace SOLVE {
    void main(){
    }
}


ll solve(ll a,ll b){
    if(a == 0 || b == 0)return 0;
    if(a<b)swap(a, b);
    ll ans = a/b*2*b;
    if(a%b==0)ans-=b;
    return ans+solve(a%b, b);
}
int main() {

    
    
    
    
    
    
    ll n,x;
    in(n,x);
    ll ans = n;
    cout<<ans+solve(x, n-x);
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

const int N = 5e5 + 5;
ll f[N];
int n, m;

ll fpow(ll a, ll b) {
    ll ret = 1;
    while (b) {
        if (b & 1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        b /= 2;
    }
    return ret;
}

ll comb(int n, int k) {
    if (k == 0) return 1;
    if (n == k) return 1;
    if (n < k) return 0;
    ll ret = f[n];
    ret = (ret * fpow(f[n - k], MOD - 2)) % MOD;
    ret = (ret * fpow(f[k], MOD - 2)) % MOD;
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    f[0] = f[1] = 1;
    for (int i = 2; i <= m; i++) {
        f[i] = (f[i - 1] * i) % MOD;
    }
    ll ans = (comb(m, n) * f[n]) % MOD;
    ll lol = 0;
    for (int i = n; i >= 0; i--) {
        ll ko = (comb(n, i) * comb(m - i, n - i)) % MOD;
        ll ntol = f[n - i];
        if (i % 2 == 0) lol += (ko * ntol) % MOD;
        else lol -= (ko * ntol) % MOD;
        // cout << i << " "2 2 << ko << " " << ntol << '\n';
        lol += MOD;
        lol %= MOD;
    }
    ans = (ans * lol) % MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7480
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
    double s,x1,y1,x2,y2,a,b;
    cin >> x1 >> y1 >> x2 >> y2;
    a = pow(x2-x1,2);
    b = pow(y2-y1,2);
    s = sqrt(a+b);
    
    printf("%lf\n",s);
    
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
using namespace std;
vector<int> f[200005];
int main(){
 int N,M,a,b;
 cin>>N>>M;
 for(int i=1;i<=M;i++)
   {
   cin>>a>>b;
   f[a].push_back(b);
   }
 for(int i=0;i<f[1].size();i++)
 {
 	for(int j=0;j<f[f[1][i]].size();j++)
 	if(f[f[1][i]][j]==N) {
 		cout<<"POSSIBLE"<<endl; return 0;
	 }
 }
 cout<<"IMPOSSIBLE"<<endl;
 return 0;
}


Measured memory_bytes: 8576
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;


int main(void) {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<bool> wat(f + 1, false);
  queue<int> que;
  que.push(0);
  while (not que.empty()) {
    int t = que.front(); que.pop();
    if (t > f) { continue; }
    if (wat[t]) { continue; }
    wat[t] = true;
    que.push(t + 100 * a);
    que.push(t + 100 * b);
  }
  vector<bool> sug(f + 1, false);
  que.push(0);
  while (not que.empty()) {
    int t = que.front(); que.pop();
    if (t > f) { continue; }
    if (sug[t]) { continue; }
    sug[t] = true;
    que.push(t + c);
    que.push(t + d);
  }
  pair<double, PI> ma(-5e15, PI(0, 0));
  REP(i, 1, f + 1) {
    if (not wat[i]) { continue; }
    REP(j, 0, f - i + 1) {
      if (not sug[j]) { continue; }
      if (i * e < j * 100) { continue; }
      ma = max(ma, make_pair(j * 100.0 / i / e, PI(i + j, j)));
    }
  }
  cout << ma.second.first << " " << ma.second.second << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		sc.close();
		long s=100;
		int k=0;
		while(s<X) {
			s+=s/100;
			k++;
		}
		System.out.println(k);
	}

}

Measured memory_bytes: 35924
#include <stdio.h>
#include <math.h>


int main(void){
    int N;
    //long A[101];    
    int B[100];
    int count=0;

    scanf("%d",&N);
    B[0] = 100001;
    B[N] = 100001;
    for(int i=1; i<N; i++){
        scanf("%d",&B[i]);
    }
    for(int i=0; i<N; i++){
        if(B[i] > B[i+1]){
            count += B[i+1];
        }else{
            count += B[i];
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];

		for(int i=0;i<x.length;i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);

		int v = x[x.length-1];
		if(v%2==1) {
			v+=1;
		}

		System.out.println(x[x.length-1]+" "+x[getNearestValue(x, v/2)]);

	}

	// 最も近い値を格納した配列の添え字を求める
	//http://talavax.com/nearestvalue.html より拝借
		public static int getNearestValue( int[] list, int v )
		{
			// 変数の宣言
			int i;		// ループ用
			int num;	// 配列の添え字
			int minv;	// 配列値-指定値vの絶対値

			// 配列の個数が1未満の処理
			if ( 1 >list.length ) return -1;

			// 指定値と全ての配列値の差を比較
			num = 0;
			minv = Math.abs( list[ 0 ] - v );
			for ( i = 1; i < list.length; ++ i ) {
				if ( Math.abs( list[ i ] - v ) < minv ) {
					num = i;
					minv = Math.abs( list[ i ] - v );
				}
			}

			return num;
		}

}


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

namespace Atcoder_0403
{
    class Program
    {
        static void Main(string[] args)
        {
            var _XY = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int _needRed = _XY[0];
            int _needGreen = _XY[1];
            long[] _reds = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long[] _greens = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long[] _clears = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            List<long> _result = new List<long>();

            Array.Sort(_reds);
            Array.Sort(_greens);
            Array.Sort(_clears);

            //緑と赤からのみ取得
            for (int i = 0; i < _needRed; i++)
            {
                _result.Add(_reds[_reds.Length-1-i]);
            }

            for (int i = 0; i < _needGreen; i++)
            {
                _result.Add(_greens[_greens.Length - 1 - i]);
            }
            _result.Sort();


            int nowCheck = 0;
            int clearRemain=_clears.Length-1;
            while (true)
            {
                if (nowCheck >= _result.Count) break;
                if (clearRemain < 0) break;
                long min = _result[nowCheck];
                long max = _clears[clearRemain];
                if (max > min)
                {
                    _result[nowCheck] = max;
                    clearRemain--;
                    nowCheck++;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(_result.Sum());

        }
    }
}


Measured memory_bytes: 43876
#include<bits/stdc++.h>
using namespace std;
	int main() {
		int a, b;
		cin >> a >> b;
		int x = b - a;
		int height = 0;

		for (int i = 1; i <= x; i++) {
			height += i;
		}
		int ans = height - b;
		cout << ans << endl;
		
		}

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> pct(h);
    for (int i = 0; i < h; i++)
    {
        cin >> pct.at(i);
    }
    string s;
    for (int i = 0; i < w + 2; i++)
    {
        s += '#';
    }
    cout << s << endl;
    for (int i = 0; i < h; i++)
    {
        putchar('#');
        cout << pct.at(i);
        putchar('#');
        putchar('\n');
    }
    cout << s << endl;
}

Measured memory_bytes: 3612
N,M = map(int,input().split())

P,C = [],[]
for i in range(N):
    P.append(list(map(int,input().split())))
for j in range(M):
    C.append(list(map(int,input().split())))

for i in range(N):
    min_point = 0
    min_man = 0
    for j in range(M):
        man = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
        if min_man > man or min_point==0:
            min_man = man
            min_point = j+1
    print(min_point)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  vector<tuple<int,int,int>> city;
  rep(i,m){
    int a,b,c;cin>>a>>b;c=i;
    city.emplace_back(a,b,c);
  }
  sort(city.begin(),city.end());
  city.emplace_back(inf,inf,inf);
  int last=0;
  int cur=1;
  vector<P> res(m);
  rep(i,m){
    if(get<0>(city[i])!=last){
      last=get<0>(city[i]);
      cur=1;
      res[get<2>(city[i])]={get<0>(city[i]),cur};
    }
    else{
      cur++;
      res[get<2>(city[i])]={get<0>(city[i]),cur};
    }
  }
  rep(i,m){
    printf("%06lld%06lld\n",res[i].first,res[i].second);
  }
  return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<pair<int, ll> > bc;
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    for(int i=0; i<m; ++i){
        ll b,c;
        cin >> b >> c;
        bc.push_back(make_pair(b,c));
    }
    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end(), [](auto x, auto y){return x.second > y.second; });
    int ctr1=0,  ctr2=0;
    for(int i= 0; i< n; ++i){
        int b = bc[ctr1].first;
        ll c = bc[ctr1].second;
        if(a[i] < c){
            a[i] = c;
            ctr2++;
            if(ctr2 >= b){
                ctr2 = 0;
                ctr1++;
            }
        }
        if (ctr1 >= bc.size()) break;
    }
    ll ret = accumulate(a.begin(), a.end(), 0LL);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3188
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
 
int main() {


int  n;
  string s;
  
  cin>>n>>s;
  int c=0;
  for(int i=0;i<n-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
      c++;
    }
  }
  cout<<c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm

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

int64_t A, B, C, D; cin >> A >> B >> C >> D;
int64_t LCM = boost::integer::lcm(C, D);
--A;
// 
cout << (B - (B/C + B/D - B/LCM)) - (A - (A/C + A/D - A/LCM)) << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

int main() {
	long long int n,m,a,b,c;
	string str;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	b+=3*a;
	cout<<b/2;
	cout<<endl;
} 


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

int main() {
  int n;
  bool ok=true;
  string S;
  cin >>S;
  n=S.size();
  for(int i=0;i<n;i++){
    if((i%2)==1){if(S[i]=='R'){ok=false;}}
    else if((i%2)==0){if(S[i]=='L'){ok=false;}}
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  
}

Measured memory_bytes: 256
s = input()
n_s = len(s)
S = ''
for i in range(n_s):
    S += s[-i-1]
words = ["maerd", "remaerd", "esare", "resare"]
cnt = 0
result = 'YES'
while True:
    if S[cnt:cnt+5] == 'maerd':
        cnt += 5
    elif S[cnt:cnt+5] == 'esare':
        cnt += 5
    elif S[cnt:cnt+6] == 'resare':
        cnt += 6
    elif S[cnt:cnt+7] == 'remaerd':
        cnt += 7
    else:
        result = 'NO'
        break
    if cnt == n_s:
        break
print(result)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a == b && b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b, c, x, y;
	int cost = 0;
	cin >> a >> b >> c >> x >> y;
	while(x > 0 || y > 0) {
		if (x > 0 && y > 0) {
			if (a + b > c * 2) {
				cost += c * 2;
			} else {
				cost += a + b;
			}
			x--;
			y--;
		} else if(x > 0) {
			if (a > c * 2) {
				cost += c * 2;
			} else {
				cost += a;
			}
			x--;
		} else if(y > 0) {
			if (b > c * 2) {
				cost += c * 2;
			} else {
				cost += b;
			}
			y--;
		}
	}
	cout << cost << endl;
	return 0;
}

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

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

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


int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, n){cin >> lis[i];}
    map<ll, ll> mp;
    REP(i, n){
        mp[lis[i]]++;
    }
    ll ans = 0;
    for(auto &x: mp){
        if(x.second > x.first){
            ans += x.second - x.first;
        }else if(x.second < x.first){
            ans += x.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7040
;; E - Max-Min Sums

(defun main ()
  (let* ((n (read)) ; 全数
         (k (read)) ; 選択数
         (a (loop repeat n collect (read))))
    (princ (solve n k a))
    (fresh-line)))

(defparameter *modulus* (+ (expt 10 9) 7))

(defun solve (n k a-lst)
  "aからk個選ぶ選び方すべてについての(最大 - 最小)の和"
  (let ((pre-sum (make-array (1+ n) :initial-contents
                   (prefix-sum (sort a-lst #'<)))))
    (mod
      (loop for m from k to n
            for comb = 1 then (mod/ (mod* comb (- m 2)) (- m k))
            sum (mod* comb (- (aref pre-sum n) (aref pre-sum (1- m))
                              (aref pre-sum (- (1+ n) m)))))
      *modulus*)))

(defun prefix-sum (lst)
  (nreverse
    (reduce #'(lambda (l x) (cons (+ (car l) x) l)) lst
      :initial-value '(0))))

;; modulo product/division

(defun mod* (&rest rest)
  (mod (apply #'* rest) *modulus*))

(defun mod/ (num denom)
  (mod* num (mod-inverse denom)))

(defun bit-sequence (v)
  "(bit-sequence 13) => (1 1 0 1)"
  (nreverse
    (loop for x = v then (ash x -1) while (plusp x) collect (logand x 1))))

(let ((modulus-2-bits (bit-sequence (- *modulus* 2))))
  ; Mが素数のとき，a^(M-2) ≡ a^(-1) mod M (フェルマーの小定理より)
  (defun mod-inverse (a)
    (loop for b in modulus-2-bits
          for e = a then (mod* e e (if (zerop b) 1 a))
          finally (return e))))

(main)


Measured memory_bytes: 73320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrintTestCases
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;

            do
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0)
                {
                    break;
                }
                Console.WriteLine("Case {0}: {1}", i + 1, a);
                i++;
            } while (true);
        }
    }
}



Measured memory_bytes: 15864
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define B

#ifdef A
int main(void)
{
	const int thousand = 1000;
	string hello = "Hello World\n";
	for (size_t i = 0; i < thousand; i++)
	{
		cout << hello;

	}
	return 0;
}


#endif // A

#ifdef B
#define _MAX 10000
int main(void)
{
	vector<int> arr(_MAX);
	int in = -1;
	for (size_t i = 0; i < _MAX && in != 0; i++)
	{
		cin >> in;
		arr[i] = in;

	}

	for (size_t i = 0; i < _MAX; i++)
	{
		if (arr[i] == 0)break;
		cout << "Case " << i + 1 << ": " << arr[i] << endl;
	}

	return 0;
}
#endif // B


#ifdef C

#endif // C

#ifdef D

#endif // D

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";


int main(){
    ll N,ans = 0;cin >> N;
    vector<string> strList(N);
    std::unordered_map<string, int> mp;
    REP(i,N){
        cin >> strList[i];
        sort(strList[i].begin(),strList[i].end());
        if(mp[strList[i]] > 0) ans += mp[strList[i]];
        mp[strList[i]]++;
    }
    // for(const auto& p : mp){
    //     cout << p.first << ": " << p.second <<endl;
    // }
    cout << ans << endl;
    
    // REP(i,N) cout << strList[i] <<endl;
    // int x[N][26] ={};
    // REP(i,N){
    //     REP(j,10){
    //         x[i][int(strList[i][j])-97]++;
    //     }
    // }
    // vector<long long int> ansstr(N);
    // REP(i,N){
         

    // REP(i,N){
    //     REP(j,26){
    //         cout << x[i][j] << " ";
    //     }
    //     cout << endl;

    // }

    // REP(i,10){
    //     ans[0] += int(s1[i]);
    //     ans[1] += int(s2[i]);
    //     ans[2] += int(s3[i]);

    // }
    // cout << ans[0] << " " << ans[1]<< " " << ans[2] << endl; 

    // long long int count=0;
    // REP(i,100000){
    //     count += i;
    // }
    // cout << count << endl;
    // string s="abcdefghijklmnopqrstuvwxyz";

    // string s1="arstuvwxyz";
    // REP(i,26){
    // cout << int(s1[0]) << " " << endl;
    
    // }
    // cout << int(c)<< endl;
}

Measured memory_bytes: 17700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if (w >= s) {
            System.out.println("unsafe");
            return;
        }
        System.out.println("safe");
    }

}


Measured memory_bytes: 35848
#ABC079-C-Train Ticket
s = input()

n = len(s) - 1

for i in range(n**2):
    tmp = ""
    for j in range(n+1):
        tmp += s[j]
        
        if (i >> j)&1 :
            tmp += '+'
        else:
            tmp += '-'
            
    tmp = tmp[:-1]
    
    if eval(tmp) == 7:
        print(tmp+'=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 //  Find the minimum number of coins the sum of which is S (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to S.



int main()
{
  ios_base::sync_with_stdio(false);
ll n,flag=0,i,j=0,count=0,temp=1;
cin>>n;
string s[n+1];
ll store[n]={0};
vector<string> v;

for(i=0;i<n;i++)cin>>s[i];
  s[n]="zzzzzzzzzzzzzzzzzzzzzzzzzzz";

sort(s,s+n);

for(i=0;i<n;i++)
{
  if(s[i]==s[i+1])
  {
    temp++;
  }
  else 
  {
   if(temp==count)v.push_back(s[i]);
   else if(temp>count)
   {
      v.clear();
      v.push_back(s[i]);
      count=temp;
   }
   temp=1;
  }

 }




  for(i=0;i<v.size();i++)cout<<v[i]<<endl;


return 0;

}

Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
const int N=8005,M=205;
const int mo=998244353;
const int P=16500;
int n,m,f[M][N];
int fac[N],inv[N];
int A[P],B[P],R[P];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
void FFT(int *a,int n,int f){
	for (int i=1;i<n;i++)
		if (i<R[i]) swap(a[i],a[R[i]]);
	for (int d=1;d<n;d<<=1){
		int wn=power(3,(mo-1)/(d<<1));
		if (f==-1) wn=power(wn,mo-2);
		for (int i=0;i<n;i+=(d<<1))
			for (int j=i,w=1;j<i+d;j++){
				int y=1ll*a[j+d]*w%mo;
				a[j+d]=(a[j]+mo-y)%mo;
				a[j]=(a[j]+y)%mo;
				w=1ll*w*wn%mo;
			}
	}
	if (f==-1){
		int v=power(n,mo-2);
		for (int i=0;i<n;i++)
			a[i]=1ll*a[i]*v%mo;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=n+2;i++)
		inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	for (int i=1;i<=n+2;i++){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*inv[i]%mo;
	}
	int c=1,L=0;
	for (;c<=2*n;c<<=1,L++);
	for (int i=1;i<=c;i++)
		R[i]=(R[i>>1]>>1)|((i&1)<<(L-1));
	for (int i=0;i<=n;i++) f[m][i]=1ll*fac[n]*inv[i]%mo*inv[n-i]%mo;
	for (int i=0;i<=n;i++) B[n-i]=inv[i+2];
	FFT(B,c,1);
	for (int i=m;i;i--){
		memset(A,0,sizeof(A));
		for (int j=0;j<=n;j++)
			A[j]=1ll*f[i][j]*fac[j+2]%mo;
		FFT(A,c,1);
		for (int j=0;j<c;j++)
			A[j]=1ll*A[j]*B[j]%mo;
		FFT(A,c,-1);
		for (int j=0;j<=n;j++)
			f[i-1][j]=1ll*A[n+j]*inv[j]%mo;
		for (int j=0;j<=n;j++)
			f[i-1][j]=(f[i-1][j]+mo-1ll*f[i][j]*j%mo)%mo;
	}
	printf("%d\n",f[0][0]);
}

Measured memory_bytes: 6784
import java.util.Scanner;
public class Main {
	private int page;
	private int max;
	 boolean flg = true;
	public Main(int a,int b){
		page = a;
		max = b;
	}
	public void study(){
		this.page -= this.max;
		if(this.page <=0){
			this.page = 0;
			this.flg = false;
		}
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int l,a,b,c,d,ans = 0;
		 l = sc.nextInt();
		 a = sc.nextInt();
		 b = sc.nextInt();
		 c = sc.nextInt();
		 d = sc.nextInt();
		Main ko = new Main(a,c);
		Main su = new Main(b,d);
		while(ko.flg || su.flg){
			ko.study();
			su.study();
			ans ++;
		}
		System.out.println(l - (ans));
	}

}

Measured memory_bytes: 25944
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    print("No");
  } else {
    print("Yes");
    int wh = w * h - 1;
    int val1 = 100000000 / wh;
    int val2 = val1 * wh - 1;
    REP(i, H) {
      REP(j, W) {
        if (i % h == 0 && j % w == 0)
          cout << val2 << " ";
        else {
          cout << -val1 << " ";
        }
      }
      cout << "\n";
    }
  }
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------
int A, B, C, X, Y;

signed main(){
	cin >> A >> B >> C >> X >> Y;
	
	int ans = 0;
	// Ａ，Ｂの両方あれば、Ｃがお得
	if(A + B > C*2) {
		while(X > 0 && Y > 0) {
			ans += C*2;
			X--; Y--;
		}
	}
	// Ａ１枚よりＣ２枚が安い！
	if(A > C*2) {
		while(X > 0) {
			ans += C*2;
			X--;
		}
	}
	// Ｂ１枚よりＣ２枚が安い！
	if(B > C*2) {
		while(Y > 0) {
			ans += C*2;
			Y--;
		}
	}
	ans += X * A;
	ans += Y * B;
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    int n, x; cin >> n >> x;
    while (n != 0 || x != 0) {
        int ans = 0;
        for (int first = 1; first <= n; ++first) {
            for (int second = first + 1; second <= n; ++second) {
                for (int third = second + 1; third <= n; ++third) {
                    int sum = first + second + third;
                    if (sum == x) ++ans;
                }
            }
        }
        cout << ans << endl;
        
        cin >> n >> x;
    }
    return 0;
}


Measured memory_bytes: 3064
#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;


int main(){
  string s;cin>>s;
  string t = s;
  int ans1=0,ans2=1;
    rep(i,s.size()-1){
      if(s[i]!=s[i+1])continue;
      s[i]=='0'?s[i+1]='1':s[i+1]='0';
      ans1 ++;
    }
    t[0]=='0'?t[0]='1':t[0]='0';
    rep(i,t.size()){
      if(t[i]!=t[i+1])continue;
      t[i]=='0'?t[i+1]='1':t[i+1]='0';
      ans2 ++;
    }
  
  cout <<min(ans1,ans2);
}




Measured memory_bytes: 512