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

int n;
vector<string> A;

void DFS(string s, int num){
    bool a = false, b = false, c = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') a = true;
        if(s[i] == '5') b = true;
        if(s[i] == '7') c = true;
    }
    if(a and b and c){
        A.push_back(s);
    }
    if(num == to_string(n).length()){
        return;
    }
    DFS(s + '3', num + 1);
    DFS(s + '5', num + 1);
    DFS(s + '7', num + 1);
    return;
}


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

    cin >> n;
    DFS("", 0);

    int ans = 0;
    for(auto &x : A){
        int nyo = stoi(x);
        if(nyo <= n){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1660
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{  
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] str=br.readLine().split(" ");
        long S=Long.parseLong(str[0]);
        long W=Long.parseLong(str[1]);
        if(W>=S) System.out.println("unsafe");
        else System.out.println("safe");
        }
    }


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;
string S[6];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	FOR(y,H) cin>>S[y];
	
	int hm,wm;
	int ret=0;
	FOR(hm,1<<H) FOR(wm,1<<W) {
		int num=0;
		FOR(y,H) FOR(x,W) {
			if(hm&(1<<y)) continue;
			if(wm&(1<<x)) continue;
			if(S[y][x]=='#') num++;
		}
		if(num==K) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; ++i) {
		double A;
		cin >> A;
		ans += 1.0 / A;
	}
	ans = 1.0 / ans;
	printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

bool isLeap(int i){
	return i % 400 == 0 
			? true : i % 100 == 0
			? false : i % 4 == 0
			? true : false;
}

int getSum(int y,int m,int d,const int* month){
	int sum=0;
	for(int i=0;i<y;i++){
		sum += isLeap(i) ? 366 : 365;
	}

	for(int i=1;i<m;i++){
		sum += i != 2 ? month[i] :
			isLeap(y) ? month[i] + 1 : month[i];
	}

	sum += d;

	return sum;
}

int main(){
	const int month[] = {-1,31,28,31,30,31,30,31,31,30,31,30,31};
	int y1, m1, d1, y2, m2, d2;
	while(~scanf("%d %d %d %d %d %d",&y1, &m1, &d1, &y2, &m2, &d2)){
		if(y1 < 0 || m1 < 0 || d1 < 0
			|| y2 < 0 || m2 < 0 || d2 < 0) break;

		cout << abs(getSum(y1,m1,d1,month) - getSum(y2,m2,d2,month)) << endl;
	}
}

Measured memory_bytes: 0
from collections import defaultdict
def gcd(x,y):
    while y:
        x, y = y, x%y 
    return x

K=int(input())
gcd_of_two = defaultdict(int)
for i in range(1, K+1):
    for j in range(1, K+1):
        gcd_of_two[gcd(i,j)] += 1
result = 0
for val, freq in gcd_of_two.items():
    for k in range(1,K+1):
        result += freq * gcd(val, k)
print(result)

Measured memory_bytes: 9472
#include<iostream>
#include<cmath>
#include<complex>
#include<iomanip>
#include<cassert>

using namespace std;

typedef complex<double> point;
typedef pair<point,point> line;


bool makeable(int a, int b, int c){
  return a+b>c && b+c>a && c+a>b;
}

inline double my_pow(double a, double b){
  return pow(a, b);
}

