akhauriyash/Code-Regression huggingface dataset:
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define scan(n) scanf("%lld",&n)
#define scan2(a,b) scanf("%lld %lld",&a,&b)
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define print(n) printf("%lld\n",n)
#define scanS(s) scanf("%s",&s)
#define printS(s) printf("%s",s)

#define ff first
#define ss second
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define pb push_back
#define popb pop_back
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli n;
    cin >> n;
    vlli v(n);
    lli i, j;
    rep (i, n) {
        cin >> v[i];
    }
    sort(all(v));
    i = 1, j = n - 2;
    deque<lli> q;
    lli sum = 0;
    q.push_front(v[n - 1]);
    sum += (q.front() - q.back());
    if(n > 1)   q.push_front(v[0]);
    while (i <= j) {
        lli ele1 = q.front(), ele2 = q.back();
        lli a = abs(v[i] - ele1);
        lli b = abs(v[i] - ele2);
        lli c = abs(v[j] - ele1);
        lli d = abs(v[j] - ele2);
        lli maxi = max(a, max(b, max(c, d)));
        if (maxi == a) {
            q.push_front(v[i]);
            i++;
        } else if (maxi == b) {
            q.push_back(v[i]);
            i++;
        } else if (maxi == c) {
            q.push_front(v[j]);
            j--;
        } else {
            q.push_back(v[j]);
            j--;
        }
    }
    //if (abs(v[i] - q.front()) > abs(v[i]))
    for(i = 1; i < q.size(); i++) {
        sum += abs(q[i] - q[i - 1]);
    }
    cout << sum << endl;
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

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

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << c+b-d << " " << d-a+c << " " << a+b-d << " " << b+c-a << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(n,10*n+1):
    judge=True
    num=list(str(i))
    num=map(int,num)
    if set(num)&set(d):
        judge=False
    if judge:
        print(i)
        exit()

Measured memory_bytes: 3064
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string s;
unordered_map<char, int> mp;

void solve() {
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return;
    }
    rep(i, s.length()) mp[s[i]] = int(i + 1);
    for (int i = 'a'; i <= 'z'; i++) {
        if (mp[char(i)] == 0) {
            cout << s + char(i) << endl;
            return;
        }
    }
    string min_s;
    rep(i, s.length()) {
        string cs(s);
        string temp1 = cs.substr(0, i + 1), temp2 = cs.substr(0, i + 1);
        unordered_map<char, int> mp1, mp2;
        rep(j, temp1.length()) mp1[temp1[j]]++;
        rep(j, temp2.length()) mp2[temp2[j]]++;
        for (char j = temp1[i]; j <= 'z'; j++) {
            if (mp1[j] == 0) {
                temp1[i] = j;
                min_s = min_s.empty() ? temp1 : min(min_s, temp1);
                break;
            }
        }
        if (i != 0)
            for (char j = temp2[i - 1]; j <= 'z'; j++) {
                if (mp2[j] == 0) {
                    temp2[i - 1] = j;
                    min_s = min_s.empty() ? temp2 : min(min_s, temp2);
                    break;
                }
            }
    }
    cout << min_s << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int cars[10];

    int in_car;
    int cnt = 0;
    while (scanf("%d", &in_car) != EOF) {
        if (in_car != 0) {
            cars[cnt] = in_car;
            cnt++;
        } else {
            cnt--;
            printf("%d\n", cars[cnt]);
        }
    }

    return 0;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  
  if ( a == 'H' && b == 'H'){
    cout << "H";
  }
  else if ( a == 'H' && b == 'D' ){
    cout << "D";
  }
  else if ( a == 'D' && b == 'H' ){
    cout << "D";
  }
  else if ( a == 'D' && b == 'D' ){
    cout << "H";
  }
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<int> X(N), Y(N);

REP(i, N){
	cin >> X[i];
	Y[i] = X[i];
}

sort(all(Y));

