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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



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

    int n;
    cin >> n;
    vector <int> a(n);


    rep(i, n) cin >> a[i];

    ll max = a[0];
    ll ans = 0;

    for (int i = 1; i < SZ(a); i++) {
        if (max < a[i]) {
            max = a[i];
            continue;
        }
        else { ans += max - a[i]; }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 200001;
const int MOD = 1e9 + 7;
void add(int& a, int b){
  a += b;
  if(a >= MOD)
    a -= MOD;
}
struct State{
  int dp[3];
  State(){dp[0] = dp[1] = MOD / 2 + 1;dp[2] = 0;}
  void merge(State& b){
    int nw[3] = {0};
    for(int i = 0;i <= 2;i++)
      for(int j = 0;j <= 2;j++)
        add(nw[min(i + j, 2)], 1ll * dp[i] * b.dp[j] % MOD);
    for(int i = 0;i <= 2;i++)
      dp[i] = nw[i];
  }
};
int de[N];
vector<deque<State>> qs;
vector<vector<int>> adj;
int sz = 0;
int join(int a, int b){
  assert(qs[b].size() >= qs[a].size());
  for(int i = 0;i < qs[a].size();i++){
    qs[b][i].merge(qs[a][i]);
  }
  return qs[a].size();
}
void dfs(int u){
  if(adj[u].size() == 0){
    de[u] = sz++;
    qs.push_back(deque<State>());
    qs[de[u]].push_front(State());
    return;
  }
  int mx, mxi;
  mx = -1;
  for(auto v : adj[u]){
    dfs(v);
    int ch_in = de[v];
    int ch_sz = qs[ch_in].size();
    if(ch_sz > mx)
      mx = ch_sz, mxi = v;
  }
  int l = 0;
  assert(mx != -1);
  de[u] = de[mxi];
  for(auto v : adj[u])
    if(v != mxi)
      l = max(l, join(de[v], de[u]));

  int in = de[u];
  for(int i = 0;i < l;i++)
    qs[in][i].dp[0] += qs[in][i].dp[2], qs[in][i].dp[2] = 0;
  qs[in].push_front(State());
}


int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  n++;
  adj.resize(n);
  for(int i = 0;i < n - 1;i++){
    int p;
    cin >> p;
    adj[p].push_back(i + 1);
  }
  dfs(0);

  int pp = 1;
  for(int i = 0;i < n;i++)
    pp = 1ll * pp * 2 % MOD;
  int res = 0;
  for(auto el : qs[de[0]]){
    add(res, el.dp[1]);
//    cout << 1ll * el.dp[1] * pp % MOD << endl;
  }
  cout << 1ll * pp * res % MOD;
}



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

