akhauriyash/Code-Regression huggingface dataset:
mod = 1000000007

# 繰り返し二乗法  
def mod_pow(a, n, p):
    if n == 1:
        return a % p
    if n % 2 == 1:
        return (a* mod_pow(a, n - 1, p)) % p
    tmp = mod_pow(a, n / 2, p)
    return ( tmp * tmp ) % p

# 組み合わせ
def mod_cmb(n, k, p):
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if (k > n - k):
        return mod_cmb(n, n - k, p)
    c = d = 1
    for i in range(k):
        c *= (n - i)
        d *= (k - i)
        c %= p
        d %= p
    return c * mod_pow(d, p - 2, p) % p

def main():
    n, a, b = map(int, input().split())

    ans = mod_pow(2, n, mod) - 1

    tmp_a = mod_cmb(n , a, mod)
    tmp_b = mod_cmb(n , b, mod)

    print((ans-tmp_a-tmp_b)%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+1;
 
 
int n,fa[N],tot[N],fr[N],a[N],b[N],c[N],cnt,head[N];
 
struct nd{int ne,to;}e[N];
 
void in(int x,int y){e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;}
int w1[5001],q[N];
void dfs(int x)
{
	for(int i=head[x];i;i=e[i].ne)dfs(e[i].to);
	if(!fr[x])return;
	q[0]=0;
	int ret=tot[x],tot1=0;
	for(int i=head[x];i;i=e[i].ne)
	{
		ret-=min(a[e[i].to],b[e[i].to]);
		q[++q[0]]=abs(a[e[i].to]-b[e[i].to]);
		tot1+=a[e[i].to]+b[e[i].to];
	}
	if(ret<0){cout<<"IMPOSSIBLE";exit(0);}
memset(w1,0,sizeof(w1));
	w1[0]=x;
	for(int i=1;i<=q[0];++i)
	for(int t=5000;t>=q[i];--t)
	if(w1[t-q[i]]==x)w1[t]=x;
	for(int i=ret;i>=0;--i)
	if(w1[i]==x){ret-=i;break;}
	a[x]=tot[x];b[x]=tot1+ret-a[x];
	return;
}
 
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
	scanf("%d",&fa[i]),in(fa[i],i),fr[fa[i]]++;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&tot[i]);
		if(!fr[i])a[i]=tot[i],b[i]=0;
	}
	dfs(1);
	cout<<"POSSIBLE";
 
 
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define read	freopen("input.txt", "r", stdin)
#define write	freopen("output.txt", "w", stdout)
#define mx      5e9

using namespace std;

int main()
{
	// read;
	// write;

    int n, k;
    cin>>n>>k;

    int h[n], ans[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        ans[i] = mx;
    }
    ans[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<min(n,i+k+1); j++){
            ans[j] = min(ans[j], ans[i]+abs(h[j]-h[i]));
        }
    }

    
    cout<<ans[n-1];


}
    



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

int main() {
	long long a;
  cin >> a;
  string b;
  cin >> b;
  string bd;
  
  //cout << a << endl;
  
  for(int i = 0 ; i < b.size() ; i++){
	if(b.at(i)!= '.'){
    	bd += b.at(i);
    }  
  }
  //cout << bd << endl;
  cout << stoi(bd)*a / 100 << endl;
}



