akhauriyash/Code-Regression huggingface dataset:
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

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

		int[] intArray = new int[100];
		while(stdIn.hasNext()){
			intArray[stdIn.nextInt()-1]++;
		}
		int[] indexArray = indexOfMaxArrayNumber(intArray);

		for(int i:indexArray){
			System.out.println(i);
		}
	}
	//受け取った配列のなかで、最大の値を持っている要素の添え字＋１を配列にして返す
	//最大の値が複数あったときは、添え字＋１の値を小さい順に配列に格納して返す
	public static int[] indexOfMaxArrayNumber(int[] intArray){
		List<Integer> indexList = new ArrayList<Integer>();
		int max = 0;
		//intArrayの最大値を求める
		for(int i:intArray){
			max = Math.max(i, max);
		}

		for(int i = 0;i < intArray.length; i++){
			if(intArray[i] == max){
				indexList.add(i + 1);
			}
		}
		int[] indexArray = new int[indexList.size()];
		for(int i = 0;i < indexArray.length; i++){
			indexArray[i] = indexList.get(i);
		}
		return indexArray;
	}
}

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

using namespace std;

string reverse(string a) {
	if (a.size() == 1) {
		return a;
	} else {
		return reverse(a.substr(1))+a[0];
	}
}

int main() {
	string s;
	while (cin >> s) {
		string a, b, c;
		int r = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '+') {
				r++;
			} else if (s[i] == '=') {
				r++;
			} else {
				if (r == 0) {
					a += s[i];
				} else if (r == 1) {
					b += s[i];
				} else {
					c += s[i];
				}
			}
		}
		//cout << a << ' ' << b <<  ' ' << c << endl;
		bool h = false;
		if ((a[0] == 'X' && a.size() > 1) || (b[0] == 'X' && b.size() > 1) || (c[0] == 'X' && c.size() > 1)) {
			h = true;
		}
		a = reverse(a);
		b = reverse(b);
		c = reverse(c);
		int d = -1;
		for (int i = 0; i < 10; i++) {
			//cout << i << endl;
			if (a.size() > c.size() || b.size() > c.size()) {
				break;
			}
			if (i == 0 && h) {
				continue;
			}
			int p = 0;
			bool hh = true;
			for (int j = 0; j < c.size(); j++) {
				//cout << i << ' ' << j << endl;
				int aa, bb, cc;
				aa = bb = cc = 0;
				if (j < a.size()) {
					if (a[j] == 'X') {
						aa = i;
					} else {
						aa = a[j]-'0';
					}
				}
				if (j < b.size()) {
					if (b[j] == 'X') {
						bb = i;
					} else {
						bb = b[j]-'0';
					}
				}
				if (c[j] == 'X') {
					cc = i;
				} else {
					cc = c[j]-'0';
				}
				if ((aa+bb+p)%10 == cc) {
					if (aa+bb+p > 9) {
						p = 1;
					} else {
						p = 0;
					}
				} else {
					hh = false;
					break;
				}
			}
			if (hh) {
				d = i;
				break;
			}
		}
		if (d == -1) {
			cout << "NA" << endl;
		} else {
			cout << d << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};


int main(){
 ll s;
 cin >> s;
 ll m = 1e9;
 	int x = (m - s % m) % m;
	int y = (s + x) / m;
	
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;

}

Measured memory_bytes: 256
import sys
from collections import defaultdict
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N, K, L = map(int, input().split())
pq_and_rs = list(map(int, read().split()))

ps = pq_and_rs[:2*K:2]
qs = pq_and_rs[1:2*K:2]
rs = pq_and_rs[2*K::2]
ss = pq_and_rs[2*K+1::2]

pq_adj = csr_matrix(([1] * (2 * K), (ps + qs, qs + ps)), shape=(N+1, N+1))
rs_adj = csr_matrix(([1] * (2 * L), (rs + ss, ss + rs)), shape=(N+1, N+1))

group = ((connected_components(pq_adj)[1].astype(np.int64) << 32) + connected_components(rs_adj)[1]).tolist()
group_to_elements = defaultdict(list)
for v, g in enumerate(group):
    group_to_elements[g].append(v)

