akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut ans = std::usize::MAX;
    for a_mx in a {
        let mut a_mx = a_mx;
        let mut tmp = 0;
        while a_mx % 2 == 0 {
            tmp += 1;
            a_mx /= 2;
        }
        ans = min(tmp, ans);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    string s; cin >> s;
    if(s == "#") break;
    int y, m, d; cin >> y >> m >> d;
    bool ch = false;
    if(y > 31) {
      ch = true;
    } else if(y == 31 && m >= 5) {
      ch = true;
    }
    if(ch) {
      cout << "?" << " " << y-30 << " " << m << " " << d << endl;
    } else {
      cout << s << " " << y << " " << m << " " << d << endl;
    }
  }
}



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

int n;
const int INF = 100100100;

int a[105][105];

int u,minv;
int d[105],p[105],color[105];

int prim(){

  for(int i = 0; i < n; i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = 0;
  }
  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(int i = 0; i < n; i++){
      if(minv > d[i] && color[i] != 2){
        minv = d[i];
        u = i;
      }
    }
    if(u==-1) break;

    color[u] = 2;

    for(int i = 0; i < n; i++){
      if(color[i]!= 2 && a[u][i] != INF){
        if(d[i] > a[u][i]){
          d[i] = a[u][i];
          p[i] = u;
          color[i] = 1;
        }
      }
    }
  }
  int sum = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != -1) sum+=a[i][p[i]];
  }
  return sum;
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int e;
      cin >> e;
      a[i][j] = (e == -1) ? INF:e;
    }
  }
  cout << prim() << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<30)

signed main(){
	int x;
	cin >> x;
	int r = x / 11;
	int m = x % 11;

	int result;
	if (m == 0) result = 2 * r;
	else if (m <= 6) result = 2 * r + 1;
	else result = 2 * r + 2;

	cout << result << endl;		

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {

		int Q = sc.nextInt();
		
		
		for(int i = 0 ; i < Q ; i++){
			int ni = sc.nextInt();
			
			int r = solve(ni);
			
			System.out.println(r);
		}
		
	}
	
	
	int solve(int ni){
		
		Set<Integer> visited = new TreeSet<Integer>();
		int count = 0;
		for(;;){
			if(ni < 10){
				return count;
			}

			ni = nextNum(ni);
			if(visited.contains(ni)){
				return -1;
			}
			visited.add(ni);
			
			count++;
		}
		
	}
	
	
	int nextNum(int a){
		int[] div = {10,100,1000,10000,100000};
		int max = 0;
		for(int d : div){
			int x = a/d;
			int y = a%d;
			max = Math.max(max, x*y);
		}
		return max;
	}
}



Measured memory_bytes: 27816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4010;
int n;ll x,a[N],Min[N][N];
int main()
{
	cin>>n>>x;
	for (int i=1;i<=n;i++) cin>>a[i],a[i+n]=a[i];
	for (int l=1;l<=n*2;l++){
		Min[l][l]=a[l];
		for (int r=l+1;r<=n*2;r++) Min[l][r]=min(Min[l][r-1],a[r]);
	}
	ll ans=1e16;
	for (int k=0;k<n;k++){//使用k次+1操作
		ll cost=k*x;
		for (int i=n+1;i<=n*2;i++) cost+=Min[i-k][i];
		ans=min(ans,cost);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	string s;
	int k;
	cin>>s;
	cin>>k;
	
	if (s.size()==1){
		cout<<k/2<<endl;
		return 0;
	}
	
	char last='#';
	long long seq=0;
	long long res=0;
	s+='*';
	int first=0;
	int lasts;
	
	for (int i=0; i<s.size(); i++){
		if (s[i]!=last){
			lasts=seq;
			if (!first) first=seq;
			res+=seq/2;
			seq=1;
			last=s[i];
		}
		
		else seq++;
	}
	
	//cout<<first<<" "<<lasts<<endl;
	
	if (first==s.size()-1){
		cout<<1LL*k*(s.size()-1)/2<<endl;
		return 0;
	}
	
	if (k==1) cout<<res<<endl;
	
	else{
		if (first%2==0 or lasts%2==0 or s[0]!=s[s.size()-2]){
			cout<<res*k<<endl;
		}
		
		else{
			cout<<res+(res+1)*(k-1)<<endl;
		}
	}

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int N, C;
vector<vector<LL>> D;
vector<vector<LL>> c;

int main() {
  cin >> N >> C;
  D.resize(C, vector<LL>(C));
  c.resize(N, vector<LL>(N));
  for (int i = 0; i < C; ++i) cin >> D[i];
  for (int i = 0; i < N; ++i) cin >> c[i];

  map<int, vector<LL>> m;
  for (int x = 0; x < C; ++x) {
    m[x] = vector<LL>(3, 0);
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        int before = c[i][j]-1;
        m[x][(i + j) % 3] += D[before][x];
      }
    }
  }

  LL min_score = 1e18;
  for (int a = 0; a < C; ++a) {
    for (int b = 0; b < C; ++b) {
      if (a == b) continue;
      for (int c = 0; c < C; ++c) {
        if (c == a || c == b) continue;
        LL score = m[a][0] + m[b][1] + m[c][2];
        min_score = min(min_score, score);
      }
    }
  }
  cout << min_score << endl;
}


