akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;

int main(){
  
  while(1){
    
    int memo[20][20]={0};
    int a,b;
    int n;
    int nx,ny;
    
    for(int i=0;i<20;i++){
      for(int j=0;j<20;j++){
	if(i!=0 && j!=0){
	  memo[i][j]=1;
	}
      }
    }
    
    scanf("%d %d",&a,&b);
    if(a==0 && b==0) break;
  
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      scanf("%d %d",&nx,&ny);
      memo[ny][nx]=0;
    }
    
    memo[1][0]=1;
    
    
    for(int i=1;i<=b;i++){
      for(int j=1;j<=a;j++){
	if(memo[i][j]==0);
	else memo[i][j]=memo[i-1][j]+memo[i][j-1];
      }
    }
    
    printf("%d\n",memo[b][a]);
    
    /*
    for(int i=0;i<=b;i++){
      for(int j=0;j<=a;j++){
	printf("%d ",memo[i][j]);
      }
      printf("\n");
    } 
    */

  }
  
  return 0;
}

Measured memory_bytes: 1188
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};

fn main() {
    input!{
      n: usize,
      s: chars,
      q: usize,
      ks: [usize; q],
    }

    let solve = |k| {
        let mut ans = 0usize;
        let mut d = 0usize;
        let mut m = 0usize;
        let mut dm = 0usize;

        for i in 0..n {
            if s[i] == 'D' {
                d += 1
            }
            if s[i] == 'M' {
                m += 1;
                dm += d;
            }
            if i >= k {
                if s[i-k] == 'D' {
                    d -= 1;
                    dm -= m;
                }
                if s[i-k] == 'M' {
                    m -= 1;
                }
            }

            if s[i] == 'C' {
                ans += dm;
            }
        }
        ans
    };
    for k in ks {
        println!("{}", solve(k));
    }
}


Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),sum(n+1);
	for(int i =0;i<n;i++)
	{
		cin >> a[i];
	}

	for(int i = 0;i<n;i++)
	{
		sum[i+1]= sum[i]+a[i];
	}
	sort(sum.begin(),sum.end());
	ll l = 1;
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		if(sum[i]==sum[i+1])
		{
			l++;
		}
		else
		{
			ans+=l*(l-1)/2;
			l = 1;
		}
	}
	ans += l*(l-1)/2;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  c=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    if(i<0){
      c++;
    }
    if(i>0){
      c+=2;
    }
    else if(i==0){
      c=0;
      break;
    }
  }
  if(c%2==1){
    cout<<"Negative"<<endl;
  }
  else if(c==0){
    cout<<"Zero"<<endl;
  }
  else{
    cout<<"Positive"<<endl;
  }
}

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

int minX[26], maxX[26], minY[26], maxY[26];
bool has[26];

int main() {
	int t, H, W;
	cin >> t;
	while (t--) {
		for (int i=0; i<26; ++i) {
			minX[i] = minY[i] = 51;
			maxX[i] = maxY[i] = -1;
			has[i] = false;
		}
		cin >> H >> W;
		vector<string> img(H, "");
		for (int i=0; i<H; ++i) {
			cin >> img[i];
			for (int j=0; j<W; ++j) {
				char c = img[i][j];
				if (c != '.') {
					minX[c - 'A'] = min(minX[c - 'A'], j);
					maxX[c - 'A'] = max(maxX[c - 'A'], j);
					minY[c - 'A'] = min(minY[c - 'A'], i);
					maxY[c - 'A'] = max(maxY[c - 'A'], i);
					has[c - 'A'] = true;
				}
			}
		}
		int k = 0;
		while (k <= 26) {
			if (has[k]) {
				bool ok = true;
				for (int i=minY[k]; i<=maxY[k] && ok; ++i) {
					for (int j=minX[k]; j<=maxX[k] && ok; ++j) {
						if (img[i][j] - 'A' != k && img[i][j] != '#') {
							ok = false;
						}
					}
				}
				if (ok) {
					for (int i=minY[k]; i<=maxY[k]; ++i) {
						for (int j=minX[k]; j<=maxX[k]; ++j) {
							img[i][j] = '#';
						}
					}
					has[k] = false;
					k = 0;
					continue;
				}
			}
			++ k;
		}
		bool safe = true;
		for (int i=0; i<26; ++i) {
			if (has[i]) {
				safe = false;
				break;
			}
		}
		cout << (safe ? "SAFE" : "SUSPICIOUS") << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static readonly long MOD = 1000000000 + 7;
        static void Main(string[] args)
        {
            var nk = ReadLine().Split(' ').Select(long.Parse).ToList();
            long n = nk[0];
            long k = nk[1];
            var a = ReadLine().Split(' ').Select(long.Parse).ToList();

            long cnt_internal = 0;
            long cnt_outer = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (a[i] > a[j])
                    {
                        cnt_internal++;
                    }
                }

                for (int l = 0; l < n; l++)
                {
                    if (a[i] > a[l])
                    {
                        cnt_outer++;
                    }
                }
            }

            long ans = cnt_internal * k % MOD;
            long cmb = ((k * (k - 1)) / 2) % MOD;
            ans = (ans + (cnt_outer * cmb) % MOD) % MOD;

            WriteLine(ans);
        }
    }
}



