akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
using namespace std;

int A[300][300] = {0};
set<int> removedSet;

int main()
{
    // 整数の入力
    string S;
    long long w,i;
    cin >> S;
    cin >> w;
    i = 0;
    while (i < S.length()){
        cout << S[i];
        i += w;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
s = list(input())

cant = False
if c>d:
        cant = True
        for i in range(max(0,b-2), min(d-1, n-2)):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False

for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True
for i in range(a-1, c-1):
        if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])

Measured memory_bytes: 4916
#include <iostream>

using namespace std;

namespace L{
template <class T> inline T abs(T x)     { return x>0 ? x : -x; }
template <class T> inline T max(T x, T y){ return x>y ? x : y ; }
template <class T> inline T min(T x, T y){ return x>y ? y : x ; }
}


main(){
        int INF=0x7fffffff;

        int N, K;
        cin >> N >> K;

        int h[101000], dp[101000];
        for(int i=0; i<N; i++)   cin >> h[i];
        for(int i=0; i<N+K; i++) dp[i] = INF;


        dp[0] = 0;
        for(int i=0; i<N; i++){
                for(int j=1; j<=K; j++){
                        dp[i+j] = L::min(dp[i+j], dp[i]+L::abs(h[i]-h[i+j])) ;
                }
        }
        cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
k = int(input())
a, b=map(int,input().split())

fly=0
l=[]
while fly<b:
    fly += k
    l.append(fly)
    
if len(l)==1:
    if k>=a and k<=b:
        print('OK')
    else:
        print('NG')
else:
    if l[-1]>=a and l[-1]<=b:
        print('OK')
    elif l[-2]>=a and l[-2]<=b:
        print('OK')
    else:
        print('NG')

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int n,k;
    cin>>n>>k;
    int ans = 0;
    rep(i,k,n+2)
    {
        ans = (ans + ((n+1)*i - i*i + 1))%mod;
    }

    cout<<ans<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int n;
		cin >> n;
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		auto max = max_element(a.begin(),a.end());
		int sum = accumulate(a.begin(),a.end(),0);
		if(sum > *max * 2){
				cout << "Yes";
		}else{
				cout << "No";
		}
}



Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = float('inf')
for i in range(1,int(math.sqrt(n))+1):
    if n%i == 0:
        res = min(res, i + n/i)
print(int(res-2))


Measured memory_bytes: 40808
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}


int main()
{
    int n;
    cin >> n;
    vector<int> h(n) , cost(n , 1e9+7);
    for(int i = 0 ; i < n ; i++) cin >> h[i];
    cost[0] = 0;
    for(int i = 0 ; i < n-1 ; i ++){
        for(int j = i+1 ; j <= i+2 ; j++){
            if(j < n) cost[j] = min(cost[j] , cost[i] + abs(h[i] - h[j]));
        }
    }
    cout << cost[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
#define MO 1000000007
#define MAXM 131072
#define MAXN 43
#define LL long long
LL dp[MAXN][MAXM];
LL bit[MAXN];
int x,y,z,n;
bool check(int a)
{
	if((a&(1<<(x+y+z-1)))&&(a&(1<<(y+z-1)))&&(a&(1<<(z-1))))
		return 1;
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	bit[0]=1;
	for(int i=1;i<=n;i++)
		bit[i]=10*bit[i-1]%MO;
	dp[0][0]=1;
	LL ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<MAXM;j++)
			if(dp[i][j])
			{
				for(int k=1;k<=10;k++)
				{
					int j1=((j<<k)+(1<<(k-1)))%MAXM;
					if(check(j1))
					{
						ans+=dp[i][j]*bit[n-i-1]%MO;
						ans%=MO;
					}
					else
					{
						dp[i+1][j1]+=dp[i][j];
						dp[i+1][j1]%=MO;
					}
				}
			}
	printf("%lld\n",ans);
}

Measured memory_bytes: 41088
#include <stdio.h>


int partition(int A[],int p,int r)
{
  
  int x, i, j, a;
  
  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j] <= x){
      i = i+1;
      a = A[i];
      A[i] = A[j];
      A[j] = a;
    }
  }
  a = A[i+1];
  A[i+1] = A[r];
  A[r] = a;
  
  return i+1;
  
}


int main()
{

  int n, i, q;

  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  q = partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i==q) printf("[%d] ",A[i]);
    else if(i==n-1) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }

  return 0;
  
}



