akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


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

  Vi pre(m, -1);
  UnionFind uf(n);

  rep(i, n) {
    int k; cin >> k;
    rep(j, k) {
      int l; cin >> l;
      --l;
      if (pre[l] != -1) uf.unite(pre[l], i);
      pre[l] = i;
    }
  }

  cout << (uf.size(0) == n ? "YES" : "NO") << '\n';
}


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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    int tMP, tUT, aMP, aUT;
    cin >> tMP >> tUT >> aMP >> aUT;

    while(1){
        aMP -= tUT;
        if(aMP <= 0){
            cout << "Yes" << endl;
            break;
        }
        tMP -= aUT;
        if(tMP <= 0){
            cout << "No" << endl;
            break;
        }
    }
    
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dig[20];

ll dfs(int l,int r,ll d){
  if(l<=r) return d ? 0 : ((l==r)?10:1);
  ll t=(10-d%10)%10;
  ll v=d-dig[l-r]*t+t;
  return ((r?10:9)-t)*dfs(l-1,r+1,llabs(v)/10);
}

int main(){
  dig[0]=1;
  for(int i=1;i<19;i++)
    dig[i] = dig[i-1]*10;
  ll d;
  cin>>d;
  ll ans = 0;
  for(int i=1;i<=18;i++) {
    ans += dfs(i,0,d);
    //cout<<ans<<endl;
  }
  //cout<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, m = 0, c = 0, before, current;
  cin >> N >> before;
  for (int i = 1; i < N; i++)
  {
    cin >> current;
    if (before >= current)
    {
      c++;
      m = max(c, m);
    }
    else
    {
      c = 0;
    }
    before = current;
  }
  cout << m << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
const ll MOD = 1000000007;
const int N = 100005;
int cnt[N + 5];
int main()
{
  FASTER;
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    for (int j = 0; j < x; j++){
      int knd;
      cin >> knd;
      cnt[knd]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (cnt[i] == n)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

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

        int a[] = new int[3];
        for (int i = 0; i < a.length; i++)
            a[i] = sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[2] - a[0]);
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n;
int a[110];

void quit()
{
	cout << "Impossible" << endl;
	exit(0);
}

int main()
{
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int Max = a[n];
	int Min = (Max + 1) / 2, Maxappear = (Max & 1) ? 2 : 1, cnt = 0;
//	cout << Max << ' ' << Min << endl;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] < Min) quit();
		if (a[i] == Min)
		{
			cnt++;
			if (cnt > Maxappear) quit();
		}
	}
	if (!cnt) quit();
	int cur = 1;
	for (int val = Min + 1; val <= Max; val++)
	{
		while (a[cur] < val) cur++;
		if (a[cur] > val) quit();
		cnt = 0;
		while (a[cur] == val) cur++, cnt++;
		if (cnt < 2) quit();
	}
	cout << "Possible" << endl;
	return 0;
}


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


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
    return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/
int a[100005];
int mins[100005] = {0};
int maxs[100005] = {0};

int main(void){
    int n, t;
    int mincnt = 0;
    int maxcnt = 0;
    int mini;
    scanf("%d %d", &n, &t);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int minv = 1000000010;
    int maxv = -1;
    for (int i = 0; i < n; i++){
        if (a[i] - minv> maxv){
            maxv = a[i] - minv;
        }        
        if (a[i] < minv){
            minv = a[i];
        }
    }
    minv = 1000000010;
    for (int i = 0; i < n; i++){
        if (a[i] < minv){
            minv = a[i];
            mini = i;
        }
        if (a[i] - minv == maxv){
            maxs[i] = 1;
            mins[mini] = 1;
        }
    }
    for (int i = 0; i < n; i++){
        if (mins[i] == 1){
            mincnt++;
        }
        if (maxs[i] == 1){
            maxcnt++;
        }
    }

    printf("%d\n", mincnt<maxcnt?mincnt:maxcnt);
    return 0;

}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
inline long long mymin(long long A,long long B)
{if(A<B)return A;return B;}
inline long long mymax(long long A,long long B)
{if(A>B)return A;return B;}
const int maxn=510;
int N,K,a[maxn],sum;
int p[10010],cnt;
long long b[maxn];
void div(int x){
	for(int i=1;i*i<=x;i++)
		if(x%i==0){
			p[++cnt]=i;
			if(i*i!=x)
				p[++cnt]=x/i;
		}
}
bool check(int x){
	for(int i=1;i<=N;i++)
		b[i]=a[i]%x;
	sort(b+1,b+1+N);
	for(int i=1;i<=N;i++)
		b[i]+=b[i-1];
	long long ret=K+1;
	for(int i=1;i<=N;i++)
		ret=mymin(ret,mymax(b[i],1LL*(N-i)*x-(b[N]-b[i])));
	return ret<=K;
}
int main(){
	//freopen("in","r",stdin);
	N=read(),K=read();
	for(int i=1;i<=N;i++)
		a[i]=read(),sum+=a[i];
	div(sum);
	int ans=1;
	for(int i=1;i<=cnt;i++)
		if(p[i]>ans&&check(p[i]))
			ans=max(ans,p[i]);
	printf("%d\n",ans);
	return 0;
}



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() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int			n;
	int			max;
	int			second_max;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B(n);

	rep(i, n)
		cin >> A.at(i);
	B = A;
	sort(B.begin(), B.end(), greater<>());
	max = B.at(0);
	second_max = B.at(1);
	rep(i, n)
	{
		if (A.at(i) != max)
			cout << max << endl;
		else
			cout << second_max << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
    reverse(a[i].begin(), a[i].end());
  }
  vector<P> q;
  auto check = [&](int i) {
    if (a[i].size() == 0) return;
    int j = a[i].back();
    if (a[j].size() == 0) return;
    if (a[j].back() == i) {
      P p(i,j);
      if (p.second < p.first) swap(p.first, p.second);
      q.push_back(p);
    }
  };
  rep(i,n) {
    check(i);
  }
  int day = 0;
  while (q.size() > 0) {
    day++;
    sort(q.begin(), q.end());
    q.erase(unique(q.begin(), q.end()), q.end());
    vector<P> prevQ;
    swap(prevQ, q);
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p : prevQ) {
      int i = p.first, j = p.second;
      check(i);
      check(j);
    }
  }
  rep(i,n) {
    if (a[i].size() != 0) {
      puts("-1");
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 4224
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M, K = in.next().toInt
  val uf = new UnionFind(N)
  val friend = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to M) {
    val A, B = in.next().toInt
    uf.connect(A, B)
    friend(A) = B :: friend(A)
    friend(B) = A :: friend(B)
  }

  val block = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to K) {
    val C, D = in.next().toInt
    block(C) = D :: block(C)
    block(D) = C :: block(D)
  }

  //
  val ans = new Array[Int](N+1)
  for (i <- 1 to N) {
    ans(i) = (uf.size(i) - 1) - friend(i).length
    val hoge = friend(i).toSet
    for (e <- block(i)) {
      if (!hoge(e) && uf.isConnect(i, e)) {
        ans(i) -= 1
      }
    }
  }

  println(ans.drop(1).mkString(" "))
}

