akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;
int n,x,y;
string S;

vector<int> hor, ver;

bool check(int x, vector<int> &v)
{
    vector<int> cur;
    cur.pb(0);
    for(auto &i:v)
    {
        vector<int> temp;
        for(auto &y:cur)
        {
            temp.pb(y+i); temp.pb(y-i);
        }
        sort(temp.begin(), temp.end());
        auto it = unique(temp.begin(), temp.end());
        temp.resize(distance(temp.begin(),it));
        cur = temp;
    }
    for(int &i:cur) if(i == x) return true;
    return false;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin >> S; n = S.size();
    int kk = 0;
    int st = 1;
    int ctr = 0;
    bool first = true;
    for(int i = 0; i < n; ++i)
    {
        char temp = S[i];
        if(temp == 'T')
        {
            if(ctr != 0)
            {
                if(first == true)
                {
                    kk -= ctr;
                }
                else
                {
               // cout << "st " << st << " ctr " << ctr << endl;
                    if(st == 1)
                    {
                        hor.pb(ctr);
                    }
                    else
                    {
                        ver.pb(ctr);
                    }
                }
                ctr = 0;
            }
            st *= -1;
            first = false;
        }
        else
        {
            ctr++;
        }

    }
    if(ctr != 0)
    {
        //cout << "st " << st << " ctr " << ctr << endl;
        if(first == true)
                {
                    kk -= ctr;
                }
                else
                {
               // cout << "st " << st << " ctr " << ctr << endl;
                    if(st == 1)
                    {
                        hor.pb(ctr);
                    }
                    else
                    {
                        ver.pb(ctr);
                    }
                }
                ctr = 0;
    }
    cin >> x >> y; x += kk;
    if(check(x,hor) and check(y,ver))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
	//IO();
	
	int n, len = 0; cin >> n;
	vector<int> a(n); unordered_map<int, int> hmap;
	for(auto &it : a) {
		cin >> it; len = max(len, it);
		hmap[it]++;
	}
	vector<bool> v(len+1, true);

	for(auto it : a) {
		for(int j = 2*it ; j <= len ; j+=it) v[j] = false;
	}

	int ans = 0;
	for(int i=1 ; i<=len ; i++) ans += (v[i] && hmap.count(i) && hmap[i] == 1) ? 1 : 0;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12516
const main = input => {
  let x = Number(input.trim())
  let m = 100
  let y = 0
  while(m < x) {
    y += 1
    m = Math.floor(m * 1.01)
  }
  console.log(String(y))
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 29500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ld long double
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int mod = 1e9+7;
const int mod1 = 998244353;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int, int>&i, const pair<int, int>&j) {
    return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   int n, m;
   cin >> n >> m;
  
   int h[n+1];
   for(int i = 1; i <= n; ++i) {
      cin >> h[i];
   }
  
   int u, v;
   vector<int> adj[n+1];
   for(int i = 1; i <= m; ++i) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
  
   int good = 0;
   int maxe[n+1] = {0};
   for(int i = 1; i <= n; ++i) {
      if(!adj[i].empty()) {
         int mx = -1;
         for(auto x : adj[i]) {
            mx = max(mx, h[x]);
         }
         maxe[i] = mx;
      }
   }

   for(int i = 1; i <= n; ++i) {
      if(adj[i].empty()) {
         good++;
      }
      if(h[i] > maxe[i] && maxe[i] != 0) {
         //cout << h[i] << " " << maxe[i] << endl;
         good++;
      }
   }
  
   cout << good;
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   faster;
   cout.precision(10);
   cout << fixed;

   int t = 1;
   //cin >> t;
   while(t--)
      test();

   return 0;
}

Measured memory_bytes: 9520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
	int n,m; cin>>n>>m;
	double l[n],a[n],b[n]; rep(i,n) cin>>l[i]>>a[i]>>b[i];
	double d2[n][n];
	rep(i,n)rep(j,n){
		d2[i][j]=(l[i]-l[j])*(l[i]-l[j])+(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]);
	}

	int perm[n]={}; rep(i,m) perm[n-1-i]=1;
	double ans=0;
	do{
		double sum=0;
		rep(i,n)for(int j=i+1;j<n;j++){
			if(perm[i]&&perm[j]){
				sum+=d2[i][j];
			}
		}
		ans=max(ans,sum);
	}while(next_permutation(perm,perm+n));
	printf("%.10f\n",ans);
	return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
