akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public class WarPair
	{
		public int Island1 {get; set;}
		public int Island2 {get; set;}
	}
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		var ary = new WarPair[m];
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt();
			ary[i] = new WarPair() { Island1 = p[0], Island2 = p[1] } ;
		}
		Array.Sort(ary, (a, b) => a.Island2 - b.Island2);
		long wa = 0;
		int bridge = -1;
		for(int i = 0; i < m; i++)
		{
			if(ary[i].Island1<=bridge)
				continue;
			
			bridge = ary[i].Island2-1;
			wa++;
		}
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 22084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (auto &x : arr) cin >> x;
    bool dp[k];
    for (int i = 0; i < k; ++i)
    {
        dp[i] = false;
        for (int j = 0; j < n; ++j)
        {
            if (arr[j] == i+1) dp[i] |= true;
            else if (arr[j] < i+1) dp[i] |= !dp[i-arr[j]];
        }
    }
    if (dp[k-1]) cout << "First\n";
    else cout << "Second\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2000005,mod=1000000007;
int f[N]={1};
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int c(int n,int m)
{
	return f[n]*qp(f[m],mod-2)%mod*qp(f[n-m],mod-2)%mod;
}
signed main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=2000000;i++)
		f[i]=f[i-1]*i%mod;
	int n,k;string s;
	cin>>k>>s;
	n=s.size();
	int ans=0;
	for(int i=n;i<=n+k;i++)
	{
		int zh=qp(26,n+k-i);
		zh=zh*c(i-1,n-1)%mod;
		zh=zh*qp(25,i-n)%mod;
		ans=(ans+zh)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void){
	int N,K;
	long long ans = 0;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	for(int l=0;l<=K;l++){
		for(int r=0;r<=K-l;r++){
			if( (l+r)>N)continue;
			int d = K - l - r;
			long long now = 0;
			vector<int> s;
			for(int i=0;i<l;i++){
				now += a[i];
				s.push_back(a[i]);
			}
			for(int i=N-r;i<N;i++){
				now += a[i];
				s.push_back(a[i]);
			}
			sort(s.begin(),s.end());
			for(int i=0;i<d;i++){
				if(i>=s.size())break;
				if(s[i]>=0)break;
				else now -= s[i];
			}
			ans = max(ans,now);
		}
	}
	cout << ans << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    double a;
    char b[123];
    double ans = 0.0;
    Rep(i,N){
        cin >> a;
        cin >> b;
        ans+= a * ( 1 + (b[0] == 'B') * 379999  );
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 256
def Con(N,Edge):
    L = [0]*N
    max = 0
    for i in range(N):
        if L[i] == 1:
            continue
        else:
            E = [i]
            F = [i]
            L[i] = 1
            while E:
                s = E.pop()
                for e in Edge[s]:
                    if L[e] == 0:
                        E.append(e)
                        L[e] = 1
                        F.append(e)
            if len(F) > max:
                max = len(F)
    return max

if __name__ == "__main__":
    N,M = map(int,input().split())
    Edge = [[] for i in range(N)]
    for i in range(M):
        A,B = map(int,input().split())
        Edge[A-1].append(B-1)
        Edge[B-1].append(A-1)
    print(Con(N,Edge))

Measured memory_bytes: 107056
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    d = defaultdict(int)
    for e in a:
        d[e] += 1
    ks = list(d.keys())
    m = len(ks)
    if m < 4:
        x = n / 3
        if m == 1 and ks[0] == 0:
            print("Yes")
            return
        elif m == 2:
            if d[0] == x:
                print("Yes")
                return
        elif m == 3:
            a, b, c = ks
            if d[a] == d[b] and d[a] == d[c] and (a^b^c) == 0:
                print("Yes")
                return
    
    print("No")


    


    
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""


Measured memory_bytes: 20728
use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(e) = run() {
        println!("{}", e);
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut k = String::new();
    io::stdin().read_line(&mut k)?;
    let k: u64 = k.trim().parse()?;
    let n = k / 50;
    let m = k % 50;
    let mut a: Vec<u64> = vec![];
    for i in 0..50 {
        a.push((i % 50) + n);
    }
    for i in 0..m {
        for j in 0..50 {
            if i == j {
                a[j as usize] += 50;
            } else {
                a[j as usize] -= 1;
            }
        }
    }
    println!("50");
    for i in 0..50 {
        print!("{}", a[i]);
        if i == 49 {
            println!();
        } else {
            print!(" ");
        }
    }
    Ok(())
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n ;
  cin >> n ;
  
  FOR(i,n,1000){
    bool tr = false ;
    REP(j,10){
      if(i==111*j){
        cout << 111*j<<endl ;
        tr = true ;
        break ;
      }
    }
    if(tr){
      break ;
    }
  }

  return 0 ;
}




Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
    
n = int(input())
p = [None] + list(map(float, input().split()))
q = list(map(float, input().split()))
T = [[500 for i in range(n+1)] for j in range(n+1)]

psum = [0] * (n+1)
qsum = [0] * (n+1)
qsum[0] = q[0]
for i in range(1,n+1):
    psum[i] = psum[i-1] + p[i]
    qsum[i] = qsum[i-1] + q[i]
    
for i in range(1,n+1):
    T[i][i] = p[i] + (q[i-1] + q[i])*2
    
for l in range(2,n+1):
    for i in range(1,n-l+1+1):
        val_list = [T[i][j] + T[j+2][i+l-1] for j in range(i,i+l-2)]
        val_list.append(T[i][i+l-2] + q[i+l-1])
        val_list.append(T[i+1][i+l-1] + q[i-1])
        if i-2>=0:
            w = psum[i+l-1]-psum[i-1] + qsum[i+l-1]-qsum[i-2]
        else:
            w = psum[i+l-1]-psum[i-1] + qsum[i+l-1]
        T[i][i+l-1] = min(val_list) + w
        
print(T[1][n])


Measured memory_bytes: 10760
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string s;
  cin >> s;
  int ans=0;
  for(int i=0; i < 3; i++){
    if(s[i] == '1')
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = (1 << 20) + 5, MAXM = 2e5 + 5, BOUND = 2e5, MOD = 45989, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-3;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define lc(x) c[x][0]
#define rc(x) c[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
char gdffsaw;
#define G gdffsaw=getchar()
#define GO G;while(gdffsaw<'-')G
#define in(z) GO;z=gdffsaw&15;G;while(gdffsaw>'-')z*=10,z+=gdffsaw&15,G
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;
}

int a, b, c;
int main() {
	ios::sync_with_stdio(false);
	in(a); in(b); in(c);
	cout << min(c, b / a) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	int F[N][10];int P[N][11];
	rep(i,0,N)rep(j,0,10) cin>>F[i][j];
	rep(i,0,N)rep(j,0,11) cin>>P[i][j];
	int ans=-INF;
	rep(i,1,(1<<10)){
		int count[N]={};
		rep(j,0,N)rep(k,0,10){
			if(F[j][k]&&(i&(1<<k))) count[j]++;
        }//print(count,N);
		int sum=0;
		rep(j,0,N) sum+=P[j][count[j]];
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long N,M,a,b,ans;
int main(){
  cin>>N>>M;
  vector<vector<long>>v(1<<17);
  for(int i=0;i<N;i++){
    cin>>a>>b;
    v[a].push_back(b);
  }
  priority_queue<long>q;
  for(int i=1;i<=M;i++) {
    for(auto e:v[i])q.push(e);
    if(q.size())ans+=q.top(),q.pop();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    stack<int> st1;
    stack<pair<int,int> > st2;
    string s;
    cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] == '/' && !st1.empty()) {
            int j = st1.top();
            st1.pop();
            
            int a = i - j;
            sum += a;
            
            while(!st2.empty() && st2.top().first > j) {
                a += st2.top().second;
                st2.pop();
            }
            
            st2.push(make_pair(j, a));
            
        } else if(s[i] == '_') {
        } else if(s[i] == '\\'){ /* \ */
            st1.push(i);
        }
        
    }
    
    vector<int> v;
    while(!st2.empty()) {
        //cout << st2.top().first << " " << st2.top().second << endl;
        v.insert(v.begin(), st2.top().second);
        st2.pop();
    
    }
    cout << sum << endl;
    cout << v.size();
    if(v.size() == 0) {
        cout << endl;
    } else {
        cout << " ";
    }
    
    rep(i,v.size()) cout << v[i] << ((i==(v.size()-1)) ? '\n' : ' ');
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define md (ll)(1e9+7)
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ll n,k,temp=0;     cin>>n>>k;      vii v(n+1,0);
    forin(0,n)  cin>>v[i+1];
    vector<vii> dp(n+1);
    for(auto &i : dp)   i.resize(k+1,0);
    forin(0,n+1) dp[i][0] = 1;
    vii pre(k+1,0);
    forin(1,n+1)
    {
        temp=0;
        for(ll j=0;j<k+1;++j)
        {
            temp += dp[i-1][j]%md;
            pre[j] = temp;
        }
        for(ll j=1;j<k+1;++j)
        {
            dp[i][j] = (pre[j]  - (j-v[i]<=0 ? 0 : pre[j-v[i]-1]))%md;
        }
    }
    cout<<dp[n][k]<<endl;

}


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

int main(void)
{
    int x[100], top = -1;               
    char s[100];

    while (scanf("%s", s) != EOF) {
        if (s[0]=='+') {
            x[top - 1] = x[top - 1] + x[top];
            top--;
        }
        else if (s[0]=='-') {
            x[top - 1] = x[top - 1] - x[top];
            top--;
        }
        else if (s[0]=='*') { 
            x[top - 1] = x[top - 1] * x[top];
            top--;
        }
        else {
            x[top + 1] = atoi(s);
            top++;
}
    }

    printf("%d\n", x[0]);

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int cnt = 1, ans = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] == cnt) cnt++;
    else ans++;
  }
  cout << ((ans == N) ? -1 : ans) << endl;
  return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}