double vofh(int a, int b, int c, int p, int q, int r)
{
  double s = -2.0 * my_pow(a, 2) * my_pow(b, 2) * my_pow(p, 2)+2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(p, 2)+2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(p, 2)-2 * my_pow(c, 4) * my_pow(p, 2)-2 * my_pow(c, 2) * my_pow(p, 4)+2 * my_pow(a, 2) * my_pow(b, 2) * my_pow(q, 2)-2 * my_pow(b, 4) * my_pow(q, 2)-2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(q, 2)+2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(q, 2)+2 * my_pow(b, 2) * my_pow(p, 2) * my_pow(q, 2)+2 * my_pow(c, 2) * my_pow(p, 2) * my_pow(q, 2)-2 * my_pow(b, 2) * my_pow(q, 4)-2 * my_pow(a, 4) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(b, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(c, 2) * my_pow(r, 2)-2 * my_pow(b, 2) * my_pow(c, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(p, 2) * my_pow(r, 2)+2 * my_pow(c, 2) * my_pow(p, 2) * my_pow(r, 2)+2 * my_pow(a, 2) * my_pow(q, 2) * my_pow(r, 2)+2 * my_pow(b, 2) * my_pow(q, 2) * my_pow(r, 2)-2 * my_pow(p, 2) * my_pow(q, 2) * my_pow(r, 2)-2 * my_pow(a, 2) * my_pow(r, 4);
  return sqrt(s / 288);
}

const double pi = 2*acos(0.0);

int main()
{
  int N;
  while(cin>>N)
  {
    double res = 0;
    if( N == 0 ) break;
    int a[N];

    for(int i = 0; i < N; ++i){
      cin >> a[i];
    }

    int comb = (1<<3) - 1;
    while(comb<(1<<N)){      
      int cnt = 0;
      int e[3];
      bool used[N];
      for(int b = 0; b < N; ++b){
        if( comb & (1<<b) ){
          // cout << 1;
          e[cnt++] = a[b];
          used[b] = true;
        }else{
          // cout << 0;
          used[b] = false;
        }
      }
      // cout << endl;
      assert(cnt==3);
      
      if( makeable( e[0], e[1], e[2] ) ){
        for(int i = 0; i < N; ++i){
          for(int j = i+1; j < N; ++j){
            if( !used[i] && !used[j] ){
              
              for(int k = 0; k < 3; ++k){
                int f0 = e[k];
                int f1 = e[(k+1)%3];
                int f2 = e[(k+2)%3];
                
                if( makeable(a[i], a[j], f0) ){
                  double f = f1;
                  double h = a[i];
                  
                  for(int l = 0; l < N; ++l){
                    if( l != i && l != j && !used[l] ){
                      int x = a[l];
                      double tcos = (x*x - f*f - h*h)/(2.*f*h);
                      double tsin = 1-tcos*tcos;
                      if( makeable(x,f1,a[i]) && tsin > 0 ){
                        res = max(res , vofh(a[i],a[j],a[l],f0,f1,f2));
                      }
                    }
                  }
                }
                

              }

            }
          }
        }
      }

      int x = comb & -comb;
      int y = comb + x;
      comb = ((comb & ~y) / x >> 1 ) | y;      
    }

    cout << fixed << setprecision(11) << res << endl;

    
  }
  return 0;
}

Measured memory_bytes: 960
#include<stdio.h>
#define M 25
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
} tree;

tree A[M];

void preorder(int x){
  if(x == NIL) return;
  printf(" %d",x);
  preorder(A[x].left);
  preorder(A[x].right);
}

void inorder(int x){
  if(x == NIL) return;
  inorder(A[x].left);
  printf(" %d",x);
  inorder(A[x].right);
}

void postorder(int x){
  if(x == NIL) return;
  postorder(A[x].left);
  postorder(A[x].right);
  printf(" %d",x);
}

int main(){
  int i;
  int j;
  int n;
  int count=0;
  int id;
  int height;
  int depth;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].parent = NIL;
    A[i].right = NIL;
    A[i].left = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&height,&depth);
    A[id].left = height;
    A[id].right = depth;
    if(height != NIL) A[height].parent = id;
    if(depth != NIL) A[depth].parent = id;
  }
  
  for(i=0;i<n;i++){
    if(A[i].parent == NIL) break;
  }

  printf("Preorder\n");
  preorder(i);
  printf("\n");

  printf("Inorder\n");
  inorder(i);
  printf("\n");

  printf("Postorder\n");
  postorder(i);
  printf("\n");

  return 0;
}




Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
[check]
辞書順最小

前から評価する。
azzzzz 26
の場合、aで26を浪費しないように！

*/

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

    rep(i, s.size()){
        if (s[i] == 'a') continue;
        int c = 'z'-s[i];
        if (c < n){
            s[i] = 'a';
            n -= c+1;
        }
    }
    if (n != 0){
        int c = s[s.size()-1]-'a';
        int alpha_num = 'z'-'a'+1;
        c = (c+n)%alpha_num;
        //cout << c << endl;
        s[s.size()-1] = c + 'a';
    }

    cout << s << endl;
}



Measured memory_bytes: 640
s=list(input())
k=int(input())
n=len(s)

for i in range(n-1):
    t=s[i]
    order=ord(t)-97
    if order==0:
        continue
    elif k>=26-order:
        s[i]='a'
        k-=26-order
    else:
        continue
s[n-1]=chr(97+(ord(s[n-1])-97+k)%26)

print(''.join(s))

Measured memory_bytes: 49520
# coding: utf-8

i = 0
while True:
    num = int(input().rstrip())
    if num == 0:
        break
    else:
        print("Case " + str(i + 1) + ": " + str(num))
        i += 1


# <?php

# $i = 0;
# while($num = trim(fgets(STDIN))) {
#     if($num == 0) {
#         break;
#     } else {
#         echo "Case " . ($i + 1). ": " . $num . PHP_EOL;
#         $i++;
#     }
# }

# ?>



Measured memory_bytes: 5608
import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0:
            return 0
    return 1


def main():
    X = int(input())

    for i in range(X, 100003+1):
        if is_prime(i):
            print(i)
            break
        else:
            continue


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math

a, b, gamma = map(float, input().split())

c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(gamma)))
h = math.sqrt(c**2-(a-b*math.cos(math.radians(gamma)))**2)
s = a*h*0.5
l = a + b + c

