akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);



int main(void)
{
    string s; cin>>s;
    string div[4]={"dream","dreamer","erase","eraser"};
    rep(i,4) reverse(div[i].begin(),div[i].end());
    reverse(s.begin(),s.end());
    bool ok=true;
    for(int i=0;i<s.size();){
        bool ok2=false;
        rep(j,4){
            string d=div[j];
            if(s.substr(i,d.size()) == d){
                i+=d.size();
                ok2=true;
            }
        }
        if(!ok2){
            ok=false;
            break;
        }
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    bool ok = false;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != s[i-1]) ok = true;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int s,w;
  cin>>s>>w;
  if (s <= w) {
    cout << "unsafe";
  } else {
    cout << "safe";
  }
}

Measured memory_bytes: 3636
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
permutations_lis = itertools.permutations(range(1,n+1))# 全ての場合のリストを生成
dis_list = []
for i,case in enumerate(permutations_lis):
    if list(case) == p :
        a = i 
    if list(case) == q :
        b = i
print(abs(a-b))

Measured memory_bytes: 3064
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize
    }

    let mut min = std::usize::MAX;
    for a in 1.. {
        if a*a > N { break; }
        if N % a > 0 { continue; }
        else {
            let b = N / a;
            let digit_a = (a as f64).log10().floor() as usize + 1;
            let digit_b = (b as f64).log10().floor() as usize + 1;
            min = cmp::min(min, cmp::max(digit_a, digit_b));
        }
    }
    println!("{}", min);

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  printf("%d\n", max(max(a + a - 1, a + b), b + b - 1));

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
xs = [gets.split.map(&:to_i), gets.split.map(&:to_i)]
memo = [[0] * n, [0] * n]
2.times do |i|
  n.times do |j|
    memo[i][j] =
    if i == 0
      if j == 0
        xs[0][0]
      else
        memo[i][j-1] + xs[i][j]
      end
    else
      if j == 0
        memo[i-1][j] + xs[i][j]
      else
        [memo[i][j-1], memo[i-1][j]].max + xs[i][j]
      end
    end
  end
end
p memo[1][n-1]


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#define ll long long
using namespace std;

ll mod=1000000007, dp[3010][3010];

int main() {
	int N;
	string S;
	cin >> N >> S;
	dp[0][0]=1;
	for(int i=0; i+1<N; ++i){
		if(S[i]=='<'){
			for(int j=1; j<=i+1; ++j){
				dp[i+1][j]=(dp[i][j-1]+dp[i+1][j-1])%mod;
			}
		}
		else{
			for(int j=i; j>=0; --j){
				dp[i+1][j]=(dp[i][j]+dp[i+1][j+1])%mod;
			}
		}
	}
	ll ans=0;
	for(int i=0; i<N; ++i) ans=(ans+dp[N-1][i])%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 69120
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, c, d) = [int(e) for e in lines[0].split(" ")]

    return (a, b, c, d)