for v in range(1, N+1):
    print(len(group_to_elements[group[v]]))

Measured memory_bytes: 112880
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	cout << r * r << '\n';
	return 0;
}


Measured memory_bytes: 256
n=int(input())
if int((2*n)**(1/2))*int((2*n)**(1/2)+1)==2*n:
  a=int((2*n)**(1/2))
  print("Yes")
  print(a+1)
  A=[[] for i in range(a+1)]
  x=0
  for i in range(a):
    for j in range(a-i):
      x=x+1
      A[i].append(x)
  B=[[] for i in range(a+1)]
  x=0
  for i in range(a):
    for j in range(a-i):
      x=x+1
      B[i].append(x)
  C=[[] for i in range(a+1)]
  for i in range(a):
    for j in range(a-i):
      C[a-j].append(B[i][j])
  D=[[] for i in range(a+1)]
  for i in range(a+1):
    D[i]=A[i]+C[i]
  for i in range(a+1):
    print(a,end=" ")
    for j in range(a):
      print(D[i][j],end=" ")
    print()
else:
  print("No")

Measured memory_bytes: 15184
n, k = map(int,input().split())
s = list(input())

bf = s[0]
kyoukai = 0
sum = 0
for i in range(1,len(s)):
    if bf != s[i]:
        kyoukai += 1
    else:
        sum += 1
    bf = s[i]

sum += min(k*2,kyoukai)
print(sum)

Measured memory_bytes: 4084
def fn(m):
    res = 0
    for a in A:
        res += (a - m) ** 2
    return res


N = int(input())
A = list(map(int, input().split()))
mean = int(sum(A) // N)
lo = fn(mean)
hi = fn(mean + 1)
print(min(lo, hi))


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000

int ans = 0;
long long n;
void count(long long now, bool t, bool f, bool s){
    if (now>n) return;
    count(10*now+3,true,f,s);
    count(10*now+5,t,true,s);
    count(10*now+7,t,f,true);
    if(t == true&& f == true && s == true) ans++;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    count(0,false,false,false);
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	ll p = (b-a-(n-1)*d)/(-c-d);
	//cout << p << endl;
	ll q = (b-a-(n-1)*c)/(-c-d);
	if((b-a-(n-1)*c)%(-c-d) != 0) q++;
	//cout << q << endl;
	if(p < 0 || q >= n) {
		cout << "NO" << endl;
		return 0;
	}
	if(q <= p) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
string s;cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++)
  {
    if(s.at(i)=='x')
      count++;
  }
  if(count<=7)
    cout<<"YES"<<endl;
  else
     cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int h,m;
		scanf("%d:%d",&h,&m);
		//~ð720ª
		int ha=h*60+m;
		int ma=m*12;
		int da=abs(ha-ma);
		da=min(da,720-da);
		if(da<60)
			cout<<"alert"<<endl;
		else if(da>=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
    int n;
    cin>>n;
    set<int> st;
    for(int i=1;i<=n;i++){
    	int x;
    	cin>>x;
    	st.insert(x);
    }
    if((int)st.size() == n)
    	cout<<"YES";
    else cout<<"NO";
}   

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int k,x;cin>>k>>x;
  string res=(x>500*k)?"No":"Yes";
  cout<<res<<endl;
}

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

int main()
{
	string s;
	cin >> s;
	while(s.find("B") != string::npos)
	{
		if(!s.empty())
		{
			if(s.find_first_of("B") == 0)
			{
				s.erase(0, 1);
			}
			else
			{
				s.erase(s.find_first_of("B") - 1, 2);
			}
		}
	}
	cout << s;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define ll long long
#define     f           first
#define     s           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<long long,long long>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a)  for(int i=0;i<int(a);i++)
#define repb(i,b,a) for(int i=(int)b;i>=(int)a;i--)
vector<ll> adj[N];
bool visited[N]={false};
void dfs(ll x)
{
   visited[x]=true;
  // cout<<x<<" ";
   for(int i=0;i<adj[x].size();i++)
   {
       if(visited[adj[x][i]]==false)
            dfs(adj[x][i]);
   }
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
      ll a,b;
      cin>>a>>b;
      adj[a].pb(b);
      adj[b].pb(a);
  }
  ll k=0;
  for(int i=1;i<=n;i++)
  {
      if(visited[i]==false)
      {
          dfs(i);
          k++;
      }
  }
  cout<<k-1<<endl;
   // getch();
    return 0;
}

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