print('{:.08f}'.format(s))
print('{:.08f}'.format(l))
print('{:.08f}'.format(h))


Measured memory_bytes: 5696
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int a[3];
    int cnt=0;
    int cnt1=0;
    int cnt2=0;
    int cnt3=0;
    while(1){
        cin >> a[0] >> a[1] >> a[2];
        sort(a,a+3);
        int min=a[0];
        int max1=a[2];
        int max2=a[1];
        if(abs(max2-max1)>=min||min>=max1+max2){
            break;
        }
        cnt++;
        if(min*min+max2*max2-max1*max1==0){
            cnt1++;
        }else if(min*min+max2*max2-max1*max1>0){
            cnt2++;
        }else{
            cnt3++;
        }
        
    }

    cout << cnt << " " << cnt1 << " " << cnt2 << " " << cnt3 << endl;
    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 10;
int h, w, n;
int a[maxn], ans[100 + 10][100 + 10];

int main()
{
    scanf("%d%d%d", &h, &w, &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    memset(ans, 0, sizeof(ans));
    int i = 1, j = 1, k = 1;
    while(k <= n)
    {   while(j <= w && ans[i][j] == 0)
        {
            ans[i][j++] = k;
            a[k]--;
            if(a[k] == 0) k++;
        }
        i++;j--;
        while(i <= h && ans[i][j] == 0)
        {
            ans[i++][j] = k;
            a[k]--;
            if(a[k] == 0) k++;
        }
        i--;j--;
        while(j >= 1 && ans[i][j] == 0)
        {
            ans[i][j--] = k;
            a[k]--;
            if(a[k] == 0) k++;
        }
        i--;j++;
        while(i >= 1 && ans[i][j] == 0)
        {
            ans[i--][j] = k;
            a[k]--;
            if(a[k] == 0) k++;
        }
        i++;j++;
    }
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
            printf("%d ", ans[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
k = int(input())
import sys

if(k < 10):
    print(k)
    sys.exit()

lun = [[1,2,3,4,5,6,7,8,9]]
count = 9

def check(n,cc):
    cc += 1
    if(cc == k):
        print(n)
        sys.exit()
    return cc


for i in lun:
    new_lun = []
    for j in i:
        a = j*10
        b = j%10
        if(b != 0):
            new_lun.append(a + b - 1)
            count = check(a + b - 1,count)
        new_lun.append(a + b)
        count = check(a + b,count)
        if(b != 9):
            new_lun.append(a + b + 1)
            count = check(a + b + 1, count)
    lun.append(new_lun)

Measured memory_bytes: 13036
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int K, S;
int ans = 0;

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

    rep(X, K+1)
        rep(Y, K+1) {
            int Z = S - X - Y;
            if (0 <= Z && Z <= K) ans ++;
        }
    cout << ans << endl;
}

Measured memory_bytes: 768
A,B = map(int,input().split())
num_list= list(map(int,input().split()))

#print(num_list)
sort_num_list = sorted(num_list)

if B >= len(num_list):
  print(0)
else:
  for i in range(B):
    test = sort_num_list.pop()
  print(sum(sort_num_list))




Measured memory_bytes: 26024
#include<iostream>
using namespace std;
int a[10000];
int Quicksort(int b[],int low,int high)
{
	if(low>=high) return 0;
	int base=b[low],i=low,j=high;
	while(i<j)
	{
		while(i<j&&b[j]>=base)
			j--;
		b[i]=b[j];
		while(i<j&&b[i]<=base)
			i++;
		b[j]=b[i];
	}
	b[i]=base;
	Quicksort(b,low,i-1);
	Quicksort(b,i+1,high);
	return 1;
}
int main()
{
	int n,i,j,k,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	if(n<3) return 0;
	Quicksort(a,0,n-1);
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
		{
			k=j+1;
			while(k<n&&a[i]+a[j]>a[k])
				k++;
			sum+=k-j-1;
		}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int c=0,p=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(!p&&s[i]=='A')p=1;
    if(p&&s[i]=='Z'){
      c++;
      p--;
    }
  }
  if(c)for(int i=0;i<c;i++)cout<<"AZ";
  else cout<<-1;
  cout<<endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
  	cin >> N;
    vector<int> A(N);
	for(int i =0;i<N;i++){
      cin >> A.at(i);
    }
    int flag = 1;
    int count = 0;
    int k = 1;
    while(flag){
      flag =0;
      for(int i = N-1;i>=k;i--){
        if(A.at(i)<A.at(i-1)){
          swap(A.at(i-1),A.at(i));
          flag = 1;
          count++;
        }
      }
	k++;
    }
    for(int h=0;h<N-1;h++){
      cout << A.at(h) << ' ';
    }
    cout << A.at(N-1) << endl;
    cout << count <<endl;
        
}


Measured memory_bytes: 3104
import collections

s = input()
slen = len(s)

sl = collections.deque(list(s))
sl_inv = collections.deque(list(s[::-1]))
cnt = 0
while len(sl)>0:
    if sl[0]== sl_inv[0]:
        sl.popleft()
        sl_inv.popleft()
    elif sl[0] == 'x' and sl_inv[0] !='x':
        sl.popleft()
    elif sl[0] != 'x' and sl_inv[0] == 'x':
        cnt += 1
        sl_inv.popleft()
    elif sl[0] != 'x' and sl_inv[0] != 'x' and sl[0]!=sl_inv[0]:
        print(-1)
        exit()
    if len(sl_inv) ==0:
        break
    #print(sl,sl_inv,cnt)
print(cnt+len(sl_inv))


Measured memory_bytes: 11884
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    ll H,W,N;
    cin >> H >> W >> N;
    set<pair<ll,ll>> black;
    set<pair<ll,ll>> checkList;
    for (int i = 0; i < N; ++i) {
        ll x,y;
        cin >> y >> x;
        black.insert(make_pair(y,x));
        for (int yi = -1; yi <= 1; ++yi) {
            for (int xi = -1; xi <= 1; ++xi) {
                ll tx,ty;
                tx = x + xi;
                ty = y + yi;
                if(1 < tx && tx <= W-1 && 1 < ty && ty <= H-1){
                    if(checkList.find(make_pair(ty,tx)) == checkList.end()){
                        checkList.insert(make_pair(ty,tx));
                    }
                }
            }
        }
    }
    vector<ll> count(10);
    ll sum = 0;
    for(auto itr = checkList.begin(); itr != checkList.end(); ++itr) {
        auto p = *itr;
        ll c = 0;
        for (int yi = -1; yi < 2; ++yi) {
            for (int xi = -1; xi < 2; ++xi) {
                if(black.find(make_pair(p.first + yi,p.second + xi)) != black.end()){
                    c++;
                }
            }
        }
        count[c]++;
        sum++;
    }
    count[0] = (H-2) * (W-2) - sum;
    for (int i = 0; i < 10; ++i) {
        cout << count[i] << endl;
    }


}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin>>n;
    map<string, ll> m;
    ll res=0;
    rep(i,n){
        string s; cin>>s;
        sort(s.begin(), s.end());
        res+=m[s];
        m[s]++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 11136
N = int(input())
A=list(map(int, input().split()))
 
ans=1
c=0
 
while c<N:
    if A[c]==0:
        ans=0
    elif ans*A[c]>1000000000000000000:
        ans=1000000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>1000000000000000000: print(-1)
else: print(ans)

Measured memory_bytes: 21776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;

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

int N;

bool DFS(vector<ll> A){
    
    vector<ll> left(N+2),right(N+2);
    ll sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i];
    }
    
    if((sum-N)%2){
        return 1;
    }
    
    for(int i=1;i<=N;i++){
        left[i]=gcd(left[i-1],A[i-1]);
    }
    
    for(int i=N;i>=1;i--){
        right[i]=gcd(right[i+1],A[i-1]);
    }
    
    bool res=false;
    
    for(int i=1;i<=N;i++){
        if(A[i-1]==1) continue;
        ll g=gcd(gcd(left[i-1],A[i-1]-1),right[i+1]);
        if(g==1) continue;
        
        if(((sum-1)/g-N)%2==0){
            vector<ll> to(N);
            to=A;
            for(int j=0;j<N;j++){
                if(j==i-1) to[j]--;
                to[j]/=g;
            }
            res|=!DFS(to);
        }
    }
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    if(DFS(A)) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    
}