Measured memory_bytes: 11364
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d[6];
    for (int i = 0; i < 6; i++) {
        cin >> d[i];
    }
    int q, tp, ft;
    cin >> q;
    while (0 < q) {
        cin >> tp >> ft;
        int i, j;
        for (i = 0; i < 6; i++)
            if (d[i] == tp)
                break;
        for (j = 0; j < 6; j++)
            if (d[j] == ft)
                break;
        
        if (i < 3 && j < 3)
            if (i < j)
                if (j-i==1)
                    cout << d[3-i-j] << "\n";
                else
                    cout << d[5-(3-i-j)] << "\n";
            else
                if (i-j==1)
                    cout << d[5-(3-i-j)] << "\n";
                else
                    cout << d[3-i-j] << "\n";
        else if (2 < i && 2 < j)
            if (i < j)
                if (j-i==1)
                    cout << d[12-i-j] << "\n";
                else
                    cout << d[5-(12-i-j)] << "\n";
            else
                if (i-j==1)
                    cout << d[5-(12-i-j)] << "\n";
                else
                    cout << d[12-i-j] << "\n";
        else if (2 < j) {
            int k = 5-j;
            if (i < k)
                if (k-i==1)
                    cout << d[5-(3-i-k)] << "\n";
                else
                    cout << d[3-i-k] << "\n";
            else
                if (i-k==1)
                    cout << d[3-i-k] << "\n";
                else
                    cout << d[5-(3-i-k)] << "\n";
        }
        else if (2 < i) {
            int k = 5-i;
            if (k < j)
                if (j-k==1)
                    cout << d[5-(3-j-k)] << "\n";
                else
                    cout << d[3-j-k] << "\n";
            else
                if (k-j==1)
                    cout << d[3-j-k] << "\n";
                else
                    cout << d[5-(3-j-k)] << "\n";
        }
        q--;
    }
}

Measured memory_bytes: 3200
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val result = array(0).toDouble * array(1).toDouble / 2d
  val several =
    if(array(0) == array(2) * 2 && array(1) == array(3) * 2) {
      1
    } else {
      0
    }
  println(result + " " + several)
}

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

using namespace std;

