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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

#define pow10(n) stoll("1"+string(n,'0'))

#define debug(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LNF = 1e18;

void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

const int N = 2e5+7;
int a[N];

int main() {
    
    setIO("input");
    int n; cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];

    sort(a, a+n);
    int take = n-2;
    ll ans = a[n-1];
    for(int i=n-2; i>=0; --i) {
        if(take) ans += a[i], --take;
        if(take) ans += a[i], --take;
    }
    cout << ans;
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		if(i%2){
			if(b%2)b--;
			b/=2;
			a+=b;
		}else{
			if(a%2)a--;
			a/=2;
			b+=a;
		}
	}
	cout<<a<<' '<<b<<endl;
	return 0;
}

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

int main(){
	int n; cin>>n;
	int b[n+2]={};
	b[0]=b[n]=(1<<30);
	for(int i=1; i<n; i++){
		cin>>b[i];
	}
	int ans=0;
	for(int i=0; i<n;i++){
		ans+=min(b[i],b[i+1]);
	}
	cout<<ans<<endl;
}
		
		

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> a(h+1,inf);
    rep(i,n){
        int f,g;
        cin >> f >> g;
        a.at(f)=min(a.at(f),g);
    }
    int t=1,ans=h;
    for (int i=1;i<h;i++){
        if (a.at(i+1)<=t) {ans=i;break;}
        if (a.at(i+1)>t+1) t++;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, m;
int ans[205];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> m;
    n = 2 * n;
    rep(i, n) ans[i] = i + 1;
    rep(i, m) {
        int com;
        cin >> com;
        int nx[205] = {};
        if (com == 0) {
            rep(j, n / 2) nx[j * 2] = ans[j];
            rep(j, n / 2) nx[j * 2 + 1] = ans[n / 2 + j];
        }
        else {
            rep2(j, com, n) nx[j - com] = ans[j];
            rep(j, com) nx[n - com + j] = ans[j];
        }
        rep(j, n) ans[j] = nx[j];
    }
    rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 3112
s = input()
ans = 0
cnt = 0
idx = len(s)

while idx >= 0:
    if s[idx - 2 : idx] == "BC":
        cnt += 1
        idx -= 2
    elif s[idx - 1 : idx] == "A":
        ans += cnt
        idx -= 1
    else:
        idx -= 1
        cnt = 0

print(ans)


Measured memory_bytes: 67592
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	int ml=1;
	vector<int>cnt(3);
	for(int i=0;i<n;i++){
		if(a[i]>cnt[2]||a[i]<cnt[0]){
			cout<<0;
			return;
		}
		int cn=0;
		for(int j=0;j<3;j++){
			if(cnt[j]==a[i]){
				cn++;
			}
		}
		ml=mul(ml,cn);
		for(int j=2;j>=0;j--){
			if(cnt[j]==a[i]){
				cnt[j]++;
				break;
			}
		}
		if(cn==0){
			cout<<0;
			return;
		}
	}
	cout<<ml;	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

const int maxn = 1e6 + 5;
vector<int> g[maxn];
int deg[maxn], fa[maxn];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n - 1 + m; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        --x, --y;
        g[x].push_back(y);
        ++deg[y];
    }
    memset(fa, -1, sizeof(fa));
    queue<int> q;
    for (int i = 0; i < n; ++i) 
        if (deg[i] == 0) q.push(i);
    while (q.size()) {
        int x = q.front(); q.pop();
        for (int i = 0; i < (int)g[x].size(); ++i) {
            int u = g[x][i];
            if ((--deg[u]) == 0) {
                fa[u] = x;
                q.push(u);
            }
        }
    }
    for (int i = 0; i < n; ++i) printf("%d\n", fa[i] + 1);
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int r,x,D;
	cin >> r >> D >> x;
	int ans = x;
	rep(i,10) {
		ans = ans*r - D;
		cout << ans<<"\n";
	}
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	scanf("%d %d %d",&a, &b, &c);
	if(a > b){
	d = a;
	a = b;
	b = d;
	if(b > c){
	d = b;
	b = c;
	c = d;
	}
	}
	if(b > c){
	d = b;
	b = c;
	c = d;
	if(a > b){
	d = a;
	a = b;
	b = d;
	}
	}
	if(a > b){
	d = a;
	a = b;
	b = d;
	if(a > c){
	d = a;
	a = c;
	c = d;
	}
	}
	if(a > c){
	d = a;
	a = c;
	c = d;
	}
	printf("%d %d %d\n",a, b, c);
	
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll X;
  cin >> X;
  cout << (X / 500) * 1000 + ((X % 500) / 5) * 5 << endl;
}