REP(i, N){
    if(X.at(i) < Y[N / 2]) print(Y[N / 2]);
    else print(Y[N / 2 - 1]);
}

}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long H;
    cin >> H;
    long int counter = 1;
    long long answer = 1;
    while (H > 1) {
        H /= 2;
        answer += pow(2,counter);
        counter++;
    }
    cout << answer << endl;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vi p(a), q(b), r(c);
	vector<pii> data;
    rep(i,a) {
        cin >> p[i];
        data.eb(p[i],1);
    }
    rep(i,b) {
        cin >> q[i];
        data.eb(q[i],2);
    }
    rep(i,c) {
        cin >> r[i];
        data.eb(r[i],0);
    }
    stable_sort(rall(data));
    
    /*
    for(auto d : data){
        cout << d.fi << " " << d.se << endl;
    }
    //*/
    
    ll ans = 0;
    int z = 0;
    for(auto d: data){
        if(d.se == 1 && x>0) {
            ans += d.fi;
            x--;
        }
        else if(d.se == 2 && y>0){
            ans += d.fi;
            y--;
        } 
        else if(d.se == 0){
            ans += d.fi;
            z--;
        }
        if(x+y+z==0) break;
    }
    cout << ans << endl;
	return;
}

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

Measured memory_bytes: 7916
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,k;
  cin >> n >> k;
  n*=500;
  if(n>=k){
    cout << "Yes" << endl;
  }  
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


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

ans = 0


if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
    print(ans)

elif (n == 2 and m >= 3) or (m == 2 and n >= 3):
    ans = 0
    print(ans)

elif (n == 1 and m >= 3) or (m == 1 and n >= 3):
    ans = n * m - 2
    print(ans)

elif n == 2 and m == 2:
    ans = 0
    print(ans)
    
elif n == 1 and m == 1:
    ans = 1
    print(ans)
    
else:
    ans = 0
    print(ans)


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