int main() {
		int N;
		cin >> N;
		string ans = "";
		while (N != 0) {
				if (N % 2 != 0) {
						N--;
						ans = "1" + ans;
				} else ans = "0" + ans;
				N /= -2;
		}

		if (ans == "") ans = "0";

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


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n, s = nm()
a = nl()
mod = 998244353
dp = [0]*(s+1)
dp[0] = 1
for i in range(n):
    v = a[i]
    for j in range(s, -1, -1):
        if j >= v:
            dp[j] = (dp[j] * 2 + dp[j-v]) % mod
        else:
            dp[j] = dp[j] * 2 % mod
print(dp[s])


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

void main_()
{
    int N;
    vector<pair<int, int>> xys;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        xys.emplace_back(x, y);
    }

    auto dist = [](auto&& a, auto&& b) {
        auto x = a.first - b.first;
        auto y = a.second - b.second;
        return sqrt(x * x + y * y);
    };

    double sum = 0;
    for (auto&& t1 : xys) {
        for (auto&& t2 : xys) {
            if (t1 < t2) {
                sum += dist(t1, t2);
            }
        }
    }

    // 2つの特定の町間の経路数:2(N-1)! / 全経路数:N! = 2/N
    auto ans = sum * 2 / N;
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    n--;
    ll t = 26;
    ll m = 1;
    while(t <= n){
    	n -= t;
    	t *= 26;
    	m++;
    }
    vector<ll> v;
    for(int i=0;i<m;i++){
    	v.pb(n%26);
    	n /= 26;
    }
    reverse(be(v));
    string s = "";
    for(auto& i : v){
    	s += char('a' + i);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3640
# Union-Find木
# 木構造を用いて、グループ分けを行うデータ構造
# 同じ木に属している場合、同じグループであるということになる
# 同じ木に属しているかどうかは、根となるノードが同じであるかどうかで判定をする
# 同じグループに属しているかどうかを、根ノードの値を参照するだけなのでO(1)で求められる
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def tmp(n)
    arr = Array.new(n, 0)
    @parent.each do |num|
      arr[num] += 1
    end
    return arr.max
  end

  # node_xとnode_yを連結し、同じグループにする
  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  # node_xの親ノードの番号を取得する
  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  # node_x, node_yが連結しているか確かめる
  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
# 与えられた頂点数の大きさで宣言を行う
union = UnionFind.new(n + 1)

# ノード読み込み
a, b = m.times.map { gets.split.map(&:to_i) }.transpose
#p a
#p b
(m).times do |i|
  # 結合処理
  #  puts "#{i} #{a[i]} #{b[i]}"
  union.unite(a[i], b[i])
end

cnt = 0
(m).times do |i|
  # 判定処理
  if union.same_parent?(a[i], b[i])
    cnt += 1
  end
end
p union.tmp(n + 1)


Measured memory_bytes: 36216
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

size_t[][26] D;

void main()
{
    auto s = readln.chomp.to!(char[]);
    auto t = readln.chomp.to!(char[]);

    foreach (i, c; s) {
        D[c - 'a'] ~= i;
    }

    ulong cnt;
    size_t p;
    bool first = true;
    foreach (c; t) {
        auto d = D[c - 'a'];

        if (d.empty) {
            writeln(-1);
            return;
        }

        if (first) {
            first = false;
            if (d[0] == 0) {
                continue;
            }
        }

        if (d[$-1] <= p) {
            p = d[0];
            ++cnt;
            continue;
        } else if (d[0] > p) {
            p = d[0];
            continue;
        }

        size_t l, r = d.length-1;
        while (l+1 < r) {
            auto m = (l+r)/2;
            if (d[m] <= p) {
                l = m;
            } else {
                r = m;
            }
        }
        p = d[r];
    }
    writeln(s.length * cnt + p + 1);
}

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


int main () {
  int N, K;
  string S;

  cin >> N >> K >> S;
  S.at(K - 1) = (char)(S.at(K - 1) + 32);
  cout << S << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[211][211];
int D[211];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%s", S[i]);

    int ans = -1;

    VI ord; ord.reserve(N);
    REP (r, N) {
	memset(D, -1, sizeof D);
	ord.clear();
	ord.push_back(r);
	D[r] = 0;
	
	bool ok = true;
	for (int i=0; ok && i<(int)ord.size(); i++) {
	    int v = ord[i];
	    REP (j, N) if (S[v][j] == '1') {
		if (D[j] == -1) {
		    D[j] = D[v] + 1;
		    ord.push_back(j);
		} else if (abs(D[v] - D[j]) != 1) {
		    ok = false;
		    break;
		}
	    }
	}

	if (ok) {
	    if ((int)ord.size() != N) ok = false;
	}
	if (ok) {
	    if (*min_element(D, D+N) == -1) ok = false;
	}
	if (ok) {
	    REP (i, N) REP (j, N) if (S[i][j] == '1') {
		if (abs(D[i] - D[j]) != 1) ok = false;
	    }
	}

	if (ok) {
	    amax(ans, *max_element(D, D+N) + 1);
	}
    }

    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;


int p,q,a,n;
int ans;
double in;

inline bool equal(double d1,double d2,double eps=1e-8) {
    return ((d1-eps)<d2 && (d2<(d1+eps)));
}

void dfs(int cnt,int den, int mul, double r) {
    if(cnt==n+1) {
        return;
    }
    if(in<r-1e-8) return;

    if(equal(in,r)) {
        //cout<<"count"<<endl;
        ans++;
    }
    // cout<<cnt<<","<<den<<","<<r<<endl;

    for(int i=den;i*mul<=a;i++) {
        //cout<<cnt<<","<<den<<" : "<<r<<" + "<<Ratio(1,i)<<" = "<<r+Ratio(1,i)<<endl;
        dfs(cnt+1,i,mul*i, r+1.0/i );
    }

}


void solve() {
    ans=0;
    in=1.0*p/q;
    dfs(0,1,1, 0);
    cout<<ans<<endl;

}

int main() {
    while(cin>>p>>q>>a>>n) {
        if(!p) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

int main()
{
    string str;
    string t;
    cin >> str >> t;

    bool flg = false;
    string res = str;
    for (int i = str.size() - 1; i >= t.size() - 1; i--) {
	int tmp_i = i;
	res = str;
	for (int j = t.size() - 1; j >= 0; j--) {
	    if (str[tmp_i] == t[j] || str[tmp_i] == '?') {
		res[tmp_i] = t[j];
		tmp_i--;
	    } else {
		break;
	    }
	    if (j == 0)
		flg = true;
	}
	if (flg)
	    break;
    }

    if (flg) {
	rep (i, res.size()) {
	    if (res[i] == '?')
		res[i] = 'a';
	}
	cout << res << endl;
    } else {
	cout << "UNRESTORABLE" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;

char in[2][4001];

void calc(int m){
    int n,a,b,ans=0,x,y,sx,sy;
    vector<pair<int,int> > M,N;
    vector<pair<int,int> >:: iterator it;
    
    
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        
        M.push_back(make_pair(a,b));
    }
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        
        N.push_back(make_pair(a,b));
    }
    
    sort(N.begin(),N.end());
    
    for(int i=0;i<n;i++){
        x=N[i].first;
        y=N[i].second;
        for(int i=1;;i++){
            if(i==m){
                printf("%d %d\n",x-M[0].first,y-M[0].second);
                return;
            }
            
            sx = M[i].first-M[0].first+x;
            sy = M[i].second-M[0].second+y;
            

            it = lower_bound(N.begin(),N.end(),make_pair(sx,sy));
            
            if(*it!=make_pair(sx,sy)) break;
        }
    }
    
    printf("%d\n",ans);
    
    return;
}

int main(){
    int m,n;
    
    while(1){
        scanf("%d",&m);
        
        if(m==0) break;
        
        calc(m);
    }
    
    return 0;
}

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

using namespace std;

long double dp[310][310][310];
int n, c[3];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x; 
		cin >> x;
		c[x - 1]++;
	}
	
	for (int k = 0; k <= c[2]; k++) {
		for (int j = 0; j <= n; j++) {
			for (int i = 0; i <= n; i++) {
				int tc = i + j + k;
				if (tc == 0 || tc > n) continue;
				dp[i][j][k] = 1;
				if (i) dp[i][j][k] += dp[i - 1][j][k] * i / n;
				if (j) dp[i][j][k] += dp[i + 1][j - 1][k] * j / n;
				if (k) dp[i][j][k] += dp[i][j + 1][k - 1] * k / n;
				dp[i][j][k] *= (long double) n / tc;
			}
		}
	}
	
	cout << fixed << setprecision(16) << dp[c[0]][c[1]][c[2]] << '\n';
}



Measured memory_bytes: 450688
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	int sum=0;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		sum+=x;	
	}
	if(sum>=n)
		cout<<"Yes";
	else
		cout<<"No";


}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#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>

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

int main() {
    
    ll n;
    cin >> n;
    if(n%2 ==0) cout << n/2 - 1 << endl;
    else cout << n/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H, W; cin >> H >> W;
  vector<string> s(H);
  rep(i, H) cin >> s[i];
  
  rep(i, H) rep(j, W) {
    if(s[i][j] == '#') {
      bool t = false;
      if((i>0&&s[i-1][j]=='#') || (j>0&&s[i][j-1]=='#') || (i<H-1&&s[i+1][j]=='#') || (j<W-1&&s[i][j+1]=='#'))
        t = true;
      if(!t) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int  N;
  cin >> N;
  vector<long long> A(N);
  long long sum = 1;
  for (int i = 0; i<N;i++){
    cin >> A.at(i);
    if(A.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i<N;i++){
    if(A.at(i) <= 1000000000000000000/sum){
        sum = sum*A.at(i);
  	}else { 
      cout << -1 << endl;
      return 0;
    }
 
  }
  cout << sum << endl;
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  vector<int> P(N);
  for(int i=0;i<N;i++) cin>>S[i]>>P[i];

  vector<pair<pair<string,int>,int>> v;
  for(int i=0;i<N;i++) v.push_back(mkp(mkp(S[i],-P[i]),i));

  sort(v.begin(),v.end());
  for(int i=0;i<N;i++) cout<<v[i].second+1<<endl;

  return 0;
}


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

A=[0]*N

A[0]=B[0]
for i in range(1,N-1):
  #print(B[i-1],B[i])
  A[i]=min(B[i-1],B[i])
A[N-1]=B[N-2]
  
#print(A)
print(sum(A))

Measured memory_bytes: 3064
#include <stdio.h>

double lim[10] = {48.00, 51.00, 54.00, 57.00, 60.00, 
                  64.00, 69.00, 75.00, 81.00, 91.00};

char rank[11][16] = {"light fly", "fly", "bantam", "feather",
                     "light", "light welter", "welter", "light middle",
                     "middle", "light heavy", "heavy"};

int main(void){
    double weight;
    while( scanf("%lf", &weight) != EOF ){
        int c = 0;
        while( weight > lim[c] && c < 10) c++;
        printf("%s\n", rank[c]);
    }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int row_sum[2001][2001], row_sum_r[2001][2001], col_sum[2001][2001], col_sum_r[2001][2001];
char m[2001][2001];

int main()
{
    int h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> m[i][j];

    rep(i, h)
    {
        int sum = 0;
        rep(j, w)
        {
            m[i][j] == '#' ? sum = 0 : sum++;
            row_sum[i][j] = sum;
        }
    }

    repr(i, h)
    {
        int sum = 0;
        repr(j, w - 1)
        {
            m[i][j] == '#' ? sum = 0 : sum++;
            row_sum_r[i][j] = sum;
        }
    }

    rep(j, w)
    {
        int sum = 0;
        rep(i, h)
        {

            m[i][j] == '#' ? sum = 0 : sum++;
            col_sum[i][j] = sum;
        }
    }
    rep(j, w)
    {
        int sum = 0;
        repr(i, h - 1)
        {

            m[i][j] == '#' ? sum = 0 : sum++;
            col_sum_r[i][j] = sum;
        }
    }

    int ans = 0;
    rep(i, h)
    {
        rep(j, w)
        {
            if (m[i][j] == '#')
                continue;
            ans = max(ans, row_sum[i][j] + row_sum_r[i][j] + col_sum[i][j] + col_sum_r[i][j] - 3);
        }
    }

    OP(ans);

    return 0;
}

Measured memory_bytes: 66688
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

idx = 1
flag = False
for i in range(1, N+1):
  idx = A[idx - 1]
  if idx == 2:
    flag = True
    break

if flag:
  print(i)
else:
  print(-1)

Measured memory_bytes: 7084
#include <cstdio>
#include <cstdint>
#include <vector>
#include <string>
#include <algorithm>

constexpr int INF = 1 << 29;

bool includes(const std::string& s, const std::string& t) {
  // s includes t?
  if (s.length() < t.length()) return false;
  for (size_t i=0; i+t.length()<=s.length(); ++i)
    if (s.compare(i, t.length(), t) == 0) return true;

  return false;
}

size_t common(const std::string& s, const std::string& t) {
  size_t max = std::min(s.length(), t.length());
  for (size_t i=max+1; i--;) {
    if (s.compare(s.length()-i, i, t, 0, i) == 0)
      return i;
  }
  return 0;
}

int tsp(const std::vector<std::vector<int>>& g, size_t s) {
  size_t n = g.size();
  std::vector<std::vector<int>> dp(1<<n, std::vector<int>(n, INF));
  dp[(1<<n)-1][s] = 0;

  for (size_t S=(1<<n)-1; S--;)
    for (size_t v=0; v<n; ++v)
      for (size_t u=0; u<n; ++u)
        if (!(S >> u & 1))
          dp[S][v] = std::min(dp[S][v], dp[S|1<<u][u] + g[u][v]);

  int res = INF;
  for (size_t i=0; i<n; ++i)
    res = std::min(res, dp[1<<i][i]);
  return res;
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<std::string> s(n);
  for (size_t i=0; i<n; ++i) {
    char buf[32];
    scanf("%s", buf);
    s[i] = buf;
  }

  std::vector<std::string> t;
  for (size_t i=0; i<n; ++i) {
    bool valid = true;
    for (size_t j=0; j<n; ++j) {
      if (i == j) continue;
      if (includes(s[j], s[i])) {
        valid = false;
        break;
      }
    }
    if (valid) t.emplace_back(s[i]);
  }

  std::vector<std::vector<int>> g(t.size(), std::vector<int>(t.size(), INF));

  for (size_t i=0; i<t.size(); ++i)
    for (size_t j=0; j<t.size(); ++j) {
      if (i == j) continue;
      g[i][j] = t[j].length() - common(t[i], t[j]);
    }

  int res = INF;
  for (size_t i=0; i<t.size(); ++i)
    res = std::min(res, int(t[i].length())+tsp(g, i));

  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll power(ll n, ll p) {
    ll ans = 1;
    while (p > 0) {
        if (p & 1) ans = ans * n;
        n = n * n;
        p >>= 1;
    }
    return ans;
}

const int maxnum = 150;

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

    vector<ll> p(maxnum);
    REP(i, 0, maxnum) p[i] = power(i, 5);

    REP(i, 0, maxnum) {
        ll diff = X - p[i];
        REP(j, 0, maxnum) {
            if (p[j] == diff) {
                cout << i << " " << -j << endl;
                return 0;
            }
            if ((-p[j]) == diff) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
        diff = X + p[i];
        REP(j, 0, maxnum) {
            if (p[j] == diff) {
                cout << -i << " " << -j << endl;
                return 0;
            }
            if ((-p[j]) == diff) {
                cout << -i << " " << j << endl;
                return 0;
            }
        }

    } 


    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		int dis[] = new int[n];
		int ans = 0;

		int min = 2000000000;
		for (int i = 0; i < n; i++) {
			int tar = Math.abs(scanner.nextInt() - x);
			min = Math.min(min, tar);
			dis[i] = tar;
		}

		boolean judge = true;
		for (int j = 1; j<=min; j++) {
			int tar = min / j;
			if (tar == 1) {
				System.out.println(1);
				return;
			}
			for (int i = 0; i < n; i++) {
				if (dis[i] % tar != 0) {
					judge = false;
					break;
				} else {
					judge = true;
					ans = tar;
				}
			}
			if (judge) {
				System.out.println(ans);
				return;
			}
		}

	}
}


Measured memory_bytes: 50120
#include <iostream>

using namespace std;

unsigned long long gcd( unsigned long long x, unsigned long long y )
{
	unsigned long long t;

	while( y != 0 ){
		t = x % y; x = y; y = t;
	}

	return x;
}

int main(int argc, char const* argv[])
{
	unsigned long long a1,m1,a2,m2,a3,m3;

	while( cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3 && a1 != 0 && m1 != 0 && a2 != 0 && m2 != 0 && a3 != 0 && m3 != 0 ){
		unsigned long long count1,count2,count3;
		unsigned long long hoge;

		count1 = count2 = count3 = 0;

		hoge = 1;
		do{
			hoge *= a1;
			hoge %= m1;
			count1++;
		}while( hoge != 1 );

		hoge = 1;
		do{
			hoge *= a2;
			hoge %= m2;
			count2++;
		}while( hoge != 1 );


		hoge = 1;
		do{
			hoge *= a3;
			hoge %= m3;
			count3++;
		}while( hoge != 1 );

		unsigned long long count = count1 * count2 * count3 / gcd( count1, count2 ) / gcd( count2, count3 ) / gcd( count1, count3 ) * gcd( gcd( count1, count2 ), count3 );

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
ll a[3000];
ll dp[3000][3000];
void f(int st, int end){
    if(st==end){
        dp[st][st]=a[st]; return ;
    }
    if(dp[st+1][end]==-1) f(st+1,end);
    if(dp[st][end-1]==-1) f(st,end-1);
    dp[st][end]=max(a[st]-dp[st+1][end],a[end]-dp[st][end-1]);
}
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<3000;i++){
        for(int j=0;j<3000;j++){
            dp[i][j]=-1;
        }
    }
    f(0,n-1);
    cout<<dp[0][n-1];
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

/*int makecontest(int day, vector<vector<int>>&s, vector<int>&c, vector<int>&last, int sat) {
  
}*/

int score(const int d, const vector<vector<int>>&s, const vector<int>&c, vector<int>&contests) {
  //vector<int> contests(d);
  vector<int> last(26, 0);
  int sat = 0;
  //makecontest(s, c, last, contests);
  for (int i = 0; i < d; i++) {
    //cout << d << " " << i << endl;
    last[contests[i]-1] = i+1;
    sat += s[i][contests[i]-1];
    for (int j = 0; j < 26; j++) {
      sat -= c[j] * (i+1 - last[j]);
    }
    //cout << sat << endl;
  }
  return sat;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);

  int d;
  cin >> d;
  vector<int> c(26);
  for (int i = 0; i < 26; i++) cin >> c[i];
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> contests(d);
  //for (int i = 0; i < d; i++) cin >> contests[i];
  for (int i = 0; i < d; i++) {
    int mx = 0, ct;
    for (int j = 0; j < 26; j++) {
      mx = max(mx, s[i][j]);
      if (mx == s[i][j]) ct = j+1;
    }
    contests[i] = ct;
  }
  
  int sc = score(d, s, c, contests);
  //cout << sc << endl;
  for (int p = 0; p < 100000; p++) {
    srand(p);
    int day = rand() % d;
    int q = rand() % 26;
    //cout << day << " " << q << endl;
    int old = contests[day];
    contests[day] = q + 1;
    if (score(d, s, c, contests) < sc) {
      contests[day] = old;
      continue;
    }
    sc = score(d, s, c, contests);
    //cout << sc << endl;
  }
  //cout << sc << endl;

  for (int i = 0; i < d; i++) cout << contests[i] << endl;
}


Measured memory_bytes: 3692
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

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

    void run() {

        long ans = 0;

        int n = sc.nextInt();
        int k = sc.nextInt();

        if (k==0) {
            long ans0 = (long)n*n;
            out.print(ans0);
            out.flush();
            return;
        }

        for (int i=1; i<=n; i++) {
            long div = n / i;
            long remain = n % i;
            ans += (long)div * Math.max(0, i-k);
            ans += (long)Math.max(0, remain-k+1);
        }


        out.print(ans);
        out.flush();
    }
}

Measured memory_bytes: 22228
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a==1&&b==1){
    a = 14;
    b = 14;
  }else if(a==1){
    a = 14;
  }else if(b==1){
    b = 14;
  }

  if (a>b){
    cout << "Alice";
  }else if(a<b){
    cout << "Bob";
  }else{
    cout << "Draw";
  }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

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

	int n;
	cin >> n;

	int b[n-1];

	loop(i,n-1)
	{
		cin>>b[i];
	}

	
   ll ans = 0;

	ans += b[0];
	ans += b[n-2];

	for(int i=0; i<n-2; i++)
	{
		ans+= min(b[i+1],b[i]);
	}


   
    cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;
int n,k;
map<int,int>mp;
vector<int>cnt;
int ans=0;
signed main() {
  cin>>n>>k;
  rep(i,n) {
    int a;
    cin>>a;
    mp[a]++;
  }
  if(mp.size()<=k) cout<<0<<endl;
  else {
    for(auto p:mp) cnt.push_back(p.second);
    sort(all(cnt));
    rep(i,mp.size()-k) {
      ans+=cnt.at(i);
    }
    cout<<ans<<endl;
  }
}

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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7,MAXN=2e5+1e1;
const double eps=1e-10;

struct Node{
	int w2,w5,p;
};

Node a[MAXN<<1];
int b[3100][3100],n;
lint ans=0;

void Read(int id){
	int x=0,f=1,X=0,F=1,cnt=0;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	if(c=='.'){
		while(!isdigit(c)){	if(c=='-') F=-F;c=getchar();}
		while(isdigit(c)){X=(X<<3)+(X<<1)+(c-48);++cnt;c=getchar();}
	}
	lint k3=X*F;
	if(k3==0) cnt=0;
	while((k3) && (k3%10==0)) k3/=10,--cnt;
	lint k1=x*f;
	a[id].p=cnt;
	while(cnt--) k1*=10;
	lint k2=k1+k3;
	while((k2) && (k2%2==0)) ++a[id].w2,k2/=2;
	while((k2) && (k2%5==0)) ++a[id].w5,k2/=5;
	return;
}

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++) Read(i);
	// for(int i=1;i<=n;i++) printf("%d %d %d\n",a[i].w2,a[i].w5,a[i].p);
	for(int i=1;i<=n;i++){
		lint res=0;
		int w2=a[i].w2,w5=a[i].w5,p=a[i].p;
		for(int j=0;j<=w2-p+48;j++) for(int k=0;k<=w5-p+48;k++) res+=b[j][k];
		++b[p-w2+48][p-w5+48];
		ans+=res;
		// printf("%lld ",res);
		// printf("%d %d\n",max(a[i].p-a[i].w2,0),max(a[i].p-a[i].w5,0));
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;

int n,k,a[110],dp[110][100010],sum[100010];

signed main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		sum[1]=dp[i-1][0];
		for(int j=2;j<=k+1;j++){
			sum[j]=sum[j-1]+dp[i-1][j-1];
			if(sum[j]>=MOD) sum[j]-=MOD;
		}
		for(int j=0;j<=k;j++){
			dp[i][j]=(sum[j+1]-sum[max(j-a[i],0ll)]+MOD);
			if(dp[i][j]>=MOD) dp[i][j]-=MOD;
		}
	}
	cout<<dp[n][k]%MOD<<endl;
	return 0;
}

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


using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){
    
    int N,K;
    double tmp;
    double n;
    double res=0;


    scanf("%d%d",&N,&K);

    for(int i=1;i<=N;i++){
        tmp = 1.0/(double)N;
        if(i>=K){
            res+=tmp;
            continue;
        }

        double pren = log((double)K/(double)i)/log(2.0);
        if(pren-(int)pren>0)
            n = (int)pren+1;
        else
            n=(int)pren;

        tmp *= pow(0.5,n);
        res+=tmp;
    }

    printf("%.10f\n",res);

    return 0;
}