template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n;
    vll t(n), p(m), x(m);
    rep(i, n)
        cin >> t[i];

    cin >> m;

    rep(i, m)
        cin >> p[i] >> x[i];

    ll norTime=0;
    rep(i, n)
        norTime += t[i];



    rep(i, m){
        //dpp(to_string(norTime) + "-(" + to_string(t[p[i]-1]) + '-' + to_string(x[i]) + ')');
        ppp(norTime-t[p[i]-1]+x[i]);
    }




    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b, c, d ;
  cin >> a >> b >> c >> d ;
  
  if(a*b>=c*d){
    cout << a*b <<endl  ;
  }
  else{
    cout << c*d <<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;



int main()
{
#ifdef local
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vi a(3);
    for(int i=0; i<3; i++)
        cin>>a[i];
    sort(all(a));
    int ans=0;
    for(int i=1; i<sz(a); i++)
        ans+=a[i]-a[i-1];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

string v="aeiou";

int main()
{
    __

    double a,b,c;
    cin>>a>>b;
    c=a/b;
    printf("%.10f",c);

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	ll X,A,B;
	cin>>X>>A>>B;
	if(A>=X){
		puts("1");
		return 0;
	}
	if(A<=B){
		puts("-1");
		return 0;
	}
	cout << (X-A+A-B-1)/(A-B)*2+1 << endl;;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int coin[]={1,5,10,50,100,500};
int main(){
    int sum=0;
    for(int i=0;i<6;i++){
        int v;
        scanf("%d",&v);
        sum+=v*coin[i];
    }
    if(sum>=1000)puts("1");
    else puts("0");

    return 0;
}

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

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    boolean flag = true;
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    for(int j = 1;j < n;j++){
      if(a[j-1] == a[j]) flag = false;
    }
    if(flag){
      System.out.println("YES");
    }else{
      System.out.println("NO");      
    }
  }
}

Measured memory_bytes: 64180
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int  n;
    cin>>n;
    double ans;
    if(n%2==1){
        ans=(double)((n/2)+1)/n;
    }else{
        ans=(double)(n/2)/n;
    }
    cout<<fixed<<setprecision(6)<<ans<<endl;
}