Measured memory_bytes: 5588
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll d;
    std::cin >> d;
    if(d==25){
        std::cout << "Christmas" << std::endl;
    }else if(d==24){
        std::cout << "Christmas Eve" << std::endl;
    }else if(d==23){
        std::cout << "Christmas Eve Eve" << std::endl;
    }else {
        std::cout << "Christmas Eve Eve Eve" << std::endl;
    }
    
}


Measured memory_bytes: 256
import math

N, M = map(int, input().split())

d = math.floor(M**(1/2))


factor = []
for i in range(1,d+1):
	if M % i == 0:
		factor.append(i)
		factor.append(M//i)

ans = 0
for f in factor:
	if M//f >= N:
		ans = max(ans, f)

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);//種類
            int X = int.Parse(input[1]);//お菓子のもと(グラム)

            int[] m = new int[N];
            for (int i = 0; i < N; i++)
            {
                m[i] = int.Parse(Console.ReadLine().ToString());
            }

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                X -= m[i];
                count++;
            }

            int min = m.Min();

            while(X >= min)
            {
                count++;
                X -= min;
            }
            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,int> pli;
typedef pair<long long, long long> pll;

int main (int argc, char*argv[]) {
  int d, n;
  cin >> d >> n;
  if(n == 100) cout << n+1 ;
  else cout << n;
  if(d == 0) {
    cout << endl;
  } else if (d== 1) {
    cout << "00" << endl;
  } else if (d == 2) {
    cout << "0000" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# N枚のカード
# 平均aにしたい
n, a = map(int, input().split())
# 手持ちのカード
x = list(map(int, input().split()))
 
# aとの差を記録してリストに入れなおす
# 「選んだカードの xi の平均が A」であることは，
# 「選んだカードの (xi − A) の合計が 0」と言い換えることができる．
x = list(map(lambda i: i-a, x))
#print(x)
 
# dp初期値(辞書型)
# dp[0] = 1という意味
dp = {0: 1}

#xから1枚取り出す
for i in x:
    #dpにあるすべてのkey,valueに対して、
    #すでにdpにkeyがi+kのデータがあればそのvalue、なければ,0を返し、
    #それ+vをdpとする。
    
    # k=key
    # v=dp[key]のvalue
    for k,v in list(dp.items()):
        dp[i+k]=dp.get(i+k,0)+v
    
    #print(dp)

#全部使わない選択肢だけ、回答から除外する
print(dp[0]-1)
#print(dp)

Measured memory_bytes: 39792
function Main(input){
    const arr = input.split(' ').map(Number);
    const num = arr[3]-arr[0];
    if(num>=0){
        let K = num-arr[1];
        console.log(K>0 ? arr[0]-K:arr[0]);
    } else {
        console.log(arr[3]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

  double ans;

  if (n % 2 == 0) {
    ans = 0.5;
  } else {
    ans = (n / 2 + 1) * 1.0 / n;
  }

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
 
using namespace std;
#define int long long
const int mod = 1000000007;
 
vector<string> str;
 
int R, C;
int a[11][10001] = {};
 
int solve(int p,string c){
    if (p == R){
        str.push_back(c);
        return 0;
    }
    solve(p + 1, c);
    solve(p + 1, c + (char)(p + 48) + ",");
}
 
signed main()
{
     
    while (1){
        int ans = 0;
        cin >> R >> C;
        if (R == 0 && C == 0) return 0;
        for (int i = 0; i < R; i++){
            for (int j = 0; j < C; j++){
                cin >> a[i][j];
            }
        }
 
        solve(0, "");
        for (int i = 0; i < str.size(); i++){
            vector<int> tmp;
            string num = "";
            for (int j = 0; j < str[i].length(); j++){
                if (str[i][j] == ','){
                    tmp.push_back(stoi(num));
                    num = "";
                }
                else {
                    num += str[i][j];
                }
            }
 
            int score = 0;
            for (int k = 0; k < C; k++){
                int t1 = 0, t2 = 0;
                for (int l = 0; l < R; l++){
                    bool flag = false;
                    for (int m = 0; m < tmp.size(); m++){
                        if (l == tmp[m]){
                            flag = true;
                            if (a[l][k] == 1) t2++;
                            else t1++;
                        }
                    }
                    if (flag == false){
                        if (a[l][k] == 1) t1++;
                        else t2++;
                    }
                }
                score += max(t1, t2);
            }
            ans = max(ans, score);
        }
        cout << ans << endl;
    }
}

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

struct grid{
char g[11][11];
int count;
};

void DFS(grid& gr,char f,char c,int x,int y){

if(gr.g[x][y] != f){
  return;
}

gr.g[x][y] = c;

DFS(gr,f,c,x+1,y);
DFS(gr,f,c,x-1,y);
DFS(gr,f,c,x,y+1);
DFS(gr,f,c,x,y-1);
}

int main(){
  int x,y;
  while(1){

      cin >> x >> y;

      if(x==0 && y==0){
      break;
      }

      grid start;

      for(int i=0; i<y; i++){
          for(int j=0; j<x; j++){
              cin >> start.g[j][i];
          }
      }

      char fc = start.g[0][0];

      bool flag = true;

      for(int i=0; i<y; i++){
          for(int j=0; j<x; j++){
              if(start.g[j][i]!=fc){
                  flag = false;
                  break;
              }
          }
          if(!flag){
              break;
          }
      }
      if(flag){
          cout << 0 << endl;
          continue;
      }

      start.count = 0;

      queue<grid> q;

      q.push(start);

      while(1){

          grid bg = q.front();
          q.pop();

          bg.count++;

          grid tmp = bg;

          fc  = tmp.g[0][0];

          if(fc != 'R'){
              DFS(tmp,fc,'R',0,0);

              flag = true;
              for(int i=0; i<y; i++){
                  for(int j=0; j<x; j++){
                      if(tmp.g[j][i]!='R'){
                          flag = false;
                          break;
                      }
                  }
                  if(!flag){
                      break;
                  }
              }
              if(flag){
                  cout << tmp.count << endl;
                  break;
              }

              q.push(tmp);
              tmp = bg;
          }

          if(fc != 'G'){
              DFS(tmp,fc,'G',0,0);

              flag = true;
              for(int i=0; i<y; i++){
                  for(int j=0; j<x; j++){
                      if(tmp.g[j][i]!='G'){
                          flag = false;
                          break;
                      }
                  }
                  if(!flag){
                      break;
                  }
              }
              if(flag){
                  cout << tmp.count << endl;
                  break;
              }

              q.push(tmp);
              tmp = bg;
          }

          if(fc != 'B'){
              DFS(tmp,fc,'B',0,0);

              flag = true;
              for(int i=0; i<y; i++){
                  for(int j=0; j<x; j++){
                      if(tmp.g[j][i]!='B'){
                          flag = false;
                          break;
                      }
                  }
                  if(!flag){
                      break;
                  }
              }
              if(flag){
                  cout << tmp.count << endl;
                  break;
              }

              q.push(tmp);
              tmp = bg;
          }
      }
  }
  return 0;
}



Measured memory_bytes: 18636
S = input()
st = list(map(str, S))
o = st[0]
st.remove(o)
if o not in st:
    print("No")
else:
    st.remove(o)
    t = st[0]
    st.remove(t)
    if o in st or o == t:
        print("No")
    elif t in st:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main () {

    int d;
    while( scanf("%d", &d) != EOF ) {
        double a = 100000;
        int i;
        for ( i = 0; i < d; ++i ) {
            a *= 1.05;
            a /= 1000;
            a = ceil(a);
            a *= 1000;
        }
        printf("%.lf\n", a);
    }
    return 0;
}

Measured memory_bytes: 632
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
bool ok[101];

int main(int argc, char const* argv[])
{
  int n;
  string s;
  cin >> n >> s;
  fill(ok, ok + n, false);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(ok[j])continue;
      if(s[j] == '('){
        int tmp = j + 1;
        while(ok[tmp] && tmp < n)tmp++;
        if(tmp == n)continue;
        if(s[tmp] == ')'){
          ok[j] = true;
          ok[tmp] = true;
        }
      }
    }
  }
  int left = 0, right = 0;
  for(int i = 0; i < n; i++){
    if(!ok[i] && s[i] == ')')left++;
    else if(!ok[i])right++;
  }
  for(int i = 0; i < left; i++)cout << '(';
  cout << s;
  for(int i = 0; i < right; i++)cout << ')';
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const int INF = INT_MAX;
const ll MOD = 1e9+7;

const int MAX_N=100010;
int N;
int dp[MAX_N][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  int pre[2]={0,0};
  repeat(i,N){
    ll a;cin>>a;
    int b=0,c=0;
    for(;(1ll<<c)<a;c++);
    b = c-1+((1ll<<c)==a);
    //debug(i+1);
    //debug(b);
    //debug(c);
    dp[i+1][0] = min(dp[i][0]+abs(pre[0]-c),dp[i][1]+abs(pre[1]-c))+c-b;
    dp[i+1][1] = min(dp[i][0]+abs(pre[0]-b),dp[i][1]+abs(pre[1]-b))+c-b;
    pre[0]=b;
    pre[1]=c;
    //debug(pre[0]);
    //debug(pre[1]);
  }
  cout<<min(dp[N][0]+abs(pre[0]),dp[N][1]+abs(pre[1]))/2<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> H(N, 0);
  REP(ii, N) cin >> H[ii];
  int max_height = 0;
  int ans = 0;
  REP(ii, N) {
    if (max_height <= H[ii]) {
      ++ans;
      max_height = H[ii];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  string S;
  cin >> S;

  int len = S.size();
  bool easy = true;

  for(int i = 1; i <= len; i++){
    if(S[i-1] == 'U' || S[i-1] == 'D')
      continue;
    else if(S[i-1] == 'R' && i % 2 == 1)
      continue;
    else if(S[i-1] == 'L' && i % 2 == 0)
      continue;
    else{
      easy = false;
      break;
    }
  }
 
  if(easy)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

s = input()
if s[-1]=="s":
    print(s+"es")
else:
    print(s+"s")




Measured memory_bytes: 9040
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=100000+5;
const int MOD=1000000000+7;
template<class T> inline void read(T &x){
	x=0;
	T f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	x*=f;
}

int n,m;
int a[105];
int cnt=0;
int add=0;
int main(){
	read(n),read(m);
	for(int i=1;i<=n;i++){
		read(a[i]);
		add+=a[i];
	}
	if(add%(4*m)!=0){
		add=add/(4*m);
		add++;
	}
	else{
		add=add/(4*m);
	}
	for(int i=1;i<=n;i++){
		if(a[i]>=add){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ansArray = new int[10001];

		for(int x = 1;x<=100 ; x++) {
			for(int y = 1;y<=100 ; y++) {
				if(x*x + y*y>10000) {
					break;
				}
				for(int z = 1; z<=100 ; z++) {
					int tmp = x*x +y*y + z*z + x*y + y*z + z*x;
					if(tmp>10000) {
						break;
					}
					ansArray[tmp]++;

				}
			}
		}

		for(int i = 1;i<=N ; i++) {
			System.out.println(ansArray[i]);
		}
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 39316
let read_array n = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun x y -> x, y))

let md (x1, y1) (x2, y2) = abs (x1 - x2) + abs (y1 - y2)

let ans n m ab cd =
  let rec solve i =
    if i < n then
      let abi = ab.(i) in
      let rec f j d ret =
        if j = m then ret
        else
          let t = md abi cd.(j) in
          if t < d then f (j + 1) t (j + 1)
          else f (j + 1) d ret
      in (Printf.printf "%d\n" (f 0 1000000000 0); solve (i + 1))
  in solve 0

let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let ab = read_array n
  and cd = read_array m in
  ans n m ab cd


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

int main(){
  int i,j,x,n,c=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x);

    if(x==2) c++;

    if(x<2||x%2==0) continue;

    j=3;
    while(j<=sqrt(x)){
      if(x%j==0) break;
      j+=2;
    }

    if(j>sqrt(x)==1) c++;
  }

  printf("%d\n",c);

  return 0;
}

Measured memory_bytes: 596
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    int cnt = 0;
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            if(a[i][j] == '#') ++cnt;
        }
    }
    if(cnt != h + w - 1) {
        cout << "Impossible" << endl;
        return;
    } else {
        cout << "Possible" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n,i;
	int a[101],b[101];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < n; i++) {
		b[i] = a[n - i - 1];
		printf("%d", b[i]);
		if (i != n-1) {
			printf(" ");
		}
	}

	printf("\n");
	return 0;
}


Measured memory_bytes: 2056
X = input()
A = int(X[0])
B = int(X[1])
C = int(X[2])
D = int(X[3])

if A+B+C+D == 7:
    print(str(A)+ "+" + str(B)+ "+" + str(C)+ "+" + str(D) + "=" + str(7))
elif A+B+C-D == 7:
    print(str(A)+ "+" + str(B)+ "+" + str(C)+ "-" + str(D) + "=" + str(7))
elif A+B-C+D == 7:
    print(str(A)+ "+" + str(B)+ "-" + str(C)+ "+" + str(D) + "=" + str(7))
elif A-B+C+D == 7:
    print(str(A)+ "-" + str(B)+ "+" + str(C)+ "+" + str(D) + "=" + str(7))
elif A+B-C-D == 7:
    print(str(A)+ "+" + str(B)+ "-" + str(C)+ "-" + str(D) + "=" + str(7))
elif A-B-C+D == 7:
    print(str(A)+ "-" + str(B)+ "-" + str(C)+ "+" + str(D) + "=" + str(7))
elif A-B+C-D == 7:
    print(str(A)+ "-" + str(B)+ "+" + str(C)+ "-" + str(D) + "=" + str(7))
elif A-B-C-D == 7:
    print(str(A)+ "-" + str(B)+ "-" + str(C)+ "-" + str(D) + "=" + str(7))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
string s;
int K;
vector<string> V;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> s >> K;
	for (int i = 0; i < s.size(); i++) {
		string b = "";
		for (int j = i, ile = 0; j < s.size() && ile < 5; ile++, j++) {
			b += s[j];
			V.PB(b);
		}
	}
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());
	cout << V[K - 1] << "\n";

	return 0;
}


Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String s = sc.next();
        StringBuilder str = new StringBuilder(s);
        int k = sc.nextInt();

        char c = s.charAt(k-1);

        for (int i=0; i<n; i++){
            if(str.charAt(i)!=c){
                str.setCharAt(i, '*');
            }
        }
        System.out.println(str);

    }
}