Measured memory_bytes: 256
//https://qiita.com/drken/items/56a6b68edef8fc605821#%E5%95%8F%E9%A1%8C-3-atcoder-abc-122-c---get-ac
//参考にさせて頂いている記事
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    ll N,ANS=0;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    vector<ll> D(N+1,0);
    map<ll,ll> nums;
    for(ll i=0;i<N;i++){
        D[i+1]=D[i]+A[i];
    }
    for(int i=0;i<N+1;i++)nums[D[i]]++;

    //愚直にやるとTLEになるので、累積和の中からイコールとなるものを数え上げ、その組みが何通りあるかを数える。
    for(auto x:nums){
        ll n=x.second;
        ANS+=(n*(n-1))/2;
    }
    cout<<ANS<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 15872
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
bool flag[19999990];
int _prime[19999990];
void get_prime(int maxn)
{
    int i,j;
    for(i=2;i<=maxn;i++)
        if(!flag[i])
        {
            _prime[++_prime[0]]=i;
            for(j=i*i;j<=maxn;j+=i)
                flag[j]=true;
        }
}
int main()
{
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
		cout<<s<<"es"<<endl;
	}
	else cout<<s<<"s"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Graph vector<vector<int>>
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321

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


int main(){
    string N;
    cin >> N;
    ll sum = 0;
    for(int i = 0;i < N.size();i++){
        sum += N[i] -48;
    }
    if(sum%9==0){
        cout << "Yes" << endl;
    }
    else{
        cout <<"No" << endl;
    }
}

Measured memory_bytes: 3720
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n); cin >> as;
    ll ans = 1;
    long double acc2 = 1;
    for(int i = 0; i < n; i++){
        if(as[i] == 0){
            cout << 0 << '\n';
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        acc2 *= as[i];
        printde(acc2, 1e18);
        if(acc2 > 1e18){
            cout << -1 << '\n';
            return 0;
        }
        ans *= as[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if k >= 0:
            if y == 10000*i + 5000*j + 1000*(k):
                print('{0} {1} {2}'.format(i,j,k))
                exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
P p[20001];
int fi[10001],sc[10001];
bool fs[20001];
int V;
vector<int> G[200001];
vector<int> rG[200001];
vector<int> vs;
bool used[200001];
int cmp[200001];

void add_edge(int from,int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v,int k){
	used[v]=true;
	cmp[v]=k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
}

int scc(){
	memset(used,false,sizeof(used));
	vs.clear();
	for(int v=0;v<V;v++){
		if(!used[v])dfs(v);
	}
	memset(used,false,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]])rdfs(vs[i],k++);
	}
	return k;
}
int n_=1;

void update(int a,int b,int v,int k=0,int l=0,int r=n_){
	if(r<=a || b<=l)return;
	if(a<=l && r<=b){
		add_edge(n_*2-1+v,k);
		return;
	}
	update(a,b,v,k*2+1,l,(l+r)/2);
	update(a,b,v,k*2+2,(l+r)/2,r);
}

