akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Xml.Serialization;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var button = new int[num];
            var check = new BitArray(num);
            
            for (int i = 0; i < num; i++)
                button[i] = int.Parse(Console.ReadLine()) - 1;

            check[0] = true;
            var count = 1;
            for (int now = button[0]; now != 1; now = button[now], count++)
            {
                if (check[button[now]])
                {
                    Console.WriteLine(-1);
                    return;
                }
                check[button[now]] = true;

            }
            Console.WriteLine(count);
        }



    }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n;
  map<string,int> MAP;
  int MAX =0;
  
  rep(i,n){
    string s ;
    cin >> s ;
    MAP[s] ++;
    MAX = max(MAX,MAP[s]);
  }
  
  for(auto p : MAP){
    if(p.second == MAX) cout << p.first <<endl;
  }
  

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;

    ll sqN = (ll)sqrt(N);
    sqN += 2;
    ll res = 0;
    for(int m=1;m<=sqN;m++){
    	if((N-m)%m == 0){
    		ll cand = (N-m)/m;
    		if(cand !=0 && N/cand == N%cand){
    			res += cand;
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7){cout<<"YES"<<endl;return 0;}
    if(a==5&&b==7&&c==5){cout<<"YES"<<endl;return 0;}
    if(a==7&&b==5&&c==5){cout<<"YES"<<endl;return 0;}
    else cout<<"NO"<<endl;
    return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  int taps = 0;
  int sum = 1;
  while (sum < b)
  {
    sum --;
    sum += a;
    taps ++;
  }
  
  cout << taps << endl;
  return 0;
}


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

void p1(int x[],int y[],int n)
{
  int i;
  double D=0,num;
  for(i=0;i<n;i++)
  {
    num=x[i]-y[i];
    if(num<0) num=-num;
    D+=num;
  }
  printf("%f\n",D);
}

void p2(int x[],int y[],int n)
{
  int i;
  double D=0,num;
  for(i=0;i<n;i++)
  {
    num=(x[i]-y[i])*(x[i]-y[i]);
    D+=num;
  }
  D=sqrt(D);
  printf("%f\n",D);
}

void p3(int x[],int y[],int n)
{
  int i;
  double D=0,num;
  for(i=0;i<n;i++)
  {
    num=x[i]-y[i];
    if(num<0) num=-num;
    num=num*num*num;
    D+=num;
  }
  D=pow(D,1.0/3);
  printf("%f\n",D);
}
void p_inf(int x[],int y[],int n)
{
  int i;
  double num,max=0;
  for(i=0;i<n;i++)
  {
    num=x[i]-y[i];
    if(num<0) num=-num;
    if(num>max) max=num;
  }
  printf("%f\n",max);
}
int main(void)
{
  int n,i,j,p;
  scanf("%d",&n);
  int x[n],y[n];
  for(i=0;i<n;i++) scanf("%d",&x[i]);
  for(i=0;i<n;i++) scanf("%d",&y[i]);
  p1(x,y,n);
  p2(x,y,n);
  p3(x,y,n);
  p_inf(x,y,n);
  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, Q;
    cin >> N >> Q;
    string s, tmp;
    cin >> s;
    int check[N + 1];
    fill(check, check + N + 1, 0);
    tmp = "";
    for (int i = 1; i <= N; i++)
    {
        tmp += s[i - 1];
        if (tmp.length() >= 2)
        {
            if (tmp[tmp.length() - 2] == 'A' && tmp[tmp.length() - 1] == 'C')
            {
                check[i] = check[i - 1] + 1;
            }
            else
            {
                check[i] = check[i - 1];
            }
        }
    }
    int l[Q], r[Q];
    for (int i = 0; i < Q; i++)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i < Q; i++)
    {
        cout << check[r[i]] - check[l[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 4820
#include<iostream>
using namespace std; 
 
 
int main()
{
string a;
cin >> a ;
if(a == "000"){printf("0");}
if(a == "001"){printf("1");}
if(a == "010"){printf("1");}
if(a == "011"){printf("2");}
if(a == "100"){printf("1");}
if(a == "101"){printf("2");}
if(a == "110"){printf("2");}
if(a == "111"){printf("3");}
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, a, b = MAP()
ans = 0
for i in range(1, n + 1):
    arr = [int(j) for j in str(i)]
    tmp = 0
    for j in arr:
        tmp += j
    if a <= tmp <= b:
        ans += i
print(ans)

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

using namespace std;
char g[250][250];
int vis[250];
int n;
int ans=-1;
vector<int> q[250];
bool check(int k)
{
    int num=q[k].size();
    /*cout<<k<<" : ";
    for(int i=0;i<num;i++)cout<<q[k][i]<<' ';
    cout<<endl;*/
    for(int i=0;i<num;i++){
        for(int j=i+1;j<num;j++){
            if(g[q[k][i]][q[k][j]]=='1')
                return true;
        }
    }
    return false;
}
int getans(int k)
{
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++)q[i].clear();
    q[0].push_back(k);
    vis[k]=1;
    int ans;
    for(int i=1;i<=n+10;i++){
        if(q[i-1].size()==0){
            ans=i-1;
            break;
        }
        int num=q[i-1].size();
        for(int j=0;j<num;j++){
            for(int z=0;z<n;z++){
                if(g[q[i-1][j]][z]=='1'&&vis[z]==0){
                    q[i].push_back(z);
                    vis[z]=1;
                }
            }
        }
    }
    for(int i=0;i<ans;i++){
        if(check(i))return -1;
    }
    return ans;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>g[i];
    for(int i=0;i<n;i++)ans=max(ans,getans(i));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
list = []
top2 = [0, 0]
n.times {
    a = gets.to_i
    if top2[0] < a
        top2[1] = top2[1]
        top2[0] = a
    elsif top2[1] < a
        top2[1] = a
    end
    
    list.push(a)
}

list.each {|a|
    puts a == top2[0] ? top2[1] : top2[0]
}

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

int main() {
    char a;

    cin >> a;

    if ('A' <= a && a <= 'Z') {
        printf("%c\n", 'A');
    }
    else {
        printf("%c\n", 'a');
    }

    return 0;
}

Measured memory_bytes: 3764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      StringBuilder buf  = new StringBuilder();

      for(int i=0; i<q; i++) {
        buf.append( deriveLcs(br.readLine(), br.readLine()) )
           .append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int deriveLcs(String seqX, String seqY) {
    int m = seqX.length();
    int n = seqY.length();
    int size = m > n ? m+1 : n+1;
    int[][] subSeq = new int[size][size];
    int maxSubSeq = 0;

    for(int i=1; i<=m; i++) subSeq[i][0] = 0;
    for(int j=1; j<=n; j++) subSeq[0][j] = 0;

    for(int i=1; i<=m; i++) {
      for(int j=1; j<=n; j++) {
        if(seqX.charAt(i-1) == seqY.charAt(j-1))
          subSeq[i][j] = subSeq[i-1][j-1] + 1;
        else
          subSeq[i][j] = Math.max(subSeq[i-1][j], subSeq[i][j-1]);

        maxSubSeq = Math.max(maxSubSeq, subSeq[i][j]);
      }
    }

    return maxSubSeq;
  }
}


Measured memory_bytes: 64408
s = input()
if 0 < int(s[:2]) <= 12:
  if 0 < int(s[2:]) <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < int(s[2:]) <= 12:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30],ans[150000];
std::vector<int> v[150000];

int main(void){
	int d,i,j,n=26,k,m=125000;
	ll ansm = -INFLL;
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			v[k].push_back(j);
		}
		std::random_device seed_gen;
		std::mt19937 engine(seed_gen());
		std::shuffle(v[k].begin(), v[k].end(), engine);
	}
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			l[j] = -1;
		}
		for(i=0; i<d; ++i){
			ans[k] += s[i][v[k][i%26]];
			l[v[k][i%26]] = i;
			for(j=0; j<n; ++j){
				ans[k] -= c[j]*(i-l[j]);
			}
		}
		ansm = std::max(ansm,ans[k]);
		// std::cout << ans[k] << std::endl;
	}
	for(k=0; k<m; ++k){
		if(ans[k] == ansm){
			for(i=0; i<d; ++i){
				std::cout << v[k][i%26]+1 << std::endl;
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e9;
 
struct SegtreeRMQ {
    ll n;
    ll inf;
    vector<ll> dat;
 
    void init(ll n_input, ll inf_input){
        inf = inf_input;
        n = 1;
        while(n < n_input)n <<= 1;
        dat.resize(2*n-1);
        for(int i = 0; i<2*n-1; i++) dat[i] = inf;
    }
 
    void update(ll k, ll a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = min(dat[2*k+1], dat[2*k+2]);
        }
    }
 
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b)return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> p(n+1);
    vector<int> pos(n+1);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        pos[p[i]] = i;
    }
    SegtreeRMQ st[2];
    st[0].init(n, INF);
    st[1].init(n, INF);

    for(int i = 0; i < n; i++)
    {
        if(i % 2 == 0)
        {
            st[0].update(i, p[i]);
            st[1].update(i, INF);
        }
        else
        {
            st[1].update(i, p[i]);
            st[0].update(i, INF);
        }
    }
    set<vector<ll>> cand;

    function<void(ll, ll)> process = [&](ll l, ll r)
    {
        if(r <= l) return;
        ll lmi = st[l%2].query(l, r, 0, 0, st[0].n);
        ll lpos = pos[lmi];
        ll rmi = st[(l+1)%2].query(lpos+1, r, 0, 0, st[0].n);
        ll rpos = pos[rmi];
        cand.insert({lmi, rmi, l, lpos, rpos, r});
    };

    process(0, n);
    vector<ll> ans;
    while(cand.size() > 0)
    {
        vector<ll> ret = *cand.begin();
        cand.erase(cand.begin());
        ans.push_back(ret[0]);
        ans.push_back(ret[1]);
        process(ret[2], ret[3]);
        process(ret[3]+1, ret[4]);
        process(ret[4]+1, ret[5]);
    }
    for(int i = 0; i < n; i++)
    {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 17904
#include<iostream>
#include<vector>
#include<algorithm>
#define allr(x) (x).rbegin(),(x).rend()
using namespace std;

int in() {
	int x;
	cin >> x;
	return x;
}
int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	int N = X + Y;
	vector<int> p(A), q(B), r(C);
	int temp;
	while (A--) {
		cin >> p[A];
	}
	while (B--) {
		cin >> q[B];
	}
	sort(allr(p)); sort(allr(q));
	vector<int> T;
	while (X--) T.push_back(p[X]);
	while (Y--) T.push_back(q[Y]);
	while (C--) T.push_back(in());
	sort(allr(T));
	long long ans = 0ll;
	while (N--) {
		ans += T[N];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  	int a,b,c,n,i,j,k,count=0;
  	cin>>a>>b>>c>>n;
  	
  	for(i=0;i<=n/a;i++){
		for(j=0;j<=(n-i*a)/b;j++){
			if((n-i*a-j*b)%c==0){
              count++;
            }
        }
    }

	cout<<count<<endl;
}

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

int main() {
  int H,N,A,sum=0;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    sum+=A;
  }
  if(H>sum)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
s = input()
ans = 0
prev = None
l = 0
r = 0
for x in s:
  if x == '<':
    if prev == '>':
      mx = max(r, l)
      mn = min(r, l)
      ans += mx * (mx + 1) // 2 + mn * (mn - 1) // 2
      l = 0
      r = 0
    l += 1
  else:
    r += 1
  prev = x
else:
  mx = max(r, l)
  mn = min(r, l)
  ans += mx * (mx + 1) // 2 + mn * (mn - 1) // 2
print(ans)

Measured memory_bytes: 4116
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

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

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 3.1415926535897932384626
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

ll a[100005],dp[100005],n,k;

ll ans(ll i){
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	if(dp[i]!=-1)
		return dp[i];
	ll solution=INT_MAX;
	for(ll j=i+1;j<min(n,i+k+1);j++){
		solution=min(solution,abs(a[i]-a[j])+ans(j));
	}
	return dp[i]=solution;
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	for(ll i=0;i<n;i++)		cin >> a[i];
	cout << ans(0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int histo[2004][2004];
int field[2004][2004];
int h, w;
int ans = 0;

void f(int index){
    stack<i_i> sta;
    sta.push({0, index});
    for(int i = 0; i < w; i++){
        if(sta.empty()){
            sta.push({i, histo[index][i]});
            continue;
        }
        i_i now = sta.top();
        if(now.second < histo[index][i]){
            sta.push({i, histo[index][i]});
            continue;
        }
        if(now.second == histo[index][i]){
            continue;
        }
        int before;
        int height = histo[index][i];
        while(true){
            if(sta.empty()) break;
            now = sta.top();
            if(now.second <= height) break;
            sta.pop();
            //cout << index << " " <<  i << " " << now.first << " " << now.second << " " << (i - now.first + 1) * now.second << endl;
            ans = max(ans, (i - now.first + 1) * now.second);
            before = now.first;
            //ans = (i - now.first + 1) * now.second;
        }
        sta.push({before, height});
    }
    while(!sta.empty()){
        i_i now = sta.top();
        sta.pop();
        ans = max(ans, (w - 1 - now.first + 1) * now.second);
    }
    return;
}

int main() {
    //cout.precision(10);
    cin >> h >> w;
    string S[2004];
    for(int i = 0; i < h; i++){
        cin >> S[i];
    }
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            int counter = 0;
            if(S[i - 1][j - 1] == '#') counter++;
            if(S[i - 1][j] == '#') counter++;
            if(S[i][j - 1] == '#') counter++;
            if(S[i][j] == '#') counter++;
            field[i][j] = counter % 2;
        }
    }
    for(int i = 0; i < w; i++){
        histo[0][i] = 1;
    }
    for(int i = 1; i < h; i++){
        for(int j = 0; j < w; j++){
            if(field[i][j + 1] == 1){
                histo[i][j] = 1;
                continue;
            }
            histo[i][j] = histo[i - 1][j] + 1;
        }
    }
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            //cout << field[i][j];
        }
        //cout << endl;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            //cout << histo[i][j] << " ";
        }
        //cout << endl;
    }
    for(int i = 0; i < h; i++){
        f(i);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, x;
  int64_t sum=0;
  cin >> N;
  vector<int> vec(100001);
  for (int i = 0; i < 100001; i++) {
    vec.at(i)=0;
  }
  for (int i = 0; i < N; i++) {
    cin >> x;
    vec.at(x)++;
    sum+=x;
  }
  int Q;
  cin >> Q;
  int B, C;
  for (int i=0; i < Q; i++){
    cin >> B >> C;
    sum += (C-B)*vec.at(B);
    vec.at(C) += vec.at(B);
    vec.at(B)=0;
    cout << sum << endl;
  }
}


Measured memory_bytes: 3760
import sys


a = int(input())
b = input()

b = (map(int,b.split()))
b = list(b)

L = b[0]

for i in range(1,a):
    if b[i] > L:
        L = b[i]

j = 0

for i in range(a):
    j += b[i]
    
j -= L

if j > L:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let l: Vec<i32> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
                    continue;
                }
                if l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2140
