akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::cmp::Ordering;

trait BinarySearch<T> {
    fn upper_bound(&self, &T) -> usize;
    fn lower_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => low = mid + 1,
                Ordering::Greater => high = mid,
            }
        }
        low
    }

    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => low = mid + 1,
                Ordering::Equal | Ordering::Greater => high = mid,
            }
        }
        low
    }
}

fn main() {
    let _n = input!(i64);
    let mut a = input!(i64; n);
    let b = input!(i64; n);
    let mut c = input!(i64; n);

    a.sort();
    c.sort();

    let mut cnt: usize = 0;
    for x in b.iter() {
        cnt += a.lower_bound(x) * (c.len() - c.upper_bound(x));
    }
    println!("{}", cnt);
}

Measured memory_bytes: 13560
class SegmentTree:
    def __init__(self, A, n=18, inf=10**20):
        l = len(A)
        self.size = n
        self.array = [inf]*(2**(n+1)-1)
        for i in range(l):
            self.array[i+2**n-1] = A[i]
        for i in range(2**n-2, -1, -1):
            self.array[i] = max(self.array[2*i+1], self.array[2*i+2])

    def _subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return 0
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_max = self._subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_max = self._subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return max(l_max, r_max)

    def max(self, l, r):
        return self._subquery(l, r, 0, 0, 2**self.size)

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = c
        while tmp > 0:
            tmp = (tmp - 1) // 2
            l = self.array[2 * tmp + 1]
            r = self.array[2 * tmp + 2]
            self.array[tmp] = max(l, r)

n = int(input())
*H, = map(lambda x: int(x)-1, input().split())
*A, = map(int, input().split())
DP = SegmentTree([0]*n)
for i in range(n):
    tmp = DP.max(0, H[i])
    DP.update(H[i], tmp+A[i])
print(DP.max(0, n))


Measured memory_bytes: 126744
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (n, a, b): (usize, usize, usize);
    input!(n, a, b);
    let mut ans = a * (n / (a + b));
    ans += std::cmp::min(a, n % (a + b));
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <ctype.h>
#include <stdio.h>
#include <string.h>

int
main()
{
	int i;
	int len;
	char ch;
	char text[1200];
	int counts[26] = {0};

	while (fgets(text, 1200*sizeof(char), stdin) != NULL)
	{
		for (i = 0, len = strlen(text); i < len; i++)
		{
			ch = tolower(text[i]);
			if ('a' <= ch && ch <= 'z')
			{
				counts[ch-'a']++;
			}
		}
	}

	for (i = 0; i < 26; i++)
	{
		printf("%c : %d\n", 'a'+i, counts[i]);
	}

	return 0;
}