Measured memory_bytes: 21716
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
     int N=int.Parse(Console.ReadLine());
     string[] str=Console.ReadLine().Split(' ');
      long[] height=str.Select(long.Parse).ToArray();

     //step.CopyTo(height,0);
    long ans=0;

      for(int i=1;i<N;i++){
     if(height[i]<height[i-1]){
       ans+=height[i-1]-height[i];
       height[i]=height[i-1];
      //  Console.WriteLine(dif[i]);
      }
      }
      Console.WriteLine(ans);
    }
    
  }

}


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

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

struct BIT{
	int siz=1<<18;
	int a[(1<<18)+10];
	void init(){
		for(int i = 0 ; i < (1<<18)+10 ; i ++){
			a[i] = 0;
		}
	}
	void add(int x){
		while(x<=siz){
			a[x]++;
			x+=x&-x;
		}
	}
	int sum(int x){
		int ret = 0;
		while(x>0){
			ret += a[x];
			x -= x&-x;
		}
		return ret;
	}
}bit[2];

int main(){
	static ll n;
	static ll a[100010];
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	
	int l=0,r=1000000000;
	while(l<r){
		int m=(l+r+1)/2;
		bit[0].init();
		bit[1].init();
		ll ret=0;
		ll cnt=0;
		bit[0].add(cnt+n);
		for(int i=1;i<=n;i++){
			if(a[i]>=m)cnt++;
			if(i&1){
				ret+=bit[1].sum(cnt-i/2+n);
				ret+=bit[0].sum(cnt-i/2+n-1);
			}
			else {
				ret+=bit[0].sum(cnt-i/2+n);
				ret+=bit[1].sum(cnt-i/2+n);
			}
			bit[i&1].add(cnt-i/2+n);
			//cout<<i<<" "<<cnt-i/2+n<<endl;
		}
		//cout<<m<<" "<<ret<<endl;
		if(ret>=((n+1)*n/2+1)/2)l=m;
		else r=m-1;
	}
	cout<<l<<endl;
}



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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);

    int a, b;
    cin >> a >> b;
    cout << a/__gcd(a, b)*b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <list>