#include<stdio.h>
int main(){
	int h, m, s;
	scanf("%d", &s);
	h = s / 3600;
	s = s - h * 3600;
	m = s / 60;
	s = s - m * 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int T, X;
    cin >> T >> X;
    double ans = (double)T/X;

    printf("%.10f",ans);    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INF 1<<21
#define DIV 1000000007

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

int main() {
  int n, c, k;
  int t[100005];
  int cnt = 0;
  queue<int> q;
  cin >> n >> c >> k;

  for (int i = 0; i < n; i++) {
	cin >> t[i];
  }
  sort(t, t + n);
  for (int i = 0; i < n; i++) {
	q.push(t[i]);
  }

  while (!q.empty()) {
	int tmp = q.front();
	for (int i = 0; i < c; i++) {
	  if (q.front() <= tmp + k) {
		q.pop();
	  }
	  if (q.empty()) {
		break;
	  }
	}
	cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	int n, m;
	ll sum=0;
	cin >> n;
	vector<ll> t(n);
	rep(i,n){
		cin >> t[i];
		sum+=t[i];
	}
	cin >> m;
	rep(i,m){
		int p;
		ll x, ans=sum;
		cin >> p >> x;
		ans-=t[p-1];
		ans+=x;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

vector<int> a;
vector<bool> ball;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;
	a.resize(N);
	ball = vector<bool>(N, false);

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

	int num_ball = 0;
	for (int i = N; i > 0; i--) {
		int count = 0;

		for (int j = 2; i * j <= N; j++) {
			if (ball[i * j - 1]) {
				count++;
			}
		}
		if (count % 2 != a[i - 1]) {
			ball[i - 1] = true;
			num_ball++;
		}
	}
	cout << num_ball << endl;
	for (int i = 0; i < N; i++) {
		if (ball[i]) {
			cout << (i + 1);
			num_ball--;
			if (num_ball == 0) {
				cout << endl;
				break;
			} else {
				cout << " ";
			}
		}
	}

	return 0;
}


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

int main() {
    long long X;
    cin >> X;
    long long hp = 0;
    for (long long i = X; i >= 500; hp += 1000) {
        i = X - 500;
        X = i;
    }
    for (long long i = X; i >= 5; hp += 5){
        i = X - 5;
        X = i;
    } 
    cout << hp << endl;
    return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n , dp[N];
string s , t;

int solve(int idx){
  if(idx == n)
    return 0;
  int &ret = dp[idx];
  if(~ret) return ret;
  if(s[idx] == t[idx])
    return ret = solve(idx+1);
  ret = OO;
  return ret = min(ret , solve(idx+1)+1);

}

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

  cin >> s >> t;
  n = SZ(s);
  memset(dp , -1 , sizeof dp);
  printf("%d\n" , solve(0));

  return 0;
}


Measured memory_bytes: 10760
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  ll h;
  cin >> h;
  ll ans = 1;
  ll tmp = 1;
  while(h != 1){
    tmp *= 2;
    ans += tmp;
    h /= 2;
  }
  cout << ans << endl;
  return 0;
}


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


int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	rep(i,N)
   	{
		cin>>A[i];
		A[i]--;
	}
	int ans=0;
	rep(i,N)
	{
		if(A[A[i]]==i&&A[i]>i)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	double T, X;
	cin >> T >> X;

	printf("%.10f\n", T/X);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    set<char> S;
    char c;
    for (int i = 0; i < N; i++) {
        cin >> c;
        S.insert(c);
    }
    if (S.size() == 3) cout << "Three" << '\n';
    else cout << "Four" << '\n';
}


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

int main(){
  ll n,m;cin >> n >> m;
  vector<ll> a(m);
  rep(i,m) cin >> a.at(i);
  vector<ll> dp(n+1);
  dp.at(0) = 1;
  ll cnt = 0;
  for(ll i=1;i<=n;++i){
    if( cnt < m && a.at(cnt) == i ){
      ++cnt;
      continue;
    }
    if( i == 1 ){
      dp.at(i) += dp.at(i-1);
      dp.at(i) %= d;
    }else{
      dp.at(i) = dp.at(i-1) + dp.at(i-2);
      dp.at(i) %= d;
    }
  }
  // rep(i,n+1) cout << dp.at(i) << endl;
  cout << dp.back() << endl;
  return 0;
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,mod=1e9+7;
ll dp[N][N][N*N];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    if(k&1){cout<<0<<endl;return 0;}
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=i;j++)
        for(int k=0;k<=i*i;k++)
    {
        dp[i+1][j][k+j]=(dp[i+1][j][k+j]+dp[i][j][k]*(2*j+1))%mod;
        if(j>0)
            dp[i+1][j-1][k+j-1]=(dp[i+1][j-1][k+j-1]+dp[i][j][k]*j*j)%mod;
        dp[i+1][j+1][k+j+1]=(dp[i+1][j+1][k+j+1]+dp[i][j][k])%mod;
    }
    printf("%lld\n",dp[n][0][k/2]);
}


Measured memory_bytes: 65792
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

ans = [-1]*(N+1)
ans[0] = 0
ans[-1] = 0
tmp = 0
for i in range(N-1):
  if s[i] == "<":
    tmp += 1
    ans[i + 1] = tmp
  elif s[i] == ">" and s[i + 1] == "<":
    tmp = 0
    ans[i + 1] = tmp
else:
  if s[-1] == "<":
    ans[-1] = ans[-2] + 1

tmp = 0
for i in range(N-1,0,-1):
  if s[i] == ">":
    tmp += 1
    if s[i - 1] == "<":
      ans[i] = max(ans[i], tmp)
    else:
      ans[i] = tmp
  elif s[i] == "<" and s[i - 1] == ">":
    tmp = 0
    ans[i] = tmp
  #print(ans)
else:
  if s[0] == ">":
    ans[0] = ans[1] + 1
#print(ans)
print(sum(ans))

Measured memory_bytes: 46408
#include <stdio.h>
#include <math.h>
int primecheck(int n);
int main(void)
{
    int n,i,k=3;
    scanf("%d", &n);
    int prime[500];
    for(i=0; i<500; i++) prime[n]=0;
    prime[0]=2;
    prime[1]=3;
    prime[2]=5;
    for(i=7; i<=1000; i++)
    {
        if(primecheck(i)==1)
        {
            prime[k]=i;
            k++;
        }
    }
    long long int num[k];
    for(i=0; i<k; i++) num[i]=0;
    for(int j=1; j<=n; j++)
    {
        int temp=j;
        for(i=0; i<k; i++)
        {
            while(temp%prime[i]==0)
            {
                temp=temp/prime[i];
                num[i]++;
            }
        }
    }
    long long int ans=1;
    for(i=0; i<=k; i++)
    {
        if(num[i]>0&&num[i]<2000) ans=(ans*(num[i]+1))%1000000007;
    }
    printf("%lld", ans);
    return 0;
}
int primecheck(int n)
{
    if(n%2==0) return 0;
    else if(n%3==0) return 0;
    else if(n%5==0) return 0;
    else
    {
        for(int i=7; i<n; i+=2)
        {
            if(n%i==0) return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(c>=a&&c<=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
  
}


Measured memory_bytes: 256
x = input()
list = x.split()

if list[0] == list[1] and list[1] == list[2] and list[0] == list[2]:
    print('No')
elif list[0] != list[1] and list[1] != list[2] and list[0] != list[2]:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline

def main():
    H, W = map(int, readline().rstrip().split())
    A = [list(map(int, readline().rstrip().split())) for _ in range(H)]
    res = []
    cnt = 0
    for h in range(H):
        for w in range(W-1):
            if A[h][w] % 2 == 1:
                A[h][w+1] += 1
                cnt += 1
                res.append('{} {} {} {}'.format(h+1, w+1, h+1, w+2))

    for h in range(H-1):
        if A[h][W-1] % 2 == 1:
            A[h+1][W-1] += 1
            cnt += 1
            res.append('{} {} {} {}'.format(h+1, W, h+2, W))
    
    print(cnt)
    print(*res, sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 18392
#include <iostream>
#include <math.h>

using namespace std;

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


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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve();

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}

void solve(){
    int n;cin>>n;
    if(n<600) cout<<'8'<<endl;
    else if(n<800) cout<<'7'<<endl;
    else if(n<1000) cout<<'6'<<endl;
    else if(n<1200) cout<<'5'<<endl;
    else if(n<1400) cout<<'4'<<endl;
    else if(n<1600) cout<<'3'<<endl;
    else if(n<1800) cout<<'2'<<endl;
    else cout<<'1'<<endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

using Graph = vector<vector<int>>;

int re[100];
int ans = 0;
void dfs(Graph& G,int a,int n){
    if(re[a] == 1 ) return;
    re[a] = 1;
    int sum = 0;
    rep(i,n){
        if(re[i] == 1){
            sum++;
        }
    }
    if(sum == n) ans++;
    for(auto x : G[a]){
        if(re[x] == 1) continue;
        dfs(G,x,n);
        re[x] = 0;
    }
}

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

    int n,m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        p[i] = make_pair(y,x);
    }
    sort(all(p));
    int ans = 0;
    int cur = -INF;
    rep(i,m){
        if(cur <= p[i].second){
            ans++;
            cur = p[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
/**
 * ?????????????????????

?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°?????????????????????????????????
??????????°?????????¨??§??????????????\???????????????

Input
?????°????????????????????????????????±???????????????????????????

Output
?????????????????±???????????????????????¢???????????????????????°?????\??????????????¢?????§????????????????????????

a : a????????°
b : b????????°
c : c????????°
  .
  .
z : z????????°
Constraints
??±???????????????????????° < 1200
Sample Input
This is a pen.
Sample Output
a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0
 */

#include <algorithm>
#include <iostream>
#include <sstream>
#include <vector>

int main(int argc, char const *argv[]) {
  std::string Source;
  unsigned short NumberOfChars = 0;
  std::vector<unsigned short> Summary(26, 0);

  while (getline(std::cin, Source)) {

    NumberOfChars = Source.length();
    if (NumberOfChars > 1200) {
      std::cout << "Error: Input string must be "
                   "less than 1200 characters."
                << std::endl;
    } else {
      std::transform(Source.begin(), Source.end(), Source.begin(), tolower);
      for (size_t i = 0; i < NumberOfChars; i++) {
        if (Source[i] >= 'a' || Source[i] <= 'z') {
          Summary[tolower(Source[i]) - 'a']++;
        }
      }
    }
  }

  for (size_t i = 0; i < 26; i++) {
    std::cout << (char)(i + 'a') << " : " << Summary[i] << std::endl;
  }
  return 0;
}

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

const int INF = int(1E9 + 7);

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H = vector<int>(N);
    for (int i = 0; i < N; i++)
        cin >> H[i];

    vector<int> dp = vector<int>(N, INF);
    dp[0] = 0;

    for (int i = 1; i < N; i++)
        for (int k = 1; k <= K; k++)
            if (i - k >= 0)
                dp[i] = min(dp[i], dp[i - k] + abs(H[i] - H[i - k]));

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
void dfs(vector<int> &ans, vector<vector<int>> &_Tree, vector<int> &score,
         ll num, int id, vector<int> &dis) {
  num += score[id];
  ans[id] = num;
  REP(i, _Tree[id].size()) {
    if (dis[id] >= dis[_Tree[id][i]]) continue;
    dfs(ans, _Tree, score, num, _Tree[id][i], dis);
  }
  return;
}
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> _Tree(N, vector<int>(0));
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b, a--, b--;
    _Tree[b].push_back(a);
    _Tree[a].push_back(b);
  }
  vector<int> score(N, 0);
  REP(i, Q) {
    int p, x;
    cin >> p >> x, p--;
    score[p] += x;
  }
  vector<int> dis(N, -1);
  queue<P> que{};
  que.push(P(0, 0));
  while (!que.empty()) {
    P tmp = que.front();
    que.pop();
    dis[tmp.first] = tmp.second;
    REP(i, _Tree[tmp.first].size()) {
      if (dis[_Tree[tmp.first][i]] != -1) continue;
      que.push(P(_Tree[tmp.first][i], tmp.second + 1));
    }
  }
  vector<int> ans(N, 0);
  dfs(ans, _Tree, score, 0, 0, dis);

  REP(i, N) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 32284
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    int m,d,c = 0;
    cin >> m >> d;

    for(int i = 1; i <= m; ++i){
        for(int j = 10; j <= d; ++j){
            int d1 = j % 10, d2 = j / 10;
            if(d1 >= 2 && d2 >= 2 && d1 * d2 == i){
                c++;
            }
                
        }
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = list(map(int, input().split()))

    total_prob = 0.0
    for i in range(1, N+1):
        res = i
        prob = 1 / N
        while res < K:
            prob *= 0.5
            res *= 2

        total_prob += prob

    print(total_prob)


if __name__ == '__main__':
    main()

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int H = 19;
const int W = 15;
string bd[H];
int id[H][W];
int dx[] = {1,1,0,-1,-1,-1,0,1};
int dy[] = {0,1,1,1,0,-1,-1,-1};

struct PH{
  template<class T, class U>
  size_t operator()(const pair<T,U>& x) const{
	size_t seed = 0;
	seed ^= hash<T>{}(x.first) + 0x9e3779b9 + (seed<<6) + (seed>>2);
	seed ^= hash<U>{}(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
	return seed;
  }
};

using D = pair<PII,int>;
namespace std{
template<> struct hash<D>{
  size_t operator()(const D& d) const{
	return PH{}(MP(PH{}(d.FF), d.SS));
  }
};
}

bool isin(const PII& p){
  return (0 <= p.FF && p.FF < H && 0 <= p.SS && p.SS < W);
}


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

  REP(i,19) cin >> bd[i];
  PII w;
  int gid = 0;
  REP(y,H) REP(x,W){
	if(bd[y][x] == 'O')
	  w = MP(y,x);
	else if(bd[y][x] == 'X')
	  id[y][x] = gid++;
  }

  int ans = -1;
  map<D,int> memo;
  queue<D> q;
  q.push(D(w,(1<<21)-1));
  memo[D(w,(1<<21)-1)] = 0;
  while(!q.empty()){
	D d = q.front();
	q.pop();
	PII p = d.FF;
	if(p.FF >= H || (p.FF == H-1 && isin(p))){
	  ans = memo[d];
	  break;
	}
	if(p.FF < 0 || p.SS < 0 || p.SS >= W)
	  continue;
	REP(dir,8){
	  int nb = d.SS;
	  PII np(p.FF+dy[dir], p.SS+dx[dir]);
	  while(isin(np) && bd[np.FF][np.SS] == 'X' && (nb>>id[np.FF][np.SS]&1)){
		nb ^= 1 << id[np.FF][np.SS];
		np.FF += dy[dir];
		np.SS += dx[dir];
	  }
	  if(nb == d.SS) continue;
	  if(!memo.count(D(np,nb))){
		 memo[D(np,nb)] = memo[d] + 1;
		 q.push(D(np,nb));
	  }
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8392
# aising2019C - Alternating Path
import sys

sys.setrecursionlimit(10 ** 9)


def dfs(x: int, y: int) -> None:
    global blk, wht
    cur = S[x][y]
    S[x][y] = 2  # make the grid visited
    if cur:
        blk += 1
    else:
        wht += 1
    for dx, dy in dxy:
        nx, ny = x + dx, y + dy
        if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == cur ^ 1:
            dfs(nx, ny)


def main():
    # separate S to connected components
    global H, W, S, dxy, blk, wht
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    S = [[1 if i == "#" else 0 for i in s] for s in S]
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] != 2:
                blk, wht = 0, 0
                dfs(i, j)
                ans += blk * wht
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 149252
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int64_t> A(N);
	for (int64_t i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());

	vector<pair<int64_t, int64_t>> v(M);
	for (int i = 0; i < M; i++) {
		cin >> v[i].second >> v[i].first;
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	int64_t vi = 0;
	for (int i = 0; i < N; i++) {
		if (vi >= M) break;
		if (A[i] < v[vi].first) {
			A[i] = v[vi].first;
			v[vi].second--;
		}
		if (!v[vi].second) vi++;
	}

	int64_t s = 0;
	for (int i = 0; i < N; i++) {
		s += A[i];
	}

	cout << s << endl;
}

Measured memory_bytes: 5588
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

class Position{
//private:
  public:
  double x;
  double y;
  int get_x(){return x;}
  int get_y(){return y;}
  void setdata(double a, double b){ x = a; y = b;}
  void disp(){printf("%.8lf %.8lf\n", x, y);}
};

void koch(int n, Position P0, Position P1){
  const double co = cos(M_PI/3);
  const double si = sin(M_PI/3);
  Position S,T,U;
  if(n == 0){
  }else{
    S.setdata((2*P0.x+P1.x)/3, (2*P0.y+P1.y)/3);
  //S.disp();
    T.setdata((P0.x+2*P1.x)/3, (P0.y+2*P1.y)/3);
    //T.disp();
    double ux = (T.x-S.x)*co - (T.y-S.y)*si + S.x;
    double uy = (T.x-S.x)*si + (T.y-S.y)*co + S.y;
    U.setdata(ux, uy);
    koch(n-1, P0, S);
    S.disp();
    koch(n-1, S, U);
    U.disp();
    koch(n-1, U, T);
    T.disp();
    koch(n-1, T, P1);
  }
}


int main(){
  Position First, Last;
  First.setdata(0, 0);
  Last.setdata(100, 0);
    int n;
  cin >> n;
  First.disp();
  koch(n, First, Last);
  Last.disp();
}

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

int main()
{
	int h, w;
	cin >> h >> w;

	vector<vector<bool>> mat(h, vector<bool>(w, false));
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < w; ++j) {
			if (s[j] == '.') {
				mat[i][j] = true;
			}
		}
	}

	vector<vector<int>> dp(h, vector<int>(w, 100000));
	dp[0][0] = 0;
	if (!mat[0][0]) {
		dp[0][0] = 1;
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (i == 0 && j == 0) {
				continue;
			}

			int a = 1000000;
			if (0 < i) {
				a = dp[i - 1][j];
				if (!mat[i][j]) {
					if (mat[i - 1][j]) {
						++a;
					}
				}
			}
			int b = 1000000;
			if (0 < j) {
				b = dp[i][j - 1];
				if (!mat[i][j]) {
					if (mat[i][j - 1]) {
						++b;
					}
				}
			}
			dp[i][j] = min(a, b);
		}
	}

	cout << dp[h - 1][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B, N;
  cin >> A >> B;
  int Y;
  if(B<10) {
    Y = 10;
  }
  else if(B<100) {
    Y = 100;
  }
  else {
    Y = 1000;
  }
  N = A * Y + B;
  int co = 0;
  rep(i, 317) {
    if(N == (i+1)*(i+1)) {
      co++;
      break;
    }
  }
  if(co == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.append(0)
s = sum(p[:k])
t = 0
for i in range(k-1,n):
    t = max(t,(k+s)/2)
    s -= p[i-k+1]
    s += p[i+1]
print(t)

Measured memory_bytes: 32380
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        int a = 0;
        int b = 0;
        int o = 0;
        int ab = 0;

        while(sc.hasNext()) {
            String[] line = sc.nextLine().split(",");
            if(line[1].equals("A")) {
                a += 1;
            } else if (line[1].equals("B")) {
                b += 1;
            } else if (line[1].equals("O")) {
                o += 1;
            } else if (line[1].equals("AB")) {
                ab += 1;
            }
           
        }

        System.out.println(a);
        System.out.println(b);
        System.out.println(ab);
        System.out.println(o);

    }
}

Measured memory_bytes: 12000