akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

struct UnionFind {
public:
	using size_type = std::size_t;
	
	UnionFind(size_type n) : n(n), size_(n, 1) {
		par.resize(n);
		std::iota(par.begin(), par.end(), 0);
	}
	
	size_type size(size_type x) { return size_[find(x)]; }
	
	size_type find(size_type x) {
		assert(x < n);
		while (par[x] != x) {
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	void unite(size_type x, size_type y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size(x) > size(y)) std::swap(x, y);
		par[x] = y;
		size_[y] += size_[x];
	}
	
	bool issame(size_type x, size_type y) { return find(x) == find(y); }
	
private:
	size_type n;
	std::vector<size_type> size_, par;
};

int main() {
	int N, M;
	cin >> N >> M;
	
	UnionFind uf(N);
	
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		uf.unite(a, b);
	}
	
	int ans = 0;
	REP(i, N) chmax(ans, uf.size(i));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6432
/*
[tenka1-2018] E - Equilateral
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int N = 300;

int H, W;
bool s[N][N];
int cnt[2][N * 4 + 2][N * 4 + 2];

bool is_in(int i, int j) { return 0 <= i && i < H && 0 <= j && j < W; }

ll solve() {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (!s[i][j]) {
                continue;
            }
            for (int d = 1; is_in(i + d, j + d); d++) {
                if (!s[i + d][j + d]) {
                    continue;
                }
                cnt[0][i + j + N][j - i - 2 * d + 2 * N]++;
                cnt[0][i + j + 2 * d + 2 + N][j - i - 2 * d + 2 * N]--;
                cnt[0][i + j + N][j - i + 2 * d + 2 * N]++;
                cnt[0][i + j + 2 * d + 2 + N][j - i + 2 * d + 2 * N]--;
            }
            for (int d = 1; is_in(i - d, j + d); d++) {
                if (!s[i - d][j + d]) {
                    continue;
                }
                cnt[1][i + j + 2 * d + N][j - i + 2 + 2 * N]++;
                cnt[1][i + j + 2 * d + N][j - i + 2 * d + 2 * N]--;
                cnt[1][i + j - 2 * d + N][j - i + 2 + 2 * N]++;
                cnt[1][i + j - 2 * d + N][j - i + 2 * d + 2 * N]--;
            }
        }
    }

    for (int u = 1; u < 4 * N; u++) {
        for (int v = 0; v < 4 * N; v++) {
            cnt[0][u][v] += cnt[0][u - 1][v];
        }
    }
    for (int u = 0; u < 4 * N; u++) {
        for (int v = 1; v < 4 * N; v++) {
            cnt[1][u][v] += cnt[1][u][v - 1];
        }
    }

    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j]) {
                int u = i + j;
                int v = j - i;
                ans += cnt[0][u + N][v + 2 * N] + cnt[1][u + N][v + 2 * N];
            }
        }
    }

    return ans;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        string row;
        cin >> row;
        for (int j = 0; j < W; j++) {
            s[i][j] = (row[j] == '#');
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 11776
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; ll ecnt = 0; ll ocnt = 0;
  
  rep(i,n){
    ll x; cin >> x;
    if(x % 2 == 0) ecnt++;
    else ocnt++;
  }
  
  if(ocnt % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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;
  cin >> s;
  YesorNo(s.find('7') != string::npos);
} 

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

class Segment_Tree {
private:
  int N;
  vector<int> dat;
public:
  Segment_Tree(int n){
    N = 1;
    while(N<n)N*=2;
    dat.resize(N * 2 - 1, INT_MAX);
  }

  // 0-indexed
  void update(int a, int x){
    a += (N - 1);
    dat[a] = x;
    while(a > 0){
      a = (a - 1) / 2;
      dat[a] = min(dat[a * 2 + 1], dat[a * 2 + 2]);
    }
  }

  int get_min(int a, int b, int k = 0, int left = 0, int right = -1){
    if(right < 0) right = N;
    
    if(right <= a || b <= left) return INT_MAX;
    if(a <= left && right <= b) return dat[k];
    else {
      int vl = get_min(a, b, 2 * k + 1, left, (left + right) / 2);
      int vr = get_min(a, b, 2 * k + 2, (left + right) / 2, right);
      return min(vl, vr);
    }
  }
};


int main(){
  int n, q;
  int com, x, y;
  cin >> n >> q;
  Segment_Tree seg(n);
  rep(i, q){
    cin >> com >> x >> y;
    if(com){
      cout<<seg.get_min(x, y + 1) << endl;
    }else{
      seg.update(x, y);
    }
  }
  return 0;
}



Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

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

int n, a[N], m;
string s, t;

int32_t main(){_
   

   int ans = 0;
   int l, r, d;
   cin >> l >> r >> d;
   
   for (int i = l; i <= r; ++i)
   {
      if (i % d == 0){
         ans ++;
      }
   }

   cout<<ans;

   return 0;
}

Measured memory_bytes: 3636
s = int(input())

a = [s]
for i in range(1, 1000001):
    if a[i-1] % 2 == 0:
        a.append(a[i-1]//2)
    else:
        a.append(3*a[i-1]+1)

    if a[i] in a[:-1]:
        print(i+1)
        break


Measured memory_bytes: 3068
#include<stdio.h>
int main()
{
	long long int mod = 1e9+7;
	long long int m = 1;
	int n,i;
	scanf("%d",&n);
	for(i = 1;i<=n;i++)
	{
		m = (m * i) % mod;
	} 
	printf("%lld",m);
	return 0;
}

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

using namespace std;
typedef pair<int, int> P;
static const int INF = 1e9;
int dp[101][101];

void solve()
{
	int n;
	cin >> n;
	vector<P> card(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> card[i].first >> card[i].second;
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n; ++j)
		{
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j <= n - i; ++j)
		{
			for (int k = j; k < j + i; ++k)
			{
				int cost = card[j].first * card[k].second * card[k + 1].first * card[j + i].second;
				dp[j][j + i] = min(dp[j][j + i], cost + dp[j][k] + dp[k + 1][j + i]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
}

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

Measured memory_bytes: 1224
from math import cos, sqrt, radians


A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)

Measured memory_bytes: 9448
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define LL long long
using namespace std;

LL dp[500][2550];
LL x, ans;

int main()
{
	int n, aver;
	cin >> n >> aver;
	dp[0][0] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> x;
		for(int j = i; j > 0; j--)
			for(int k = x; k <= 2550; k++)
				dp[j][k] += dp[j - 1][k - x];//k要大于等于x
	}
	
	for(int i = 1; i <= n; i++)
		ans += dp[i][i * aver];
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
 #include <iomanip>
//  #include<stdio.h>
using namespace std;

int main() {

    double r;
    cin>>r;
    double x = 3.14159265358979323846;

    cout<<fixed<<setprecision(6)<<(r*r*x)<<" "<<fixed<<setprecision(6)<<(2*r*x)<<endl;

}



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

int main(){
  int d, t, s;
  cin >> d >> t >> s;
  if (d > t * s) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

const string yes = "YES";
const string no = "NO";

int main(){
    string s;cin>>s;
    int n=s.size();
    vi cnt(3,0);
    for(char c : s){
        cnt[c-'a']++;
    }
    int max = *max_element(all(cnt));
    int min = *min_element(all(cnt));
    if(max-min <= 1) cout << yes << endl;
    else cout << no << endl;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# 回の決め打ち二分探索
import math


def solve(n):
    cnt = 0
    for i in a:
        if i % n == 0:
            cnt += i // n - 1
        else:
            cnt += i // n
    if cnt <= k:
        return True  # k以下の分割で長さn いかにできる
    else:
        return False


n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
ng = 0  # 長さ1にはできる
ok = 10 ** 9 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)


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

typedef long long LL;

string s,t;
vector<vector<int>> dp(3003,vector<int>(3003,-1));
vector<vector<pair<int,int>>> par(3003,vector<pair<int,int>>(3003,{-1,-1}));


int lcs(int n,int m)
{
  if(n<0 || m<0) return 0;
  if(dp[n][m]!=-1) return dp[n][m];
  if(s[n] == t[m])
  {
    if(n>=0 && m>=0) par[n][m] = {n-1,m-1};
  	return dp[n][m] = 1+lcs(n-1,m-1);
  }
  int ans1 = lcs(n-1,m);
  int ans2 = lcs(n,m-1);
  if(ans1>ans2)
  {
  	if(n>=0 && m>=0) par[n][m] = {n-1,m};
    return dp[n][m] = ans1;
  }else
  {
  	if(n>=0 && m>=0) par[n][m] = {n,m-1};
    return dp[n][m] = ans2;
  }
}

int main()
{
  cin>>s>>t;
  int n = s.size();
  int m = t.size();
  lcs(n-1,m-1);
  int i=n-1;
  int j=m-1;
  string ans = "";
  while(i>=0 && j>=0){
    if(s[i]==t[j]) ans+=s[i];
    int t = i;
  	i = par[i][j].first;
  	j = par[t][j].second;
  }
  for(int i=ans.size()-1;i>=0;i--) cout<<ans[i];
  cout<<endl;
}

Measured memory_bytes: 109632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin >>S;
  int count =0;
  int a = S.size();
  for (int i = 0; i < a; i++) {
 if(S.at(i)!=S.at(a-1-i)){
   count++;
 }
}
cout<<count/2<<endl;
 
}

Measured memory_bytes: 256
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ns()
ans = "Yes"
for i in range(1, int(len(n)/2)+1):
        if n[i-1] != n[-i]:
                ans = "No"
                break

print(ans)

Measured memory_bytes: 5312
N = [int(n) for n in input()]
 
 
dp = [[0] * 2 for _ in range(len(N) + 1)]
dp[0][1] = 1
 
for i, n in enumerate(N):
    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n))
    dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1)))
    
print(dp[-1][0])

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

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

    queue<pair<int,int>> que;
    que.push({0,n});
    int res=0;
    while(!que.empty()){
        auto range=que.front(); que.pop();
        int l=range.first,r=range.second;
        //cerr<<l<<" "<<r<<endl;
        int head=l;
        bool isBreak=false;
        for(int i=l;i<=r;i++){
            if(i==r || h[i]==0){
                if(i==r && head==l) break;
                isBreak=true;
                if(head!=i) que.push({head,i});
                head=i+1;
            }
        }
        if(isBreak) continue;
        for(int i=l;i<r;i++){
            h[i]--;
        }
        que.push({l,r});
        res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long int ll;

int main(){
  int n;  cin >> n;
  int t, a; cin >> t >> a;
  int ans = 1;
  float ansTem = 100100100;

  rep(i, 1, n+1){
    int h;  cin >> h;
    float tmp = t - h * 0.006;
    if(fabs(ansTem - a) > fabs(tmp - a)){
      ans = i;
      ansTem = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans = 0;
	for(int i = 1 ; i <= N ; i++){
		if( i >= K + 1 ) ans += Y;
		else ans += X;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ct = 0;

    int lim1 = N/R;
    for (int i = 0; i <= lim1; ++i)
    {
        int lim2 = (N-i*R)/G;
        for (int j = 0; j <= lim2; ++j)
            if ((N-i*R-j*G)%B == 0)
            {
                ++ct;
            }
    }
    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 384
dx, dy, s = [1, 0, -1, 0], [0, 1, 0, -1], 'RDLU'


def f(x, y, d):
    x -= int(d == 2)
    y = y * 2 + dy[d]
    if not(0 <= y < len(a) and 0 <= x < len(a[y])):
        return False
    return a[y][x] == '1'

a = [raw_input() for i in range(9)]
x = y = d = 0
t = ''
while True:
    x += dx[d]
    y += dy[d]
    t += s[d]
    if x == 0 and y == 0:
        break
    for i in [(d + j + 3) % 4 for j in range(3)]:
        if f(x, y, i):
            d = i
            break
    else:
        d = (d + 2) % 4
print t

Measured memory_bytes: 4252
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
        count += 1
    elif p[i] > p[i+1] and p[i+1] == p[i+2]:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007

ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	int x,y;
	while (cin >> x>>y && x+y) {
		if (x < y)cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
	}
	return 0;
}


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

int main() {

    std::string s, t;
    std::cin >> s;
    std::cin >> t;

    int cnt = 0;
    for ( int i = 0; i < 3; i++ ) {
        if ( s.substr(i, 1) == t.substr(i, 1) ) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

const int N = 1e5 + 10;

int n, m;
multiset<int> available;
vector<int> job[N];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    job[a].push_back(b);
  }

  int ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    for (int x : job[m - i])
      available.insert(x);
    if (!available.empty()) {
      ans += *prev(available.end());
      available.erase(prev(available.end()));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <array>
#include <algorithm>

int
main(void)
{
	char line[80];

	int a;
	std::array<int, 101> h;

	for (int& s: h) {
		s = 0;
	}
	
	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d", &a) != 1) {
			break;
		}

		h[a] ++;
	}
	
	int m = *(std::max_element(h.begin()+1, h.end()));

	for (auto i = h.begin()+1; i != h.end(); i++) {
		if (*i == m) {
			printf("%d\n", std::distance(h.begin(), i));
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
using System.Collections.Generic;
using static System.Console;

class Program
{
    static void Main()
    {
        var w = NextInt();
        var h = NextInt();
        var n = NextInt();
        var arr = new int[h, w];

        for (var i = 0; i < h; i++)
            for (var j = 0; j < w; j++)
                arr[i, j] = 1;

        for (var i = 0; i < n; i++)
        {
            var xi = NextInt();
            var yi = NextInt();
            var a = NextInt();

            for (var y = 0; y < h; y++)
                for (var x = 0; x < w; x++)
                    if (false) { }
                    else if (a == 1 && x < xi)
                        arr[y, x] = 0;
                    else if (a == 2 && x >= xi)
                        arr[y, x] = 0;
                    else if (a == 3 && y < yi)
                        arr[y, x] = 0;
                    else if (a == 4 && y >= yi)
                        arr[y, x] = 0;
        }
        var ans = 0;
        for (var y = 0; y < h; y++)
            for (var x = 0; x < w; x++)
                ans += arr[y, x];

        WriteLine(ans);
    }

    static int NextInt()
    {
        return int.Parse(NextString());
    }

    static string NextString()
    {
        var result = new List<char>();
        while (true)
        {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int m,n;
    cin >> n >> m;
    cout << (n*(n-1))/2+(m*(m-1))/2;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,x,tmp;
  vector<int> vec(2);
  cin >> n >> m >> x;
  rep(i,m){
    cin >> tmp;
    if(tmp>x)vec.at(0)++;
    else vec.at(1)++;
  }
  cout << min(vec.at(0),vec.at(1)) << endl;
}

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

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<long long> a(x);
  vector<long long> b(y);
  vector<long long> c(z);
  int i, j;
  for(i = 0; i < x; i++)
  {
    cin >> a.at(i);
  }
  for(i = 0; i < y; i++)
  {
    cin >> b.at(i);
  }
  for(i = 0; i < z; i++)
  {
    cin >> c.at(i);
  }
  int pa=0, pb=0, pc=0;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  reverse(c.begin(), c.end());
  vector<long long> ab(x*y);
  for(i = 0; i < x; i++)
  {
    for(j = 0; j < y; j++)
    {
      ab.at(i*y+j) = a.at(i) + b.at(j);
    }
  }
  sort(ab.begin(), ab.end());
  reverse(ab.begin(), ab.end());
  vector<long long> abc(k*z);
  for(i = 0; i < min(k, x*y); i++)
  {
    for(j = 0; j < z; j++)
    {
      abc.at(i*z+j) = ab.at(i) + c.at(j);
    }
  }
  sort(abc.begin(), abc.end());
  reverse(abc.begin(), abc.end());
  for(i = 0; i < k; i++)
  {
    cout << abc.at(i) << endl;
  }
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=50;
int n;
int a[N+1];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	vector<int> no;
	for(int i=1;i<=n;i++)if(a[i]!=i)no.pb(i);
	if(no.empty()||no.size()==2&&a[no[0]]==no[1]&&a[no[1]]==no[0])puts("YES");
	else puts("NO");
	return 0;
}
/*1
5
5 2 3 4 1
*/
/*2
5
2 4 3 5 1
*/
/*3
7
1 2 3 4 5 6 7
*/

Measured memory_bytes: 256
#include"iostream"
#include"vector"
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector< vector<int> > matrix (n, vector<int>(n) );
  vector<int> visit;
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)matrix[i][j]=0;
      int y;
      cin>>y;
      int num;
      cin>>num;
      for(int j=0;j<num;j++)
        {
          int x;
          cin>>x;
          matrix[y-1][x-1]=1;
        }
    }
  for(int i=0;i<n;i++)
    {
      cout<<matrix[i][0];
      for(int j=1;j<n;j++)
        {
          cout<<" "<<matrix[i][j];
        }
      cout<<endl;
    }
  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool check(long long a, long long b, long long t, vector<int> &h){
    long long diff= a - b;
    long long num = 0;
    for(long long c: h){
        c -= t * b;
        if(c > 0){
            num += c / diff + (c % diff ? 1 : 0);
        }
        if(num > t)
            return false;
    }
    return true;
}
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());


    int lb = 0, ub = 1000000000;
    while(ub - lb > 1){
        int half = (lb + ub) / 2;
        if(check(a, b, half, h))
            ub = half;
        else
            lb = half;
    }
    cout << ub << endl;


    return 0;
}
    


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,C,D;

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

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