Measured memory_bytes: 640
import qualified Data.Map as M

f ::Int->Int->Int->Int->[(Int,Int)]
f n n2 b add
   |n<=n2=[(n2,n2*b+add)]
   |otherwise=(n2,n2*b):f n (n2+1) b add

f2 ::String->(Int,Int)
f2 x=let (a:b:[])=(map read . words) x::[Int]
     in (a,b `div` 100)

f3::[(Int,Int)]->[(Int,Int)]->[(Int,Int)]->[(Int,Int)]
f3 _ _ []=[]
f3 [] xs2 (y:ys)=f3 xs2 xs2 ys
f3 ((c1,p1):xs1) xs2 ((c2,p2):ys)=((c1+c2),(p1+p2)):(f3 xs1 xs2 ((c2,p2):ys))

f5::Int->Int->Int
f5 a b
 |a>b=a
 |otherwise=b

f4::Int->[(Int,Int)]->[(Int,Int)]->[(Int,Int)]
f4 _ [] ys=ys
f4 b1 ((c1,p1):xs) ys=let zs= (f c1 0 b1 p1)
                      in f4 (b1+1) xs (M.toList (M.fromListWith (f5) (f3 zs zs ys)))
f6 :: Int->[(Int,Int)]->Int
f6 _ []=1
f6 n ((c,p):xs)
    |n<=p=c
    |otherwise=f6 n xs

