akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main()
{  char i;
    scanf("%c",&i);
    if(i=='a'||i=='e'||i=='i'||i=='o'||i=='u')
    {
        printf("vowel");

    }
    else
    {
        printf("consonant");
    }
    return 0;

}


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

int main(){
    int n;
    cin >> n;
    ll sum=0;
    for(int i=1; i<=n; i++){
        if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout <<sum << endl;
}


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


int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> v;
    for(int i=0;i<n;i++){
    	int x;
    	cin>>x;
    	v.push_back(x);
	}
	
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=v[i];
	}
    
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    string s; IN(s);
    int sl = s.length();
    rep(i,0,sl){
    	if(i%2){
    		if(s[i]=='R'){
    			cout << "No"<<el;
    			return 0;
    		}
    	}
    	else {
    		if(s[i]=='L'){
    			cout << "No"<<el;
    			return 0;
    		}
    	}
    }
    cout << "Yes" <<el;
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define D long double
using namespace std;
//typedef long double D;
typedef complex<long double> P;
typedef vector<P> VP;
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}
bool isecSP(P a1, P a2, P b) {
  return !ccw(a1, a2, b);
}
P crosspointLL(P a1, P a2, P b1, P b2) {
  long double d1 = cross(b2-b1, b1-a1);
  long double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  if (EQ(d2, 0)) throw "kouten ga nai";   // 交点がない
  return a1 + d1/d2 * (a2-a1);
}
P circumcenter(P a, P b, P c) {
  a = (a-c)*(long double)0.5;
  b = (b-c)*(long double)0.5;
  return c + crosspointLL(a, a*P(1,1), b, b*P(1,1));
}
int dp[1<<14],n,m;
D min_s[1<<14];
VP v;
void Mae_syori(){
  r(i,(1<<n))min_s[i]=1e15;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(isecSP(v[i],v[j],v[k]))continue;
        if(isecSP(v[i],v[k],v[j]))continue;
        if(isecSP(v[k],v[j],v[i]))continue;
        P c=circumcenter(v[i],v[j],v[k]);
        D ans=0;
        ans=max(ans,abs(v[i]-c));
        ans=max(ans,abs(v[j]-c));
        ans=max(ans,abs(v[k]-c));
        int mask=0;
        for(int l=0;l<n;l++){
          if(abs(v[l]-c)<=ans)mask|=(1<<l);
        }
        min_s[mask]=min(ans,min_s[mask]);
      }
      D ans=abs(v[i]-v[j])/2;
      P c=(v[i]+v[j]);c/=2;
      int mask=0;
      for(int l=0;l<n;l++){
        if(abs(v[l]-c)<=ans)mask|=(1<<l);
      }
      min_s[mask]=min(ans,min_s[mask]);
    }
  }
  r(i,n)min_s[(1<<i)]=0;
  for(int i=(1<<n)-1;i>=0;i--){
    for(int j=(i-1)&i;j>0;j=(j-1)&i){
      min_s[j]=min(min_s[j],min_s[i]);
    }
  }
  for(int i=0;i<(1<<n);i++) min_s[i]+=0.0000000001;
}
D dfs(int S){
  if(dp[S])return dp[S];
  D res=1e8;
  for(int i=(S-1)&S;i>0;i=(i-1)&S){
    res=min(res,dfs(i)+dfs(i^S));
  }
  return dp[S]=res;
}
bool check(D mid){
  memset(dp,0,sizeof(dp));
  for(int i=1;i<(1<<n);i++){
    if(min_s[i]<=mid)dp[i]=1;
  }
  return dfs((1<<n)-1)<=m;
}
D nibutan(){
  D l=0,r=100000;
  r(i,77){
    D mid=(l+r)/2;//cout<<mid<<endl;
    if(check(mid))r=mid;
    else l=mid;
  }
  return l;
}
int main(){
  cin>>n>>m;
  r(i,n){
    int x,y;
    cin>>x>>y;
    v.push_back(P(x,y));
  }
  Mae_syori();
  printf("%.12Lf\n",nibutan());
}


Measured memory_bytes: 3616
#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() {
    string s;
    cin >> s;
    int count=0;
    rep(i,3){
        if(s.at(i)=='1') count++;
    }
    cout << count << endl;
}

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