Measured memory_bytes: 72448
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}




Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 1e3;
bool snuke[N];
int  main()
{
	int n,k;
	cin >> n >> k;
	int d[k];
	forn(i,k)
	{
		cin >> d[i];
		int a[d[i]];
		forn(j,d[i])
		{
			cin >> a[j];
			a[j]--;
			snuke[a[j]] = true;
		}
	}
	int ret=  0;
	forn(i,n)
		if(!snuke[i])
			ret++;
	cout << ret << endl;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;
typedef long long int lint;

void answer()
{
	int dp[8][4096] = { 0 };
	dp[0][0] = 1;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j <= 4000; j++) {
			dp[i + 1][j] = dp[i + 1][j - 1] + dp[i][j] - ((j > 1000) ? dp[i][j - 1001] : 0);
		}
	}

	int n;
	while (cin >> n) {
		cout << dp[4][n] << endl;
	}
}

int main()
{
	answer();
	return 0;
}

Measured memory_bytes: 1296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long A = GetLong();
		long B = GetLong();

		if((B - A) % 2 == 0)
		{
			WriteLine(Min((B - A) / 2, Min(B - 1, N - A)));
		}
		else
		{
			long x = Min(A, N - B + 1) + (B - A - 1) / 2;
			WriteLine(Min(x, Min(B - 1, N - A)));
		}
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11092
/*
 * Ankit Raj, NIT Agartala
 */
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define MAX_RANGE 10000007
#define BOOST ios_base::sync_with_stdio(0) 
#define NITRO cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main()
{
	BOOST;
	NITRO;
	clock_t t1,t2;
	t1 = clock();
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	*/ 
	//Main Code
	string s;
	cin>>s;
	int ct_z = 0,ct_o=0;
	stack<char>S;
	for(int i=0;i<(int)s.length();i++)
	{
		if(s[i]=='0')
		{
			ct_z++;
		}
		else
		{
			ct_o++;
		}
		/*
		if(s[i]=='0')
		{
			S.push('0');
		}
		else
		{
			if(!S.empty() && S.top() == '0')
			{
				S.pop();
				ct++;
			}
			
		}
		*/ 
	}
	cout<<min(ct_z,ct_o)*2<<"\n";

	t2 = clock();
	float diff = (float)t2 - (float)t1;
	float execution_time = diff/CLOCKS_PER_SEC;
	//cout<<"\n"<<execution_time;
	//system("pause");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IO() assert(freopen("in.in", "rt", stdin)),assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl

inline int readChar();
template <class T = int> inline T readInt(); 
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x ); 
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline int readChar() {
	int c = getChar();
	while (c <= 32)
		c = getChar();
	return c;
}