int main(void)
{
  int i,j,k,c;
  int n,m,l;
  int person[50][50];
  int date[50][30];
  int map[50];

  while(1){
    scanf("%d ",&n);
    if(n==0)break;

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i==j){
	  person[i][j] = 1;
	}else{
	  person[i][j] = 0;
	}
      }
      scanf("%d ",&m);
      for(j=0;j<30;j++){
	date[i][j] = 0;
      }
      for(j=0;j<m;j++){
	scanf("%d ",&l);
	date[i][l-1] = 1;
      }
    }

    for(j=0;j<30;j++){
      for(i=0;i<n;i++){
	map[i] = 0;
      }
      for(i=0;i<n;i++){
        if(date[i][j]){
          for(k=0;k<n;k++){
	    if(person[i][k])map[k] = 1;
	  }
	}
      }
      c = 0;
      for(k=0;k<n;k++){
	if(map[k]==0)c++;
      }
      if(c==0)break;

      for(i=0;i<n;i++){
	if(date[i][j]){
	  for(k=0;k<n;k++){
	    if(map[k])person[i][k] = 1;
	  }
	}
      }
    }

    if(j==30){printf("-1\n");}
    else{printf("%d\n",j+1);}

  }
  return 0;
}

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

using namespace std;

vector<int> solve(int N, int A, int B){
	vector<int> res;
	for(int i=0;i<A;i++) res.push_back(N-A+1+i);
	long long rest = N-A;
	long long block = B-1;
	if(block > rest) return vector<int>(1, -1);
	if(rest > A * block) return vector<int>(1, -1);
	long long a = rest - block;
	for(int i=0;i<block;i++){
		int back = min(A - 1LL, a);
		for(int j=rest-back;j<=rest;j++) res.push_back(j);
		rest -= back + 1;
		a -= back;
	}
	return res;
}

int main(){
	int N, A, B;
	while(cin >> N >> A >> B){
		vector<int> v = solve(N, A, B);
		cout << v[0];
		for(int i=1;i<v.size();i++) cout << " " << v[i];
		cout << endl;
	}
}


Measured memory_bytes: 3440
def check():
    S = input()
    s_set = set(S)
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    if len(S) == 26:
        if S == alpha[::-1]:
            return -1
        else:
            for i in range(1,len(S)+1):
                S1 = S[-i:]
                if S1 != ''.join(sorted(S1, reverse=True)):
                    S1 = S1[1:]
                    break
            for s in S1[::-1]:
                if s > S[-i]:
                    return S[:-i]+s
    else:
        for a in alpha:
            if a not in s_set:
                return S+a
print(check())

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Main {
	String fileName = "input.txt";
	final boolean isDebug = false;
	//final boolean isDebug = true;
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	final int MOD = (int)1e9+7;
	final long INF = Long.MAX_VALUE / 2;
	//final int INF = Integer.MAX_VALUE / 2;
	
	//System.out.println();はつかわない！！
	void solve() throws Exception{
		int X = in.nextInt(), A = in.nextInt();
		if(X < A) out.println(0);
		else out.println(10);
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}
	
	void m() throws Exception {
		if(isDebug) in = new FastScanner(new FileInputStream(fileName));
		solve();
		out.flush();
	}
	/* end main */
}
/* end Main */

class FastScanner {
	Reader input;