main = do
       a<-getLine
       b<-getContents
       let xs=lines b
           (n:m:[])=(map read . words) a::[Int]
           m2=m `div` 100
           ys=(map f2) xs
       --print $ f3 (f 3 0 1 5) (f 3 0 1 5) [(0,0)]
       print $ f6 m2 $ f4 1 ys [(0,0)]

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

int main(){
    int n, m, X, Y;
    std::cin >> n >> m >> X >> Y;

    std::vector<int> x(n);
    for(int i = 0; i < n; ++i){
        std::cin >> x.at(i);
    }

    std::vector<int> y(m);
    for(int i = 0; i < m; ++i){
        std::cin >> y.at(i);
    }

    bool flg = false;
    std::sort(x.begin(), x.end());
    int xMax = *max_element(x.begin(), x.end());
    std::sort(y.begin(), y.end());
    int yMin = *min_element(y.begin(), y.end());
    if(xMax < yMin && xMax < Y && X < yMin){
        flg = true;
    }

    if(flg){
        std::cout << "No War" << std::endl;
    }else{
        std::cout << "War" << std::endl;
    }

    return 0;
}


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

N = int(input().strip())

openhour = [0] * 10
samehour = [0] * N

F = [0] * N
P = [0] * N
for i in range(N):
    F[i] = [int(x) for x in input().strip().split()]
