akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define DFS_ITEM 2
#define DEPTH 15

int N, ans = 0;
vector<int> l(10, -1), A(20);
int x[20][20], y[20][20];

void calc(vector<int> v) {
    vector<int> right(N+1, -1);
    for(int i=0; i<N; i++){
    	if(v[i]==0){
	    if(right[i+1]==1)
		return;
	    right[i+1]=0;
	    continue;
	}
    	for(int j=0; j<A[i]; j++){
	    if(right[i+1]==0)
		return;
	    right[i+1]=1;
    	    if(right[x[i][j]]==-1)
    		right[x[i][j]]=y[i][j];
    	    else if(right[x[i][j]]!=y[i][j])
    		return;
    	}
    }
    int sum=0;
    for(int i=0; i<N; i++){
    	sum += v[i];
    }
    ans = max(ans, sum);

}
void DFS(int depth, vector<int> v) {    
    if(depth == DEPTH){
	calc(v);
	return;
    }    
    for(int i=0; i<DFS_ITEM; i++){
	v[depth] = i;
	DFS(depth+1, v);	
    }
}

int main(){
    cin >> N;
    vector<int> v(20);    
    for(int i=0; i<N; i++){
	cin >> A[i];
	for(int j=0; j<A[i]; j++){
	    cin >> x[i][j]>> y[i][j];
	}
    }
    DFS(0, v);			    
    cout << ans << "\n";
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
long long int mod = 1e9+7;

int main(){
  // int n; cin >> n;
  // vector<int> a(n);
  // for(int i=0; i<n; i++) cin >> a[i];
  int a, b, c;
  cin >> a >> b >> c; ;
  if(a == b && b == c) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}
//


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

int N, M;
struct Section{
  int number;
  int dist;
  int expvOfraid;
};
vector<Section> vc;

bool comp(const Section& sec1, const Section& sec2){
  return sec2.expvOfraid < sec1.expvOfraid;
}

void debug(){
  for(int i = 0; i < N; i++){
    cout << "Num : " << vc[i].number << ", Dist : " << vc[i].dist << ", ExpvOfraid : " << vc[i].expvOfraid << endl;
  }
}

int main(void){
  int D, P;
  while(cin >> N >> M){
    if(N == 0 && M == 0) break;
    vc.clear();
    for(int i = 0; i < N; i++){
      cin >> D >> P;
      Section sec = {i, D, P};
      vc.push_back(sec);
    }
    sort(vc.begin(), vc.end(), comp);
    //debug();
    int ans = 0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < vc[i].dist; j++){
        if(M <= 0) ans += vc[i].expvOfraid;
        M--;
      }
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1440
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n,m;
  cin>>n>>m;
  vector< vector<int> > G(n);
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    s--;t--;
    G[s].emplace_back(t);
  }

  using D = double;
  D ans=1e18;
  for(int i=0;i<n;i++){
    vector<D> dp(n,0);
    for(int v=n-2;v>=0;v--){
      if(v==i){
        vector<D> cand;
        D sum=0;
        for(int u:G[v]){
          cand.emplace_back(dp[u]+1);
          sum+=cand.back();
        }

        dp[v]=sum/cand.size();

        if(cand.size()>1)
          for(D c:cand)
            chmin(dp[v],(sum-c)/(cand.size()-1));

        continue;
      }

      int cnt=0;
      for(int u:G[v]){
        dp[v]+=dp[u]+1;
        cnt++;
      }
      dp[v]/=cnt;
    }
    //for(D d:dp) cout<<d<<" ";
    //cout<<endl;
    chmin(ans,dp[0]);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
N , K = map(int,input().split())
 
A = list(map(int,input().split()))
 
reach = [-1 for i in range(N)]
reach[0] = 0 #最初の町は0回でいく
now = 0
#loop = 1
dic ={}
dic[0] = 0
for i in range(N):
  to = A[now]-1
  if reach[to] != -1:
    ini = i+1
    #print(i,to,reach[to])
    loop = i+1 - reach[to]
    break
  if i+1 not in dic:
    dic[i+1] = to
  reach[to] = i+1
  #loop += 1
  now = to
 
 
#print(dic,reach,loop,ini)
if K < ini:
  print(dic[K]+1)
else:
  t = (ini-loop) + (K-ini)%loop
  print(dic[t]+1)

Measured memory_bytes: 124948
#include <stdio.h>

int main(void){
    int  For,MoH,Syu,Waz[100001],Gou;
    
    scanf("%d%d",&MoH,&Syu);
    
    for(For=0;For<Syu;For++)
        scanf("%d",&Waz[For]);
        
    Gou = 0;
    for(For=0;For<Syu;For++)
        Gou += Waz[For];
    
    if((MoH - Gou) <= 0)
        printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

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

using namespace std;
int h, w;
char s[60][60];
int n[60][60];
int c = 1;

int main()
{
    cin >> h >> w;
    for(int i = 1; i < h+1; i++)
    {
        n[i][0] = 0;
        for(int j = 1; j < w+1; j++)
        {
            n[0][j] = 0;
            cin >> s[i][j];
            if(s[i][j] == '#')
            {
                n[i][j] = 1;
            }
            else
            {
                n[i][j] == 0;
            }
            
        }
    }
    
    
    for(int i = 1; i < h+1; i++)
    {
        for(int j = 1; j < w+1; j++)
        {
            if(n[i][j] == 1 && n[i-1][j] == 0 && n[i+1][j] == 0 && n[i][j-1] == 0 && n[i][j+1] == 0)
            {
                c = 0;
            }
        }
    }
    
    if(c == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#include<set>
#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define newline cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007


int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif


	int n;
	cin >> n;

	vector<int> ht(n);
	vector<int> cost(n);

	loopi(0, n)
	{
		cin >> ht[i];
	}
	cost[0] = 0;
	cost[1] = abs(ht[1] - ht[0]);
	cost[2] = abs(ht[2] - ht[0]);
	loopi(3, n)
	{
		int a = abs(ht[i - 1] - ht[i]) + cost[i - 1];
		int b = abs(ht[i - 2] - ht[i]) + cost[i - 2];
		cost[i] = min(a, b);
	}

	cout << cost[n - 1];

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int x,y,z,r;
  scanf("%d%d",&x,&y);
  if(x<y){
    z=x;
    x=y;
    y=z;
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  printf("%d",x);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(){
	int c1, c5, c10, c50, c100, c500,kanesum;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	kanesum = 1*c1 + 5*c5 + 10*c10 + c50*50 + c100*100 + c500*500;
	if(kanesum >= 1000){
		cout << 1 << endl;
	}
	else if(kanesum < 1000){
		cout << 0 << endl;

	}
	return 0;

}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void)
{
	int N, A, B;

	scanf("%d", &N);

	if (N == 1) {
		printf("Hello World");
	}
	else {
		scanf("%d", &A);
		scanf("%d", &B);
		printf("%d\n", A + B);

	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<stdio.h>



using namespace std;


int main(void)
{
	int num;
	cin >> num;
	string str;
	cin >> str;
	
	int count = 1;

	int i;
	for (i = 0; i < str.length()-1; i++)
	{
		if (str[i] != str[i + 1])
		{
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> v(n);
    int mx1 = -1, mx2 = -1;
    for(int i = 0 ; i < n ; i++) {
        cin >> v[i];
        if(v[i] >= mx1)mx2 = mx1 , mx1 = v[i];
        else if(v[i] > mx2)mx2 = v[i];
    }

    for(int i = 0 ; i < n ;i++)
        if(v[i] == mx1)
            cout << mx2 << endl ;
        else
            cout << mx1 << endl;

    return 0;
}

Measured memory_bytes: 3200
n = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in a:
    if i%2==0:
        if i%4==0:
            c4 += 1
        else:
            c2 += 1
if c2>0:
    m = c4*2 + c2
else:
    m = c4*2 + 1

if m>= n:
    print('Yes')
else:
    print('No')

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


int main(void)
{
        int R0, W0, C, R,num;

        while(1){
                num = 0;
                cin >> R0 >> W0 >> C >> R;
                if(R0 == 0 && W0 == 0 && C == 0 && R == 0){ 
                        break;
                }   
                while(R0 < W0 * C){ 
                        R0 += R;
                        num += 1;
                }   
                cout << num <<endl;
        }   
        return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,n,m,c,l,ans=10e17,d2,d1,l1,l2,k1,k2;
    vector<long long int>pos,neg;
    cin>>n>>m;
    for(i=0;i<n;i++){cin>>k;
        if(k>=0) pos.push_back(k);
        else neg.push_back(k);
    }
    l1=pos.size();l2=neg.size();
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end(),greater<int>());
    for(i=0;i<=m;i++){
        d1=i;d2=m-i;
        if(d1>l1||d2>l2) continue;
        if(d1==0) {k1=0-neg[d2-1];k2=k1;}
        else if(d2==0) {k1=pos[d1-1];k2=k1;}
        else {k1=2*pos[d1-1]-neg[d2-1];
            k2=pos[d1-1]-2*neg[d2-1];
        }
        ans=min(ans,k2);
        ans=min(ans,k1); //  cout<<i<<" show "<<k1<<" "<<k2<<endl;
    }
    cout<<ans<<endl;
    return 0;
   // for(i=0;i<l1;i++) cout<<pos[i]<<" ";cout<<endl;
   // for(i=0;i<l2;i++) cout<<neg[i]<<" ";
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, const vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b;
	cin >> a >> b;
	string ans;
	if (a == 1) a += 13;
	if (b == 1) b += 13;
	if (a > b) ans = "Alice";
	else if (a == b) ans = "Draw";
	else ans = "Bob";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=[A[0]]
for i in range(1,n):
  if A[i-1]!=A[i]:
    B.append(A[i])
a=0
ans=1
i=0
while i<len(B):
  if a==0:
    a=1
    i=i+1
  elif a==1:
    if B[i]>B[i-1]:
      f=1
      a=2
      i=i+1
    else:
      f=2
      a=2
      i=i+1
  else:
    if f==1:
      if B[i]>B[i-1]:
        i=i+1
        continue
      else:
        a=0
        ans=ans+1
    else:
      if B[i]<B[i-1]:
        i=i+1
        continue
      else:
        a=0
        ans=ans+1
print(ans)

Measured memory_bytes: 14480
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e12

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll p = n / (a+b);
    ll ans = 0;
    ans += p * a;
    ll k = n - p * (a+b);
    if (k > a) ans += a;
    else ans += k;
    cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
const int mod = 1e9 + 7;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
const int MAXN = 2e5+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
void read(vi & a) {
    for (int i = 0; i < sz(a); ++i) {
        cin >> a[i];
    }
}
int32_t main() {
    fio
    int k,c;
    cin >> k >> c;
    if(k * 500>= c)cout << "Yes" << endl;
    else cout << "No" << endl;

}






Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
 

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,z,w;
    cin>>n>>z>>w;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int mx=0;
    for(int i=1;i<n-1;i++)
    {
        int tt=1e10;
        tt=min(tt,abs(a[n]-a[i]));
        for(int j=i+1;j<n;j++)
        {
            tt=min(abs(a[j]-a[n]),tt);
        }
        mx=max(mx,tt);
    }
    if(n>1)
    {
        mx=max(mx,abs(a[n]-a[n-1]));
    }
    mx=max(mx,abs(a[n]-w));
    cout<<mx;

} 


Measured memory_bytes: 3668
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  bool ans=true;
  bool f=true;
  if(S.length()%2)ans=false;
  for(auto c:S){
    if(c!=(f?'h':'i')){
      ans=false;
    }
    f^=1;
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin >> a >> b;
	if((a*b)%2) cout << "Odd" << endl;
	else cout << "Even" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;

string S;

ll N;
ll A[100005];
ll ans[100005];




int main() {

	cin >> N;
	FOR(i, 1, N+1) {
		cin >> A[i];
	}
	ll sum = 0;
	ll sumb = 0;
	FOR(i,1,N+1){
		sum += A[i];
		if (i % 2 == 1 && i <= N - 1)sumb += A[i];
	}
	sumb *= 2;
	ans[N] = sum - sumb;
	ans[1] = 2 * A[N] - ans[N]; 
	FOR(i,2,N){
		ans[i] = 2 * A[i - 1] - ans[i - 1];
	}
	

	FOR(i, 1, N+1) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

int values[MAXN];

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	int n;

	cin >> n;

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

	ll answer = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			answer += values[i] * values[j];
		}
	}
	cout << answer << endl; 		
}

//GCD GCD GCD USE GCD IN MATH


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

int main() {
    cin >> n;
    h = vector<int>(n+1, 0);
    for(int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }

    int ans = 0;
    bool zflg = false;
    while(!zflg) {
        bool seq = false;
        for(int i = 0; i <= n; ++i) {
            if(!seq && h.at(i) != 0) {
                seq = true;
                h.at(i)--;
            }else if(seq && h.at(i) != 0) {
                h.at(i)--;
            }else if(seq && h.at(i) == 0) {
                ans++;
                seq = false;
            }else {
                
            }
        }

        zflg = true;

        for(int i = 0; i <= n; ++i) {
            if(h.at(i) != 0) {
                zflg = false;
                break;
            }
        }
    }

    cout << ans << endl;
}

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

#define MAX_LEN 1001

int c[MAX_LEN][MAX_LEN] = {0};

void lcs(char X[], char Y[]) {
	int m, n, i, j;
	m = strlen(X+1);
	n = strlen(Y+1);

	for (i = 1; i <= m; ++i) {
		c[i][0] = 0;
	}

	for (i = 1; i <= n; ++i) {
		c[0][i] = 0;
	}

	for (i = 1; i <= m; ++i) {
		for (j = 1; j <= n; ++j) {
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			} else if (c[i - 1][j] >= c[i][j - 1]) {
				c[i][j] = c[i - 1][j];
			} else {
				c[i][j] = c[i][j - 1];
			}
		}
	}
	
	return;
}

void show(int m, int n) {
	int i, j;

	for (i = 0; i <= m; ++i) {
		for (j = 0; j <= n; ++j) {
			printf("%d ", c[i][j]);
		}
		printf("\n");
	}
	return;
}

int main(void) {
	int i, n, x_len, y_len;
	char X[MAX_LEN] = {0};
	char Y[MAX_LEN] = {0};

	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		memset(X, '\0', sizeof(X));
		memset(Y, '\0', sizeof(Y));
		scanf("%s", X+1);
		scanf("%s", Y+1);
		lcs(X, Y);
		x_len = strlen(X+1);
		y_len = strlen(Y+1);
//		show(x_len, y_len);
//		printf("%d %d\n", x_len, y_len);
		printf("%d\n", c[x_len][y_len]);
	}

	return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

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

Measured memory_bytes: 3568
#include<iostream>
#include<string>

using namespace std;
 
int main()
{
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1==0) cout << 1 << endl;
  else if(x1*x2==0) cout << 2 << endl;
  else if(x1*x2*x3==0) cout << 3 << endl;
  else if(x1*x2*x3*x4==0) cout << 4 << endl;
  else cout << 5 << endl;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main{
	public static List<Integer> p=Prime(32768);
	public static int s=p.size();
	public static List<Integer> Prime(int n) {
		List<Integer> primes=new ArrayList<Integer>();
		primes.add(2);
		for(int i=3;i<= n;i++){
			int tmp=(int)(Math.sqrt(i))+1;
			for(int j=2;j<=tmp;j++){
				if(i % j == 0){
					break;
				}
				if(j == tmp){
					primes.add(i);
				}
			}
		}
		return primes;
	}
	public static int check(int n){
		int count=0;
		for(int i=0;i<s;i++){
			for(int j=s-1;j>=i;j--){
				if((p.get(i)+p.get(j))==n){
					count++;
				}
			}
		}
		return count;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int num;
		while(true){
			num=sc.nextInt();
			if(num!=0){
				System.out.println(check(num));
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 27064
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  string ans = "";
  while(n) {
  	ll xx = n%26;
  	ll zz = xx - 1;
  	if(zz < 0) zz = 25;
  	ans.pb(char('a' + zz));
  	n-= zz + 1;
  	n/=26;
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
} //good night.

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

struct BIT {
	typedef int T;
private:
	vector<T> bit;
	T N;

public:
	BIT(T size){
		N = size;
		bit.resize(N + 1, 0);
	}

	void add(T a, T w) {
		for (int x = a; x <= N; x += x & -x) bit[x] += w;
	}

	T sum(T a) {
		T ret = 0;
		for (int x = a; x > 0; x -= x & -x) ret += bit[x];
		return ret;
	}

	T sum(T left, T right){
		return sum(right) - sum(left);
	}
};

int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > a, b;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a.push_back(make_pair(x, i));
	}
	b = a;
	sort(b.begin(), b.end());
	for(int i = 0; i < n; i++)
		a[b[i].second].second = i + 1;
	long ans = 0;
	BIT bit(n);
	for (int i = 0; i < n; i++) {
		ans += i - bit.sum(a[i].second);
		bit.add(a[i].second, 1);
	}
	printf("%ld\n", ans);
}



Measured memory_bytes: 6740
#include <stdio.h>
int main(void) {
  int n[3], i, j;

  for (i = 0; i < 3; i++)
    scanf("%d", &n[i]);

  for (i = 0; i < 2; i++) {
    for (j = 1 + i; j < 3; j++) {
      if (n[i] > n[j]) {
        int temp = n[i];
        n[i] = n[j];
        n[j] = temp;
      }
    }
  }

  printf("%d", n[0]);
  for (i = 1; i < 3; i++)
    printf(" %d", n[i]);
  puts("");

  return 0;
}

Measured memory_bytes: 1036
h,w,k=map(int,input().split())
c=[input() for i in range(h)]
#c=[list(map(str,input().split())) for i in range(h)]

ans=0
for i in range(1<<w):
    for j in range(1<<h):
        cnt=0
        for x in range(w):
            for y in range(h):
                if c[y][x]=="#":
                    if (i>>x)&1==0 and (j>>y)&1==0:
                        cnt+=1

        if cnt==k:
            ans+=1

print(ans)

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

int main() {
  int a,z;
  string s;
  cin>>s;
  	for(int i=0;i<s.size();i++){
      if(s[i]=='A'){
        a=i;
        break;
      }
    }
  
    for(int i=s.size()-1;i>=0;i--){
      if(s[i]=='Z'){
        z=i;
        break;
      }
    }
  cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
	for(int i=0;i<3;i++){
		int h1,m1,s1,h2,m2,s2;
		int h,m,s,r,l;
		scanf("%d %d %d %d %d %d",&h1,&m1,&s1,&h2,&m2,&s2);
		r = ((h2*60 + m2)*60+s2) - ((h1*60 + m1)*60+s1);
		h = r/3600;
		l = r - h*3600;
		m = l/60;
		s = l - m*60;
		printf("%d %d %d\n",h,m,s);
	}
}


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

using namespace std;

#define endl "\n"
typedef long long int ll;
#define f first
#define s second

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int R, C, K;
vector<vector<int>> s;

const int mxn = 3003;
ll dp[mxn][mxn][4];

ll go(int r, int c, int itemR){
    if(r > R || c > C)
        return 0;
    if(dp[r][c][itemR] != -1) return dp[r][c][itemR];
    ll &ans = dp[r][c][itemR];
    ans = max(ans, go(r + 1, c, 0));
    ans = max(ans, go(r, c + 1, itemR));
    if(s[r][c] > 0){
        if(itemR != 3) ans = max(ans, s[r][c] + go(r + 1, c, 0));
        if(itemR != 3) ans = max(ans, s[r][c] + go(r, c + 1, itemR + 1));
    } 
    return dp[r][c][itemR];
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    
    cin >> R >> C >> K;

    memset(dp, -1, sizeof(dp));

    s.resize(R + 1, vector<int>(C + 1));

    for(int i = 1; i <= K; ++i){
        int x, y, v;
        cin >> x >> y >> v;
        s[x][y] = v;
    }

    cout << go(1, 1, 0);
    return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;

  if (X == 1 && Y == 1) {
    cout << 1000000 << endl;
    return 0;
  }

  int ans = 0;
  if (X == 1)
    ans += 300000;
  else if (X == 2)
    ans += 200000;
  else if (X == 3)
    ans += 100000;

  if (Y == 1)
    ans += 300000;
  else if (Y == 2)
    ans += 200000;
  else if (Y == 3)
    ans += 100000;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#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 endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,w;
LL vv[27];
map<LL,LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n;
    for(i=0;i<26;i++)
    {
        vv[i]=99999999999999;
    }
    for(m=0; m<n; m++)
    {
        cin>>a;
        for(i=0; a[i]; i++)
        {
            v[a[i]-'a']++;
        }
        for(i=0; i<26; i++)
        {
            vv[i]=min(vv[i],v[i]);
        }
        v.C;
    }

    for(i=0; i<26; i++)
    {
        for(j=0; j<vv[i]; j++)
        {
            printf("%c",i+'a');
        }
    }
    cout<<endl;



    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int N,Q;
    string s;
    char t[200000],d[200000];
    cin>>N>>Q;
    cin>>s;
    for(int i=0;i<Q;i++){
        cin>>t[i]>>d[i];
    }
    int le=-1;
    int ri=N;
    while(ri-le>1){
        int mid=(le+ri)/2;
        int m=mid;
        bool flag=false;
        //midが左端まで動くか確かめる
        for(int q=0;q<Q;q++){
            if(t[q]==s[m]){
                if(d[q]=='R'){
                    m++;
                }else{
                    m--;
                }
            }
            if(m>=N){
                flag=false;
                break;
            }
            if(m<0){
                flag=true;
                break;
            }
        }
        if(flag){
            le=mid;
        }else{
            ri=mid;
        }
    }
    int ans = le+1;
    //cout<<ans<<endl;
    le=-1;
    ri=N;
    while(ri-le>1){
        int mid=(le+ri)/2;
        int m=mid;
        bool flag=false;
        //midが右端まで動くか確かめる
        for(int q=0;q<Q;q++){
            if(t[q]==s[m]){
                if(d[q]=='R'){
                    m++;
                }else{
                    m--;
                }
            }
            if(m>=N){
                flag=true;
                break;
            }
            if(m<0){
                flag=false;
                break;
            }
        }
        if(flag){
            ri=mid;
        }else{
            le=mid;
        }
    }
    ans+=(N-ri);
    //cout<<ans<<endl;
    cout<<(N-ans)<<endl;
    return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.pal", "r", stdin);
	string str = "";
	int res = 0;

	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		int len = str.length();
		
		if (len == 1){
			++res;
			continue;
		} // end if
		int i;

		for (i = 0; i < len/2; ++i){
			if (str[i] == str[len - i - 1]){
				continue;
			}else{
				break;
			} // end if
		} // end for
		if (i == len/2){
			++res;
		} // end if
	} // end loop

	cout << res << endl;	
		
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x;
        x=s.nextInt();
        if(x==3||x==5||x==7){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }  
}

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

int main()
{
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;
if(0+r<=x&&x<=W-r&&0+r<=y&&y<=H-r)
cout << "Yes" << endl;
else
cout << "No" << endl;

return 0;
}

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

using namespace std;

int main() {
int a[3][3];
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
a[0][0]-=a[2][0];
a[0][1]-=a[2][1];
a[0][2]-=a[2][2];
a[1][0]-=a[2][0];
a[1][1]-=a[2][1];
a[1][2]-=a[2][2];

/*for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cout<<a[i][i]<<endl;*/
if(a[0][0]==a[0][1]&&a[0][0]==a[0][2]&&a[1][0]==a[1][1]&&a[1][0]==a[1][2])
cout<<"Yes";
else cout<<"No";
    return 0;
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	int n; cin >> n;
	vector<int> x(n), y(n);
	FOR(i, 0, n) cin >> x[i] >> y[i];
	FOR(i, 0, n) x[i]--, y[i]--;
	dsu d(n);

	vector<int> order(n);
	iota(ALL(order), 0);
	sort(ALL(order), [&](int u, int v){
		return x[u] < x[v];
	});
	
	PII now = {INF, -1};
	for(auto i: order){
		setmin(now, {y[i], i});
		d.merge(i, now.Y);
	}

	sort(ALL(order), [&](int u, int v){
		return x[u] > x[v];
	});
	
	now = {-INF, -1};
	for(auto i: order){
		setmax(now, {y[i], i});
		d.merge(i, now.Y);
	}				

	sort(ALL(order), [&](int u, int v){
		return y[u] < y[v];
	});
	
	now = {INF, -1};
	for(auto i: order){
		setmin(now, {x[i], i});
		d.merge(i, now.Y);
	}

	sort(ALL(order), [&](int u, int v){
		return y[u] > y[v];
	});
	
	now = {-INF, -1};
	for(auto i: order){
		setmax(now, {x[i], i});
		d.merge(i, now.Y);
	}				

	FOR(i, 0, n) cout << d.size(i) << '\n';
	return 0;
}


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

using namespace std;
using ll = unsigned long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < 51000; ++i) {
        if(i * 108 / 100 == n){
            cout << i << endl;
            return ;
        }
    }
    cout << ":(" << endl;
    return;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(" ");
        var N = int.Parse(inputs[0]);
        var D = int.Parse(inputs[1]);

        var X = new List<int>();
        var Y = new List<int>();
        for(int i = 0; i < N; i++)
        {
            inputs = Console.ReadLine().Split(" ");
            X.Add(int.Parse(inputs[0]));
            Y.Add(int.Parse(inputs[1]));
        }

        var count = 0;
        for(int i = 0; i < N; i++)
        {
            var distance = Math.Sqrt(Math.Pow(X[i], 2) + Math.Pow(Y[i], 2));
            if(distance <= D) count++;
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 44412
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

void main() {
    int n, k, s;
    while (readf("%d %d %d\n", &n, &k, &s), n || k || s) {
        int dfs(int m, int r, int sum) {
            if (r == 0) {
                return sum == 0;
            }
            if (m == n) return 0;
            int ans = 0;
            for (int i = m + 1; i <= n; i++) {
                ans += dfs(i, r - 1, sum - i);
            }
            return ans;
        }
        dfs(0, k, s).writeln;
    }
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long cnt=0,ma=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
			cnt++;
		}
		else{
			ma=max(ma,cnt);
			cnt=0;
		}
	}
	ma=max(ma,cnt);
	cout<<ma<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
 int a,b,c;
 scanf("%d", &a);
 scanf("%d", &b);
 scanf("%d", &c);

 if((a < b) && (b < c) ){
  printf("Yes\n");
 }else{  
  printf("No\n");
 }
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

vector<vector<int> > G(10);
int n, m;
int dfs(int u, int bit){
	if(bit == (1<<n)-1)return 1;
	int f = 0, res = 0;
	rep(i,G[u].size()){
		int to = G[u][i];
		if((bit&(1<<to)) == 0){
			res += dfs(to, bit|(1<<to));
			f = 1;
		}
	}
	if(f == 0)return 0;
	return res;
}

signed main(){
	scanf("%lld%lld", &n, &m);
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);
		G[x-1].push_back(y-1);
		G[y-1].push_back(x-1);
	}
	int ans = dfs(0, 1);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
a,b,c,d=input()
for i in range(2**3):
    ls=['+','+','+']
    for j in range(len(ls)):
        if (i>>j)&1:
            ls[j]='-'
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Measured memory_bytes: 38256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC129
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

void solve(void){
  
  int N, K;
  
  cin >> N >> K;
  
  double P=0;
  
  if(N>=K){
    P = (double)(N-K+1)/N;
  }
  
  
  REP2(i,1,N+1){
    if(i>=K){break;}
    double A=i;
    double H=1;
    while(A<K){
      H /=2;
      A *=2;
    }
    P += H/N;
  }

  cout << fixed << setprecision(15);
  cout << P << endl;
  
  return;
   
}



#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    string s;cin>>s;
    int n = SIZE(s);
    s += 'R';

    VI result(n);

    int type = 0;
    int l=0;
    int r=0;
    int ind=0;
    REP(i,n+1){
        if(type==0){
            if(s[i]=='R'){
                r++;
            }
            else{
                ind = i;
                result[i-1] += (r+1)/2;
                result[i] += r/2;
                r=0;
                l=1;
                type=1;                             
            }
        }
        else if(type==1){
            if(s[i]=='R'){
                result[ind-1] += l/2;
                result[ind] += (l+1)/2;
                r=1;
                l=0;
                type=0;
            }
            else{
                l++;
            }

        }
        else if(type==2){
            if(s[i]=='R'){

            }
            else{
                
            }

        }
        else if(type==3){
            if(s[i]=='R'){

            }
            else{
                
            }

        }
    }

    REP(i,n){
        if(i!=0){
            cout<<" ";
        }
        cout<<result[i];
    }
    cout<<endl;
	return;

}

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

Measured memory_bytes: 1104
n = int(input())

def make_luc(n):
    luc=[0]*n
    luc[0] = 2
    luc[1] = 1
    for i in range(2,n):
        luc[i] = luc[i-1] + luc[i-2]
    return luc

luc=make_luc(87)
print(luc[n])

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

const int64_t mod = 1000000007;

signed main () {
    string l;
    cin >> l;
    int n = l.size();
    vector < int64_t > twos(n + 1, 1), threes(n + 1, 1);
    for (int i = 1; i <= n; ++i) {
        twos[i] = (twos[i - 1] * 2) % mod;
        threes[i] = (threes[i - 1] * 3) % mod;
    }
    int64_t ans = 0;
    int i, cnt;
    for (i = 0, cnt = 0; i < n; ++i) {
        if (l[i] == '1') {
            (ans += (twos[cnt] * threes[n - i - 1]) % mod) %= mod;
            ++cnt;
        }
    }
    (ans += twos[cnt]) %= mod;
    cout << ans << '\n';
}


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main()
{int A, B, C , D;  char a,b,c,d;cin >> a >> b >> c >> d;
 
 A = a - '0';
 B = b - '0';
 C = c - '0';
 D = d - '0';
 
 char op1,op2,op3;
 
 for(int i = 0; i < 2;i++){
   for(int j = 0; j < 2;j++){
     for(int k = 0; k < 2;k++){
       
       int total = A;
       if(i == 0){ total += B; op1 = '+';}
        else{ total -= B; op1 = '-';}
       
       if(j == 0){total += C; op2 = '+';}
        else{ total -= C;op2 = '-';}
       
       if(k == 0){ total += D;op3 = '+';}
        else{ total -= D; op3 = '-';}
       
       if(total == 7){ cout << a << op1 << b << op2 << c << op3 << d << "=7" ;
                      return 0;}
     
                                 }}}

}
         

Measured memory_bytes: 256
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: CF

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

#define bpc __builtin_popcount
#define bpcl __builtin_popcountll
#define bpr __builtin_parity
#define bprl __builtin_parityll
#define ctz __builtin_ctz
#define ctzl __builtin_ctzll
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MOD 1000000007

//make sure to change MAXN according to constraints
#define MAXN 100005

ll t,n,m,a[MAXN];
bool good[MAXN];
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n >> m;
	rep(i,1,n+1) {
		cin >> a[i];
		good[i] = true;
	}
	
	
	int u,v;
	rep(i,0,m) {
		cin >> u >> v;
		if (a[u] >= a[v]) {
			good[v] = false;
		}
		if (a[v] >= a[u]) {
			good[u] = false;
		}
	}
	
	int cnt = 0;
	rep(i,1,n+1) {
		if (good[i]) {
			//~cout << i << " ";
			cnt ++;
		}
	}
	
	cout << cnt << "\n";

	return 0;
}





Measured memory_bytes: 4440
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) {
    	cin >> t;
    }
    vector<int> sn = a;
    sort(sn.begin(), sn.end());
    for (auto &t : a) {
    	t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
    }
    vector<int> cnt(2);
 	for (int i = 0; i < n; i++) {
 		if (i % 2 != a[i] % 2) {
 			cnt[i % 2]++;
 		}
 	}
 	cout << 2 * max(cnt[0], cnt[1]) - min(cnt[0], cnt[1]) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

char s[555][555];
int h, w;
int ans[555][555];

int main(void){
	int i, j;
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++) {
		scanf("%s", s[i]);
	}

	// 解説AC.
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				ans[i][j] = 3;
			} else if (j == 0 || j == w - 1) {
				ans[i][j] = (j ? 2 : 1);
			} else {
				ans[i][j] = (i % 2 + 1);
			}
		}
	}

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			putchar((ans[i][j] & 1) ? '#' : '.');
		}
		puts("");
	}
	puts("");

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			putchar((ans[i][j] & 2) ? '#' : '.');
		}
		puts("");
	}

	return 0;
}


Measured memory_bytes: 2048
n, m = map(int, input().split())
inf = 0
sup = 100001
for i in range(m) :
    l, r = map(int, input().split())
    inf = max(inf, l)
    sup = min(sup, r)
if sup >= inf :
    print(sup-inf+1)
else :
    print("0")


Measured memory_bytes: 9128