Measured memory_bytes: 2156
#include <iostream>
using namespace std;
int N,S;
int main() {
 while (cin >> N && N>0) {
  int max = 0;
  int min = 1000;
  int sum = 0;
  int answer;
  for (int i=0; i<N; ++i) {
   cin >> S;
   sum += S;
   if(max < S) max = S;
   if(min > S) min = S;
  }
  answer = (int)((sum-max-min)/(N-2));
  cout << answer << endl;
 }
}
  


Measured memory_bytes: 1160
S = input()
for_num = 0

for i in S:
  for_num += 1
  if for_num % 2 == 0 and i == "R":
      print("No")
      break
  elif for_num % 2 != 0 and i == "L":
      print("No")
      break
  elif for_num == len(S):
    print("Yes")

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

main() {
  string S; cin >> S;
  int init = (S[0] == 'B') ? 0 : 1;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) if (S[i] != "BW"[(init + ans) % 2]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=abs(a-c);
	int y=abs(b-d);
	for(int i=1;i<=y;i++)
	cout<<"U";
	for(int i=1;i<=x;i++)
	cout<<"R";
	for(int i=1;i<=y;i++)
	cout<<"D";
	for(int i=1;i<=x+1;i++)
	cout<<"L";
	for(int i=1;i<=y+1;i++)
	cout<<"U";
	for(int i=1;i<=x+1;i++)
	cout<<"R";
	cout<<"DR";
	for(int i=1;i<=y+1;i++)
	cout<<"D";
	for(int i=1;i<=x+1;i++)
	cout<<"L";
	cout<<"U";
	

}

Measured memory_bytes: 256
program main
  
  implicit none
  integer(8) :: a,b,n
  real(8) :: ans
  
  read(*,*) a,b,n
  
  if( n >= b ) then
    ans = real(b-1,kind=8)/real(b,kind=8)
    ans = real( a, kind=8 ) * ans 
  else
    ans = real(n,kind =8)/real(b,kind=8) - real( int( n/b, kind=8 ), kind=8 )
    ans = real( a, kind=8 ) * ans 
  end if
  
  print*, int(ans, kind=8) 
  
