akhauriyash/Code-Regression huggingface dataset:
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms[$lms_map[$l]+1]//$n;
			my$end_r=$lms[$lms_map[$r]+1]//$n;
			my$different;
			if($end_l-$l!=$end_r-$r){
				$different=1;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$different=$l==$n||$s[$l]!=$s[$r];
			}
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper+=$different;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


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

using namespace std;

#define MAX 100


int main(){
    
    int N;
    char S[MAX];
    bool is_four = false;

    cin >> N;

    for(int i=0;i<N;i++){
        scanf("%c",&S[i]);
    }

    for(int i=0;i<N;i++)
        if(S[i]=='Y')
            is_four = true;

    if(is_four)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(n==0 && p==0)break;
			
			int[] man = new int[n];
			int i=0;
			int cup=p;
			
			while(true){
				if(cup!=0){
					man[i]++;
					cup--;
				}else if(cup==0){
					cup = man[i];
					man[i] = 0;
				}
				if(man[i]==p){
					System.out.println(i);
					break;
				}
				i++;
				if(i==n)i=0;
			}
		}
	}
}

Measured memory_bytes: 20244
#include <stdio.h>

double aaa(double a){
    return (a + 1.0) / 2.0;
}

int main(void){
    int n, k, i;
    scanf("%d %d", &n, &k);
    double p[n];
    double ans = 0.0, tmp = 0.0;
    for(i = 0; i < n; i++){
        scanf("%lf", &p[i]);
        p[i] = aaa(p[i]);
    }

    for(i = 0; i < k; i++){
        ans += p[i];
    }
    tmp = ans;

    for(i = k; i < n; i++){
        tmp += (p[i] - p[i - k]);
        if(ans < tmp) ans = tmp;
    }

    printf("%.8f\n", ans);
    return 0;
}


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