Measured memory_bytes: 3800
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print(r % M)


Measured memory_bytes: 3060
"""
Writer: SPD_9X2
https://atcoder.jp/contests/abc160/tasks/abc160_f

全方位木dpの実装はどうしよう？
まず0について求め、必要な値を取っておいて、親に近い方から親の値を使って求める
がよさそう


かけるべきは、 N-1 C (N-小部分木に含まれる頂点数) * 親の答え // (小部分木のmu* N-1C小部分木の頂点数)
"""
import sys
sys.setrecursionlimit(10 ** 6)

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


N = int(input())
mod = 10**9+7
fac,inv = modfac(N,mod)

lis = [ [] for i in range(N)]

for i in range(N-1):

    a,b = map(int,input().split())
    a -= 1
    b -= 1

    lis[a].append(b)
    lis[b].append(a)

plis = [i for i in range(N)]
chnum = [0] * N
mulis = [0] * N

def dfs(v,p):

    rch = 1
    rmu = 1
    chlis = []

    for nex in lis[v]:

        if nex != p:

            ch,mu = dfs(nex,v)
            rch += ch
            rmu *= mu
            rmu %= mod
            chlis.append(ch)

    nsum = sum(chlis)

    for i in range(len(chlis)):

        rmu *= modnCr(nsum,chlis[i],mod,fac,inv)
        rmu %= mod
        nsum -= chlis[i]

    plis[v] = p
    chnum[v] = rch
    mulis[v] = rmu

    return rch,rmu