int main() {
  int N, A, B, t, n;
  cin >> N >> A >> B;
  int S = 0;
  
  for(int i = 1; i < N + 1; i ++) {
    int t = 0;
    int n = i;   
    while(n > 0) {
      t += n % 10;
      n /= 10;
    }
    
    if(A <= t && t <= B) {
      S += i;
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7

D = [0] * n

for i in range(n):
    D[A[i]] += 1

ok = 1
if n % 2 == 0:
    for i in range(1, n, 2):
        if D[i] != 2:
            ok = 0
            break
else:
    if D[0] != 1:
        ok = 0
    for i in range(2, n//2+1, 2):
        if D[i] != 2:
            ok = 0
            break

ans = 0
if ok == 1:
    ans = 1
    for i in range(n//2):
        ans = (ans * 2) % mod

print(ans)

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        a -= d;
        c -= b;
    }
    if (c <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){

	int n;
	int i,j;
	int sum[120]={0};
	
	scanf("%d", &n);
	
	int building[n];
	int floor[n];
	int room[n];
	int people[n];
	
	for(i=0;i<n;i++){
		scanf("%d",&building[i]);
		scanf("%d",&floor[i]);
		scanf("%d",&room[i]);
		scanf("%d",&people[i]);
		sum[(building[i]-1)*30+(floor[i]-1)*10+room[i]-1] += people[i];
	}

	for(i=0;i<120;i++){
		if(i%30==29 && i!=119){
			printf(" %d\n",sum[i]);
			for(j=0;j<20;j++){
				printf("#");
			}
			printf("\n");
		}else if(i%10==9){
			printf(" %d\n",sum[i]);
		}else{
			printf(" %d",sum[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	bool flag=1;
	int t,mx,mn;
	scanf("%d",&t);
	scanf("%d",a+1);
	mx=mn=a[1];
	for(int i=2;i<=t;++i)
	{
		scanf("%d",a+i);
		if(a[i]!=a[i-1]) flag=0;
		mx=max(mx,a[i]);mn=min(mn,a[i]);
	}
	if(mx>mn+1) {puts("No");return 0;}
	int n=0,m=0;
	for(int i=1;i<=t;++i)
	if(a[i]==mx) ++n;
	else ++m;
	if(!flag)
	{
		if(mx-m<=0) {puts("No");return 0;}
		if(2*(mx-m)<=n) puts("Yes");
		else puts("No");
	}
	else
	{
		if(mx==t-1) {puts("Yes");return 0;}
		if(mx<=t/2) puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s,t;cin >> s;
    rep(i,s.size()){
        if(i%2==0)t+=s[i];
    }
    cout << t <<endl;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000000 + 100;
int e, Begin[Maxn], To[Maxn * 2], Next[Maxn * 2];
int Dp[Maxn], Val[Maxn], fa[Maxn];
int N;
inline void add_edge(int x, int y)
{
	To[++e] = y;
	Next[e] = Begin[x];
	Begin[x] = e;
}
inline void dfs(int x)
{
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		if (fa[x] == y || Val[y] >= Val[x])
			continue;
		dfs(y);
		if (!Dp[y])
			Dp[x] = 1;
	}
}
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
		scanf("%d", &Val[i]);
	int x, y;
	for (int i = 1; i < N; ++i)
	{
		scanf("%d%d", &x, &y);
		add_edge(x, y);
		add_edge(y, x);
	}
	for (int i = 1; i <= N; ++i)
	{
		memset(Dp, 0, sizeof(Dp));
		dfs(i);
		if (Dp[i])
			printf("%d ", i);
	}
	cout<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#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())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= max(a, b) * 100; i++) {
        double aa = floor(i * 0.08);
        double bb = floor(i * .1);
        if (aa == a && bb == b) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  string s;
  cin >> s;
  int n = s.size();

  mint dp[n+1][13];
  rep(i, n+1) rep(j, 13) dp[i][j] = 0;
  dp[0][0] = 1;

  rep(i, n) {
    if(s[i] != '?') {
      int x = s[i]-'0';
      rep(j, 13) dp[i+1][(10*j+x)%13] += dp[i][j];
    }
    else {
      rep(x, 10) {
        rep(j, 13) dp[i+1][(10*j+x)%13] += dp[i][j];
      }
    }
  }
  cout << dp[n][5].x << endl;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int counter = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
        if (0<=z && z <= K) counter++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
from collections import Counter
from operator import itemgetter
import math
num1 = 2
num2 = 3
chk = 0
N,K =map(int,input().split())
if K > (N-1)*(N-2)//2:
	print(-1)
else:
	left = (N-1)*(N-2)//2 - K
	print(left+N-1)
	for i in range(2,N+1):
		print("1"+" "+str(i))

	for i in range(left):
			if N >= num2 :
				if chk == 1:
					num2 += 1
					chk = 0
				print(str(num1) + " " + str(num2))
				num2 += 1
			else:
				num1 +=1
				num2 = num1+1
				print(str(num1) + " " + str(num2))
				chk = 1

Measured memory_bytes: 3588
pw=[input() for i in range(2)]
length=len(pw[0])
full_pw=[]
i=0
while i < length:
    full_pw.append(pw[0][i])
    if i <=len(pw[1])-1:
        full_pw.append(pw[1][i])
    i+=1

print(*full_pw,sep='')

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int,int> D;
int P[100005];
vector<int> G[100005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, a, b, K, v, p;
  cin >> N;
  for( int i=0; i<N-1; i++ ){
    cin >> a >> b;
    G[b].push_back( a );
    G[a].push_back( b );
  }
  cin >> K;
  priority_queue< D, vector<D>, greater<D> > q;
  for( int i=1; i<=N; i++ ){
    P[i] = -1;
  }
  for( int i=0; i<K; i++ ){
    cin >> v >> p;
    P[v] = p;
    q.emplace( p, v );
  }
  while( !q.empty() ){
    p = q.top().first;
    v = q.top().second;
    q.pop();
    for( int i=0; i<G[v].size(); i++ ){
      int u = G[v][i];
      if( P[u] >= 0 ){
        if( P[u] != p-1 && P[u] != p+1 ){
          cout << "No" << '\n';
          return 0;
        }
      } else {
        P[u] = p + 1;
        q.emplace( P[u], u );
      }
    }
  }
  cout << "Yes" << '\n';
  for( int i=1; i<=N; i++ ){
    cout << P[i] << '\n';
  }
}

Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int main(int argc, char *argv[])
{
    int n;
    long long d;
    scanf("%d%lld",&n,&d);
    long long dis=d*d;
    long long x,y;
    int ans=0;
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&x,&y);
        long long xy=x*x+y*y;
        if(xy<=dis){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}

 

Measured memory_bytes: 3824
import math
A, B, H, M = map(int, input().split())
tan_kaku = H * 30 + M * 0.5
cho_kaku = M * 6
rad = math.radians(abs(tan_kaku-cho_kaku))
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(rad)))


Measured memory_bytes: 9452
#include <cstdio>

using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  int a[2];
  a[0] = n / 10;
  a[1] = n % 10;
  if(a[0] == 9||a[1]==9){
    printf("Yes");
  }else{
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>

typedef long long int LLD;

int main() {
    int a[3];
    scanf("%d%d%d", a, a+1, a+2);
    std::sort(a, a+3);
    printf("%d\n", a[2]*10+a[1]+a[0]);
    return 0;
}


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }
    ll res = r*g*b;

    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            if(j-i <= n-1-j){
                int k = 2*j-i;
                if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) res--;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, ans = inf;
int w[200];

int main() {

	cin >> n;
	rrep(i, n) {
		int tmp;
		cin >> tmp;
		w[i] = w[i - 1] + tmp;
	}


	rrep(i, n) {
		ans = min(ans, abs(w[i - 1] - (w[n] - w[i - 1])));
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int r = c / b;
    if (c % b)
        r++;

    int s = a / d;
    if (a % d)
        s++;

    cout << (r <= s ? "Yes" : "No") << endl;
}

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

int main(){
	int n, k;
	string s;
	cin >> n >> k >> s;
	k--;
	if(s[k] >= 'A' && s[k] <= 'Z'){
		s[k] = s[k] - ('A' - 'a');
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty -sy
r = ''
if dx > 0:
    dxc = 1
else:
    dxc = 0
    
if dy > 0:
    dyc = 1
else:
    dyc = 0
    
if dxc:
    r += 'R' * dx
else:
    r += 'L' * dx
    
if dyc:
    r += 'U' * dy
else:
    r += 'D' * dy
    
if dxc:
    r += 'L' * dx
else:
    r += 'R' * dx
    
if dyc:
    r += 'D' * dy
else:
    r += 'U' * dy
    
    
if dyc:
    r += 'D' * 1
else:
    r += 'U' * 1      
    
if dxc:
    r += 'R' * (dx +1)
else:
    r += 'L' * (dx+1)
    
if dyc:
    r += 'U' * (dy + 1)
else:
    r += 'D' * (dy + 1)
    
if dxc:
    r += 'L' * 1
else:
    r += 'R' * 1
    
    
    
if dyc:
    r += 'U' * 1
else:
    r += 'D' * 1      
    
if dxc:
    r += 'L' * (dx +1)
else:
    r += 'R' * (dx+1)
    
if dyc:
    r += 'D' * (dy + 1)
else:
    r += 'U' * (dy + 1)
    
if dxc:
    r += 'R' * 1
else:
    r += 'L' * 1
    
    
print(r)
    
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define MOD 1e9+7
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 300100

ll N,U,D;

vi V;
bool done[MAXN];

int main(){
	cin>>N>>U>>D;
	if (U*D<N||U+D>N+1){
		cout<<-1;
		return 0;
	}
	for (int i=N;i>0;i-=D){V.pb(i);done[i]=1;}
	for (int i=1;i<=N&&SZ(V)<U;++i){
		if(done[i])continue;
		V.pb(i);
		done[i]=1;
	}
	vi out;
	sort(ALL(V));
	for (auto i : V){
		int t = i-1;
		out.pb(i);
		while(t>0&&!done[t]){
			out.pb(t);
			done[t]=1;
			--t;
		}
	}
	for (auto i : out)cout<<i<<' ';
	assert(SZ(out) == N);
}

Measured memory_bytes: 11884
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
      cin.tie(NULL);
      ios::sync_with_stdio(false);
      long long n,h[100010],sum=0;
      cin>>n;
      long long big=0;
      for(int i=1;i<=n;i++) cin>>h[i];
      for(int i=1;i<=n-1;i++){
        if(h[i]>=h[i+1]) sum++;
        if(h[i]<h[i+1]){
          big=max(big,sum);
          sum=0;
        }
      }
      cout<<max(big,sum)<<'\n';
      return 0;
    }

Measured memory_bytes: 1024
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Max 100009
ll n,m,a,b,ans;
ll v[Max],p[Max];

int main() {
	cin>>n;
	string sh;
	cin>>sh;
	cin>>m;
	for(int i=0;i<sh.size();i++){
		if(sh[i]==sh[m-1]) cout<<sh[i];
		else cout<<"*";
	}
	cout<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

void print_v(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+97);
    }
    cout << endl;
}

int main()
{
	string s,t;
    cin >> s >> t;
    cout << t+s << endl;



    return 0;
}


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int n,sz,ok=0;
    cin>>n;
    string s;
    cin>>s;
    sz=s.size();
    if(sz%2==1)
    {
        cout<<"No"<<nl;
        return 0;
    }
    for(int i=0,j=(sz/2); i<(sz/2) && j<sz; i++,j++)
    {
        if(s[i]!=s[j])
            ok=1;
    }
    if(ok==0)
        cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
//約数の列挙
vector<ll> divisor(ll n){
    vector<ll> res;//約数を格納する列
    for(int i= 1;i*i <= n;i++){
        if(n % i == 0){
           res.push_back(i);
           if(i != n/i) res.push_back(n/i);
         }
    }
    return res;
}

int main(){
  ll N,M;
  cin >> N >> M;

  vector<ll> res = divisor(M);
  sort(res.begin(),res.end());
  reverse(res.begin(),res.end());

  /*for(int i = 0;i<res.size();i++){
      cout << res[i] << endl;
  }*/
  ll ans = 0;
  for(int i = 0;i<res.size();i++){
      if(M/res[i] >= N){
          ans = res[i];
          break;
      }
  }
  cout << ans << endl;
 }

Measured memory_bytes: 256
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int train = N*A;
    int taxi = B; 
 
    if(train - taxi >0){
      System.out.println(taxi);
    } else {
      System.out.println(train);
    }
    
  }
}

Measured memory_bytes: 22740
/* 
 * Project: AtCoder Beginners Contest 152 C - Low Elements
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/18
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <climits>
using namespace std;

int n;
int p;

int main() {

    scanf("%d", &n);
    int min_p = INT_MAX;
    int cnt = 0;
    for (int i=0;i<n;i++) {
        scanf("%d", &p);
        if (p < min_p) {
            min_p = p;
            cnt++;
        }
    }
    printf("%d\n", cnt);

}

Measured memory_bytes: 3212
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cmath>

#define ll long long

typedef struct cplx{
  double real;
  double imag;
}cplx;

typedef struct poly{
  std::vector<ll> coef;  
}poly;

cplx mul(cplx a, cplx b){
  cplx erg;
  erg.real = a.real * b.real - a.imag * b.imag;
  erg.imag = a.real * b.imag + b.real * a.imag;
  return erg;
};

cplx add(cplx a, cplx b){
  cplx erg;  
  erg.real = a.real + b.real;
  erg.imag = a.imag + b.imag;
  return erg;
};

cplx ic(int a){
  cplx erg;  
  erg.real = a;
  erg.imag = 0.0;
  return erg;
};

ll ci(cplx a){
  return std::llround(a.real);
};

void fft(std::vector<cplx> &in, std::vector<cplx> &out, int inv){
  int sz = in.size();
  int lg = __builtin_ctz(sz);
  for(int i = 0;i<sz;i++)out[i] = in[i];
  for(int i = 1;i<sz;i++){
    int rev = 0;
    for(int j = 0;j<lg;j++)rev |= (((i & (1<<j))>>j)<<(lg-j-1));
    if(i > rev)std::swap(out[i],out[rev]);
  };
  double arg;
  double pi = acos(-1.0f);
  cplx unR;
  cplx unK;
  int ss = 2;
  while(ss <= sz){
    arg = 2.0 * pi * 1.0/ss;    
    arg *= inv ? 1 : -1;
    unR.real = cos(arg);
    unR.imag = sin(arg);
    for(int i = 0;i<sz;i+=ss){
      unK.real = 1.0;  
      unK.imag = 0.0;
      int sss = ss>>1;
      for(int j = i;j<i+sss;j++){
        cplx f1 = out[j];
        cplx f2 = out[j+sss];
        out[j] = add(f1,mul(unK,f2));
        out[j+sss] = add(f1,mul(unK,mul(f2,ic(-1))));
        unK = mul(unK,unR);
      };
    };
    ss <<= 1;
  };
  cplx br;
  br.real = 1.0/sz;
  br.imag = 0;
  if(inv)for(auto &i:out)i = mul(i,br);
};

poly mulP(poly &a, poly &b){
  int sz = std::max(a.coef.size(),b.coef.size()); 
  int nsz = 0;
  while((1ll<<nsz)<sz)nsz++;
  nsz++;
  std::vector<cplx> p1(1ll<<nsz,{0.0,0.0});
  std::vector<cplx> p2(1ll<<nsz,{0.0,0.0});
  /*for(int i = 0;i<a.coef.size();i++)p1[i+(1ll<<(nsz-1))] = a.coef[i];
  for(int i = 0;i<b.coef.size();i++)p2[i+(1ll<<(nsz-1))] = b.coef[i];
  */
  for(int i = 0;i<a.coef.size();i++)p1[i] = ic(a.coef[i]);
  for(int i = 0;i<b.coef.size();i++)p2[i] = ic(b.coef[i]);
  fft(p1,p1,0);
  fft(p2,p2,0);
  for(int i = 0;i<p1.size();i++){
    p1[i] = mul(p1[i],p2[i]);  
  };
  fft(p1,p1,1);
  poly erg;
  for(auto i: p1)erg.coef.push_back((ll)ci(i));
  return erg;
}; 


#define MM 200003ll

ll mp[MM];
ll mmp[MM];

int main(void){
  mp[0] = 1; 
  mmp[1] = 0;
  for(int i = 1;i<MM-1;i++){
    mp[i] = (mp[i-1] * 2) % MM;  
    mmp[mp[i]] = i;
  };
  poly a;
  a.coef = std::vector<ll>(MM);
  std::vector<int> asq;
  int n;
  scanf("%d",&n);
  int al;
  for(int i = 0;i<n;i++){
    scanf("%d",&al);  
    if(al){
      asq.push_back(al);
      a.coef[mmp[al]]++;
    };
  };
  auto b = mulP(a,a);
  ll erg = 0;
  for(int i = 0;i<asq.size();i++){
    b.coef[mmp[asq[i]] * 2]--;
  };
  for(int i = 0;i<b.coef.size();i++){
    if(b.coef[i] != 0){
      //printf("%lld\n",b.coef[i]);
      if(i >= MM-1){
        erg += b.coef[i]/2 * mp[i-MM+1];  
      }else{
        erg += b.coef[i]/2 * mp[i];  
      };    
    };
  };
  printf("%lld\n",erg);
  return 0;
};


Measured memory_bytes: 29188
#include<iostream>
#include<algorithm>
#include <array>
int main(void){
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;
	if (x - r<0 || y - r<0 || x + r>W || y + r>H){
		std::cout << "No" << std::endl;
	}
	else{
		std::cout << "Yes" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9+7;
using P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll mod_pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  long long N,check=0,maxA=0;
  cin>>N;
  vector<long long> A(N);
  long long lasta=0;
  for(long long i=0;i<N;i++){
    cin>>A.at(i);
    maxA=max(maxA,A.at(i));
  }
  //cout<<A.size()<<endl;
  long long count;
  long long money;
  money=1000;
  count=0;
  long long minimum=A.at(0);
  for(long long i=1;i<N;i++){
    if(A.at(i)<minimum){
      minimum=A.at(i);
    }
    else if(i<N-1){
      if(A.at(i+1)<A.at(i) && A.at(i)>minimum){
      count=money/minimum;
      money-=count*minimum;
      money+=count*A.at(i);
      //cout<<count<<" "<<minimum<<" "<<A.at(i)<<endl;
      count=0;
      minimum=1000;
    }
    }
    if(i==N-1){
      if(A.at(i)>minimum){
        count=money/minimum;
      money-=count*minimum;
      money+=count*A.at(i);
      //cout<<count<<" "<<minimum<<" "<<A.at(i)<<endl;
      count=0;
      }
    }
  }
  cout<<money<<endl;
}

Measured memory_bytes: 3632
s=input().split()
x=[]
top=len(s)
for i in range(top):
        
    if s[i]=="+":
        a=x.pop()
        b=x.pop()
        x.append(int(b)+int(a))
    elif s[i]=="-":
        a=x.pop()
        b=x.pop()
        x.append(int(b)-int(a))
    elif s[i]=="*":
        a=x.pop()
        b=x.pop()
        x.append(int(b)*int(a))
    else:
        x.append(s[i])
   
print(x[0])



Measured memory_bytes: 5600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author GYSHGX868
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int k = in.nextInt();
      int s = in.nextInt();
      int answer = 0;
      for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
          int z = s - x - y;
          if (z >= 0 && z <= k) {
            answer++;
          }
        }
      }
      out.printLine(answer);
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }
}



Measured memory_bytes: 21460
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    //return p1.second > p2.second;
    return p1.second < p2.second;
}

//a, bの最大公約数．a > b
ull gcd(ull a, ull b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
//a, bの最小公倍数
ull lcm(ull a, ull b) {
    return a*(b/gcd(a, b));
}

void solve(){
    int n,res=0;;
    int p[25];
    cin >> n;
    rep(i, n) cin >> p[i];
    for(int i = 1; i < n-1; i++){
        if((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])){
            res++;
        }
    }
    cout << res << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#define ll long long

using namespace std;

const int M = 1000000007;

int n, x;
int a[100010];

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> x; x--;
		a[x] = i+1;
	}
	
	for (int i = 0; i < n; i++) cout << a[i] << " ";
	
return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;

int main()
{
	fast();
	int n;
	cin >> n;
	vector<int> a(n + 1);
	map<int, int> ma;
	ll rs = 0;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		if(i > 1){
			rs += ma[a[i] - i];
		}
		int t = -1 *(a[i] + i);
		ma[t] ++;
		
	}
	cout << rs;

}			