int n;
int a[2][100];

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < 2; i++)
		for (j = 0; j < n; j++)
			cin >> a[i][j];
	
	//i回右に移動してから下に移動
	int ans = 0;
	for (i = 0; i < n; i++) {
		int s = 0;
		for (j = 0; j <= i; j++) s += a[0][j];
		for (j = i; j < n; j++) s += a[1][j];
		ans = max(ans, s);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int n, c, k;
	scanf("%d%d%d", &n, &c, &k);
	vector<int> t(n);
	rep(i, n)scanf("%d", &t[i]);
	sort(all(t));
	int f = -1;
	ll count = 0, people = 0;
	rep(i, n) {
		if (f == -1)f = t[i];
		if (f + k < t[i] || people == c) {
			++count;
			f = t[i];
			people = 0;
		}
		++people;
	}
	printf("%d\n", count + 1);

	Please AC;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6


int arr[3][3];


int32_t main()
{



    for(int i = 0; i < 3; i++)
    {
      for(int j = 0; j < 3; j++)
      {
        cin >> arr[i][j];
      }
    }


    int n;
    cin >> n;

    for(int k = 1; k <= n; k++)
    {
      int x;
      cin >>x;

      for(int i = 0; i < 3; i++)
      {
        for(int j = 0; j < 3; j++)
        {
          if(x == arr[i][j])arr[i][j] = -1;
        }
      }
    }



    bool ok = false;

    vector<int> v;
    v.PB(-1);
    v.PB(-1);
    v.PB(-1);


    for(int i = 0; i < 3; i++)
    {
      vector<int> v1,v2;
      for(int j = 0; j < 3; j++)
      {
        v1.PB(arr[i][j]);
        v2.PB(arr[j][i]);
      }

      if(v1 == v or v2 == v)ok = true;
    
    }

      vector<int> v1,v2;

      for(int i = 0; i < 3; i++)
      {
        v1.PB(arr[i][i]);
        v2.PB(arr[i][2-i]);
      }    

      if(v1 == v or v2 == v)ok = true;

      cout << (ok ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

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

    int l, i=0;
    int a[n];
    int check[n];
    int count[n];
    int max=0;
  
    while (std::cin >> l) {
        a[i] = l;
        if(i>0){
          if(a[i]<= a[i-1]){
            check[i-1] = 1;
            if(i>1){
              count[i-1] = count[i-2]+1;
            }else{
              count[i-1]=1;
            }
          }else{
             count[i-1]=0;
          }
                 if(max<= count[i-1]){ max= count[i-1] ;}
        }
   
    i++;
      if (i >= n) {
            break;
        }
    }
  cout <<  max << endl;



    return 0;
}


Measured memory_bytes: 1408
/*
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
//const ll N = 200007 ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }
//vector<ll> adj[N] ;



int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll n , i ;

    cin >> n ;
    vector<ll>v(n);
    for ( i= 0 ; i< n;i++) cin >> v[i] ;

    ll ans = 0 , res = 1 ;

    for ( i = 0 ; i< n ;i++) {
        if (i==0)  { if (v[i]) res = 0 ; }
        else {
            if (v[i]>v[i-1]+1) res = 0 ;
            else {
                if (v[i]) {
                if ( v[i]-1!=v[i-1] ) ans+= v[i] ;
                else ans++ ;
                }
            }
           //1 cout << ans << endl ;
        }
    }
    if (!res) ans=-1 ;
    cout << ans << endl ;
    stay_home_stay_safe ;
}







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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(const char &ch) {
  return string(1, ch);
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
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 pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define pr(...) 42
#endif

double tick() {
  static clock_t oldtick;
  clock_t newtick = clock();
  double diff = 1.0 * (newtick - oldtick) / CLOCKS_PER_SEC;
  oldtick = newtick;
  return diff;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(10);
  cout << fixed;
  #ifdef LOCAL
    freopen("c_school.in", "rt", stdin);
  #endif

  int n;
  cin >> n;
  vector <int> ans(n);
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    int pos = val - 1;
    ans[pos] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;


  #ifdef LOCAL
    fprintf(stderr, "Time elapsed: %.12lf secs...\n", tick());
  #endif
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1LL << 61;

int main()
{
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int64_t left = -INF, right = INF;
  while (right - left > 1)
  {
    int64_t x = (left + right) / 2;
    int64_t S = 0, T = 0;
    for (int i = 0; i < N; i++)
    {
      if (A.at(i) > 0)
      {
        int l = -1, r = N;
        while (r - l > 1)
        {
          int m = (l + r) / 2;
          if (A.at(i) * A.at(m) <= x)
            l = m;
          else
            r = m;
        }
        S += r;
      }
      else if (A.at(i) < 0)
      {
        int l = -1, r = N;
        while (r - l > 1)
        {
          int m = (l + r) / 2;
          if (A.at(i) * A.at(m) <= x)
            r = m;
          else
            l = m;
        }
        S += N - r;
      }
      else if (x >= 0)
        S += N;
      if (A.at(i) * A.at(i) <= x)
        T++;
    }
    int64_t n = (S - T) / 2;
    if (n >= K)
      right = x;
    else
      left = x;
  }
  cout << right << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,pair<int,int>>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

string s;
int dp[114514][2];
signed main() {
	cin >> s;
	dp[0][0] = 1;
	rep(i, s.size()) {
		if (s[i] == '1') {
			dp[i + 1][0] = dp[i][0] * 2 % mod;
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] += dp[i][1] * 3;
			dp[i + 1][1] %= mod;
		}
		else {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] += dp[i][1] * 3 % mod;
		}
	}
	cout << (dp[s.size()][0] + dp[s.size()][1]) % mod << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define int        long long
#define MOD        1000000007
#define MAX        100005
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define mii        map<int,int>
#define vi         vector<int>
#define ff         first
#define ss         second
#define T          int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi        unordered_map<int,int>
#define maxheap    priority_queue<int>
#define minheap    priority_queue<int,vector<int>,greater<int> >
#define inp(n)     for(int i=0;i<n;i++)
#define N          200005
#define mxN           2000005
#define all(v)        v.begin(),v.end()
#define lb(v,val)  (int)(lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (int)(upper_bound(v.begin(),v.end(),val)-v.begin())
using namespace std;
using namespace std::chrono;

void solve(){
    int h,w,K;
    cin >> h >> w >> K;
    char a[h+1][w+1];
    inp(h)loop(j,0,w)cin>>a[i][j];
    int output = INT_MAX;

    for(int mask = (1<<(h-1));mask < (1<<h);mask++){
        bool possible = true;
        //cout << mask << ' ';
        int k,cut = 0;
        vi ans(10,0),cur(10,0);

        for (int j = 0; j < w; j++){
            inp(10) cur[i] = 0;
            k = 0;
            for(int i = 0; i < h; i++){
                if(a[i][j] == '1'){
                    cur[k]++;
                    ans[k]++;
                }
                if(mask&(1<<i)){
                    k++;
                }
            }
            for(int i = 0; i < k; i++){
                if(cur[i] > K){
                    possible = false; break;
                }
            }
            for(int i = 0; i < k; i++){
                if(ans[i] > K){
                    cut++;
                    for(int x = 0; x < k; x++){
                        ans[x] = cur[x];
                    }
                    break;
                }
            }
            if(!possible) break;
        }
        if(possible) output = min(output,cut+__builtin_popcount(mask)-1);     
        //cout << cut << '\n';
    }
    cout << output;
}

signed main(){
/*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif  */  
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1; 
    //cin >> t;
    while(t--){
    solve(); 
    }
}




Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input.split(' ')
  if (
    input[0][input[0].length - 1] == input[1][0] &&
    input[1][input[1].length - 1] == input[2][0]
  ) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(12); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

const int mxN = 3010;

int N;
double p[mxN];
double dp[mxN][mxN];

double solve(int pos, int cnt) {
    if (pos >= N) {
        if (cnt >= (N + 1) / 2) return 1.0;
        return 0.0;
    }
    if (dp[pos][cnt] != -1.0) return dp[pos][cnt];
    return dp[pos][cnt] = (p[pos] * solve(pos + 1, cnt + 1) * 1.0) + ((1 - p[pos]) * solve(pos + 1, cnt) * 1.0);
}

int main() {
    optimize();
    fraction();
    for (int i = 0; i < mxN; ++i) {
        for (int j = 0; j < mxN; ++j) {
            dp[i][j] = -1.0;
        }
    }
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> p[i];
    cout << solve(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll p(n);
  REP(i, n) cin >> p.at(i);
  vll ord(n); iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](ll x, ll y){
    return p.at(x) < p.at(y);
  });
  vll a(n), b(n);
  REP(i, n) a.at(i) = 30000 * (i + 1);
  REP(i, n) b.at(i) = 30000 * (n-i+1) + ord.at(i);
  REP(i, n) {
    cout << a.at(i);
    if (i != n-1) cout << ' ';
  }
  cout << endl;
  REP(i, n) {
    cout << b.at(i);
    if (i != n-1) cout << ' ';
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
int L, ML, MR, R, d;

// (a^d.b)^L . a^ML . b^MR . (a.b^d)^R
inline bool get(int pos) {
	return pos < (d + 1) * L ? pos % (d + 1) == d : (pos -= (d + 1) * L) < ML + MR ? pos >= ML : (pos - (ML + MR)) % (d + 1);
}

void solve(int n, int U, int l, int r, bool flip) {
	d = (n + U) / (n + 1);
	L = (d == 1 ? 0 : ((ll)d * n - U + d - 1) / ((ll)d * d - 1));
	n -= d * L, U -= L;
	R = std::min(n, U / d);
	ML = n - R, MR = U - d * R;
	flip ? ({for (; r >= l; --r) putchar(66 - get(r));}) : ({for (; l <= r; ++l) putchar(65 + get(l));});
	putchar(10);
}

void work() {
	int A, B, l, r;
	scanf("%d%d%d%d", &A, &B, &l, &r);
	A <= B ? solve(A, B, l - 1, r - 1, false) : solve(B, A, A + B - r, A + B - l, true);
}

int main() {
	int T;
	for (scanf("%d", &T); T; --T) work();
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n-1);
  rep(i,n-1) cin >> a[i];

  vector<ll> b(n+5);
  rep(i,n-1) b[a[i]]++;

  rep(i,n) {
    cout << b[i+1] << endl;
  }
  return 0;
}


Measured memory_bytes: 6056
s1=''
while True:
    try:
        s1 += input().lower()
    except:
        break
for i in ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'):
    print(i,":",s1.count(i))


Measured memory_bytes: 5568
//Nipah!~☆
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;

int n;
string ans;
bool mark[maxn];
int kid[maxn];
vector<int> adj[maxn];

void in();
void solve();
void dfs(int, int);
void out();

int main(){
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	in();
	solve();
	out();
}

void in(){
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void solve(){
	ans = "Second";
	dfs(0, -1);
}

void dfs(int u, int par){
	mark[u] = 1;
	kid[u] = -1;
	for(auto v: adj[u])
		if(!mark[v])
			dfs(v, u);
	if(kid[u] == -1){
		if(par == -1 || kid[par] != -1)
			ans = "First";
		else
			kid[par] = u;
	}
}

void out(){
	cout << ans;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define N 100005 

int color[N] , n ; 
vector<vector<pair<int,int> > > g(N) ; 

void dfs(int k , int p){
	for(int i=0;i<g[k].size();i++){
		int v = g[k][i].ff ; 
		int cost = g[k][i].ss ; 
		if(cost%2){
		if(color[k] == -1 && color[v] == -1){
			color[k] = 0 ; 
			color[v] = 1 ; 
		}
		else{
			if(color[k] != -1 && color[v] != -1){

			}
			else{
				if(color[k] == -1){
					color[k] = color[v]^1 ; 
				}
				else{
					color[v] = color[k]^1 ; 
				}
			}
		}
        }
        else{
           if(color[k] == -1 && color[v] == -1){
			color[k] = 0 ; 
			color[v] = 0 ; 
		}
		else{
			if(color[k] != -1 && color[v] != -1){

			}
			else{
				if(color[k] == -1){
					color[k] = color[v] ; 
				}
				else{
					color[v] = color[k] ; 
				}
			}
		}	
        }
		if(v != p){
			dfs(v , k) ; 
		}
	}
}

int main(){
	cin>>n ; 
    
    for(int i=1;i<=n;i++){
    	color[i] = -1 ; 
    }

	for(int i=1;i<=n-1;i++){
		int u , v , c ; 
		cin>>u>>v>>c ; 
		g[u].pb({v,c}) ; 
		g[v].pb({u,c}) ; 
    }
    
    dfs(1 , 0) ; 

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

Measured memory_bytes: 8320
M, D = map(int, input().split())

cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d = str(d)
        if len(d) == 1:
            continue
        d1, d2 = map(int, d)
        if d1 > 1 and d2 > 1 and m == d1*d2:
            cnt += 1

print(cnt)


Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MOD = 1e9 + 7;
const int MAXV = 1e5;

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<int> odd, even;
    rep(i, N) {
        int x; cin >> x;
        if(i % 2 == 1) odd.push_back(x);
        else even.push_back(x);
    }
    vector<int> cntOdd(MAXV + 1), cntEven(MAXV + 1);
    rep(i, sz(odd)) cntOdd[odd[i]]++;
    rep(i, sz(even)) cntEven[even[i]]++;
    int FirstFreqIdxOdd = -1, FirstFreqIdxEven = -1;
    int FirstFreqOdd = 0, FirstFreqEven = 0;;
    repp(i, 1, MAXV) {
        if(cntOdd[i] > FirstFreqOdd) {
            FirstFreqOdd = cntOdd[i];
            FirstFreqIdxOdd = i;
        }
    }
    repp(i, 1, MAXV) {
        if(cntEven[i] > FirstFreqEven) {
            FirstFreqEven = cntEven[i];
            FirstFreqIdxEven = i;
        }
    }
    int SecondFreqIdxOdd = -1, SecondFreqIdxEven = -1;
    int SecondFreqOdd = 0, SecondFreqEven = 0;
    repp(i, 1, MAXV) {
        if(cntOdd[i] >= SecondFreqOdd && i != FirstFreqIdxOdd) {
            SecondFreqOdd = cntOdd[i];
            SecondFreqIdxOdd = i;
        }
    }
    repp(i, 1, MAXV) {
        if(cntEven[i] >= SecondFreqEven && i != FirstFreqIdxEven) {
            SecondFreqEven = cntEven[i];
            SecondFreqIdxEven = i;
        }
    }
    if(FirstFreqIdxOdd == FirstFreqIdxEven) {
        cout << sz(odd) + sz(even) - max(FirstFreqOdd + SecondFreqEven, FirstFreqEven + SecondFreqOdd) << endl;
    } else {
        cout << sz(odd) + sz(even) - FirstFreqOdd - FirstFreqEven << endl;
    }
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l( n );
	for ( int i = 0; i < n; i++ ) cin >> l[i];
	int p = 0, c = 1;
	for ( int i = 0; i < n && p <= x; i++ ) {
		p += l[i];
		if ( p <= x ) c++;
	}
	cout << c << endl;
	return 0;
}

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

int n, ta[9] = { 111,222,333,444,555,666,777,888,999 };

int main(){
	cin >> n;
	for (int i = 0; i < 9; i++) {
		if (n <= ta[i]) {
			cout << ta[i] << endl;
			break;
		}
	}
	return 0;
}

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

int main()
{
  int k;
  string s;
  cin >> k;
  cin >> s;
  
  if(s.size() <= k)
  {
    cout << s << endl;
  }
  else
  {
    cout << s.substr(0, k) + "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.rbegin(), res.rend());
    return res;
}

int main(){
    ll N,M; cin >> N >> M;
    auto D = enum_divisors(M);
    for(auto c:D){
        if(c <= M/N && (M-(N-1)*c) % c == 0){
            cout << c << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("-O2")
#include<bits/stdc++.h>
#define int long long
#define vi vector<int> 
#define pb push_back
#define eb emplace_back
#define For(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define MAX 100005
#define endl '\n'
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	// freopen("output1.txt", "w", stdout);
	#endif
	int x;
	cin>>x;
	if(x==1){
		cout<<0;
		return 0;
	}
	else{
		cout<<1;
		return 0;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=(n/(a+b))*a;
    n%=(a+b);
    ans+=min(a,n);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
dp=[]
dp.append(0)
dp.append(abs(a[0]-a[1]))
for i in range(2,n):
    k=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]))
    dp.append(k)
print(dp[n-1])


Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int X,N; cin>>X; cin>>N;
  set<int> SET;
  for (int i = 0; i < N; i++)
  {
     int X;cin>>X;
     SET.insert(X);
  }
  int D = 0;
  while(true)
  {
    if(SET.find(X-D) == SET.end())
    {
      cout<<X-D<<endl;
      return;
    }

    if(SET.find(X+D) == SET.end())
    {
      cout<<X+D<<endl;
      return;
    }
    D++;
    
  } 
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
  int i,j,count=0;
  string s;

  while(getline(cin,s)){
    string n = s;
    reverse(s.begin(),s.end());
    if(n == s)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int a[2][maxn];
int dp[2][maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)scanf("%d",&a[i][j]);
    for(int j=0;j<n;j++){
        for(int i=0;i<2;i++){
            dp[i][j]=a[i][j];
            if(i>0)dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j]);
            if(j>0)dp[i][j]=max(dp[i][j],dp[i][j-1]+a[i][j]);
        }
    }
    printf("%d\n",dp[1][n-1]);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def comb_mod(n, m, M):
    return (perm_mod(n, m, M) * inv_mod(fact_mod(m, M), M)) % M

def perm_mod(n, m, M):
    ret = 1
    for i in range(n, n - m, -1):
        ret = (ret * i) % M
    return ret

def inv_mod(a, M):
    return pow_mod(a, M - 2, M)

def fact_mod(a, M):
    ret = 1
    for i in range(2, a + 1):
        ret = (ret * i) % M
    return ret

def pow_mod(a, k, M):
    if k == 0:
        return 1

    t = pow_mod(a, k // 2, M)
    res = (t * t) % M
    if k % 2 == 1:
        res = (res * a) % M

    return res


def solve(N: int, K: int):
    B = K
    R = N - B

    ret = []
    for i in range(K):
        r = (comb_mod(R + 1, i + 1, MOD) *  comb_mod(B - 1, i, MOD)) % MOD
        ret.append(r)
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    result = solve(N, K)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5756
import math
def split(word):
    return [int(char) for char in word]

input1 = int(input())
input2 = split(str(input()))
def indexEverything(input2):
    whereDict = dict()
    for index in range(len(input2)):
        try:
            whereDict[input2[index]].append(index)
        except:
            whereDict[input2[index]] = [index]
    return whereDict

def doesCodeExist(n, whereDict):
    ##n = int(n)
    ##print(n)
    ## n is a list of the three digits
    try:
        firstLoc = whereDict[int(n[0])][0]
    except:
        ##print("what")
        return False
    ##print(firstLoc)
    found2 = False
    counter2 = 0
    ##print("getting in here")
    while not found2:
        ##print("trying")
        try:
            ##print(whereDict[int(n[1])][counter2], firstLoc)
            ##print(whereDict[int(n[1])][counter2] > firstLoc)
            if (whereDict[int(n[1])][counter2] > firstLoc):
                secondLoc = whereDict[int(n[1])][counter2]
                ##print("beep")
                ##print(secondLoc)
                found2 = True
            ##print("jebtime")
            counter2 += 1

            #print(secondLoc)
        except:
            return False
    ##print(secondLoc)
    found3 = False
    counter3 = 0
    while not found3:
        try:
            if (whereDict[int(n[2])][counter3] > secondLoc):
                ##print(whereDict[int(n[2])][counter3])
                return True
            counter3 += 1
            ##print(counter3)
        except:
            return False

whereDict = indexEverything(input2)
counter = 0
##print("here")
##print(doesCodeExist("242", whereDict))
##print("fin")
for index in range(0, 1000):
    if (index < 100):
        if (index < 10):
            index = "00" + str(index)
        else:
            index = "0" + str(index)
    if (doesCodeExist(split(str(index)), whereDict)):
        ##print(index)
        counter += 1
print(counter)


Measured memory_bytes: 4672
n, k = map(int, input().split())

cnt = [0 for i in range(n)]
for i in range(k):
    d  = int(input())
    A  = list(map(int, input().split()))
    
    # print("A:", A)
    for j in A:
        # print(cnt)
        cnt[j-1] += 1

ans = 0
for p in cnt:
    if p == 0:
        ans += 1

print(ans)


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

int main(){
  while(1){
    int N;
    cin >> N ;
    if(N==0){
      break;
    }
    int str[11][6]={0};
    for(int i=N-1;i>=0;i--){
      for(int j=0;j<5;j++){
        cin >> str[i][j];
      }
    }
    int score=0;
    for(int i=0;i<10;i++){
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
//    cout << endl;
      for(int j=0;j<N;j++){
        int a=str[j][0];
        int ch=0;
        for(int k=0;k<=5;k++){
          if(a==str[j][k]&&a!=0){
            ch++;
          }else{
            if(ch>=3){
              for(int l=k-1;l>=k-ch;l--){
                score+=str[j][l];
                str[j][l]=0;
              }
              break;
            }else{
              a=str[j][k];
              ch=1;
            }
          }
        }
      }
      for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
          for(int l=0;l<5;l++){
            if(str[k][l]==0){
              str[k][l]=str[k+1][l];
              str[k+1][l]=0;
            }
          }
        }
      }
    }
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
    cout << score << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<char>color(N);
  for(int i = 0; i < N; i++){
    cin >> color.at(i);
    if(color.at(i) == 'Y'){
      cout << "Four" << endl;
      break;
    }else if(i == N -1 && color.at(i) != 'Y'){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main() {
    double a, b, c, S, L, h;
    (void)scanf("%lf %lf %lf", &a, &b, &c);
    double rad = c * M_PI / 180;
    S = b * a * sin(rad) / 2.0;
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
    h = 2 * S / a;
    printf("%.5lf\n%.5lf\n%.5lf\n", S, L, h);
}





Measured memory_bytes: 2924
# A
x1, x2, x3, x4, x5 = map(int, input().split())
if (x1 == 0):
    print(1)
elif(x2 == 0):
    print(2)
elif(x3 == 0):
    print(3)
elif(x4 == 0):
    print(4)
else:
    print(5)

Measured memory_bytes: 61552
#include<stdio.h>

#define N 10001
#define Q 501

int main(){

  int i,j,n,q;
  int cnt=0;
  int S[N],T[Q];
  
  scanf("%d",&n);  
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  scanf("%d",&q); 
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    for (j=0;j<n;j++) {
      if (T[i] == S[j]) {
        cnt++;
        break;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int d,e;
	while(true){
		cin>>d>>e;		
		if(d==0 && e==0)break;
		double ans=100000000.0;
		for(int i=0;i<=d;i++){
			double x=(double)sqrt(i*i+(d-i)*(d-i));
			double num=(double)x-e;
			if(num<0)num*=-1;
			ans=min(ans,num);
		}
		printf("%.10lf\n",ans);
	}
    return 0;
}


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

int main(){
  int N,i,p[51],counter=0 ;
  
  cin >> N;
  
  for(i=1;i<=N;i++){
    cin >> p[i] ;
    if(i != p[i]){
      counter++ ;
    }
  }
  
  if(counter <= 2){
    cout <<"YES" ;
  }else{
    cout << "NO" ;
  }
}

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

int main(void) {
  int x_1, x_2, x_3, x_4, y_1, y_2, y_3, y_4;
  cin >> x_1 >> y_1 >> x_2 >> y_2;

  x_3 = x_2 + y_1 - y_2;
  y_3 = y_2 + x_2 - x_1;
  x_4 = x_1 - y_2 + y_1;
  y_4 = y_1 + x_2 - x_1;

  cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vll all;
vll allp;

ll p(ll n, ll x){
    if(x >= all[n]) return allp[n];
    if(x <= 0) return 0;
    ll ret = 0;
    if(x >= all[n]/2+1){
        ret++;
        ret += p(n-1, x-(all[n]/2+1));
    }
    ret += p(n-1, x-1);
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, x;
    cin >> n >> x;
    ll tmp = 1;
    ll tmp2 = 1;
    rep(i, 51){
        all.push_back(tmp);
        allp.push_back(tmp2);
        tmp = tmp * 2 + 3;
        tmp2 = tmp2 * 2 + 1;
    }
    cout << p(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;
const int MAXN = 5e5 + 10;
class Edges{
public:
	int next , to;
};
Edges edge[MAXN * 2];
int te = 0 , first[MAXN];
int n , k , a[MAXN] , p[MAXN] , dg[MAXN] , ans[MAXN];
int minn[MAXN << 2];
priority_queue <int , vector<int> , greater<int> > q;
void build(int id , int l , int r){
	if(l == r){
		minn[id] = (l > 0 && l <= n ? a[l] : MAXN);
		return ;
	}
	int mid = (l + r) >> 1;
	build(id << 1 , l , mid);
	build((id << 1) + 1 , mid + 1 , r);
	minn[id] = min(minn[id << 1] , minn[(id << 1) + 1]);
}
void modify(int id , int x , int l , int r){
	if(l == r){
		minn[id] = MAXN;
		return ;
	}
	int mid = (l + r) >> 1;
	if(x > mid) modify((id << 1) + 1 , x , mid + 1 , r);
	else modify(id << 1 , x , l , mid);
	minn[id] = min(minn[id << 1] , minn[(id << 1) + 1]);
}
int query(int id , int ll , int rr , int l , int r){
	if(ll <= l && r <= rr) return minn[id];
	int mid = (l + r) >> 1 , ret = MAXN;
	if(rr > mid) ret = query((id << 1) + 1 , ll , rr , mid + 1 , r);
	if(ll <= mid) ret = min(ret , query(id << 1 , ll , rr , l , mid));
	return ret;
}
void add(int s , int t){
	++ te;
	edge[te].to = t;
	edge[te].next = first[s];
	dg[t] ++;
	first[s] = te;
}
int main(){
	ios::sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 1 ; i <= n ; ++ i) cin >> a[i];
	for(int i = 1 ; i <= n ; ++ i) p[a[i]] = i;
	build(1 , 0 , n + 1);
	for(int i = 1 ; i <= n ; ++ i){
		int q1 = query(1 , min(n + 1 , p[i] + 1) , min(n + 1 , p[i] + k - 1) , 0 , n + 1);
		if(q1 != MAXN) add(p[i] , p[q1]);
		int q2 = query(1 , max(0 , p[i] - k + 1) , max(0 , p[i] - 1) , 0 , n + 1);
		if(q2 != MAXN) add(p[i] , p[q2]);
		modify(1 , p[i] , 0 , n + 1);
	}
	for(int i = 1 ; i <= n ; ++ i) if(!dg[i]) q.push(i);
	int len = 0;
	while(!q.empty()){
		int now = q.top();
		q.pop();
		ans[++ len] = now;
		for(int e = first[now] ; e ; e = edge[e].next){
			int to = edge[e].to;
			dg[to] --;
			if(!dg[to]) q.push(to);
		}
	}
	for(int i = 1 ; i <= n ; ++ i) p[ans[i]] = i;
	for(int i = 1 ; i <= n ; ++ i) cout << p[i] << endl;
	return 0;
}
/*
8 3
4 5 7 8 3 1 2 6
*/

Measured memory_bytes: 29056
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    cout << (N) * (N - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(){
	string a, b;
	int ta = 0;
	cin >> a >> b;
	a += b;
	ta = stoi(a);
	for (int i = 1; i <= sqrt(ta); i++) {
		if (i*i == ta) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string S, T;
    cin >> S >> T;
    int l = S.size() - T.size() + 1;
    int k = 0;
    int mm = 0;
    int minnn = 1009;
    string q;
    rep(i, l)
    {
        string X = S.substr(i, T.size());
        int cnt = 0;
        int yy = 0;
        rep(p, X.size())
        {
            if(X[p] == T[p]) ++cnt;
            else ++yy;
        }
        // if(mm < cnt)
        // {
        //     mm = cnt;
            
        //     k = i;
        // }
        if(yy < minnn) minnn = yy;
    }
    cout << minnn;


    return 0;
}

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


int main(){
	string s,s2,s3,s4;
	cin >> s;
	reverse(s.begin(),s.end());
	
	for(int i=1;i<s.size();i++){
		s2=s.substr(i);
		s3=s.substr(i,s2.size()/2);
		s4=s.substr(s2.size()/2+i);
		if(s3==s4){
			cout << s2.size() << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  c_fac();
  ll N, M, K; cin >> N >> M >> K;
  ll result = 0;

  ll pm[N] = {}; rep(i,N) pm[i] = i==0 ? 1 : (pm[i-1]*(M-1))%MOD;
  rep(k,K+1) {
    result += ((nck(N-1,k)*M)%MOD*pm[N-1-k])%MOD;
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 12700
S,T=input(),input();l,m=len(S),len(T)
for i in range(l-m+1):
 if all(c in"?"+d for c,d in zip(S[-i-m:],T)):S=S.replace("?","a");print(S[:-i-m]+T+S[l-i:]);quit()
print("UNRESTORABLE")


Measured memory_bytes: 2940