for i in range(N):
    P[i] = [int(x) for x in input().strip().split()]

def f(i, openhour, samehour):
    if i == 10:
        if sum(openhour) == 0:
            return - 10 ** 9 - 7
        global N, F, P
        ret = sum([P[n][samehour[n]] for n in range(N)])
        return ret
    oh1 = openhour[:]
    oh2 = openhour[:]
    oh1[i] = 0
    oh2[i] = 1
    sh2 = samehour[:]
    for n in range(N):
        if F[n][i] == 1:
            sh2[n] += 1

    return max(f(i+1, oh1[:], samehour[:]),f(i+1, oh2[:], sh2[:]))

print(f(0, openhour[:], samehour[:]))



Measured memory_bytes: 3064
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    String S;
    boolean answer = false;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        S = sc.next();
    }
    
    //解答処理
    boolean solve() {
        String str = null;
        String a = null;
        String b = null;
        for (int i=0; i<S.length(); ++i){
            for (int j=i; j<S.length(); ++j){
                a = S.substring(0,i);
                b = S.substring(j,S.length());
                str = a+b;
                if (str.equals("keyence") || str.equals("key of science")){
                    answer = true;
                    break;
                }
            }
        }
        
        return answer;
    }
    
    //出力
    void show(boolean answer) {
        if (answer){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 3005
#define mxnn 2000005
int arr[mxn],dp[mxn][mxn][2],memo[mxn][mxn][2];
int func(int l,int r,int turn){
if(r==l){
        if(turn == 0) return arr[r];
        else          return -arr[r];
}
if(memo[l][r][turn]) return dp[l][r][turn];
int x;
if(turn == 0){
    x = max(arr[r]+func(l,r-1,1),arr[l]+func(l+1,r,1));
}
else x = min(func(l,r-1,0)-arr[r],-arr[l]+func(l+1,r,0));
memo[l][r][turn] = 1;
return dp[l][r][turn] = x;
}
int32_t main(){
sp;
memset(memo,0,sizeof memo);
int n;
cin >>n;
for(int i = 1;i<=n;i++) cin >>arr[i];
cout<<func(1,n,0);
return 0;
}


Measured memory_bytes: 281088
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int num[110000];

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1) A+=13;
  if(B==1) B+=13;
  if(A==B) cout<<"Draw"<<endl;
  else if(A>B) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
}


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