Measured memory_bytes: 21084
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let r = read::<f64>();
    println!("{}", 2.0 * r * std::f64::consts::PI);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2184
H, W, K = map(int, input().split())
c = []
for i in range(H):
  tmp = input()
  c.append(tmp)
ans = 0
for h in range(2**H):
  h_list = []
  for i in range(H):
    if ((h >> i) & 1):
      h_list.append(i)
  for w in range(2**W):
    w_list = []
    for j in range(W):
      if ((w >> j) & 1):
        w_list.append(j)
    tmp = 0
    for i in range(H):
      for j in range(W):
        if i in h_list:
          continue
        if j in w_list:
          continue
        if c[i][j] == '#':
          tmp += 1
    if tmp == K:
      ans += 1
print(ans)
          

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;


vector<li> edge[2020];
li n, k;

inline li calc(li root, li parent, li lim) {
    stack<pair<PI, li>> stk;
    li cnt = 0;
    stk.push({{root, parent}, 0});
    while (!stk.empty()) {
        li now = stk.top().first.first;
        li from = stk.top().first.second;
        li now_d = stk.top().second;
        stk.pop();
        cnt++;
        if (now_d >= lim)continue;
        for (auto next : edge[now]) {
            if (next == from)continue;
            stk.push({{next, now}, now_d + 1});
        }
    }
    return cnt;
}