bool C(ll d){
	n_=1;
	while(n_<n*2)n_*=2;
	V=n_*3;
	for(int i=0;i<V;i++){
		G[i].clear();
		rG[i].clear();
	}
	for(int i=0;i+1<n_;i++){
		add_edge(i,i*2+1);
		add_edge(i,i*2+2);
	}
	for(int i=0;i<n*2;i++){
		if(fs[i]){
			add_edge(n_-1+sc[p[i].second],n_*2-1+i);
			add_edge(n_-1+i,n_*2-1+sc[p[i].second]);
		}
		int l=lower_bound(p,p+2*n,P(p[i].first-d+1,0))-p;
		update(l,i,i);
		int r=lower_bound(p,p+2*n,P(p[i].first+d,0))-p;
		update(i+1,r,i);
	}
	scc();
	for(int i=0;i<n;i++){
		if(cmp[n_-1+i]==cmp[n_*2-1+i])return false;
	}
	return true;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		p[i*2]=P(a,i);
		p[i*2+1]=P(b,i);
	}
	sort(p,p+n*2);
	memset(fi,-1,sizeof(fi));
	for(int i=0;i<n*2;i++){
		if(fi[p[i].second]==-1){
			fi[p[i].second]=i;
			fs[i]=true;
		}else{
			sc[p[i].second]=i;
			fs[i]=false;
		}
	}
	ll l=0,r=INF;
	while(l+1<r){
		ll mid=(l+r)/2LL;
		if(C(mid))l=mid;
		else r=mid;
	}
	printf("%lld\n",l);
	return 0;
}


Measured memory_bytes: 27768
#include <bits/stdc++.h>
#define pb push_back
#define tam 320
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
bool grafo[tam][tam];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    memset(grafo,0,sizeof grafo);
    int iz,der;
    forr(i,0,m)
    {
        cin>>iz>>der;
        grafo[iz][der]=1;
        grafo[der][iz]=1;
    }
    vector<int> v;
    forr(i,1,n+1)
    {
        v.pb(i);
    }
    int tot=0;
    do
    {
        bool nop=false;
        if (v[0]!=1)
            continue;
        forr(i,0,v.size()-1)
        {
            if (grafo[v[i]][v[i+1]]==0)
                nop=1;
        }
        if (nop==0)
            tot++;
    }while(next_permutation(v.begin(),v.end()));
    cout<<tot<<endl;
}

Measured memory_bytes: 384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long xs = sc.nextLong();
		long ys = sc.nextLong();
		long xt = sc.nextLong();
		long yt = sc.nextLong();
		int n= sc.nextInt();
		long[] x = new long[n+2];
		long[] y = new long[n+2];
		long[] r = new long[n+2];
		x[0] = xs;
		x[1] = xt;
		y[0] = ys;
		y[1] = yt;
		r[0] = 0;
		r[1] = 0;
		for(int i=0; i<n; i++){
			x[i+2] = sc.nextLong();
			y[i+2] = sc.nextLong();
			r[i+2] = sc.nextLong();
		}
		sc.close();

		double flen = len(xs, ys, xt, yt, 0, 0);
		double[][] edge = new double[n+2][n+2];
		for(int i=0; i<n+2; i++){
			for(int j=0; j<n+2; j++){
				if(i==j){
					edge[i][j] = 0.0f;
				}else{
					double mlen = len(x[i], y[i], x[j], y[j], r[i], r[j]);
					if(mlen <= flen){
						edge[i][j] = mlen;
					}else{
						edge[i][j] = -1.1f;
					}
				}
			}
		}

		double[] dis = new double[n+2];
		
		dijkstra(edge, 0, dis);
		System.out.printf("%.10f",dis[1]);
	}

	public static double len(long x1, long y1, long x2, long y2, long r1, long r2){
		double md = (double)Math.sqrt((Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2)));
		double md2 = md - (double)r1 - (double)r2;
		if(md2 > 0){
			return md2;
		}else{
			return 0.0f;
		}
	}

	public static void dijkstra(double[][] map,int src,double[] distance) {
		int nTown = distance.length;
		boolean[] fixed = new boolean[nTown]; // 最短距離が確定したかどうか
		for (int i=0; i<nTown; i++) { // 各都市について初期化する
			distance[i] = 10000000000000f; // 最短距離の初期値は無限遠
			fixed[i] = false;	// 最短距離はまだ確定していない
		}
		distance[src] = 0;	// 出発地点までの距離を0とする
		while (true) {
			// 未確定の中で最も近い都市を求める
			int marked = minIndex(distance,fixed);
			if (marked < 0) return; // 全都市が確定した場合
			if (distance[marked]==Integer.MAX_VALUE) return; // 非連結グラフ
			fixed[marked] = true; // その都市までの最短距離は確定となる
			for (int j=0; j<nTown; j++) { // 隣の都市(i)について
				if (map[marked][j]>-0.1f && !fixed[j]) { // 未確定ならば
					// 旗の都市を経由した距離を求める
					double newDistance = distance[marked]+map[marked][j];
					// 今までの距離よりも小さければ、それを覚える
					if (newDistance < distance[j]) distance[j] = newDistance;
				}
			}
		}
	}
	// まだ距離が確定していない都市の中で、もっとも近いものを探す
	static int minIndex(double[] distance,boolean[] fixed) {
		int idx=0;
		for (; idx<fixed.length; idx++)	// 未確定の都市をどれか一つ探す
			if (!fixed[idx]) break;
		if (idx == fixed.length) return -1; // 未確定の都市が存在しなければ-1
		for (int i=idx+1; i<fixed.length; i++) // 距離が小さいものを探す
			if (!fixed[i] && distance[i]<distance[idx]) idx=i;
		return idx;
	}

}