long long n,x,j,ans;
long long a[210000],s[210000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		a[i]=a[i-1]^x;
		s[i]=s[i-1]+x;
	}
	j=1;
	for(int i=1;i<=n;i++)
	{
		while((a[i]^a[j-1])!=s[i]-s[j-1])j++;
		ans+=i-j+1;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 6892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 
ll n,m,j,k,t,l,r;
ll a,b,c,d,x;
char A,B,C,X,Y,Z;
ll ans,MAX,MIN=40,sum;
ll ax[1000000];
char str[100000];
ll dx[12];
ll bx[2000500];


int main()
{
    ll i;
    t=1;
    //scanf("lld",&t);
    while(t--)
    {
        ll flag=0;
        cin>>x;
        n=100;
        i=0;
        while(n<x)
        {
            n+=n/100;
            i++;
        }
        cout<<i<<endl;

    }
	return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int n, sum = 0,x,a[234567];
	cin >> n;
	x = 2 * ((n-1) / 11)+1;
	if ((n-1)%11 > 5) { cout << x + 1; }
	else { cout << x; }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a=0,b=0,n,m,y=0,max;
  int X[500];
  int Z[500];
  char B[11];
  
  scanf("%s",B);
  
  while(B[a])
    a++;
  
  for(n=0;n<a;n++){
    if(B[n]=='A' || B[n]=='C'){
      y++;
    }else if(B[n]=='G' || B[n]=='T'){
      y++;
    }else{
      X[b] = y;
      b++;
      y = 0;
    }
  }
  
  X[b] = y;
  b++;  
  max = X[0];
  
  for(m=1;m<b;m++){
    if(max < X[m]){
      max = X[m];
    }
  }
    
  printf("%d",max);
  
  return 0;
}

Measured memory_bytes: 128
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const P: usize = 1000000007;

fn prime_division(n: usize, a: &mut Vec<usize>) {
    let mut x = n;
    for i in 2..n+1 {
        while x%i == 0 {
            a[i] += 1;
            x /= i;
        }
    }
}

fn main() {
    let n = get!(usize);
    let mut a = vec![0; 1000];
    for i in 2..n+1 {
        prime_division(i, &mut a)
    }
    let mut r: usize = 1;
    for x in a {
        if x > 0 {
            r = (r * (x+1)) % P;
        }
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        int[] a = Arrays.stream(stdin.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        
        Queue<Integer> x = new ArrayDeque<>(); // 奇数
        Queue<Integer> y = new ArrayDeque<>(); // 2の倍数だが4の倍数ではない
        Queue<Integer> z = new ArrayDeque<>(); // 4の倍数
        
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                if (a[i] % 4 == 0) {
                    z.add(a[i]);
                } else {
                    y.add(a[i]);
                }
            } else {
                x.add(a[i]);
            }
        }
        
        List<Integer> b = new ArrayList<>();
        while (!(x.isEmpty() && z.isEmpty())) {
            if (!x.isEmpty()) {
                b.add(x.poll());
            }
            
            if (!z.isEmpty()) {
                b.add(z.poll());
            }
        }
        b.addAll(y);
        
        boolean ok = IntStream.range(0, n - 1).allMatch(i -> (b.get(i) * b.get(i + 1)) % 4 == 0);
        System.out.println(ok ? "Yes" : "No");
    }
}

Measured memory_bytes: 46896
#include<stdio.h>
int main(){
  int n,i,j,k,c[100010]={};
  long long ans=1,M=1e9+7;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    k=i;
    for(j=2;j<=i;j++){
      while(k%j==0){
	c[j]++;
	k/=j;
      }
    }
  }
  //for(i=0;i<=n;i++)printf("%d\n",c[i+1]);
  for(i=1;i<=n;i++)ans=(ans*(c[i]+1))%M;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 512