ans = [None] * N

temp,ans[0] = dfs(0,0)

#print (plis,chnum,mulis)


def dfs2(v,p):

    #print (v,p)

    if v != 0:
        vn = chnum[v]
        mn = mulis[v]

        ans[v] = ans[p] * modnCr(N-1,N-vn,mod,fac,inv) * inverse( modnCr(N-1,vn,mod,fac,inv) ,mod) % mod
    for nex in lis[v]:
        if nex != p:
            dfs2(nex,v)

dfs2(0,0)
print ("\n".join(map(str,ans)))
            
    


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	vector<Vi> s(H, Vi(W));
	int cnth = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (cnth < B) {
				if (j < A) {
					s[i][j] = 1;
				}
				else {
					s[i][j] = 0;
				}
			}
			else {
				if (j < A) {
					s[i][j] = 0;
				}
				else {
					s[i][j] = 1;
				}
			}
		}
		++cnth;
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			cout << s[i][j];
		}
		cout << s[i][W - 1] << endl;
	}

	return 0;
}

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

int main(){
	int n;
	char buf;
	map<char, char> conv;
	
	while(1){
		cin >> n;
		if(n != 0){
			conv.clear();
			
			for(int i = 0; i < n; i++){
				cin >> buf;
				cin >> conv[buf];
			}

			cin >> n;
			for(int i = 0; i < n; i++){
				cin >> buf;
				
				if(conv.count(buf)){
					cout << conv[buf];
				}else{
					cout << buf;
				}
			}
			
			cout << endl;
		}else{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 900
#include <stdio.h>
#include <stack>
#include <vector>
#include <utility>
#include <tuple>

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
  std::vector< std::vector<int> > adj(N);
  std::vector<int> ncol(N, 0);
  for (int n = 0; n < N-1; ++n) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a-1].push_back(b-1); adj[b-1].push_back(a-1);
  }

  std::vector< std::pair<int, int> > list;
  ncol[0] = K; list.push_back(std::make_pair(-1, 0));
  while (!list.empty()) {
    int par = list.back().first;
    int cur = list.back().second;
    list.pop_back();
    int rest = K - 1 - (par >= 0);
    for (int j = 0; j < (int)adj[cur].size(); ++j) {
      int next  = adj[cur][j];
      if (next == par) continue;
      ncol[next] = rest--;
      list.push_back(std::make_pair(cur, next));
    }
  }

  unsigned ans = 1;
  for (int i = 0; i < N; ++i) ans = ((long long)ans*ncol[i])%1000000007;
  printf("%u\n", ans);

  return 0;
}