#define pb push_back
#define fi first
#define se second
#define mem(x,n) memset(x,n,sizeof(x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define foreach(it,l) for(auto it=(l).begin();it!=(l).end();it++)
#define pnl printf("\n")
#define endl '\n'
#define len(x) (x).length()

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<int> VI;
const double EPS=1e-10;
//const double PI=acos(-1.0);
const int INF=1<<30;
const LL LLINF=1ll<<60;
const int MOD=1e9+7;
const int xx[8]={1,0,-1,0,1,-1,1,-1};
const int yy[8]={0,1,0,-1,-1,1,1,-1};

void fastio(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }

/***********************************\
     _____ _             _
    /  __ \ |           (_)
    | /  \/ | __ _ _ __  _  ___
    | |   | |/ _` | '_ \| |/ _ \
    | \__/\ | (_| | |_) | |  __/
     \____/_|\__,_| .__/|_|\___|
                  | |
                  |_|
\***********************************/

map<int,int> mp;

int main(){
	int tc;
	scanf("%d",&tc);
	while(tc--){
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	int cnt=0;
	for(auto it=mp.begin();it!=mp.end();it++){
		if(it->second%2!=0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	ll ans = 0;
	ll temp = 1;
	int j = 1;
	while (ans + temp * 26 < T)
	{
		temp *= 26;
		ans += temp;
		j++;
	}
	// cout << "value of J " << j << endl;
	int arr[j] = {0};
	for (int i = 0; i < j; i++)
	{
		while (ans + temp < T)
		{
			arr[i]++;
			ans += temp;
		}
		temp /= 26;
	}
	for (int i = 0; i < j; i++)
	{
		cout << char(arr[i] + 'a');
	}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i=0; i<n; i++){
    if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
      ans += 2;
    }
    else if (a[i] == b[i] && b[i] == c[i]){
      continue;
    }
    else ans += 1;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r, g, b;
    rep(i, 0, n){
        if(s[i] == 'R') r.push_back(i);
        else if(s[i] == 'G') g.push_back(i);
        else if(s[i] == 'B') b.push_back(i);
    }
    ll ans = r.size() * g.size() * b.size();
    int tmp;
    if(n % 2 == 0) tmp = n / 2 - 1;
    else tmp = (n - 1) / 2;
    rep(i, 1, tmp + 1){
        int tail = 0;
        int mid = i;
        int head = i * 2;
        rep(j, 0, n){
            if(head > n - 1) break;
            else{
                if(s[tail] != s[mid] && s[mid] != s[head] && s[head] != s[tail]) ans--;
            }
            tail++;
            mid++;
            head++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int n,m,a,k;
	cin>>n>>m;
	
	vector<bool> v(n+1);
	vector<int> va(n+1);
	string c;int b;
	for(int i=0;i<m;i++)
	{
		cin>>b>>c;
		if(c=="WA")
		{
			if(!v[b]){
				va[b]++;
			}
		}
		else {
			v[b]=true;
		}
	}
	
	long long ans=0,pen=0;
	for(int i=1;i<=n;i++)
	{
		if(v[i]){
		ans++;
		pen+=va[i];}
	}
	cout << ans << " " << pen << endl;
	return 0;
}


Measured memory_bytes: 640
def judge(S:str) -> bool:
    if S[0] != "A":
        return False
    
    elif S[2:-1].count("C") != 1:
        return False
    
    else:
        s_list = list(S)
        s_list.remove("A")
        s_list.remove("C")
        for s in s_list:
            if ord(s)<ord("a") or ord(s)>ord("z"):
                return False

        return True
            
S = input()

if judge(S):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){

	int left_num = 0;
	int right_num = 0;

	for(left_num = 1;left_num <= 9;left_num++){
		for(right_num = 1;right_num <= 9;right_num++){
			printf("%dx%d=%d\n",left_num,right_num,left_num * right_num);	
		}	
	}	
	return(0);
}

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

ll n,m;
vector<ll> v;
vector<ll> l;

int main()
{
  cin >> n >> m;
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  rep(m){
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  rep(m-1) l.push_back(v[i+1]-v[i]);
  sort(l.begin(),l.end());
  ll tmp = v[m-1]-v[0];
  rep(n-1){
    tmp-=l[m-i-2];
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const ll oo = (ll) 1e18;
ll a,b,c,d,e,res,mini;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> a >> b >> c >> d >> e;
	e*=4;
	res=(e/8)*min(min(a*8,b*4),min(c*2,d));
	e%=8;
	mini=oo;
	for (ll i=0; i<=7; i++)
	for (ll j=0; j<=7; j++)
	for (ll x=0; x<=7; x++)
	if (e==i+j*2+x*4)
	mini=min(mini,a*i+b*j+c*x);
	cout << res+mini;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="MON")
        cout<<6<<endl;
    if(s=="TUE")
        cout<<5<<endl;
    if(s=="WED")
        cout<<4<<endl;
    if(s=="THU")
        cout<<3<<endl;
    if(s=="FRI")
        cout<<2<<endl;
    if(s=="SAT")
        cout<<1<<endl;
    if(s=="SUN")
        cout<<7<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int pow2(int a,int b){
    return (a-b)*(a-b);
}
int main(){
    int n;
    int a[1001];
    cin>>n;
    for (int i=0;i<n;++i) cin>>a[i];
    int ans=INT_MAX;
    for (int i=0;i<=100;++i){
        int sum=0;
        for (int j=0;j<n;++j)
            sum+=pow2(i,a[j]);
        ans=min(ans,sum);
    }
    cout<<ans;
}

Measured memory_bytes: 256
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}

int main(){
  int a, b;
  cin >> a >> b;
  if (a + b == 15)cout <<"+" << endl;
  else if (a*b == 15)cout <<"*" << endl;
  else cout <<"x" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int x = 0;
    REP(i, n){
        if(s[i] == 'I') x++;
        else if(s[i] == 'D') x--;
        ans = max(ans, x);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int num[10000];
int main( void ) 
{
  
    int n;
    scanf( "%d", &n );
     
    int i, j;
 
    int cnt = n;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num[i] );
    }
    for( i=0; i<n; i++ ) {    
        if( 2 == *(num+i) ) { continue; }
         
        if( 0 == *(num+i)%2 ) {
            cnt--;
            continue;
        }
         
        for( j=3; j*j<=*(num+i); j+=2 ) {
            if( 0 == *(num+i)%j ) {
                cnt--;
                break;
            }
        }
    }
      
    printf( "%d\n", cnt );
     
    return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define N 1000
using namespace std;
int ans,n;
int mem[5][4001];

int dfs(int x,int cnt){
  if(cnt==4&&x==n)return 1;
  if(cnt==4||x>n) return 0;
  if(mem[cnt][x]!=-1) return mem[cnt][x];
  mem[cnt][x]=0;
  for(int i=0;i<=N;i++)mem[cnt][x]+=dfs(x+i,cnt+1);
  return mem[cnt][x];
}


long long dp[6][5001];
int main(){
   while(cin>>n){
     memset(dp,0,sizeof(dp));
     memset(mem,-1,sizeof(mem));
     cout << dfs(0,0)<<endl;
   }
  return 0;
}

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

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

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

    int q;
    cin >> q;

    int t;
    int res = 0;
    for (int i = 0; i < q; i++) {
        cin >> t;
        bool is_found = binary_search(S, S + n, t);
        if (is_found) {
            res++;
        }
    }

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



Measured memory_bytes: 3432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const int INF=1e9+5e8;

int N;
vector<P> rob;
int X[MAX], L[MAX];
void input(){
    cin>>N;
    rep(i, N){
        int x, l;
        cin>>x>>l;
        P p = mp(x+l, x-l);
        rob.pb(p);
    }
    sort(all(rob));
    int ans = 0;
    int tmp = -INF;
    rep(i, N){
        if(tmp <= rob[i].se){
            ans += 1;
            tmp = rob[i].fi;
          	//cout<<i<<" "<<rob[i].fi<<" "<<rob[i].se<<endl;
        }
    }
    cout<<ans<<endl;
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 1400
/*
 * https://atcoder.jp/contests/abc160/tasks/abc160_d
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long


/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1e9 + 7;


#define INF 1e+9
#define MAX_V 100000

struct edge {
    ll to;
    ll cost;
};

using P = pair<ll, ll>;

vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll V, ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

void pushV(ll node,ll to, ll cost) {
    edge e = {to, cost};
    G[node].push_back(e);
}
int main() {
    INIT();

    ll n,x,y,results[20001];
    cin >> n >> x >> y;
    x--;
    y--;
    pushV(0, 1, 1);
    REPS(i,1,n - 1) {
        pushV(i, i - 1, 1);
        pushV(i, i + 1, 1);
    }
    pushV(n - 1, n - 2, 1);
    pushV(x, y, 1);
    pushV(y, x, 1);
    REP(i,n) {
        results[i] = 0;
    }
    REP(i,n) {
        dijkstra(n, i);
        REPS(j,i+1,n) {
            results[d[j]]++;
        }
    }
    REPS(i,1,n) {
        cout << fixed << results[i] << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	long long n;
	cin >> n;
	bool check = false;
	long long m = 1;
	long long end = sqrt(n) + 1;
	for (int i = 1; i <= end; i++)
	{
		if ((n % i) == 0)
		{
			m = i;
		}
	}
	//cout << m << " " << n / m;
	cout << (m - 1) + (n / m - 1);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

/*
ID: jamerz1
PROG: hidden
LANG: C++11
*/

using namespace std;

// TIMER
std::clock_t __start;
double __duration;
void start_timer() { __start = std::clock(); }
void print_timer() {
	__duration = (std::clock() - __start) / (double)CLOCKS_PER_SEC;
	std::cout << "Duration (msec): " << __duration * 1000 << '\n';
}
// END TIMER

//PI
#define M_PI		3.14159265358979323846
// fast input
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)

template <class T>
T min_(T a, T b) { return (a < b ? a : b); }
template <class T>
T max_(T a, T b) { return (a > b ? a : b); }

double EPS_ = 1e-16;
bool eq_(const double& lhs, const double &rhs) {
	return (fabs(lhs - rhs) < EPS_);
}

//#define F first
//#define S second

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef pair<int, int> ii;
typedef pair<double, double> dd;

typedef pair<ll, ll> llll;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<llll> vllll;
typedef vector<int> vi;
typedef vector<ull> vull;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;

const int INF = int(2e9);
const ll INF_LL = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()  {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N, A, B;
	cin >> N >> A >> B;
	cout<<min(B, A*N)<<'\n';

	return 0;
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    CIN(N);
    map<string,int> mp;
    rep(i,N){
        SCIN(s);
        mp[s]++;
    }
    printf("%d\n",mp.size()); 

    return 0;
}

Measured memory_bytes: 19316
#include<bits/stdc++.h>
using namespace std;
long long count( long long S[], long long m, long long n ) 
{ 
    long long i, j, x, y; 
    long long table[n + 1][m]; 
    for (i = 0; i < m; i++) 
        table[0][i] = 1; 
    for (i = 1; i < n + 1; i++) 
    { 
        for (j = 0; j < m; j++) 
        { 
            x = (i-S[j] >= 0) ? table[i - S[j]][j] : 0; 
  
            y = (j >= 1) ? table[i][j - 1] : 0; 
  
            table[i][j] = x + y; 
        } 
    } 
    return table[n][m - 1]; 
} 
int main()
{
    long long n;
    long long arr[3];
    cin>>arr[0]>>arr[1]>>arr[2]>>n;
    cout<<count(arr,3,n)<<endl;
    return 0;
    
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
v = list(li())
v.sort()
ans = (v[0] + v[1]) / 2
for vi in v[2:]:
    ans = (ans + vi) / 2

print(ans)


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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int* a = new int [n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int i = 0, ohajiki = 32;
        while (ohajiki > 0) {
            ohajiki -= (ohajiki - 1) % 5;
            cout << ohajiki << endl;
            if (ohajiki < a[i]) {
                ohajiki = 0;
            } else {
                ohajiki -= a[i];
            }
            i = (i + 1) % n;
            cout << ohajiki << endl;
        }
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>q[200000];
int color[200000];
int flag[200000];
int n,m;
int v[200000],d[200000],c[200000];
void dfs(int x,int cnt,int c)
{
   if(!color[x])
   {
       color[x]=c;
   }
   if(flag[x]>=cnt)
   {
       return;
   }
   if(cnt==0)
   {
       return;
   }
   flag[x]=cnt;
   for(int i=0;i<q[x].size();i++)
   {
       dfs(q[x][i],cnt-1,c);
   }
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++)
    {
       cin>>v[i]>>d[i]>>c[i];
    }
    for(int i=q;i>=1;i--)
    {
        dfs(v[i],d[i],c[i]);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<color[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11896
n = int(input())
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for _ in range(n):
    b,f,r,v = map(int,input().split())
    rooms[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        ans = [str(_) for _ in rooms[i][j]]
        print(' '+' '.join(ans))
    else:
        if i != 3:
            print('####################')


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;
 
long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};
 
void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}
 
long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}
long long h, w, a, b;
 
long long solve();
 
int main() {
  smodfact();
  cin >> h >> w >> a >> b;
  cout << solve() << endl;
  return 0;
}
 
long long solve() {
  long long ans = 0, bf = 0, now;
  for(long long i = b; i < w; ++i) {
    now = calccomb(h - 1 - a + i, i) - bf;
    while(now < 0) now += N;
    ans += now * calccomb(a + w - 1 - i, a) % N;
    ans %= N;
    bf = calccomb(h - 1 - a + i, i);
  }
  return ans;
}

Measured memory_bytes: 11904
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    sub = [0]*N

    for i in range(N-1):
        sub[A[i]-1] += 1
    print(*sub,sep='\n')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 92896
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int H[100100];
    rep(i, N) cin >> H[i];
    rep1(i, N - 1) {
        if(H[i - 1] < H[i]) {
            H[i] --;
        } else if(H[i - 1] == H[i]) {
            continue;
        } else {
            No();
        }
    }
    Yes();
	return 0;
}

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

using namespace std;

int main(){
	int n,t,a;
	cin >> n;
	cin >> t >> a;
	vector <pair<double,int> > h;
	int x;
	for (int i = 0; i < n; ++i){
		cin >> x;
		h.push_back({abs(double(t-(x*0.006))-a),i+1});
	}
	sort(h.begin(),h.end());
	cout << h[0].second << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	ios::sync_with_stdio(false);

	int n, m, W, w[16], K = 0;
	cin >> n >> m >> W;
	--m;
	int f[12345], top;
	for (int i = 0; i < n; ++i)
	{
		int k;
		cin >> k;
		int s = 0;
		for (int j = 0; j < k; ++j, ++K)
		{
			cin >> w[K];
			s |= 1 << K;
		}
		f[i] = s;
		if (s)
			top = i;
	}
	if (f[0] == (1 << K) - 1)
	{
		cout << 0 << endl;
		return 0;
	}

	int sum_w[1 << 15];
	for (int i = 0; i < 1 << K; ++i)
	{
		int s = 0;
		for (int j = 0; j < K; ++j)
			if (i >> j & 1)
				s += w[j];
		sum_w[i] = s;
	}

	int dp[1 << 15];
	dp[0] = 0;
	for (int S = 1; S < 1 << K; ++S)
	{
		dp[S] = 1 << 27;
		for (int T = S; T > 0; T = --T & S)
		{
			if (sum_w[T] <= W)
				min_swap(dp[S], dp[S ^ T] + 1);
		}
	}

	int rider = 0;
	int res = abs(m - top);
	for (int i = n - 1; i > 0; --i)
	{
		rider |= f[i];
		if (rider)
			res += dp[rider] * 2 - 1;
	}
	cout << res << endl;
}

Measured memory_bytes: 0
package main

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

func main() {
	X, K, D := ReadInt(), ReadInt(), ReadInt()
	if X < 0 {
		X = -X
	}
	L := (X + D - 1) / D
	if K < L {
		fmt.Println(X - K*D)
		return
	}
	lx := X - L*D
	if lx == 0 {
		if (K-L)%2 == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(D)
		}
		return
	}
	if (K-L)%2 == 1 {
		fmt.Println(X % D)
	} else {
		fmt.Println(D - X%D)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]

	if (B-2*A)%2 == 0 {
		y := (B - 2*A) / 2
		x := A - y
		if x >= 0 && y >= 0 {
			fmt.Printf("Yes\n")
			return
		}
	}
	fmt.Printf("No\n")
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,d[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin >> n;
    for(int i = 0;i < n; ++i) cin >> d[i];
    sort(d,d+n);
    // for(int i = 0;i < n; ++i) cout << d[i] <<" ";
    cout << d[n/2] - d[n/2-1];
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		if (n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(n * 2);
		}
	}

}


Measured memory_bytes: 21844
import math
n , k = map(int, input().split())

res = 0
pi = 1 / n
for i in range(1, n + 1):
    i = k / i
    i = math.log2(i)
    if i <= 0:
        index = 0
    elif int(i) == i:
        index = int(i)
    else:
        index = int(i) + 1
    res += pi / (2 ** index)

print(res)


Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll dp[100010];
int main()
{
	int N;
	cin >> N;
	ll h[100010];
	for(int i = 0; i < 100010; i++) dp[i] = INF;
	for(int i = 0; i < N; i++) cin >> h[i];

	dp[0] = 0;
	for(int i = 1; i < N + 1; i++)
	{
		if(i > 1) chmin(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
		chmin(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[N - 1] << endl;
}

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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i = 0;i<n;i++)cin >> h[i];
	sort(h.begin(),h.end());
	int ans = 1e9;
	for(int i = 0;i<n-k+1;++i)
	{
		ans = min(ans,h[i+k-1]-h[i]);
		//cout<<h[i+k-1]<< ' '<<h[i]<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        System.out.println(solve(n));
    }
    public static String solve(int n) {
        if (n < 1000) {
            return "ABC";
        }
        return "ABD";
    }
}


Measured memory_bytes: 19924
#include <bits/stdc++.h>
using namespace std;
string ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",s,t,m;
int main(){
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		m=s;
		for(int j=i;j<i+t.size();j++){
			if(m[j]=='?')m[j]=t[j-i];
			else if(m[j]!=t[j-i]||j>=s.size())goto u;
		}
		for(int j=0;j<m.size();j++){
			if(m[j]=='?')m[j]='a';
		}
		ans=min(m,ans);
		u:;
	}
	if(ans=="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")cout<<"UNRESTORABLE"<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

def kock(n, x1, y1, x2, y2):
    if n == 0:
        return

    angle = math.radians(60)

    sx = (2*x1 + x2)/3
    sy = (2*y1 + y2)/3
    tx = (2*x2 + x1)/3
    ty = (2*y2 + y1)/3
    ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
    uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy

    kock(n-1, x1, y1, sx, sy)
    print sx, sy
    kock(n-1, sx, sy, ux, uy)
    print ux, uy
    kock(n-1, ux, uy, tx, ty)
    print tx, ty
    kock(n-1, tx, ty, x2, y2)

n = input()

p1x = float(0.)
p1y = float(0.)
p2x = float(100.)
p2y = float(0.)

print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y

Measured memory_bytes: 6652
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var hArray = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ret = 0;
            for (int i = 0; i < firstLine[0]; i++)
            {
                if (hArray[i] >= firstLine[1])
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 17248
local function memoize(f)
    local cache = {}
    local function key(...)
        local args = {...}
        local k = tostring(args[1])
        for i=2,#args do
            k = k .. "*" .. tostring(args[i])
        end
        return k
    end
    return function(...)
        local k = key(...)
        if cache[k] then
            return cache[k]
        end
        local r = f(...)
        cache[k] = r
        return r
    end
end

local thickness
thickness = memoize(function(n)
    if n == 0 then
        return 1
    else
        return 2 * thickness(n-1) + 3
    end
end)

local patties
patties = memoize(function (n, x)
    if n == 0 then
        return 1
    end
    local th_upper = thickness(n-1)
    if x == 1 then
        return 0
    elseif x <= th_upper + 1 then
        return patties(n-1, x-1)
    elseif x == th_upper + 2 then
        return 1 + patties(n-1, th_upper)
    else
        return 1 + patties(n-1, th_upper) + patties(n-1, x-2-th_upper)
    end
end)

local N, X = io.read("n", "n")
print(patties(N,X))


Measured memory_bytes: 760
#include <iostream>

using namespace std;
int a[100005]={0};
int main(int argc, char *argv[])
{
    int n,t;
    scanf("%d",&n);
    int last=0,f=0,i=1,sum=0;
    scanf("%d",&last);
    while(1){
        if(i==n){
            sum++;
            printf("%d\n",sum);
        return 0;}
        scanf("%d",&t);
        i++;
        if(last>t)
            f=0;//1>2
        else if(last<t)
             f=1;
        else
            continue;
        last=t;

        while(1){
            if(i==n){
                sum++;
                printf("%d\n",sum);
            return 0;}
            scanf("%d",&t);
            i++;
            if(f){
                if(last>t){
                    sum++;
                   last=t;
                    break;
                }


            }
            else{
                if(last<t){
                    sum++;
                    last=t;
                    break;
                }

            }
            last=t;

        }


}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int Inf = 1e9;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, m;
  cin >> n >> m;
  vector <vector <char>> a(n, vector <char> (m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  vector <vector <int>> dp(n + 1, vector <int> (m + 1, Inf));
  dp[1][0] = 0;
  dp[0][1] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = min(dp[i - 1][j] + (a[i - 1][j - 1] == '#' && (i == 1 || a[i - 2][j - 1] == '.')), dp[i][j - 1] + (a[i - 1][j - 1] == '#' && (j == 1 || a[i - 1][j - 2] == '.')));
    }
  }
  cout << dp[n][m] << '\n';
}



Measured memory_bytes: 384
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	B=map(x->parse(Int,x),split(readline()))
	K=sum(A)-sum(B)
	if K<0
		println(-1)
	else
		ans=N
		D=Int[]
		for i=1:N
			if A[i]>=B[i]
				push!(D,A[i]-B[i])
			end
		end
		sort!(D)
		for d=D
			if d<=K
				K-=d
				ans-=1
			end
		end
		println(ans)
	end
end
main()


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vector < double > p(n + 1);
  for(int i = 1; i <= n; i++) cin >> p[i];
  vector < vector < double > > dp(n + 1, vector < double > (n + 1, 0.0));

  p[0] = 0;
  dp[0][0] = 1.0;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= n; j++){
      if(j == 0) dp[i][j] = (1 - p[i]) * dp[i - 1][j];
      else dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
    }
  }

  double ans = 0;
  for(int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i];

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


Measured memory_bytes: 70784
#include <stdio.h>
int read(char s[]){
  int i,tmp=1,ret=0;
  for(i=0;s[i];i++){
    if(s[i]=='m'){
      ret+=tmp*1000;
      tmp=1;
    }
    else if(s[i]=='c'){
      ret+=tmp*100;
      tmp=1;
    }
    else if(s[i]=='x'){
      ret+=tmp*10;
      tmp=1;
    }
    else if(s[i]=='i')
      ret+=tmp;
    else
      tmp=s[i]-'0';
  }
  return ret;
}
int main(void){
  int n,t1,t2,ans;
  char s1[9],s2[10];
  scanf("%d",&n);
  while(n--){
    scanf("%s",s1);scanf("%s",s2);
    ans=read(s1)+read(s2);
    if(ans/1000==1)
      printf("m");
    else if(ans/1000)
      printf("%dm",ans/1000);
    ans%=1000;
    if(ans/100==1)
      printf("c");
    else if(ans/100)
      printf("%dc",ans/100);
    ans%=100;
    if(ans/10==1)
      printf("x");
    else if(ans/10)
      printf("%dx",ans/10);
    ans%=10;
    if(ans==1)
      printf("i");
    else if(ans)
      printf("%di",ans);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M, A[201010], B[201010];
vector<pair<int,int>> E[1010];
int ma[1010][1010], mi[1010][1010], vis[1010];
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
//---------------------------------------------------------------------------------------------------
void dfs1(int i, int cu, int v) {
    if (i == cu) return;
    if (ma[cu][i]) return;
    ma[cu][i] = v;
    fore(p, E[i]) dfs1(p.second, cu, v);
}
//---------------------------------------------------------------------------------------------------
void dfs2(int i, int cu, int v) {
    if (i == cu) return;
    if (mi[cu][i]) return;
    mi[cu][i] = v;
    fore(p, E[i]) dfs2(p.second, cu, v);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].push_back({ i + 1, b });
        //E[b].push_back({ i + 1, a });
        A[i] = a;
        B[i] = b;
    }

    // for max
    rep(i, 0, N) sort(all(E[i]), greater<pair<int, int>>());
    rep(cu, 0, N) fore(p, E[cu]) dfs1(p.second, cu, p.first);

    // for min
    rep(i, 0, N) sort(all(E[i]));
    rep(cu, 0, N) fore(p, E[cu]) dfs2(p.second, cu, p.first);

    rep(i, 0, M) {
        int a = A[i], b = B[i];

        if (mi[a][b] != ma[a][b] and mi[b][a]) {
            printf("same\n");
        }
        else if (mi[a][b] == ma[a][b] and !mi[b][a]) {
            printf("same\n");
        } else printf("diff\n");
    }
}

Measured memory_bytes: 13824
import math
N,D=map(int,input().split()) #Nはポイントの数　Dは次元数（点を示す変数の数）
P=0
Q=0
X= [list(map(int, input().split())) for t in range(N)]
for i in range(N-1):
  for j in range(i+1,N):
    for k in range(D):
      P=P+(X[i][k]-X[j][k])**2
    if int(math.sqrt(P))==math.sqrt(P):
      Q=Q+1
    P=0
print(Q)

Measured memory_bytes: 3064