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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  int ans = 0;
  for (int i = 1, y = 0; y < x; i++) {
    y += i;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
  int N,X;
  cin>>N>>X;
  int M[N];
  for(int i=0;i<N;i++){
    cin>>M[i];
  }
  sort(M,M+N);
  int sum=0;
  for(int i=0;i<N;i++){
    sum=sum+M[i];
  }
  int plus=0;
  plus=(X-sum)/M[0];
  cout<<N+plus<<endl;

  return 0;
}

  

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Psi = P<string,int>;
using Pdd = P<double,double>;

// Run Length Encoding
V<Psi> RLE(string s){
    V<Psi> rle; 
    string r = "";
    int cnt = 0;
    for(int i=0; i<s.size(); i++){
        string c = s.substr(i,1);
        if(c == r){
            cnt++;
        }else{
            if(cnt!=0) rle.pb(mp(r,cnt));
            r = c;
            cnt = 1;
        }
    }
    rle.pb(mp(r,cnt));
    return rle;
}

int main(){
    string s;
    cin>>s;
    auto rle = RLE(s);

    REP(i,rle.size()/2){
        int r = rle[i*2].se;
        int l = rle[i*2+1].se;
        int r_num = 0;
        int l_num = 0;
        REP(j,r){
            if(j%2 == 0){
                r_num++;
            }else{
                l_num++;
            }
        }
        REP(j,l){
            if(j%2 == 0){
                l_num++;
            }else{
                r_num++;
            }
        }
        REP(j,r-1) cout<<0<<" ";
        cout<<r_num<<" "<<l_num<<" ";
        REP(j,l-1) cout<<0<<" ";
    }
    cout<<endl;
    return 0;
}

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


void swap(int& a, int& b){
	int tmp = a;
	a = b;
	b = tmp;
}