template <class T>
inline T readInt() {
	int s = 1, c = readChar();
	T x = 0;
	if (c == '-')
		s = -1, c = getChar();
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getChar();
	return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
	if (write_pos == buf_size)
		fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
	write_buf[write_pos++] = x;
}

template <class T> 
inline void writeInt( T x, char end ) {
	if (x < 0)
		writeChar('-'), x = -x;

	char s[24];
	int n = 0;
	while (x || !n)
		s[n++] = '0' + x % 10, x /= 10;
	while (n--)
		writeChar(s[n]);
	if (end)
		writeChar(end);
}

inline void writeWord( const char *s ) {
	while (*s)
		writeChar(*s++);
}

struct Flusher {
	~Flusher() {
		if (write_pos)
			fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
	}
} flusher;

typedef long long ll;
const ll MOD=1e9+7;
const int N = 1e7+9, M = 1e5+9, OO = 0x3f3f3f3f;
const double EPS = 1e-10;


int main()
{
	#ifdef _LOCAL_DEFINE
	IO();
	#endif
    int n=readInt(),l=readInt();
	int mn = OO;
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		int x = l+i;
		sum+=x;
		mn = (abs(mn)>abs(x))?x:mn;

	}
	writeInt(sum-mn);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int i, n, m, min = 1000000, max = -1000000;
	long long int sum = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) 
	{
		scanf("%d", &m);
		if (m < min) 
		{
			min = m;
		} if (m > max) 
		{
			max = m;
		}
		sum += m;
     } 

	printf("%d %d %lld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const int INF = numeric_limits<int>::max();
int main()
{
	int N;
	cin >> N;

	int res{};
	REP2( i, 1, N + 1 )
	{
		res += i;
	}
	cout << res << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int N,M;
int n[100002];
int red[100002] = {};
int x,y;
int ans;
int main(){
  int i;
  scanf("%d %d",&N,&M);
   red[1] = 1;
   for(i = 0; i <= N; i++){
     n[i] = 1;
   }
 
  for(i = 0; i < M; i++){
    scanf("%d %d",&x,&y);

    if(red[x] == 1)red[y] = 1;
    n[x]--;
    n[y]++;
    if(n[x] == 0)red[x] = 0;
  }
  for(i = 1; i <= N; i++){
    if(red[i])ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**7)

# debug = True
# debug = False
#
# def dprint(*objects):
#     if debug == True:
#         print(*objects)

def solve():
    L, R = map(int, input().split())

    l = L % 2019
    r = R % 2019
    if R - L >= 2019:
        print(0)
        return

    if r <= l:
        r = min(r+2019, R)

    mn = 2019
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            md = i * j % 2019
            #print(i, j, md, mn)
            if md < mn:
                mn = md
    print(mn)
solve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int A,B,X;
    cin >> A >> B;
    X = 0;
    for(int i = 0; i < 2; i++){
        if(A > B){
            X += A; 
            A--;
        }else{
            X += B;
            B--;
        }
    }

    cout << X << endl;
}

Measured memory_bytes: 256
line = input().rstrip().split(' ')
n = int(line[0])
k = int(line[1])

ans = 0
i = 1
while n >= k:
    ans += (n % k) * i
    n = int(n / k)
    i *= 10
ans += n * i
s = str(int(ans))
print(len(s))

Measured memory_bytes: 3064
import numpy as np
N = int(input())
A = list(map(int,input().split())) + [10**6+1]
A.sort()
B = np.zeros(10**6+1)
count = 0
for i in range(N):
  if B[A[i]] == 0:
    B[::A[i]] = 1
    if A[i] != A[i+1]:
      count += 1
print(count)

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

signed
main(){
		int n;
		while(cin >> n and n!=0)
		{
				vector<string> s(n);
				for(int i=0;i<n;i++)
						cin >> s[i];

				for(int i=0;i<n;i++)
				{
						for(int j=s[i].size()-1;j>=0;j--)
						{
								if(s[i][j]=='.')
								{
										s[i][j] = '+';
										break;
								}
						}
				}
				vector<bool> line(1100,false);

				for(int i=n-1;i>=0;i--)
				{
						for(int j=0;j<s[i].size();j++)
						{
								if(line[j] && s[i][j]=='.')
								{
										s[i][j] = '|';
								}else if(s[i][j]=='+')
								{
										line[j] = true;
										for(int k=j+1;k<line.size();k++)
												line[k] = false;
										break;
								}
						}
				}

				
				for(int i=0;i<n;i++)
				{
						for(int j=s[i].size()-1;j>=0;j--)
						{
								if(s[i][j]=='.')
								{
										s[i][j] = ' ';
								}
						}
				}

				for(int i=0;i<n;i++)
						cout << s[i] << endl;

		}
}


Measured memory_bytes: 3656
#1 Doubling: O(log k)
# Python (3.8.2): TLE
# PyPy3
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, k = 4, 5
    A = [3, 2, 4, 1]

  else:
    ##INPUT 
    #n = input()
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  D = 60 # 10^18 is 60 digits, so we'll see to the 59th power of 2.
  MAX_N = 200005 #Namber of nodes
  to = [[0 for _ in range(MAX_N)] for _ in range(D)]

  # to[i][j]:nodes to 2^i away from j  
  for i in range(n):
    to[0][i] = A[i]
    to[0][i] -= 1

  # Doubling matrix
  for i in range(D-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]

  v = 0
  for i in range(D-1, -1, -1):
    l = 1<<i # Look go to 2^i
    if l <= k:
        v = to[i][v]
        k -= l

  print(v+1)
    
main()

Measured memory_bytes: 217948
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ans = p[:X]+q[:Y]+r[:X+Y]
ans.sort(reverse=True)
su = sum(ans[:X+Y])

print(su)

Measured memory_bytes: 23328
N=int(input())
XY=[[] for i in range(N)]

for i in range(N):
  A=int(input())
  for j in range(A):
    XY[i].append(list(map(int,input().split())))
#print(XY)

ans=0
for i in range(2**N):
  ch=1
  cnt=0
  for j in range(N):
    if i>>j & 1:
      cnt+=1
      for xy in XY[j]:
        if xy[1]==1 and (i>>(xy[0]-1)&1) or xy[1]==0 and (i>>(xy[0]-1)&1)==0:
          continue
        else:
          ch=0
          break
    if ch==0:
      break
  if ch:
    ans=max(ans,cnt)

print(ans)

Measured memory_bytes: 44912
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,T;
    cin >> N >> M >> T;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    int sum = V[0] - M;
    sum += max(0, T - V[N-1] - M);
    rep(i,1,N){
        sum += max(0, V[i] - V[i-1] - M * 2);
    }
    cout << sum << endl;
}


Measured memory_bytes: 3092
n=int(input())
c=input()
list=[0 for i in range(n+1)]
r=0
for i in range(n):
  if c[i]=='R':
    r+=1
w=0
list[0]=max(r,w)

#i corresponds to the right side boundary of c[i]
for i in range(n):
  if c[i]=='W':
    w+=1
  if c[i]=='R':
    r-=1
  list[i+1]=max(r,w)
print(min(list))

Measured memory_bytes: 17320
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int par[10010];

void init(int n){
	REP(i,n){
		par[i]=i;
	}
}

int find(int x){
	if(par[x]==x){
	   return x;
	}else{
	  return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x); y=find(y);
	if(x==y) return;

	par[x]=y;
}

bool same(int x,int y){
	return find(x)==find(y);
}

struct edge { int from,to,cost; };

bool comp(const edge& e1,const edge& e2){
	return e1.cost<e2.cost;
}

edge es[100010];

int V,E;

int kruskal(){
	sort(es,es+E,comp);
	init(V);
	int res=0;
	REP(i,E){
		edge e=es[i];
		if(!same(e.from,e.to)){
			unite(e.from,e.to);
			res+=e.cost;
		}
	}
	return res;
}

int main(void){

	          cin >> V >> E;
	          REP(i,E){
	        	  cin >> es[i].from >> es[i].to >> es[i].cost;
	          }

	          cout << kruskal() << endl;

	          return 0;
}

Measured memory_bytes: 4316
// Day10 HashMap AOJ0029
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    
    void main() {
        Scanner sc = new Scanner(System.in);

        String[] s = sc.nextLine().split(" ");
        HashMap<String,Integer> count = new HashMap<>();
        HashMap<String,Integer> length = new HashMap<>();
        for(int i=0;i<s.length;i++) {
            if(count.get(s[i]) == null) {
                count.put(s[i], 1);
                length.put(s[i], s[i].length());
            }else {
                count.replace(s[i], count.get(s[i])+1);
            }
        }
        int max = 0;
        int maxlen = 0;
        String m = "";
        String mlen = "";
        for(String key:count.keySet()) {
            m = (max < count.get(key) ? key:m);
            max = Math.max(count.get(key), max);
        }
        for(String key:length.keySet()) {
            mlen = (maxlen < length.get(key) ? key:mlen);
            maxlen = Math.max(length.get(key), maxlen);
        }
        
        System.out.println(m + " " + mlen);
    }
        
    
    public static void main(String[] args){
       new Main().main();
   }
}


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