Measured memory_bytes: 524
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    int n, a;
    cin >> n >> a;
    int num = n % 500;
    if (num <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
  vector<vector<int>> grid(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> grid.at(i).at(j);
    }
  }
  int by_1 = grid.at(1).at(0) - grid.at(0).at(0);
  int by_2 = grid.at(2).at(0) - grid.at(0).at(0);
  bool b = true;
  for (int i = 1; i < 3; i++) {
    if (grid.at(1).at(i) != grid.at(0).at(i) + by_1 ||
        grid.at(2).at(i) != grid.at(0).at(i) + by_2) {
      b = false;
    }
  }
  if (b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define sq(x) ((x) * (x))
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
const vi di = {1, -1, 0, 0}, dj = {0, 0, 1, -1};
bool good(int n, int m, int i, int j)
{
    return 0 <= i && i < n && 0 <= j &&  j < m;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m, sx, sy, x, y;
    cin >> n >> m >> sx >> sy >> x >> y;
    sx--, sy--, x--, y--;
    vs a(n);
    cin >> a;
    deque<pii> q;
    q.push_front({sx, sy});
    vvi d(n, vi(m, LLONG_MAX));
    d[sx][sy] = 0;
    while (sz(q))
    {
        pii cur = q.front();
        q.pop_front();
        int i = cur.fi, j = cur.se;
        for (int k = 0; k < 4; k++)
        {
            int ni = i + di[k], nj = j + dj[k];
            if (good(n, m, ni, nj) && a[ni][nj] == '.' && d[ni][nj] > d[i][j])
            {
                d[ni][nj] = d[i][j];
                q.push_front({ni, nj}); 
            }
        }
        for (int k = -2; k <= 2; k++)
            for (int l = -2; l <= 2; l++)
            {
                int ni = i + k, nj = j + l;
                if (good(n, m, ni, nj) && a[ni][nj] == '.' && d[ni][nj] > d[i][j] + 1)
                {
                    d[ni][nj] = d[i][j] + 1;
                    q.push_back({ni, nj});
                }
            }
    }
    if (d[x][y] == LLONG_MAX)
        cout << -1 << endl;
    else
        cout << d[x][y] << endl;
    GAME_OVER;
}

Measured memory_bytes: 12648
N,M=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
P=10**9+7
X=0
Y=0
for i in range(1,N+1):
  X+=x[i-1]*(2*i-1-N)
  X=X%P
for j in range(1,M+1):
  Y+=y[j-1]*(2*j-1-M)
  Y=Y%P
print((X*Y)%P)


Measured memory_bytes: 85092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int a, b, c; cin >> a >> b >> c;
	cout << (c || a && b ? "Open" : "Close") << endl;
	return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; 
    P u = make_pair(x2-x1, y2-y1);
    int x4 = x1 - u.second;
    int y4 = y1 + u.first;
    int x3 = x2 - u.second;
    int y3 = y2 + u.first;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
// frog2

#include <climits>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int n, k;
ll arr[1000005];
ll dp[1000005];

ll cost(int x)
{
    if (dp[x] != -1)
        return dp[x];
    if (x == n)
        return 0;
    if (x == n - 1)
        return abs(arr[x] - arr[x + 1]);

    long long minCost = INT_MAX;
    for (int i = 1; i <= k && x + i <= n; i++)
    {
        dp[x + i] = cost(x + i);
        minCost = min(minCost, abs(arr[x + i] - arr[x]) + dp[x + i]);
    }
    dp[x] = minCost;
    return dp[x];
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i < 1000005; i++)
    {
        dp[i] = -1;
    }
    cout << cost(1);
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int odp = 0;
    for (int i = 1; i < n - 1; ++i)
    {
        int mn = 0;
        if (a[i - 1] < a[i])
            ++mn;
        if (a[i + 1] < a[i])
            ++mn;
        if (mn == 1)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

int main ()
{
  std::array<int, 101> sum_each_col;
  sum_each_col.fill(0);

  size_t r, c;
  std::cin >> r >> c;

  int input, sum_each_row=0, sum_all=0;

  for (size_t i=0; i<r; i++)
    {
      sum_each_row = 0;
      for (size_t j=0; j<c; j++)
        {
          std::cin >> input;
          sum_each_row += input;
          sum_each_col.at(j) += input;
          std::cout << input << " ";
        }
      sum_all += sum_each_row;
      std::cout << sum_each_row << std::endl;
    }

  std::for_each(sum_each_col.begin(), sum_each_col.begin()+c, [](int a){std::cout << a << " ";});
  std::cout << sum_all << std::endl;
}


Measured memory_bytes: 3104
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func calcGcd(l, r int) int {
	if r > l {
		r, l = l, r
	}

	d := l % r
	for d != 0 {
		l = r
		r = d
		d = l % r
	}
	return r
}

func calcDsOCd(l, r int) int {
	gcd := calcGcd(l, r)
	max := math.Sqrt(float64(gcd))
	maxI := int(math.Ceil(max))
	primes := []int{1}

	for i := 2; i <= maxI; i++ {
		isDivid := false
		for gcd%i == 0 {
			gcd = gcd / i
			isDivid = true
		}
		if isDivid {
			primes = append(primes, i)
		}
	}
	if gcd != 1 {
		primes = append(primes, gcd)
	}
	return len(primes)
}

func main() {
	l, r := nextInt(), nextInt()
	result := calcDsOCd(l, r)
	fmt.Println(result)
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    cin >> N >> P;
    bool odd = false;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        if (temp % 2 == 1) odd = true;
    }
    if (odd) {
        cout << (long int)pow(2, N - 1) << endl;
    } else {
        if (P == 0) {
            cout << (long int)pow(2, N) << endl;
        } else {
            cout << 0 <<endl;
        }
    }
}


Measured memory_bytes: 256
S=input()
if 1<=int(S[0:2])<=12 and 1<=int(S[2:])<=12:
    print('AMBIGUOUS')
elif 1<=int(S[0:2])<=12:
    print('MMYY')
elif 1<=int(S[2:])<=12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
N = gets.to_i
PTS = (0...N).map{ gets.split.map &:to_i }
if ![0,1].any?{ |q| PTS.all?{ |x,y| (x+y)%2 == q } }
  puts -1; exit
end

InvParity = 1 - (PTS[0][0] + PTS[0][1]) % 2

def compose(u)
  v = u + (2**31) - 1
  (0..30).map{ |k| ((1 << (k+1)) & v) > 0 ? +1 : -1 }
end

D = ((InvParity == 0 ? [] : [1]) + (0..30).map{ |k| 1 << k })
puts D.size, D * " "

PTS.each{ |x,y|
  u,v = [x+y,-x+y]
  ud,vd = [u, v].map{ |u|
    w = u+InvParity
    ds = compose(w.abs)
    w > 0 ? ds : ds.map{ |d| -d }    
  }
  ops = (0..30).map{ |k|
    case [ud[k],vd[k]]
    when [-1,+1]; "L"
    when [+1,-1]; "R"
    when [+1,+1]; "U"
    when [-1,-1]; "D"
    end
  }.join
  ops = "D"+ops if InvParity == 1
  puts ops

  # self judge
  a,b = [0,0]
  (0...ops.size).map{ |i|
    case ops[i]
    when "L"; a -= D[i]
    when "R"; a += D[i]
    when "U"; b += D[i]
    when "D"; b -= D[i]
    end
  }
  $stderr.puts x == a && y == b
}

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

const int MAX_SIZE = 101;

int dp[MAX_SIZE][MAX_SIZE];

int solve(int p[], int begin,int end) {
	if (dp[begin][end] != -1)return dp[begin][end];
	if (begin >= end - 1)return 0;
	int res = -1;
	for (int i = begin + 1; i < end; i++) {
		int temp = solve(p, begin, i) + solve(p, i, end) + (p[begin] * p[i] * p[end]);
		if (res != -1) {
			res = min(temp, res);
		}
		else {
			res = temp;
		}
	}
	return dp[begin][end] = res;
}

int main() {
	int N;
	int p[MAX_SIZE + 1];

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

	for (int i = 0; i < MAX_SIZE; i++) {
		for (int j = 0; j < MAX_SIZE; j++) {
			dp[i][j] = -1;
		}
	}

	cout << solve(p, 0, N) << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
const double INF = 3e3;
const double EPS = 1e-11;

struct P3{
  double x,y,z;
  double vx,vy,vz;
  double r,vr;
  P3(double x=0, double y=0, double z=0):x(x),y(y),z(z){}
  P3 operator + (const P3 &a) const{ return P3(x+a.x, y+a.y, z+a.z); }
  P3 operator - (const P3 &a) const{ return P3(x-a.x, y-a.y, z-a.z); }
  P3 operator * (const double &c) const{ return P3(x*c, y*c, z*c); }
  void input(){scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x,&y,&z,&vx,&vy,&vz,&r,&vr);};
  P3 v ()const{return P3(vx,vy,vz);}
};
P3 operator * (double c, const P3 &a){ return P3(c * a.x, c * a.y, c * a.z); }


double norm(const P3 &a){ return a.x*a.x + a.y*a.y + a.z*a.z; }
double abs(const P3 &a){ return sqrt(norm(a)); }

typedef pair<int,int> P;
typedef pair<double,P> PP;

double calc(const P3 &A,const P3 &B,double t){
  if((A.r-t*A.vr)<0|| (B.r-t*B.vr)<0) return -1;
  return abs((A+t*A.v())-(B+t*B.v())) - ((A.r-t*A.vr) + (B.r-t*B.vr));
}

double calc(const P3 &A,const P3 &B){
  double L=0,R=INF,cnt = 65;
  while(cnt--){
    double M = (L+R)/2;
    double y1 = calc(A,B,M);
    double y2 = calc(A,B,M+EPS);
    if(y1<0||y1-y2<0) R = M;
    else L = M+EPS;
  }
  return L-EPS;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P3>A(n);
    for(int i=0;i<n;i++) A[i].input();

    priority_queue<PP,vector<PP>,greater<PP> >Q;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	double t = calc(A[i],A[j]);
	if(abs(calc(A[i],A[j],t))<2e-8)Q.push(PP(t,P(i,j)));
      }

    vector<double> ans(n,INF);
    while(!Q.empty()){
      PP t = Q.top();Q.pop();
      double c = t.first;
      int a = t.second.first;
      int b = t.second.second;
      if(ans[a]<INF||ans[b]<INF)continue;
      ans[a] = ans[b] = c;
    }

    for(int i=0;i<n;i++){
      ans[i] = min(ans[i],A[i].r / A[i].vr);
      printf("%.10lf\n",ans[i]);
    }    
    
  }
  return 0;    
}