// O(α(n)) << O(log(n))
// v は頂点数
// ノード番号は 1-origin 
class UnionFind(v: Int){
  // 根であれば *そのグループの要素数(負)* が、子であれば親の番号が入る。
  val uni = Array.fill(v+1)(-1)

  // 頂点 v の所属するグループを調べる
  def root(v: Int): Int =
    uni(v) < 0 match{
      case true  =>  // v が親の場合
        return v
      case false =>  // v が子の場合
        uni(v) = root(uni(v))  // 親のrootを調べる
        return uni(v)
    }

  // 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す
  def connect(a: Int, b: Int): Boolean = {
    // まずはそれぞれ根の番号に置き換える
    var ra = root(a)
    var rb = root(b)
    if(ra == rb)
      return false  // a と b がそもそも同じグループに属しているなら即終了

    // ra を大きなグループにしたいので、逆であれば入れ替える
    if(uni(ra) > uni(rb)) {  // rbの方が要素数が多ければ
      var tmp = ra
      ra = rb
      rb = tmp
    }

    // ra と rb を結合し、rb の親を ra とする
    uni(ra) += uni(rb)
    uni(rb) = ra
    return true
  }

  // 頂点 a, b が同じグループであるかを調べる
  def isConnect(a: Int, b: Int): Boolean =
    root(a) == root(b)