def solve(a, b, c, d):

    result = max([a*c, a*d, b*c, b*d])

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62292
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n];
        long[] b = new long[n];
        int ns = 66;
        String kbit = String.format("%" + ns + "s", Long.toBinaryString(k)).replace(' ', '0');
        String[] abit = new String[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            abit[i] = String.format("%" + ns + "s", Long.toBinaryString(a[i])).replace(' ', '0');
        }
        sc.close();

        long ans = 0;
        for(int l=1; l<35; l++){
            long mans = 0;
            String mkbit;
            if(kbit.charAt(ns - l) == '1'){
                mkbit = kbit.substring(0, ns-l);
                mkbit += "0";
                for(int m=0; m<l-1; m++){
                    mkbit += "1";
                }
            }else{
                mkbit = kbit;
            }
            out:
            for(int i=0; i<n; i++){
                for(int j=0; j<ns; j++){
                    if(mkbit.charAt(j) == '0' && abit[i].charAt(j) == '1'){
                        continue out;
                    }
                }
                mans += b[i];
            }
            ans = Math.max(mans, ans);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 184736
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int a,b,n;
  cin>>n;
  if(n==1) cout<<"Hello World\n";
  else{
    cin>>a>>b;
    cout<<a+b<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3612
#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>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> a(n), c(m);
    rep(i, n) cin >> a.at(i).first >> a.at(i).second;
    rep(i, m) cin >> c.at(i).first >> c.at(i).second;

    rep(i, n) {
        int md = 1001001001;
        int ans = -1;
        rep(j, m) {
            int d = abs(a.at(i).first - c.at(j).first) + abs(a.at(i).second - c.at(j).second);
            if(d < md) {
                md = d;
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using ll = long long;

int main(){
	ll N;
	scanf("%lld", &N);
	ll triangle = N*(N + 1) >> 1, sum = 0;
	int a[N];
	for (int i = 0; i < N; ++i){
		scanf("%d", a + i);
		sum += a[i];
	}
	if(sum % triangle){
		printf("NO\n");
		return 0;
	}
	ll sousa = sum/triangle;
	for (int i = 0; i < N; ++i){
		if(sousa + a[i] - a[(i + 1) % N] < 0 || (sousa + a[i] - a[(i + 1) % N]) % N){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

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

int main(){
  int n,x;
  cin>>n >>x;
  vector<int> m(n);
  
  for(int i=0;i<n;i++){
    cin>>m.at(i);
  }
  
  sort(m.begin(),m.end());
  reverse(m.begin(),m.end());
  
  for(int i=0;i<n-1;i++){
    x -= m.at(i);
  }
  cout<<n-1+x/m.at(n-1)<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  int ans=(n+k-3)/(k-1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int w, d; w = in, d = in;) {
		vector<int> W(w), D(d);
		for (int &i: W)
			i = in;
		for (int &i: D)
			i = in;
		sort(rbegin(W), rend(W)), sort(rbegin(D), rend(D));
		int r {};
		for (auto i {begin(W)}, j {begin(D)}; i != end(W) || j != end(D);)
			r+= i == end(W) ? *j++ : j == end(D) ? *i++ :
				*i == *j ? *i++, *j++ : *i > *j ? *i++ : *j++;
		outl(r);
	}
}


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

int main() {
  double l;
  cin >> l;

  double x = l / 3;
  double ans = 1;
  for (int i = 0; i < 3; i++) ans *= x;
  cout << fixed << setprecision(15) << ans << endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n; std::cin >> n;
    vi a(n); rep(i, n) std::cin >> a[i];
    sort(rng(a));
    map<ll, ll> m;
    ll sum = 0;
    rep(i, n) {
        m[a[i]]++;
        sum += a[i];
    }
    int q; std::cin >> q;
    rep(i, q) {
        ll b, c; std::cin >> b >> c;
        if (m.count(b) == 0) {
            std::cout << sum << "\n";
        } else {
            sum += m[b] * (c-b);
            m[c] += m[b];
            m.erase(b);
            std::cout << sum << "\n";
        }
    }
}


Measured memory_bytes: 7632
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const ll INFL = 9e18;

int main() {
  double T, X; cin >> T >> X;
  cout << T / X << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, x, y int
	fmt.Scanf("%d %d %d", &n, &x, &y)

	// index is from 1 to n - 1 (do not use 0)
	countPerK := make([]int, n)

	for i := 1; i <= n-1; i++ {
		for j := i + 1; j <= n; j++ {
			dNormal := j - i
			dShortcut := Abs(x-i) + 1 + Abs(y-j)
			k := Min(dNormal, dShortcut)
			countPerK[k]++
		}
	}

	for k := 1; k <= n-1; k++ {
		fmt.Println(countPerK[k])
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

using namespace std;

int main(void)
{
    long long N, M, X[100001], Y[100001], i, ans=0;

    cin >> N >> M;

    for(i=1; i<=M; i++){
        cin >> X[i];
    }

    if(M==1){
        cout << 0 << endl;
    }

    else if(N >= M){
        cout << 0 << endl;
    }

    else{
        sort(X+1, X+M+1);

        for(i=1; i<=M-1; i++){
            Y[i] = abs(X[i]-X[i+1]);
        }

        sort(Y+1, Y+M);

        for(i=1; i<=M-N; i++){
            ans += Y[i];
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
import collections
import sys
import math
N,T = map(int, input().split())
A = list(map(int, input().split()))
ans=0
for i in range(N-1):
    if A[i+1]-A[i]<T:
        ans+=A[i+1]-A[i]
    else:
        ans+=T
print(ans+T)

Measured memory_bytes: 31152
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn func(x: i64) -> i64 {
    if x/10 == 0 {return x;}
    x%10 + func(x/10)
}

fn main() {
    input! {
        s: String,
    }
    let n:usize = s.len();
    let mut ans:i64 = func(s.parse::<i64>().unwrap());
    for i in 0..n {
        let t = s.clone();
        let mut t:Vec<char> = t.chars().collect();
        if t[i] == '0' {continue;}
        t[i] = from_digit((t[i] as u8 - b'0' - 1) as u32, 10).unwrap();
        for j in 0..n {
            if i == j {continue;}
            t[j] = '9';
        }
        //debug!(t.iter().collect::<String>());
        let t:String = t.iter().map(|x| *x).collect();
        let num = t.parse::<i64>().unwrap();
        //debug!(num);
        if num > s.parse::<i64>().unwrap() {continue;}
        let sum = func(num);
        //debug!(sum);
        ans = max(ans, sum);
    }
 
    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import defaultdict


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    G = defaultdict(list)
    for _ in range(M):
        a, b = read_ints()
        G[a].append(b)
        G[b].append(a)

    def dfs(node, visited):
        if len(visited) == N:
            return 1
        answer = 0
        for child in G[node]:
            if child not in visited:
                visited.add(child)
                answer += dfs(child, visited)
                visited.discard(child)
        return answer
    
    return dfs(1, set([1]))


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 74488
#include <cmath>
#include <iostream>

int main(){
  int N,K;
  std::cin >> N >> K;

  long long ans = 0;
  for(int b = K+1; b <= N; b++){
    ans += (b-K)*(N/b);
    if((N%b) >= K) ans += (N%b)-std::max(0,K-1);
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=503;

int k;
int a[N][N];

void make(int n){
    FOR(i,0,n-1)FOR(j,0,n-1)a[i][j]=(i+j)%n;
    FOR(i,0,n-1)if(i&1)FOR(j,0,n-1)a[i][j]+=n;
}

int main(){
    cin>>k;
    if(k<500){
        printf("%d\n",k);
        FOR(i,1,k)FOR(j,1,k)printf("%d%c",i," \n"[j==k]);
        return 0;
    }
    make(500);
    printf("%d\n",500);
    FOR(i,0,499)FOR(j,0,499)if(k<=a[i][j])a[i][j]-=500;
    FOR(i,0,499)FOR(j,0,499)printf("%d%c",a[i][j]+1," \n"[j==499]);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  vl h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  ll ans = 1e18;
  rep(i, n - k + 1) ans = min(ans, h[i + k - 1] - h[i]);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
bool isstraight(int *n){
	for(int i=0;i<4;i++){
		if(n[i+1] - n[i] != 1){
			if(n[4] == 13 && n[0] == 1 && n[1] == 10 && n[2] == 11 && n[3] == 12){
				return true;
			}
			return false;
		}
	}
	return true;
}

int main(){
	int card[5];
	char tmp[4];
	while(cin >> card[0] >> tmp[0] >> card[1] >> tmp[1] >> card[2] >> tmp[2] >> card[3] >> tmp[3] >> card[4]){
		int n[14] = {0};
		for(int i=0;i<5;i++){
			n[card[i]]++;
		}
		sort(n,n+14,greater<int>());
		sort(card,card+5);
		if(isstraight(card)){
			cout << "straight" << endl;
		}
		else{
			if(n[0] == 4){
				cout << "four card" << endl;
			}
			else if(n[0] == 3){
				if(n[1] == 2){
					cout << "full house" << endl;
				}
				else{
					cout << "three card" << endl;
				}
			}
			else if(n[0] == 2){
				if(n[1] == 2){
					cout << "two pair" << endl;
				}
				else {
					cout << "one pair" << endl;
				}
			}
			else cout << "null" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.*;

class Main {
    public static void main(String[] args) throws java.io.IOException{
        int fst = 0,snd = 0,thi = 0;
        int temp;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for (int i=0; i<10; i++) {
            int j = Integer.parseInt(in.readLine());
            if (j > fst) {
                temp = snd;
                snd = fst;
                thi = temp;
                fst = j;
            } else if (j > snd) {
                thi = snd;
                snd = j;
            } else if (j > thi) {
                thi = j;
            }
        }
        System.out.println(fst);
        System.out.println(snd);
        System.out.println(thi);
    }
}

Measured memory_bytes: 24344
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int y=n%10;
  if(y==2||y==4||y==5||y==7||y==9)
  {
    cout<<"hon"<<endl;
  }
  else if(y==0||y==1||y==6||y==8)
  {
    cout<<"pon"<<endl;
  }
  else if(y==3)
  {
    cout<<"bon"<<endl;
  }
  return 0;
}

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

int main() {
  int N, K, Sum=0;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  sort(A.begin(), A.end());
  rep(i, K) Sum+=A.at(i);
  cout << Sum << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;

int main() {
    ll L,R; cin>>L>>R;
    unordered_map<ll,ll> data;
    for(ll i=L;i<=R;i++){
        ll m=i%2019;
        data[m]=1;
        if(data[0]>=1){cout<<0<<endl; return 0;}
    }
    ll ans=10000;
        rep0(i,2019){
            rep0(j,2019){
                if(data[i]&&data[j]&&j!=i){ll m=(i*j)%2019;
                //cout<<m<<endl;
                ans=min(m,ans);}
            }
        }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,i,j,n,m,k,ans,cnt=0,sum=0,c=0,ck,ck1,res;
    string s,s1,s2,tmp;
    cin>>s;
    for(i=0;i<s.size()-2;i++){
           tmp=s.substr(i,3);
           stringstream sso;
           sso<<tmp;
           sso>>ck;
           ans=abs(ck-753);
           if(cnt==0){
            c=ans;
            cnt=1;
           }
           res=min(ans,c);
           c=res;

    }
    cout<<res<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int db=log10(b)+1;
	int n=a*pow(10,db)+b;
	
	int s=sqrt(n);
	if(s*s==n)cout<<"Yes\n";
	else cout<<"No\n";
	
}


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

typedef int flow_type;

struct edge {
	int to;
	flow_type cap;
	int rev;
	edge(int t, flow_type c, int r):to(t), cap(c), rev(r){}
};

const flow_type INF = 0xfffffff;
vector<vector<edge> > G;
vector<int> level;
vector<int> iter;

inline void init(int V) {
	G.assign(V, vector<edge>());
	level.assign(V, 0);
	iter.assign(V, 0);
}

inline void add_edge(int from, int to, flow_type cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

void bfs(int s) {
	fill(level.begin(), level.end(), -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(int i = 0; i < static_cast<int>(G[v].size()); ++i) {
			const edge& e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0) { // 実数ならEPS比較
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

flow_type dfs(int v, int t, flow_type f) {
	if(v == t) return f;

	for(int& i = iter[v]; i < static_cast<int>(G[v].size()); ++i) {
		edge& e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]) {
			const flow_type d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}

	return 0;
}

flow_type max_flow(int s, int t) {
	flow_type flow = 0;

	for(;;) {
		bfs(s);
		if(level[t] < 0)
			return flow;

		fill(iter.begin(), iter.end(), 0);
		while(flow_type f = dfs(s, t, INF) > 0) {
			flow += f;
		}
	}
}

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

	vector<pair<int, int>> blocks;
	for(int i = 0; i < n; ++i) {
		int w, h;
		cin >> w >> h;
		if(w > h) swap(w, h);
		blocks.emplace_back(w, h);
	}

	const int source = n + n;
	const int sink = source + 1;
	const int num = sink + 1;
	init(num);

	for(int i = 0; i < n; ++i) {
		add_edge(source, i, 1);

		for(int j = 0; j < n; ++j) {
			if(blocks[i].first < blocks[j].first && blocks[i].second < blocks[j].second) {
				add_edge(i, j + n, 1);
			}
		}
	}

	for(int i = 0; i < n; ++i) {
		add_edge(i + n, sink, 1);
	}

	cout << n - max_flow(source, sink) << endl;

	return 0;
}


Measured memory_bytes: 1332
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
	string txt = "man i need a taxi up to ubud";
	string answer;
	unsigned int D, T, S;
	cin >> D >> T >> S;

	if (T*S < D){
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}

	//cout << answer << endl;
	return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 55;
const int MAXW = 2505;
const ll INF = 1e18;

int n, m, s;

ll dp[MAXN][MAXW];
bool used[MAXN][MAXW];
int c[MAXN], d[MAXN];
vector<pair<int, pair<int, int>>> g[MAXN];

void init() {
	for (int i = 0; i < MAXN; ++i) for (int j = 0; j < MAXW; ++j) dp[i][j] = INF;
}

void solve() {
	cin >> n >> m >> s;
	init();
	for (int i = 0; i < m; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b; --u; --v;
		g[u].push_back({v, {a, b}});
		g[v].push_back({u, {a, b}});
	}
	for (int i = 0; i < n; ++i) {
		cin >> c[i] >> d[i];
	}
	s = min(s, MAXW - 1);
	dp[0][s] = 0;
	set<pair<ll, pair<int, int>>> dist;
	dist.insert({0, {0, s}});
	while (!dist.empty()) {
		auto top = *dist.begin();
		dist.erase(dist.begin());
		int v = top.second.first, coins = top.second.second;
		ll curd = top.first;
		if (used[v][coins]) continue;
		used[v][coins] = true;
		//cout << "v: " << v << ' ' << coins << ' ' << curd << endl;
		// add coins;
		int newasscoins = min(coins + c[v], MAXW - 1);
		if (!used[v][newasscoins] && dp[v][newasscoins] > curd + d[v]) {
			dp[v][newasscoins] = curd + d[v];
			dist.insert({curd + d[v], {v, newasscoins}});
		}
		// go to next v
		for (auto to : g[v]) {
			int u = to.first, a = to.second.first, b = to.second.second;
			int newcoins = coins - a;
			if (newcoins < 0 || used[u][newcoins]) continue;
			if (dp[u][newcoins] > curd + b) {
				dp[u][newcoins] = curd + b;
				dist.insert({curd + b, {u, newcoins}});
			}
		}
	}
	for (int i = 1; i < n; ++i) {
		ll mintime = INF;
		for (int j = 0; j < MAXW; ++j) mintime = min(mintime, dp[i][j]);
		cout << mintime << "\n";
	}
}

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

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

#define sz(x) (int)(x.size())
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int n;
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon";
    else if(n == 0 or n == 1 or n == 6 or n == 8)
        cout << "pon";
    else if(n == 3)
        cout << "bon";
}


Measured memory_bytes: 3640
import bisect

N = int(input())
L = [int(x) for x in input().split()]
L.sort()
ret = 0
# print(L)
for i in range(N-2):
    for j in range(i+1, N-1):
        add = bisect.bisect_left(L,L[i]+L[j]-0.01) - (j+1)
        # print(f"{L[i]}, {L[j]} , add:{add}")
        ret += add

print(ret)



Measured memory_bytes: 43100
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("AtCoder Beginner Contest");
            //ABC
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("AtCoder Snuke Contest");
            //ASC
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("AtCoder X Contest");
            //AXC
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string s = InputList[0];

        string[] wkArr = s.Split(' ');
        Array.ForEach(wkArr, A => Console.Write(A[0]));
        Console.WriteLine();
    }
}


Measured memory_bytes: 2904
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);
        int W = nextInt(r);
        int w[] = new int[N+1];
        int v[] = new int[N+1];
        for (int i = 1; i <= N; i++) {
            w[i] = nextInt(r);
            v[i] = nextInt(r);
        }

        long dp[][] = new long[N+1][W+1];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= W; j++) {
                if (j >= w[i]) {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
                }
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j]);
            }
        }
        System.out.println(dp[N][W]);
    }

    public static String nextString(InputStreamReader r) throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        return Integer.parseInt(nextString(r));
    }

    public static long nextLong(InputStreamReader r) throws Exception {
        return Long.parseLong(nextString(r));
    }
}


Measured memory_bytes: 126676
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN=1000;
const double INF=1e18;
int beg[2],ove[2],rnd[MAXN+5][3];
double dis[MAXN+5][MAXN+5];
int n;
double F[MAXN+5];
bool vis[MAXN+5];
double Dij()
{
	fill(F,F+MAXN+5,INF);
	F[0]=0;
	for(int i=0;i<=n;i++)
	{
		double MIN=INF;
		int u;
		for(int j=0;j<=n+1;j++)
			if(F[j]<MIN && !vis[j])
				MIN=F[j],u=j;
		vis[u]=true;
		for(int j=0;j<=n+1;j++)
			F[j]=min(F[j],F[u]+dis[u][j]);
	}
	return F[n+1];
}
int main()
{
	scanf("%d%d%d%d",&beg[0],&beg[1],&ove[0],&ove[1]);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=0;j<3;j++)
			scanf("%d",&rnd[i][j]);
	rnd[0][0]=beg[0];rnd[0][1]=beg[1];
	rnd[n+1][0]=ove[0];rnd[n+1][1]=ove[1];
	for(int i=0;i<=n+1;i++)
		for(int j=i+1;j<=n+1;j++)
			dis[i][j]=dis[j][i]=max(sqrt(1.0*(rnd[i][0]-rnd[j][0])*(rnd[i][0]-rnd[j][0])+1.0*(rnd[i][1]-rnd[j][1])*(rnd[i][1]-rnd[j][1]))-rnd[i][2]-rnd[j][2],0.0);
	printf("%.9lf\n",Dij());
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int k = (b-1);
    int l = (a-1);
    if (k%l == 0) cout << k/l << '\n';
    else cout << k/l + 1 << '\n';
}


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


void solve(long long A, long long B){
    long long ans = 0;
    long long a = A;
    long long b = B;
    for(int i = 0; i <= 1; i++){
        if(a >= b){
            ans = ans + a;
            a--;
        }else{
            ans = ans + b;
            b--;
        }
    }
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 50

int main() {
	static char o[N + 1], e[N + 1], s[N + N + 1];
	int n, m, i, j;

	scanf("%s%s", o, e);
	n = strlen(o);
	m = strlen(e);
	for (i = 0, j = 0; i < n * 2 && j < n * 2; i += 2, j++)
		s[i] = o[j];
	for (i = 1, j = 0; i < m * 2 && j < m * 2; i += 2, j++)
		s[i] = e[j];
	printf("%s\n", s);
	return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n;
    string s, t;

    cin >> n >> s >> t;

    string ans = "";
    REP(i, n){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    int n, m;
    int a[105];
    int sum = 0;
    int cnt = 0;
    cin >> n >> m;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    rep(i, n) {
        if ((double)a[i] >= (double)(sum)/(double)(4*m)) {
            cnt++;
        }
    }
    if (cnt >= m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int N;
VV<int> G;
V<mint> w;
V<mint> calc(int v,int p=-1){
	V<mint> dp(2,0);dp[1]=1;
	for(int u:G[v]) if(u!=p){
		auto f = calc(u,v);
		V<mint> ndp(dp.size()+f.size()-1);
		rep(i,dp.size()) rep(j,f.size()){
			ndp[i+j] += dp[i] * f[j];
			ndp[i] -= dp[i] * f[j] * w[j];
		}
		dp = ndp;
	}
//	show(v);
//	show(dp);
	return dp;
}

int main(){
	cin>>N;
	G.resize(N);
	rep(i,N-1){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	{
		w.resize(N+1);
		w[0] = 1;
		for(int i=2;i<=N;i++){
			if(i%2==0){
				w[i] = w[i-2] * (i-1);
			}else{
				w[i] = 0;
			}
		}
	}
	V<mint> res = calc(0);
	mint ans = 0;
	rep(i,res.size()){
		ans += res[i] * w[i];
	}
	cout<<ans<<endl;
}

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

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

bool check(ll a, ll b, ll c) {
    bool f = 1;
    if(a == 0 && b == 2 && c == 1) f = 0;
    if(a == 0 && b == 1 && c == 2) f = 0;
    if(a == 2 && b == 0 && c == 1) f = 0;
    return f;
}

bool check2(ll a, ll b, ll c, ll d) {
    bool f = 1;
    if(a == 0 && b == 2 && d == 1) f = 0;
    if(a == 0 && c == 2 && d == 1) f = 0;
    return f;
}

int main() {
    ll n, i, j, k, l, m;
    cin >> n;
    ll dp[n + 1][4][4][4];
    for(i = 0; i <= n; i++) {
        for(j = 0; j < 4; j++) {
            for(k = 0; k < 4; k++) {
                for(l = 0; l < 4; l++) {
                    dp[i][j][k][l] = 0;
                }
            }
        }
    }

    for(j = 0; j < 4; j++) {
        for(k = 0; k < 4; k++) {
            for(l = 0; l < 4; l++) {
                if(check(j, k, l)) {
                    dp[3][j][k][l] = 1;
                }
            }
        }
    }

    for(i = 4; i <= n; i++) {
        for(j = 0; j < 4; j++) {
            for(k = 0; k < 4; k++) {
                for(l = 0; l < 4; l++) {
                    for(m = 0; m < 4; m++) {
                        if(check(j, k, l) && check(m, j, k) && check2(m, j, k, l)) {
                            dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][m][j][k]) % MOD;
                        }
                    }
                }
            }
        }
    }

    ll ret = 0;
    for(j = 0; j < 4; j++) {
        for(k = 0; k < 4; k++) {
            for(l = 0; l < 4; l++) {
                if(check(j, k, l)) ret = (ret + dp[n][j][k][l]) % MOD;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
fives = n
cnt = 0
cnt2 = 0

if n%2 == 0:
  while (1):
    if fives // 5 > 0:
      fives //= 5
      cnt += 1
    else:
      break

for i in range(cnt):
  cnt2 += n // (2*5**(i+1))

print(cnt2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))

const ll INF = 1LL << 60;
ll a[100010][3];
ll dp[100010][3];

int main() {
  int n;
  cin >> n;
  rep(i,n) rep(j,3) cin >> a[i][j];
  rep(i,n) rep(j,3) rep(k,3) {
    if(j==k) continue;
    maxs(dp[i+1][k], dp[i][j]+a[i][k]);
  }
  ll ans = 0;
  rep(i,3) maxs(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;

int main() {
  ll n,m;cin>>n>>m;
  queue<P>qu;
  if(n%2==1){
    rep(i,m){
      qu.push(P(n-i,2ll+i));
    }
  }
  if(n%2==0){
    rep(i,m){
      ll r=2ll+i;
      ll l=n-i;
      if(l-r>n/2){qu.push(P(r,l));}
      else{qu.push(P(r,l-1ll));}
    }
  }
  rep(i,m){
    auto t=qu.front();qu.pop();
    cout<<t.first<<' '<<t.second<<endl;
  }
}

Measured memory_bytes: 4920