Measured memory_bytes: 3200
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         //lol
         for(int v=K-N+1; v <= K+N-1; v++)
            System.out.print(v+" ");
         //end
      }
   }

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define el '\n'

bool isp(int x) {
  for (int i = 2; i*i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  vector<int> freq;
  for (int i = 2; i <= n; i++) {
    if (isp(i)) {
      int tmp = n / i, pkt = 0;
      while (tmp) {
        pkt += tmp;
        tmp /= i;
      }
      freq.push_back(pkt);
    }
  }
  int ans = 0, len = freq.size();
  for (int i = 0; i < len; i++) {
    for (int j = i+1; j < len; j++) {
      for (int k = 0; k < len; k++) {
        if (k == i || k == j) continue;
        if (freq[i] >= 4 && freq[j] >= 4 && freq[k] >= 2) ans++;
      }
    }
  }
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < len; j++) {
      if (i == j) continue;
      if (freq[i] >= 24 && freq[j] >= 2) ans++;
      if (freq[i] >= 14 && freq[j] >= 4) ans++;
    }
  }
  for (int i = 0; i < len; i++) {
    if (freq[i] >= 74) ans++;
  }
  cout << ans << el;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	char c ;
	cin >> c ;
	if (isupper(c)) cout << "A\n";
	else cout <<  "a\n";



	// }

	return 0;
}