int main()
{
    int N, K;

    cin >> N >> K;

    int count = 0;
    for(int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if(h >= K) {
            count += 1;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int N = 2e5;
int n, m;
vector<int> g[N];
vector<int> dp(N, -1);
vector<int> input(N, 0);
vector<int> leaves;
void read_input(){
    cin >> n >> m;
    for(int i = 0;i < m;i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        input[y]++;
    }
    for(int i = 0;i < n;i++){
        if(input[i] == 0){
            leaves.push_back(i);
        }
    }
}

int dfs(int v){
    if(dp[v] != -1){
        return dp[v];
    }
    if(sz(g[v]) == 0){
        return dp[v] = 0;
    }
    int ans = 0;
    for(auto u : g[v]){
        int d = dfs(u);
        ans = max(ans, d + 1);
    }
    return dp[v] = ans;
}

signed main(){
    ios::sync_with_stdio(false);
    read_input();
    for(auto leaf : leaves){
        dfs(leaf);
    }
    int ans = 0;
    for(auto leaf : leaves){
        ans = max(ans, dp[leaf]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

int N,A;
ll dp[51][5010];

int data[51];

ll sch(int i,int a){
    int x=a+2500;
    if(i==0) return dp[i][x];
    if(dp[i][x]!=-1) return dp[i][x];
    return dp[i][x]=sch(i-1,a)+sch(i-1,a-data[i]);
}

int main(){

    cin>>N>>A;

    for(int i=1;i<=N;i++) {
        cin>>data[i];
        data[i]-=A;
    }

    dp[0][2500]=1;
    for(int i=1;i<=50;i++){
        for(int j=0;j<5010;j++) dp[i][j]=-1;
    }
    
    cout<<sch(N,0)-1<<endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d;
        int r;
        double f;
        d = a /b;
        r = a % b;
        f = 1.0 * a / b;
        System.out.print(d + " " + r + " " );
        System.out.println(String.format("%.8f", f));
}

}



Measured memory_bytes: 26496
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

int n;
char s1[110], s2[110];
char p[4] = {'.', '.', '#', '#'};
char q[4] = {'.', '#', '.', '#'};
char res[5];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    scanf("%d", &n);
    s1[1] = s2[1] = '\0';
    FOR(i,0,3) {
        s1[0] = p[i];
        s2[0] = q[i];
        printf("%s\n%s\n", s1, s2); fflush(stdout);
        scanf("%s", res);
        if (strcmp(res, "T") == 0) break;
        else if (strcmp(res, "end") == 0) return 0;
    }
    int remain = n-1;
    while (remain) {
        s1[n-remain+1] = s1[n-remain];
        s2[n-remain+1] = s2[n-remain];
        bool co = false;
        FOR(i,0,3) {
            s1[n-remain] = p[i];
            s2[n-remain] = q[i];
            printf("%s\n%s\n", s1, s2); fflush(stdout);
            scanf("%s", res);
            if (strcmp(res, "T") == 0) {
                co = true;
                break;
            }
            else if (strcmp(res, "end") == 0) return 0;
        }
        if (co) remain--;
        else break;
    }
    if (remain) s1[n-remain] = s2[n-remain] = '\0';
    while (remain) {
        FORE(i,n-remain+1,1) {
            s1[i] = s1[i-1];
            s2[i] = s2[i-1];
        }
        FOR(i,0,3) {
            s1[0] = p[i];
            s2[0] = q[i];
            printf("%s\n%s\n", s1, s2); fflush(stdout);
            scanf("%s", res);
            if (strcmp(res, "T") == 0) break;
            else if (strcmp(res, "end") == 0) return 0;
        }
        remain--;
    }
    return 0;
}


Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int two = 0;
        int four = 0;
        int twoNotFour = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (num % 2 == 0) {
                two++;
            }
            if (num % 4 == 0) {
                four++;
            }
            if (num % 2 == 0 && num % 4 != 0) {
                twoNotFour++;
            }
        }
        
        boolean ok = false;
        if (two == n) {
            ok = true;
        } else if (four >= n / 2) {
            ok = true;
        } else if (n - (four * 2) <= twoNotFour) {
            ok = true;
        }
        
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 48340
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb push
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001


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

    ll r,c,ma=0,u,v,dist;
    cin>>r>>c;
	string s[r];
    ifr(i,0,r) cin>>s[i];
    ifr(i,0,r) {
    	ifr(j,0,c) {
    		bool vis[r][c];
    		ifr(t,0,r) ifr(k,0,c) vis[t][k] = 0; 
    		if(s[i][j]=='#') continue;
		    queue<tuple<ll,ll,ll>> q;
		    q.pb(mt(i,j,0));vis[i][j]=1;
		    ll tma = 0;
		    while(!q.empty()) {
		    	tie(u,v,dist) = q.front();
		    	tma = max(tma,dist);
		    	q.pop();
		    	if( v+1<c && s[u][v+1]!='#' && !vis[u][v+1]){
		    		q.pb(mt(u,v+1,dist+1));
		    		vis[u][v+1] = 1;
		    	}
		    	if( u+1<r && s[u+1][v]!='#' && !vis[u+1][v]) {
		    		q.pb(mt(u+1,v,dist+1));
		    		vis[u+1][v] = 1;
		    	}
		    	if( v-1>=0 && s[u][v-1]!='#' && !vis[u][v-1]){
		    		q.pb(mt(u,v-1,dist+1));
		    		vis[u][v-1] = 1;
		    	}
		    	if( u-1>=0 && s[u-1][v]!='#' && !vis[u-1][v]) {
		    		q.pb(mt(u-1,v,dist+1));
		    		vis[u-1][v] = 1;
		    	}
		    }
		    ma = max(ma,tma);
		    // cout<<i+1<<" "<<j+1<<" "<<tma<<endl;
		}
	}
	cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        // input N
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt(), D = sc.nextInt() ;
        int ANS = 0;
        for (int i = 0;i<N;i++){
            long x = sc.nextInt(),y = sc.nextInt();
            if (D*D >= x*x + y*y){
                ANS += 1;
            }
        }

        System.out.println(ANS);
        
    }
}

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

int main(){
  int N;
  cin >> N;
  int64_t ans=0;
  map<pair<char,char>,int> m;
  string s;
  pair<char,char> p;
  for(int i=1;i<=N;i++){
    if(i%10==0){
      continue;
    }
    s=to_string(i);
    p=make_pair(s.front(),s.back());
    if(m.count(p)){
      m.at(p)++;
    }else{
      m[p]=1;
    }
  }
  char f,b;
  for(auto & x:m){
    tie(f,b)=x.first;
    p=make_pair(b,f);
    if(m.count(p)){
      ans+=x.second*m.at(p);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
#define TRUE 1
#define FALSE 0

int N;

typedef struct{
  char mark;
  int value;
} trump;

/* 値をいれかえる関数*/
void swap(trump *a, trump *b){
  trump tmp;
  
  tmp = *a;
  *a = *b;
  *b = tmp;
}

void BubblleSort(trump C[]){
    int i,j;
    
    for(i=0; i<N-1; i++){
      for(j=N-1; j>=i+1; j--){
        if(C[j].value < C[j-1].value) 
          swap(&C[j],&C[j-1]);
      }
    }
}

void SelectionSort(trump C[]){
  int i,j;
  int minj;
  
  for(i=0; i<N; i++){
    minj = i;
    for(j=i; j<N; j++){
      if(C[j].value < C[minj].value)
        minj = j;
    }
    
    swap(&C[i],&C[minj]);
  }
}

/* ソートの結果を出力する関数*/

void Allprint(trump C[]){
  int i;
  
  for(i=0; i<N; i++){
    if(i != 0) printf(" ");
    printf("%c%d",C[i].mark,C[i].value);
  }
  printf("\n");
}

/*安定かどうかを調べ、安定ならTRUE(1)を、そうでないならFALSE(0)を返す関数*/

int check_stable(trump in[],trump out[]){
  int i,j,k,l;
  for(i=0; i<N; i++){
    for(j=i+1; j<N; j++){
      for(k=0; k<N; k++){
        for(l=k+1; l<N; l++){
          if(in[i].value == in[j].value
             && in[i].value == out[l].value 
             && in[i].mark == out[l].mark 
             &&in[j].value == out[k].value
             &&in[j].mark == out[k].mark)
            return FALSE;
        }
      }
    }
  }
  
  return TRUE;
}


int main(){
  int i;
  trump in[36];
  trump bubble[36];
  trump selection[36];
  
  scanf("%d",&N);
  for(i=0; i<N; i++){ 
    scanf(" %c%d",&in[i].mark,&in[i].value);
  }

  /*バブルソート、選択ソートをした結果をそれぞれ保存する配列を用意する*/
  for(i=0; i<N; i++){
    bubble[i] = in[i];
    selection[i] = in[i];
  }

  /*バブルソートの結果と安定かどうか出力する*/
  BubblleSort(bubble);
  Allprint(bubble);
  if( check_stable(in,bubble) ) printf("Stable\n");
  else printf("Not stable\n");

  /*選択ソートの結果と安定かどうか出力する*/
  SelectionSort(selection);
  Allprint(selection);
  if(check_stable(in,selection)) printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
  
}



Measured memory_bytes: 2728
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()
mi=h[len(h)-1]
for i in range(n-k+1):
    if h[i+k-1]-h[i]<mi:
        mi=h[i+k-1]-h[i]
print(mi)

Measured memory_bytes: 7384
using System;
using System.IO;
using System.Linq;

class Program{
    static void Main(string[] args) {
        var A1 = Console.ReadLine().Split();
        var A2 = Console.ReadLine().Split();
        var A3 = Console.ReadLine().Split();
        var sheet = new[] {A1, A2, A3};
        var N = int.Parse(Console.ReadLine());
        var isHole = Enumerable.Repeat(false, 9).ToArray();
        for (int i = 1; i <= N; i++){
            var b = Console.ReadLine();
            var j = 0;
            for (int r = 0; r < 3; r++){
                for (int c = 0; c < 3; c++){
                    if (b == sheet[r][c]) isHole[j] = true;
                    j++;}}}
        var h1 = isHole[0] && isHole[1] && isHole[2];
        var h2 = isHole[3] && isHole[4] && isHole[5];
        var h3 = isHole[6] && isHole[7] && isHole[8];
        var v1 = isHole[0] && isHole[3] && isHole[6];
        var v2 = isHole[1] && isHole[4] && isHole[7];
        var v3 = isHole[2] && isHole[5] && isHole[8];
        var d1 = isHole[0] && isHole[4] && isHole[8];
        var d2 = isHole[2] && isHole[4] && isHole[6];
        var isBingo = new[] { h1, h2, h3, v1, v2, v3, d1, d2 };
        var answer = isBingo.Contains(true) ? "Yes" : "No";
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 28500
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	cnt := 0
	for i := 0; i < 2; i++ {
		if a > b {
			cnt += a
			a--
			continue
		} else if a < b {
			cnt += b
			b--
			continue
		}

		cnt += a
		a--
	}
	fmt.Print(cnt)
}


Measured memory_bytes: 512
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> one = nextCharArray();
      for(int i = 0; i < one.size(); i++){
        if(one.get(i).equals("1")){
          one.set(i, "9");
        }else if(one.get(i).equals("9")){
          one.set(i, "1");
        }
      }
      myout(myconv(one, 0));
	}
	//Method addition frame start



	//Method addition frame end
}


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

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int i;
    for (i = 0; i < n - 1; i++) {
        if (x >= a[i])
            x -= a[i];
        else
            break;
    }

    if (x == a[n - 1])
        i++;

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq as hp

class Edge:
    def __init__(self, end, cost):
        self.to = end
        self.cost = cost


class Dijkstra:
    def __init__(self, V):
        self._node = V
        self._graph = [[] for i in range(self._node)]
        self._inf = sys.maxsize
        self.dist = [self._inf for i in range(self._node)]

    def add_edge(self, st, ed, cost):
        self._graph[st].append(Edge(ed, cost))
    def solve(self, s):
        que = []
        self.dist[s] = 0
        hp.heappush(que, (0, s))
        while que:
            cur_cost, cur_vertex = hp.heappop(que)
            if self.dist[cur_vertex] < cur_cost:
                continue
            for e in self._graph[cur_vertex]:
                if cur_cost + e.cost < self.dist[e.to]:
                    self.dist[e.to] = cur_cost + e.cost
                    hp.heappush(que, (self.dist[e.to], e.to))


if __name__ == '__main__':
    V, E, r = map(int, input().split())
    dk = Dijkstra(V)
    for i in range(E):
        s, t, d = map(int, input().split())
        dk.add_edge(s, t, d)
    dk.solve(r)
    for value in dk.dist:
        if value == sys.maxsize:
            print("INF")
        else:
            print(value)



Measured memory_bytes: 139716
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

ans = 0
(0..a).to_a.each do |ai|
  (0..b).to_a.each do |bi|
    (0..c).to_a.each do |ci|
      ans += 1 if 500*ai + 100*bi + 50*ci == x
    end
  end
end

puts ans


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

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

    vector<vector<int>> adjacency_list(N + 1, vector<int>());

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        adjacency_list[A].push_back(B);
        adjacency_list[B].push_back(A);
    }

    vector<bool> reached(N + 1, false);
    vector<int> sign(N + 1);
    queue<int> rec;
    int count = 0;

    reached[1] = true;
    rec.push(1);
    ++count;

    while(!rec.empty()) {
        int room = rec.front();
        rec.pop();

        for (int next_room : adjacency_list[room]) {
            if (!reached[next_room]) {
                rec.push(next_room);
                reached[next_room] = true;
                sign[next_room] = room;
                ++count;
            }
        }

        if (count >= N) {
            break;
        }
    }

    cout << "Yes" << endl;

    for (int i = 2; i < N + 1; ++i) {
        cout << sign[i] << endl;
    }
}

Measured memory_bytes: 10012
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int a[N];
int cnt[N];
int main(void)
{   int n;
    int maxx = 1;
    while(scanf("%d",&n)!=EOF)
    { memset(cnt,0,sizeof(cnt));
      for(int i = 0;i < n;i++)
      {
         scanf("%d",&a[i]);
         cnt[a[i]]++;
         cnt[a[i]-1]++;
         cnt[a[i]+1]++;
         maxx = max(cnt[a[i]],maxx);
         maxx = max(cnt[a[i] - 1],maxx);
         maxx = max(cnt[a[i] + 1],maxx);
      }
      printf("%d\n",maxx);
    }
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
Wn = [input() for _ in range(N)]

if len(set(Wn)) != N:
    print("No")
else:
    bw = Wn[0]
    for W in Wn[1:]:
        if W[0] != bw[-1]:
            print("No")
            break
        bw = W
    else:
        print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define X 200010
int p[X],n,m,N;
void Unite(int a,int b){
	int x=a,y=b;
	while(p[x]!=x)x=p[x];
	while(p[y]!=y)y=p[y];
	while(a!=x){int t=p[a];p[a]=x,a=t;}
	while(b!=y){int t=p[b];p[b]=y,b=t;}
	p[x]=y;
}
int main(){
	cin>>n>>m;
	N=n+m;
	lol(i,N)p[i]=i;
	lol(i,n){
		int a;cin>>a;
		lol(j,a){
			int b;cin>>b;
			Unite(i,b+n-1);
		}
	}
	set<int> st;
	lol(i,n){
		int x=p[i];
		while(p[x]!=x)x=p[x];
		st.insert(x);
	}
	cout<<(st.size()==1?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
using namespace std;
const long long inf=1e18;
typedef long long ll;
int main()
{
   int n,l,r;
   cin>>n>>l>>r;
   if((r-l-1)%2==1)
   {
       cout<<"Alice"<<endl;
   }
   else
   {
       cout<<"Borys"<<endl;
   }
    return 0;
}


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

using namespace std;

//#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;

inline void setMax(int &a, int b){ a = max(a, b); }
inline void setMin(int &a, int b){ a = min(a, b); }

signed main(){
    cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0);

    int N;
    cin >> N;
    double a;
    priority_queue<double, vd, greater<double>> pq;

    for(int i=0; i<N; i++){
        cin >> a;
        pq.push(a);
    }

    while(pq.size() != 1){
        double f, s;
        f = pq.top(); pq.pop();
        s = pq.top(); pq.pop();
        pq.push((f+s)/2);
    }    

    cout << setprecision(12) << pq.top();
}

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

void trace(int A[], int N){
	for(int i = 0; i < N; i++){
		cout<<A[i];
		if(i < N - 1) cout<<" ";
	}
	cout<<endl;
}

int Bubble_Sort(int A[], int N) {
	int count = 0, flag = 1, i = 0;

	while(flag){
		flag = 0;
		for(int j = N - 1; i + 1 <= j; j--){
			if(A[j] < A[j - 1]){
				swap(A[j], A[j - 1]);
				count++;
				flag = 1;
			}
		}
		i++;
	}

	trace(A, N);

	return count;
}

int main(){	
	int N, A[100];

	cin>>N;

	for(int i = 0; i < N; i++) cin>>A[i];
	
	cout<<Bubble_Sort(A, N)<<endl;
	
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;

int main(){
	string S;
	int N,C,K;
	N = 0;
	C = 0;
	cin >> S;
	if (S[0]=='0' && '0'<S[1] && S[1]<='9' ){
		N=1;
		C++;
	}
	else if( S[0]=='1' && S[1]<='2'){
		N=1;
		C++;
	}

	if (S[2]=='0' && '0'<S[3] && S[1]<='9'){
		N=2;
		C++;
	}
	else if( S[2]=='1' and S[3]<='2'){
		N=2;
		C++;
	}
	if(C==2){
		cout << "AMBIGUOUS";
	}
	else if(N==1){
		cout << "MMYY";
	}
	else if(N==2){
		cout << "YYMM";
	}
	else{
		cout << "NA";
	}

	cin >> K;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    int n;
    cin >> n;
    int ans = n;
    for(int i = 0; i <= n; i++) {
        int cnt =0;
        int t = i;
        while(t > 0){
            cnt += t % 6;
            t /= 6;
        }
        t = n - i;
        while(t > 0){
            cnt += t % 9;
            t /= 9;
        }
        ans = min(ans, cnt);
    }
    pf(ans)
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N,L;
  cin>>N>>L;
  int total=0;
  vector<int> aji(N);
  for(int i=0;i<N;i++){
    aji[i]=L+i;
    total+=aji[i];
  }
  int ans=1e9;
  int kotae=0;
  for(int i=0;i<N;i++){
    if(ans>abs((total-aji[i])-total)){
    ans=abs((total-aji[i])-total);
    kotae=total-aji[i];
    }
  }
  cout<<kotae<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
const int N=100010;
int a[N];
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,i,maxa,ans,d,mind;
    maxa=-1,ans=mind=0x3f3f3f3f;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        if(maxa<a[i]) maxa=a[i];
    }
    for(i=1; i<=n; i++)
    {
        d=abs(maxa-2*a[i]);
        if(d<=mind)
        {
            mind=d;
            ans=a[i];
        }
    }
    printf("%d %d",maxa,ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10;
const int mod=1e9+7;
const int inf=1e9;

ll dp[N][2];
bool vis[N];
vector<int> g[N];

void dfs(int u){
    if(vis[u]) return;
    vis[u]=true;
    dp[u][0]=1;
    dp[u][1]=1;
    for(auto v : g[u]){
        if(vis[v]) continue;
        dfs(v);
        dp[u][0]=(dp[u][0]*(dp[v][0] + dp[v][1]))%mod;
        dp[u][1]=(dp[u][1]*dp[v][0])%mod;
    }
}

int main(){
    int n;
    cin>>n;
    int a,b;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1);
    ll ans=(dp[1][0] + dp[1][1])%mod;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 17496
n,q = map(int, input().split())


s = input()
arr = []
c = 0
for i in range(len(s)):
    if i == 0:
        arr.append(0)
    else: 
        # print(s[i-1]+s[i])
        if (s[i-1]+s[i]) == "AC":
            c+=1
        arr.append(c)

# print(arr)
for _ in range(q):
    l,r = map(int, input().split())
    print(arr[r-1]-arr[l-1])

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int temp,flag=1;
    char letters[100];
    int alphabets[27] = { 0 };
    cin>>letters;
    for(int i=0; i<strlen(letters); i++)
    {
        alphabets[letters[i]-'a']++;
    }
    for(int i=0; i<26; i++)
    {
        if(alphabets[i]%2!=0)
        {
            flag=0;
            break;
        }
    }
    if(flag==0)
        cout<<"No\n";
    else
        cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

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

int main() {
    int n;
    int t;
    cin >> n >> t;
    vector<int> a(n);
    ll total = 0;
    int delta = 0;
    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        delta = a[i] - a[i - 1];
        if (delta < t) {
            total += delta;
        } else {
            total += t;
        }
    }
    total += t;

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

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

    ll n, k;
    cin >> n >> k;

    ll cum = 1;
    ll ans = 0;
    while (cum <= n) {
        cum *= k;
        ans++;
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double v[100];
int main()
{
  int n;
  long double pw = 2,sum = 0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v,v+n);
  sum+=v[0]+v[1];
  for(int i=2;i<n;i++){
   sum+=pw*v[i]; 
    pw*=2;
  }
  cout<<fixed<<setprecision(16);
  cout<<sum/pw;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if(a==b+c||b==a+c||c==a+b) System.out.println("Yes");
		else System.out.println("No");
		scanner.close();
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)

int main ()
{
    int N; cin >> N;
    vector < int > d(N);
    REP(i,N) cin >> d[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	//file();
	fast();
	string a, b, c; cin >> a >> b >> c;
	if (b.front() == a.back() && c.front() == b.back())
		cout << "YES" << endl;
	else cout << "NO" << endl;	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;

  return 0;
}


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

int main(void)
{
    int N, D, X;
    cin >> N >> D >> X;

    vector<int> A(N, 0);
    int minimum = 100;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        minimum = min(minimum, A[i]);
    }

    vector<int> days(D, 0);
    days[0] = N;
    for (int i = 0; i < N; i++) // members
    {
        for (int j = 1; j < 100; j++)
        {
            int day = j * A[i] + 1;
            if (day <= D)
            {
                days[day - 1]++;
            }
        }
    }

    int sum = X;
    for (int i = 0; i < D; i++)
    {
        // printf("%d ", days[i]);
        sum += days[i];
    }
    cout << sum << endl;

    return (0);
}

Measured memory_bytes: 256
from itertools import combinations

N = int(input())
L = list(map(int,input().split()))

stick = combinations(L,3)

cnt = 0
for x, y, z in stick:
    l = sorted([x, y, z])
    if x - y != 0 and x - z != 0 and y - z != 0:
        if l[2] < l[0]+l[1]:
            cnt += 1
print(cnt)            
    



Measured memory_bytes: 9180
#include <stdio.h>
int main(void){
int K,N,max,min;
int i=0;
  scanf("%d",&K);
  scanf("%d",&N);
 int d[N];
  for(i;i<N;i++)
   scanf("%d",&d[i]);
  max=d[0]+(K-d[N-1]);
  for(i=1;i<N;i++){
  if(max<d[i]-d[i-1])
    max=d[i]-d[i-1];}
  min=K-max;
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int cnt = 0;
	while (cnt < C)
	{
		if (B >= A)
		{
			B -= A;
			cnt++;
		}
		else break;
	}
	cout << cnt;
}

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



namespace CSharpSample01
{



    class Program
    {

        static int[] e;
        
        static int Elen(int m)
        {
            int len = 0;
            for(int i = 0; i < e.Length; i++)
            {
                if (e[i] >= m - 1) len++;
            }

            return len;
        }
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            e = new int[N + 1];

            for(int i = 2; i <= N; i++)
            {
                int now = i;
                for(int j = 2; j <= now; j++)
                {
                    while(now % j == 0)
                    {
                        now /= j;
                        e[j]++;
                    }
                   
                }
            }

            int[] table = { 2, 4, 14, 24, 74 };
            int[] cnt = new int[5];
            
            for(int i = 0; i < e.Length; i++)
            {
                for(int j = table.Length - 1; j >= 0; j--)
                {
                    if(e[i] >= table[j])
                    {
                        cnt[j]++;
                        break;
                    }
                }
            }

            int ans = 0;

            
            ans = Elen(75) + Elen(25) * (Elen(3) - 1) + Elen(15) * (Elen(5) - 1)
                + Elen(5) * (Elen(5) - 1) * (Elen(3) - 2) / 2;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
e = 10**9 + 7
P = []
for i in range(2,N+1):
    a = 1
    for p in P:
        if i % p == 0:
            a = 0
            break
    if a == 1:
        P.append(i)
d = {}
for p in P:
    d[p] = 1
for i in range(1,N+1):
    x = i
    for p in P:
        while x % p == 0:
            x = x//p
            d[p] += 1
ans = 1
for p in P:
    ans = (ans*d[p])%e
    
print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vp;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    ll n,k; cin>>n>>k;
    n = n % k;
    cout<<min(n, k-n);
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
loop vars,1LL in mult, out of bounds, int v ll, endl, finish taking inputs, large doubles, larger INF
*/





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

int main(){

    int a, b;
    cin >> a >> b;

    int i = 0;

    while(1){

        ++i;

        int ai = a+i;
        int bi = b+i;

        //cout << 1 << " "<< ai << " " << bi << endl;

        int j = 0;

        while(ai >= j){

            ai -= j;
            bi -= j;
            ++j;

            //cout << 2 << " "<< ai << " " << bi << endl;

            if(ai == 0 && bi== j){

                cout << i << endl;
                 return 0;
            }

        }

    }

}

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

kakuritu = 0

for i in range(N):
    tokuten = i+1
    mokuhyou = tokuten
    cnt = 0
    while mokuhyou < K:
        mokuhyou += tokuten
        tokuten *= 2
        cnt += 1
    kakuritu += (1/N)*(1/(2**cnt))

print(kakuritu)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d,e;
    cin >> a >> b >> c >> d >>e ;
    int k;
    cin >> k;
 
    if ((e - a) > k){ cout <<  ":("<<endl;}
    else {cout << "Yay!"<<endl;}
	return 0;	
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
class Fenwick{
private:
    int length, vecsize;
    long long *vec;
public:
    Fenwick(int l);
    ~Fenwick();
    void add(int a,long long x);
    long long sum(int a);
    long long operator[](int i);
    void init();
    void set(int a,long long x);
};
Fenwick::Fenwick(int l){
    this->length=l;
    vecsize=1;
    while(l>0){
        vecsize<<=1;
        l>>=1;
    }
    vecsize++;
    this->vec=new long long[vecsize];
    init();
}
Fenwick::~Fenwick(){
    delete[] vec;
}
// v[0]+v[1]+...+v[a-1]
long long Fenwick::sum(int a){
    if(a<0)return 0;
    if(a>length)a=length;
    long long sum=0;
    while(a>0){
        sum+=vec[a];
        a-=a&(-a);
    }
    return sum;
}
// v[a]+=x
void Fenwick::add(int a,long long x){
    while(a<length){
        vec[a]+=x;
        a+=a&(-a);
    }
}
void Fenwick::init(){
    for(int i=0;i<vecsize;i++){
        vec[i]=0;
    }
}
int main(){
    int n,m,l,r;
    scanf("%d%d",&n,&m);
    std::vector<std::pair<int,int>> vp;
    for(int i=0;i<n;i++){
        scanf("%d%d",&l,&r);
        vp.push_back({r-l+1,l});
    }
    std::sort(vp.begin(),vp.end(),std::greater<std::pair<int,int>>());
    Fenwick cumsum(m+2);
    for(int d=1;d<=m;d++){
        while(!vp.empty() && (*vp.rbegin()).first<=d){
            l=(*vp.rbegin()).second;
            r=(*vp.rbegin()).first+l-1;
            cumsum.add(l,1);
            cumsum.add(r+1,-1);
            vp.pop_back();
        }
        int ans=vp.size();
        for(int k=d;k<=m;k+=d){
            ans+=cumsum.sum(k);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 6384
H, W = [int(i) for i in input().split()]
M = []
for i in range(H):
  S = input()
  M.append(S)

X = []
for i in range(H):
  C = [0 for _ in range(W)]
  count = 0
  for j in range(W-1, -1, -1):
    if M[i][j] == ".":
      count += 1
      C[j] = count
    else:
      count = 0

  r = [0 for _ in range(W)]
  current = C[0]
  for j in range(W):
    if M[i][j] == ".":
      r[j] = current
    else:
      r[j] = 0
      if j + 1 < W:
        current = C[j+1]
  X.append(r)
Y = []
for i in range(W):
  C = [0 for _ in range(H)]
  count = 0
  for j in range(H-1, -1, -1):
    if M[j][i] == ".":
      count += 1
      C[j] = count
    else:
      count = 0

  r = [0 for _ in range(H)]
  current = C[0]
  for j in range(H):
    if M[j][i] == ".":
      r[j] = current
    else:
      r[j] = 0
      if j + 1 < H:
        current = C[j+1]
  Y.append(r)

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, X[i][j]+Y[j][i]-1)
print(ans)


Measured memory_bytes: 146712
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,i,c,c1,l;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    c = 0;
    while(a[0]%2 == 0)
    {
        c++;
        a[0] /= 2;
    }    
    for(i=1;i<n;i++)
    {
        c1 = 0;
        while(a[i]%2 == 0)
        {
            c1++;
            a[i] /= 2;
        }
        if(c1 != c)
        {
            cout<<0;
            return 0;
        }
    }
    l = a[0];
    for(i=1;i<n;i++)
    {
        l = l*(a[i]/__gcd(a[i],l));
        if(l > m)
        {
            cout<<0;
            return 0;
        }
    }
    c--;
    while(c)
    {
        l = 2*l;
        c--;
        if(l > m)
        {
            cout<<0;
            return 0;
        }
    }
    cout<<((m/l+1)/2);
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
typedef struct S{
  int parent;
  int *d;
  int e;
}Node;

int depth();

int main(){
  int n,i,j,a,b,c;
  Node *node;
  scanf("%d",&n);
  node=(Node*)malloc(sizeof(Node)*n);
  for(i=0;i<n;i++){
    node[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    node[a].d=(int*)malloc(sizeof(int)*b);
    node[a].e=b;
    for(j=0;j<b;j++){
      scanf("%d",&node[a].d[j]);
      node[node[a].d[j]].parent=a;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",node[i].parent);
    printf("depth = %d, ",depth(node,i));
    if(node[i].parent==-1){
      printf("root, ");
    }
    else if(node[i].e==0){
      printf("leaf, ");
    }
    else{
      printf("internal node, ");
    }
    printf("[");
    for(j=0;j<node[i].e;j++){
            printf("%d",node[i].d[j]);
            if(j!=node[i].e-1){
                printf(", ");
            }
        }
        printf("]\n");
    }
}
int depth(Node node[],int n){
    if(node[n].parent==-1){
        return 0;
    }
    return depth(node,node[n].parent)+1;
}



Measured memory_bytes: 7564
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	ll n;
	cin >> n;
	ll ans = (n-(ll)1)*n/(ll)2;

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

Measured memory_bytes: 256