akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
int t[2][300005],d[300005];
int main(){
  int n,ma;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&d[i]);
    d[i] /= 10;
  }
  ma = 0;
  for(int i=0;i<n-1;i++){
    ma = max(ma-1,d[i]);
    t[0][i] = ma;
  }
  ma = 0;
  for(int i=n-1;i>0;i--){
    ma = max(ma-1,d[i]);
    t[1][i] = ma;
  }
  int j,ans = 0;
  j = 0;
  while(j < n-1 && t[0][j] != 0) j = j+t[0][j];
  if(j >= n-1) ans++;
  j = n-1;
  while(j > 0 && t[1][j] != 0) j = j-t[1][j];
  if(j <= 0) ans++;
  puts(ans==2?"yes":"no");
  return(0);
}



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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005

int main(){
ll h,w;
cin>>h>>w;
char g[h][w];
ll dp[h][w];
memset(dp,0,sizeof(dp));
ll fl1=0,fl2=0,li=h,lj=w;
fr(i,0,h){
	fr(j,0,w){
		cin>>g[i][j];
//cout<<"abcd1";
		if(i==0&&g[i][j]=='#'&&fl1==0){
//cout<<"abcd2";
			fl1=1;
			lj=j;
//			cout<<j<<" ";
		}
		if(j==0&&g[i][j]=='#'&&fl2==0){
//cout<<"abcd3";
			fl2=1;
			li=i;
//			cout<<i<<" ";
		}
	}
}
fr(j,0,lj){
	dp[0][j]=1;
}
fr(i,1,li){
	dp[i][0]=1;
}

fr(i,1,h){
	fr(j,1,w){
		if(g[i][j]=='#'){
			dp[i][j]=0;
		}else{
			dp[i][j]=((dp[i-1][j]%mod)+(dp[i][j-1]%mod))%mod;
		}
	}
}


//cout<<"abcd";
//fr(i,0,h){
//	fr(j,0,w){
//cout<<dp[i][j]<<" ";
//}
//cout<<endl;
//}
cout<<dp[h-1][w-1]%mod;
}


Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;


    ll W,H,N;
    ll sum;
    ll ans=0;
    ll sm,lr;
    ll A[1100];
    ll C[10];
    bool f=false;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    REP(i,N){
        if(A[i]<400){
            C[0]++;
        }else if(A[i]<800){
            C[1]++;
        }else if(A[i]<1200){
            C[2]++;
        }else if(A[i]<1600){
            C[3]++;
        }else if(A[i]<2000){
            C[4]++;
        }else if(A[i]<2400){
            C[5]++;
        }else if(A[i]<2800){
            C[6]++;
        }else if(A[i]<3200){
            C[7]++;
        }else{
            C[8]++;
        }
    }
    REP(i,9){
        if(i!=8){
            if(C[i]>0){
                sm++;
                lr++;
            }
        }else{
            if(C[i]>0){
                if(sm==0)sm++;
                DEB(C[i])
                lr++;
                lr+=C[i]-1;
            }
        }
    }
    cout<<sm<<" "<<lr;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] ans = new int[N];
        for(int i=0;i<N-1;i++){
            ans[sc.nextInt()-1]++;
        }
        for(int i=0;i<N;i++){
            System.out.println(ans[i]);
        }
    }

}


Measured memory_bytes: 60332
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main(void)
{
    int n, k;
    cin >> n >> k;
    v_ll h(n);
    ll ans = 0;
    
    irep(i, n) {
        ll tmp;
        cin >> h[i]; 
    }
    sort(h.begin(), h.end());

    int i_max = min(n, k);

    irep(i, n - i_max) {
        ans += h[i];
    }
    cout << ans << endl;

	return 0;
}
/** atcodr **/


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	deq := newDeque(400000)
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		switch t {
		case 0:
			d := getNextInt(scanner)
			x := getNextInt(scanner)
			if d == 0 {
				deq.pushFront(x)
				continue
			}
			deq.pushBack(x)
		case 1:
			p := getNextInt(scanner)
			fmt.Fprintln(writer, deq.at(p))
		case 2:
			d := getNextInt(scanner)
			if d == 0 {
				deq.popFront()
				continue
			}
			deq.popBack()
		}
	}
}

type deque struct {
	list       []int
	l, r, size int
}

func newDeque(size int) deque {
	return deque{
		list: make([]int, size),
		l:    0,
		r:    0,
		size: size,
	}
}
func (deq *deque) index(i int) int {
	if i < 0 {
		i += deq.size
	}
	if i >= deq.size {
		i -= deq.size
	}
	return i
}
func (deq *deque) at(i int) int {
	return deq.list[deq.index(deq.l+i)]
}
func (deq *deque) pushBack(x int) {
	deq.list[deq.r] = x
	deq.r = deq.index(deq.r + 1)
}
func (deq *deque) pushFront(x int) {
	deq.l = deq.index(deq.l - 1)
	deq.list[deq.l] = x
}
func (deq *deque) popBack() {
	deq.r = deq.index(deq.r - 1)
}
func (deq *deque) popFront() {
	deq.l = deq.index(deq.l + 1)
}