Measured memory_bytes: 22832
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

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

  string ans = "red";
  if(a >= 3200){
  	ans = s;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const mod = 1e9 + 7;
ll n, k, i;
ll ans = 0;
ll nhan(ll x,ll y)
{
    if (y == 0)
        return 0;
    ll t;
    t = nhan(x, y/2) % mod;
    t = t % mod + t % mod;
    if (y % 2 == 0)
        return t % mod;
    else
        return (t % mod + x % mod) % mod;
}

ll mu(ll x, ll y)
{
    if (y == 0)
        return 1;
    ll t;
    t = mu(x, y/2) % mod;
    t = nhan(t, t) % mod;
    if (y % 2 == 0)
        return t % mod;
    else
        return nhan(t,x) % mod;
}

int main()
{
    cin >> n >> k;
    for(i=k; i<=n + 1; i++)
		ans = (ans + nhan(i, n-i+1) + 1) % mod;
		cout << ans % mod;
}


Measured memory_bytes: 3636
from collections import deque

inf = float('inf')
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = 0

# bfs
for si in range(h):
    for sj in range(w):
        if s[si][sj] == '#':
            continue
        dist = [[-inf for j in range(w)] for i in range(h)]
        q = deque()
        
        def update(i, j, x):
            if dist[i][j] != -inf:
                return
            dist[i][j] = x
            q.append([i, j])
        
        update(si, sj, 0)
        
        while len(q):
            i = q[0][0]
            j = q[0][1]
            q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if ni < 0 or ni >= h or nj < 0 or nj >= w:
                    continue
                if s[ni][nj] == '#':
                    continue
                update(ni, nj, dist[i][j] + 1)

        # 2次元配列のmax
        dist_max = max(list(map(lambda x: max(x), dist)))
        ans = max(ans, dist_max)

print(ans)

Measured memory_bytes: 52828
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = nextCharArray();
  var output = 0;
  var mae = "";
  for(var i = 0; i < s.length; i++){
    if(i == 0){
       mae = s[i];
    }else{
       if(mae != s[i]){
          output++;
       }
      mae = s[i];
    }
  }
  myout(output);
}


Measured memory_bytes: 12364
import sys
input=sys.stdin.readline
n=int(input())
p=[int(input()) for _ in range(n)]
q=[0]*(n+1)
for i in range(n):
    q[p[i]]=i+1

q=q[1:]
m=0
k=1
for i in range(1,n):
    if q[i]>q[i-1]:
        k+=1
    else:
        m=max(m,k)
        k=1
m=max(m,k)
print(n-m)