#include <unordered_map>
#include <string>
using namespace std;
#define ll long long
#define pb push_back
using vi = vector<int>;
using vvi = vector<vector<int>>;

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

	vvi happinessLevels(n);
	for (int d = 0; d < n; d++) {
		vi happiness(3);
		cin >> happiness[0] >> happiness[1] >> happiness[2];
		if (d == 0) {
			happinessLevels[d] = happiness;
		} else {
			for (int curAct = 0; curAct < 3; curAct++) {
				int maxHappiness = 0;
				for (int prevAct = 0; prevAct < 3; prevAct++) {
					if (prevAct != curAct) {
						maxHappiness = max(maxHappiness, happinessLevels[d-1][prevAct] + happiness[curAct]);
					}
				}
				happinessLevels[d].pb(maxHappiness);
			}
		}
	}

	int maxHappiness = 0;
	for (int act = 0; act < 3; act++) {
		maxHappiness = max(happinessLevels[n-1][act], maxHappiness);
	}

	cout << maxHappiness << endl;

	return 0;
}

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    vector<string> board(100);
    for (int i = 0; i < 100; i++) {
        string str;
        for (int j = 0; j < 50; j++) {
            str += '#';
        }
        for (int j = 0; j < 50; j++) {
            str += '.';
        }
        board[i] = str;
    }
    [&]() {
        for (int i = 1; i < 50; i += 2) {
            for (int j = 1; j < 50-1; j += 2) {
                if (A == 1) return;
                board[i][j] = '.';
                --A;
            }
        }
    }();
    [&]() {
        for (int i = 1; i < 50; i += 2) {
            for (int j = 51; j < 100-1; j += 2) {
                if (B == 1) return;
                board[i][j] = '#';
                --B;
            }
        }
    }();
    cout << "100 100" << endl;
    for (int i = 0; i < 100; i++) {
        cout << board[i] << endl;
    }
}

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

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H / 2;
    bool multi = false;
    if (x == W / 2.0 && y == H / 2.0) {
        multi = true;
    }
    cout << fixed << setprecision(12) << ans << " " << multi << endl;
}


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