signed main(){
	cin>>A>>B>>C>>D;
	int X=A-(A/C+A/D-A/(lcm(C,D)));
	DEB(X)END
	int Y=B-(B/C+B/D-B/(lcm(C,D)));
	DEB(Y)END
	int ans=Y-X;
	if(A%C!=0&&A%D!=0){
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
idx = -1
ans = 1e9
for i in range(len(h)):
	res = t-h[i]*0.006
	if abs(a-res) < ans:
		ans = abs(a-res)
		idx = i
print(idx+1)

Measured memory_bytes: 3064
#include <stdio.h>

typedef struct pair* ppair;

typedef struct pair {
  int first, second;
} pair;


int size;
pair v[1000000];
int psize;
pair preorder[1000000];
int sorted;

void swap(ppair a, ppair b) {
  pair t = *a;
  *a = *b;
  *b = t;
}

int getp(int begin, int end) {
  int i;
  int p = begin;
  for(i = begin+1; i < end; ++i) {
    if(v[i].first < v[p].first) {
      p = i;
    }
  }
  swap(&v[end-1], &v[p]);
  return end-1;
}

void qsort(int begin, int end) {
  int i, j;
  if(begin >= end) return;
  getp(begin,end);
  preorder[psize++] = v[end-1];
  if(begin+1 == end) return;
  for(i = begin, j = begin; i < end; ++i) {
    if(v[i].second < v[end-1].second) {
      swap(&v[i], &v[j++]);
    }
  }
  swap(&v[j],&v[end-1]);
  qsort(begin, j);
  qsort(j+1, end);
}

int binary_search(int k) {
  int l, r;
  l = 0;
  r = size;
  while(l < r) {
    int m = (l+r)/2;
    if(v[m].second == k) {
      return m;
    } else if(v[m].second < k) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return -1;
}

int main() {
  int i, j;
  int n, k;
  char s[100];
  size = 0;
  sorted = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    if(s[0] == 'i') {
      scanf("%d", &k);
      v[size] = (pair){size,k};
      ++size;
      sorted = 0;
    } else if(s[0] == 'p') {
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      for(j = 0; j < size; ++j) {
        printf(" %d", v[j].second);
      }
      printf("\n");
      for(j = 0; j < size; ++j) {
        printf(" %d", preorder[j].second);
      }
      printf("\n");
    } else {
      scanf("%d", &k);
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      printf(binary_search(k)!=-1?"yes\n":"no\n");
    }
  }
  return 0;
}


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

string a;

int main()
{
	cin >> a;
	if (a == "A") cout << "T";
	if (a == "C") cout << "G";
	if (a == "T") cout << "A";
	if (a == "G") cout << "C";
	return 0;
}

// 02:13


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n, m;
vll can_use(10, 0);

map<ll, ll> match = { {1, 2}, {2, 5}, {3 ,5}, {4, 4}, {5, 5}, {6, 6}, {7, 3}, {8, 7}, {9, 6} };
map<ll, ll> digi;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        ll a; cin >> a;
        can_use[a] = 1;
        if (digi.find(match[a]) == digi.end()) digi[match[a]] = a;
        else chmax(digi[match[a]], a);
    }

    vll dp(n + 1, -1);
    vll fr(n + 1, -1);
    dp[0] = 0;
    for (ll i = 1; i <= n; i++) {
        for (ll d = 9; d >= 1; d--) {
            if (can_use[d] == 0) continue;
            if (i - match[d] >= 0 && dp[i - match[d]] >= 0) {
                if (chmax(dp[i], dp[i - match[d]] + 1)) {
                    fr[i] = i - match[d];
                }
            }
        }
    }

    string ans;
    ll pre = n;
    while (pre != 0) {
        ll tmp = fr[pre];
        ans.push_back('0' + digi[pre - tmp]);
        pre = tmp;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
S = list(input())
T = list(input())

Slen=len(S)
Tlen=len(T)
flag=0
def check(S,T,i):
	k=0
	Slen=len(S)
	Tlen=len(T)
	for _ in range(Tlen):
		if S[_+i]==T[_] or S[_+i]=="?":
			k+=1
	if k==Tlen:
		return True
	else:
		return False
	
for j in range(Slen-Tlen,-1,-1):
	if check(S,T,j):
		S[j:j+Tlen]=T[::]
		for _ in range(Slen):
			if S[_] == "?":
				S[_]="a"
		ans="".join(S)
		flag=1
		print(ans)
	

if flag !=1:
	print("UNRESTORABLE")
	

 			
			
		

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int five=0;
  int seven=0;
  if(a==5) five++;
  else if(a==7) seven++;
  if(b==5) five++;
  else if(b==7) seven++;
  if(c==5) five++;
  else if(c==7) seven++;
  
  if(five==2&&seven==1) cout << "YES" << endl;
  else cout << "NO" << endl;
}



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

int main(){
    int N,K;
    cin>>N>>K;
    int a[12][8];
    for(int i=1;i<=11;i++){
        for(int j=1;j<=7;j++){
            a[i][j]=9*(7*i+j-7)%11;
            //cout<<a[i-1][j-1]<<' ';
        }
    }
    if(N<3){
        cout<<0<<endl;
    }else{
        int64_t res=0;
        for(int i=1;i<=min(11,N-1);i++){
            for(int j=2;j<=6;j++){
                if(a[i][j]==K){
                    if(i==1){
                        res += (N-1-i)/11;
                    }else{
                        res += (N-1-i)/11 + 1;
                    }
                }
            }
        }
        cout<<res<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
const int MAX_V=500,INF=1e8;
int G[MAX_V][MAX_V],V;
bool used[MAX_V];
void add_edge(int from, int to){
    G[from][to]=1;
    G[to][from]=1;
}
void erase_edge(int from, int to){
    G[from][to]=0;
    G[to][from]=0;
}
int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<V;i++){
        int &c=G[v][i];
        if(!used[i] && c>0){
            int d=dfs(i,t,min(f,c));
            if(d>0){
                c-=d;
                G[i][v]+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(true){
        memset(used,0,sizeof(used));
        int f=dfs(s,t,INF);
        if(f==0) return flow;
        flow+=f;
    }
}
int main(){
    int N,E,Q;
    cin>>N>>E>>Q;
    V=N;
    rep(i,E){
        int F,T;
        cin>>F>>T;
        add_edge(F-1,T-1);
    }
    int now=max_flow(0,N-1);
    rep(i,Q){
        int m,a,b;
        cin>>m>>a>>b;
        a--,b--;
        if(m==1){
            add_edge(a,b);
            now+=max_flow(0,N-1);
        }else{
            int ecap=G[a][b];
            erase_edge(a,b);
            if(ecap>1)swap(a,b);
            if(ecap!=1){
                memset(used,0,sizeof(used));
                int f=dfs(a,b,1);
                if(f==0){
                    memset(used,0,sizeof(used));
                    dfs(a,0,1);
                    memset(used,0,sizeof(used));
                    dfs(N-1,b,1);
                    now--;
                }
            }
        }
        cout<<now<<endl;
    }
}

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

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

using namespace std;

typedef pair<int, int> P;

int find(int v, vector<int>& p){
    if(p[v] == -1){
        return v;
    }
    p[v] = find(p[v], p);
    return p[v];
}

void unite(int u, int v, vector<int>& p){
    int u_root = find(u, p);
    int v_root = find(v, p);

    if(u_root == v_root){
        return;
    }
    p[u_root] = v_root;
}

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

signed main(){
    int n, q;
    cin >> n >> q;

    vector<int> p(n, -1);

    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0){
            unite(x, y, p);
        }

        if(com == 1){
            int px = find(x, p);
            int py = find(y, p);

            cout << (px == py ? 1 : 0) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3316
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vector<T>>;
using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = (s); i < (e); ++i)

int main()
{
    cin.tie(0);
    
    int N, K; cin >> N >> K;
    int t = 0;
    REP(i, 0, N) 
    {
        int h; cin >> h;
        if (h >= K) ++t;
    }
    
    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  Real a, b;
  cin >> a >> b;
  cout << (Bint)(a*b) << endl;
  return 0;
}

Measured memory_bytes: 4000
import math

D = input().split()
a = int(D[0])
b = int(D[1])
x = int(D[2])

tan = (((a ** 2) * b - x) / (a ** 3)) * 2

if tan * a < b:
    res = math.degrees(math.atan(tan))
    print(res)
else:
    tmp = (((a ** 2) * b - x) * 2 / (a * b)) - a
    res = math.degrees(math.atan(b / (a - tmp)))
    print(res)


Measured memory_bytes: 3064
#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 int
#define endl "\n"
#define mod 1000000007 
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
template <typename T>
#define all(v) v.begin(),v.end()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
 
    x = x % p;
    while (y > 0)
    {
 
        if (y & 1)
            res = (res * x) % p;
 
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;//cin>>tc; 
    while (tc--)
    {
       string s;
       cin>>s;
       if(s[2]==s[3]&&s[4]==s[5]){
           cout<<"Yes"<<endl;
       }
       else{
           cout<<"No"<<endl;
       }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int n,m,a[200005],b[200005],x,y;

int main()
{
    cin>>n>>m;
    int k=0,d=0;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==1) a[k++]=y;
        if(y==n) b[x]=1;
    }
    for(int i=0;i<k;i++)
       if(b[a[i]]==1) d=1;
    if(d) cout<<"POSSIBLE";
    else  cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 1408
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  if(s=="SAT") cout<<1<<endl;
  else if(s=="SUN") cout<<7<<endl;
  else if(s=="MON") cout<<6<<endl;
  else if(s=="TUE") cout<<5<<endl;
  else if(s=="WED") cout<<4<<endl;
  else if(s=="THU") cout<<3<<endl;
  else if(s=="FRI") cout<<2<<endl;

  return 0;
}



Measured memory_bytes: 256
def main():
    k = int(input())
    l = []
    for i in range(1,10):
        l.extend(dfs(i))
    l.sort()
    print(l[k-1])
    
def dfs(n,limit = 10**9):
    l = [n]
    if n>limit:
        return l
    i = n%10
    n *=10

    if i==0:
        l.extend(dfs(n+i))
        l.extend(dfs(n+i+1))
        return l
    elif i==9:
        l.extend(dfs(n+i-1))
        l.extend(dfs(n+i))
        return l
    
    else:
        l.extend(dfs(n+i-1))
        l.extend(dfs(n+i))
        l.extend(dfs(n+i+1))
        return l

if __name__ == "__main__":
    main()

Measured memory_bytes: 12756
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1000000007
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n,w[333];
int dp[333][333];

int rec(int l,int r){
  if(dp[l][r]!=-1)return dp[l][r];
  dp[l][r]=0;
  for(int i=l+1;i<r;i++){
    int res=0;
    int suml=rec(l+1,i);
    int sumr=rec(i+1,r);
    if(suml==i-l-1&&abs(w[l]-w[i])<2)res+=2;
    dp[l][r]=max(dp[l][r],res+suml+sumr);
  }
  return dp[l][r];
}

signed main(){
  while(1){
  cin>>n;
  if(n==0)break;
  for(int i=0;i<n;i++)cin>>w[i];
  fill_n(*dp,333*333,-1);
  for(int i=0;i<n;i++){
    dp[i][i]=0;
    dp[i][i+1]=0;
  }
  cout<<rec(0,n)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3956
#include<iostream>
using namespace std;
#include<cmath>
int main()
{
	long long a,b,x,kq[1000];
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		long long k=0;
		if(a>b) swap(a,b);
		if(a==b) kq[i]=(2*a-2);
		else 
		{
			long long y =a*b;
			x=int(sqrt(y-1));
			if(x*x>y-1) x--;
			if(x*(x+1)<y) k++;
			kq[i]=k+2*x-2;
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<kq[i]<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i< n+1; i++){
        ans = ans * i % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>//accumulateを使うためにインクルード

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while (cin >> n, n) {
		vi a(n + 1, 0);
		rep (i, n) cin >> a[i + 1];
		rep (i, n) a[i + 1] += a[i];
		int ans = -INF;
		rep (i, n) {
			range (j, i, n) {
				ans = max(ans, a[j + 1] - a[i]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<ctime>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 200500
#define inf (int)1e9
#define ll long long
#define mm 1000000007
#define eps 1e-9
#define low(x) x&(-x)
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
using namespace std;

ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int f[32798][21],a[21][21],sum[40050];
int all,n,m;
int cost(int x,int y){
	return sum[x|y]-sum[x]-sum[y];
}
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	n=read(); m=read();
	rep(i,1,m){
		int x=read()-1,y=read()-1,z=read();
		a[x][y]=a[y][x]=z;
	}
	int all=(1<<n)-1;
	rep(s,0,all) {
		rep(j,0,n-1) if (s&(1<<j)){
			rep(k,j+1,n-1) if (s&(1<<k)) sum[s]+=a[j][k];
		}
	}
	rep(s,0,all) rep(i,0,n-1) f[s][i]=inf;
	f[1][0]=0;
	rep(s,0,all) {
		rep(i,0,n-1) if (f[s][i]!=inf) {
			rep(j,0,n-1) {
				if (s&(1<<j)) continue;
				if (a[i][j]==0) continue;
				f[s|(1<<j)][j]=min(f[s|(1<<j)][j],f[s][i]+cost(s^(1<<i),1<<j));
			}
			for (int s0=all&(~s);s0;s0=(s0-1)&~s){
				f[s|s0][i]=min(f[s|s0][i],f[s][i]+cost(s^(1<<i),s0));
			}
		}
	}
	printf("%d\n",f[all][n-1]);
    return 0;
}

Measured memory_bytes: 3072
def solve(N, K):
    p = 0
    for i in range(1, N + 1):
        prob = 1 / N
        point = i
        while point < K:
            point = point * 2
            prob = prob / 2
        p += prob
    return p


N, K = map(int, input().split())
print(solve(N, K))


Measured memory_bytes: 2940