public class Program {
    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        var arr = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();

        var head = 0;
        var tail = arr.Sum();

        var ansArr = new int[n];

        for (int i = 0; i < n; i++) {
            head += arr[i];
            tail -= arr[i];
            ansArr[i] = Math.Abs(head - tail);
        }

        Console.WriteLine(ansArr.Min());
    }
}


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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int sum = 0;
        int[] m = new int[N];
        for (int i = 0; i < N; i++) {
            m[i] = sc.nextInt();
            sum += m[i];
        }
        Arrays.sort(m);
        X = X - sum;
        System.out.println(N + X / m[0]);
    }
}


Measured memory_bytes: 23764
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
f=[1]
for i in range(n):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod
ans=0
for i in range(n-k+1):
  t=a[-1-i]
  ans=(ans+t*comb(n-i-1,k-1))
  ans%=mod
a=a[::-1]
for i in range(n-k+1):
  t=a[-1-i]
  ans=(ans-t*comb(n-i-1,k-1))
  ans%=mod
print(ans)

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> heights(n);
    for (int i = 0; i < n; i++)cin >> heights[i];

    vector<bool> good(n, true);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b, a--, b--;
        if (heights[a] <= heights[b])good[a] = false;
        if (heights[b] <= heights[a])good[b] = false;
    }

    int ret = 0;
    for (auto x:good) {
        if (x)ret++;
    }
    cout << ret << endl;
    return 0;
}

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