int main() {
  	int n;
  	cin >> n;
  
  	vector<ll> a(n);
  	rep(i, n) cin >> a.at(i);
  
	ll maxValue=0, ans=0;
  	rep(i, n){
      if(a.at(i) < maxValue) ans += maxValue-a.at(i);
      else maxValue = a.at(i);
    }
  	cout << ans << endl;
  
  	return 0;
}


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

int main()
{
    string s,r_s="";
    cin >> s;
    for(int i=s.length()-1; i>=0; i--) {
        r_s+=s[i];
    }
    if(s==r_s){ cout <<"Yes"<< endl; }
    else { cout << "No" << endl; }
    return 0;
}

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

int cnt1[25], cnt2[25], a[20], b[20];
int main() {
    while(true) {
        int w, d;
        cin >> w >> d;
        if(!w && !d) break;
        for(int i=0; i<21; ++i) cnt1[i] = cnt2[i] = 0;
        for(int i=0; i<w; ++i) { 
            cin >> a[i];
            cnt1[a[i]]++;
        }
        for(int i=0; i<d; ++i) {
            cin >> b[i];
            cnt2[b[i]]++;
        }
        for(int i=1; i<=20; ++i) {
            cnt1[i] -= min(cnt1[i], cnt2[i]);
        }
        int ret = 0;
        for(int i=1; i<=20; i++) {
            ret += i*(cnt1[i] + cnt2[i]);
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 3076
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <cassert>

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define irep(i, a, b) for (int i = a; i <= b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }

    vector<int> b(n);
    rep(i, 0, n) {
        int j = n - i - 1;
        int idx = 0;
        if (i % 2 == 0) {
            idx = i / 2;
        } else {
            idx = n - 1 - i / 2;
        }
        b[idx] = a[j];
    }

    rep(i, 0, n) {
        cout << (i == 0 ? "" : " ") << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3712
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                long a = Long.parseLong(sc.next());
                long b = Long.parseLong(sc.next());
                int c = Integer.parseInt(sc.next());
                int d = Integer.parseInt(sc.next());
                sc.close();
                long cc = c;
                int dd = d;
                while(c % d != 0){
                        int e = c % d;
                        c = d;
                        d = e;
                }
                long s = cc * dd / d;
                a--;
                long yono = b - a - b / cc + a / cc - b / dd + a / dd + b / s - a / s;
                ou.print(yono + "\n");
                ou.flush();
        }
}

Measured memory_bytes: 38712
from collections import deque

R,C = list(map(int,input().split()))
Sx,Sy = 0,0
Gx,Gy = R-1,C-1
Mize = [input() for _ in range(R)]
dd = [[1, 0], [-1, 0], [0, 1], [0, -1]]

def bfs():
    d = [[float('inf')] * C for i in range(R)]
    q = deque([])
    d[Sx][Sy] = 0
    q.append((Sx,Sy))
    while(len(q) != 0):
        x,y = q.popleft()
        if x == Gx and y == Gy:
            break
        for dx,dy in dd:
            
            if -1<x+dx<R and -1<y+dy<C and Mize[x+dx][y+dy]=='.' and d[x+dx][y+dy] == float('inf'):
                q.append([x+dx,y+dy])
                d[x+dx][y+dy] = d[x][y] + 1
    return d[Gx][Gy]

white = sum([m.count('#') for m in Mize])
need = bfs()
if need == float('inf'):
    print(-1)
else:
    print(R*C-white-need-1)

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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> f(n,vector<int>(10));
    for(int i=0;i<n;i++) for(int j=0;j<10;j++) cin>>f[i][j];
    vector<vector<int>> p(n,vector<int>(11));
    for(int i=0;i<n;i++) for(int j=0;j<11;j++) cin>>p[i][j];
    int res=-1e9-3;
    for(int i=1;i<(1<<10);i++){
        int sum=0;
        for(int j=0;j<n;j++){
            int val=i;
            int c=0;
            for(int k=0;k<10;k++){
                c+=(val%2 && f[j][k]);
                val/=2;
            }
            sum+=p[j][c];
        }
        res=max(res,sum);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int main () {
  int N ;
  cin >> N ;
  ll a[N] ;
  for(int i =0 ; i < N ;i++) cin  >> a[i] ;
  if(N==1){
    cout<<a[0]/2<<endl;
    return 0 ;
  }
  sort(a,a+N) ;
  int sum =0 ;
  for(int i = 0; i < N-1;i++)
    sum+=a[i];
  sum+=a[N-1]/2 ;
  cout<<sum<<endl;
  return 0 ;
}

Measured memory_bytes: 256
import math
n = int(input())

# def is_prime(n):
#     if n == 1:
#         return False
#     for i in range(2,int(n**0.5)+1):
#         if n % i == 0:
#             return False
#     return True

# if is_prime(n):
#     print(len(str(n)))
#     exit()

# rtn = math.floor(math.sqrt(n))

# for i in range(rtn,n+1):
#     if n % i == 0:
#         print(len(str(i)))
#         exit()

# n = a * b = b * aでなのでa<=bのaの方を求めてその時のbの桁数出力すれば間に合う。
# 上記のようにbの方から求めるとぎり間に合わない。

rtn = math.ceil(math.sqrt(n))
for i in reversed(range(1, rtn + 1)):
    if n % i == 0:
        b = n // i #求めるのはa(=i)ではなくbの方
        print(len(str(b)))
        exit()

Measured memory_bytes: 3060
#include <cstdio>
 
int main()
{
    int money = 100000;
    int n;
    float a = 0.05;
     
    scanf("%d", &n);
    while (n != 0){
        money += money * a;
        if ((money % 1000) != 0){
            money -= money % 1000;
            money += 1000;
        }
        n--;
    } 
    printf("%d\n", money);
     
    return (0);
}

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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

class Modulo
{
public:
    Modulo(const int n, const ll mod = 1000000007LL) : m_size{n + 1}, m_mod{mod}  // mod should be prime
    {
        assert(n > 0);
        m_fact.resize(n + 1);
        m_inv.resize(n + 1);
        m_inv_fact.resize(n + 1);
        m_fact[0] = 1;
        m_inv[0] = 1;
        m_inv_fact[0] = 1;
        m_fact[1] = 1;
        m_inv[1] = 1;
        m_inv_fact[1] = 1;
        for (int i = 2; i <= n; i++) {
            m_fact[i] = (m_fact[i - 1] * static_cast<ll>(i)) % mod;
            m_inv[i] = ((mod - (mod / static_cast<ll>(i))) * m_inv[static_cast<unsigned int>(mod) % i]) % mod;
            m_inv_fact[i] = (m_inv_fact[i - 1] * m_inv[i]) % mod;
        }
    }

    ll factorial(const int n) const
    {
        assert(n < m_size);
        return m_fact[n];
    }

    ll inverse(const int n) const
    {
        assert(n < m_size);
        return m_inv[n];
    }

    ll inverseFactorial(const int n) const
    {
        assert(n < m_size);
        return m_inv_fact[n];
    }

    ll permutation(const int n, const int k) const
    {
        assert(n < m_size);
        assert(k <= n);
        return (m_fact[n] * m_inv_fact[k]) % m_mod;
    }

    ll combination(const int n, const int k) const
    {
        assert(n < m_size);
        assert(k <= n);
        return (((m_fact[n] * m_inv_fact[k]) % m_mod) * m_inv_fact[n - k]) % m_mod;
    }

private:
    const int m_size;
    const ll m_mod;
    vector<ll> m_fact;
    vector<ll> m_inv;
    vector<ll> m_inv_fact;
};

int main()
{
    int n;
    cin >> n;
    vector<int> a(n, -1);
    int p1 = -1;
    int p2 = -1;
    for (decltype(n + 1) i = 0; i < n + 1; i++) {
        int x;
        cin >> x;
        x--;
        if (a[x] == -1) {
            a[x] = i;
        } else {
            p1 = a[x];
            p2 = i;
        }
    }
    Modulo mod{n + 1};
    const int num = p1 + (n - p2);
    for (decltype(n + 1) i = 1; i <= n + 1; i++) {
        const ll total = mod.combination(n + 1, i);
        const ll red = (num >= i - 1) ? mod.combination(num, i - 1) : 0;
        cout << ((total - red) % MOD + MOD) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	int n, d;
	cin >> n >> d;
	cout << (n + 2 * d) / (2 * d + 1);
}	

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c, d = 0, sum = 0;
	for (int h = 0; h < 51; h++) {
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (sum < b + c) {
				d = a; sum = b + c;
			}
		}
		cout << d << ' ' << sum << endl;
		d = 0; sum = 0;
	}
	cin >> n;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    a--; b--;
    vector<bool> ans(3, true);
    ans.at(a) = false;
    ans.at(b) = false;
    for(int i = 0; i < 3; ++i) {
        if(ans.at(i)) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
S=list(input())
T=list(input())

#S=['a', 'b', 'c', 'd', 'e']
#T=['a', 'b', 'c', 'd', 'e','f']

Result='Yes'
for i in range(len(S)):
    if S[i]==T[i]:
        pass
    else:
        Result='No'
        break

print(Result) 


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

int main() {
    int n;
    cin >> n;
    ll max = 0;
    ll ans = 0;
    rep(i,n) {
        ll a;
        cin >> a;
        if (i == 0) {
            max = a;
        }
        if (a < max) {
            ans += max-a;
        }
        else if (a >= max) max = a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;
int main()
{
	int h,w;
	cin >> h >> w;
	char s[h+3][w+3];
	for(int i=0; i<h; i++){
		cin >> s[i];
		for(int j=0; j<w; j++){
			if(s[i][j] == '.')
				s[i][j] = '0';
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j] == '#'){
				if(i > 0){
					if(s[i-1][j] != '#') s[i-1][j]++;
					if(s[i-1][j+1] != '#') s[i-1][j+1]++;
				}
				if(j > 0){
					if(s[i][j-1] != '#') s[i][j-1]++;
					if(s[i+1][j-1] != '#') s[i+1][j-1]++;
				}
				if(i > 0 && j > 0){
					if(s[i-1][j-1] != '#') s[i-1][j-1]++;
				}
				if(s[i][j+1] != '#') s[i][j+1]++;
				if(s[i+1][j] != '#') s[i+1][j]++;
				if(s[i+1][j+1] != '#') s[i+1][j+1]++;
			}
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cout << s[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> M(N);
    REP(i, N)
    {
        cin >> M[i];
    }
    vector<int> sum(N);
    sum[0] = M[0];
    FOR(i, 1, N)
    {
        sum[i] = sum[i - 1] + M[i];
    }
    int ans = INF;
    REP(i, N)
    {
        if (ans > abs(sum[N - 1] - 2 * sum[i]))
        {
            ans = abs(sum[N - 1] - 2 * sum[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256