int main(){
	int N;cin >> N;
	int a[N];
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=N-1;j>i;j--){
			if(a[j-1]>a[j]){
				swap(a[j-1],a[j]);
				ans++;
			}
		}
	}
	for(int i=0;i<N;i++){
		if(i == N-1) {
			cout << a[i] << endl;
		}else {
			cout << a[i] << " ";
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3124
L, R = map(int, input().split())
mod = 2019

if R - L >= 2019:
    print(0)
else:
    ans = float('inf')
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i * j) % mod, ans)
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long lli;
using namespace std;
struct Water{
	lli v;
	double t;
}w[500010];
lli maxv,n,sumv,t,v,l=1,r;
double s;
int main()
{
	scanf("%lld%lld",&n,&maxv);
	while(n--){
		scanf("%lld%lld",&t,&v);
		while(sumv+v>maxv){
			lli out=min(w[l].v,sumv+v-maxv);
			w[l].v-=out;
			sumv-=out;
			s-=1.0*w[l].t*out;
			if(!w[l].v) l++;
		}
		w[++r].t=1.0*t,w[r].v=v;
		s+=t*v;
		sumv+=v;
		while(l<r&&w[r-1].t>w[r].t){
			w[--r].t=1.0*(w[r].t*w[r].v+w[r+1].t*w[r+1].v)/(w[r].v+w[r+1].v);
			w[r].v+=w[r+1].v;
		}
		printf("%.7f\n",1.0*s/maxv);
	}
}

Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, K;
  cin >> N >> K;
  vector <int> H(N);
  rep(i,N) cin >> H[i];
  sort(all(H));
  K = min(K, N);
  rep(i,K) H.pop_back();
  ll ans = 0;
  rep(i,H.size()) ans += H[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4032
#include<stdio.h>
#include<string.h>

int main(){
    int ans = 1;
    char s[200001];
    scanf("%s", s);
    for(int i=1; i<strlen(s); i++){
        if(s[i-1] != s[i]){
            ans++;
        }else{
            if(i == strlen(s)-1){
                break;
            }else if(i == strlen(s)-2){
                ans++;
                break;
            }
            ans += 2;
            i += 2;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>

#define MAX 1000000001
#define M    500000
using namespace std;

int count=0;
vector<int> L(M/2+2);
vector<int> R(M/2+2);

  void merge(int A[],int n,int left,int mid, int right){
    int  n1 = mid - left;
    int  n2 = right - mid;

    for(int i=0;i< n1;i++){
      L[i]= A[left+i];
    }
    for(int i=0;i< n2; i++){
      R[i]=A[mid + i];
    }
    L[n1]=MAX;
    R[n2]=MAX;
    int i=0;
    int j=0;
    for(int k= left ; k< right ; k++){
      count++;
      if(L[i]<=R[j]){
        A[k] = L[i];
        i++;
      }
      else {
        A[k] = R[j++];
      }
    }
  }


void mergeSort(int A[], int n,int left, int right){
  if ((left+ 1)< right){
    int    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int n=0;
  cin>>n;
  int A[M];
  for(int i=0;i<n;i++){
    cin>> A[i];
  }

  mergeSort(A,n, 0, n);

  for(int i=0;i< n; i++){
    cout<< A[i];
    if(i != n-1){
      cout<<" ";
    }
  }
  cout<< endl;
  cout<< count<<endl;

  return 0;
}



Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};


signed main() {
int h,w;
cin>>h>>w;
int a[h][w];
for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
int b;
for(int i=0;i<h;i++)for(int j=0;j<w;j++){
    cin>>b;
    a[i][j]=abs(a[i][j]-b);
}
bool k[w][6401],x[6401];for(int i=0;i<w;i++)fill(k[i],k[i]+6401,false);
fill(x,x+6401,false);
x[a[0][0]]=true;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        
        if(i>0){
            for(int t=0;t<=6400;t++){
                if(k[j][abs(t-a[i][j])])x[t]=true;
                if(t+a[i][j]<6401&&k[j][t+a[i][j]])x[t]=true;
            }
        }
        swap(k[j],x);
        if(j>0){
            for(int t=0;t<=6400;t++){
                if(k[j-1][abs(t-a[i][j])])k[j][t]=true;
                if(t+a[i][j]<6401&&k[j-1][t+a[i][j]])k[j][t]=true;
            }
        }

        fill(x,x+6401,false);
    }
}
for(int i=0;i<=6400;i++){
    if(k[w-1][i]){
        cout<<i;
        return 0;
    }
}




return 0;
}


Measured memory_bytes: 768
x, k, d = map(int, input().split())
x = abs(x)

s = x // d

if s > k:
  nx = x - k * d
  print(nx)

else:
  nx = x - s * d
  nk = k - s
  if nk % 2 != 0:
    nx = abs(nx - d)
  print(nx)

Measured memory_bytes: 9188
import math
import numpy as np
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
alice=0
bob=0
k=math.floor(n/2)
if (n%2)==0:
    for i in np.arange(1,k+1):
        alice+=a[2*i-2]
        bob+=a[2*i-1]
if (n%2)==1:
    for i in np.arange(1,k+1):
        alice+=a[2*i-2]
        bob+=a[2*i-1]
    alice+=a[n-1]  
print(alice-bob)

Measured memory_bytes: 27120
#include "bits/stdc++.h"
using namespace std;

int main(void) {
	int n, m;
	cin >> n;
	string s[n];
	for(int i=0;i<n;i++) cin >> s[i];
	cin >> m;
	string t[m];
	for(int i=0;i<m;i++) cin >> t[i];

	int counts, countt;
	int ans=0;

	for(int i=0;i<n;i++) {
		counts=0;
		countt=0;
		for(int j=0;j<n;j++) {
			if(s[i] == s[j]) counts++;
		}
		for(int k=0;k<m;k++) {
			if(s[i] == t[k]) countt++;
		}
		ans = max(ans, counts-countt);
	}
	
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = (int)(k);i < (int)(n);i++)
int main() {
  int N;cin >> N;
  vector<vector<int>> dp(N+1, vector<int>(3, 0));
  vector<int> a(N), b(N), c(N);
  rep(i, 1, N+1) cin >> a[i] >> b[i] >> c[i];
  rep(i, 1, N+1) {
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
    dp[i][1] = max(dp[i-1][2] + b[i], dp[i-1][0] + b[i]);
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
  }
  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 9780
//============================================================================
// 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//============================================================================
long maxval(long x, long y)
{
    if (x<y)
        return y;
    return x;
}
long minval(long x, long y)
{
    if (x<y)
        return x;
    return y;
}
//============================================================================
#define MAXVAL 2000000000
int main(void)
{
    long i,j,k, max, min, N, *Array;

    scanf("%ld", &N);
    Array = malloc(N*sizeof(long));
	for (i=0; i<N; i++)
        scanf("%ld", &Array[i]);
    //for (i=k=0, max=-MAXVAL, min=MAXVAL; i<N-1; i++)
    //if (Array[i]<min){
    //    min=Array[i];
    //    k=i;
    //}
    //max=-MAXVAL;
    for (j=1, max=-MAXVAL, min=*Array; j<N; j++){
        max=maxval(Array[j]-min, max);
        min=minval(Array[j], min);
        //printf("max=%ld, min=%ld\n", max, min);
    }
    free(Array);
    printf("%ld\n", max);
    return 0;
}
//============================================================================

Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x;
	cin>>x;
	for(ll i=2;;i++){
		ll now=i;
		bool ch=true;
		for(ll j=2;j<=sqrt(i);j++){
			if(now%j==0){
				ch=false;
				break;
			}
		}
		if(ch){
			if(i>=x){
				cout << i;
				return 0;
			}
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 1e5+5, MOD = 998244353;

int R[MN], B[MN], G[MN], L[MN], H[MN];

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	int N; cin >> N;
	for (int i = 0, r = 0, g = 0, b = 0; i < 3*N; ++i) {
		char c; cin >> c;
		if (c == 'R') R[r++] = i;
		else if (c == 'B') B[b++] = i;
		else G[g++] = i;
	}

	for (int i = 0; i < N; ++i)
		L[i] = min({ R[i], B[i], G[i] }), H[i] = max({ R[i], B[i], G[i] });
	
	ll ans = 1;
	for (int i = 0, l = 0, h = 0, x = 0, y = 0; i < 3*N; ++i) {
		if (l < N && L[l] == i) ++x, ++l;
		else if (h < N && H[h] == i) (ans *= y--) %= MOD, ++h;
		else (ans *= x--) %= MOD, ++y;
	}
	for (int i = 1; i <= N; ++i) (ans *= i) %= MOD;
	cout << ans;
}


Measured memory_bytes: 5572
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = readline().decode().rstrip()
N = len(S)
for i in range(N-1):
    if  S[i] == S[i+1]:
        print(i+1,i+2)
        sys.exit()
    if i+2 <= N-1:
        if S[i] == S[i+2]:
            print(i+1,i+3) 
            sys.exit()
print(-1,-1)

Measured memory_bytes: 70096
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll dp[301][301][301];
int N, M;
struct constraint{
    int l, x;
};

vector<constraint> v[301];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int l, r, x;
        cin >> l >> r >> x;
        v[r].push_back((constraint){l, x});
    }
    dp[0][0][0] = 1;
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < i; j++){
            for(int k = 0; k < i; k++){
                dp[i][j][k]     =   (dp[i][j][k]        +   dp[i-1][j][k])%MOD;
                dp[k][i][j]     =   (dp[k][i][j]        +   dp[k][i-1][j])%MOD;
                dp[j][k][i]     =   (dp[j][k][i]        +   dp[j][k][i-1])%MOD;
                dp[i-1][i][k]   =   (dp[i-1][i][k]      +   dp[i-1][j][k])%MOD;
                dp[k][i-1][i]   =   (dp[k][i-1][i]      +   dp[k][i-1][j])%MOD;
                dp[i][k][i-1]   =   (dp[i][k][i-1]      +   dp[j][k][i-1])%MOD;
                dp[i-1][j][i]   =   (dp[i-1][j][i]      +   dp[i-1][j][k])%MOD;
                dp[i][i-1][j]   =   (dp[i][i-1][j]      +   dp[k][i-1][j])%MOD;
                dp[j][i][i-1]   =   (dp[j][i][i-1]      +   dp[j][k][i-1])%MOD;
            }
        }
        dp[1][0][0] = 1; dp[0][1][0] = 1; dp[0][0][1] = 1;
        for(int j = 0; j < i; j++){
            for(int k = 0; k < i; k++){
                for(auto iter = v[i].begin(); iter != v[i].end(); iter++){
                    int l = iter->l;
                    int x = iter->x;
                    int cnt = 1;
                    if(j >= l) cnt++;
                    if(k >= l) cnt++;
                    if(cnt != x) {
                        dp[i][j][k] = 0;
                        dp[k][i][j] = 0;
                        dp[j][k][i] = 0;
                    } 
                }
                if(i == N){
                    ans += 3*dp[i][j][k];
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 213376
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];


int main() {
	scanf("%lld", &N);
	ll sum = 0;
	ll cnt = 0;
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		if(arr[i] < 0) {
			arr[i] = -arr[i];
			cnt++;
		}
		sum += abs(arr[i]);
	}
	// cout << sum << " ";
	sort(arr, arr + N);
	if(cnt % 2) {
		sum -= 2 * arr[0];
	}
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int n;
    double v[50];
    int i,j,k;
    cin>>n;
    for(i=0;i<n;i++)cin>>v[i];
    sort(v,v+n);
    for(i=1;i<n;i++)v[i]=(v[i]+v[i-1])/2.0;
    cout<<v[n-1]<<endl;
}

Measured memory_bytes: 256
import math
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

A.sort()

D = defaultdict(int)
for a in A:
    D[a] += 1

B = [False] * (10**6 + 1)

ans = 0

for a in A:
    if B[a] == False:
        c = 1
        i = a * c
        while i <= 10 ** 6:
            B[i] = True
            c += 1
            i = a * c
        if D[a] == 1:
            ans += 1

print(ans)


Measured memory_bytes: 121196
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <stack>
#include<cassert>
#include <cfloat>
#include <list>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define testMyStupedCode TCF--
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
void ReadFromFile( string name , string extention ){
    string fullPath = name + "." + extention ;
    freopen( fullPath.c_str() , "r" , stdin ) ;
}
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline char C(){
    char c ;
    scanf( "%c" , &c ) ;
    return c ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e5 + 5;
ll dp[N];
int w[101], v[101];
ll inf = 1e13 + 5, n;
int main(){
     //freopen("//Users//Mr.X//Desktop//tests//tst.text", "r", stdin);
     n = D();
     int W = D();
     int V = 0;
     for(int i = 0; i < n; ++i){
          w[i] = D(), v[i] = D();
          V += v[i];
     }
     for(int i = 0; i <= V; ++i)
          dp[i] = inf;
     dp[0] = 0;
     for(int i = 0; i < n; ++i)
          for(int j = V - v[i]; j >= 0; --j)
               dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
     int ans = 0;
     for(int i = 0; i <= V; ++i)
          if(dp[i] <= W)
               ans = max(ans, i);
     printf("%d", ans);
     return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		int d = b + c;
		if (a < d) {
			System.out.println(d - a);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21204
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

min = 10
min_index = 0
time = 0

data = []

data.append(a)
data.append(b)
data.append(c)
data.append(d)
data.append(e)

for i in range(0, 5):
	if data[i] % 10 < min and data[i] % 10 > 0:
		min = data[i] % 10
		min_index = i
for i in range(0, 5):
	if i == min_index:
		continue
	if data[i] % 10 == 0:
		time += data[i]
	else:
		time += ((int(data[i] / 10) + 1) * 10)
	
print(time + data[min_index])

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,j,k,Num,alpha[Num];
	scanf("%d",&Num);
	for( i=0; i<Num; i++){
		scanf("%d",&alpha[i]);
	}
	for( j=0; j<Num; j++){
	for( k=0; k<Num-1; k++){
		if(alpha[k] > alpha[k+1]){
		int tem = alpha[k];
		alpha[k] = alpha[k+1];
		alpha[k+1] = tem;
		}
	}
	}
	printf("%d",alpha[Num-1]-alpha[0]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define stpr setprecision
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

long double dp[3007][3007],sum=0;

int main(){
    ll N;cin >> N;
    long double p[3007];
    rep(i,N){
        cin >> p[i];
    }
    dp[0][0]=1;
    rep(i,N+1){
        rep(j,N+1){
            if(i>j&&i+j==N){
                sum+=dp[i][j];
            }
            if(i+j>=N){
                break;
            }
            dp[i+1][j]+=dp[i][j]*p[i+j];
            dp[i][j+1]+=dp[i][j]*(1-p[i+j]);
        }
    }
    cout << stpr(10) << sum << endl;
}

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1 << 29;

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

  vector<vector<P>> edge(n);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v, c;
      cin >> v >> c;
      edge[u].push_back(P(c, v));
    }
  }

  vector<int> dist(n, INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[0] = 0;
  que.push(P(0, 0));
  while (!que.empty()) {
    P p = que.top();
    que.pop();

    for (int i = 0; i < edge[p.second].size(); i++) {
      if (dist[edge[p.second][i].second] > p.first + edge[p.second][i].first) {
        dist[edge[p.second][i].second] = p.first + edge[p.second][i].first;
        que.push(
            P(p.first + edge[p.second][i].first, edge[p.second][i].second));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << dist[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 7788
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 2e5 + 55, mod = 1e9 + 7 , i2 = (mod+1)/2;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	string s(n, '\0');
	int x;
	char c;
	while(m--) {
		cin >> x >> c, x--;
		if(s[x]=='\0') s[x] = c;
		if(s[x] != c) return cout << -1, 0;
	}
	for(int i = 0; i < n; i++) {
		if(s[i]=='\0') s[i] = i || n == 1 ?'0':'1';
	}
	if(s[0]=='0'&&n>1) return cout << -1, 0;
	cout << s;
}



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

int main(){
    int n; cin >> n;
    string a,b,c; cin >> a >> b >> c;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i] && b[i] == c[i]) continue;
        else if((a[i] == b[i] && b[i] != c[i]) || (b[i] == c[i] && a[i] != b[i]) || (c[i] == a[i] && c[i] != b[i])) cnt++;
        else cnt += 2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 2020;
char s[maxn][maxn];
bool ok[maxn][maxn];
int up[maxn];
int lmin[maxn], rmin[maxn];

int main() {
	int n = read, m = read;

	for(int i = 1; i <= n; i ++)
		scanf("%s", s[i] + 1);

	for(int i = 1; i < n; i ++)
		for(int j = 1; j < m; j ++) {
			int x = (s[i][j] == '#') + (s[i][j + 1] == '#') +
				(s[i + 1][j] == '#') + (s[i + 1][j + 1] == '#');
			ok[i][j] = !(x & 1);
		}

	int ans = std::max(n, m);

/* 	for(int i = 1; i < n; i ++) { */
/* 		for(int j = 1; j < m; j ++) */
/* 			debug("%c", ".#"[ok[i][j]]); */
/* 		debug("\n"); */
/* 	} */

	for(int i = 1; i < n; i ++) {
		for(int j = 1; j < m; j ++)
			if(ok[i][j]) ++ up[j];
			else up[j] = 0;

		for(int j = 1; j < m; j ++) {
			int &l = (lmin[j] = j - 1);
			while(l and up[l] >= up[j])
				l = lmin[l];
		}

		for(int j = m - 1; j; j --) {
			int &r = (rmin[j] = j + 1);
			while(r < m and up[r] >= up[j])
				r = rmin[r];
		}

		for(int j = 1; j < m; j ++)
			ans = std::max(ans, (up[j] + 1) * (rmin[j] - lmin[j]));
	}

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


Measured memory_bytes: 8064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed dp[1<<26];

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

    string s;
    cin >> s;
    int n = SZ(s);
    vector<int> a(n + 1);

    rep(i, n){
        a[i+1] = a[i] ^ (1 << (s[i] - 'a'));
    }

    rep(i, 1 << 26){
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        if(__builtin_popcount(a[i]) <= 1){
            dp[a[i]] = 1;
        }
        rep(j, 26){
            int x = (1 << j) ^ a[i];
            dp[a[i]] = min(dp[a[i]], dp[x] + 1);
        }
    }
    cout << dp[a[n]] << endl;

    return 0;
}


Measured memory_bytes: 264316
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MAX 200000
typedef long long ll;
using namespace std;
int n;
ll cnt=0;
int A[MAX];
int L[MAX/2+2];
int R[MAX/2+2];

void merge(int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (size_t i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (size_t i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INTINF;
  R[n2] = INTINF;
  int i=0;
  int j=0;
  for (size_t k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt+=n1-i;
    }
  }
}


void mergesort(int left, int right){
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergesort(left, mid);
    mergesort(mid, right);
    merge(left, mid, right);
  }
}


int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cin >> n;
  for (size_t i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  mergesort(0,n);

  std::cout << cnt << '\n';

  return 0;
}



Measured memory_bytes: 4768
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int b[30];
int main(){
	int n,m,c;
	cin>>n>>m>>c;
	for(int i = 0; i < m; i++){
		cin>>b[i];
	}
	int ans = 0;
	for(int i = 0 ; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			int a;
			cin>>a;
			sum+=a*b[j];
		}
		if(sum+c>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;


ll N;
ll a[100001];
void swap(ll *p, ll *q)
{
    ll temp;
    temp = *p; 
    *p = *q;
    *q = temp;
}

void partition(ll p, ll q, ll *jp, ll *ip)
{
    ll i, j, s;
    i = p; j = q; s = a[p];
    while(i <= j){
        while(a[i] < s) i++;
        while(a[j] > s) j--;
        if(i <= j){
            swap(&a[i], &a[j]);
            ++i; --j;
        }
    }
    *jp =j; *ip = i;
}

void qsort(ll p, ll q)
{
    ll i, j;

    if(p < q){
        partition(p, q, &j, &i);
        qsort(p, j);
        qsort(i, q);
    }
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    
    ll h1 = 0, h2 = 0;
    ll i = N-1;
    while(!h1 && i > 0){
        if(a[i] == a[i - 1]){
            h1 = a[i];
            i--;
        }
        i--;
    }
    while(!h2 && i > 0){
        if(a[i] == a[i - 1]){
            h2 = a[i];
        }
        i--;
    }

    cout << h1 * h2 << '\n';

    return 0;
    
}


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

using namespace std;

void solve()
{
    int even=0;

    string s;
    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='+')
            even++;
        else
            even--;
    }
    cout<<even<<endl;
}

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

    solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
using namespace std;

int N;
vector<vector<int>> to, weight;

const int INIT = -1;
vector<int> color;

void dfs(int pos)
{
    for (int i = 0; i < (int)to[pos].size(); i++) {
        int dst = to[pos][i];
        if (color[dst] != INIT)
            continue;

        color[dst] = color[pos] + weight[pos][i];
        color[dst] %= 2;

        dfs(dst);
    }
}

int main(void)
{
    cin >> N;

    to = vector<vector<int>>(N, vector<int>());
    weight = vector<vector<int>>(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;

        u--;
        v--;
        w %= 2;

        to[u].push_back(v);
        weight[u].push_back(w);

        to[v].push_back(u);
        weight[v].push_back(w);
    }

    
    color = vector<int>(N, INIT);
    color[0] = 0;

    queue<int> task;
    task.push(0);

    while (task.empty() != true) {
        int src = task.front();
        task.pop();

        for (int i = 0; i < (int)to[src].size(); i++) {
            int dst = to[src][i];
            if (color[dst] != INIT)
                continue;

            color[dst] = (color[src] + weight[src][i]) % 2;

            task.push(dst);
        }
    }

    //dfs(0);

    for (int i = 0; i < N; i++)
        cout << color[i] << endl;

    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <cmath>
#include <limits>

int main() {
    int N, T, A;
    std::cin >> N >> T >> A;

    int t = (T - A) * 1000;

    int H;
    int i_min, e_min = std::numeric_limits<int>::max();
    for (int i = 1; i <= N; i++) {
        std::cin >> H;
        int e = std::abs(H * 6 - t);
        if (e < e_min) {
            e_min = e;
            i_min = i;
        }
    }

    std::cout << i_min << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[3];
int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<((a[0]&1&a[1]&1&a[2]&1)?a[0]*a[1]:0)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] strv = br.readLine().split(" ");
        double[] v = Stream.of(strv).mapToDouble(Double::parseDouble).toArray();

        PriorityQueue<Double> pq = new PriorityQueue<>();
        
        for(int i = 0; i < N; i++){
            pq.add(v[i]);
        }
        
        while( pq.size() > 1 ) {
            double a = pq.poll();
            double b = pq.poll();
            pq.add( (a + b) / 2 ) ;
        }

        System.out.println(pq.poll());
    }
}


Measured memory_bytes: 28500
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



vector<int> vec[20];
int p[20];
signed main(){
  int n, m;cin >> n >> m;
  rrep(i,m){
    int k;cin >> k;
    rrep(j,k){
      int tmp;cin >> tmp;
      vec[i].pb(tmp);
    }
  }
  rrep(i,m)cin >> p[i];
  
  int ans = 0;
  rep(bit,1<<n){
    int cnt2 = 0;
    rrep(i,m){
      int cnt = 0;
      rep(j,vec[i].size()){
        int sw = vec[i][j]-1;
        if((bit>>sw) & 1 == 1)cnt++;
      }
      if(cnt%2 == p[i])cnt2++;
    }
    if(cnt2 == m)ans++;
  }
  cout << ans << endl;
  return 0;
}






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

typedef long long  ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define INPUT(arr,n) for(ll i = 0;i<n;i++) cin>>arr[i];
#define PRINT(arr,n) for(ll i = 0;i<=n;i++) printf("%lld ",arr[i]);printf("\n");
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define mp make_pair
#define pb push_back

const ll NMAX = 3000+7;
const ll MOD = 1000*1000*1000+7;
const ll INT_BITS = 32 ;
double arr[NMAX];

double dp[NMAX][NMAX];

ll N;

double func(ll i, ll k){
  if(i == -1 ){
    if( N / 2 < k) return 1;
    return 0;
  }
  if(dp[i][k]>-1.0)return dp[i][k];

  double res = func(i-1,k)*(1-arr[i])+ func(i-1,k+1)*arr[i];
  dp[i][k] = res;
  // cout<<i<<" "<<k<<" "<<res<<endl;
  return res;
}

int main(int argc, char const *argv[])
{
	cin>>N;
  MEM(dp,-1);
  INPUT(arr,N);
  printf("%0.10f\n",func(N-1,0) );
  // cout<<dp[N-1][0]<<endl;
  // double ans = 0;
  // for(ll i = 0;i<N;i++)
  // for (ll k =0;k<N;k++)
  //   cout<<dp[i][k]<<" ";
  //   // ans+=dp[N-1][k];
  // cout<<ans<<endl;
	return 0;
}

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

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

  int total = 0;
  int maxp = 0;
  for (int i = 0; i < N; ++i) {
    int p;
    cin >> p;
    total += p;
    maxp = max(maxp, p);
  }

  cout << total - maxp / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100007];
long long mem[100007];
long long res = 0;

//long long swim(int i,int lst=a[0])
//{
//    if(i == n)
//        return a[i];
//    if(i>n)
//        return 1e10 ;
////    long long &r = mem[i];
////    if(~r)
////        return mem[i];
//    res = min(swim(i+1,a[i]) + abs(lst-a[i+1]),swim(i+2,a[i]) + abs(lst-a[i+2]));
////    cout<<i<<" "<<abs(a[i]-swim(i+1,a[i]))<<" "<<abs(a[i]-swim(i+2,a[i]))<<endl;
//    return res;
//}

int main()
{
    int k;
    cin>>n>>k;
    memset(mem,-1,sizeof(mem));
    for(int i=0;i<n;++i)
        cin>>a[i];
//    cout<<min(swim(1,a[0]),swim(2,a[0]))<<endl;
    mem[0]=0;
    //mem[0]=abs(a[0]-a[1]);
    for(int i=1;i<n;++i)
    {
        mem[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i-j<0)
                break;
            mem[i] = min(mem[i-j]+ abs(a[i]-a[i-j]) ,mem[i]);
        }
    }
    cout<<mem[n-1]<<endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;
const string sp = " ";

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

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

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};

int n, k, q;
int a[100010];

signed main() {
	cin >> n >> k >> q;
	rep(i, n) {
		a[i] = k - q;
	}
	rep(i, q) {
		int b;
		cin >> b;
		b--;
		a[b]++;
	}
	rep(i, n) {
		if (a[i] <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main() {
    string S;
    cin >> S;
    string ans;
    for(char &s : S) {
        if(s == 'B') {
            if(!ans.empty()) {
                ans.erase(ans.end() - 1, ans.end());
            }
        } else {
            ans += s;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	string ans;
	cin >> str;
	for (auto &c : str)
	{
		if (ans.empty()) ans.push_back(c);
		else
		{
			if (ans.back() == c) ans.push_back(c);
			else
			{
				if (c == 'T') ans.pop_back();
				else ans.push_back(c);
			}
		}
	}
	cout << ans.length() << endl;
	return 0;
}

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

int main() {
  int N;
  string n = "Three",S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      n = "Four";
      break;
    }
  }
  cout << n << endl;
}



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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	string s,t;cin>>s>>t;
	ll res=0;
	for(int i=0;i<s.size();++i)res+=(s[i]!=t[i]);
	cout<<res<<endl;
}


Measured memory_bytes: 3836
package main
import (
  "fmt"
  "bufio"
  "os"
  "strings"
)

var sc = bufio.NewScanner(os.Stdin)
func main() {
  sc.Scan()
  strScan := sc.Text()
  judge := true
  
  strlen := len(strScan)
  for i:=0; i<strlen; i++ {
    even := 0
    odd := strings.Index("RUD",fmt.Sprintf("%c",strScan[i]))
    if i+1 < strlen {
	  even = strings.Index("LUD",fmt.Sprintf("%c",strScan[i+1]))
    }
    if odd == -1 || even == -1 { 
      judge = false 
      break 
    }
    i++
  }
  
  if judge == true {
    fmt.Println("Yes")
  } else { 
    fmt.Println("No")
  }
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();
        String[] data = new String[H];
        for (int i = 0; i < H; i++) {
            data[i] = sc.next();
        }
        int result = 0;
        for (int row = 0; row < (1 << H) - 1; row++) {
            for (int col =0; col < (1<<W) -1; col++) {
                int totalBlack = 0;
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        if (((1<<i) & row) > 0) {
                            continue;
                        }
                        if (((1<<j) & col) > 0) {
                            continue;
                        }
                        if (data[i].charAt(j) == '#') {
                            totalBlack++;
                        }
                    }
                }
                if (totalBlack == K) {
                    result++;
                }
            }
        }
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 36256
#include<stdio.h>
#include<stdlib.h>

#define M 2000000


int n,A[M],B[M+1],C[M];


void counting(int max){

  int i, j;

  for(j=0;j<n;j++) C[A[j]] = C[A[j]] + 1;


  for(i=1;i<=max;i++) C[i] = C[i] + C[i-1];


  for(j=n-1;j>=0;j--){
        
    B[C[A[j]]] = A[j];
    C[A[j]]--;

  }


  for(i=1;i<=n;i++){
    if(i==n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
    
  }
}
  
  

int main(){


  int i,j,k;


  scanf("%d",&n);

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

  k = A[0];
  for(i=1;i<n;i++){
    if(k<A[i]) k =A[i];
  }


  counting(k);

  return 0;
}



Measured memory_bytes: 17464
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int[] cab = {Z,X,Y};
		for(int i : cab) {
			System.out.print(i + " ");
		}
		sc.close();
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define int long long
#define vi vector<long long>
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 500 
#define FORN(start, end) for(int i=start; i<=end; i++)
#define pb push_back
#define vpp vector<pair<int,int>>

using namespace std;

int caseNo=0;

void debugVector(vi A) {
    cout<<endl<<"**********DEBUG***********"<<endl;
    FORN(0,A.size()-1) cout<<A[i]<<" ";
    cout<<endl;
}


void solve() {

    int a,b;
    //,c,d;
//    int temp;
    int n;
    cin>>n;

//    vi vec;

    int p = sqrt(n);

    for(int i=p; i>=1; i--) {
        if(n%i==0) {
            a=i;
            b=n/a;
            break;
        }
    }

    cout<<a+b-2<<endl;

    // cin>>n;
    // cin>>a;
    // cin>>b;
    // cin>>c;
    // cin>>d;

    // FORN(0,n-1) {
    //     cin>>temp;
    //     vec.pb(temp);
    // }

}

int32_t main() {
    fastio;

    int t=1;
//    cin>>t;

    while(t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
def make_kmp_table(t):
    i = 2
    j = 0
    m = len(t)
    tbl = [0] * (m + 1)
    tbl[0] = -1
    while i <= m:
        if t[i - 1] == t[j]:
            tbl[i] = j + 1
            i += 1
            j += 1
        elif j > 0:
            j = tbl[j]
        else:
            tbl[i] = 0
            i += 1
    return tbl


def kmp(s, t):
    matched_indices = []
    tbl = make_kmp_table(t)
    i = 0
    j = 0
    n = len(s)
    m = len(t)
    while i + j < n:
        if t[j] == s[i + j]:
            j += 1
            if j == m:
                matched_indices.append(i)
                i += j - tbl[j]
                j = tbl[j]
        else:
            i += j - tbl[j]
            if j > 0:
                j = tbl[j]
    return matched_indices


t = input()
p = input()
result = kmp(t, p)
if result:
    print(*result, sep='\n')


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

multiset<int> S;

int main() {
	int N, A, cnt = 0;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> A;
		auto it = S.lower_bound(A);
		if (it == S.begin()) {
			cnt++;
			S.insert(A);
		}
		else {
			it--;
			S.erase(it);
			S.insert(A);
		}
	}
	cout << cnt << endl;
}

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

using namespace std;

struct city
{
	int p;
	long long y;
	int ynum;
	int num;
}c[100001];

bool cmp1(city a,city b)
{
	return a.y<b.y;
}

bool cmp2(city a,city b)
{
	return a.num<b.num;
}

int main()
{
	int n,m,cnt[100001]={0};
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>c[i].p>>c[i].y;
		c[i].num=i;
	}
	sort(c+1,c+m+1,cmp1);
	for(int i=1;i<=m;i++)
	{
		cnt[c[i].p]++;
		c[i].ynum=cnt[c[i].p];
//		cout<<c[i].y<<endl; 
	}
	sort(c+1,c+m+1,cmp2);
	for(int i=1;i<=m;i++)
	{
		printf("%06d%06d\n",c[i].p,c[i].ynum);
	}
	return 0;
 }

Measured memory_bytes: 4224
N, K = map(int, input().split())
ball = list(map(int, input().split()))

def gcd(a, b):
    #aとbの最大公約数を求める
    #math.gcdもしくはnp.gcdを使えばいいのだが、AtCoder上のpythonでは使えない
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        c = a % b
        return gcd(b, c)
def gcd_list(l):
    #リストlに対して、lの要素の最大公約数を返す
    d = l[0]
    for i in range(len(l) - 1):
        d = gcd(d, l[i + 1])
    return d

d = gcd_list(ball)
if K <= max(ball) and K % d == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14252