end program main



Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=998244353;
const int maxn=205;
int x[maxn],y[maxn];
int two[maxn];
int main()
{
    two[0]=1;
    for(int i=1;i<maxn;i++) two[i]=two[i-1]*2%mod;
    int n;
    cin>>n;
    ll ans=(two[n]-n+mod-1)%mod;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int cc=0;
            for(int k=j+1;k<n;k++)
            {
                if((y[k]-y[j])*(x[j]-x[i])==((x[k]-x[j])*(y[j]-y[i]))) cc++;
            }
            ans=(ans-two[cc]+mod)%mod;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	while (true)
	{
		int n, m;
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0)
			break;

		bool p[1000];
		fill(p, p+n, true);
		for (int i = 0, c = 0, esc = 0; ; ++i)
		{
			if (i == n)
				i = 0;
			if (p[i])
			{
				if (++c % m == 0)
				{
					p[i] = false;
					if (++esc == n)
					{
						printf("%d\n", i+1);
						break;
					}
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vvi tree(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    vi sum(n),par(n),dist(n);
    par[0] = -1;
    function<void(int,int,int)> dfs = [&](int now,int p,int d) {
        int nsum = 1;
        dist[now] = d;
        for(int i : tree[now]) {
            if(i == p) continue;
            dfs(i,now,d+1);
            nsum += sum[i];
            par[i] = now;
        }
        sum[now] = nsum;
    };
    dfs(0,-1,0);
    assert(sum[0] == n);
    int now = n-1;
    int ndis = 1;
    while(true) {
        if(ndis < dist[par[now]]) {
            ndis++;
            now = par[now];
        } else break;
    }
    cout << (sum[now] >= (n-sum[now]) ? "Snuke" : "Fennec") << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N;
	LL L;
	cin >> N >> L;
	vector<LL> a(N);
	rep(i,N) cin >> a[i];
	LL M=0, num=0;
	rep(i,N-1){
		if(M<a[i]+a[i+1]){
			M=a[i]+a[i+1];
			num=i;
		}
	}
	if(M<L) cout << "Impossible" << endl;
	else{
		cout << "Possible" << endl;
		rep(i,num) cout << i+1 << endl;
		for(int i=N-1; i>num+1; i--) cout << i << endl;
		cout << num+1 << endl;
	}

	return 0;
}

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


int main(){
  string N;
  cin >> N;
  switch(N.back()){
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
    cout << "hon" << endl;
    break;
    case '0':
    case '1':
    case '6':
    case '8':
    cout << "pon" << endl;
    break;
    case '3':
    cout << "bon" << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];

    LL dp[50][2];
    memset(dp, -1, sizeof(dp));
    dp[45][1] = 0;
    for(LL i=45; i>=0; i--){
        LL mask = 1LL<<i;
        int n1 = 0;
        rep(j, n)if(a[j] & mask) n1++;
        int n0 = n - n1;
        if(dp[i+1][0] >= 0) dp[i][0] = max(dp[i][0], dp[i+1][0] + mask*max(n0, n1));
        if(dp[i+1][1] >= 0){
            if(k & mask){
                // 1が選択できる -> 0の個数分1になる
                dp[i][1] = max(dp[i][1], dp[i+1][1] + mask*n0);
                dp[i][0] = max(dp[i][0], dp[i+1][1] + mask*n1);
            }else{
                dp[i][1] = max(dp[i][1], dp[i+1][1] + mask*n1);
            }
        }
        // cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int i,n;
  cin>>n;
  int a[n],c=0;
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++)
  {
		if(i%2==0&&a[i]%2!=0)
          c++;
  }
  cout<<c<<endl;
}
	
  
  


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int main(){
  int N;
  cin>>N;
  vector<int> PPP(N);
  for(int i=0; i<N ;i++){
    cin>> PPP.at(i) ;
  }
  bool ans =true;
  int count=0;
  for(int i=0;i<N;i++){
   if(PPP.at(i)!=i+1){
     if(PPP.at(PPP.at(i)-1) !=i+1 ){
       ans =false;
       break;
     }
     else if(PPP.at(PPP.at(i)-1) ==i+1 ){
       count ++;
     }
   }
  }
  if(count ==2){
    cout <<"YES"<<endl;
  }
  else if(ans && count ==0){
    cout <<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

int main()
{
	int n;
	
	while(scanf("%d", &n),n != -1){
		char adic[1000] = {0};
		int i = 0;
		
		if(n == 0)printf("0\n");
		else{
		while(n > 0){
			adic[i] = n%4 + '0';
			n /= 4;
			i++;
		}
		
		reverse(adic, adic+i);
		
		printf("%s\n", adic);
		}
	}
	
	return(0);
}

Measured memory_bytes: 1008
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll r=0;
  ll sum=a[0],xorsum=a[0];
  ll ans=0;
  rep(i,n){
    while(sum==xorsum&&r<n-1){
      r++;
      sum+=a[r];
      xorsum^=a[r];
    }
    if(r==n-1){
      if(sum!=xorsum){
        sum-=a[r];
        xorsum^=a[r];
        r--;
      }
    }
    else{
      sum-=a[r];
      xorsum^=a[r];
      r--;
    }
    ans+=r-i+1;
    sum-=a[i];
    xorsum^=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4816
//............Created by:- Arth Raj...........................//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<pair<int,int>>
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=b;i>=a;i--)
#define ld long double
#define tl tuple<ll,ll,ll>
#define all(x) (x).begin(),(x).end()
#define bs(x,b) binary_search(all(x),b)
#define vip vector<pair<int,pair<int,int>>>
#define pip pair<int,pair<int,int>>
#define INF 1e18
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll abm(ll a, ll b, ll m) {ll ans = 1; a = a % m; while (b > 0) {if (b & 1)ans = (ans * a) % m; a = (a * a) % m; b = b / 2;} return ans % m;}
ll ncr(ll n, ll r, ll m) {if (r == 0)return 1; ll fac[n + 5]; fac[0] = 1; lp(i, 1, n + 1) {fac[i] = fac[i - 1] * i % m;} return (((fac[n] * abm(fac[r], m - 2, m)) % m) * (abm(fac[n - r], m - 2, m))) % m;}
vi graph[100005];
bool vis[100005];
void dfs(int x)
{
	vis[x] = 1;
	lp(i, 0, graph[x].size())
	{
		int u = graph[x][i];
		if (!vis[u])
		{
			dfs(u);
		}
	}
}
int main()
{
	int n, m;
	cin >> n >> m;
	int u, v;
	lp(i, 0, m)
	{
		cin >> u >> v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	lp(i, 0, n + 1)
	vis[i] = 0;
	int ans = 0;
	lp(i, 1, n + 1)
	{
		if (!vis[i])
		{
			ans++;
			dfs(i);
		}
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 9692
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
sum_a=sum(a)
c=sum_a/(4*m)

p=0

for i in range(n):
    if a[i]>=c:
        p+=1
if p>=m:
    print('Yes')
else:
    print('No')

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

const int maxn=2e5+10;

int n,m,v,x[maxn],Lg[19][maxn],Rg[19][maxn];
int L[1<<18],R[1<<18];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,j,v0,S;
	scanf("%d%d",&n,&v);
	for (i=1;i<=n;i++)
		scanf("%d",&x[i]);
	x[0]=x[1]-23333333;
	x[n+1]=x[n]+23333333;
	for (v0=v,m=0;;v0>>=1,m++)
	{
		j=1;
		for (i=j=1;i<=n;i++)
		{
			j=max(i,j);
			while (x[j+1]-x[j]<=v0) j++;
			Rg[m][i]=j;
		}
		for (i=j=n;i>=1;i--)
		{
			j=min(i,j);
			while (x[j]-x[j-1]<=v0) j--;
			Lg[m][i]=j;
		}
		if (!v0) break;
	}
	int cnt=0;
	for (i=1;i<=n;i=j+1)
		j=Rg[0][i],cnt++;
	if (cnt>m+1)
	{
		for (i=1;i<=n;i++)
			puts("Impossible");
		return 0;
	}
	for (S=0;S<1<<m;S++)
		R[S]=0,L[S]=n+1;
	for (S=1;S<1<<m;S++)
	{
		for (i=0;i<m;i++)
			if ((S>>i)&1)
			{
				R[S]=max(R[S],Rg[i+1][R[S-(1<<i)]+1]);
				L[S]=min(L[S],Lg[i+1][L[S-(1<<i)]-1]);
			}
	}
	for (i=1;i<=n;i=j+1)
	{
		j=Rg[0][i];
		bool flag=0;
		for (S=0;S<1<<m;S++)
			flag|=R[S]+1>=i&&L[(1<<m)-1-S]-1<=j;
		for (int x=i;x<=j;x++)
			puts(flag?"Possible":"Impossible");
	}
}


Measured memory_bytes: 34944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

    double c = A*100/8;
    for(int i=c-13; i<=c+13; i++){
        if(i*8/100==A && i/10==B){
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	var tmp = input.split("\n");
	
	var num = tmp[0].split(" ");
	var price = tmp[1].split(" ");
	var newprice = [];
	var total = 0;
	
	for(var i=0; i<num[0]; i++){
	    newprice.push(parseInt(price[i]));
	}
	
	newprice.sort(
	    function(a,b){
	        if(a>b){
	            return 1;
	        }else if(a<b){
	            return -1;
	        }else{
	            return 0;
	        }
	    }
	);

	for(var n=0; n<num[1]; n++){
	    total+=newprice[n];
	}
	
	console.log(total);
}

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

Measured memory_bytes: 29332
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long  
long double esp=0.00000001;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*sqrtl(a*b)<c)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 384
s = input("")
Scnt = 0
Smem = 0

for i in range(len(s)):
    if s[i] == "S":
        Scnt += 1
        Smem = i

if Scnt == 3:
    print(0)
elif Scnt == 2:
    print(1)
elif Scnt == 0:
    print(3)
elif Scnt == 1 and Smem == 1:
    print(1)
elif Scnt == 1 and Smem != 1:
    print(2)

Measured memory_bytes: 8992
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 105;
const int mod = 1e9 + 7;
short dp[maxn][maxn][maxn];
short row[maxn][maxn], col[maxn][maxn];
char mp[maxn][maxn];
short max(short a, short b) {
    return a>b? a : b;
}
int main()
{
    int n, m, ex, ey;
    scanf("%d%d", &n, &m);
    for (int i=1; i<=n; i++) scanf("%s", mp[i]+1);
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
            if (mp[i][j] == 'E'){
                ex = i, ey = j;
                break;
            }
    }
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) {
            row[i][j] = row[i][j-1] + (mp[i][j] == 'o');
            col[i][j] = col[i-1][j] + (mp[i][j] == 'o');
    }
    int L = ey - 1, R = m - ey, U = ex - 1, D = n - ex;
    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0;
    short ans = 0;
    for (int l=0; l<=L; l++){
        for (int u=0; u<=U; u++){
            for (int r=0; r<=R; r++){
                for (int d=0; d<=D; d++) if(dp[u][r][d] != -1){
                    int up = max(ex - u, d + 1), down = min(ex + d, n - u);
                    int left = max(ey - l, r + 1), right = min(ey + r, m - l);
                    if (up > down || left > right) continue;
                    ans = max(ans, dp[u][r][d]);
                    short add;
                    //printf("\n=========%d %d %d %d -> %d %d %d %d=========\n",l,u,r,d,left,up,right,down);
                    if(u+d < U){
                        add = row[ex-u-1][right] - row[ex-u-1][left-1];
                        //printf("u: %d ",add);
                        dp[u+1][r][d] = max(dp[u+1][r][d], dp[u][r][d] + add);
                    }
                    if(l+r < R){
                        add = col[down][ey+r+1] - col[up-1][ey+r+1];
                        //printf("r: %d ",add);
                        dp[u][r+1][d] = max(dp[u][r+1][d], dp[u][r][d] + add);
                    }
                    if(u+d < D){
                        add = row[ex+d+1][right] - row[ex+d+1][left-1];
                        //printf("d: %d ",add);
                        dp[u][r][d+1] = max(dp[u][r][d + 1], dp[u][r][d] + add);
                    }
                    if (l+r < L){
                        add = col[down][ey-l-1] - col[up-1][ey-l-1];
                        //printf("l: %d ",add);
                        dp[u][r][d] = max(dp[u][r][d], dp[u][r][d] + add);
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;

const int inf = 1e9;
const double eps = 1e-9;
struct point {
	double x, y, z;
	point() :x(0), y(0), z(0) {}
	point(double x, double y, double z) :x(x), y(y), z(z) {}
	point operator+(const point &p) const { return point(x + p.x, y + p.y, z + p.z); }
	point operator-(const point &p) const { return point(x - p.x, y - p.y, z - p.z); }
	point operator*(const double &d) const { return point(x*d, y*d, z*d); }
	point operator/(const double &d) const { return point(x / d, y / d, z / d); }
};
struct sphere {
	point p; double r;
	sphere() {}
	sphere(point p, double r) :p(p), r(r) {}
};
struct line {
	point a, b;
	line() {}
	line(point a, point b) :a(a), b(b) {}
};

inline double norm(const point &a) { return a.x*a.x + a.y*a.y + a.z*a.z; }
inline double abs(const point &a) { return sqrt(norm(a)); }
inline double dot(const point &a, const point &b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
point proj(const line &l, const point &p) {
	double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + (l.a - l.b)*t;
}
bool intersect(const line &l, const sphere &s) {
	point a = l.a - s.p, b = l.b - s.p, c = proj(l, s.p) - s.p;
	if(abs(a) < s.r - eps && abs(b) < s.r - eps && abs(c) < s.r - eps) return 0; // contain
	if(abs(c) > s.r + eps) return 0; // far
	if(abs(a) < s.r - eps || abs(b) < s.r - eps) return 1; // intersect
	if(abs(a - c) + abs(b - c) < abs(a - b) + eps) return 1; // intersect
	return 0;
}

struct light {
	point p;
	double b;
};

sphere b[2000];
light l[15];
line lines[15];
point o;
vector<int> v[15];

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

	int N, M, R;
	while(cin >> N >> M >> R, N | M | R) {
		for(int i = 0; i < N; i++) {
			cin >> b[i].p.x >> b[i].p.y >> b[i].p.z >> b[i].r;
		}
		for(int i = 0; i < M; i++) {
			cin >> l[i].p.x >> l[i].p.y >> l[i].p.z >> l[i].b;
		}
		cin >> o.x >> o.y >> o.z;
		for(int i = 0; i < M; i++) {
			lines[i].a = l[i].p;
			lines[i].b = o;
		}

		for(int i = 0; i < M; i++) {
			v[i].clear();
			for(int j = 0; j < N; j++) {
				if(intersect(lines[i], b[j])) {
					v[i].push_back(j);
				}
			}
		}

		double ans = 0;
		for(int i = 0; i < 1 << M; i++) {
			vector<int> used(N);
			double sum = 0;
			int cnt = 0;
			for(int j = 0; j < M; j++) {
				if(i >> j & 1) {
					for(int x : v[j]) {
						if(!used[x]) {
							used[x] = true;
							cnt++;
						}
					}
					sum += l[j].b / norm(o - l[j].p);
				}
			}

			if(cnt <= R) {
				ans = max(ans, sum);
			}
		}

		cout << setprecision(15) << ans << endl;
	}
}

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

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  
  int swnum[10][11]={};
  for(int i=0;i<M;i++){
    scanf("%d",&swnum[i][0]);
    for(int j=1;j<=swnum[i][0];j++){
      scanf("%d",&swnum[i][j]);
    }
  }
  int cond[10]={};
  for(int i=0;i<M;i++){
    scanf("%d",&cond[i]);
  }
  
  int swcnb=pow(2,N);
  int onconb=0;
  for(int i=0;i<swcnb;i++){
    
    int swcond[10]={};
    int temp=i;
    for(int s=0;s<N;s++){
      swcond[N-1-s]=(temp>=pow(2,N-1-s)) ? 1 : 0;
      if(temp>=pow(2,N-1-s)){
        temp-=pow(2,N-1-s);
      }
    }
    
    int lampcount=0;
    for(int j=0;j<M;j++){
      int count=0;
      for(int k=1;k<=swnum[j][0];k++){
        if(swcond[swnum[j][k]-1]==1){
          count++;
        }
      }
      if(count%2==cond[j]){
        lampcount++;
      }else{
        break;
      }
      if(lampcount==M){
        onconb++;
      }
    }
  }
  printf("%d",onconb);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int N,i=0,l,d=0;
	scanf("%d",&N);
	char s[N];
	char t[]="ABC",p[3];
	scanf("%s",s);
	for(i=0;i<N-2;i++){
		l=i;
		p[0]=s[l];
		p[1]=s[++l];
		p[2]=s[++l];
		if(strcmp(p,t)==0) d++;
	}
	printf("%d\n",d);
	return 0;
 } 

Measured memory_bytes: 128
N = int(input())
B = list(map(int, input().split()))

A = list()
A.append(B[0])

for i in range(0, N - 2):
  if B[i] <= B[i+1]:
    A.append(B[i])
  else:
    A.append(B[i+1])
  
A.append(B[N-2])

result = sum(A)

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int n, m;
    cin >> n >> m;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n, greater<int>());
    int sum = 0;
    for (int i = 0; i < m; i++)
        sum += arr[i];
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 21:12:06 2019

@author: yuta
"""

B = input()

def main(b):
    if b == "A":
        print("T")
    elif b == "C":
        print("G")
    elif b == "G":
        print("C")        
    elif b == "T":
        print("A")
main(B)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pll>> edge(n);
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		edge[a - 1].push_back({ b - 1,-c });
	}
	vll memo(n, 1LL<<48);
	memo[0] = 0;
	REP(i, n - 1) {
		REP(j, n) {
			if (memo[j] == 1LL << 48 || edge[j].empty())
				continue;
			REP(k, edge[j].size()) {
				if (memo[edge[j][k].first]>memo[j]+edge[j][k].second) {
					memo[edge[j][k].first] = memo[j] + edge[j][k].second;
				}
			}
		}
	}
	vb veg(n, false);
	REP(i, n) {
		REP(j, n) {
			if (memo[j] == 1LL << 48||edge[j].empty())
				continue;
			REP(k, edge[j].size()) {
				if (memo[edge[j][k].first]>memo[j] + edge[j][k].second) {
					memo[edge[j][k].first] = memo[j] + edge[j][k].second;
					veg[edge[j][k].first] = true;
				}
				if (veg[j] == true)
					veg[edge[j][k].first] = true;
			}
		}
	}
	if(veg[n-1])
		cout << "inf" << endl;
	else
	cout << -memo[n - 1] << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int now = 1;
	bool ok = false;
	int counts = 0;
	rep(i,n){
		now = a[now-1];
		counts++;
		if(now == 2) {
			cout << counts << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3628
import sys
from operator import itemgetter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    def update(self, k, x):
        k += self.N0 - 1
        ################################################################
        self.data[k] = x
        ################################################################
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    def query(self, left, right):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        ################################################################
        
        while L < R:
            if L & 1:
                res = self.segfunc(res, self.data[L - 1])
                L += 1
            if R & 1:
                R -= 1
                res = self.segfunc(res, self.data[R - 1])
            L >>= 1
            R >>= 1
        
        ################################################################
        return res


def solve():
    N, M = map(int, rl().split())
    LRC = [list(map(int, rl().split())) for _ in range(M)]
    LRC.sort(key=itemgetter(0, 1))
    
    INF = 10 ** 18
    dist = [INF] * N
    dist[0] = 0
    seg_tree = SegmentTree(dist, min, INF)
    
    for L, R, C in LRC:
        L, R = L - 1, R - 1
        tmp = seg_tree.query(L, R)
        cost = tmp + C
        if cost < dist[R]:
            dist[R] = cost
            seg_tree.update(R, cost)
    print(dist[-1] if dist[-1] != INF else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 89820
#include <stdio.h>
#include <string.h>

int main(){
long long int a, b, v, w, t;
scanf("%lld %lld", &a, &v);
scanf("%lld %lld", &b, &w);
scanf("%lld", &t);
if(a < b){
if(((v * t) + a) >= ((w * t) + b)){
		printf("YES\n");
}else{
		printf("NO\n");
}
}else if(a > b){
	if(((v * t) - a) >= ((w * t) - b)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}else{
	printf("YES\n");
}
return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int K = 0,N = 0;
  cin >> K >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  vector<int>B(N);
  rep(i,N - 1){
    B[i] = A[i + 1] - A[i];
  }
  B[N - 1] = K + A[0] - A[N - 1];
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  cout << K - B[0];
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100010

VI graf[MAXSIZE];
int dl[MAXSIZE];
int n,m;
int wyn=1;

void dfs(int v){
	dl[v]=1;
	for(auto x:graf[v]){
		if(dl[x]==0)
			dfs(x);
		dl[v]=max(dl[v],dl[x]+1);
	}
	wyn=max(wyn,dl[v]);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	REP(i,m){
		int t1,t2;
		cin>>t1>>t2;
		graf[t1].PB(t2);
	}
	
	FOR(i,1,n){
		if(dl[i]==0)
			dfs(i);
	}
	
	cout<<wyn-1;
	return 0;
}


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

int main() {

  int N;
  cin >> N;
  
  vector<int> card(N);

  for(int i=0; i<N; i++){
    cin >> card.at(i);
  }

  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());

  int ans = 0;
  for(int i=0; i<N; i++){
    if(i%2==0){
      ans += card.at(i);
    }else{
      ans -= card.at(i);
    }
  }

  cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    int n;
    ll ans=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0){
            continue;
        }
        ans+=i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3672
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
    
    ll n,i,j;
    cin>>n;
    vector<ll> v;
    for(i=2;i<=sqrt(n);i++) 
    { 
        if (n%i==0) 
        { 
            if (n/i == i) 
                v.pu(i); 
  
            else
                v.pu(i),v.pu(n/i); 
        } 
    } 
    if(v.empty())
        cout<<n-1<<'\n';
    else
    {
        sort(all(v));
        int x=lower_bound(all(v),sqrt(n))-v.begin();
        cout<<v[x]+(n/v[x])-2<<'\n';
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    ll N = S.length();
    string substr_one = S.substr(0, (N - 1) / 2);
    string substr_two = S.substr((N + 3) / 2 - 1, N);
    ll counter = 0;
    string reversed_S = S;
    string reversed_substr_one = substr_one;
    string reversed_substr_two = substr_two;

    reverse(reversed_S.begin(), reversed_S.end());
    reverse(reversed_substr_one.begin(), reversed_substr_one.end());
    reverse(reversed_substr_two.begin(), reversed_substr_two.end());

    if (S != reversed_S) counter++;
    if (substr_one != reversed_substr_one) counter++;
    if (substr_two != reversed_substr_two) counter++;

    if (counter > 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    
    int t,o;
    cin >> t >> o;
    if(t*500 >= o)
	cout << "Yes\n";
    else
	cout << "No\n";
    
}

Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] val = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int must = val[0];
            SetContent scA = new SetContent(val[1], val[2]);
            SetContent scB = new SetContent(val[3], val[4]);

            Console.WriteLine(Math.Min(scA.GetPrice(must), scB.GetPrice(must)));
        }
    }

    public class SetContent
    {
        private int _count;
        private int _price;

        public SetContent(int count, int price)
        {
            _count = count;
            _price = price;
        }

        public int GetPrice(int must)
        {
            int ans = must / _count;
            if (must % _count != 0)
                ans++;

            return ans * _price;
        }
    }
}


Measured memory_bytes: 17932
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,d; cin>>n>>d;
    vector<vector<int>> points(n, vector<int>(d));
    rep(i,n)rep(j,d)cin>>points[i][j];
    
    int ans = 0;
    rep(i,n){
        for(int j = i+1; j<n; ++j){
            double sum = 0.0;
            rep(dim,d){
                sum += pow(points[i][dim]-points[j][dim],2);
            }
            if(sqrt(sum) == (int)sqrt(sum))++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);
    String N = sc.next();
    int total = 700;
    
    if(N.charAt(0) == 'o'){
    	total += 100;
    }
    if(N.charAt(1) == 'o'){
    	total += 100;
    }
    if(N.charAt(2) == 'o'){
    	total += 100;
    }
    System.out.println(total);
  }
}

Measured memory_bytes: 21716
s = input()
a = int(s[0:2])
b = int(s[2:])
if((0 < a and a <= 12) and (0 < b and b <= 12)):
    print("AMBIGUOUS")
elif((0 < a and a <= 12) == False and (0 < b and b <= 12)):
    print("YYMM")
elif ((0 < a and a <= 12) and (0 < b and b <= 12) == False):
    print("MMYY")
else:
    print("NA")




Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    S, W = inpl()
    if W >= S:
        print("unsafe")
    else:
        print("safe")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61780
#include<stdio.h>

int main(void){
	int a,b,x;
	
	scanf("%d %d %d",&a,&b,&x);
	
	if(0 <= (x-a) && (x-a) < b)
		printf("YES\n");
	else
		printf("NO\n");
		
	return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
int a,b;

int main(){
	cin>>a>>b;
	if(a>0)cout<<"Positive";
	else if(a==0||(a<0&&b>0))cout<<"Zero";
	else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
	else cout<<"Negative";
	return 0;
}

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

int main(){
	int N;
	cin>>N;
	long A[N];
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	long x[N];
	x[0] = 0;
	for(int i=1;i<N;++i){
		x[i] = A[i] - x[i-1];
	}
	long y = (A[0] - x[N-1])/2;
	long ans[N];
	for(int i=0;i<N;++i){
		if(i%2==0){
			ans[i] = 2*(y + x[i]);
		}
		else{
			ans[i] = 2*(x[i] - y);
		}
	}
	for(int i=0;i<N;++i){
		if(i==0){
			cout<<ans[N-1]<<" ";
		}
		else{
			cout<<ans[i-1]<<" ";
		}
	}
	cout<<endl;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    double r,D,S;
    scanf("%lf", &r);
    
    D = 3.141592653589 * r * r;
    S = 3.141592653589 * 2 * r;
    
    printf("%.6lf %.6lf\n", D, S);
    return 0;
    
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main() {
  stack<int> s;
  string str;
  int a, b;

  while(cin >> str) {
    if(str == "+" || str == "-" || str == "*") {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
    }

    if(str == "+") {
      s.push(a + b);
    } else if(str == "-") {
      s.push(-a + b);
    } else if(str == "*") {
      s.push(a * b);
    } else {
      s.push(stoi(str));
    }
  }

  cout << s.top() << endl;

  return 0;
}


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

vec = [[0] * N for _ in range(N)]
color = [0] * (N + 1)
i = 0
while (1 << i) <= N :
    for j in range((1 << i), N + 1, 1 << (i + 1)) :
        color[j] = i + 1
    i += 1
        
for i in range(N) :
    for j in range(i + 1, N) :
        vec[i][j] = color[j - i]
        
for i in range(N) :
    print(*vec[i][i+1:])

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

int main() {
  string w;
  getline(cin, w);
  int c = 0;
  while(!cin.eof()) {
    string s;
    cin >> s;
    if (s == "END_OF_TEXT") break;
    transform(s.begin(), s.end(), s.begin(),
        [](unsigned char c){ return tolower(c); });
    if (s == w) c++;
  }
  cout << c << endl;
}



Measured memory_bytes: 3156