	FastScanner() {this(System.in);}
	FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}
	
	int nextInt() {return (int) nextLong();}

	long nextLong() {
		try {
			int sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			long ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) return ret * sign;
				ret *= 10;
				ret += b - '0';
			}
		} catch (IOException e) {
			e.printStackTrace();
			return -1;
		}
	}

	double nextDouble() {
		try {
			double sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			double ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) break;
				ret *= 10;
				ret += b - '0';
			}
			if (b != '.') return sign * ret;
			double div = 1;
			b = input.read();
			while ('0' <= b && b <= '9') {
				ret *= 10;
				ret += b - '0';
				div *= 10;
				b = input.read();
			}
			return sign * ret / div;
		} catch (IOException e) {
			e.printStackTrace();
			return Double.NaN;
		}
	}

	char nextChar() {
		try {
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			return (char) b;
		} catch (IOException e) {
			e.printStackTrace();
			return 0;
		}
	}

	String nextStr() {
		try {
			StringBuilder sb = new StringBuilder();
			int b = input.read();
			while (Character.isWhitespace(b)) {
				b = input.read();
			}
			while (b != -1 && !Character.isWhitespace(b)) {
				sb.append((char) b);
				b = input.read();
			}
			return sb.toString();
		} catch (IOException e) {
			e.printStackTrace();
			return "";
		}
	}
}

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

int main(){
  vector<int> l(11,0);
  int x;
  cin >> x;
  l[x]++;
  cin >> x;
  l[x]++;
  cin >> x;
  l[x]++;
  
  if (l[5] == 2 && l[7] == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, i, j, k;
	cin >> n;
	vector<long double> p(n);
	for (i = 0; i < n; i++) cin >> p[i];

	vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, 0));
	dp[0][0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			dp[i + 1][j + 1] += dp[i][j] * p[i];
		}
	}

	long double ans = 0;
	for (i = 0; i <= n; i++) {
		if (i > n - i) ans += dp[n][i];
	}

	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}




Measured memory_bytes: 141056
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ACoffee {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      if (s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
};

signed main() {
  ACoffee solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();

        int[] dp = new int[n];
        for(int i = 1; i <= n - 1; i++) {
            if(s.substring(i - 1, i + 1).equals("AC")) {
                dp[i] = dp[i - 1] + 1;
            }else {
                dp[i] = dp[i - 1];
            }
        }

        for(int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(dp[r - 1] - dp[l - 1]);
        }

        sc.close();
    }
}

Measured memory_bytes: 67500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int A,B;
    cin >> A >> B;
    if(A>9||B>9){
        cout << -1 << endl;
    }else{
        cout << A*B << endl;
    }
    return 0;
}

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

const int mod = 1000000007;


std::vector<long long> fac(1000100), inv(1000100), finv(1000100); //階乗 / 逆元 / inv * fac
void comb_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2;i < 1000100; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long comb(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0)return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main()
{
    comb_init();
    int x,y;
    std::cin>>x>>y;
    bool res;
    int cnt = (x + y) / 3; 
    res = (x + y) % 3 == 0;
    x -= cnt;
    y -= cnt;
    int ans = comb(cnt,x);
    std::cout<<(res ? ans : 0)<<std::endl;
}

Measured memory_bytes: 23680
#include <iostream>
#include <algorithm>
#include <queue>
#include <array>
using namespace std;
typedef pair<int,int> P;

const array<int,8> dx={0,1,0,-1,1,1,-1,-1};
const array<int,8> dy={1,0,-1,0,1,-1,-1,1};
const int W=50;
const int H=50;

char M[H+1][W+1];

inline bool in_M(const int y,const int x){
    return (y>=0 && y<H && x>=0 && x<W);
}

void bfs(const int sy,const int sx){
    queue<P> que;

    que.push(P(sy,sx));
    M[sy][sx]='0';

    while(!que.empty()){
        P p=que.front();que.pop();

        for(int i=0;i<dx.size();i++){
            int ddy=p.first+dy[i],ddx=p.second+dx[i];
            if(in_M(ddy,ddx) && M[ddy][ddx]=='1'){
                que.push(P(ddy,ddx));
                M[ddy][ddx]='0';
            }
        }
    }
}

void solve(){
    int sum;
    int w,h;

    while(cin>>w>>h,w|h){
        cin.ignore();
        sum=0;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>M[i][j];
                cin.ignore();
            }
        }

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(M[i][j]=='1'){
                    bfs(i,j);
                    sum++;
                }
            }
        }

        cout<<sum<<endl;
    }
}

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


        

Measured memory_bytes: 1208
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  N = int(input())
  right_count = [0] * N
  left_count = [0] * N

  for i, h in enumerate(map(int, input().split())):
    right = i + h
    left = i - h

    if right < len(right_count):
      right_count[right] += 1

    if left >= 0:
      left_count[left] += 1

  print(sum(rc * lc for rc, lc in zip(right_count, left_count)))