inline li solve_node() {
    li res = n;
    rep(i, n) {
        res = min(res, n - calc(i, -1, k / 2));
    }
    return res;
}

inline li solve_link() {
    li res = n;
    rep(i, n) {
        for (auto to : edge[i]) {
            res = min(res, n - calc(i, to, k / 2) - calc(to, i, k / 2));
        }
    }
    return res;
}

int main(void)
{
    cin >> n >> k;
    rep(i, n - 1) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    if (k % 2 == 0) {
        cout << solve_node() << endl;
    } else {
        cout << solve_link() << endl;
    }


    return 0;
}

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

int main()
{
    string S;
    for(int i = 0; i < 3; ++i) {
        string tmp;
        cin >> tmp;
        S.push_back(tmp[0] - 'a' + 'A');
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;

int main(){

    int N;cin>>N;
    vector<char> S(N);
    for(int i=0;i<N;i++) cin>>S[i];
    
    ll dp[N+1][N+1];
    memset(dp,0,sizeof(dp));
    
    dp[0][0]=1;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            if(S[i]=='-'){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
            }else if(S[i]=='U'){
                dp[i+1][j+1]+=dp[i][j]*(i-j);
                dp[i+1][j]+=dp[i][j];
                
                dp[i+1][j+1]%=mod;
                dp[i+1][j]%=mod;
            }else if(S[i]=='D'){
                dp[i+1][j+2]+=dp[i][j]*(i-j)*(i-j);
                dp[i+1][j+1]+=dp[i][j]*(i-j);
                
                dp[i+1][j+2]%=mod;
                dp[i+1][j+1]%=mod;
            }
        }
    }
    
    cout<<dp[N][N]<<endl;
}