Measured memory_bytes: 10144
#include<iostream>
using namespace std;;
int main(){
double n,m;
cin >>n>>m;

double ans=0;
double nm =n-m;
ans=nm*100;
double ans1=m*1900;
ans1+=ans;
double div=1;
for(double i =0;i<m;i++){
div=div/2;
}
double ans2,ans3;
ans2=ans1*div;
double div2=1-div;
double div1=div*div2;
ans3=ans2+(ans1*2)*div1;
double count=3;
while(1){
if(ans2==ans3)break;
ans2=ans3;
div1=div1*div2;
ans3=ans2+(ans1*count)*div1;
count++;
}
cout <<ans3;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pp prev_permutation
#define np next_permutation
#define pi acos(-1)
#define  all(v) (v).begin(),(v).end()
#define gcd(x,y)      __gcd(x,y);
#define lcm(x,y)      ( x / __gcd(x,y) ) * y
///---------------STL-------------------
#define b_s(v,n)    binary_search((v).begin(),(v).end(),n)  /// return bool
#define u_b(v,n)   upper_bound((v).begin(),(v).end(),n)    ///return pointer iterator
#define l_b(v,n)    lower_bound((v).begin(),(v).end(),n)   ///return pointer iterator
///---------------VECTOR-----------------
#define pb push_back
#define v_sort(v)  sort((v).begin(),(v).end())
#define rv_sort(v) sort((v).rbegin(),(v).rend())
#define  v_sum(v)  accumulate((v).begin(),(v).end(),0)
#define v_min(v)  *min_element(v.begin(),v.end())
#define v_max(v)  *max_element(v.begin(),v.end())
#define v_unique(v)     v.erase(unique(v.begin(),v.end()),v.end()); ///only for sorted vector.
///----------------STRING-----------------
#define get(s) getline(cin.ignore(),s)

using namespace std;

int main()
{
    ll tc=1,n,a,b,c,d,i,ans=0;
   // vector<pair<int,string>>v;
   vector<ll>v;
    string s;
  // cin>>tc;
    while(tc--)
    {
       cin>>a;
       cout<<(a+a*a+a*a*a)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3588
from collections import defaultdict
import queue

N = int(input())
to = defaultdict(list)
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))

ans = [-1] * N
ans[0] = 0
q = queue.Queue()
q.put(0)
while not q.empty():
    u = q.get()
    for v, w in to[u]:
        if ans[v] != -1:
            continue
        ans[v] = (ans[u] + w) % 2
        q.put(v)

for i in range(N):
    print(ans[i])


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

int main(){
  int N;
  cin >> N;
  int min_p = N;
  int ans=0;
  for(int ii=0; ii<N; ii++){
    int p;
    cin >> p;
    if(p<=min_p) ans++;
    min_p = min(min_p, p);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

void solve()
{
    int n = 1001;
    ll a, b;
    cin >> a >> b;
    
    ll f = 1, s = 1 + 2;
    for(int i = 3; i <= n; i++)
    {
        if(f - a >= 0 && f - a == s - b)
        {
            cout << f - a;
            return;
        }
        f = s;
        s += i;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>

typedef std::vector< std::string > vs;
std::string BigIntegerSum( std::string str1, std::string str2 );

std::string SubStr( std::string str, int x, int y ){
  return str.substr( x, y - x + 1 );
}

//cast functions
template<class T>
char ToChar( T t ){
  std::stringstream ss;
  char c;
  
  ss<<t;
  ss>>c;

  return c;
}
template<class T>
int ToInt( T t ){
  std::stringstream ss;
  int i;
  
  ss<<t;
  ss>>i;
  return i;
}

template<class T>
std::string ToStr( T t ){
  std::stringstream ss;
  std::string str;
  ss<<t;
  ss>>str;
  
  return str;
}

vs cut(std::string str){
  int res[2];
  vs s(3); 
  s[0] = SubStr( str, 0, ( res[0] = str.find( "+" ) ) -1  );
  s[1] = SubStr( str, res[0]+1, ( res[1] = str.find( "=" ) ) -1 );
  s[2] = SubStr( str, res[1]+1, str.size()-1 );
  
  return s;
}

std::string LeftCalc( vs s, int x ){
  int res[2] = { 0, 0 }, pos;
  
  int l = 2;
  while( l-- )
    for( int i = 0; i< s[l].size(); ++i )
      if( s[l][i] == 'X' ){
        if( i == 0 && s[l].size() != 1 && x == 0 )return "";
        s[l][i] = ToChar( x );
      }

  //std::cout<<res[0] <<"+"<< res[1]<<"="<<res[0]+res[1]<<std::endl;
  return BigIntegerSum( s[0], s[1] );
}
std::string RightCalc( std::string str, int x ){
  int res, pos = 0;
  while( ( res = str.find( "X", pos ) ) != std::string::npos ){
    if( res == 0 && str.size() != 1 && x == 0 )return "___";
    str[res] = ToChar( x );
    pos = res + 1;
  }
  //std::cout<<" "<<str<<std::endl;
  return str;
}

std::string BigIntegerSum( std::string str1, std::string str2 ){
  bool up = false;
  std::reverse( str1.begin(), str1.end() );
  std::reverse( str2.begin(), str2.end() );
  
  for( int i =0; i < std::max( str1.size(), str2.size() ) || up; ++i ){
    if( i >= str1.size() ) str1+='0';
    if( i >= str2.size() ) str2+='0';
    str1[i] += ToInt( str2[i] ) + up;
    up = false;
    if( str1[i] > '9' )str1[i]-=10, up = true;
  }
  std::reverse( str1.begin(), str1.end() );

  return str1;
}

int main(){
  std::string str;
  vs cStr;
  int i;
  
  while( std::cin >> str ){
    cStr = cut( str );
    for( i = 0; i < 10; ++i ){
      vs s( 2 );
      s[0] = cStr[0], s[1] = cStr[1];
      //std::cout<<"Debug:79, "<<i<<std::endl;
      if( LeftCalc( s, i ) == RightCalc( cStr[2], i ) ){
        break;
      }
    }
    if( i == 10 )std::cout<<"NA"<<std::endl;
    else std::cout<< i <<std::endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> d;
int main() {
  cin >> n;
  read_n(d, n);
  sort(begin(d), end(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

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

using namespace std;



int main(){
	int n,m; cin >> n >> m;
	vector<set<int>> edges(m);
	vector<bool> communicatable(m, true);
	int first;
	rep(i,n){
		vector<int> input;
		int K; cin >> K;
		rep(j,K){
			int temp; cin >> temp;
			input.push_back(temp - 1);
		}
		sort(input.begin(), input.end());
		first = input[0];
		rep(j, input.size()){
			communicatable[input[j]] = false;
			if(j == 0)
				continue;
			edges[first].insert(input[j]);
			edges[input[j]].insert(first);
		}
	}
	queue<int> q;
	q.push(first);
	communicatable[first] = true;
	while(!q.empty()){
		int nowelem = q.front();
		q.pop();
		for(auto itr = edges[nowelem].begin(); itr != edges[nowelem].end(); itr++){
			int src = *itr;
			if(!communicatable[src]){
				communicatable[src] = true;
				q.push(src);
			}
		}
	}
	bool ans = true;
	rep(i,m){
		if(!communicatable[i]){
			ans = false;
			break;
		}
	}
	if(ans)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000;

struct Comp {
	bool operator()(const pair<ll, ll> &a, const pair<ll, ll> &b) {
		if (a.first != b.first) {
			return a.first < b.first;
		}
		return a.second > b.second;
	}		
};

int n;

// 0 = don't take, 1 = take
int dp[N][2];


int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (int i = 0; i < n; i++) {
		ll x, l;
		cin >> x >> l;
		a[i].first = x + l;
		a[i].second = max(0ll, x - l);
	}
    sort(a.begin(), a.end(), Comp());
    
	dp[0][0] = 0;
	dp[0][1] = 1;
    for (int i = 1; i < n; i++) {
		// cout << a[i].first << " " << a[i].second << "\n";
		auto it = lower_bound(a.begin(), a.end(), make_pair(a[i].second, -1ll), Comp());
		if (it == a.begin()) {
			dp[i][1] = 1;
			// cout << "oof";
		} else {
			--it;
			int index = distance(a.begin(), it);
			// cout << "index: " << index << "\n";
			dp[i][1] = max(dp[index][1], dp[index][0]) + 1;
		}
		dp[i][0] = max(dp[i - 1][1], max(dp[i - 1][0], 0));
		// cout << dp[i][0] << " " << dp[i][1] << "\n";
	}
    
    cout << max(dp[n - 1][0], dp[n - 1][1]);
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n;
    String[] time;
    int[] in;
    int[] out;
    int atOsaki;
    int outOsaki;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n!=0){
		atOsaki = 0;
		outOsaki = 0;
		in = new int[n];
		out = new int[n];
		solve();
		System.out.println(atOsaki+outOsaki);
	    }
	}
    }

    void solve(){
	for(int i=0; i<n; i++){
	    time = sc.next().split(":");
	    out[i] = 
		Integer.parseInt(time[0])*3600 +
		Integer.parseInt(time[1])*60 +
		Integer.parseInt(time[2]);
	    time = sc.next().split(":");
	    in[i] =
		Integer.parseInt(time[0])*3600 +
		Integer.parseInt(time[1])*60 + 
		Integer.parseInt(time[2]);
	    //System.out.println("*"+out[i]+" "+in[i]);
	}
	Arrays.sort(out);
	Arrays.sort(in);

	int Idx = 0;
	int Odx = 0;
	while(Idx<in.length || Odx<out.length){
	    //System.out.println(outOsaki+" "+atOsaki);
	    if(Odx==out.length){
		arrive();
		Idx++;	 
	    }
	    else if(out[Odx] < in[Idx]){
		leave();
		Odx++;
	    }
	    else{
		arrive();
		Idx++;
	    }
	}
    }

    void leave(){
	if(atOsaki>0) atOsaki--;
	outOsaki++;
    }

    void arrive(){
	outOsaki--;
	atOsaki++;
    }
}
		

Measured memory_bytes: 97804
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int a[4];

int main(){
	for(int i = 0; i < 4; i++) a[i] = 0;
	string str;
	while(cin >> str){
		if(str[str.size()-1] == 'A') a[0]++;
		else if(str[str.size()-1] == 'O') a[3]++;
		else if(str[str.size()-1] == 'B' && str[str.size()-2] == 'A') a[2]++;
		else a[1]++;
	}
	for(int i = 0; i < 4; i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,k;
signed main(){
	cin>>n>>k;
	double ans=0.0;
	for(int i=1;i<=n;i++){
		int x=i;
		double cnt=1;
		while(1){
			if(x>=k)break;
			x*=2;
			cnt*=0.5;
		}
		ans+=cnt;
	}
	printf("%.12lf\n",ans/n);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int px[90001], py[90001];
int d[90001];

int main() {
  int H, W, D; cin >> H >> W >> D;
  rep(i, H) rep(j, W) {
    int A; cin >> A;
    py[A] = i, px[A] = j;
  }
  REP(i, D + 1, H * W + 1) {
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
  }
  int Q; cin >> Q;
  while(Q--) {
    int L, R; cin >> L >> R;
    cout << d[R] - d[L] << "\n";
  }
}


Measured memory_bytes: 2176
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		double min = Integer.MAX_VALUE;
		double max = Integer.MIN_VALUE;
		double n;
		while (sc.hasNext()) {
			n = sc.nextDouble();
			min = Math.min(min,n);
			max = Math.max(max,n);
		}
		out.println(Math.abs(max-min));
	}
}


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

int main() {
  int a,b,n;
  int first,second;
  cin >> n >> a >> b;
  
  first = a * n;
  second = b;
  
  if ( first < second ) {
  	cout << first << endl;
  } else {
  	cout << second << endl;
  }
}

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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif

bool sameChar(const string& s) {
    int n = sz(s);
    fo1(i, n-1) {
        if (s[i] != s[i+1])
            return false;
    }
    return true;
}

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

    string s; int k;
    cin >> s >> k;
    int n = sz(s);

    if (s[0] != s.end()[-1]) {
        int p = 1;
        s += '!';
        ll ans = 0;
        fo1(i, n) {
            if (s[i] != s[i+1]) {
                ans += p / 2;
                p = 1;
            } else p++;
        }
        cout << ans * ll(k) << endl;
    } else if (sameChar(s)) {
        cout << ll(n) * ll(k) / 2ll << endl;
    } else {
        int p = 1;
        ll ans = 0;
        int front = 1, back = 1;
        fo1(i, n-1) {
            if (s[i] == s[i+1]) front++;
            else break;
        }
        repb(i, n-1, 0) {
            if (s[i] == s[i-1]) back++;
            else break;
        }
        debugf("front = %d, back = %d\n", front, back);
        rep(i, front, n - back) {
            if (s[i] != s[i+1]) {
                ans += p / 2;
                p = 1;
            } else p++;
        }
        debugf("ans = %lld\n", ans);
        cout << ans * ll(k) + ll(front) / 2ll + ll(back) / 2ll + (ll(front + back) / 2ll) * ll(k-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
a,b,c=map(float,input().split())
S=b*math.sin(math.radians(c))*a*1/2
x=math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(c)))
L=a+b+x
h=b*math.sin(math.radians(c))
print(format(S, '.8f'))
print(format(L, '.8f'))
print(format(h, '.8f'))


Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long int ll;
ll A[SIZE],B[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	for(int i=0;i<n;i++) scanf("%lld",&B[i]);
	ll sa=0,sb=0;
	for(int i=0;i<n;i++) sa+=A[i],sb+=B[i];
	if(sa<sb)
	{
		puts("-1");
		return 0;
	}
	int cnt=0;
	ll d=0;
	vector <ll> vx;
	for(int i=0;i<n;i++)
	{
		if(A[i]<B[i])
		{
			d+=B[i]-A[i];
			cnt++;
		}
		else
		{
			vx.push_back(A[i]-B[i]);
		}
	}
	sort(vx.begin(),vx.end(),greater <ll>());
	for(int i=0;i<vx.size();i++)
	{
		if(d>0)
		{
			d-=vx[i];
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2936
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }
        int[] c = new int[n];
        for(int i=0; i<n; i++){
            c[i] = stdIn.nextInt();
        }

        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);

        long counter = 0;
        for(int i=0; i<n; i++){
            int lower = lowerBound(a, b[i]);
            int upper = upperBound(c, b[i]);
            counter += (long) lower * (n - upper);
        }

        System.out.println(counter);
    }

	private static int lowerBound(int[] a, int x) {
		int l = -1, r = a.length - 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (x <= a[m]) r = m;
			else l = m;
		}
		if (r == a.length - 1 && a[r] < x) r++;
		return r;
	}

	private static int upperBound(int[] a, int x) {
		int l = 0, r = a.length;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (a[m] <= x) l = m;
			else r = m;
		}

		if (l == 0 && a[l] > x) l--;
		return l + 1;
	}
}


Measured memory_bytes: 92892
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
using namespace std;



int main(int argc, char *args[]) {
	string s[100], t[100];
	int N, M;
	int max_counter = -100;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> s[i];
	cin >> M;
	for (int i = 0; i < M; i++) cin >> t[i];

	for (int i = 0; i < N; i++) {
		int counter = 0;
		string u = s[i];
		for (int j = 0; j < N; j++) if (u == s[j]) counter++;
		for (int k = 0; k < M; k++) if (u == t[k]) counter--;
		if (max_counter < counter) max_counter = counter;
	}
	if (max_counter < 0) {
		cout << 0 << endl;
	}
	else {
		cout << max_counter << endl;
	}
}


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

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

	ll c = 0;
	for (ll i = 1; i <= N; i++) {
		c += i * (N - i + 1);
	}

	for (ll i = 0; i < N - 1; i++) {
		ll u, v;
		cin >> u >> v;
		if(v < u) swap(u, v);
		c -= u * (N - v + 1);
	}

	cout << c << endl;
	return(0);
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
using namespace std;
#define mop2 998244353

struct robot{
    ll s,t;
};

bool asc( const robot& left, const robot& right ) {
    return left.t == right.t ? left.s < right.s : left.t < right.t;
}

int main() {
    

    ll n;
    cin >> n;
    vector <robot> v;
    for(ll i=0;i<n;i++){
        ll x,l;
        cin >> x >> l;
        robot tmp;
        tmp.s = x - l;
        tmp.t = x + l;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end(), asc);
    ll nowt = v[0].s;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(nowt <= v[i].s){
            nowt = v[i].t;
            ans++;
        }
    }
    cout << ans << endl;




}

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

using namespace std;
typedef long long ll;

int main(void) {
    ll D, G;
    cin >> D >> G;

    vector<pair<ll, ll>> p_c(D);
    for(int i = 0; i < D; i++) {
        cin >> p_c[i].first >> p_c[i].second;
    }

    vector<ll> ans_arr;

    for(int bit = 0; bit < (1 << D); bit++) {
        ll question_num = 0;
        ll total_point = 0;
        vector<ll> rest_index;

        for(ll i = 0; i < D; i++) {
            if(bit & (1 << i)) {
                pair<ll, ll> _p_c = p_c[i];
                total_point += 100 * (i + 1) * _p_c.first + _p_c.second;
                question_num += _p_c.first;
            } else {
                rest_index.push_back(i);
            }
        }

        if(total_point >= G) {
            ans_arr.push_back(question_num);
        } else {
            sort(rest_index.begin(), rest_index.end(), greater<ll>());
            for(ll i : rest_index) {
                int current_point = 100 * (i + 1);

                // 切り上げ
                int need_num = (G - total_point + current_point - 1) / current_point;

                pair<ll, ll> _p_c = p_c[i];
                if(need_num <= _p_c.first) {
                    ans_arr.push_back(question_num + need_num);
                    break;
                }

                ll solved_num = _p_c.first - 1;
                question_num += solved_num;
                total_point += current_point * solved_num;
            }
        }
    }

    sort(ans_arr.begin(), ans_arr.end());

    cout << ans_arr[0] << endl;
}

Measured memory_bytes: 256
/*
  AOJ 2119
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int c_win[20];
int M,N;

void turn()
{
  int i,c_win2[20];
  memset(c_win2,0,sizeof(c_win));
  
  for(i=N-1;i>=1;i--)
    {
      
      if((c_win[i] % 2)==1)
	c_win2[i]=1;
      else
	c_win2[i]=0;
      
      if(c_win[i] > 1)
	{
	  c_win2[i+1]+=c_win[i]/2;
	  c_win2[0  ]+=c_win[i]/2;
	}
    }
  c_win2[1] += c_win[0]/2;
  c_win2[0] += (c_win[0]-c_win[0]/2);
  memcpy(c_win,c_win2,sizeof(c_win));
}
main()
{
  int cnt,cas;

  cas=1;
  while(scanf("%d %d",&N,&M) && (N||M))
    {
      memset(c_win,0,sizeof(c_win));
      c_win[0]=N;
      cnt=0;
      while(c_win[M]==0)
	{
	  turn();
	  cnt++;
	}
      printf("Case %d: %d\n",cas,cnt);
      cas++;
    }
  return(0);
}

Measured memory_bytes: 600
// insertion sort alg.
// input some number elements, output process insertion sort
#include<iostream>
int main(){
  int j, N, key;
  std::cin >> N;
  int A[N];
  for(int i=0; i<N; i++)
  std::cin >> A[i];
  for(int i=0; i<N; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
    for(int k=0; k<N; k++){
      std::cout << A[k];
      if(k+1 < N) std::cout << " ";
    }
    std::cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

const ll MAX = 1000000000;
const int mod = 1e9 + 7;

// https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

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

// return 2^n (mod n)
mint mintpow(int n) {
  if (n == 0) return 1;
  mint x = mintpow(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}


int main() {
  int n, a, b;
  cin >> n >> a >> b;

  mint ans = mintpow(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
}


Measured memory_bytes: 256
class Array
  def medmed
    if size.odd?
      self[size/2]
    else
      self[size/2] + self[size/2-1]
    end
  end
end

n = gets.to_s.to_i
a = []
b = []
n.times{ |i| a[i], b[i] = gets.to_s.split.map{|e| e.to_i } }

a.sort!
b.sort!

ans = [0, b.medmed - a.medmed + 1].max

puts ans

Measured memory_bytes: 19992
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())

remain = []
must_change = []
for n in range(N):
    if (A^B)&(1<<n):
        must_change.append(n)
    else:
        remain.append(n)

ans = []
def dfs(ind, bit, end):
    if ind == 0:
        n = must_change[0]
        bit = dfs(ind+1, bit, False)
        bit = dfs(ind+1, bit^(1<<n), True)
    elif ind < len(must_change):
        n1, n2 = must_change[ind], must_change[ind+1]
        if end:
            bit = dfs(ind+2, bit, False)
            bit = dfs(ind+2, bit^(1<<n2), False)
            bit = dfs(ind+2, bit^(1<<n1), False)
            bit = dfs(ind+2, bit^(1<<n2), True)
        else:
            bit = dfs(ind+2, bit, False)
            bit = dfs(ind+2, bit^(1<<n1), False)
            bit = dfs(ind+2, bit^(1<<n2), False)
            bit = dfs(ind+2, bit^(1<<n1), False)
    elif ind < N:
        n = remain[ind-len(must_change)]
        bit = dfs(ind+1, bit, end)
        bit = dfs(ind+1, bit^(1<<n), end)
    else:
        ans.append(bit)
    
    return bit


if len(must_change)%2 == 0:
    print("NO")
else:
    dfs(0, A, False)
    print("YES")
    print(*ans)

Measured memory_bytes: 11360
def f(n,x):
  #0以上n以下の整数のうち、xで割り切れるものの個数
  if n>=0:
    return n//x + 1
  elif n==-1:
    return 0
a,b,x = [int(i) for i in input().split()]
print(f(b,x)-f(a-1,x))

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

int main()
{	
	string S;
	cin >> S;
	if(S =="Sunny")cout << "Cloudy";
	else if(S =="Cloudy")cout << "Rainy";
	else cout << "Sunny";
}

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

string a[105];

int main(){
    int h, w;
    cin >> h >> w;
    for(int i=0;i<h;++i)
        cin >> a[i];

    map<char, int> mp;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            mp[a[i][j]]++;
        }
    }

    for(char c='a';c<='z';++c){
        while(mp[c] >= 4)mp[c] -= 4;
    }
    if((h%2 != 0) || (w%2 != 0)){
        int limit;
        if((h%2 != 0) && (w%2 != 0))limit = w+h-2;
        else if(h%2 != 0)limit = w;
        else if(w%2 != 0)limit = h;
        else limit = 0;
        int sum = 0;
        for(char c='a';c<='z';++c){
            while(mp[c] >= 2 && sum <= limit){
                mp[c] -= 2;
                sum += 2;
            }
        }
    }
    if((h%2 != 0) && (w%2 != 0)){
        for(char c='a';c<='z';++c){
            if(mp[c] > 0){
                mp[c]--;
                break;
            }
        }
    }

    bool flag = true;
    for(char c='a';c<='z';++c){
        if(mp[c] > 0){
            flag = false;
            break;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  mint ans = 1;
  vector<int> v(3, 0);
  rep(i, n){
    int sc = 0, f = -1;
    rep(j, 3){
      if(v.at(j) == a.at(i)){
        sc++;
        f = j;
      }
    }
    // cerr << sc << " " << f << endl;
    ans *= sc;
    if(sc != 0) v.at(f)++;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3788
io = STDIN
h,w,k=io.gets.split.map(&:to_i)
board=h.times.map{io.gets.chomp}
ans=0
[0,1].repeated_permutation(h+w) do |mask|
  cnt=0
  mask[0,h].each_with_index do |mh,i|
    mask[h,w].each_with_index do |mw,j|
      cnt+=1 if board[i][j]=="#" && mh==0 && mw==0 
    end
  end
  (ans+=1) if cnt==k
end
puts ans


Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
const int up=3;
int a,b,c;
int p1[N][up][up][up],p2[N][up][up][up],p3[N][up][up][up];
char opt[N][up][up][up];
bool dp[N][up][up][up];
void updatedp(int x,int a,int b,int c,int aa,int bb,int cc,char optt)
{
    dp[x][a][b][c]=true;
    p1[x][a][b][c]=aa;
    p2[x][a][b][c]=bb;
    p3[x][a][b][c]=cc;
    opt[x][a][b][c]=optt;
}
void AB(int x)
{
    for(int a=0;a<up;a++)
        for(int b=0;b<up;b++)
        for(int c=0;c<up;c++)
        if(dp[x-1][a][b][c])
    {
        if(a-1>=0)
            updatedp(x,a-1,min(b+1,up-1),c,a,b,c,'B');
        if(b-1>=0)
            updatedp(x,min(a+1,up-1),b-1,c,a,b,c,'A');
    }
}
void AC(int x)
{
    for(int a=0;a<up;a++)
        for(int b=0;b<up;b++)
        for(int c=0;c<up;c++)
        if(dp[x-1][a][b][c])
    {
        if(a-1>=0)
            updatedp(x,a-1,b,min(c+1,up-1),a,b,c,'C');
        if(c-1>=0)
            updatedp(x,min(a+1,up-1),b,c-1,a,b,c,'A');
    }
}
void BC(int x)
{
    for(int a=0;a<up;a++)
        for(int b=0;b<up;b++)
        for(int c=0;c<up;c++)
        if(dp[x-1][a][b][c])
    {
        if(b-1>=0)
            updatedp(x,a,b-1,min(c+1,up-1),a,b,c,'C');
        if(c-1>=0)
            updatedp(x,a,min(b+1,up-1),c-1,a,b,c,'B');
    }
}
void getans(int x,int a,int b,int c)
{
    if(x==0) return;
    getans(x-1,p1[x][a][b][c],p2[x][a][b][c],p3[x][a][b][c]);
    printf("%c\n",opt[x][a][b][c]);
}
int main()
{
    int n;scanf("%d",&n);
    scanf("%d%d%d",&a,&b,&c);
    a=min(a,up-1);b=min(b,up-1);c=min(c,up-1);
    dp[0][a][b][c]=true;
    for(int i=1;i<=n;i++)
    {
        string opt;
        cin>>opt;
        if(opt=="AB") AB(i);
        else if(opt=="AC") AC(i);
        else BC(i);
    }
    for(int i=0;i<up;i++)
        for(int j=0;j<up;j++)
        for(int k=0;k<up;k++)
        if(dp[n][i][j][k])
    {
        printf("Yes\n");
        getans(n,i,j,k);return 0;
    }
    printf("No\n");
}


Measured memory_bytes: 45392
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];

	sort(A.begin(), A.end());

	bool f = false;
	for (ll i = 0; i < N-1; ++i)
	{
		if (A[i] == A[i + 1])
		{
			f = true;
			break;
		}
	}

	if (f)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}

	//system("pause");
}


Measured memory_bytes: 1792
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2149

#include <iostream>
using namespace std;

int main() {
  int N, A, B, C, X;
  int Y[110];
  while (scanf("%d%d%d%d%d", &N, &A, &B, &C, &X) != EOF && N) {
    int x = X;
    int count = -1;
    for (int i=0; i<N; i++) {
      scanf("%d", &Y[i]);
    }
    for (int i=0; i<N; i++) {
      do {
	count == -1 ? x = X : x = (A * x + B) % C;
	count++;
      } while (x != Y[i] && count <= 10000);
      if (count > 10000) {
	count = -1;
	break;
      }
    }
    printf("%d\n", count);
  }
}

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

int main(){
  long long int n,wm; cin >> n >> wm;
  vector<vector<long long int>> a(4);
  long long int w; cin >> w;
  long long int v; cin >> v;
  a[0].push_back(v);
  for(int i=1;i<n;i++){
    long long int ww; cin >> ww >> v;
  	a[ww-w].push_back(v);
  }
  for(int i=0;i<4;i++) sort(a[i].begin(),a[i].end(), greater<int>());
  long long int ans = 0;
  for(int i=0;i<=a[0].size();i++)
    for(int j=0;j<=a[1].size();j++)
      for(int k=0;k<=a[2].size();k++)
        for(int l=0;l<=a[3].size();l++){
          if(i*w + j*(w+1) + k*(w+2) + l*(w+3) <= wm){
          long long int sum=0;
          for(int m=0;m<i;m++) sum+=a[0][m];
          for(int m=0;m<j;m++) sum+=a[1][m];
          for(int m=0;m<k;m++) sum+=a[2][m];
          for(int m=0;m<l;m++) sum+=a[3][m];
          ans = max(ans,sum);
          }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S=input()
S1=int(S.split("/")[0])
S2=int(S.split("/")[1])
S3=int(S.split("/")[2])

if S1 < 2019:
    print("Heisei")
elif S1 > 2019:
    print("TBD")
elif S2 < 4:
    print("Heisei")
elif S2 > 4:
    print("TBD")
elif S3 <= 30:
    print("Heisei")
else:
    print("TBD")





Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    private static int count = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        scanner.nextLine();
        char[][] map = new char[n][m];
        boolean[][] visited = new boolean[n][m];
        for (int i = 0; i < n; i++) {
            String tmp = scanner.nextLine();
            map[i] = tmp.toCharArray();
        }
        int mod = (int)(1e9 + 7);
        int[][] dp = new int[n][m];
        dp[0][0]=1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
               int[][] directions = new int[][]{{1,0},{0,1}};
                for (int[] direction : directions) {
                    int x= i + direction[0];
                    int y= j + direction[1];
                    if(x<n&&y<m&&map[x][y]=='.') {
                        dp[x][y] += dp[i][j];
                        if(dp[x][y] > mod) {
                            dp[x][y]-=mod;
                        }
                    }
                }
            }
        }
        System.out.println(dp[n-1][m-1]);
    }




}

Measured memory_bytes: 64752
#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
#define modp 998244353
int n;
int a[Maxn],now[Maxn];
pair<int,int> que[Maxn];
int cnt=0;
int val[Maxn];
void solve(int len)
{
    ++cnt;
    que[cnt].first=len;
    que[cnt].second=0;
    for (int i=1;i<=len;i++)
        que[cnt].second=(2LL*que[cnt].second+a[i])%modp;
    bool check=true;
    for (int i=1;i<=len;i++)
        now[i]=a[i];
    for (int i=len+1;i<=n;i++)
        now[i]=now[i-len]^1;
    for (int i=1;i<=n;i++)
        if (a[i]!=now[i])
        {
            if (now[i]>a[i]) check=false;
            break;
        }
    if (check) que[cnt].second=(que[cnt].second+1)%modp;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        char ch=getchar();
        while (ch!='0'&&ch!='1') ch=getchar();
        a[i]=ch-'0';
    }
    for (int i=1;i<=n;i++)
        if ((n%i==0)&&((n/i)%2==1)) solve(i);
    sort(que+1,que+cnt+1);
    int ans=0;
    for (int i=cnt;i;i--)
    {
        int tmp=(que[i].first-val[i]+modp)%modp;
        ans=(ans+1LL*tmp*que[i].second)%modp;
        for (int j=1;j<=cnt;j++)
            if (que[i].first%que[j].first==0) val[j]=(val[j]+tmp)%modp;
    }
    ans=(2LL*ans)%modp;
    printf("%d\n",ans);
    return 0;
}

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

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

  if (s <= 1e9) {
    printf("%lli %lli %lli %lli %lli %lli\n", s, 0ll, 0ll, 1, 0ll, 0ll);
    return 0;
  }

  long long a = 1e9;
  for (int i=1; i<=1e9; i++) {
    if (a * i - s >= 0) {
      printf("%lli %lli %lli %lli %lli %lli\n", a, a * i - s, 1, i, 0ll, 0ll);
      return 0;
    }
  }
}

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

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x-k+1; i <= x+k-1; i++) {
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256