akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;


}




Measured memory_bytes: 3624
process.stdin.resume();
process.stdin.setEncoding('utf8');


function splitDegistSum(number)
{
    var sum = 0, num = number;
    while (num > 0) {
        sum += parseInt(num % 10);
        num = parseInt(num / 10);
    }
    
    return sum;
}

function Main(input) {
    var inputs = input.split(" ").map(e => parseInt(e));
    
    var N = inputs[0],
        A = inputs[1],
        B = inputs[2],
        result = 0;
        
    for (var i = 1; i <= N; i++) {
        var sum = splitDegistSum(i);
        if (A <= sum && sum <= B) {
            result += i;
        }
    }
    
    console.log(result);
    
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9792
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repe(i, n) REPN(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec pn;

void init(){
	pn.pb(2);
	
	REP(num, 3, 1e5){
		bool flg = true;
		for(ll i : pn){
			if(num%i == 0){
				flg = false;
				break;
			}
			if(i*i > num) break;
		}
		if(flg) pn.pb(num);
	}
}

Vec fac, inv, finv;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(n%2 == 0) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

void build(ll n){
	fac.resize(n+1);
	fac[0] = 1;
	repn(i, n) fac[i] = (fac[i-1]*i)%MOD;
	finv.resize(n+1);
	finv[n] = PowMod(fac[n], MOD-2);
	repr(i, n) finv[i] = (finv[i+1]*(i+1))%MOD;
	finv[0] = 1;
}

int main(void){
	ll n, m;
	cin >> n >> m;
	init();
	build(n+100);

	unordered_map<ll, ll> ump;
	for(ll i : pn){
		if(m == 1) break;
		ll cnt = 0;
		while(m%i == 0){
			m /= i;
			cnt++;
		}
		if(cnt) ump[i] = cnt;
		if(m < i*i && m != 1){
			ump[m] = 1;
			m = 1;
		}
	}
 
	ll ans = 1;
	for(P i : ump){
		ans *= combi(n-1+i.sc, i.sc);
		ans %= MOD;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 2048
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll sol(ll pos,ll h,ll w,std::vector<std::vector<ll>> &sum,ll k) {
	ll prev = -1;
	vector<ll> temp;
	temp.pb(0);
	for(ll i=0;i<h-1;i++) {
		ll z = (1ll<<i);
		if(z&pos) {
			temp.pb(i);
			temp.pb(i+1);
		}
	}
	vector<pll> v;
	temp.pb(h-1);
	for(ll i=0;i<temp.size();i+=2) {
		v.pb(mp(temp[i],temp[i+1]));
	}
	vector<pll> temp2;
	// for(auto x:v) {
	// 	cout<<x.fi<<' '<<x.se<<' ';
	// }
//	cout<<endl;
	ll c = 0;
	for(ll i=0;i<w;i++) {
		/// 0 to i
		/// 0 to pos1
		/// pos1+1 to pos2
		/// and so on
		ll st = prev+1;
		ll mx = 0;
		for(auto &p:v) {
			ll r1 = p.fi;
			ll r2 = p.se;
			ll c1 = st;
			ll c2 = i;
	//		error(r1);error(c1);error(r2);error(c2);
			ll tempsum = sum[r2][c2];
			if(r1>0)tempsum-=sum[r1-1][c2];
			if(c1>0)tempsum-=sum[r2][c1-1];
			if(r1>0 && c1>0)tempsum+=sum[r1-1][c1-1];
			mx = max(mx,tempsum);
		}
	//	error(mx);
	//	error(k);
		if(mx > k) {
			if(prev+1 == i) {
				return INT_MAX;
			}
			temp2.pb(mp(st,i-1));//error(st);error(i-1);
			prev = i-1;
			i--;
		}
//		error(prev);
	}
	temp2.pb(prev+1,w-1);
	// for(auto x:temp2)cout<<x.fi<<' '<<x.se<<' ';
	// 	cout<<endl;
	ll rr = v.size()-1;
	ll cc = temp2.size()-1;
	// error(rr);
	ll ans = cc+rr;
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll h,w,k;
    cin>>h>>w>>k;
    vector<vector<ll> > v(h,vector<ll>(w,0));
    for(ll i=0;i<h;i++) {
    	string s;
    	cin>>s;
    	for(ll j=0;j<w;j++) {
    		if(s[j]=='1')v[i][j]=1;
    		else v[i][j]=0;
    	}
    }
    vector<vector<ll> > sum(h,std::vector<ll>(w,0));
    sum[0][0]=v[0][0];
    for(ll i=1;i<h;i++) {
    	sum[i][0] = v[i][0]+sum[i-1][0];
    }
    for(ll i=1;i<w;i++) {
    	sum[0][i] = v[0][i]+sum[0][i-1];
    }
    for(ll i=1;i<h;i++) {
    	for(ll j=1;j<w;j++) {
    		sum[i][j] = sum[i-1][j]+sum[i][j-1]+v[i][j]-sum[i-1][j-1];
    	}
    }
    // for(auto x:sum) {
    // 	ContainerError(x);
    // }
    ll minAns = (h-1)+(w-1);
    ll tot = (1ll<<(h-1));
    for(ll i=0;i<tot;i++) {
    	ll ans = sol(i,h,w,sum,k);
    	// error(ans);
    	minAns = min(ans,minAns);
    }
    cout<<minAns;
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll l, r, d;
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long n;
    while (cin >> n)
    {
        long long ans = 0;
        if (n < 3)
            cout << 0 << endl;
        else
        {
 
            for (long long i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    if (i != n / i && i + 1 != n / i) ans += n / i - 1;
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const long long mod = 1000000007;
const int maxn = 1000001;
long long f[maxn], rf[maxn];

long long modpow(long long b, long long e){
	long long ret = 1;
	for(; e; e >>= 1){
		if(e & 1) ret = (ret * b) % mod;
		b = (b * b) % mod;
	}
	return ret;
}

void init(){
	f[0] = rf[0] = 1;
	for(int i = 1; i < maxn; i++){
		f[i] = (i * f[i - 1]) % mod;
		rf[i] = modpow(f[i], mod - 2);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	init();
	
	long long x, y;
	cin >> x >> y;
	if(x > y) swap(x, y);
	
	if((x + y) % 3 || x * 2 < y){
		cout << 0 << endl;
		return 0;
	}
	
	long long n = (x + y) / 3;
	long long ret = (f[n] * ((rf[x - n] * rf[y - n]) % mod)) % mod;
	cout << ret << endl;

	return 0;
} 

Measured memory_bytes: 15872
var ms=[];
var flag=[];
for(var i=0;i<300000;i++)flag[i]=true;
var i=1;
while(true){
   var m=(7*i)-1;
   var s=(7*i)+1;
   if(m>300000)break;
   i++;
   if(flag[m])ms.push(m);
   if(flag[s])ms.push(s);
   var j=2;
   while(true){
      if(m*j>300000)break;
      flag[m*j]=false;
      flag[s*j]=false;
      j++;
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n==1)break;
   var ans=[];
   var i=0;
   ms.some(function(v){
      if(n%v==0)ans.push(v);
      return (n<v);
   });
   console.log(n+": "+ans.join(" "));
}

Measured memory_bytes: 28564
//#include <climits>
#include <vector>
#include <iostream>
#include <sstream>
using namespace std;
const int QUEUE_SIZE = 100000;


//リングバッファ
class MyQueue {
    private:
        int m_head = 0;
        int m_tail = 0;
        vector<pair<string, int>> m_buffer;
    public:
        void init();
        void enqueue(pair<string, int> v);
        pair<string, int> dequeue();
        bool isEmpty();
        bool isFull();
        void show();

};

void MyQueue::init() {
    m_head = 0;
    m_tail = 0;
    m_buffer.resize(QUEUE_SIZE);
}

void MyQueue::enqueue(pair<string, int> v) {
    if(isFull()) {
        cout << "error: queue is full." << endl;
        return;
    }

    m_buffer[m_tail++] = v;

    //終端に来たとき
    if(m_tail == QUEUE_SIZE) {
        m_tail = 0;
    }
}

pair<string, int> MyQueue::dequeue() {
    if(isEmpty()) {
        cout << "error: queue is empty." << endl;

        //空の要素を返す
        pair<string, int> res;
        res.first = "";
        res.second = -1;
        return res;
    }

    pair<string, int> res = m_buffer[m_head];
    m_head++;

    //終端に来たとき
    if(m_head == QUEUE_SIZE) {
        m_head = 0;
    }

    return res;
}


bool MyQueue::isEmpty() {
    return (m_head == m_tail);
}

bool MyQueue::isFull() {
    return (m_head == (m_tail + 1) % QUEUE_SIZE);
}

void MyQueue::show() {
    for (int i = 0; i < m_buffer.size(); ++i)
    {
        if(i == m_tail) {
            break;
        }
        cout << i << " : " << m_buffer[i].first << ", " << m_buffer[i].second << endl;
    }
}



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

    MyQueue queue;
    queue.init();

    for (int i = 0; i < n; ++i)
    {
        string process;
        int    time;
        cin >> process >> time;

        pair<string, int> p;
        p.first  = process;     //プロセス名
        p.second = time; //必要処理時間
        
        queue.enqueue(p);
    }
    //queue.show();


    int total_time = 0; //処理時間を入れる
    while(!queue.isEmpty()) {
        pair<string, int> p = queue.dequeue();

        //1回で処理が終了しないときは実行後にキューの後ろに入れる
        if(p.second > q) {
            //残りの処理時間を減らす
            p.second -= q;

            //処理時間を記録する
            total_time += q;

            //キューに戻す
            queue.enqueue(p);
        } else { //処理が終了するときは、キューには戻さない
            //処理時間を記録する
            total_time += p.second;

            //回答を出力
            cout << p.first << " " << total_time << endl;
        }
    }

    return 0;
}


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

const int N = (int)1e5+5;
const int INF = (int)1e9+5;
int n, k, h[N], dp[N];

int solve(int cur) {
	if (cur == n) return 0;
	if (dp[cur] != -1) return dp[cur];
	int ret = INF;
	for (int i = 1; i <= k; i++) {
		if (cur+i <= n)
			ret = min(ret, solve(cur+i)+abs(h[cur]-h[cur+i]));
		else break;
	}

	return dp[cur] = ret;
}

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

	memset(dp, -1, sizeof dp);
	printf("%d\n", solve(1));

	return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    ll n,k;
    cin >> n;
    vector<ll> a(n),b(n);
    k = n*(n+1)/2;
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(sum%k!=0){
        put("NO");
        return 0;
    }
    ll t = sum/k;
    REP(i,n){
        int next = (i+1)%n;
        b[i]=a[i]-a[next]+t;
    }
    REP(i,n){
        if(b[i]%n!=0||b[i]<0){
            put("NO");
            return 0;
        }
    }
    put("YES");
    return 0;
}


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

int main() {
    //変数の宣言
    double x1, y1, x2, y2;//入力
    double i; //処理用
    double a; //答え用
    
    //入力
    scanf("%lf %lf %lf %lf ", &x1, &y1, &x2, &y2);
    
    //処理
    i = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1));
    a = sqrt(i);
    
    printf("%f\n", a);
    
    return 0;
}



Measured memory_bytes: 2104
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

S = list(input().strip())
T = list(input().strip())

s = set(S)
t = set(T)
f = True
for v in t:
    if v not in s:
        f = False
        break
if f == False:
    print(-1)
    exit()

m = defaultdict(list)
for i in range(len(S)):
    m[S[i]].append(i)

counter = 0
before = -1
for v in T:
    c = m[v]
    index = bisect.bisect_left(c, before+1)
    if index >= len(c):
        before = -1
        index = bisect.bisect_left(c, before+1)
        before = c[index]
        counter += 1
    else:
        before = c[index]

print(counter * len(S) + before + 1)

Measured memory_bytes: 11100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		if (a < 9 && b < 9){
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;
    
int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double c, t;
    t = (m+60*h)*M_PI/360 - m*M_PI/30;
    c = (double)a*a + (double)b*b - 2*a*b*cos(t);
    c = sqrt(c);
    cout << fixed << setprecision(15)<< c << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=1000005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int f[MAXN],pre[MAXN],S[MAXN],n,H,D;
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod,S[i]=S[i-1],ad(S[i],pre[i]);
	n=read();H=read();D=read();
	f[0]=pre[n];
	for(int i=1,sum=f[0];i<=H;i++)
	{
		if(i-D-1>=0)dl(sum,f[i-D-1]);
		if(i!=H)
		{
			f[i]=1LL*sum*S[n]%mod;
			ad(sum,f[i]);
		}else f[i]=sum;
	}pr2(f[H]);
	return 0;
}



Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ans;
typedef long long ll;
ll t[310][310],d[310][310];
char ch[310][310],s[310];
int n;
ll AP_hash(char *s)
{
	ll ans=0;
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	if(i&1)
	ans=~(ans<<7)^s[i]^(ans>>3);
	else ans=(ans<<11)^s[i]^(ans>>5);
	return ans; 
}
int main()
{
	scanf("%d",&n); 
	for(int i=1;i<=n;i++)
	scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		memset(s,0,sizeof(s));
		for(int k=j;k<=j+n-1;k++)
		s[k-j+1]=ch[i][(k-1)%n+1];
		t[i][j]=AP_hash(s);
		memset(s,0,sizeof(s));
		for(int k=i;k<=i+n-1;k++)
		s[k-i+1]=ch[(k-1)%n+1][j];
		d[i][j]=AP_hash(s);
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		int nowi=n-i,nowj=n-j,p=1;
		for(int k=1;k<=n;k++)
		{
			if(d[nowi+1][(nowj+k-1)%n+1]!=t[(nowi+k-1)%n+1][nowj+1])
			{
				p=0;break;
			}
		}
		ans+=p;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

ll f(vi A)
{
    vi B = A;
    SORT(B);
    ll res = 1;
    do
    {
        if (A == B)
        {
            break;
        }
        ++res;
    } while (next_permutation(ALL(B)));
    return res;
}

int main()
{
    IN(ll, N);
    AIN(ll, P, N);
    AIN(ll, Q, N);
    OUT(abs(f(P) - f(Q)))
}

Measured memory_bytes: 3608
#include <iostream>
 
int main() {
  int n, a, b, c, d;
 
  std::cin >> n >> a >> b >> c >> d;
 
  std::string s;
  std::cin >> s;
 
  a--; b--;
  c--; d--;
 
  std::string answer = "Yes";
 
  for (int i = a + 1; i <= c; i++) {
    if (s[i] == '#' && s[i - 1] == '#') {
      answer = "No";
    }
  }
 
  for (int i = b + 1; i <= d; i++) {
    if (s[i] == '#' && s[i - 1] == '#') {
      answer = "No";
    }
  }
 
  if (d < c) {
    bool can_overtake = false;
    for (int i = b; i <= d; i++) {
      if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
        can_overtake = true;
      }
    }
 
    if (!can_overtake) {
      answer = "No";
    }
  }
 
  std::cout << answer << std::endl;
 
  return 0;
}

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

int main(){
    int N;cin>>N;
    vector<int> a(N);
    rep(i,N)cin>>a[i];
    // dp[i][j][k] 寿司が1個残った皿がi個、 2個残った皿がj個、 3個残った皿がk個ある時の期待値
    vector<vector<vector<double>>> dp(N+1,vector<vector<double>>(N+1,vector<double>(N+1,0.0)));

    rep(k,N+1)rep(j,N+1)rep(i,N+1){
        if(i+j+k>N || i+j+k==0)continue;
        int l=N-i-j-k;
        dp[i][j][k]+=((double)N)/(N-l);
        if(i>0)dp[i][j][k]+=i*dp[i-1][j][k]/(N-l);
        if(j>0)dp[i][j][k]+=j*dp[i+1][j-1][k]/(N-l);
        if(k>0)dp[i][j][k]+=k*dp[i][j+1][k-1]/(N-l);
    }
    int cnt1=0,cnt2=0,cnt3=0;
    rep(i,N){
        if(a[i]==1)cnt1++;
        else if(a[i]==2)cnt2++;
        else cnt3++;
    }
    cout<<fixed<<setprecision(15)<<dp[cnt1][cnt2][cnt3]<<endl;
    return 0;
}

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

int main()
{
    string str;

    int sum = 0;
    while( cin >> str )
    {
        int digit = 1;
        for( int i = str.size() - 1; i >= 0; i-- )
        {
            if( '0' <= str[i] && str[i] <= '9' )
            {
                sum += ( str[i] - '0' ) * digit;
                digit *= 10;                        
            }
            else
                digit = 1;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
int main()
{
    long double n;
    cin>>n;
    long double rez;
    rez=n/3;
    long double p;
    p=rez*rez*rez;
    std::cout << std::fixed;
    std::cout << std::setprecision(12);
    std::cout << p;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
 
 
#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(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
 
typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
 
const int maxn = 300010;
const int mod = 1e9+7,MAX = 0x3f3f3f3f;
const double eps = 1e-6;
const ld PI = acos(-1);
 
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
 
template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}
 
int n;
 
ld ans;
 
int X1,Y1,X2,Y2;
 
int x[maxn],y[maxn];
 
int hs[maxn],dp[maxn],c[maxn],id[maxn];
 
ld d1=20.-5.*PI;
ld d2=10.*PI-20;
 
bool cmp(int i,int j){
	return x[i]<x[j]||(x[i]==x[j]&&y[i]<y[j]);
}
 
void add(int x,int y){
	for(;x<=n;x+=x&-x)c[x]=max(c[x],y);
}
 
int query(int x){
	int ans=-MAX;
	for(;x;x-=x&-x)ans=max(ans,c[x]);
	return ans;
}
 
void Work(){
	if(X1==X2){
		ld ok=0;
		REP(i,1,n)if(x[i]==X1&&Y1<=y[i]&&y[i]<=Y2)ok=1;
		printf("%.15Lf\n",(ld)(Y2-Y1)*100.0+ok*d2);
		return;
	}
	if(Y1==Y2){
		ld ok=0;
		REP(i,1,n)if(y[i]==Y1&&X1<=x[i]&&x[i]<=X2)ok=1;
		printf("%.15Lf\n",(ld)(X2-X1)*100.0+ok*d2);
		return;
	}
	n++;x[n]=X1;y[n]=Y1;
	n++;x[n]=X2;y[n]=Y2;
	REP(i,1,n)id[i]=i;
	sort(id+1,id+n+1,cmp);
	REP(i,1,n)hs[i]=y[i],c[i]=-MAX;
	sort(hs+1,hs+n+1);
	REP(tmp,1,n){
		int i=id[tmp];
		if(x[i]==X1&&y[i]==Y1)dp[i]=0;else dp[i]=-MAX;
		int t=lower_bound(hs+1,hs+n+1,y[i])-hs;
		dp[i]=max(dp[i],query(t)+1);
		add(t,dp[i]);
		if(x[i]==X2&&y[i]==Y2)ans=dp[i]-1;
	}
	if(ans==min(X2-X1+1,Y2-Y1+1))printf("%.15Lf\n",(ld)(X2-X1+Y2-Y1)*100.0-(ans-1)*d1+d2);else printf("%.15Lf\n",(ld)(X2-X1+Y2-Y1)*100.0-(ans)*d1);
}
 
void Init(){
	read(X1,Y1,X2,Y2);
	read(n);
	REP(i,1,n)read(x[i],y[i]);
	if(X1>X2)swap(X1,X2),swap(Y1,Y2);
	if(Y1>Y2){
		Y1=100000005-Y1;
		Y2=100000005-Y2;
		REP(i,1,n)y[i]=100000005-y[i];
	}
}
 
int main(){
	Init();
	Work();
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-8;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ull qpow(ull a, ull b)
{
    ull ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
ll cal(ll n, ll x)
{
    ll a, b;
    a = (x - 1) * x / 2;
    b = (n + n - x + 1) * x / 2;
    return b - a + 1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int i = k; i <= n + 1; i++)
    {
        ans += cal(n, i);
        ans %= MOD;
    }
    cout << ans;
}


Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef  pair<int,int> pii;
int H,W;
bool inrange(int y,int x){return(0<=x&&x<W&&0<=y&&y<H);}
int dy[]={0,0,1,-1};
int dx[]={1,-1,0,0};
int main(){
    while(cin>>W>>H,H+W){
        vector<vector<int>>graph(31,vector<int>(31,INF));
        vector<vector<int>>un(31);
        vector<vector<int>>ci(31);
        rep(i,H){
            rep(j,W-1){
                int t; cin>>t;
                ci[i].push_back(t);
            }
            if(i==H-1)continue;
            rep(j,W){
                int t; cin>>t;
                un[i].push_back(t);
                
            }
        }
        rep(j,W)un[H-1].push_back(0);
        queue<pii>que;
        que.push(pii(0,0));
        graph[0][0]=1;
        while(!que.empty()){
            pii now=que.front();que.pop();
            rep(i,4){
                int x=now.second+dx[i];
                int y=now.first+dy[i];
                if(!inrange(y,x))continue;
                if(graph[y][x]!=INF)continue;
                if(i==0||i==1){
                    if(i==1){if(ci[now.first][(now.second-1)]==0){que.push(pii(y,x));cmin(graph[y][x],graph[now.first][now.second]+1);}}
                    else {if(ci[now.first][(now.second)]==0){que.push(pii(y,x));cmin(graph[y][x],graph[now.first][now.second]+1);}}
                }else{
                    if(un[(i==3?now.first-1:now.first)][now.second]==0){que.push(pii(y,x));cmin(graph[y][x],graph[now.first][now.second]+1);}
                }
            }
        }
        cout<<(graph[H-1][W-1]==INF?0:graph[H-1][W-1])<<endl;
    }
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int max = a;
        if (max < b)
            max = b;
        if (max < c)
            max = c;
        int min = a;
        if (min > b)
            min = b;
        if (min > c)
            min = c;
        System.out.println(max - min);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#define N 4005

char buffer[N];
int block[N][N], edge[N][N];

int main()
{
	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	for(int i = 1; i <= n; ++i)
	{
		scanf("%s", buffer + 1);
		for(int j = 1; j <= m; ++j)
			block[i<<1][j<<1] = (buffer[j] == '1');
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			edge[i<<1][j<<1|1] = (block[i<<1][j<<1] && block[i<<1][(j<<1)+2]);
			edge[i<<1|1][j<<1] = (block[i<<1][j<<1] && block[(i<<1)+2][j<<1]);
		}
	for(int i = 1; i <= n<<1; ++i)
	{
		for(int j = 1; j <= m<<1; ++j)
			block[i][j] += block[i][j-1],
			edge[i][j] += edge[i][j-1];
		for(int j = 1; j <= m<<1; ++j)
			block[i][j] += block[i-1][j],
			edge[i][j] += edge[i-1][j];
	}

	int x1, y1, x2, y2;
	while(q--)
	{
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 <<= 1;
		x2 <<= 1;
		y1 <<= 1;
		y2 <<= 1;
		int b = (block[x2][y2] - block[x1-1][y2] - block[x2][y1-1] + block[x1-1][y1-1]);
		int e = (edge[x2][y2] - edge[x1-1][y2] - edge[x2][y1-1] + edge[x1-1][y1-1]);
		printf("%d\n", b - e);
	}

	return 0;
}


Measured memory_bytes: 127104
import numpy as np

n=int(input())
a=0
b=0
ab=0
count=0
for i in range(n):
    s=input()
    if s[0]=='B':
        a+=1
    if s[-1]=='A':
        b+=1
    if s[0]=='B' and s[-1]=='A':
        ab+=1
    for j in range(len(s)-1):
        if s[j]=='A' and s[j+1]=='B':
            count+=1
if a>0 and a==ab and b==ab:
    count+=min([a,b])-1
else:
    count+=min([a,b])
print(count)

Measured memory_bytes: 12424
#include<cstdio>
using namespace std;
int main()
{
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	if(a=='R')
	{
		if(b=='R')
		{
			if(c=='R')
			{
				printf("3\n");
				return 0;
			}
			else
			{
				printf("2\n");
				return 0;
			}
		}
		else
		{
			printf("1\n");
			return 0;
		}
	}
	if(b=='R')
	{
		if(c=='R')
		{
			printf("2\n");
			return 0;
		}
		else
		{
			printf("1\n");
			return 0;
		}
	}
	if(c=='R')
	{
		printf("1\n");
		return 0;
	}
	printf("0\n");
	return 0;
} 

Measured memory_bytes: 1588
x,n = map(int,input().split())
l = list(map(int,input().split()))
l.sort()



result = x
for i in range(100):
    if x in l:
        pass
    else:
        result = x
        break

    if x - i in l:
        pass
    else:
        if x - i >= 0:
            result = x - i
            break

    if x + i in l:
        pass
    else:
        if x + i <= 101:
            result = x + i
            break



print(result)



Measured memory_bytes: 9100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	if (N >= A + B) {
		cout << min(A, B) <<" "<< 0 << endl;
	}
	else {
		cout << min(A, B) << " " << A+B-N << endl;
	}
}


Measured memory_bytes: 3616
x=int(input())

a=[0]*1001

for i in range(1001):
    a[i]=i**5

for i in range(1001):
    for j in range(1001):
        if a[i]-a[j]==x:
            print(i,j)
            exit()
        elif a[i]+a[j]==x:
            if (-1*i)**5-j**5==x:
                print(-1*i,j)
                exit()
            elif i**5-(j*-1)**5==x:
                print(i,-1*j)
                exit()



Measured memory_bytes: 63752
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t N, L[10];
    int64_t i, sum = 0;

    scanf("%"PRId64, &N);
    for (i = 0; i < N; i++) {
        scanf("%"PRId64, &L[i]);
        sum += L[i];
    }

    for (i = 0; i < N; i++) {
        if ((L[i] * 2) >= sum) break;
    }

    if (i == N) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
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;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const ll INF=1e17;
ll dp[400][400][400];
main(){
    int n=in();
    int m=in();
    vec2 G(n),H(n);
    rep(i,m){
        int a=in()-1;
        int b=in()-1;
        G[a].pb(b);
        H[b].eb(a);
    }
    vector<double> dp(n),p(n);
    dp[n-1]=0;
    rep3(i,n-2,0){
        for(auto e:G[i]){
            dp[i]+=dp[e]/G[i].size();
        }
        dp[i]+=1.0;
    }
    double ans=dp[0];
    p[0]=1;
    rep(i,n){
        for(auto e:G[i]){
            p[e]+=p[i]/G[i].size();
        }
    }
    double tmp=dp[0];
    // print(p);
    rep(i,n){
        if(G[i].size()==1)continue;
        for(auto e:G[i]){
            double P=p[i]/G[i].size();
            double t=tmp-P*(dp[e]+1);
            P/=(double)(G[i].size()-1);
            for(auto ee:G[i]){
                if(ee!=e)t+=P*(dp[ee]+1);
            }
            // cout<<i<<" "<<e<<" "<<t<<endl;
            chmin(ans,t);
        }
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 2560
#include<cstdio>

int n,ans;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		int tmp=0;
		for(int j=1; j<=i; j++)if(i%j==0)tmp++;
		if(tmp==8&&i&1)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import math
a = int(input())
lis =[]
ans = 0
for x in range(1,a+1):
    for y in range(1, a+1):
        lis.append(math.gcd(x,y))
for z in range(1, a+1):
    for l in lis:
        ans += math.gcd(z,l)
print(ans)

Measured memory_bytes: 9400
N,K=map(int, input().split())
*A,=map(int, input().split())

def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333)
    x = x + (x >> 4) & 0x0f0f0f0f0f0f0f0f
    x += x >> 8
    x += x >> 16
    x += x >> 32
    return x & 0x7f

ans = 10**18

for p in range(1<<N):
    P=p
    if popcount(p) < K: continue
    cost = 0
    mx = 0
    for a in A:
        flag = p&1
        p >>= 1
        if flag:
            if mx >= a:
                cost += mx + 1 - a
                mx += 1
            else: mx = a
        else: mx = max(mx, a)
    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll x, a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    return 0;

}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
check = [0]*n
count = 1
sum = 0
back = 0
for i in range(n):
  if l[i] == count:
    check[i] = 1
    count += 1
  
    
if check.count(1) == 0:
  print(-1)
elif check.count(1) == n:
  print(0)
else:
  print(check.count(0))

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,m=0;
  cin>>a>>b;
  vector<int> f(a);
  for(int i=0;i<a;i++)
    cin>>f[i];
  sort(f.begin(),f.end());
  for(int i=0;i<b;i++)
    m+=f[i];
  cout<<m;
  return 0;
}

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

int main(){
    int cnt{};
    int n;cin >> n;
    vector<int> s(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> s[i];
    
    int q;cin>>q;
    for(int i = 0; i < q; ++i){
        int t; cin >> t;
        int ng = -1, ok = n;
        while(abs(ok-ng)>1){
            int mid = (ok+ng)/2;
            if(s[mid] == t){
                ++cnt;
                break;
            }
            else if(s[mid] > t){
                ok = mid;
            }
            else{
                ng = mid;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using ll = long long;
#define f first
#define s second

#ifndef LOCAL
	#define cerr if(0) cerr
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	
	int k;
	cin >> k;
	
	int num = 0;
	for (int i = 1; i <= 1e6; ++i) {
		num = (num * 10 + 7) % k;
		if (!num) {
			return cout << i << "\n", 0;
		}
	}
	cout << -1 << "\n";
}


Measured memory_bytes: 3620
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        var b = long.Parse(line[2]);
        var ans = getAns(k, a, b);
        Console.WriteLine(ans);
    }
    static long getAns (long k, long a, long b)
    {
        if (b - a <= 2) return k + 1;
        if (a - 1 > k) return k + 1;
        k -= a - 1;
        var ans = a;
         ans += (b - a) *( k / 2L);
        if (k % 2 == 1) ans++;
        return ans;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e5+10;
const int M=1e9+7;
const int inf=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
int n;
int a,b,c;
int main(){Accel
	cin>>a>>b;
	if(a+b==15)
	cout<<'+';
	else if(a*b==15)cout<<"*";
	else cout<<"x";
	
}

Measured memory_bytes: 256
x=int(input())

a=1
while a**2<=x:
    a+=1
b=1
while b**3<=x:
    b+=1
ans=max((a-1)**2,(b-1)**3)
if 32<=x:
    ans=max(ans,32)
if 243<=x:
    ans=max(ans,243)
if 128<=x:
    ans=max(ans,128)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	int n; cin>>n;
	string ans;
	while(n!=0){
		int x=(n%26==0) ? 26 : n%26;
		ans.pb(x+'a'-1);
		n=(n-x)/26;
	}
	reverse(all(ans));
	cout<<ans<<endl;

}

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

namespace AtCoder
{
    class Program
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

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

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

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

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static string[] ReadStringSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        static void A()
        {
            var AB = ReadLongs();
            var A = AB[0];
            var B = AB[1];
            Console.WriteLine(Math.Max(A - (2 * B), 0));
        }

        static void B()
        {

        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            A();
            //B();
            //C();
            //D();
        }
    }
}


Measured memory_bytes: 28140
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

ideal = (t-a)/0.006

mindif = 100000
ans = 100001
for i in range(n):
  dif = abs(ideal - h[i])
  if dif < mindif:
    ans = i
    mindif = dif

print(ans+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
char a1,a2,a3,b1,b2,b3,c1,c2,c3;
int main()
{
    scanf("%c%c%c\n%c%c%c\n%c%c%c",&a1,&a2,&a3,&b1,&b2,&b3,&c1,&c2,&c3);
    printf("%c%c%c",a1,b2,c3);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int dp[11][1 << 10];

int main() {
  while (true) {
    int w, d, a[10], b[10];
    cin >> w >> d;
    if (w == 0 && d == 0) break;
    rep (i, w) cin >> a[i];
    rep (i, d) cin >> b[i];
    rep (i, 11) rep (j, 1 << 10) dp[i][j] = 1e9;
    dp[0][0] = 0;
    rep (i, d) {
      int mask1 = 0, mask2 = 0;
      rep (j, w) if (a[j] >= b[i]) mask1 |= 1 << j;
      rep (j, w) if (a[j] <= b[i]) mask2 |= 1 << j;
      rep (k, 1 << w) rep (l, 1 << w) if (mask1 & l) {
	int sum = 0;
	rep (j, w) {
	  if (l & 1 << j) {
	    sum += min(a[j], b[i]);
	  }
	}
	dp[i + 1][k | (l & mask2)] = min(dp[i + 1][k | (l & mask2)], dp[i][k] + sum);
      }
    }
    cout << dp[d][(1 << w) - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1204