Measured memory_bytes: 3640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
  cin>>n;
  vvi G(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  vi in(n);
  rep(i,n)cin>>in[i];
  sort(all(in));
  int now=0;
  vi co(n);
  rep(i,n)co[i]=G[i].size();
  
  vi used(n);
  queue<int>que;
  rep(i,n)if(co[i]==1)que.push(i),used[i]=true;
  vi out(n);
  while(!que.empty()){
    int t=que.front();
    que.pop();
    out[t]=in[now++];
    rep(i,G[t].size())co[G[t][i]]--;
    rep(i,G[t].size())if(used[G[t][i]]==0&&co[G[t][i]]==1){
      que.push(G[t][i]);
      used[G[t][i]]=true;
    }
  }
  int sum=0;
  rep(i,n)rep(j,G[i].size())sum+=min(out[i],out[G[i][j]]);
  cout<<sum/2<<endl;
  rep(i,n)cout<<out[i]<<" ";cout<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main(void){
    long long n,a,b,x,y,ans;
    scanf("%lld%lld%lld",&n,&a,&b);
    
    x = n/(a+b);
    
    if (n%(a+b) >= a){
        y = a;
    }else{
        y = n%(a+b);
    }
    
    ans = x*a + y;
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std;
const int N=1000,V=5000,inf=0x3f3f3f3f;
int f[N+10][2],v[N+10],n;
vector<int> G[N+10]; int tmp[N+10][V+10];
void dfs(int x){
	for(int i=0;i<G[x].size();++i) dfs(G[x][i]);
	for(int i=0;i<=1;++i){
		for(int j=0;j<=v[x];++j) tmp[0][0]=inf; tmp[0][0]=0;
		for(int j=0;j<G[x].size();++j){
			int e=G[x][j];
			for(int k=0;k<=v[x];++k) tmp[j+1][k]=inf;
			for(int k=0;k<=v[x];++k){
				if(k+v[e]<=v[x]) tmp[j+1][k+v[e]]=min(tmp[j+1][k+v[e]],tmp[j][k]+f[e][i^1]);
				if(k+f[e][i^1]<=v[x])
					tmp[j+1][k+f[e][i^1]]=min(tmp[j+1][k+f[e][i^1]],tmp[j][k]+v[e]);
			}
		}
		f[x][i]=inf;
		for(int j=0;j<=v[x];++j) f[x][i]=min(f[x][i],tmp[G[x].size()][j]);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;++i){
		int x; scanf("%d",&x); G[x].push_back(i);
	}
	for(int i=1;i<=n;++i) scanf("%d",&v[i]);
	dfs(1);
	printf("%s",f[1][0]<inf||f[1][1]<inf?"POSSIBLE":"IMPOSSIBLE"); return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  int N;
  cin >> N;
  if(N < 2000){
    if(N < 100){
      cout << 0 << endl;
    }
    else{
      int M = N/100;
      int D = N%100;
      if(M * 5 >= D){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
  else{
    cout << 1 << endl;
  }

}

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

int main() {
	int w,n;
	
	cin >> w >> n;
	int a[30];
	for ( int i = 1; i <= 30; i++ )
		a[i - 1] = i;
	int ai,bi;
	for ( int i = 0; i < n; i++ ) {
		scanf ("%d,%d",&ai,&bi);
		swap ( a[ai-1],a[bi-1] );
	}
	for ( int i = 0; i < w; i++ )
		cout << a[i] << endl;
	
	return 0;
}

Measured memory_bytes: 1240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in );
		
		int []pow=new int [6];
		pow[0]=1;
		for(int i=1;i<=5;i++)
			pow[i]=2*pow[i-1];
		int n=sc.nextInt();int m=sc.nextInt();
		int ans=(n-m)*100+1900*m;
		System.out.println(pow[m]*ans);
		
		
		
		
		
	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


Measured memory_bytes: 21332
//https://atcoder.jp/contests/abc128/tasks/abc128_a

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int P = sc.nextInt();
        System.out.println((A*3+P)/2);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
#define INFINITY 1000000000

int A[500000];
int num=0;
int n1,n2;
int L[5000000/4];
int R[5000000/4];

void merge(int A[],int left,int mid,int right){
  int i,k,j;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
num++;
    }
   else{
     num++;
  A[k]=R[j];
  j=j+1;
    }
  }
}
void mergesort(int A[],int left,int right){
  if(left+1<right){
    int mid;
    mid = (left + right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int main(){
  int n,i;
  scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&A[i]);
}
mergesort(A,0,n);
for(i=0;i<n;i++){
if(i==n-1){
printf("%d\n",(int)A[i]);
break;
}
printf("%d ",(int)A[i]);
}
printf("%d\n",num);

return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  ll height = A[0], ans = 0;
  for (int i = 1; i < N; i++) {
    if (height > A[i]) {
      ans += height-A[i];
      A[i] = height;
    }
    height = A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    vector<ll> s(m, 0);
    rep(i, m){
        ll k;
        cin >> k;

         rep(j, k){
             ll s_i;
             cin >> s_i;
             s_i--;
             s[i] += (1<<s_i);
         }
    }

    ll p = 0;
    rep(i, m){
        ll p_i;
        cin >> p_i;
        p += (1<<i)*p_i;
    }

    ll ans = 0;
    rep(i, (1<<n)){
        ll res = 0;

        rep(j, m){
            ll and_s = (i & s[j]);
            
            ll cnt = 0;
            rep(k, n){
                if((1<<k)&and_s)cnt++;
            }

            res += (1<<j) * (cnt%2);
        }

        if(res == p)ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B;
	in >> A >> B;
	out << (B%A == 0 ? A + B : B - A) << std::endl;
}


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

using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  for (int i=0; i<n; i++) {
  	vector<int> dis(n);
    for (int i=0; i<n; i++) dis[i] = -INF;
    queue<int> q;
    auto push = [&](int ind, int d) {
    	if (dis[ind]!= -INF) return;
      	dis[ind] = d;
      	q.push(ind);
    };
    push(i,0);
    while (!q.empty()) {
    	int temp = q.front();
         q.pop();
      	if (temp+1<n) push(temp+1, dis[temp]+1);
      	if (temp-1>=0) push(temp-1, dis[temp]+1);
      	if (temp==x) push(y,dis[temp]+1);
      	if (temp==y) push(x,dis[temp]+1);
    }
   	for (int i=0; i<n; i++) ans[dis[i]]++;
  }
  for (int i=1; i<n; i++) ans[i] /= 2;
  for (int i=1; i<n; i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
def examA():
    K, X = LI()
    if K*500>=X:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    return

def examC():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3572
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        
        int max = Math.max(x,y);
        int min = Math.min(x,y);
        
        while(min > 0){
            int r = max % min;
            max = min;
            min = r;
        }
        System.out.println(max);
    }

}



Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int main()
{
	fastIO;
	int H, W, m; cin >> H >> W >> m;
	int maxi = 0, maxj = 0;
	vi h(m), w(m), x, y;
	vi hor(300001,0), ver(300001,0);
	map<pair<int,int>,bool> vis;

	for(int i = 0; i < m; i++) 
	{
		cin >> h[i] >> w[i];
		hor[h[i]]++; maxi = max(maxi,hor[h[i]]);
		ver[w[i]]++; maxj = max(maxj,ver[w[i]]);
		vis[make_pair(h[i],w[i])] = true;
	}

	int n = max(H,W), ans = maxi + maxj;
	for(int i = 1; i <= n; i++)
	{
		if(hor[i] == maxi) x.pb(i);
		if(ver[i] == maxj) y.pb(i);
	}

	for(int i = 0; i < x.size(); i++)
		for(int j = 0; j < y.size(); j++)
			if(vis[make_pair(x[i],y[j])] == false)
			{
				cout << ans << endl;
				return 0;
			}

	cout << ans - 1 << endl;

	return 0;
}


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

int main(){
	int n,k;scanf("%d%d",&n,&k);
	vector<int> v(n);
	for(auto &x:v)scanf("%d",&x);

	sort(v.begin(),v.end());
	
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=v[i];
	}
	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, N, total=0, l;
  cin >> H >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    total += A[i];
  }

  if(H<=total){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<59;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=4000;

int n,k;

int main(){
	cin>>n>>k;
	vl dp,DP,dp1,DP1;
	dp=DP=dp1=DP1=vl(M);
	dp1[0]=1;
	int L=0;
	for(int i=n;i>0;i--){
		for(int j=0;j<M;j++) DP[j]=DP1[j]=0;
		for(int j=0;j<=k;j++) for(int l=0;l<=L;l++){
			if(j<=i){
				int I=l+(l+j)/i;
				(DP1[I]+=dp1[l])%=mod;
				(DP[I]+=dp[l]+(l+j)%i*dp1[l])%=mod;
			}
			else{
				(DP1[l]+=dp1[l])%=mod;
				(DP[l]+=dp[l]+(l+j)*dp1[l])%=mod;
			}
		}
		dp=DP;
		dp1=DP1;
		L+=(i+L)/i;
	}
	int res=0;
	for(int i=0;i<M;i++) (res+=dp[i])%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 384
N,A,B=map(int,input().split())
 
sum_k=0
 
for i in range(N+1):
    if i <10:
        k=i
    elif i<100:
        k=i//10+i%10
    elif i<1000:
        k=i//100+(i%100)//10+(i%100)%10
    elif i<10000:
        k=i//1000+(i%1000)//100+((i%1000)%100)//10+((i%1000)%100)%10
    else:
        k=1
    if A<=k and k<=B:
        sum_k=sum_k+i
      
print(sum_k)

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

int main() {
  vector<int>v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << v[k-1] << endl;
  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template<class T1,class T2,class BiOp1,class BiOp2,class BiOp3>
struct LazySegmentTree {
	//BiOp1:T1×T1->T1
	//BiOp2:T2×T2->T2
	//BiOp3:T1×T2->T1
	vector<T1> data;
	vector<T2> lazy;
	T1 e1;
	T2 e2;
	BiOp1 op1;
	BiOp2 op2;
	BiOp3 op3;
	int size;
	LazySegmentTree(int n, T1 e1, T2 e2, BiOp1 op1, BiOp2 op2, BiOp3 op3) :e1(e1), e2(e2), op1(op1), op2(op2), op3(op3) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		lazy.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) {
			data[i] = e1;
			lazy[i] = e2;
		}
	}
	LazySegmentTree(int n, vector<T1> &v, T1 e1, T2 e2, BiOp1 op1, BiOp2 op2, BiOp3 op3) :e1(e1), e2(e2), op1(op1), op2(op2), op3(op3) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		lazy.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) {
			data[i] = e1;
			lazy[i] = e2;
		}
		for (int i = n - 1 + (size - 1); i >= 0; i--) {
			if (i >= size - 1) {
				data[i] = v[i - (size - 1)];
			}
			else {
				data[i] = op1(data[i * 2 + 1], data[i * 2 + 2]);
			}
		}
	}
	void push(int k) {
		if (lazy[k] == e2) return;
		if (k < size) {
			lazy[k * 2 + 1] = op2(lazy[k * 2 + 1], lazy[k]);
			lazy[k * 2 + 2] = op2(lazy[k * 2 + 2], lazy[k]);
		}
		data[k] = op3(data[k], lazy[k]);
		lazy[k] = e2;
	}
	T1 query(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) return e1;
		if (a <= l && r <= b) return op3(data[k], lazy[k]);
		push(k);
		return op1(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	void update(int a, int b, T2 v, int k, int l, int r) {
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = op2(lazy[k], v);
			return;
		}
		push(k);
		update(a, b, v, k * 2 + 1, l, (l + r) / 2);
		update(a, b, v, k * 2 + 2, (l + r) / 2, r);
		data[k] = op1(op3(data[k * 2 + 1], lazy[k * 2 + 1]), op3(data[k * 2 + 2], lazy[k * 2 + 2]));
	}
};
struct Add {
	int operator()(int a, int b) const {
		return a + b;
	}
};
struct Min {
	int operator()(int a, int b) const {
		return min(a, b);
	}
};
struct Apply {
	int operator()(int a, int b) const {
		return a + b;
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	vector<int> data(n, 0);
	LazySegmentTree<int, int, Min, Add, Apply> S(n, data, 1 << 30, 0, Min(), Add(), Apply());
	for (int i = 0; i < q; i++) {
		int type;
		int s, t, x;
		cin >> type;
		if (type == 0) {
			cin >> s >> t >> x;
			t++;
			S.update(s, t, x, 0, 0, S.size);
		}
		else {
			cin >> s >> t;
			t++;
			cout << S.query(s, t, 0, 0, S.size) << endl;
		}
	}

}


Measured memory_bytes: 5212
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

#pragma warning(disable:4996)

int main()
{
	string a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Yes";
		return 0;
	}
	for (int i = 0; i < a.size(); i++)
	{
		rotate(a.begin(), a.begin() + 1, a.end());
		if (a == b) {
			cout << "Yes";
			return 0;
		}
			
	}
	cout << "No";
	return 0;

	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
#define vvi vector<vector<int>>
using namespace std;
using namespace __gnu_pbds;
typedef tree <pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
vi mm(10000000);
ll fact(int n){
    return mm[n];
}
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// } 
void solve(){
    int n,m;
    cin>>n>>m;
    mm[0]=1;
    for(int i=1;i<=m;i++){
        mm[i]=i*mm[i-1];
        mm[i]%=mod;
    }
    int h=((fact(m)*powi(fact(m-n),mod-2))%mod);
    int g2=fact(n),g1=0;
    for(int i=1;i<=n;i++){
        if(i&1)
        {
            int x=powi((fact(n-i)*fact(i))%mod,mod-2);
            x*=fact(m-i);
            x%=mod;
            x*=powi(fact(m-n),mod-2);
            x%=mod;
            g1+=(-1)*(x);g1=(g1+mod)%mod;
        }
        else{
            int x=powi((fact(n-i)*fact(i))%mod,mod-2);
            x*=fact(m-i);
            x%=mod;
            x*=powi(fact(m-n),mod-2);
            x%=mod;
            g1+=x;
            g1%=mod;
        }

    }
    h*=(h+((g1)*g2)%mod)%mod;
    h%=mod;
    cout<<h;
    // debug(fact(356237));
}
signed main(){
    //boost;
    int t=1;
    //freopen("input.txt", "r", stdin);
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2){
        puts("No");
        return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");

    return 0;
}

Measured memory_bytes: 256
n, h, w = map(int, input().split())
a,b = [],[]
for _ in range(n):
	ta, tb = map(int, input().split())
	a.append(ta)
	b.append(tb)
cnt = 0
for i in range(n):
	if a[i] >= h and b[i] >= w:
		cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 2000000
#define infly 1<<30
using namespace std;

int a[maxn+5],h;
char s[100];

void maxheapfy(int i)
{
    int l=i*2;
    int r=i*2+1;
    int large;
    if(l<=h && a[l]>a[i])
        large=l;
    else large=i;
    if(r<=h && a[r]>a[large])
        large=r;

    if(large!=i)
    {
         swap(a[i],a[large]);
         maxheapfy(large);
    }

}

void heapinsert(int i,int k)
{
    if(k<a[i]) return;
    a[i]=k;
    while(i>1 && a[i/2]<a[i])
    {
        swap(a[i],a[i/2]);
        i/=2;
    }
}

void insert(int k)
{
    a[++h]=-infly;
    heapinsert(h,k);
}

int extract()
{
    if(h<1) return -infly;
    int maxv=a[1];
    swap(a[h],a[1]);
    h--;
    maxheapfy(1);
    return maxv;
}

int main()
{
    int k;
    while(scanf("%s",s) && s[2]!='d')
    {
        if(s[0]=='i')
        {
            scanf("%d",&k);
            insert(k);
        }
        else if(s[0]=='e')
        {
            printf("%d\n",extract());
        }
    }
    return 0;
}

Measured memory_bytes: 7068
#include <stdio.h>
#include <stdlib.h>
#define VMAX 100000

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);

    int C[VMAX];
    for (int i = 0; i < VMAX; i++) {
        C[i] = 0;
    }
    
    unsigned short *A, *B;
    A = (unsigned short*)malloc(sizeof(unsigned short)*n + 1);
    B = (unsigned short*)malloc(sizeof(unsigned short)*n + 1);

    for (int i = 1; i <= n; i++) {
        scanf("%hu", &A[i]);
        C[A[i]]++;
    }
    
    for (int i = 1; i < VMAX; i++) {
        C[i] = C[i] + C[i - 1];
    }

    for (int i = 1; i <= n; i++) {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

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

    return 0;
}




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

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    int ans = 0, tmp = 0;
    for (int i = 0; i < n; i++) {
        if (s.at(i) == 'I') tmp++;
        if (s.at(i) == 'D') tmp--;
        ans = max(ans, tmp);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256