Measured memory_bytes: 3372
input0=input("")
e=0
f=0
g=0
i=0

c=input0[::2]
d=input0[1::2]

for a in c:
    b=2
    if(a=="L"):
        b=1
    else:
        b=0
    e=e+b
    
for a in d:
    b=2
    if(a=="R"):
        b=1
    else:
        b=0
    f=f+b

g=e+f

if(g==0):
    print("Yes")
else:
    print("No")

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, S;
	cin >> N >> K >> S;
	int t = S + 1;
	if (S == 1000000000) {
		t = S - 1;
	}
	vector<int> res(N, t);
	for (int i = 0; i < K; i++) {
		res[i] = S;
	}
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << res[i];
	}
	cout << endl;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(){
  int i,j,min,n,a[100],cnt=0,array;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j]<a[min]){
	min=j;
      }
    }
    if(min!=i){
      cnt++;
      array=a[i];
      a[i]=a[min];
      a[min]=array;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2732
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(K)

temp = 0
for i in range(N):
  if temp < A[i+1] - A[i]:
    temp = A[i+1] - A[i]
A.pop(-1)

ans = K - max(temp, A[0] - A[-1] + K)

print(ans)

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

vector<int> bit;

void make_bit( long long n){
//    cout << n << endl;
    if(n==0){
        return;
    }
    if( abs(n) %2==1){
        bit.push_back(1);
        return  make_bit( (n-1)/2 *(-1) );
    }
    if( abs(n) %2==0){
        bit.push_back(0);
        return make_bit( n/2 *(-1) );
    }
}

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

    if(N==0){
        cout << N << endl;
        return 0;
    }
    make_bit(N);
//    cout << bit.size() << endl;
    for(int i=0; i<bit.size(); i++){
        cout << bit.at(bit.size()-i-1) ;
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(int argc, char const *argv[])
{
	string S;
	long long cnt = 0, ans = 0;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'B')
		{
			cnt++;
		}
		else
		{
			ans += cnt;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
// bear.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
bool cmp(int i, int j)
{
	return i < j;
}
int main()
{
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
	{
		cout << s;
		cout << "es";
	}
	else
	{
		cout << s;
		cout << "s";
	}
	return 0;
}



Measured memory_bytes: 3632
import math

while True:
  try:
    V = float(input())
    for n in range(1, 1000):
      height = 5 * n - 5
      t = math.sqrt( height/4.9 ) 
      v = 9.8 * t
      if v >= V:
        break
    print(n)
  except:
    break


Measured memory_bytes: 5640