int main(){
    ll n;
    scanf("%lld",&n);

    int cnt=0;
    ll ans=100;
    while(ans<n){
        ans+=(ans/100)*1;
        cnt++;
    }
    printf("%d\n",cnt);


    return 0;
}


Measured memory_bytes: 3760
<?php
    $num = explode(" ",trim(fgets(STDIN)));
   
    $num[0]= intval($num[0]);
    $num[1]= str_replace(".","",$num[1]);
    
    
    
    $answer =  intval($num[1])*($num[0]);
    
    if($answer<1000){
        echo floor($answer/100);
        exit;
    }
    
    $answer = strval($answer);
    
    $answer = str_split($answer);
    
    array_pop($answer);
    array_pop($answer);

    
    foreach ($answer as $value) {
        echo $value;
    }

?>

Measured memory_bytes: 16104
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define sc(x) scanf("%d",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int _,t,a,b,n,m,k,x;

int A[500005];
const double EPS = 1e-8;
int y;
char s[500004];
int q;
const int M = 200000;
signed main()
{
    scanf("%s",s+M);
    int len = strlen(s+M);
    int i=M-1,j=len+M;
    sc(q);
    int f=0;
    char c;
    while(q--)
    {
        sc(t);
        if(t==1)
        {
            f^=1;
        }
        else
        {
            sc(t);
            if(t==2)
            {
                cin>>c;
                //scanf("%c",&c);
                if(f)
                {
                    s[i--]=c;
                }
                else
                {
                    s[j++]=c;
                }
            }
            else
            {
                cin>>c;
                if(f)
                {
                    s[j++]=c;
                }
                else s[i--]=c;

            }
        }

    }

    if(!f)
        for(int k=i+1;k<j;k++)cout<<s[k];
    else
     for(int k=j-1;k>i;k--)cout<<s[k];
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}


void solve(int N){
    string S[100];
    string p[100];
    set<string>n[100];
    map<string,int>ps;
    vector<int>G[100];

    rep(i,N){
        cin>>S[i];
        int x=find(all(S[i]),':')-S[i].begin();
        p[i]=S[i].substr(0,x);
        S[i]=S[i].substr(x+1,S[i].size()-x-1);
        ps[p[i]]=i;
    }

    rep(i,N){
        while(S[i].size()){
            int x=0;
            while(isalpha(S[i][x]))x++;
            string t=S[i].substr(0,x);
            S[i]=S[i].substr(x+1,S[i].size()-x-1);
            if(ps.find(t)!=ps.end())G[ps[t]].pb(i);
            else n[i].insert(t);
        }
    }

    int deg[100]={0};
    queue<int>que;
    rep(i,N)for(auto to:G[i])deg[to]++;
    rep(i,N)if(deg[i]==0)que.push(i);
    while(que.size()){
        int v=que.front();que.pop();
        for(auto to:G[v]){
            n[to].insert(all(n[v]));
            if(--deg[to]==0)que.push(to);
        }
    }

    cout<<n[0].size()<<endl;
}

signed main(){
    int N;
    while(cin>>N,N)solve(N);
    return 0;
}

Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	int n;
	cin>>n;
	vector<double> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-p[i-1]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
		}
	}