  // 頂点 a を含むグループの頂点数を調べる
  def size(a: Int): Int = -uni(root(a))
}


object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 109840
#include <iostream>
using namespace std;
 
int main() {
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; ++a) {
    for (int b = 0; b + a <= N; ++b) {
      int c = N - a - b;
      int total = 10000*a + 5000*b + 1000*c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<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; }


int main(){
    int ab, bc, ca; cin >> ab >> bc >> ca;
    COUT(ab * bc / 2);
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N, K = map(int, input().split())
    
    i = 0
    while K**i <= N:
        i += 1
    print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64876
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        System.out.println(a[n-1]-a[0]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25352
#include <cstdio>
#include <cstring>
using namespace std;

#define L 3194304
bool HA[L] = {0};
int T[256] = {0};

inline int get( unsigned char c ) {
    return T[c];
}

int main() {
    int n, sum, t, c;
    T['A'] = 1, T['C'] = 2, T['G'] = 3, T['T'] = 4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register int i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<queue>
//int[1e7] ll[5*1e6]
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

int x,y,ans;

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> x >> y;
    while(x){
        ++ans , x /= y;
    }
    cout << ans << "\n";

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	int n,a;
	scanf("%d%d",&n,&a);
	int b=n%500;
	string ret=b<=a?"Yes":"No";
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long H = sc.nextLong();
		// Hのlog2をとる
		double val = Math.log(H) / Math.log(2);
		val = Math.floor(val);

		long cnt = 0;

		for (int i = 0; i <= val; i++) {
			cnt += Math.pow(2, i);
		}

		System.out.println(cnt);
		sc.close();
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = sc.nextInt();
			int sum = 0;
			int max = 0;
			
			for (int i = 0; i < n; i++) {
				int l = sc.nextInt();
				sum += l;
				if (max < l) {
					max = l;
				}
			}
			
			int sum_o = sum - max;
			if (sum_o > max) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
 
		} finally {
			sc.close();
		}
	}
}




Measured memory_bytes: 21716
//C - Reconciled?:  
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

vector<ll> f(MAX, 0);

ll fat(ll n) {
    if(f[n]) return f[n];
    return f[n] = (n * fat(n-1)) % MOD;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    f[1] = 1; f[2] = 2;
    int n, m;
    ll ans;
    cin >> n >> m;
    if(abs(n-m) > 1) ans = 0;
    else if(abs(n-m) == 1) ans = ((fat(n) % MOD) * (fat(m) % MOD)) % MOD;
    else ans = (((2 * fat(n)) % MOD) * (fat(m) % MOD)) % MOD;
    
    cout << ans << "\n";
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  map<int, int> memo1; // a[i]とその登場回数
  for (int i=0; i<N; i++) {
    if (!memo1.count(a[i])) memo1[a[i]] = 1;
    else memo1[a[i]]++;
  }
  vector<int> memo2(100001, 0); // 各数字の登場回数を配列に格納したもの
  for (auto p : memo1) {
    auto k = p.first;
    auto v = p.second;
    memo2[k] = v;
  }
  if (N==1) cout << 1 << endl;
  else if (N==2) {
    int ans = memo2[0]+memo2[1];
    for (int i=0; i<100000; i++) ans = max(ans, memo2[i]+memo2[i+1]);
    cout << ans << endl;
  }
  else {
    int ans = memo2[0]+memo2[1]+memo2[2];
    for (int i=0; i<99999; i++) ans = max(ans, memo2[i]+memo2[i+1]+memo2[i+2]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3968
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
#include<string>
#include<iostream>
using std::cout;
using std::endl;
using std::string;
int ask(string x)
{
	cout<<"? "+x<<endl;
	int _tp;
	scanf("%d",&_tp);
	return _tp;
}
int t=0;
bool good(string x)
{return(ask(x)+(int)x.length())==t;}
int match(string x)
{return x.length()-ask(x);}
string merge(string x,string y)
{
	string ret="";
	for(;x.length()&&y.length();)
	{
		if(good(y+x.back()+ret))ret=x.back()+ret,x.pop_back();
		else ret=y.back()+ret,y.pop_back();
	}for(;x.length();)ret=x.back()+ret,x.pop_back();
	for(;y.length();)ret=y.back()+ret,y.pop_back();
	return ret;
}
string str[1111];
string pw(char c,int k)
{
	register int i;
	string ret="";
	for(i=1;i<=k;i++)ret=ret+c;
	return ret;
}
#include<queue>
struct comp{
	bool operator()(cpnst string&x,cpnst string&y){return x.length()>y.length();}
};
std::priority_queue<string,std::vector<string>,comp>Q;
char mp[]="1234567890QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
int main()
{
	register int i;
	for(i=0;i<62;i++)
	{
		int len=match(pw(mp[i],128));
		if(len)Q.push(pw(mp[i],len)),t+=len;
	}for(;Q.size()>1;)
	{
		string A=Q.top();Q.pop();
		string B=Q.top();Q.pop();
		Q.push(merge(A,B));
	}if(!Q.size())cout<<"! "<<endl;
	else cout<<"! "+Q.top()<<endl;
}
/*
Just go for it.
*/

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>>;
using GraphEdge = vector<vector<int>>;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int main(){
    bool x;cin >> x;
    cout << (!x) << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
using ll=long long;
const ll MOD=100000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return (v[(size / 2) - 1] + v[size / 2]) / 2;
}


int main(){
    ll s;
    cin>>s;
    if(0<s/100&&s/100<13){
        if(0<s%100&&s%100<13) cout<<"AMBIGUOUS";
        else cout<<"MMYY";
    }
    else{
        if(0<s%100&&s%100<13) cout<<"YYMM";
        else cout<<"NA";
    }
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
ar = []
if len(a) == len(b):
    for i in range(len(a)):
        ar.append(a[i])
        ar.append(b[i])
else:
    for i in range(len(b)):
        ar.append(a[i])
        ar.append(b[i])
    ar.append(a[len(a)-1])
print("".join(ar))
   

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int table[200][200]={{0}};
   int c,r; //column,row
   cin>>r>>c;
   for(int i=0;i<r;i++){
       for(int j=0;j<c;j++){
           cin>> table[i][j];
       }
    }
   //横計算します
    for(int i=0;i<r+1;i++){
        int sum=0;
       for(int j=0;j<c;j++){
           sum +=table[i][j];
           }
           table[i][c]=sum;
       }
   //縦計算します。（こちらはお願い）
    for(int i=0;i<c+1;i++){
        int sum=0;
       for(int j=0;j<r;j++){
           sum +=table[j][i];
           }
           table[r][i]=sum;
     }   
       
       
      //先に出力を作る
   for(int i=0;i<r+1;i++){
       for(int j=0;j<c;j++){
           cout<<table[i][j]<<" ";
       }
       cout<<table[i][c]<<endl;
   }
    
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans = double(w) * double(h) / 2;
    int cnt = 0;
    if (2 * x == w && 2 * y == h) cnt = 1;
    cout << fixed << setprecision(4) << ans <<  " " << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
devlist = []
while True:
    n = int(input())
    if n == 0:
        break
    else:
        s = list(map(float, input().split()))
        vari = 0
        mean = sum(s)/n
        for i in range(n):
            vari += ((s[i]-mean)**2)/n
        stdev = vari ** 0.5
        devlist.append(stdev)

for i in range(len(devlist)):
    print("{:8f}".format(devlist[i]))



Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
int n, m;
int dp[200009];
vector<int> g[200009];
int f(int v){
    if(dp[v] != 0)
        return dp[v];
    int maxi = 0;
    for(auto u : g[v])
        maxi = max(f(u), maxi);
    return dp[v] = 1 + maxi;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n >> m;
    while(m--){
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        ans = max(ans, f(i));
    }
    cout << ans-1 << "\n";
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  int all = a*x+b*y;

  int ans = all;
  while (x > 0 && y > 0) {
      all = all - (a+b) + c*2;
      x--;
      y--;
  }
  ans = min(ans,all);

  if(x == 0){
    ans = min(ans, all - b*y+c*2*y);
  }
  if(y == 0){
    ans = min(ans, all - a*x+c*2*x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
def opeCounter(S, K):
    T = S * K
    c = 0
    i = 1
    while i < len(T):
        if T[i-1] == T[i]:
            c += 1
            i += 1
        i += 1
    return c

def agc039a(S, K):
    s1 = opeCounter(S, 1)
    s2 = opeCounter(S, 2)
    s3 = opeCounter(S, 3)
    d1 = s2 - s1
    d2 = s3 - s2

    ans = 0
    if d1 == d2: ans = s1 + d1 * (K-1)
    else:
        if(K%2 != 0): ans = s1 + (d1+d2) * ((K+2-1)//2-1) ##(k/2):roundup
        else: ans = s2 + (d1+d2) * (K//2-1)
    return ans

S = input()
K = int(input())
print(agc039a(S, K))

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>p(N),copy(N);
	for (int i = 0; i < N; i++)cin >> p[i];
	copy = p;
	sort(copy.begin(), copy.end());
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (p[i] != copy[i])cnt++;
	}
	if (cnt == 0 || cnt == 2)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	while (1){
		int n, a[5001] = { 0 };
		cin >> n;
		if (n == 0)break;
		a[0] = 0;
		int maxv = -100000;
		for (int i = 1; i <= n; i++)
			cin >> a[i];
		for (int i = 1; i <= n; i++){
			a[i] = max(a[i - 1] + a[i], a[i]);
			maxv = max(a[i], maxv);
			if (maxv < a[i])
				maxv = a[i];
		}
		cout << maxv << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    string S = read_s(), T = read_s();
    map<char, int> MS, MT;
    int len = S.size();
    for (int i = 0; i<len; i++) {
        if (!MS[S[i]]) MS[S[i]] = i+1;
        if (!MT[T[i]]) MT[T[i]] = i+1;
        if (MS[S[i]] != MT[T[i]]) {
            printf("No\n");
            return;
        }
    }
    printf("Yes\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 900
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main(void)
{
	long long n;
	cin >> n;
	long long min=999999999, max=-999999999, sum=0;
	for (long long i=0 ; i<n ; i++)
	{
		long long k;
		cin >> k;
		if (k < min)
		{
			min = k;
		}
		if (k > max)
		{
			max = k;
		}
		sum += k;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3084
x = input()
s = input()

n, a, b = map(int, x.split())

p = 0
wp = 0

for char in s:
    if char == 'c' or p >= a+b:
        print('No')
        continue
    if char == 'a':
        p += 1
        print('Yes')
        continue
    if wp < b:
        p += 1
        wp += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9192
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

inline ll f(int n, int x) {
    ll c = n / x;
    return x * ((c * (c + 1)) >> 1);
}

void solve() {
    int n; cin >> n;
    cout << f(n, 1) - f(n, 3) - f(n, 5) + f(n, 15) << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3576
#include <stdio.h>



int main(){
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);

    int sum = 0;
    // i == 123
    // 123 % 10 == 3; 123 / 12
    // 12 % 10 == 2; 12 / 10 == 1
    // 1 % 10 == 1; 1/ 10 = 0
    // 3 + 2 + 1 = 6
    for(int i = 0; i <= N; i++){
        int digitSum = 0;
        int temp = i;  
        while (temp != 0){
            // berhenti selama tidak 0
            digitSum = digitSum + temp % 10;
            temp /= 10;
        } 
        if(digitSum >= A && digitSum <= B){
            //printf("%d ", i);
            sum += i;
        }
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1692
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 3e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
/*************************************************************************/

int dp[maxn];
void solve() {
    dp[0] = 1;
    int up = 1e5;
    REPP(i,0,up) {
        if(dp[i] == 0) {
            continue;
        }
        REPP(k,100,105) {
            dp[i+k] = 1;
        }
    }
    int x;
    SA(x);
    printf("%d\n", dp[x]);
}

int main()
{
#ifndef ONLINE_JUDGE
  //freopen("i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
#endif
  solve();

  return 0;
}





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

#define forn(i,m,n) for(int i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007

bool is_prime[1000001];
vi prime;
void sieve(int n)
{
    memset(is_prime,true,sizeof(is_prime));
    for(int i=2;i*i<=n;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                is_prime[j]=false;
            }
        }
    }
    forn(i,2,n+1)
    {
        if(is_prime[i])
            prime.pb(i);
    }
}


ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }


int main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
    //sieve(1000000);
    int te=1;
    //cin>>te;
    while(te--)
    {
        int n;
        cin>>n;
        double a[n+1];
        forn(i,1,n+1)
            cin>>a[i];
        double dp[n+1][n+1];
        dp[0][0]=1.0;
        forn(i,1,n+1)
        {
            dp[i][i]=dp[i-1][i-1]*a[i];
            for(int j=i-1;j>=0;j--)
            {
                dp[i][j]=dp[i-1][j]*(1-a[i]);
                if(j>0)
                    dp[i][j]+=dp[i-1][j-1]*a[i];
            }
        }
        double ans=0.0;
        forn(i,n/2+1,n+1)
            ans+=dp[n][i];
        cout<<setprecision(10)<<ans;
    }
}


Measured memory_bytes: 49984
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=100005;
vector<ll> adj[N],indeg(N,0), dp(N,0);
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n;
	cin>>n;
	ld dp[3005][3005];
	vector<ld> v(n+1);
	rep(i,1,n+1)
		cin>>v[i];
	dp[0][0]=(ld)(1.0);
	rep(i,1,n+1){
		rep(j,0,i){
			dp[i][j+1]+=dp[i-1][j]*v[i];
			dp[i][j]+=dp[i-1][j]*(1.0-v[i]);
		}
	}
	ld ans=0;
	rep(i,1,n+1){
		if(n-i<i)ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 145024
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    lli sum = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                sum += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 12;
const int INF = 1 << 30;
 
int main(){
    int N,M,X;
    int C[MAX];
    int A[MAX][MAX];
 
    cin >> N >> M >> X;
 
    for(int i = 0;i < N;i++){
        cin >> C[i];
        for(int j = 0;j < M;j++){
            cin >> A[i][j];
        }
    }
 
    int ans = INF;
 
    for(int i = 0;i < 1 << N;i++){
        int sum = 0;
        int cnt[MAX] = {0};
        bool f = true;
 
        for(int j = 0;j < N;j++){
            if((i >> j) & 1){
                sum += C[j];
                for(int k = 0;k < M;k++){
                    cnt[k] += A[j][k];
                }
            }
        }
 
        for(int j = 0;j < M;j++){
            if(cnt[j] < X)f = false;
        }
 
        if(f)ans = min(ans,sum);
    }
 
    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3196
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int cost = A[0];
      if (i != 0) {
        for (int k = 1; k <= i; k++)
          cost += A[k];
      }
      for (int j = i; j < N; j++) {
        cost += B[j];
      }
      ans = Math.max(cost, ans);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

string to_string(string s){
  return '"' + s + '"';
}
string to_string(const char *s){
  return to_string((string)s);
}
string to_string(bool b){
  return (b ? "true" : "false");
}
template<class A, class B>
string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template<class A, class B, class C>
string to_string(tuple<A, B, C> p){
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template<class A, class B, class C, class D>
string to_string(tuple<A, B, C, D> p){
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
template<class A>
string to_string(A v){
  bool first = true;
  string res = "{";
  for(const auto &x : v){
    if(!first){
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out(){cerr << endl;}
template<class Head, class... Tail>
void debug_out(Head H, Tail... T){
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL//compile with -DLOCAL
#define debug(...) cerr << "LINE" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int K;
  cin >> K;
  string A = "ACL";
  rep(i,K)  cout << A;
  cout << endl;

  return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

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

    for(int i = 0; i < N - K; i++){
        if(x[i] < x[i + K]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }


}


Measured memory_bytes: 4840