(let* ((n (read))
       (m (read))
       (q (read))
       (p (make-array (list (1+ q) 4) :initial-element 0))
       (ans 0))
  ; read
  (loop :for i :from 1 :to q
        :do (progn
              (setf (aref p i 0) (read))
              (setf (aref p i 1) (read))
              (setf (aref p i 2) (read))
              (setf (aref p i 3) (read))))
  
  (defun ev (stack)
    (loop :for i :from 1 :to q
          :if (= (aref p i 2)
                 (- (aref stack (aref p i 1))
                    (aref stack (aref p i 0))))
          :sum (aref p i 3)))

  (defun main (ind stack)
    (cond ((= ind (1+ n))
           (setf ans (max ans (ev stack))))
          (t
           (loop :for i :from (aref stack (1- ind)) :to m
                 :do (progn
                       (setf (aref stack ind) i)
                       (main (1+ ind) stack))))))
  ;;
  (let ((s (make-array `(,(1+ n)) :initial-element 1)))
    (main 1 s))
  (format t "~A~%" ans))


Measured memory_bytes: 24752
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dbl := makeInts(64, n)
	for i := 0; i < n; i++ {
		dbl[0][i] = getNextInt(scanner) - 1
	}

	for i := 1; i < 64; i++ {
		for j := 0; j < n; j++ {
			dbl[i][j] = dbl[i-1][dbl[i-1][j]]
		}
	}
	ans := 0
	for i := 62; i >= 0; i-- {
		if k>>uint(i)%2 == 0 {
			continue
		}
		ans = dbl[i][ans]
	}
	fmt.Fprintln(writer, ans+1)
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 107468
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  string s;
  cin >> s;
  rep(i,sz(s)){
    cout << s[i];
    if(i==3)cout << ' ';
  }
  cout << endl;
  return 0;
}


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

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  int kazu = S.size();
  for (int i = 0; i < min(kazu, K); i++) {
    cout << S.at(i);
  }
  if (K < S.size()) {
    cout << "...";
  }
  cout << endl;
  return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll l;cin>>l;
  cout<<fixed<<setprecision(10)<<(l*l*l)/27.0<<endl;
}


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

int main(){
  int a, b;
  vector<int> result(3);
  cin >> a >> b;
  result[0] = a+b;
  result[1] = a-b;
  result[2] = a*b;
  cout << *max_element(result.begin(), result.end()) << endl;
}

Measured memory_bytes: 256
import sys
  
BUILDINGS = tuple(x for x in range(4))
FLOORS = tuple(x for x in range(3))
ROOMS = tuple(x for x in range(10))
  
occupant = [[[0 for r in ROOMS] for f in FLOORS] for b in BUILDINGS]
  
n = input() # ????????¨???
  
for line in sys.stdin:
    b, f, r, v = map(int, line.split())
    occupant[b - 1][f - 1][r - 1] += v
      
for b in BUILDINGS:
    if b:
        print('#' * 20)
    for f in FLOORS:
        print("", *occupant[b][f])

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

using namespace std;
const long long int MOD=1e9+7;

int main(){
  long long n, a[200009];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int now=0;
  for(int i=0;i<n;i++){
    if(a[i] == now+1){
      now ++;
    }
  }
  if(now == 0)cout << -1 << endl;
  else cout << n - now << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a;
    string s;
    t = 1;
    while(t--) {
     a = 0;
     cin >> s;
     if(s[0] == '1')
      a++;
     if(s[1] == '1')
      a++;
     if(s[2] == '1')
      a++;
     cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

const MOD = 1000000007

func main() {
    var n int
    var s1, s2 string
    var ans, preState, index int
    fmt.Scan(&n)
    fmt.Scan(&s1)
    fmt.Scan(&s2)
    if s1[0] == s2[0] {
        ans = 3
        preState = 0
        index = 1
    } else {
        ans = 6
        preState = 1
        index = 2
    }

    for index < n {
        if s1[index] == s2[index] {
            if preState == 0 {
                ans *= 2
            } else {
                ans *= 1
            }
            preState = 0
            index += 1
        
        } else {
            if preState == 0 {
                ans *= 2
            } else {
                ans *= 3
            }
            preState = 1
            index += 2
        }
        ans %= MOD
    }
    fmt.Println(ans)
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



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

    if(s.size()<4){
        cout << "No" << endl;
        return 0;
    }

    if("YAKI"==s.substr(0,4)){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
using System;

namespace abc053_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;
            x = Convert.ToInt32(Console.ReadLine());
            if (x<1200)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ARC");
            }
        }
    }
}


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

void solve() {
	int l, r, d;
	cin >> l >> r >> d;
  	int count = 0;
	for (int i=l; i<=r; ++i) {
		if (i%d == 0) ++count;
	}
	cout << count;
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tc = 1; //cin >> tc;
	while (tc--) {
		solve();
		cout << '\n';
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 55

const double g = 9.8;

int N,V,X,Y;
int L[NUM],B[NUM],R[NUM],T[NUM];

double calc(double vy,double t){
	return vy*t-g*t*t/2;
}

int cmp(double lb,double ub,double a){
	return a < lb + EPS ? -1: a > ub - EPS? 1:0;
}

bool check(double qx,double qy){
	double a = g*g/4, b = g*qy-V*V, c = qx*qx + qy*qy;
	double D = b*b-4*a*c;

	if(D < 0 && D > -EPS)D = 0;
	if(D < 0)return false;

	for(int d = -1; d <= 1; d += 2){
		double t2 = (-b + d*sqrt(D)) / (2 * a);
		if(t2 <= 0)continue;
		double t = sqrt(t2);
		double vx = qx/t,vy = (qy+g*t*t/2)/t;

		double yt = calc(vy,X/vx);
		if(yt < Y-EPS)continue;

		bool ok = true;
		for(int i = 0; i < N; i++){
			if(L[i] >= X)continue;
			if(R[i] == X && Y <= T[i] && B[i] <= yt)ok = false;
			int yL = cmp(B[i],T[i],calc(vy,L[i]/vx));
			int yR = cmp(B[i],T[i],calc(vy,R[i]/vx));
			int xH = cmp(L[i],R[i],vx*(vy/g));
			int yH = cmp(B[i],T[i],calc(vy,vy/g));
			if(xH == 0 && yH >= 0 && yL < 0)ok = false;
			if(yL * yR <= 0)ok = false;
		}
		if(ok)return true;
	}
	return false;
}

void solve(){

	for(int i = 0; i < N; i++){
		R[i] = min(R[i],X);
	}

	bool ok = check(X,Y);

	for(int i = 0; i < N; i++){
		ok |= check(L[i],T[i]);
		ok |= check(R[i],T[i]);
	}
	puts(ok ? "Yes" : "No");
}

int main(){

	scanf("%d %d %d %d",&N,&V,&X,&Y);

	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d",&L[i],&B[i],&R[i],&T[i]);
	}

	solve();

	return 0;
}



Measured memory_bytes: 3176
#include<iostream>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    rep(i, 0, S.size()) {
        if (i % 2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int sum = 0;
    char c;
    while (true) {
        scanf("%c", &c);
        if (c == '\n') {
            printf("%d",sum);
            printf("%c",'\n');
            sum = 0;
            scanf("%c", &c);
            if (c == '0')break;
        }
        sum += int(c - '0');
    }
    return 0;
}


Measured memory_bytes: 2704
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	ll mi = 1e18, ans = -1;
	rep(i,n){
		if(abs(2*a[i] - a[n-1]) < mi){
			ans = a[i];
			mi = abs(2*a[i] - a[n-1]);
		}
	}
	cout << a[n-1] << " " << ans << endl;
	return 0;
}

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

long long a, b;
int main() {
	cin >> a >> b;
	if(a == b) cout << 1, exit(0);
	int r = 60;
	while((a >> r & 1) == (b >> r & 1)) --r;
	a &= (1ll << r+1)-1, b &= (1ll << r+1)-1;
	int k = r-1;
	while(k >= 0 && !(b >> k & 1)) --k;
	long long ans = (1ll << r+1) - a;
	if(1ll << k+1 < a) ans -= a - (1ll << k+1);
	cout << ans;
}


Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

ll MOD=1000000007;
inline ll add_m(ll a, ll b) { return (a + b) % MOD; }

int main(void)
{
    int N, K;
    cin >> N >> K;

    ll ret = 0;
    FORE(k, K, N+1) {
        ll minS = (ll)(0+(k-1))*k/2LL;
        ll maxS = (ll)((N-(k-1))+N)*k/2LL;
        ret = add_m(ret, maxS - minS + 1LL);
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  rep(i, 0, k) {
    if(a >= b) b *= 2;
    else if(b >= c) c *= 2;
  }
  if(a < b && b < c) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,rt=1;
char s[N];
vector<pair<int,int> >v;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    if(s[n]=='1'||s[1]=='0'||s[n-1]=='0'){printf("-1\n");return 0;}
    int l=1,r=n-1;
    while(l<=r)
        if(s[l++]!=s[r--]){printf("-1\n");return 0;}
    v.push_back({1,2});
    rt=2;
    for(int i=3;i<=n;i++)
    {
        v.push_back({rt,i});
        if(s[i-1]=='1') rt=i;
    }
    for(int i=0;i<v.size();i++)
        printf("%d %d\n",v[i].first,v[i].second);
}


Measured memory_bytes: 2420
Uses math;
var m,d,d1,d10,i,j,k,count:int64;
begin
read(m,d);
count:=0;
d1:=d mod 10;
d10:= d div 10;
for i := 4 to min(m,81) do
begin
 for j:= 2 to d10-1 do
  for k:= 2 to 9 do
   if i=j*k then inc(count);
 for k:= 2 to d1 do
  if i=k*d10 then inc(count);
end;

write(count)
end.

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
debug = False

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

# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())



def solve():
    n = int(input())
    mat_list = []
    for i in range(n):
        mat_list.append(list(map(int, input().split())))
    dprint(mat_list)

    # 掛け始めのidxと掛け終わりのidxをi, jとし、計算回数を持つメモ
    memo = [[0 for i in range(n)] for i in range(n)]

    def calc(start, end):
        dprint("*", start, end)
        # 1つの行列なら0
        if end == start:
            return 0

        # メモがあれば返す
        if memo[start][end] != 0:
            return memo[start][end]

        # 2つの行列なら、答えを計算しメモ追記
        if end - start == 1:
            cost = mat_list[start][0] * mat_list[start][1] * mat_list[end][1]
            memo[start][end] = cost
            dprint(start, end, cost)
            return cost

        # 3つ以上なら、再帰
        min_cost = -1
        if end - start >= 2:
            for right_start in range(start+1, end+1):
                left = calc(start, right_start-1)
                right = calc(right_start, end)
                cost = left + right + mat_list[start][0] * mat_list[right_start][0] * mat_list[end][1]
                if min_cost == -1 or min_cost > cost:
                    min_cost = cost
                dprint(start, end, right_start, min_cost, cost)

        memo[start][end] = min_cost
        return min_cost

    ans = calc(0, n-1)
    dprint(memo)
    print(int(ans))

solve()


Measured memory_bytes: 5908
#include <bits/stdc++.h>
#define INF 100000000000000000ll
using namespace std;
typedef long long int ll;

int main()
{
	ll N, P, Q, res = -INF, tmp = 0;
	cin >> N >> P >> Q;
	vector<ll> C(N), add(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		tmp += C[i];
	}
	for (int i = 0; i < N; i++) {
		add[i] = Q * P - C[i] - i * P;
	}
	sort(add.begin(), add.end());
	res = max(res, tmp);
	for (int i = 0; i < N; i++) {
		tmp += add[N - 1 - i] + P * i * 2;
		res = max(res, tmp);
	}
	cout << res << endl;
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;

  if(a-2*b <=0 ){
    cout << 0;
  }
  else
  {
    cout << a - 2 * b;
  }

}


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

int main(){
  int n;
  int field[15][15];

  while(cin >> n, n){
    memset(field, 0, sizeof(field));

    int x = n / 2;
    int y = n / 2 + 1;

    field[y][x] = 1;

    x++, y++;
    int cnt = 2;
    
    while(cnt != n*n+1){
      if(field[y][x] > 0 && 0 <= x && x < n && 0 <= y && y < n){
	x--, y++;
	continue;
      }
      else if(x >= n){
	x = 0;
	continue;
      }
      else if(x < 0){
	x = n-1;
	continue;
      }
      else if(y >= n){
	y = 0;
	continue;
      }
      field[y][x] = cnt;
      cnt++, x++, y++;
    }
  
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	printf("%4d", field[i][j]);
      }
      cout << endl;
    }
  }
  return 0;
}


  

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int n = 0;
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			return;
		}
		
		int n2 = n;
		int sn = 0;
		while (n2 > 0) {
			sn += (n2 % 10);
			n2 /= 10;
		}
		
		System.out.println((n % sn == 0) ? "Yes" : "No");
	}
}


Measured memory_bytes: 21332
#include<iostream>

using namespace std;
typedef unsigned long long ULL;
void process(ULL N, int use[3], int finish, ULL *ans,ULL number, int pos);
int main(){
    ULL N;
    ULL temp;
    int use[3] ={0,0,0};
    int count;
    ULL ans = 0;
    
    cin >> N;
    temp = N;
    count = 0;
    while(temp > 0 ){
        count++;
        temp /= 10;
    }
    process(N,use,count,&ans,0,0);
    
    cout << ans << endl;
}

void process(ULL N, int use[3], int finish, ULL *ans,ULL number, int pos){
    int i;
    if( use[0] > 0 && use[1] > 0 && use[2] > 0 && number <= N){
        //cout << number << endl;
        *ans += 1;
    }
    if( pos > finish){
        return;
    }
    for(i=0;i<3;i++){
        use[i]++;
        process(N,use,finish,ans,number * 10 + (i+1)*2+1,pos+1);
        use[i]--;
    }
}


Measured memory_bytes: 256
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn gcd(a: usize, b: usize) -> usize {
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn main() {
    let (n, m) = input_pair::<usize>();
    let arr: Vec<usize> = input_arr();

    let x = arr.iter().fold(1, |a, &b| a * b / gcd(a, b));
    if arr.iter().all(|a| (x / a) % 2 == 1) {
        println!("{}", 2 * m / x - m / x);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4152
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;

int main()
{
    IO;
    int n;
    int d,x;
    cin>>n>>d>>x;
    for(int i=0;i<n;i++)
    {
        int s;
        cin>>s;
        x += (d-1) / s + 1;
    }
    cout<<x<<endl;
    return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

// Function to sort the vector elements 
// by second element of pairs 
bool sortbysec(const pair<int, int>& a, 
			const pair<int, int>& b) 
{ 
	return (a.second < b.second); 
} 

// Function to find maximal disjoint set 
void maxDisjointIntervals(vector<pair<int, int> > list) 
{ 

	// Sort the list of intervals 
	sort(list.begin(), list.end(), sortbysec);

    ll count = 1;

	// End point of first interval 
	int r1 = list[0].second; 

	for (int i = 1; i < list.size(); i++) { 
		int l1 = list[i].first; 
		int r2 = list[i].second; 

		if (l1 >= r1) { 
            count++;
			r1 = r2; 
		} 
	}
    cout << count << nl;
} 

// Driver code 
int main() 
{ 
	int n;
    cin >> n; 
	vector<pair<int, int> > intervals(n);
    loop(z, intervals)
    {
        int x, l;
        cin >> x >> l;
        z.F = x - l;
        z.S = x + l;
    } 
	maxDisjointIntervals(intervals); 
	return 0; 
} 


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

const ll MOD = 998244353;

template <typename T>
struct BIT_tree{
    int n;  // 配列の要素数(数列の要素数+1)
    vector<T> bit; // データの格納先(1-indexed)。初期値は0
    BIT_tree(vector<T> v){
        n = v.size() + 1;
        bit.assign(n, 0);
        int i;
        for(i = 0;i < v.size();++i){
            add(i, v.at(i));
        }
    }
    
    //0-indexedで受け取り, 内部は1-indexedで作動
    void add(int i, T x){
        ++i;
        int ind;
        for(ind = i;ind < n;ind += (ind & -ind)){
            bit.at(ind) += x;
        }
    }
    
    //1-indexedで作動
    T sum_sub(int i){
        T s = 0;
        int idx;
        for(idx = i;idx > 0;idx -= (idx & -idx)){
            s += bit.at(idx);
        }
        return s;
    }
    
    //0-indexedで受け取り, [l, r)に加算, 1-indexedで渡す
    T sum(int l, int r){
        return sum_sub(r) - sum_sub(l);
    }
    
    ll lower_bound(T w){
        if(w < 0) return -1;
        int x = 0, r = 1;
        while(r < n) r = r<<1;
        int len;
        for(len = r;len > 0;len = len >> 1){
            if(x + len < n && bit.at(x + len) < w){
                w -= bit.at(x+len);
                x += len;
            }
        }
        return x;
    }
};

int main()
{
    ll i,j;
    ll n, k;
    cin >> n >> k;
    vector<ll> l(k);
    vector<ll> r(k);
    rep(i,k){
        cin >> l[i] >> r[i];
    }
    vector<ll> a(n+10, 0);
    BIT_tree<ll> bit(a);
    bit.add(1, 1);
    for(i = 2;i <= n;++i){
        ll sup = 1;
        ll inf = i-1;
        ll tmp = 0;
        rep(j,k){
            ll left = i - r[j];
            ll right = i - l[j];
            if(inf < left) continue;
            else if(sup > right) continue;
            ll ss = max(sup, left);
            ll ii = min(inf, right);
            tmp += bit.sum(ss, ii+1);
            tmp %= MOD;
        }
        bit.add(i, tmp);
    }
    cout << bit.sum(n, n+1) << endl;

    return 0;
}

Measured memory_bytes: 8008
#include<iostream>

using namespace std;

int main(){
  int a,b;
  int count;
  while(1){
    count = 0;
    cin >> a;
    if( a == 0) break;

    b = 1000 - a;
    a = b%500;
    count = count + b/500;

    b= a%100;
    count = count + a/100;

    a = b%50;
    count = count + b/50;

    b = a%10;
    count = count + a/10;

    a = b%5;
    count = count + b/5;

    b = a%1;
    count = count + a/1;

    cout << count <<endl;

  }
  return 0;
}

Measured memory_bytes: 1160
N,K = map(int,input().split())
nums = list(map(int,input().split()))
nums.sort()
dif = []
cnt=[]
for i in range(N-1):
  if nums[i] != nums[i+1]:
    dif.append(i+1) #玉の番号の変わり目を記録する
if len(dif)==0:
  print(0)
else:
  for i in range(len(dif)+1):
    if i == 0:
      cnt.append(dif[0])
    if i == len(dif):
      cnt.append(N-dif[-1])
      break
    cnt.append(dif[i]-dif[i-1])
  cnt.sort(reverse=True)#それぞれの球が何個ずつあるかのリスト作成
  n = 0
  if len(cnt)<=K:
    print(0)
  else:
    for i in range(K):
      n+=cnt[i]
    print(N-n)
  
    
  


Measured memory_bytes: 24852
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = Long.parseLong(scan.next());
		LinkedList<Long> slimes = new LinkedList<>();
		while(scan.hasNext()) {
			slimes.add(Long.parseLong(scan.next()));
		}
		Collections.sort(slimes);
		long sum = slimes.poll();
		long size = N;
		while (!slimes.isEmpty()) {
			long slime = slimes.poll();
			if (sum * 2 < slime) {
				size = slimes.size() + 1;
			}
			sum += slime;
		}
		System.out.println(size);
	}
}


Measured memory_bytes: 54220
"use strict"

function main(input) {
  input = input.split(" ").map(v => ~~v)

  const N = input[0] //100
  const M = input[1] // 5
  let b = (N - M) * 100 //ms // 95

  let a = 1 / Math.pow(0.5, M) //32
  // console.log((1900 * M + b) * a)
  console.log(1900 * M * a + b * a)
  // console.log(a, b, a * b, 608000 - a * b, a * 1900, a * 1900 + a * b)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21192
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashSet;

fn divisors(n: i64) -> HashSet<i64> {
    let mut ds = vec![];
    let mut d = 1;
    while d * d <= n {
        if n % d == 0 {
            ds.push(d);
            ds.push(n / d);
        }
        d += 1;
    }
    let uniq: HashSet<i64> = ds.into_iter().collect();
    uniq
}

fn main() {
    let n: i64 = read();

    let mut ans = 0;
    for i in 0..n+1 {
        if i % 2 == 0 {
            continue;
        }
        let a = divisors(i);
        if a.len() == 8 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    long mat1[n][m]={},mat2[m][l] = {},result[n][l] = {};
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            scanf("%ld",&mat1[i][j]);
        }
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < l;j++){
            scanf("%ld",&mat2[i][j]);
        }
    }
    
    int x=0;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            for(int k = 0;k < m;k++){
                result[i][j] += mat1[i][k] * mat2[k][j];
            }
        }
    }
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            if(j != l-1){
                printf("%ld ",result[i][j]);
            } else{
                printf("%ld\n",result[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2952
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << min(N*A, B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    int a[5];
    int temp = 0;
    for(int i=0; i<5; i++){
        cin >> a[i];
    }
    for(int i=1; i<5; i++){
        if((a[i]-1)%10 < (a[temp]-1)%10){
            temp = i;
        }
    }

    int ans = 0;
    for(int i=0; i<5; i++){
        if(i != temp){
            int temp2 = (a[i] + 9)/10;
            ans += temp2*10;
        }
    }
    ans += a[temp];

    cout << ans;



    return 0;
}

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

int main(){
  int n,k,len=0;
  int l[55];
  cin>>n>>k;
  for (int i = 0; i < n; i++) {
    cin>>l[i];
  }

  sort(l, l+n, greater<int>());
  for (int i = 0; i < k; i++) {
    len += l[i];
  }
  cout<<len<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  ll l=2;
  ll r=3;
  if(a[n-1]!=2){
    COUT(-1);
    return 0;
  }
  for(int i=n-2;i>=0;i--){
    ll k=((l+a[i]-1)/a[i])*a[i];
    if((r<k)){
      COUT(-1);
      return 0;
    }
    l=((l+a[i]-1)/a[i])*a[i];
    r=(r/a[i])*a[i]+a[i]-1;
  }
  cout<<l<<" "<<r<<endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

#define PI 3.14159265358979
#define INF INT_MAX

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

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

    vector<int> dir(n, -1);
    vector< vector<int> > adj(n);

    int a, b;
    rep(i,m) {
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int e : adj[v]) {
            if (e == v) continue;
            if (dir[e] != -1) continue;

            dir[e] = v;
            que.push(e);
        }
    }

    bool result = true;
    rep(i,n) if (dir[i] == -1) result = false;

    if (result) {
        cout << "Yes" << endl;
        rep(i,n) if(i) cout << dir[i]+1 << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 10344
n,a,b = map(int, input().split())
diff = abs(a-b)

if diff%2 == 0:
    print(diff//2)
    exit()

adiff = min( abs(a-1), abs(n-a) )
bdiff = min( abs(b-1), abs(n-b) )
mdiff = min(adiff,bdiff)

ans = mdiff + 1 + diff//2
print(ans)

Measured memory_bytes: 61764
import math
Q=int(input())
A=[list(map(int,input().split())) for i in range(Q)]
B,C=zip(*A)
a=max(max(B),max(C))

def get_primenumber(n):
  prime=[]
  limit=math.sqrt(n)
  data=[i+1 for i in range(1, n)]
  while True:
    p=data[0]
    if limit<=p:
      return prime+data
    prime.append(p)
    data=[e for e in data if e % p != 0]
        
X=get_primenumber(a)
P=[False]*(a+1)
L=[False]*(a+1)
for i in X:
  P[i]=True
for i in X:
  if P[(i+1)//2]:
    L[i]=True
C=[]
c=0
for i in range(a+1):
  if L[i]:
    c+=1
  C.append(c)
for s,t in A:
  print(C[t]-C[s-1])

Measured memory_bytes: 36080
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n){
		vi d(n);
		rep(i,0,n) cin>>d[i];
		sort(all(d));
		rep(i,1,n) d[i]+=d[i-1];
		int ans=0;
		rep(i,0,n) ans+=d[i];
		o(ans);
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3006;

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

void solve()
{
	dp[0][0]=1;
	for(int i=0;i<N;++i){
		double prb = p[i];
		for(int j=0;j<=i;++j){
			dp[i+1][j+1] += prb*dp[i][j];
			dp[i+1][j] += (1.0-prb)*dp[i][j];
		}
	}
	double res = 0;
	for(int i=(N+1)/2;i<=N;++i) res+=dp[N][i];
	printf("%.12lf", res);
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i){
		cin >> p[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
const ll INF=1000000;
using namespace std;

int main() {
    ll K;
    cin>>K;
    vec A(K);
    A[0]=7;
    rep(i,0,K-1) {
        A[i+1]=(A[i]*10+7)%K;
    }
    rep(i,0,K) {
        if(A[i]%K==0) {
            cout<<i+1<<endl;
            return 0;
        }
        }
        cout<<"-1"<<endl;
    }


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 512
/*hello! guys~*/
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
int n,x[101],mmin=0,mmax=0,sum=0;
double o;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
	scanf("%d",&x[i]);
	o+=x[i];
}
int pj=o/n;
if(o/n-pj>=0.5)
pj+=1;
for(int i=0;i<n;i++)
{
	sum+=(x[i]-pj)*(x[i]-pj);
}
printf("%d\n",sum);
return 0;
}

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

int main() {
    string S,T;
    cin >> S;
    cin >> T;
    int s = S.size();
    int t = T.size();
    
    vector<int> vec(s-t+1);
    int N = vec.size();
    for (int i=0; i<N; i++) {
        int count = 0;
        for (int j=0; j<t; j++) {
            if (S.at(i+j) != T.at(j)) {
                count++;
            }
        }
        vec.at(i) = count;
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(0) << endl;
}

Measured memory_bytes: 3600
def main():
    n = int(input())
    xs = [int(x) for x in input().split()]

    dests = [0] + xs + [0]
    tos = dests[1:]
    frs = dests[:-1]

    cur, allcost = 0, 0
    for dest in tos:
        allcost += abs(dest - cur)
        cur = dest

    for i in range(n):
        cost = allcost - abs(frs[i] - tos[i]) - abs(frs[i+1] - tos[i+1]) + abs(frs[i] - tos[i+1])
        print(cost)


if __name__ == '__main__':
    main()

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

int main() {
  int x, y;
  cin >> x >> y;
  rep(i,400) {
    rep(j,400) {
      if(i+j==x&&2*i+4*j==y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3624