//	for(int i=0;i<=n;i++)
//	{
//		for(int j=0;j<=n;j++)
//		{
//			cout<<dp[i][j]<<' ';
//		}
//		cout<<'\n';
//	}
	double ans=0.0;
	for(int i=n/2+1;i<=n;i++)
	{
		ans+=dp[n][i];
	}
	cout<<setprecision(10)<<ans<<'\n';
}

int main()
{
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 70656
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();

const getAns = (K: number): number => {
  let cnt = 0;
  const hits = new Map<number, boolean>();

  let tmp = 7;
  // eslint-disable-next-line no-constant-condition
  while (true) {
    cnt++;
    const r = tmp % K;

    if (r === 0) return cnt;
    else if (hits.get(r)) return -1;

    hits.set(r, true);
    tmp = (10 * tmp + 7) % K;
  }
};

{
  const K = nCin();
  const ans = getAns(K);
  console.log(ans);
}


Measured memory_bytes: 90748
// https://atcoder.jp/contests/abc159/submissions/11141024
// - Broute Force

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int K = sc.nextInt();
    String[] S = new String[H];
    for (int i = 0; i < H; i++) {
      S[i] = sc.next();
    }
    int ans = Integer.MAX_VALUE;
    // 1-split creates 2 groups.
    for (int div = 0; div < 1 << (H - 1); div++) {
      int grp = 0;
      int[] id = new int[H];
      for (int i = 0; i < H; i++) { // Assign each row to a group.
        id[i] = grp;
        if (((div >> i) & 1) == 1) {
          grp++;
        }
      }

      int[][] choco = new int[grp + 1][W]; // Group is [0, grp].
      // Count white-choco in each group per column.
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          choco[id[i]][j] += S[i].charAt(j) - '0';
        }
      }

      int num = grp;
      int[] now = new int[grp + 1];
      for (int col = 0; col < W; col++) {
        if (!add(col, now, choco, K)) {
          num++;
          now = new int[grp + 1];
          if (!add(col, now, choco, K)) {
            num = Integer.MAX_VALUE;
            break;
          }
        }
      }
      ans = Math.min(ans, num);
    }
    System.out.println(ans);
  }

  static boolean add(Integer col, int[] now, int[][] choco, int K) {
    for (int i = 0; i < now.length; i++) now[i] += choco[i][col];
    for (int i = 0; i < now.length; i++) if (now[i] > K) return false;
    return true;
  }
}


Measured memory_bytes: 40384
N = int(input())
H = [int(i) for i in input().split()]
if N == 1:
    print("Yes")
    exit()
for i in range(N-1, 0, -1):
    if H[i-1] <= H[i]:
        continue
    elif H[i-1]-1 == H[i]:
        H[i-1] -= 1
    else:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c,x;cin>>a>>b>>c>>x;
  int ans=0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        if(500*i+100*j+50*k==x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	int cnt = 0;
	
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i-1]) cnt++;
	}
	
	cout << cnt;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

    int ans = 1;
    Rep(i, 1, n)
    {
        rep(j, i)
        {
            if (h[i] < h[j]) break;
            if (j == i - 1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0,c=1,b;
    cin>>n;
    vector<int>a(n);
    cin>>a[0];
    b=a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]==b){c++;}
        else if(a[i]!=b){ans+=c/2;c=1;b=a[i];}
        
    }
    ans+=c/2;
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[1000]={};
	int x[1000]={};
	int n,w;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >>w;
		a[i]=a[i-1]+w;
	}
	for(int i=0;i<n;i++){
		x[i]=(a[n]-a[i])-a[i];
		if(x[i]<0){
			x[i]*=-1;
		}
	}
	sort(x,x+n);
	cout << x[0] << '\n';
return 0;
}	


Measured memory_bytes: 256