Measured memory_bytes: 3624
#include<cstdio>

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int H[N];
	for (int i = 0; i < N; ++i){
		scanf("%d", H + i);
	}
	bool is_good[N];
	for (int i = 0; i < N; ++i){
		is_good[i] = true;
	}
	int ans = N;
	for (int i = 0; i < M; ++i){
		int a, b;
		scanf("%d %d", &a, &b);
		a--;b--;
		if(is_good[a] && H[a] <= H[b]){
			is_good[a] = false;
			ans--;
		}
		if(is_good[b] && H[b] <= H[a]){
			is_good[b] = false;
			ans--;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2208
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=1e5,INF=0x3f3f3f3f;
ll h[MAXN+5];
ll n,Max=-INF;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	for(int i=1;i<=n-1;i++)
	{
		if((h[i]>h[i+1]&&h[i]-1==h[i+1]&&h[i]-1>=Max)||(h[i]<=h[i+1]))
			Max=max(h[i]-1,Max);
		else
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  int sum = 0;
  for(int i = 0; i < m; i++) {
    int x;
    cin >> x;
    sum+=x;
  }
  if(sum > n) cout << -1;
  else cout << n - sum;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%lld", (ll)x * y / __gcd(x, y));
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int n;
    int sum=0;
    cin >> n;
    int on=n;
    int k=log10(n)+1;
    int r=pow(10,k-1);
    while(r>0){
        sum+=n/r;
        n-=r*(n/r);
        r=r/10;
    }
    if(on%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
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;}

int main() {
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  printf(s<t?"Yes\n":"No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

ll mod = 1e9 + 7;


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


	int N, M;
	cin >> N >> M;

	ll kotae = 1;

	rep1(i, N) kotae = kotae * i % mod;
	rep1(i, M) kotae = kotae * i % mod;
	
	if (N == M) kotae = 2 * kotae % mod;
	else if (abs(N - M) != 1) kotae = 0;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int ans = 0;
			for(int i = 1 ; i <= 5 ; i++ ) {
				int v = sc.nextInt();
				
				if ( v == 0 ) {
					ans = i;
				}
			}
			
			System.out.println(ans);
				
		}
	}

}

Measured memory_bytes: 35624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;

  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());

  if (n <= k) {
    cout << 0 << endl;
    return 0;
  }
  
  long long ans = 0; 
  for (int i = 0; i < n; ++i) {
    if (i < k) continue;
    ans += h.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>                                                                                                                                                                                                  
int main(void){
    int citynum, roadnum, i,j;
    int inarr[2];
    scanf("%d %d", &citynum, &roadnum);
    int cityarr[citynum];
    for(i=0;i<citynum;i++){
       cityarr[i] = 0;
    }   
    for(i=0;i<roadnum;i++){
      scanf("%d %d", &inarr[0], &inarr[1]);
      for(j=0;j<2;j++){
              cityarr[inarr[j]-1]++;
      }   
    }   
    for(i=0;i<citynum;i++){
            printf("%d \n",cityarr[i]);
    }   
    return 0;
}                                                                                                                                                                                                       

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  // シミュレーション
  string ans = "Draw";
  bool turn = true;
  for (int i = 0; i < 1000; i++) {
    if (turn) {
      if (A + 1 < B) {
        A++;
      } else {
        if (A - 1 < 1) {
          ans = "Borys";
          break;
        } else {
          A--;
        }
      }
    } else {
      if (B - 1 > A) {
        B--;
      } else {
        if (B + 1 > N) {
          ans = "Alice";
          break;
        } else {
          B++;
        }
      }
    }
    turn = !turn;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>

using namespace std;

int main()
{
  int m,a,b;
  bool pp[100001];
  vector<int> prime;
  {
    memset(pp,true,sizeof(pp));
    pp[0]=pp[1]=false;
    for(int i=2;i<100001;i++)
      {
        if(pp[i])
          {
            prime.push_back(i);
            for(int j=i+i;j<100001;j+=i)
              pp[j]=false;
          }
      }
  }

  for(;cin>>m>>a>>b,m;)
    {
      for(;m>0;)
        {
          for(int i=0;i<prime.size();i++)
            {
              if(prime[i]>m/2)
                break;
              if(m%prime[i]==0 &&  pp[m/prime[i]] &&
                 ((double)a/b) <= ((double)(m/prime[i])/prime[i]) &&
                 ((double)(m/prime[i])/prime[i]) <=1
                 )
                {
                  cout<<m/prime[i]<<" "<<prime[i]<<endl;
                  m=-1;
                  i=-1;
                }
            }
          m--;
        }
    }
}

Measured memory_bytes: 1424
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
  int n;    cin >> n;
  ll ans=0,minimam=INF;
  ll a[n]; rep(i,n){
      cin >> a[i];
      if(a[i]<0)cnt++;
      minimam = min( minimam , abs(a[i]) );
      ans+=abs(a[i]);
      }
      


      if(cnt%2 == 0){
          cout << ans << endl;
          
          return 0;
      }
      if(cnt % 2 == 1){
          cout << ans - 2*minimam << endl;
          
          return 0;
      }

 
}

Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
n = int(input())
a = list(map(int,input().split()))
su = 0
mod = 10**9+7
sum_a = 0
for i in range(n):
    sum_a += a[i]
    sum_a %= mod

for i in range(n-1):
    sum_a -= a[i]
    su += a[i]*sum_a
    su %= mod
print(su)

Measured memory_bytes: 31528
# include <bits/stdc++.h>
# define ll long long int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
  fast
  double n,ans=0;
  cin>>n;
  vector <double> v;
  for(ll i=0;i<n;i++)
  {
    double x;
    cin>>x;
    v.pb(1/x);
  }
  for(ll i=0;i<n;i++)
  {
    //cout<<v[i]<<" ";
    ans+=v[i];
  }
  cout<<setprecision(6)<<(1/ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const long long LINF = 1e18;

const int MAX_N = 100010;
const int MAX_M = 100010;

vector<vector<int>> G;
int dp[MAX_N];

int rec(int v) {
  if (dp[v] != -1) return dp[v];

  int res = 0;
  for (int nv : G[v]) {
    chmax(res, rec(nv) + 1);
  }

  return dp[v] = res;
}

int main()
{
  int N, M; cin >> N >> M;
  G.assign(N, vector<int>());

  for (int i = 0; i < M; ++i) {
    int x, y; cin >> x >> y;
    G[--x].push_back(--y);
  }

  for (int i = 0; i < N; ++i) {
    dp[i] = -1;
  }

  int res = 0;
  for (int v = 0; v < N; ++v) {
    chmax(res, rec(v));
  }

  cout << res << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

bool ok[28];



int n, m;
int a[28];
int b[28];

int rec(int node) {
    int ans = 0;

    bool done = true;
    REP(i, n) {
        if (!ok[i])
            done = false;
    }
    if (done)
        return 1;

    REP(i, m) {
        if (a[i] == node) {
            if (ok[b[i]])
                continue;
            ok[b[i]] = true;
            ans += rec(b[i]);
            ok[b[i]] = false;
        }
        else if (b[i] == node) {
            if (ok[a[i]])
                continue;
            ok[a[i]] = true;
            ans += rec(a[i]);
            ok[a[i]] = false;
        }
    }
    return ans;
}



int main() {
    cin >> n >> m;
    REP(i, m) {
        cin >> a[i] >> b[i];
        a[i] -= 1;
        b[i] -= 1;
    }
    ok[0] = true;
    cout << rec(0) << endl;
    //REP(i, m) {
    //    cout << "ok[" << i << "]:" << ok[i] << endl;
    //}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,i;
    char s[10];
    cin>>a;
    cin>>s;
    if(a>=2800&&a<5000)
    {
        if(a>=3200)
          cout<<s;
        else if(a<3200)
            cout<<"red";
    }

}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n; cin >> n;
  mint ans = 1;
  for(int i = 1; i <= n; ++i) ans *= i;
  cout << ans.x << endl;
}

Measured memory_bytes: 3548
#include<cstdio>
#include<cassert>
#include<vector>
#include<utility>
using namespace std;

template<typename T>
class priority_queue{
	vector<T> v;
public:
	bool empty(){
		return v.empty();
	}
	void push(T a){
		v.push_back(a);
		for(int k=v.size()-1;k;){
			int t=(k-1)/2;
			if(v.at(t)<=v.at(k))break;
			swap(v.at(t),v.at(k));
			k=t;
		}
	}
	T pop(){
		int ls = v.size();
		assert(ls>0);
		T res = v.at(0);
		v.at(0) = v.at(ls-1);
		v.pop_back(); ls--;
		
		for(int k=0;;){
			int l=k*2+1,r=k*2+2;
			int t;
			if(l>=ls)break;
			else if(r>=ls)t = l;
			else{
				t=l;
				if(v.at(l) > v.at(r))t = r;
			}
			if(v.at(k)<=v.at(t))break;
			swap(v.at(k),v.at(t));
			k = t;
		}
		return res;
	}
};


int main(void){
	priority_queue<long long int> que;
	for(;;){
		char s[10];
		scanf("%s",s);
		if(s[0]=='i'){
			long long int a;
			scanf("%lld",&a);
			que.push(-a);
		}
		else if(s[1]=='x'){
			printf("%lld\n",-que.pop());
		}
		else break;
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

struct edge_t {
  int dest;
  int weight;
};

struct vertex_t {
  vector<edge_t> edges;
  vector<int> weight;

  // for dijkstra
  bool done; // confirm or not
  int cost;  // now cost
  int from;

  bool operator<(const vertex_t &another) const { // priority --> min
    return another.cost < cost;                   // order(cost)
  }

  bool operator>(const vertex_t &another) const { // priority --> min
    return another.cost > cost;                   // order(cost)
  }

  bool operator==(const vertex_t &another) const {
    return another.cost == cost; // order(cost)
  }

  vertex_t() {
    cost = INF;
    done = false;
  }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
  int i, j, k, count = 0;
  bool flag = false;
  graph[start].cost = 0;
  REP(i, size) {
    REP(j, size) {
      vertex_t cur = graph[j];
      for (edge_t edge : cur.edges) {
        if (cur.cost + edge.weight < graph[edge.dest].cost) {
          if (i == size - 1)
            flag = true;
          graph[edge.dest].cost = cur.cost + edge.weight;
        }
      }
    }
  }
  if (flag) {
    return 1;
  } else {
    return 0;
  }
}

class tree_t {
  public:
  bool is_leaf;
  tree_t *right;
  tree_t *left;

  tree_t() {
    is_leaf = false;
    right = NULL;
    left = NULL;
  }
};

vector<string> splitstr(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch : s) {
    if (ch == delim) {
      if (!item.empty())
        elems.push_back(item);
      item.clear();
    } else {
      item += ch;
    }
  }
  if (!item.empty())
    elems.push_back(item);
  return elems;
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

unsigned GetDigit(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

int main() {

  int N;

  cin >> N;

  int n = GetDigit(N);

  int sum = 0;

  if (n % 2 == 0) {
    //偶数
    //n-1, n-3, ..., 1
    for (i = n - 1; i > 0; i = i - 2) {
      sum += pow(10, i) - pow(10, i - 1);
    }
  } else {
    //odd
    //n-2, n-4, ..., 1
    for (i = n - 2; i > 0; i = i - 2) {
      sum += pow(10, i) - pow(10, i - 1);
    }
    int tmp = pow(10, n - 1);

    if (n != 1) {
      sum += N - pow(10, n - 1) + 1;
    } else {
      sum += N;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[8] = { 0,0,1,-1, 1,1,-1,-1 };// 前４つで４近傍
const int c_Dy[8] = { 1,-1,0,0 ,1,-1,1,-1};// 全部で８近傍
const int c_div = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846;


int main() {

	int H, W;
	char S[100][100];
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", S[i]);
	}

	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (S[j][i] == '.') {
				int temp = 0;
				for (int k = 0; k < 8; k++) {
					if (S[j +c_Dy[k]][i + c_Dx[k]] =='#'  &&i + c_Dx[k] >= 0 && i + c_Dx[k] < W && j + c_Dy[k] >= 0 && j + c_Dy[k] < H) {
						temp++;
					}
				}
				S[j][i] = temp + 48;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		printf("%s\n", S[i]);
	}








}







Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	int ans = a * 10 + b + c;
	if (ans < a + b * 10 + c) {
		ans = a + b * 10 + c;
	}
	if (ans < a + b + c * 10) {
		ans = a + b + c * 10;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;

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;
}







int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    if(y > 4*x || y < 2*x){
        cout << "No" << endl;
        return 0;
    }
    if((4*x-y) % 2 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int m, d;
  cin >> m >> d;

  int c = 0;
  for (int j = 1; j <= m; ++j) {
    for (int i = 22; i <= d; ++i) {
      int d1 = i % 10;
      int d10 = i / 10;
      if (d1 <= 1 || d10 <= 1) {
        continue;
      } else if (j == d1 * d10) {
        c++;
      }
    }
  }
  p(c);
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int min = A * X + B * Y;
    if (A + B > 2 * C) {
        if (X == Y) min = C * X * 2;
        else if (X > Y) {
            if (A >= C * 2) min = C * X * 2;
            else min = A * (X - Y) + C * Y * 2;
        } else {
            if (B >= C * 2) min = C * Y * 2;
            else min = B * (Y - X) + C * X * 2;
        }
    } 
    cout << min << endl;
}


Measured memory_bytes: 256
# 基本シミュレーション
# Nが小さいので予めN回の入力を保存しておく方針

n = int(input())
inputs = []
for _ in range(n-1):
    c, s, f = map(int, input().split())
    inputs.append([c, s, f])

for i in range(n - 1):
    current_time = 0
    for data in inputs[i:]:
        c, s, f = data
        if current_time < s:
            # 開通式前なので待つ（始発に乗る）
            current_time = s
        else:
            # すでに開通式を終えて運行が開始されている
            # 次に出る最も速いやつまで待つ
            # c + f * nを満たすnのうちcurrenttimeを超える最小のnを求める
            # にぶたんでええか
            left, right = 0, 10 ** 9
            while left < right:
                mid = (left + right) // 2
                if (s + f * mid) >= current_time:
                    right = mid
                else:
                    left = mid + 1
            # left が n
            current_time = s + f * left
        # 乗車時間
        current_time += c
    print(current_time)
# N番目からN番目には0秒
print(0)


Measured memory_bytes: 43740
#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, M;
  cin >> N >> M;
  vector<ll> H(N,true);
  vector<bool> G(N,true);
  rep(i,N) cin >> H[i];
  rep(i,M) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    if(H[A]>H[B]) G[B]=false;
    else if(H[A]<H[B]) G[A]=false;
    else {
      G[A]=false;
      G[B]=false;
    }
  }
  int ans = 0;
  rep(i,N) {
    if(G[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

tuple<int,int,int> dp[3001][3001];
tuple<int,int,char> ans[3001][3001];

string a,b;

tuple<int,int,int> solve(int x, int y){
    if (x == a.size()) return make_tuple(0,-1,-1);
    if (get<0>(dp[x][y]) != 0) return dp[x][y];
    tuple<int,int,int> aux = solve(x+1,y);
    bool v = false;
    for (int i = y; i < b.size() && !v; i++){
        if (a[x] == b[i]) {
            tuple<int,int,int> aux2 = solve(x+1,i+1);
            if (get<0>(aux2)+1 > get<0>(aux)){
                ans[x][y] = make_tuple(get<1>(aux2),get<2>(aux2),a[x]);
                return dp[x][y] = make_tuple(get<0>(aux2)+1,x,y);
            }
            v = true;
        }
    }
    ans[x][y] = make_tuple(get<1>(aux),get<2>(aux),(char)0);
    return dp[x][y] = aux;
}

int main(int argc, char const *argv[]) {
    cin >> a >> b;
    tuple<int,int,int> c = solve(0,0);
    int x = get<1>(c), y = get<2>(c);
    while (x != -1){
        tuple<int,int,char> res = ans[x][y];
        cout << get<2>(res);
        x = get<0>(res);
        y = get<1>(res);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 210304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  rep(i, 5)
  {
    int x;
    cin >> x;
    if (x == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	map<long long, int, greater<long long>> a;
	for (int i = 0; i < n; i++)
	{
		int ai;
		cin >> ai;
		auto it = a.find(ai);
		if (it != a.end()) it->second++;
		else a[ai] = 1;
	}
	long long e[2] = {};
	int i = 0;
	for (auto&& p : a)
	{
		for (int j = i; j < 2 && p.second >= 2; j++)
		{
			e[j] = p.first;
			p.second -= 2;
			i++;
		}
	}
	cout << e[0]*e[1] << endl;
	return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main(void){
	int N,T=0,ans=0;
	int p[100];
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> p[i];
	}
	for(int i=0;i<N+1;i++){
		for(int j=0;j<N;j++){
			if(p[j]>=i){
				ans++;
			}
		}
		if(ans<i){
			break;
		}
		T=i;
		ans=0;
	}
	cout << T << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")"; }
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it; ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k ;
    vi a(n);
    for(int & i : a)
        cin >> i ;
    int ans = (int)1e9;
    for(int i = 0; i + k < n + 1; i++) {
        int l = a[i], r = a[i + k - 1];
        int minimum = min( abs(l) + abs(l - r), abs(r) + abs(l -r) );
        ans = min(ans, minimum);
    }
    cout << ans << '\n';
    return 0;
}












Measured memory_bytes: 640
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c = IL()
ans = sum([a,b,c])-max(a,b,c)
print(ans)

Measured memory_bytes: 21708
#include<iostream>
using namespace std;
int main()
{
	int n,a[1000000],ans=0,t=0,num=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(num>=a[i])
		{
			t++;
			if(t>ans)
			ans = t;
		}
		else if(num<a[i])
		{
			t = 0;
		}
		num = a[i];
	}
	cout<<ans;
	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, a, b;
	cin >>n >>a >>b;
	
	ll w = n/(a+b);
	ll am = n%(a+b);
	cout << w * a + min(a, am) <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;
struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

class combination {
 private:
  vector<mint> fact, finv;

 public:
  combination(int N) {
    fact = finv = vector<mint>(N + 1);
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i <= N; i++) {
      fact[i] = fact[i - 1] * i;
      finv[i] = fact[i].inv();
    }
  }
  mint f(int i) { return fact[i]; }
  mint comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
  }
  mint hcomb(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return comb(n + k - 1, k);
  }
};

int main() {
  //
  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3 > 0) {
    cout << 0 << endl;
    return 0;
  }
  ll total = (x + y) / 3;
  ll diff = y - x;
  ll cnt2 = (total - diff) / 2;
  ll cnt1 = cnt2 + diff;
  // cerr << total << cnt1 << cnt2 << endl;
  combination comb(total + 1);
  mint ans = comb.comb(total, cnt1);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 10752
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int n,m;
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int t;
		cin>>t;
		n-=t;
	}
	if (n<0) n=-1;


	cout<< n<< endl;
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int q,h,s,d,n;
    scanf("%d%d%d%d%d",&q,&h,&s,&d,&n);
    s = min(min(q*4,h*2),s);
    if(s*2 <= d)printf("%lld\n",1ll*n*s);
    else printf("%lld\n",1ll*(n/2)*d+(n%2)*s);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;


int main()
{
	int n,x;
	cin>>n>>x;
	int *D = new int[n+1];
	D[0] = 0;
	rep(i,n){
		int l;
		cin>>l;
		D[i+1] = D[i] + l;
	}
	int bound = 0;
	for(int i = 0; i <= n; i++){
		if( D[i] <= x) bound++;
	}
	cout<<bound<<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 unsigned long long ull;

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

    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    rep(i, D) cin >> p[i] >> c[i];

    int res = 1e9;

    rep (mask, 1 << D) {
        int score = 0; // All or nothing
        int numSolved = 0, maxRestP = -1;

        rep (i, D) {
            if (mask & 1 << i) {
                score += 100*(i+1) * p[i] + c[i];
                numSolved += p[i];
            }
            else
                maxRestP = i;
        }

        if (score < G) {
            int scoreMaxRestP = 100 * (maxRestP + 1);
            int numNeeded = (G - score + scoreMaxRestP - 1) / scoreMaxRestP;
            if (numNeeded >= p[maxRestP])
                continue;
            numSolved += numNeeded;
        }

        res = min(res, numSolved);
    }

    cout << res << "\n";
}

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

int main() {

int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if((a+b)>(c+d)){cout<<"Left"<<endl;}
  else if((a+b)==(c+d)){cout<<"Balanced"<<endl;}
  else{cout<<"Right"<<endl;}

}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN(n);
  if(n>=1000) OUT("ABD");
  else OUT("ABC");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int min(int a, int b){
    return (a<b?a:b);
}
int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0;  i < n;  i++)
        cin >> arr[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i = 2;  i < n;  i++){
        dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i]), dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout << dp[n-1] << endl;
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

const int N = 1000;
int n, m;
vector<int> graph[N+1];
vector<int> ans;
map<int, int> used;

void dfs(int cur, map<int, int>& seen, int depth) {
    used[cur] = depth;
    seen.insert({cur, depth});
    int node = 0;
    for(int child : graph[cur]) {
        if(seen.count(child)) {
            node = max(node, seen[child]);
        }
    }
    if(ans.empty() && node != 0) {
        for(auto p : seen) {
            if(p.second >= node) ans.push_back(p.first);
        }
        return;
    }
    vector<int> puts;
    for(int child : graph[cur]) {
        if(!used.count(child)) {
            puts.push_back(child);
            used[child] = depth+1;
        }
    }
    for(int child : graph[cur]) {
        if(used[child] == depth+1) {
            dfs(child, seen, depth+1);
            if(!ans.empty()) return;
        }
    }
    for(int p : puts) used.erase(p);
    seen.erase(cur);
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
    }

    for(int i = 1; i <= n; ++i) {
        if(ans.empty() && !used.count(i)) {
            map<int, int> seen;
            dfs(i, seen, 1);
        }
    }
    
    if(ans.empty()) {
        cout << -1 << endl;
    } else {
        cout << ans.size() << '\n';
        for(int a :ans) cout << a << '\n';
    }
    
    return 0;
}


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

using namespace std;

int main(){
  int q,x;
  char c;
  vector <int> v;
  
  cin>>q;
  for(int i=0; i<q; i++){
    //    cout<<"#"<<endl;
    cin >>c;
    if(c=='0'){
      cin >>x;
      v.push_back(x);
    }
    else if(c=='1'){
      cin>>x;
      cout << v[x]<<endl;
    }
    else if(c=='2'){
      v.pop_back();

    }



  }


  return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;
    int count = 0;
    string back;
    for(int i=0; i<n; i++){
      string s;
      cin >> s;
      if(s == "lu" && back == "ru") count++;
      if(s == "ru" && back == "lu") count++;
      if(s == "ld" && back == "rd") count++;
      if(s == "rd" && back == "ld") count++;
      back = s;
    }
    cout << count << endl;
  }
  return 0;
}


Measured memory_bytes: 3140
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var ans = 0;

            var a = cin.ReadInt;
            var b = cin.ReadInt;

            int inta = 0;
            int intb = 0;

            for(var i = 1; i <= b; i++) 
            {
                inta = inta + a;
                inta = inta * 10;
            }

            for (var i = 1; i <= a; i++)
            {
                intb = intb + b;
                intb = intb * 10;
            }

            inta = inta / 10;
            intb = intb / 10;

            if (inta < intb)
            {
                WriteLine(intb.ToString());
            }
            else
            {
                WriteLine(inta.ToString());
            }

            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int a,b;
int cnt = 0;
char s[5],sr[5];
int main() {
    cin >> a >> b;
    rep(i,a,b+1){
        int c = 0;
        int ii = i;
        rep(j,0,5){
            s[j] = ii%10;
            ii /= 10;
        }
        rep(k,0,5){
            sr[k] = s[4-k];
        }
        rep(l,0,5){
            if(s[l] == sr[l]){
                c++;
                if(c == 5){
                    cnt++;
                }
            }
        }
    }
    pout(cnt);
    return 0;
}

Measured memory_bytes: 256
#CODE FESTIVAL 2017 qual A
"""
やるか・やらないかだけで、結果的にできるものは同じ。順序に関係はない。
縦・横にいくつ使うかを全探索で求まった。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m,k = map(int,readline().split())

for i in range(n+1):
    for j in range(m+1):
        dup = i*j*2
        res = i*m + j*n - dup
        if k == res:
            print("Yes")
            exit()

print("No")

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


	
int main()
{ 
	int r;
	cin>>r;
	double pi=3.1415926;
	double ans=2*r*pi;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3764