Measured memory_bytes: 7672
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0; j<k; j++) {
        llong s=0;
        while(s+T[i] <= P) {
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000 * 10000;
    llong mid;
    while(right-left > 1) {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    
    return right;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3876
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long a,b,ans;
int main() 
{
    int T;
    scanf("%d", &T);
    while(T--) 
	{
        scanf("%lld%lld",&a,&b);
        if(a>b) 
			swap(a,b);
        if(a==b) 
            ans=2*(a-1);
        else if (a==b-1)
            ans=2*(a-1);
        else 
		{
            long long c=sqrt(a*b);
            if(c*c==a*b)
				c--;
            if(c*(c + 1)>=a*b) 
                ans=2*c-2;
            else
                ans=2*c-1;
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 128
#pragma GCC optimize "O3"

#include<bits/stdc++.h>

using namespace std;

constexpr int N = 40;

typedef long long LL;

int n, m, c[N], ans = INT_MAX;
LL adj[N], pw2[N];

void dfs(int u, LL ad) {
  if(u == n - 1) {
    ad |= pw2[u];
    LL aad = 0;
    for(int i = 0; i < n; ++i)
      if(ad & pw2[i])
        aad |= adj[i];
    int tans = 0;
    for(int i = 0; i < n; ++i)
      if(aad & pw2[i])
        tans += c[i];
    ans = min(ans, tans);
    return;
  }
  for(int v = 0; v < n; ++v) 
    if((adj[u] & pw2[v]) && !(adj[v] & ad))
      dfs(v, ad | pw2[u]);
}

int main() {

  for(int i = 0; i < N; ++i)
    pw2[i] = (1LL << i);

  scanf("%d %d", &n, &m);
  for(int i = 0; i < n; ++i)
    scanf("%d", c+i);
  for(int i = 0; i < m; ++i) {
    int u, v; scanf("%d %d", &u, &v); --u, --v;
    adj[u] |= pw2[v];
    adj[v] |= pw2[u];
  }

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

}

Measured memory_bytes: 3220
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x>=r&&x+r<=W&&y>=r&&y+r<=H){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 1996
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   int N; cin >> N;
   vector<int> P(N);
   rep(i,N) cin >> P[i];
   map<int,int> mp;
   rep(i,N){
       mp[P[i]] = i;
   }
   int ans = 0;
   int cnt = 0;
   int now = -1;
   for(auto u : mp){
       if(u.second > now) cnt++;
       else{
           ans = max(ans,cnt);
           cnt = 1;
       }
       now = u.second;
   }
   ans = max(ans,cnt);
   ans = N-ans;
   cout << ans << endl;
}



Measured memory_bytes: 10496
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}
function countAB(str:string):number{
  let count=0;
  let pos=0;
  for(let c of str){
    if(pos==1 && c=="B"){count++;}
    if(c=="A")pos=1;
    else pos=0;
  }
  return count;
}
function xor(a:boolean, b:boolean){return (a && !b) ||(!a && b);}
function add(a:number,b:number):number{return a+b;}
const countIf=<V>(f:(V)=>boolean)=>(sum:number, current: V)=>{return sum+(f(current)?1:0);}
const countIfTrue=countIf<boolean>((value)=>value);
function solve(N:number,s:string[]){
  let inner=s.map(str=>countAB(str)).reduce(add,0);
  let startB=s.map(str=>str.startsWith("B")).reduce(countIfTrue,0);
  let endA=s.map(str=>str.endsWith("A")).reduce(countIfTrue,0);
  let existsHagure=s.map(str=>xor(str.startsWith("B"),str.endsWith("A"))).some((value)=>value);
  return inner + Math.max(0, Math.min(startB, endA) + (existsHagure?0:-1));
}
function Main(raw: string) {
  const input=new NormalInput(raw);
  const N=input.int();
  const s=input.strs(N);
  //出力
  console.log(solve(N,s));
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 12144
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	typedef long long ll;
	
	int all_trees;
	int lit_trees;
	ll ans = 1000000001;//10^9+1
	ll temp_hight;

	std::cin >> all_trees >> lit_trees;
	std::vector<ll> hight(all_trees);
	for (int i = 0; i < all_trees; i++){
		std::cin >> hight[i];
	}
	//入力終わり

	std::sort(hight.begin(), hight.end());//昇順ソート

	for (int i = 0; i <= all_trees - lit_trees; i++){
		temp_hight = hight[i + lit_trees - 1] - hight[i];
		ans = std::min(ans, temp_hight);
	}

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

	return 0;
}

Measured memory_bytes: 1024
import heapq
import itertools


class Graph:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.edges = [[] for _ in range(n_nodes)]

    def add_edge(self, s, t, d=None, undirected=False):
        if d is not None:
            self.edges[s].append((t, d))
        else:
            self.edges[s].append(t)
        if undirected:
            self.add_edge(t, s, d)

    def add_edges(self, edges, undirected=False):
        for edge in edges:
            self.add_edge(*edge, undirected=undirected)


class Dijkstra:
    def __init__(self, graph):
        self.graph = graph

    def compute_all(self, s):
        distances = [float('inf') for _ in range(self.graph.n_nodes)]
        visited = [False for _ in range(self.graph.n_nodes)]
        prev_nodes = [None for _ in range(self.graph.n_nodes)]
        distances[s] = 0
        q = []
        for t in range(self.graph.n_nodes):
            heapq.heappush(q, (distances[t], t))
        while q:
            dist_x, x = heapq.heappop(q)
            if visited[x]:
                continue
            visited[x] = True

            for y, d_xy in self.graph.edges[x]:
                if visited[y]:
                    continue
                dist_y = dist_x + d_xy
                if dist_y < distances[y]:
                    distances[y] = dist_y
                    prev_nodes[y] = x
                    heapq.heappush(q, (dist_y, y))
        return distances, prev_nodes


n, m, r = map(int, input().split())
rs = list(map(int, input().split()))

graph = Graph(n + 1)
graph.add_edges([list(map(int,
                          input().split())) for _ in range(m)],
                undirected=True)
dijkstra = Dijkstra(graph)
distances = []
for i in range(n + 1):
    ds, _ = dijkstra.compute_all(i)
    distances.append(ds)
res = float('inf')
for perm in itertools.permutations(rs):
    s = sum([distances[a][b] for a, b in zip(perm, perm[1:])])
    res = min(res, s)
print(res)

Measured memory_bytes: 10236
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	mp := map[string]int{}
	for i := 0; i < n; i++ {
		s := next()
		mp[s]++
	}

	puts(len(mp))
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  map<int, bool> flag;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if (flag[a])
      flag[a] = false;
    else
      flag[a] = true;
  }
  int ans = 0;
  for (pair<int, bool> t : flag)
    if (t.second)
      ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    int res{};
    for( int i = 0; i <= 100/4; i++ )
    {
        for( int j = 0; j <= 100/7; j++ )
        {
            res = i*4 + j*7;
            if( res == N )
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    S = readstr()
    T = readstr()
    ans = 1001
    for i in range(len(S) - len(T) + 1):
        s = S[i:i + len(T)]
        t = 0
        for j in range(len(T)):
            if s[j] != T[j]:
                t += 1
        ans = min(ans, t)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9068
#include <cstdio>
#include <iostream>
#include <climits>
#include <cmath>
#include <utility>
#include <vector>

#define MAX 10010

using namespace std;

int C[MAX] = {0};

void printArr(vector<int> &A, int n)
{
  for(int i = 0; i < n-1 ; i++) cout << A[i] << " ";
  cout << A[n-1] << endl;
}

void CountingSort(vector<int> &A, vector<int> &B, int n)
{
  for(int i = 0; i < n; i++) C[A[i]]++;
  for(int i = 1; i <= MAX; i++) C[i] += C[i-1];
  for(int i = n-1; i >= 0; i--)
  {
      B[--C[A[i]]] = A[i];
  }
}

int main()
{
  int n, tmp;
  vector<int> A, B;
  cin >> n;
  A.resize(n+10);
  B.resize(n+10);
  for(int i = 0; i < n; i++) cin >> A[i];
  CountingSort(A, B, n);
  printArr(B, n);
  return 0;
}

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

int main(){
    string a,b;
    cin>>a>>b;
    size_t la=a.length();
    size_t lb=b.length();

    if(la>lb) cout<<"GREATER"<<"\n";
    else if(la<lb) cout<<"LESS"<<"\n";
    else{
        if(a>b) cout<<"GREATER"<<"\n";
        else if(a<b) cout<<"LESS"<<"\n";
        else cout<<"EQUAL"<<"\n";
    }
     return 0;
}

Measured memory_bytes: 3628
h, w = gets.split.map(&:to_i)
ch, cw = gets.split.map(&:to_i)
dh, dw = gets.split.map(&:to_i)

c = [?., ?#]
s = Array.new(h+3) {Array.new(w+3, c[1])}
h.times {|i| s[i+1][1,w+1] = gets.chars}

move = [[1,0], [-1,0], [0,1], [0,-1]]
warp = (-2..2).to_a.product((-2..2).to_a) - move - [[0,0]]

init = 1 << 20
d = Array.new(h+3) {Array.new(w+3, init)}
d[ch][cw] = 0
t = [[ch, cw]]

(0..).each do |k|
    break if t.empty? || d[dh][dw] < init
    u = []

    while (x,y = t.pop)
        next if d[x][y] < k

        move.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k
                d[xx][yy] = k
                t << [xx, yy]
            end
        end

        warp.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k + 1
                d[xx][yy] = k + 1
                u << [xx, yy]
            end
        end
    end

    t = u
end

p d[dh][dw] == init ? -1 : d[dh][dw]


Measured memory_bytes: 110668
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ld t, l;
  cin >> l;
  l /= 3;
  l = l * l * l;
  cout << fixed << setprecision(15) << l << endl;
}


Measured memory_bytes: 256
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9+7;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> x(n);
    ll ans = 1;
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
        x[i]--;
        if(x[i]<(i-cnt)*2){
            ans *= i+1-cnt;
            cnt++;
            ans %= MOD;
        }
    }

    for (ll i = 1; i <= n-cnt; i++) {
        ans *= i;
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        for(int i = 0; i < q; i++) {
            int m = sc.nextInt();
            if(solve(a, n, m, 0)) System.out.println("yes");
            else System.out.println("no");
        }

        sc.close();
    }

    private static boolean solve(int[] a, int n, int m, int i) {
        if(m == 0) return true;
        if(i == n) return false;
        return solve(a, n, m, i + 1) || solve(a, n, m - a[i], i + 1);
    }
}


Measured memory_bytes: 26792
import math
n, d = map(int,input().split())
lst = []
for i in range(n):
    x = list(map(int,input().split()))
    lst.append(x)
def check (lst, a, b):
    tmp = 0
    for i in range(len(lst[a])):
        tmp = tmp + (lst[a][i] - lst[b][i])**2
    tmp = math.sqrt(tmp)
    if (tmp//1 == tmp):
        return (1)
    else:
        return (0)
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans = ans + check(lst, i, j)
print(ans)


Measured memory_bytes: 9184
N = gets.to_i
A = gets.split.map(&:to_i)

xs = []
xs[0] = A.inject(:+) - 2 * 1.step(N - 1, 2).inject(0) { |sum, ai| sum + A[ai] }

1.upto(N-1) do |i|
  xs[i] = 2 * A[i-1] - xs[i-1]
end

puts xs.join(' ')

Measured memory_bytes: 14156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<20;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,t;cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    vector<LL> dp(n+1,0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        auto k = lower_bound(a.begin(),a.begin() + i,a[i] - t) - a.begin();
        dp[i+1] = dp[i] * (i - k + 1) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}



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

int main(){
  int n; cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  sort(num.begin(),num.end());
  double ans=num[0];
  for(int i=1;i<n;i++){
    ans=(ans+num[i])/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t N;

    scanf("%zu", &N);

    printf("%zu\n", (N-2)*180);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define imin INT_MIN
#define imax INT_MAX
int mod =1e9+7;

 
int main(){
	cin.tie(NULL);
    ios_base::sync_with_stdio();
    ll n,d; cin>>n>>d;
    ll cnt=0;
    for(int i=0; i<n; i++){
     	ll x,y; cin>>x>>y;
      	if(sqrt(x*x + y*y) <= d){
          cnt++;
        }
    }
  cout<<cnt<<"\n";
	return 0;
}

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

using namespace std;

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

    vector<pair<int, int>> p(m);

    for (int i = 0; i < m; i++) {
        cin >> p[i].first >> p[i].second;
    }

    sort(p.begin(), p.end());
    int ans = 1;

    int l = p[0].first;
    int r = p[0].second;

    for (int i = 1; i < m; i++) {
        if (p[i].first == p[i-1].first) continue;

        if (p[i].first >= r) {
            ans++;
            l = p[i].first;
            r = p[i].second;
        } else if (p[i].second < r ) {
            l = p[i].first;
            r = p[i].second;
        } else {
            l = p[i].first;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(void){
  int n;cin >> n;
  vector<int>b(n-1);
  for(int i=0;i<n-1;i++){
    cin >> b[i];
  }
  vector<int>a(n);
  for(int i=0;i<n-1;i++){
    if(b[i-1]>b[i] && i!=0){
      a[i]=b[i];
    }
    if(i==0)a[i]=b[i];
    a[i+1]=b[i];
  }
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
let pi = 4.0 *. atan 1.0;;
let to_radians x = x *. pi /. 180.;;
let split_float s = Str.split (Str.regexp_string ",") s
                    |> List.map float_of_string;;
let () =
  let rec read x y turn =
    let nth = read_line () |> split_float |> List.nth in
    let (d, t) = (nth 0, nth 1) in
    (
      match (d, t) with
        (0., 0.) -> (x, y)
      | (d, t) ->
         read (x +. (d *. (cos (to_radians turn)))) (y +. ((d *. sin (to_radians turn)))) (turn -. t))
  in
  let (x, y) = read 0. 0. 90. in
  Printf.printf "%d\n%d\n" (int_of_float x) (int_of_float y);;

Measured memory_bytes: 2664
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N;
    string S;

    cin >> N >> S;

    bool flag = true;
    if(N%2 == 0){
        REP(i, N/2){
            if (S[i] != S[N/2+i]) {
                flag = false;
                break;
            }
        }
    }
    else flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592