akhauriyash/Code-Regression huggingface dataset:
#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 n;
    cin >> n;
    int k=0;

    rep(i,9){
        rep(j,9){
            if((i+1)*(j+1)==n){
                k=1;
            }
        }
    }

    if(k==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=505;
const int MAX_C=35;
int n,C;
int D[MAX_C][MAX_C];
int rec[3][MAX_C];
int main()
{
	cin>>n>>C;
	For(i,1,C)
	{
		For(j,1,C)
		{
			cin>>D[i][j];
		}
	}
	For(i,1,n)
	{
		For(j,1,n)
		{
			int c;
			cin>>c;
			rec[(i+j)%3][c]++;
		}
	}
	int ans=INF;
	For(c1,1,C)
	{
		For(c2,1,C)
		{
			For(c3,1,C)
			{
				if(c1==c2 || c2==c3 || c1==c3)continue;
				int cc[3]={c1,c2,c3};
				int res=0;
				rep(i,0,3)
				{
					For(c,1,C)
					{
						res+=rec[i][c]*D[c][cc[i]];
					}
				}
				ans=min(ans,res);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列



#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

string s;
int ans;

int main() {

	cin >> s;
	rep(i, 4) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;



	




	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(){
    int A[N];
    int i,j,a,b;
    
    scanf("%d",&a);
    for(i=0;i<a;i++)
        scanf("%d",&A[i]);
    
    for(i=0;i<a;i++){

        
        b = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > b){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = b;
        for(j=0;j<a-1;j++)
            printf("%d ",A[j]);
        printf("%d\n",A[j]);
    }

    return 0;
    
}



Measured memory_bytes: 2124
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

bool check(vector<int> X, int x){
	int MAX = 32001;
	int cen = MAX/2;
	vector<bool> pos(MAX,false);
	pos[cen] = true;//原点0にいる。
	x += cen;
	int size = X.size();
	for(int i=0;i<size;++i){
		vector<bool> next(MAX,false);
		int move = X[i];
		for(int j=0;j<MAX;++j){
			if( pos[j] ){
				next[j+move] = true;
				next[j-move] = true;
			}
		}
		pos = next;
	}
	return pos[x];
}
void solve(){
	string str;
	int x,y;
	cin>>str>>x>>y;
	int size = str.size();
	vector<int> X,Y;
	int dir = 0;
	int count = 0;
	int pos = 0;
	for(pos;pos<size;pos++){
		if( str[pos]=='F' ){
			--x;
		}else{
			break;
		}
	}
	
	for(int i=pos;i<size;++i){
		if( str[i] == 'T' ){
			if( count == 0 ){
			}else if( dir&1){
				Y.push_back( count );
			}else{
				X.push_back( count );
			}
			count = 0;
			dir = (dir+1)%4;
		}else{//F
			++count;
		}
	}
	if( count == 0 ){
	}else if( dir&1){
		Y.push_back( count );
	}else{
		X.push_back( count );
	}

	if( check( X,x ) == false){
		cout << "No" << endl;
		return;
	}
	if( check( Y,y ) == false){
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

std::pair<double, double> p, q;
double r_p, r_q;
int n;

void solve() {
    double center_dist = pow(p.first - q.first, 2) + pow(p.second - q.second, 2);
    double radius_dist = pow(r_p+r_q, 2);

    if (center_dist > radius_dist) {
        std::cout << 0 << std::endl;
    } else if (center_dist < pow(r_q, 2) + pow(r_p, 2) - 2*r_p*r_q) {
        if (r_p > r_q) {
            std::cout << 2 << std::endl;
        } else {
            std::cout << -2 << std::endl;
        }
    } else {
        std::cout << 1 << std::endl;
    }
}

int main(void) {
    std::cin >> n;
    for (int i=0; i<n; i++) {
        std::cin >> p.first >> p.second >> r_p
                 >> q.first >> q.second >> r_q;
        solve();
    }
}



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

typedef long long ll;

using namespace std;

const ll MOD = 998244353;

#define all(x) (x).begin(), (x).end()
#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    ll ans = 1;
    for (ll i = 0; i < n; i++)
        ans = ans * __gcd(i, a[i]) % MOD;
    cout << ans;
}


Measured memory_bytes: 1024
N = gets.to_i
A = 5.times.map { gets.to_i }

min_i = nil
min_a = Float::INFINITY
A.each_with_index do |a, i|
  if min_a > a
    min_a = a
    min_i = i
  end
end

ans = 4 + N / min_a + (N % min_a != 0 ? 1 : 0)
puts ans


Measured memory_bytes: 1788
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
// char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e5+5;
ll n , x , m ;
void solve(){
  cin>> n >> x >> m ;
  vector<ll> dp;
  set<ll> st ;
  dp.pb(x);
  st.insert(x);
  ll i;
  for(i=1;i<n ;i++){
      x = (x%m*x%m)%m ;
      if(st.find(x)!=st.end()){
        break;   
      }
      st.insert(x);
      dp.push_back(x);
    //   cerr<<x<<" ";
  }
  ll idx1=i , idx2;
  for(ll j=0;j<dp.size();j++){
      if(dp[j]==x){
        idx2=j;
      }
  }
   ll ans=0 , sum=0 , cnt=0, sum2=0 , sum1=0;
  for(ll i=0;i<dp.size(); i++){
     if(i<=idx1)sum2+=dp[i];
 }
 if(idx1>=n){
     cout<<sum2<<endl;
     return ;
 }
//   cerr<<idx1<<" "<<idx2<<endl;
  
  ll ps = idx1-idx2;
  ll ss = (n-i)/ps;
  ll rem = (n-idx1)%ps;
  for(ll i = idx2 ; i<dp.size();i++){
    sum+=dp[i];
    if(cnt<rem)sum1+=dp[i];
    cnt++;
  }
  ans = sum*ss + sum1 + sum2;
  cout<<ans<<endl;
}

int main(){
// 	mahakal();
	fast;
	ll t =1 ;
// 	cin>> t ; 
	while(t--)solve();
// 	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}


Measured memory_bytes: 5860
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << 180 * (n - 2) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main()
{

    int k,s;
    scanf("%d%d",&k,&s);
    int cnt=0;
    for(int i=0; i<=k; i++)
        for(int j=0; j<=k; j++)
        {
            int z=s-i-j;
            if(z>=0&&z<=k)
                cnt++;
        }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

	rep(i, s.size()) {
		cout << 'x';
	}
	cout << endl;


  return 0;
}

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

const int maxn = 200005;
const long long mod = 1000000007;

int n, m;
long long ans = 1;
long long fact[maxn];
unordered_map < int, int > factors;

long long mul_mod (long long a, long long b) {
    return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
    long long res = 1, t = a;
    while (b) {
        if (b & 1)
            res = mul_mod(res, t);
        t = mul_mod(t, t);
        b >>= 1;
    }
    return res;
}

long long div_mod (long long a, long long b) {
    return mul_mod(a, pow_mod(b, mod - 2));
}

void precalc () {
    fact[1] = fact[0] = 1;
    for (int i = 2; i < maxn; ++i)
        fact[i] = mul_mod(fact[i - 1], i);
}

long long ncr_mod (int a, int b) {
    return div_mod(fact[a], mul_mod(fact[b], fact[a - b]));
}

long long ncr_rep_mod (int a, int b) {
    return ncr_mod (a + b - 1, b);
}

signed main () { 
    precalc();
    scanf("%d %d", &n, &m);
    if (m != 1) {
        for (int i = 2; i * i <= m; ++i) {
            while (m % i == 0) {
                m /= i;
                ++factors[i];
            }
        }
        if (m != 1)
            ++factors[m], m = 1;
        for (auto pr: factors) 
            ans = mul_mod(ans, ncr_rep_mod(pr.second + 1, n - 1));
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
"use strict";
function Main(input) {
  const args = input.split(' ').map(m => parseInt(m));
  let N = args.shift();
  let L = args.shift();
  let pie = [];
  for (let i = 0; i < N; i++) {
    pie.push(L + i);
  }
  pie.sort((a, b) => {
    let a1 = a > 0 ? a : -a;
    let b1 = b > 0 ? b : -b;
    return a1 - b1;
  });
  pie.shift();
  console.log(pie.reduce((p ,c) => p + c));
}

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


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define MAXN 10010
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, W, v[MAXN], w[MAXN];

map<pii, ll> dp;

ll go(int x, int m){
	if(m < 1) return 0;
	if(x < 0) return 0;
	if(dp.count({x, m})) return dp[{x, m}];
	if(w[x] > m) return dp[{x, m}] = go(x - 1, m);
	return dp[{x, m}] = max(go(x - 1, m), go(x - 1, m - w[x]) + v[x]);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> W;
    for(int i = 0; i < n; i++){
    	cin >> w[i] >> v[i];
    }
    cout << go(n - 1, W);
}

Measured memory_bytes: 6272
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const ll INF = 	922337203685477580;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
ll dp[100010];

int main(){
  int n;
  cin>>n;
  int sum = 0;
  int flg = 0;
  for(int i = 1; ; i++){
    sum+=i;
    if(sum<n) continue;
    else {
      flg = i;
      break;
    }
  }
  for(int i = 1; i <= flg; i++){
    if(sum-i!=n){
      cout<<i<<endl;
    }
    else{
      continue;
    }
  }
  return 0;
}


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

if n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9:
    print('hon')
elif n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8:
    print('pon')
else:
    print('bon')

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

int main() {
  int A,B;
  cin>>A>>B;
  int count=0;
  for(int i=A;i<=B;i++) {
    if(i/10000%10==i%10 && i/1000%10==i/10%10) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 384
p[]={-1,0,1,-2,2,-2,2,-2,2,-1,0,1};
P[]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
s[]={-1,0,1,-1,0,1,-1,0,1};
S[]={-1,-1,-1,0,0,0,1,1,1};
m[10],M[10];
int D(x,y,d,n){
int i=0,j;
for(;i<12;i++)for(j=0;j<9;j++)if(
	x+p[i]==m[d]+s[j]&&y+P[i]==M[d]+S[j]&&
	0<=x+p[i]&&x+p[i]<10&&
	0<=y+P[i]&&y+P[i]<10
){
	if(d==n-1||D(x+p[i],y+P[i],d+1,n))return 1;
	break;
}
return 0;
}
main(X,Y,n,i,x,y){for(;scanf("%d%d%d",&X,&Y,&n)>2;puts(D(X,Y,0,n)?"OK":"NA"))for(i=0;i<n;i++)scanf("%d%d",m+i,M+i);exit(0);}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N],b[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n1,n2,m;
    while(cin>>n1>>n2>>m)
    {
        int ia=N,ib=N;
        for(int i=1;i<=n1;i++){
            cin>>a[i];
            ia=min(ia,a[i]);
        }
        for(int i=1;i<=n2;i++){
            cin>>b[i];
            ib=min(ib,b[i]);
        }
        int ans=ia+ib,x,y,z;
        for(int i=1;i<=m;i++){
            cin>>x>>y>>z;
            ans=min(ans,a[x]+b[y]-z);
        }

        cout<<ans<<endl;

    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long

ll MOD=1e9+7;
ll a[100005];
using namespace std;

int main(){
	ll n;
	cin>>n;
	
	ll flag=1;//标志 
	ll ans=1;
	
	if(n%2==0){ //偶数 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;//a[7]++
			
			//给出数据x出错 
			if(x>=n || x%2==0 || a[x]>2){ 
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//正确情况 
			if(a[x]==1)
				ans=ans*2%MOD; // a * b %c == a%c * b%c 
		}
	} 
	
	else{ //奇数 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			
			//给出数据x出错 
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//正确情况
			if(x!=0 && a[x]==1)
				ans=ans*2%MOD;
		}
	}
	
	if(flag)
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
s = s.replace("BC", "D")
result = 0
i = 0
while i < len(s)-1:
    if s[i]=="A":
        y = 1
        for j in range(i+1, len(s)):
            i += 1
            if s[j]=="A":
                y += 1
            elif s[j]=="D":
                result += y
            else:
                break
    else:
        i += 1
print(result)

Measured memory_bytes: 42352
// 26.07.2020
// 00:38:12

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    long long n;
    cin >> n;
    long long ans = 1000;
    vector<long long> a(n);
    long long st = 0;

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

    for (int i = 0; i < n; ++i) {
        if (st > 0) {
            ans += st * a[i];
            st = 0;
        }

        if (i != n - 1 && a[i] < a[i + 1]) {
            st = ans / a[i];
            ans -= ans / a[i] * a[i];
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3636
#ifndef ___CLASS_MODINT
#define ___CLASS_MODINT

#include <cstdint>

template<std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::uint64_t n_) : n(n_ % mod) {};
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	std::uint32_t get() const { return n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint binpow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
	modint inv() { return (*this).binpow(mod - 2); }
};

#endif // ___CLASS_MODINT

#include <vector>
#include <iostream>
using namespace std;
using modulo = modint<1000000007>;
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	vector<modulo> fact(N + 1), factinv(N + 1);
	for (int i = 0; i <= N; ++i) {
		fact[i] = (i > 0 ? fact[i - 1] * i : 1);
		factinv[i] = fact[i].inv();
	}
	vector<modulo> dp(N + 1);
	dp[0] = fact[N];
	for (int i = A; i <= B; ++i) {
		for (int j = N; j >= 0; --j) {
			modulo pw = factinv[i].binpow(C);
			for (int k = C; k <= D && k * i <= j; ++k) {
				dp[j] += dp[j - k * i] * pw * factinv[k];
				pw *= factinv[i];
			}
		}
	}
	cout << dp[N].get() << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;

class Main{
		
		 public static void factorial(String x){
		 
		 	int count = Integer.valueOf(x).intValue();
		 	String y;
		 	
		 	BigInteger big_a,big_b;
		 	big_a = new BigInteger(x);
		 	
		 	for(int i=count;i>1;i--){
		 		y = Integer.toString(i-1);
		 		big_b = new BigInteger(y);
		 		big_a = big_a.multiply(big_b);
		 	}
		 	
        	System.out.println(big_a);
    	}
		
				
		public static void main(String args[]) throws IOException{
			String str;

			Scanner scan = new Scanner(System.in);
			
			while(scan.hasNext()){
				str = scan.next();
				factorial(str);
			}
		}
}

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

using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int main() {
  ll n, ans = 1;
  cin >> n;
  vector<int> d;
  while (n / 10) {
    d.push_back(n % 10);
    n = n / 10;
  }
  d.push_back(n);
  for (int i = 0; i < d.size()-1; i++) {
    if (d[i] != 9) {
      cout << (d[d.size() - 1] - 1) + 9 * (d.size() - 1);
      return 0;
    }
  }

  cout << d[d.size() - 1] + 9 * (d.size() - 1) << endl;

  return 0;
}


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

ans = N + 1
for t in range(N + 1):
    cnt = 0
    v6 = t
    while v6 > 0:
        cnt += v6 % 6
        v6 //= 6
    v9 = N - t
    while v9 > 0:
        cnt += v9 % 9
        v9 //= 9
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 2940
n,A,B=map(int,input().split())

bis=1
en=0

if A+2>=B:
  ans=bis+n
else:
  if (n+1)>=(A+2):
    #はじめの交換
    n-=(A-1)+2
    en+=1+n//2
    #print(en,n)
    bis=B+(en-1)*(B-A)
    #print(bis)
    n=n%2
  if n==0:
    ans=bis
  else:
    ans=bis+n
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N; 
  int A, B; cin >> A >> B;
  vi x(N);
  rep(i,N) cin >> x[i];
  int ans = 0;
  rep2(i,1,N){
    if( (x[i]-x[i-1])*A <= B) ans+= (x[i]-x[i-1])*A;
    else ans += B;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3984
n = int(input())
a = list(map(int,input().split()))
ans = 0
if a[0] == 1:
  ans += 1
  a[0] = a[1]
  a[1] = 1
for i in range(1,n):
  if i != n-1:
    if (a[i] == i+1 and a[i+1] == i+2):
      ans += 1
      a[i+1] = a[i]
    elif a[i] == i+1:
      ans += 1
  else:
    if a[i] == i+1:
      ans += 1
print(ans)

Measured memory_bytes: 14008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    
    priority_queue<pair<int,int>> pq;
    int n;
    cin>>n;
    map<int,int> m;
    rep(i,n){
        int t;
        cin>>t;
        m[t]++;
    }
    irep(i,m){
        pq.push(mp(i->second,i->first));
    }
    while(1){
        auto now = pq.top();
        if(now.first == 1)break;
        pq.pop();
        now.first--;
        if(now.first>0)pq.push(now);

        auto a=pq.top();pq.pop();
        a.first--;
        if(a.first>0)pq.push(a);
    }
    fin(pq.size());
    
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> sizee;
    UnionFind(int N): par(N),sizee(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            sizee[i] = -1;
        }
            
    }/*
    void UnionFind2(int N): sizee(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            sizee[i] = -1;
        }
            
    }*/

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        sizee[ry] += sizee[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -sizee[root(x)];
    }
};

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> A(M+1),B(M+1),C(K+1),D(K+1);
    vector<vector<int>> Fr(N+1), Bl(N+1);
    rep(i,M){
        cin >> A[i] >> B[i];
        Fr[A[i]].push_back(B[i]);
        Fr[B[i]].push_back(A[i]);
    }
    rep(i,K){
        cin >> C[i] >> D[i];
        Bl[C[i]].push_back(D[i]);
        Bl[D[i]].push_back(C[i]);
    }
    UnionFind tree(N+1);
    rep(i,M){
        tree.unite(A[i], B[i]);
    }
    rep(i,N){
        int sum = tree.getsize(i+1);
        sum -= Fr[i+1].size();
        rep(j,Bl[i+1].size()){
            if(tree.same(i+1,Bl[i+1][j])){
                sum--;
            }
        }
        cout << sum-1 << " ";

    }
    cout << endl;
}


Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)

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

    string s;
    cin >> s;
    ll n = s.size();
    ll p = 0;
    rep(i,0,n) {
        if (s[i] == 'p') p--;
    }
    cout << (p + n/2) << endl;

    return 0;
}


Measured memory_bytes: 512
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// MACRO

#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

// Global Tables

// Functions

void TC(int t)
{
    long long N, M, val, i;
    cin >> N >> M;
    for(i = 0; i < M; i++)
    {
        cin >> val;
        N -= val;
    }
    //cout.setf(ios::fixed, ios::floatfield);
    //cout.precision(4);
    cout << MAX(N, -1) << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3640
N = int(input())

max_num = 1
max_cnt = 0
for n in range(1, N+1):
    cnt = 0
    tmp_n = n
    while True:
        if tmp_n % 2 == 0:
            cnt += 1
            tmp_n /= 2
        else:
            if cnt > max_cnt:
                max_num = n
                max_cnt = cnt
            break

print(max_num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N; cin >> N;
	int T, A; cin >> T >> A;
	int ans = 0;
	vector<int> H(N);
	vector<int> diff(N);
	int min_diff = 1 << 30;
	for (int i = 0; i < N; ++i) cin >> H[i];	
	for (int i = 0; i < N; ++i) {
		diff[i] = (T * 1000) - (H[i] * 6);
	}
	for (int i = 0; i < N; ++i) {
		int a_diff = abs((A * 1000)  - diff[i]);
		if (a_diff < min_diff) {
			min_diff = a_diff;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

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

int N, M;
int a[100010], b[100010];
pii p[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    p[i] = pii(b[i], a[i]);
  }
  sort(p, p + M);
  int s = 1, ans = 0;
  for (int i = 0; i < N - 1; i++) {
    auto pos = lower_bound(p, p + M, pii(i + 1, i - s + 1));
    if (pos->first == i + 1) {
      ans++;
      s = 1;
    } else {
      s++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

long dp[60][60][50*50+10];

int main() {
  long N, A;
  cin >> N >> A;
  long maxX = A;
  vector<long> X(N);
  for (long& x : X) {
    cin >> x;
    maxX = max(maxX, x);
  }

  for (long j = 0; j <= N; j++) dp[j][0][0] = 1;
  for (long j = 1; j <= N; j++) {
    for (long k = 1; k <= j; k++) {
      for (long s = 0; s <= N*maxX; s++) {
        dp[j][k][s] = dp[j-1][k][s];
        if (X[j-1] <= s) dp[j][k][s] += dp[j-1][k-1][s-X[j-1]];
      }
    }
  }

  long ans = 0;
  for (long i = 1; i <= N; i++) {
    ans += dp[N][i][i*A];
  }
  cout << ans << endl;
}

Measured memory_bytes: 59648
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod        1000000007 
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod;}
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll ans=0;
ll arr[1000000];
vector<ll>root;
map<string,ll>m1;
map<pair<string,ll>,ll>m2;

void comp()
{
	ll i,j,k,n,m;
	string s,t;
	cin>>n;
	vector<ll>v1;
	fl(i,n)
	{
		cin>>j;
		v1.pb(j);
	}
	reverse(all(v1));
	vector<ll>v2(n+1);
	v2[0]=0;
	ll ans=0;
	fli(i,1,n)
	{
		if(v1[i]>=v1[i-1])
		{
			v2[i]=v2[i-1]+1;
		}
		else
		{
			v2[i]=0;
		}
		ans=max(ans,v2[i]);
	}
	cout<<ans<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	if(n%2==0) cout<<n/2-1<<endl;
	else cout<<n/2<<endl;
}


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

int main(){
	ll x,y; cin>>x>>y;
	ll cnt=0, r=x;
	while(r<=y){
		cnt++;
		r*=2;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3640
N = int(input())
A = [int(s) for s in input().split()]

def main():

    a = A
    len_all = len(a)
    len_2 = len(list(filter(lambda n: n % 2 == 0 and n % 4 != 0, a)))
    len_4 = len(list(filter(lambda n: n % 4 == 0, a)))
    len_others = len(list(filter(lambda n: n % 2 != 0, a)))

    if len_all == len_2:
        ans = 'Yes'
    else:
        ans = 'Yes' if len_4 + 1 >= min(1, len_2) + len_others else 'No'
    print(ans)

if __name__ == '__main__':
    main()

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


int main() {
  int N,K;
  cin >> N >> K;
  vector<double> vec(N);
  for (int i = 0;i<N;i++) {
    double a;
    cin >> a;
    double p = (a+1)/2;
    vec.at(i) = p;
  }
  double ans = 0;
  for (int i = 0;i <K;i++) {
    ans += vec.at(i);
  }
  double temp = ans;
  for (int i = 0;i<N-K;i++) {
    temp += vec.at(i+K);
    temp -= vec.at(i);
    ans = max(temp,ans);
  }
  printf("%.16f", ans);

    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 1e18LL

const ll MAX = 1000000000000000000; //1e18

int main(){
    int n; cin >> n;
    vector<ll> ans(n+2);
    ans[0] = 2;
    ans[1] = 1;
    for(int i = 2; i < n+1; i++){
        ans[i] = ans[i-1] + ans[i-2];
    }
    cout << ans[n] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
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; }

signed main()
{
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 1)cout << "IMPOSSIBLE";
	else cout << (A + B) / 2;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
h.sort() # sort

re = 10**9
for i in range(N - K + 1):
    min_h = h[i]
    max_h = h[i+K-1]
    diff = max_h - min_h
    if diff < re:
        re = diff
print(re)

Measured memory_bytes: 7384
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

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

	N := nextInt()

	subordinateCount := make([]int, N)
	for i := 0; i < N; i++ {
		subordinateCount[i] = 0
	}

	for i := 0; i < N-1; i++ {
		subordinateCount[nextInt()-1]++
	}

	for i := 0; i < N; i++ {
		fmt.Println(subordinateCount[i])
	}
}


Measured memory_bytes: 6180
import java.util.Scanner;

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

		long x = sc.nextLong();
		long y = sc.nextLong();

		int count = 1;
		while (x * 2 <= y) {
			x *= 2;
			count++;
		}

		System.out.println(count);

		sc.close();
	}
}

Measured memory_bytes: 22736
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc145/tasks/abc145_c

def solve():
    import math
    from math import factorial
    import itertools

    N = int(input())
    cities = []
    for i in range(N):
        x, y = list(map(int, input().split()))
        cities.append((x,y))

    def calc(b, a):
        bc, ac = cities[b], cities[a]
        return math.sqrt((bc[0]-ac[0])**2 + (bc[1]-ac[1])**2)

    perms = itertools.permutations([i for i in range(N)], r=N)
    total = 0
    for perm in perms:  # 8! = 40320
        a = perm[0]
        for i in range(1, N):  # 8
            b = perm[i]
            total += calc(b, a)
            a = b
    print(total/factorial(N))


def solve2():
    # TLE
    import copy
    import math
    from math import factorial

    N = int(input())
    cities = []
    for i in range(N):
        x, y = list(map(int, input().split()))
        cities.append((x,y))

    def calc(visit):
        d = 0
        a = cities[visit[0]]
        for i in range(1, N):
            b = cities[visit[i]]
            d += math.sqrt((b[0]-a[0])**2 + (b[1]-a[1])**2)
            a = b
        return d

    def rec(visit, visit_set, rest):
        if len(visit) == N:
            return calc(visit)

        total = 0
        for i in rest:
            tmp_visit = copy.deepcopy(visit)
            tmp_visit_set = copy.deepcopy(visit_set)
            tmp_rest = copy.deepcopy(rest)

            if i in tmp_visit_set:
                continue
            tmp_visit.append(i)
            tmp_visit_set.add(i)
            tmp_rest.remove(i)

            total += rec(tmp_visit, tmp_visit_set, tmp_rest)
        return total

    d = rec([], set(), set([i for i in range(N)]))
    print(d/factorial(N))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    vector<char> chars(4);
    for (char& ch : chars) { cin >> ch; }
    vector<int> nums(4);
    for (int i = 0; i < 4; ++i)
    {
        nums[i] = chars[i] - '0';
    }
    // bit全探索
    for (int bit = 0; bit < (1 << 3); ++bit)
    {
        int ans = nums[0];
        for (int i = 1; i < 4; ++i)
        {
            if (bit & (1 << (i - 1)))
            {
                ans += nums[i];
            }
            else
            {
                ans -= nums[i];
            }
        }
        if (ans == 7)
        {
            cout << nums[0];
            for (int i = 1; i < 4; ++i)
            {
                if (bit & (1 << (i - 1)))
                {
                    cout << '+';
                }
                else
                {
                    cout << '-';
                }
                cout << nums[i];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll M=1e9+7;
typedef vector<ll> Vec;
typedef vector<Vec> Mat;

int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        Mat S(n+1,Vec(k+1));
        S[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=k;j++)
            {
                S[i][j]=S[i-1][j]*j%M+S[i-1][j-1];
                S[i][j]%=M;
            }
        }
        ll ans=0;
        for(int i=1;i<=k;i++)
        {
            ans=(ans+S[n][i])%M;
        }
        cout<<ans<<endl;
    }

    return 0;
}




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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  vi32 v(3);
  cin >> v;
  swap(v[0], v[1]);
  swap(v[0], v[2]);
  cout << v << endl;
}

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

#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;

int main() {
	fast;

	string s, t;
	cin >> s >> t;

	int ans = inf;
	for(int i=0; i + t.size() <= s.size(); i++) {
		int cnt = 0;
		for(int j=0; j < t.size(); j++) {
			cnt += s[i+j] != t[j];
		}

		ans = min(cnt, ans);
	}

	cout << ans;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  char s[n+1];
  char c;
  for ( int i = 0;i < n; i++){
    cin >> c ;
    if(i==k-1){s[i] = c + 0x20; }
    else{ s[i] = c;}
  }

  for ( int i = 0; i < n; i++){
    cout << s[i];
  }
 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

int main(int argc, char *argv[]) {
  ll r,d,x;
  cin >> r >> d >> x;
  REP(i,10) {
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define allr(x) (x.rbegin()),(x.rend())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...
string str;
int k;
void test_case(){
    cin>>k>>str;
    if(sz(str) <= k) cout<<str;
    else cout<<str.substr(0,k)<<"...";
}




int main(){
	FAST_IO;
	int tt;
//	cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3580
import Control.Applicative
import Control.Monad

main = do
    (x1:y1:x2:y2:_) <- (map read.words) <$> getLine :: IO [Double]
    
    putStr $ show(sqrt ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) )
    

Measured memory_bytes: 3900
from collections import defaultdict
from heapq import heappop, heappush

N, K = map(int, input().split())
TD = []

for _ in range(N):
  TD.append(tuple(map(int, input().split())))

TD.sort(key = lambda x:x[1], reverse=True)

D = defaultdict(list)
T = [0]*(N+1)
H = []
ans = [0]

for i, td in enumerate(TD):
  t, d = td[0], td[1]
  if i == K:
    break
  T[t] += 1
  D[t].append(d)
  ans[0] += d
  if T[t] >= 2:
    heappush(H, (D[t].pop(), t))
    T[t] -= 1

cnt = sum(1 for c in T if c >= 1)
ans[0] += cnt**2

for i in range(K, N):
  if H:
    t1, d1 = TD[i]
    if T[t1] == 0:
      d2, t2 = heappop(H)
      ans.append(ans[-1] + d1 - d2 + 2*cnt + 1)
      cnt += 1
      T[t1] += 1
  else:
    break

print(max(ans))

Measured memory_bytes: 35092
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans=0;
    rep(i,0,n+1){
        if(i%3&&i%5){ans+=i;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
n, m, x = map(int, input().split())

a = list(map(int, input().split()))

counta=0;
countb=0;

for i in a:
    if (n<i and i<x) or (x<i and i<n):
        counta+=1

for i in a:
    if (0<i and i<x):
        countb+=1


if (counta<countb):
    ans = counta
else:
    ans = countb

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12
//priority_queue<int,vector<int>, greater<int> > q2;



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

	/*
	double A, B;
	cin >> A >> B;
	B += eps;
	int C = A * B;
	cout << C << endl;
	*/

	int A;
	string S;
	cin >> A >> S;


	int ans = A * (S[2] - '0') * 10;
	ans += A * (S[3] - '0');
	ans /= 100;
	ans += A * (S[0] - '0');


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3608