int main() {
        int N, W;
        cin >> N >> W;
        int w[N], v[N];
        for (int i=0; i<N; ++i) {
                cin >> w[i] >> v[i];
        }
        long long dp[N+1][W+1];
        for (int i=0; i<=W; ++i) {
                dp[0][i] = 0;
        }
        for (int i=0; i<N; ++i) {
                for (int j=0; j<=W; ++j) {
                        if (j < w[i]) {
                                dp[i+1][j] = dp[i][j];
                        } else {
                                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
                        }
                }
        }
        cout << dp[N][W] << endl;
        return 0;
}

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

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


Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b);
int min(int c,int d);
int main(){ 
	int sum,a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
	if(c>b||d<a){
		sum=0;
	}
	else if(c<=b){
	sum=min(b,d)-max(a,c);	
	}printf("%d\n",sum); }
	return 0;
}
int max(int a,int b){int max;
	max=a;
	if(b>max)max=b;
	return max;
}
int min(int c,int d){int min;
	min=c;
	if(d<min)min=d;
	return min;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  
  for (int i = 0; i < N; i++) {
    if (x >= K) {
      x += K;
      continue;
    }
    x *= 2;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 3624
package main

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

func main() {
	nextReader = newScanner()
	n, m := nextInt(), nextInt()
	fmt.Println(n*(n-1)/2 + m*(m-1)/2)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import numpy as np

N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
ans = 1
c = 1
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        #print("{}".format(-1))
        c=0
        break

if c==1:
    print("{}".format(ans))
elif c==0:
    if 0 in A:
        print("{}".format(0))
    else:
        print("{}".format(-1))


Measured memory_bytes: 39816