Measured memory_bytes: 53980
#include <cstdio>
#include <cctype>
#include <iostream>
#include <algorithm>
#define reg register
using namespace std;
const int MaxN=101;
struct Node
{
	string s;
	int val,id;
	inline bool operator < (const Node &nt) const
	{
		return s==nt.s?val>nt.val:s<nt.s;
	}
}a[MaxN];
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int n;
	rd(n);
	for(int i=1;i<=n;++i)
	{
		cin>>a[i].s;
		rd(a[i].val);
		a[i].id=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		printf("%d\n",a[i].id);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define N 100009
using namespace std;
int n,a[N];
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	ll Min=2,Max=2;
	for (int i=n;i;i--)
	{
		ll x=Min/a[i]*a[i];
		if (x<Min) x+=a[i];
		ll y=Max/a[i]*a[i]+(a[i]-1);
		Min=x,Max=max(Max,y);
	}
	if (Min>Max) puts("-1");
	else printf("%lld %lld\n",Min,Max);
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  deque<char> D;
  for (char c : S) D.push_back(c);
  bool b = 0;
  int Q;
  cin >> Q;
  while (Q--) {
    int q;
    cin >> q;
    if (q == 1) {
      b ^= 1;
    }
    if (q == 2) {
      int n;
      char c;
      cin >> n >> c;
      if (n == 1) {
        if (!b) D.push_front(c);
        else D.push_back(c);
      }
      if (n == 2) {
        if (!b) D.push_back(c);
        else D.push_front(c);
      }
    }
  }
  if (b) reverse(D.begin(), D.end());
  for (auto d : D) cout << d;
  cout << "\n";
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005,M=200005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,cnt,S,T,ans,a[N],b[N],bela[N],belb[N];
int fir[N],firr[N],siz;
struct edge{int u,v,w,nex;}e[M*2];
void add(int u,int v,int w){
	e[++siz]=(edge){u,v,w,fir[u]};fir[u]=siz;
	e[++siz]=(edge){v,u,0,fir[v]};fir[v]=siz;
}
int dist[N],que[N];
void dec(int x,int fl){e[x].w-=fl;e[x^1].w+=fl;}
bool bfs(int S,int T){
	memset(dist,0x3f,4*(cnt+1));
	int l=1,r=1;que[l]=S;dist[S]=0;
	while (l<=r){
		int x=que[l];
		for (int i=fir[x];i;i=e[i].nex)
		if ((e[i].w)&&(dist[e[i].v]>dist[x]+1)){
			que[++r]=e[i].v;
			dist[e[i].v]=dist[x]+1;
		}
		l++;
	}
	return dist[T]!=inf;
}
int dfs(int x,int flow){
	if (x==T) return flow;
	int fl=0,t=0;
	for (int i=firr[x];i;i=e[i].nex)
	if (e[i].w&&(dist[e[i].v]>dist[x])){
		t=dfs(e[i].v,min(flow-fl,e[i].w));
		dec(i,t);fl+=t;
		if (fl==flow) {firr[x]=i;return fl;}
	}
	firr[x]=0;
	return fl;
}
int dinic(){
	int flow=0;
	while (bfs(S,T)){
		for (int i=0;i<=cnt;i++) firr[i]=fir[i];
		flow+=dfs(S,inf);
		//cerr<<flow<<endl;
	}
	return flow;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	siz=1;
	n=read();
	for (int i=1;i<=n;i++) a[i]=read()+1;
	for (int i=1;i<=n;i++) b[i]=read()+1;
	for (int i=1;i<=n;i++)
	if ((a[i]!=i)&&(!bela[i])){
		cnt++;int x=i;
		while (!bela[x]){bela[x]=cnt;x=a[x];}
	}
	for (int i=1;i<=n;i++)
	if ((b[i]!=i)&&(!belb[i])){
		cnt++;int x=i;
		while (!belb[x]){belb[x]=cnt;x=b[x];}
	}
	S=0;T=cnt+1;cnt++;ans=n;
	for (int i=1;i<=n;i++)
	if (bela[i]&&belb[i]) {
		add(bela[i],belb[i],1);
		if (a[i]==b[i]) add(belb[i],bela[i],1);
	}
	else if (bela[i]) add(bela[i],T,1);
	else if (belb[i]) add(S,belb[i],1);
	else ans--;
	ans-=dinic();
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
	int n, i;
	string str1, str2;
	int a = 0, b = 0;

	cin >> n;

	i = 0;
	while (i < n) {
		cin >> str1 >> str2;

		if (str1 == str2) {
			a += 1;
			b += 1;
		}
		else if (str1 > str2) {
			a += 3;
		}
		else {
			b += 3;
		}
		i++;
	}
	cout << a << " " << b << endl;

    return 0;
}




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

int main() {
  int x, y, z;
  char n, m;
  cin >> x >> n >> y >> m >> z;
  
  if(y > 4) 
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;


ll n, T;
pi A[200005];
void input() {
    cin >> n >> T;
    for (int i = 1; i <= n; i++) {
        cin >> A[i].first >> A[i].second;
        A[i].second += A[i].first + 1;
    }
    sort(A + 1, A + n + 1, [&](pi a, pi b) {
        ll l = a.second * b.first, r = a.first * b.second;
        if (l == r) return a.second < b.second;
        return l < r;
    });
}

ll dp[40];
void calc() {
    for (int i = 1; i < 40; i++) dp[i] = T + 1;
    for (int i = 1; ; i++) {
        ll x, y;
        tie(x, y) = A[i];
        if (x == 0) {
            ll S = 0, ans = 0;
            for (int j = 0; j < 40; j++) {
                if (dp[j] <= T) ans = j;
            }
            for (int j = i; j <= n; j++) {
                S += A[j].second;
                for (int k = 0; k < 40; k++) {
                    if (dp[k] + S <= T) {
                        ans = max(ans, k + j - i + 1ll);
                    }
                }
            }
            cout << ans;
            return;
        }
        for (int j = 39; j > 0; j--) {
            dp[j] = min(dp[j], dp[j - 1] * (x + 1) + y);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    calc();
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int a[200001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, q; cin >> n >> q;
	string s; cin >> s;
	bool f = false;
	if (s[0] == 'A')f = true;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == 'A') {
			f = true;
			a[i] = a[i - 1];
		}
		else if (s[i] == 'C' && f) {
			a[i] = a[i - 1] + 1;
			f = false;
		}
		else {
			f = false;
			a[i] = a[i - 1];
		}
	}

	for (int i = 0; i < q; i++) {
		int x, y; cin >> x >> y;
		x -= 1;
		y -= 1;
		cout << a[y] - a[x] << '\n';
	}



}

Measured memory_bytes: 1488
N=int(input())
S=input()
S_=[]
T=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for j in range(len(S)):
    for i in range(len(T)):
        if S[j] == T[i]:
            if i+N>=len(T):
                S_.append(T[i+N-len(T)])
            else:
                S_.append(T[i+N])
            break

y=""
for x in S_:
    y+=x

print(y)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

ll a, b, x;
int h, w;
string s[100];

int main()
{
	cin >> h >> w;
	for (int i = 0;i < h;i++) cin >> s[i];

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

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう

N=3
M=3
i=0
j=0
k=0



N=int(input())
dis_list=[]
housepos_list=list(map(int, input().split(" ")))#数字の時
#ソートして小さい順から差を求めていけばいいか
housepos_list=sorted(housepos_list)
for i in range(N-1):
    dis_list.append(housepos_list[i]-housepos_list[i+1])
print(abs(sum(dis_list)))
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"




#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
        int n,i,j,v;
        Scanner scan=new Scanner(System.in);
        n=scan.nextInt();
        int m[]=new int[n];
        int k[]=new int[n];
        for(i=0;i<m.length;i++)
        {
        	m[i]=scan.nextInt();
        }
        
        for(i=0;i<m.length-1;i++)
        {
        	System.out.print(m[i]+" ");
        }
        System.out.println(m[n-1]);
        for(i=1;i<=m.length-1;i++)
        {
        	v=m[i];
        	j=i-1;
        	while(j>=0&&m[j]>v)
        	{
        		m[j+1]=m[j];
        		j--;
        	}
        	m[j+1]=v;
        	for(j=0;j<m.length-1;j++)
        	{
        		System.out.print(m[j]+" ");
        	}
        	System.out.println(m[n-1]);
        }
	}
}

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

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  long long int N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long int X = min({A, B, C, D, E});
  cout << (X + N - 1) / X + 4 << endl;
}


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

long long read()
{
	long long x = 0,f = 1;
	char ch= getchar();
	while(ch<'0' || ch>'9')
	{
		if(ch == '-')
			f=-1;
		ch = getchar();
	} 
	while(ch>='0' && ch<='9')
	{
		x = (x<<1) + (x<<3) + ch-'0';
		ch = getchar();
	}
	return x*f;
}

ll dfs(ll b,ll n)
{
	long long ans = 0;
	while(n)
	{
		ans += n % b;
		n /= b;
	}
	return ans;
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n = read(),s =read();
	long long ans = -1;
	ll u = sqrt(n) + 1;
	for(ll i = 2;i <= u;i++)
	{
		if(dfs(i, n) == s)
		{
			ans = i;
			break;
		}
	}
	if(n == s)
		ans = n + 1;
	else if(ans < 0 && n > s)
	{
		ll temp = n - s;	
		ll b = temp / (u - 1) + 1;
		for(ll i = b;i >= 1;i --)
		{	
			if (!(temp % i) && s >= i && (s - i) < (temp / i + 1) && i < (temp / i + 1))
			{
				ans = temp / i + 1;	
				break;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long n,A,B,cnt,ans,head[5005],dp[5005][5005][2],f[5005][2],son[5005],s[5005];
struct edge
{
	long long nxt,to;
}ed[10005];
inline void add(long long x,long long y)
{
	ed[++cnt].to=y;
	ed[cnt].nxt=head[x];
	head[x]=cnt;
	ed[++cnt].to=x;
	ed[cnt].nxt=head[y];
	head[y]=cnt;
}
inline void dfs(long long u,long long fa)
{
	long long i,v,j,k;
	dp[u][1][0]=1;
	son[u]=1;
	for(i=head[u];i;i=ed[i].nxt)
	{
		v=ed[i].to;
		if(v==fa)continue;
		dfs(v,u);
		for(j=1;j<=son[u];j++)
			f[j][0]=dp[u][j][0],dp[u][j][0]=0,f[j][1]=dp[u][j][1],dp[u][j][1]=0;
		for(j=1;j<=son[u];j++)
			for(k=1;k<=son[v];k++)
			{
				dp[u][j+k][0]+=f[j][0]*dp[v][k][0]%mod+f[j][1]*dp[v][k][1]%mod;
				dp[u][j+k][0]%=mod;
				dp[u][j+k][1]+=f[j][0]*dp[v][k][1]%mod+f[j][1]*dp[v][k][0]%mod;
				dp[u][j+k][1]%=mod;
				dp[u][j][0]+=f[j][0]*s[k-1]%mod*dp[v][k][1]%mod+f[j][1]*s[k-1]%mod*dp[v][k][0]%mod;
				dp[u][j][1]+=f[j][1]*s[k-1]%mod*dp[v][k][1]%mod+f[j][0]*s[k-1]%mod*dp[v][k][0]%mod;
				dp[u][j][0]%=mod;
				dp[u][j][1]%=mod;
			}
		son[u]+=son[v];
	}
}
int main()
{
	long long i; 
	cin>>n;
	for(i=1;i<n;i++)
	{
		cin>>A>>B; 
		add(A,B);
	}
	s[1]=1;
	for(i=3;i<=n;i+=2)
		s[i]=s[i-2]*i%mod;
	dfs(1,0);
	for(i=2;i<=n;i+=2)
	{
		ans+=dp[1][i][0]*s[i-1]%mod;
		ans%=mod;
		ans-=dp[1][i][1]*s[i-1]%mod;
		if(ans<0)ans+=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 160924
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
  while(true){
    int x;
    int y;
    int s;
    cin >> x >> y >> s;
    if(x == 0 && y == 0 && s == 0){
      break;
    }

    int ans = 0;
    for(int org_price1 = 1; org_price1 < s; org_price1 ++){
      for(int org_price2 = 1; org_price2 < s; org_price2 ++){
        if(org_price1 * (x + 100) / 100 + org_price2 * (x + 100) / 100 == s){
          ans = max(ans, org_price1 * (y + 100) / 100 + org_price2 * (y + 100) / 100);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3064
def resolve():
    h, w = map(int, input().split())
    maze = [input() for _ in range(h)]
    from collections import deque
    def slv(maze, startx, starty):
        if maze[startx][starty] == "#":
            return 0
        else:
            visited = [[-1] * w for _ in range(h)]
            visited[startx][starty] = 0
            nxt = deque([[startx, starty]])
            while len(nxt) != 0:
                a = nxt.popleft()
                x = a[0]
                y = a[1]
                if 0 <= (x + 1) < h and 0 <= y < w:
                    if maze[x + 1][y] == "." and visited[x + 1][y] == -1:
                        visited[x + 1][y] = visited[x][y] + 1
                        nxt.append([x + 1, y])
                if 0 <= x < h and 0 <= y - 1 < w:
                    if maze[x][y - 1] == "." and visited[x][y - 1] == -1:
                        visited[x][y - 1] = visited[x][y] + 1
                        nxt.append([x, y - 1])
                if 0 <= x - 1 < h and 0 <= y < w:
                    if maze[x - 1][y] == "." and visited[x - 1][y] == -1:
                        visited[x - 1][y] = visited[x][y] + 1
                        nxt.append([x - 1, y])
                if 0 <= x < h and 0 <= y + 1 < w:
                    if maze[x][y + 1] == "." and visited[x][y + 1] == -1:
                        visited[x][y + 1] = visited[x][y] + 1
                        nxt.append([x, y + 1])
            rtn = 0
            for i in range(h):
                rtn = max(rtn, max(visited[i]))
            return rtn

    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(slv(maze, i, j), ans)
    print(ans)
resolve()

Measured memory_bytes: 59356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long x = sc.nextLong();
		long a = 0l, b = 0l;
		ArrayList<Long> list = new ArrayList<>();
		boolean check = false;
		for(long i = -118; i < 120; i++) {
			if(check) break;
			a = i;
			for(long j = -119; j < 119; j++) {
				b = j;
				long y = (long)(Math.pow(a, 5)-Math.pow(b, 5));
				list.add(y);
				if(y == x) {
					check = true;
					break;
				}
			}
		}
		System.out.println(a + " " + b);
	}
	
	static void check(long y) {
		BigDecimal yb = new BigDecimal(String.valueOf(y));
		BigDecimal five = new BigDecimal("5");
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main(){
    int n,d;
    cin >> n >> d;
    int ans = n /(2*d+1);
    if(n%(2*d+1)!=0){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < K; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				int a = sc.nextInt();
				A[a - 1]++;
			}
		}
		sc.close();
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] == 0) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 37256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	// if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	cout << (m == n ? "Yes" : "No");
	
}

 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
def get_dividers(n):
    low_dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    high_dividers = {n // divider for divider in low_dividers}
    return low_dividers | high_dividers


N = int(input())
print(len([i for i in range(105, N + 1, 2) if len(get_dividers(i)) == 8]))


Measured memory_bytes: 2940
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n){
        int x;
        cin >> x;
        a[i] = {x, i + 1};
    }
    sort(ALL(a));

    rep(i, n){
        cout << a[i].second << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using Int = long long;

int main() {
    Int N, W;
    cin >> N >> W;
    vector<Int> w, v;
    for (Int i = 0; i < N; i++) {
        Int x, y;
        cin >> x >> y;
        w.push_back(x);
        v.push_back(y);
    }
    vector<vector<Int>> f(N, vector<Int>(W + 1));
    for (Int x = w[0]; x <= W; x++) {
        f[0][x] = v[0];
    }
    for (Int k = 1; k <= N - 1; k++) {
        for (Int x = 0; x <= W; x++) {
            if (x < w[k]) {
                f[k][x] = f[k - 1][x];
            } else {
                f[k][x] = max(f[k - 1][x - w[k]] + v[k], f[k - 1][x]);
            }
        }
    }
    cout << f[N - 1][W] << endl;
}


Measured memory_bytes: 79488
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong sanjou(llong k) {
	return k * k * k;
}

llong N, K;

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

	llong ans = sanjou(N / K);

	if (K % 2 == 0) {
		ans += sanjou(N / (K / 2) - N / K);
	}

	cout << ans;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  const lines = input.split('\n');
  const [a1, a2, a3] = lines[0].split(' ').map(v => v*1);
  
  console.log(a1 + a2 + a3 < 22 ? 'win' : 'bust');
}

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

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

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) cout << " " << i;
        else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << "\n";
}


Measured memory_bytes: 3112