if __name__ == '__main__':
  main()


Measured memory_bytes: 96040
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
ll c[3];

int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
        if(a[i]%4==0){
            c[2]++;
        }else if(a[i]%2==0){
            c[1]++;
        }else{
            c[0]++;
        }
    }
    ll ans;
    if(c[1]==0){
        ans=2*c[2]+1;
    }else{
        ans=2*c[2]+c[1];
    }
    if(ans>=n){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
    
    return 0;
}


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

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

    int N;
    cin >> N;
    double x;
    string u;
    double sum = 0.0;
    double rate = 380000.0;
    for (int i = 0; i < N; i++) {
        cin >> x >> u;
        if (u == "JPY") {
            sum += x;
        } else {
            sum += (rate * x);
        }
    }

    cout << fixed << sum << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int i;
	scanf("%d",&n);

	for (i = 1; i <= n; ++i) {
		if ((i % 3 == 0) || (i % 10 == 3) || ((i / 10) % 10 == 3) ||
			(i / 10 / 10) % 10 == 3 || (i / 10 / 10 / 10) % 10 == 3 ||
			(i / 10 / 10 / 10 / 10) % 10 == 3)
		{
			printf(" %d", i);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
  long long int x,y,a,b;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    b=0;
    if(x<y){
      a=x;
      x=y;
      y=a;
    }
    while(1){
      a=x%y;
      x=y;
      y=a;
      b++;
      if(y==0)break;
    }
    cout<<x<<" "<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int H,A;cin>>H>>A;
    if(H%A==0){
        cout<<H/A<<endl;
    }else{
        cout<<H/A+1<<endl;
    }
}

Measured memory_bytes: 3504
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


int X;


int solve(){
	if(X == 1) return 1;
	int ans = 0;
	for(int i = 2;i <= X;i++){
		for(int j = 2;;j++){
			if((int)pow(i, j) > X) break;
			ans = max(ans, (int)pow(i, j));
		}
	}
	return ans;
}


int main(){
	cin >> X;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
count,okey=0,0

for i in range(N):
    if A[i]%2 == 0:
        count += 1
        if A[i]%3==0 or A[i]%5==0:
            okey += 1

if count==okey:
    print("APPROVED")
else:
    print("DENIED")

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

void solve(){
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }

    vector<bool> v(n, false);
    v[0] = true;
    vector<int> order = {0};
    int ne = -1;
    while(true){    
        v[order[order.size()-1]] = true;
        int next = a[order[order.size()-1]];
        if(v[next]){
            ne = next;
            break;
        }   
        order.push_back(next);
    }
    //cout <<  << endl;
    int start = find(order.begin(), order.end(), ne) - order.begin();

    // for(int i : order){
    //     cout << i << " ";
    // }cout << '\n';
    // cout << start << endl;

    if(k < order.size()){
        cout << order[k]+1 << '\n';
    }
    else{
        int s = order.size()-start;
        int ans = order[(k-start)%s + start]+1;
        cout << ans << '\n';
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 5092
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    string s;
    R(s);
    W(s.substr(0,3));
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cmath>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<double,int> pid;


double simple(double nenri,double root,int year){
	return root*(1+year*nenri/100.0);
}

double comp(double nenri,double root,int year){
	return root*pow(1+nenri/100.0,year);
}

int main(){
	int n,y,b,r,t;
	while(cin>>n,n){
		cin>>y;
		pid pr[n];
		rep(i,n){
			cin>>b>>r>>t;
			if(t==1)pr[i]=pid(simple(r,1,y),b);
			else pr[i]=pid(comp(r,1,y),b);
		}
		sort(pr,pr+n);
		cout<<pr[n-1].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		Point[] points = new Point[n];
		int xPlusYMax = 0;
		int xMinusYMax = Integer.MIN_VALUE;
		int xPlusYMin = Integer.MAX_VALUE;
		int xMinusYMin = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++){
			points[i] = new Point(sc.nextInt(), sc.nextInt());
			int xPlusY = points[i].x + points[i].y;
			int xMinusY = points[i].x - points[i].y;

			xPlusYMax = Math.max(xPlusYMax, xPlusY);
			xPlusYMin = Math.min(xPlusYMin, xPlusY);
			xMinusYMax = Math.max(xMinusYMax, xMinusY);
			xMinusYMin = Math.min(xMinusYMin, xMinusY);
		}

		long result = Math.max(xPlusYMax - xPlusYMin, xMinusYMax - xMinusYMin);

		System.out.println(result);
	}
}

class Point {
	int x;
	int y;

	Point(int x, int y){
		this.x = x;
		this.y = y;
	}

//	@Override
//	public int compareTo(Point p) {
//		// TODO 自動生成されたメソッド・スタブ
//		return (this.x + this.y) - (p.x + p.y);
//	}


}

Measured memory_bytes: 54652
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,n,t,sum;
	cin>>a>>b>>n;
	t=n/b;
	if(t==0){
		sum=(n*a)/b-a*(n/b);
	}
	else{
		t=n%b;
		n=n-t-1;
		sum=sum=(n*a)/b-a*(n/b);
	}
	cout<<sum;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
const int Maxn=200010;
const int mod=1000000007;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int f[Maxn],n,c[Maxn],pos[Maxn],nxt[Maxn];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		c[i]=read();
		if(pos[c[i]])nxt[pos[c[i]]]=i;
		pos[c[i]]=i;
	}
	f[1]=1;
	for(int i=1;i<=n;i++)
	{
		if(nxt[i]>i+1)upd(f[nxt[i]],f[i]);
		upd(f[i+1],f[i]);
	}
	
//	for(int i=1;i<=n;i++)printf("%d %d\n",i,f[i]);
	printf("%d",f[n]);
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int K;
    cin >> K;
    queue<ll> q;
    q.push(1);
    q.push(2);
    q.push(3);
    q.push(4);
    q.push(5);
    q.push(6);
    q.push(7);
    q.push(8);
    q.push(9);
    ll ans;
    REP(i, K){
        ans = q.front();
        if (ans % 10 != 0) q.push(ans * 10 + (ans % 10) - 1);
        q.push(ans * 10 + (ans % 10));
        if (ans % 10 != 9) q.push(ans * 10 + (ans % 10) + 1);
        q.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,m; cin>>n>>m;
	for(int x,i=1;i<=m;i++)cin>>x,n-=x;
	if(n>=0)cout<<n<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, pair<int, int> > PII;
typedef priority_queue<PII,
                       vector<PII>,
                       greater<PII> > dijQ;

int Abs(int a){
    return a < 0 ? -a : a;
}

const int MN = 100002;
int T[MN], dist[MN];

int main(){
    int n, k; cin >> n >> k;
    rep(i, 0, n) cin >> T[i];
    if(n == 2){
        cout << Abs(T[0] - T[1]);
        return 0;
    }
    rep(i, 0, n) dist[i] = 2000000000;
    dist[0] = 0;

    rep(i, 1, n){
        rep(j, 1, k+1){
            if(i - j < 0) break;
            dist[i] = min(dist[i-j]+Abs(T[i-j] - T[i]), dist[i]);
        }
    }
    cout << dist[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int n,m;
int a[N],b[N],f[N],sz[N]={0};
ll ans[N];
int find(int x)
{
    return f[x]==x?x:f[x]=find(f[x]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&a[i],&b[i]);

    for(int i=1;i<=n;i++)f[i]=i,sz[i]=1;

    ll sum=1ll*n*(n-1)/2, res=0;

    for(int i=m;i>=1;i--)
    {
        ans[i]=sum-res;
        int fa=find(a[i]),fb=find(b[i]);
        if(fa!=fb)
        {
            res+=1ll*sz[fa]*sz[fb];
            sz[fa]+=sz[fb];
            f[fb]=fa;
        }
    }
    for(int i=1;i<=m;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 3712
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int A,B;
	cin>>A>>B;
	cout<<(A+B)%24<<endl;
}

Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main(){
   int N,K;
   int sum =0;
 cin >> N >> K;
   for(int i=0;i<N;i++){
       int s;
       
       cin >> s;
       
       if(K>=2*s){
           sum=sum+2*s;
       }
       else{
           sum =sum +2*(K-s);
       }
   }
   cout <<sum<<endl;
}
  

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

using ll = long long;
using ull = unsigned long long;

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

double f(int n, int m, vector<double> &prob, vector<vector<double> > &dp) {
	if(n < m) return 0;
	if(n < 0) return 1;
	if(m < 0) {
		double x = 1;
		for(int i = 0; i <= n; i++) x *= (1 - prob[i]);
		return x;
	}
	if(dp[n][m] >= 0) return dp[n][m];
	double x = (prob[n] * f(n - 1, m - 1, prob, dp)) + ((1 - prob[n]) * f(n - 1, m, prob, dp));
	dp[n][m] = x;
	return x;
}

void solve() {
	int n;
	cin >> n;
	vector<double> prob(n);
	for(int i = 0; i < n; ++i) cin >> prob[i];
	vector<vector<double> > dp(n, vector<double>(n, -1));
	double ans = 0;
	for(int i = n /2; i <= n; i++) {
		ans += f(n - 1, i, prob, dp);
	}
	printf("%.10lf", ans);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 74056
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define MAXN 101
typedef long long ll;
int n,w;
ll dp[100001];
int main() {
  cin>>n>>w;
  for(int i = 0,a,v; i < n; i++){
    cin>>a>>v;
    for(int j = w; j >= a; j--){
      dp[j] = max(dp[j], dp[j-a] + v);
    }
  }
  cout<<dp[w];
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>(),T=in<string>();
	vector<int> SN(26,0),TN(26,0);
	for(int i=0,ei=S.size();i<ei;i++){
		SN[S[i]-'a']++;
		TN[T[i]-'a']++;
	}
	sort(ALL(SN));
	sort(ALL(TN));
	REP(i,26){
		if(SN[i]!=TN[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 916
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

if 0 in a:
  b = list(map(abs, a))
  print(sum(b))
  
else:
  if (a[a<0].size % 2) == 0:
    b = list(map(abs, a))
    print(sum(b))
  else:
    b = list(map(abs, a))
    b = sorted(b)
    b.reverse()
    c = b.pop()
    print(sum(b)-c)

    
    

    

Measured memory_bytes: 23304
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//try thinking from a different angle after spending some time
//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
	//global var
	int n,k;cin>>n>>k;
	vector<int> inp(n);
  	for(int i=0;i<n;++i){cin>>inp[i];}
  	int lft=0,rgt=k;
  	while(rgt<n){
      	if(inp[lft]<inp[rgt]){cout<<"Yes\n";}
      	else{cout<<"No\n";}
    	++rgt;++lft;
    }
}

Measured memory_bytes: 4776
n = int(input())
count_dict = {}
for _ in range(n):
    e = input()
    if e in count_dict.keys():
        count_dict[e] += 1
    else:
        count_dict[e] = 1

m = max(count_dict.values())
for e in sorted(k for k in count_dict if count_dict[k] == m):
    print(e)

Measured memory_bytes: 32092
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;

class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;
		cost=c;
	}
};
vector<Edge> g[100];
int dp[100][1001]; //頂点iにおいてコストを0にした辺の数がjのときの最小コスト
priority_queue<pair<P,int>,vector<pair<P,int>>,greater<pair<P,int>>> q;

int main()
{
	while(1)
	{
		int n,m,c;
		int ans=1e8-1;
		cin>>n>>m>>c;
		if(m==0)
			break;
		for(int i=0;i<100;i++)
			g[i].clear();
		fill(dp[0],dp[100],1e8-1);
		for(int i=0;i<m;i++)
		{
			int a,b,t;
			cin>>a>>b>>t;
			a--;b--;
			g[a].push_back(Edge(b,t));
		}
		//ダイクストラっぽいことをする
		dp[0][0]=0;
		q.push(make_pair(P(0,0),0));
		while(!q.empty())
		{
			auto p=q.top();q.pop();
			//枝刈りをする
			if(dp[p.second][p.first.first]<p.first.second)
				continue;
			//cerr<<"loop"<<endl;
			for(int i=0;i<g[p.second].size();i++)
			{
				Edge e=g[p.second][i];
				//コストを上回らないなら経路に追加
				if(p.first.second+e.cost<=c && dp[e.to][p.first.first]>p.first.second+e.cost)
				{
					dp[e.to][p.first.first]=p.first.second+e.cost;
					q.push(make_pair(P(p.first.first,dp[e.to][p.first.first]),e.to));
				}
				if(p.first.first<501 && dp[e.to][p.first.first+1]>p.first.second)
				{
					dp[e.to][p.first.first+1]=p.first.second;
					q.push(make_pair(P(p.first.first+1,p.first.second),e.to));
				}
			}
		}
		for(int i=0;i<1001;i++)
		{
			if(dp[n-1][i]!=1e8-1)
				ans=min(ans,i);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3480
fun main(args: Array<String>) {
    val br = System.`in`.bufferedReader()
    val (hp) = br.readLine().split(" ").map { it.toInt() }
    val attacks = br.readLine().split(" ").map { it.toInt() }

    val OUTPUT = if (hp <= attacks.sum()) {
        "Yes"
    } else {
        "No"
    }
    print(OUTPUT)
}


Measured memory_bytes: 48132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n,g;
	cin >> n >> g;
	cout<< 2*g-n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#define INF 100000001
#define all(a) a.begin(),a.end()

using namespace std;

struct edge{
  int to;
  double cost;
};

typedef pair<int,int>P;
int N;
double d[3001];
vector<edge>G[3001];
vector<int>S;

void dijkstra(void){
  priority_queue<P,vector<P>,greater<P> >que;
  fill(d,d+N+1,INF);
  for(int i=0;i<S.size();i++){
    d[S[i]]=0;
    que.push(P(0,S[i]));
  }

  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;

    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(void){
  int M,K,a,b,l,s;

  cin >> N >> M >> K;

  edge e;
  for(int i=0;i<M;i++){
    cin >> a >> b >> e.cost;
    e.to=b;
    G[a].push_back(e);
    e.to=a;
    G[b].push_back(e);
  }
  for(int i=0;i<K;i++){
    cin >> s;
    S.push_back(s);
  }
   
  dijkstra();

  double ans=0;
  for(int i=1;i<=N;i++)
    for(int j=0;j<G[i].size();j++)
      ans=max(ans,round((d[i]+d[G[i][j].to]+G[i][j].cost)/2.0));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7080
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        if( N % 2 == 0 ){
            System.out.println(0.5);
        } else {
            int odd  = (N - 1) / 2 + 1;
            System.out.println((double)odd/N);
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define pb push_back
#define f first
#define s second
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int k;
	cin>>k;
	if(k==7 || k==1){
		cout<<1<<endl;
		return 0;
	}
	int rem=0;
	for(int i=1; i<=1000005; i++){
		rem=((rem*10)+7)%k;
		if(rem==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


struct w_t
{
	char *p;
	int l;
	bool operator < (const w_t&rhs) const
	{
		for(int i=0;i<l;i++)
		{
			if(i>=rhs.l) return false;
			if(p[i]!=rhs.p[i])
			{
				return p[i]<rhs.p[i];
			}
		}
		return l<rhs.l;
	}
};


int main(void)
{
	char s[200000+2];

	while(scanf("%200000[a-z]\n", s)==1)
	{
		vi c={1};

		char p=s[0];
		for(int i=1;s[i];i++)
		{
			if(p!=s[i])
			{
				c.push_back(1);
			}
			else
			{
				c.back()++;
			}
			p=s[i];
		}

		int ans=0;
		for(int i=0;i+1<c.size();i++)
		{
			ans+=(c[i]/3)*2;
			switch(c[i]%3)
			{
				case 1: ans++; break;
				case 2: ans+=2; c[i+1]--; break;
			}
		}
		ans+=(c.back()/3)*2;
		if(c.back()%3) ans++;

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


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) cin >> a[i][j];
  }
  vector<int> b(m,0);
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i < n; i++) {
    int ci = 0;
    for(int j = 0; j < m; j++) {
      ci += a[i][j] * b[j];
    }
    cout << ci << "\n";
  }
}


Measured memory_bytes: 3196