akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k,x,y,sum=0;
   cin>>n;
   cin>>k;
   cin>>x;
   cin>>y;
   sum=0;
   if(n>k)
   {
       for(int i=1;i<=k;i++)
       {
           sum+=x;
       }
       for(int j=1;j<=n-k;j++)
       {
           sum+=y;
       }
       cout<<sum<<endl;
   }
   else if(k>=n)
   {
       cout<<n*x<<endl;
   }
}


Measured memory_bytes: 3560
N,Q = gets.split.map(&:to_i)
T = [[nil,0]]
(N-1).times do
  a,b = gets.split.map(&:to_i)
  T[b-1] = [a-1, 0]
end
Q.times do
  i,x = gets.split.map(&:to_i)
  T[i-1][1] += x
end
1.step(N-1) {|i| T[i][1] += T[T[i][0]][1] }
puts T.map {|_,n| n }.join(' ')


Measured memory_bytes: 22140
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let xs: Vec<i64> = sc.chars().iter().map(|&c| ((c as u8) - ('0' as u8)) as i64).collect();
    for ops in 0..8 {
        let op1 = ops & 1;
        let op2 = (ops >> 1) & 1;
        let op3 = (ops >> 2) & 1;
        let mut eval = xs[0];
        eval += if op1 == 0 { xs[1] } else { -xs[1] };
        eval += if op2 == 0 { xs[2] } else { -xs[2] };
        eval += if op3 == 0 { xs[3] } else { -xs[3] };
        if eval == 7 {
            println!("{}{}{}{}{}{}{}=7",
                xs[0],
                if op1 == 0 { '+' } else { '-' },
                xs[1],
                if op2 == 0 { '+' } else { '-' },
                xs[2],
                if op3 == 0 { '+' } else { '-' },
                xs[3]);
            return;
        }
    }

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const int n1=(1<<18);
const ll mod=1000*1000*1000+7;
const ll inf=1e18;

int n, m;

int l[nax];
int r[nax];
ll w[nax];

vi kt[nax];

ll dp[nax];

ll narz[nax];
ll pod[nax];

ll daj(int v)
{
	return pod[v]+narz[v];
}

void upd(int v)
{
	pod[v]=max(daj(2*v), daj(2*v+1));
}

void pisz(int v, int a, int b, int graa, int grab, ll w)
{
	if (a>=graa && b<=grab)
	{
		narz[v]+=w;
		return;
	}
	if (a>grab || b<graa)
	{
		return;
	}
	pisz((v<<1), a, (a+b)>>1, graa, grab, w);
	pisz((v<<1)^1, (a+b+2)>>1, b, graa, grab, w);
	upd(v);
}

ll czyt(int v, int a, int b, int graa, int grab)
{
	if (a>=graa && b<=grab)
	{
		return daj(v);
	}
	if (a>grab || b<graa)
	{
		return -inf;
	}
	return max(
	czyt((v<<1), a, (a+b)>>1, graa, grab),
	czyt((v<<1)^1, (a+b+2)>>1, b, graa, grab)
	)+narz[v];
}

int main()
{
	scanf("%d%d", &n, &m);
	n+=2;
	for (int i=1; i<=m; i++)
	{
		scanf("%d%d%lld", &l[i], &r[i], &w[i]);
		l[i]++;
		r[i]++;
		kt[r[i]].push_back(i);
	}
	for (int i=2; i<=n; i++)
	{
		dp[i]=czyt(1, 1, n1, 1, i-1);
		pisz(1, 1, n1, i, i, dp[i]);
		for (int j : kt[i])
			pisz(1, 1, n1, l[j], r[j], w[j]);
		//~ debug() << i << " " << dp[i];
	}
	printf("%lld\n", dp[n]);
	return 0;
}


Measured memory_bytes: 51200
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int
main(int argc, const char *argv[])
{
    int n;
    while (cin >> n && n) {
        double sum = 0;
        vector<int> vi;
        for (int i = 0; i < n; ++i) {
            int s;
            cin >> s;
            sum += s;
            vi.push_back(s);
        }
        double m = sum / n;
        double v = 0;
        for (auto & s : vi) {
            v += (s - m) * (s - m); 
        }
        printf("%.5lf\n", sqrt(v / n));
    }

    return 0;
}

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

using namespace std;

#define l first
#define r second
#define int long long

int n, m;
string s;
pair<char, char> d[500000];

int simulate(int i)
{
    for (int j = 0; j < m; j++)
    {
        if (d[j].l == s[i])
        {
            if (d[j].r == 'R') i++;
            else i--;
        }
        if (i == -1 || i == n) return i;
    }
    return i;
}

signed main()
{
    cin >> n >> m; 
    cin >> s;
    for (int i = 0; i < m; i++) cin >> d[i].l >> d[i].r;
    int l = -1, r = n;
    while (l + 1 < r)
    {
        int mid = (l + r) / 2;
        if (simulate(mid) == -1) l = mid;
        else r = mid;
    }
    int l2 = -1, r2 = n;
    while (l2 + 1 < r2)
    {
        int mid = (l2 + r2) / 2;
        if (simulate(mid) == n) r2 = mid;
        else l2 = mid;
    }
    cout << min(n, max(0LL, r2 - l - 1));
}


Measured memory_bytes: 900
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
using LL = long long;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1;; i++) {
		sum += i;
		if (sum >= n) {
			int pos = i;
			while (n != 0) {
				if (n >= pos) {
					cout << pos << endl;
					n -= pos;
				}
				pos--;
			}
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

// combination
class Com{
public:
    int n;
    int mod;

    Com(int n, int mod){
        this->n = n;
        this->mod = mod;

        f.resize(n + 1);
        fInv.resize(n + 1);
        inv.resize(n + 1);

        f[0] = f[1] = 1;
        fInv[0] = fInv[1] = 1;
        inv[1] = 1;

        for(int i = 2; i <= n; i++){
            f[i] = (f[i - 1] * i) % mod;
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            fInv[i] = (fInv[i - 1] * inv[i]) % mod;
        }
    }

    long long query(int n, int k){
        if(n < k){
            return 0;
        }
        if(n < 0 || k < 0){
            return 0;
        }
        return (((f[n] * fInv[k]) % mod) * fInv[n - k]) % mod;
    }
private:
    vector<long long> f, fInv, inv;
};


int main(){

    int S;
    cin >> S;

    Com com(S, MOD);

    long long ans = 0;
    for(int i = 1; 3 * i <= S; i++){
        ans = (ans + com.query(S - 2 * i - 1, i - 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

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

long long n;
int q;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> q;
	set<pair<int, int>> x, y;
	long long ans = (n - 2) * (n - 2);
	x.insert({n, n - 1}), y.insert({n - 1, n - 1}); 
	for(int i = 0; i < q; i++){
		int typ, crd;
		cin >> typ >> crd, crd--;
		if(typ == 1){
			int fir = y.lower_bound({crd, 0}) -> second;
			ans -= fir - 1;
			x.insert({fir - 1, crd});
		}else{
			int fir = x.lower_bound({crd, 0}) -> second;
			ans -= fir - 1;
			y.insert({fir - 1, crd});
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 12984
#define TEST_MODE false

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

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

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

class Solver {
public:
    int n;
    int a[200005];
    int res[200005];

    void solve() {
        cin >> n;
        rep(i, n) cin >> a[i];
        rep(i, n/2 + n%2) res[i] = a[(n/2 + n%2)*2-2-i*2];
        rep2(i, n/2 + n%2, n) res[i] = a[(i-(n/2 + n%2))*2 + 1];
        if (n % 2 == 0) {
            reverse(res, res + n);
        }
        rep(i, n) {
            cout << res[i] << " ";
        } 
        cout << endl;
    }
};

signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
    // while (true) {    
    //     auto ptr = new Solver();
    //     ptr->solve();
    //     delete ptr;
    // }
    return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'




Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
pair<pair<string,int>,int>a[114];
signed main(){
	int n;
	cin>>n;
	rep(0,i,n){
		cin>>a[i].first.first;
		cin>>a[i].first.second;
	}
	rep(0,i,n){
		a[i].second=i+1;
	}
	rep(0,i,n){
		a[i].first.second*=-114514;
	}	
	sort(a,a+n);
	rep(0,i,n){
		c(a[i].second)
	}	
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int &x : a) {
        cin >> x;
    }
    for (int &x : b) {
        cin >> x;
    }
    for (int &x : c) {
        cin >> x;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        a[i]--;
        res += b[a[i]];
        if (i && a[i - 1] + 1 == a[i]) {
            res += c[a[i] - 1];
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int b[100];
inline bool can(int x)
{
	while(x)
	{
		if(b[x%10]) return false;
		x/=10;
	}
	return true;
}
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1,x;i<=k;i++)
		scanf("%d",&x),b[x]=true;
	for(int i=n;;i++)
		if(can(i)) return !printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 256
//////////////////////////////
// Author: whatisit
// Date: 2020-05-13 03:41 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

const int N = 13;
int n, m, x, c, a[N][N], ans = 1e9;
void solve() {
	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= m; ++j) {
			cin >> a[i][j];
		}
	}
	for (int s = 0; s < (1 << n); ++s) {
		int cost = 0;
		vector<int> cur_a(m);
		for (int i = 0; i < n; ++i) {
			if ((s >> i) & 1) {
				cost += a[i][0];
				for (int j = 0; j < m; ++j) {
					cur_a[j] += a[i][j+1];
				}
			}
		}
		bool satisfied = true;
		for (int j = 0; j < m; ++j) {
			if (cur_a[j] < x) {
				satisfied = false;
				break;
			}
		}
		if (satisfied) ans = min(ans, cost);
	}
	if (ans == 1e9) ans = -1;
	cout << ans;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

Measured memory_bytes: 3620
n=int(input())
s=str(input())

#s = "........."

list_ = []
last = "."
counter = 0
for i in range(n):
    now = s[i]
    if now != last:
        list_.append(counter)
        counter = 0
    counter += 1
    last = now
list_.append(counter)

if len(list_)%2==1:
    list_.append(0)

#print(list_)


list_w = []
list_w.append(0)
list_w.append(0)
c_w = 0
list_b = []
list_b.append(0)
list_b.append(0)
c_b = 0
for i in range(0,len(list_),2):
    c_w += list_[-1*i-2]
    c_b += list_[i+1]
    list_w.append(c_w)
    list_b.append(c_b)
    
#print(list_w)
#print(list_b)

list_count = []
for i in range(0,len(list_w)):
    list_count.append(list_b[i]+list_w[-1*i-1])
    
#print(list_count)

print(min(list_count))

Measured memory_bytes: 17264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n,k;
ll sum = 0;
cin >> n >> k;
vector<ll>a(n);
for(ll i=0;i<n;i++) cin >> a[i];
sort(a.begin(),a.end());
for(ll i=0;i<n-k;i++){
 sum += a[i];
}
cout << sum;
return 0;
}

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

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)


typedef long long ll;
const int maxn= 100005;
const int mod = 475;
const ll INF = 0x3f3f3f3f;
const double eps = 1e-6;


int n;
int cnt;
int vis[maxn];
int pre[maxn];
int head1[maxn],head2[maxn];
ll dis[maxn];

struct node
{
    int s,t,w,lca,next;
}e1[maxn*2],e2[maxn*4];

void init()
{
    mst(vis,0);
    mst(dis,0);
    mst(head1,-1);
    mst(head2,-1);
    for(int i=1;i<=n;i++)
        pre[i]=i;
}

int find(int x)
{
    int t,r=x;
    while(x!=pre[x])
    {
        x=pre[x];
    }
    while(r!=x)
    {
        t=pre[r];
        pre[r]=x;
        r=t;
    }
    return x;
}

void join(int a,int b)
{
    int A,B;
    A=find(a);
    B=find(b);
    if(A!=B)
        pre[B]=A;
}
void add1(int s,int t,int w)
{
    e1[cnt].s=s;
    e1[cnt].t=t;
    e1[cnt].w=w;
    e1[cnt].next=head1[s];
    head1[s]=cnt++;
}

void add2(int s,int t)
{
    e2[cnt].s=s;
    e2[cnt].t=t;
    e2[cnt].lca=-1;
    e2[cnt].next=head2[s];
    head2[s]=cnt++;
}

void Tarjan(int now)
{
    vis[now]=1;
    for(int i=head1[now];i!=-1;i=e1[i].next)
    {
        int t=e1[i].t;
        if(vis[t]==0)
        {
            int w=e1[i].w;
            dis[t]=dis[now]+w;
            Tarjan(t);
            join(now,t);
        }
    }
    for(int i=head2[now];i!=-1;i=e2[i].next)
    {
        int t=e2[i].t;
        if(vis[t]==1)
        {
            e2[i].lca=find(t);
            e2[i^1].lca=e2[i].lca;
        }
    }
}

int main()
{
    int x,y,w;
    int q,k;
    while(~scanf("%d",&n))
    {
        init();
        cnt=0;
        for(int i=0;i<n-1;i++)
        {
            scanf("%d%d%d",&x,&y,&w);
            add1(x,y,w);
            add1(y,x,w);
        }
        cnt=0;
        scanf("%d%d",&q,&k);
        for(int i=0;i<q;i++)
        {
            scanf("%d%d",&x,&y);
            add2(x,k);
            add2(k,x);
            add2(k,y);
            add2(y,k);
        }
        Tarjan(1);
        for(int i=0;i<q;i++)
        {
            int now=i*4;
            int u=e2[now].s;
            int v=e2[now].t;
            int lca=e2[now].lca;
            ll ans=dis[u]+dis[v]-2*dis[lca];
            now=i*4+2;
            u=e2[now].s;
            v=e2[now].t;
            lca=e2[now].lca;
            ans=ans+dis[u]+dis[v]-2*dis[lca];
            printf("%lld\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 20480
a = list(map(int , input().split()))
ans = 0
if a[0] >= a[3]:
  ans = a[3]
if a[0] + a[1] <= a[3]:
  ans = a[0] + a[1]*0 + (a[3] - (a[0] + a[1]))*(-1)
print(ans)

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

using namespace std ;
/*
ifstream cin ("input") ;
ofstream cout ("output") ;*/

int main(int argc, char const *argv[])
{
	int n ;
	cin >> n ; 
	vector <int> fv (200, 0) ;
	int distinct = 0 ; 
	int cate = 0 ; 
	for (int i = 1 ; i <= n ; ++ i) {
		int x ; 
		cin >> x ; 
		x /= 400 ; 
		fv [x] += 1 ; 
		if (fv [x] == 1 and x <= 7) {
			distinct += 1 ; 
		}
		if (x > 7) cate += 1 ; 
	}
	cout << max (1, distinct) << ' ' << distinct + cate ;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long LL;
const int e[40]={0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,
                 5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8};
LL IN(void)
{
  LL x=0;short f=0,c=getchar();
  while(c<48||c>57)f^=c==45,c=getchar();
  while(c>47&&c<58)x=x*10+c-48,c=getchar();
  return f?-x:x;
}
int main(void)
{
  int x=0;LL a=0,i,N=IN();
  while(N%2==0){x++;N/=2;}a+=e[x],x=0;
  while(N%3==0){x++;N/=3;}a+=e[x],x=0;
  while(N%5==0){x++;N/=5;}a+=e[x];
  for(i=6;i*i<=N;i+=6)
  {
    x=0;while(N%(i+1)==0){x++,N/=i+1;}a+=e[x];
    x=0;while(N%(i+5)==0){x++,N/=i+5;}a+=e[x];
  }
  if(N>1)a++;
  return printf("%lld\n",a),0;
}

Measured memory_bytes: 1604
n=int(input())
H=list(map(int,input().split()))
c=0
C=[]
h=H[0]
ans=0
for i in range(1,n):
  if H[i]<=h:
    c+=1
    h=H[i]
    ans=max(c,ans)
  if H[i]>h:
    c=0
    h=H[i]
    
print(ans)

Measured memory_bytes: 20252
N=int(input())
Mod=10**9+7
if N == 1:
    print(0)
else:
    # ans = pow(10, N, Mod)
    # ans -= pow(8, N, Mod)
    # ans -= 2 * pow(9, N-1, Mod)
    # ans *= 2
    # ans -= pow(2, N-2)
    # ans %= Mod
    # ans *= N * (N - 1) // 2 % Mod
    ans = 0
    a = 8
    b = 2
    for _ in range(N - 1):
        ans *= 10
        ans += b
        b *= 9 
        b += a * 2
        a *= 8
        ans %= Mod
        a %= Mod
        b %= Mod

    print(ans%Mod)


Measured memory_bytes: 63820
#左からn個目でendが特定の色の場合に
N,M,K = list(map(int,input().split()))

def xgcd(a, b):
  x0, y0, x1, y1 = 1, 0, 0, 1
  while b != 0:
    q, a, b = a // b, b, a % b
    x0, x1 = x1, x0 - q * x1
    y0, y1 = y1, y0 - q * y1
  return a, x0, y0
def modinv(a, m):
  g, x, y = xgcd(a, m)
  if g != 1:
    raise Exception('modular inverse does not exist')
  else:
    return x % m
def combination(n, k, mod=1e9+7) -> int:
  ret = 1
  for i in range(1, k+1):
    ret = (ret * (n-k+i) * modinv(i, mod))%mod
  return int(ret)

def pow(base, exponent, mod=1e9+7) -> int:
  if exponent == 0:
    return 1
  if exponent > 1:
    d,m = divmod(exponent, 2)
    return (base**m * pow(base, d, mod)**2 ) % mod
  else:
    return base

m = 998244353
res = 0
B = 1
if M != 1:
  mi = modinv(M-1,m)
  A = M * pow(M-1,N-1,m)
  for k in range(K+1):
    if k>0:
      B = (B*(N-k)*modinv(k,m))%m
    res = (res+ A*B)%m
    A = (A*mi)%m
  print (res)
else:
  if K == N-1:
    
    print(1)
  else:
    print(0)

Measured memory_bytes: 68236
import java.util.*;class Main{public static void main(String[]g){g=new Scanner(System.in).nextLine().split(" ");int m=0,l=0,t,i=0,c=0,x=0,y=0;for(Arrays.sort(g);++i<g.length;g[0]=g[i]){if(g[0].equals(g[i])){if(++c>m){m=c;x=i;}}else c=0;t=g[i].length();if(t>l){l=t;y=i;}}System.out.println(g[x]+" "+g[y]);}}


Measured memory_bytes: 26112
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=5e5+5;

ll sp[N];

void sieve(){
  for(int i=2;i<N;i++)sp[i]=i;

    for(int i=2;i*i<N;i++){
      if(sp[i]==i){
      for(int j=i*i;j<N;j+=i){
        sp[j]=i;
      }
    }
}

}

ll fac[N],inv[N];

ll p=1e9+7;

void fill(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%p;
    inv[i]=powM(fac[i],p-2,p);
  }
}

ll c(ll a,ll b,ll p){
if(a<b)return 0;

  return (fac[a]*inv[a-b]%p)*(inv[b])%p;
}


bool cmp(const pll& a,const pll& b){
  return a.ss<b.ss;
}

int main()
{ 

  IOS;

ll n;cin>>n;

vpll a(n);

for(int i=0;i<n;i++){
  cin>>a[i].ff>>a[i].ss;
}

sort(all(a),cmp);

ll flag=0;
ll x=0;

for(int i=0;i<n;i++){
  x+=a[i].ff;
  if(x>a[i].ss){
    flag=1;
    break;
  }
}

cout<<(flag?"No":"Yes")<<endl;


return 0;
 
}



Measured memory_bytes: 6352
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < S.size()/2; i++) {
	if (S[i] != S[S.size()-1-i])
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S = ST()
    imos = []
    for s in S:
        if s == "(":
            imos.append(1)
        else:
            imos.append(-1)
    status = [0]
    head = ""
    tail = ""
    for imo in imos:
        appp = status[-1] + imo
        if appp < 0:
            head += "("
            appp = 0
        status.append(appp)
    if status[-1] > 0:
        tail = ")" * status[-1]
    print(head+S+tail)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X;
  cin >> X;
  ll item = X / 100;
  ll res = X - item * 100;
  if (item >= 21) {
    cout << 1 << endl;
  } else {
    ll value = 5;
    ll gain;
    while (item > 0 && value > 0) {
      gain = res / value;
      res -= gain * value;
      item -= gain;
      value--;
    }
    if (res > 0 || item < 0) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3608
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n%M) * (f(n - 1) % M);
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll X; cin >> X;

	ll n = 100;
	ll y = 0;
	while (1) {
		if (n >= X) {
			cout << y << endl;
			return 0;
		}
		y++;
		n += n * 1 / 100.0;
	}
}


Measured memory_bytes: 11024
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

    List<Character> lst = Arrays.asList('A', 'C', 'G', 'T');
    int max = 0;
    int seq = 0;
    for (int i = 0; i < s.length(); i++) {
      if (lst.contains(s.charAt(i))) {
        ++seq;
      } else {
        if (seq > max) {
          max = seq;
        }
        seq = 0;
      }
    }
    if (seq > max) {
      max = seq;
    }

    System.out.println(max);
  }
}


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

int main() {
     int n,k,sum=0;
     cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)sum+=a[i];
    cout<<sum;
}

Measured memory_bytes: 3632
#pylint: disable=missing-docstring,bad-whitespace,invalid-name,len-as-condition,trailing-newlines,multiple-statements,unnecessary-semicolon,trailing-whitespace,superfluous-parens
import math as M

n,x,t = (map(int,input().split()))
print(t*(n//x) + t*(min(n%x,1)))
exit()

n = int(input())
a = list(map(int,input().split()))
cm = 1000
p1 = p2 = a[0]
for i in range(1,n):
    #print(i,a[i],p1,p2)
    if(a[i]>=p2):
        p2 = a[i]
    elif(a[i]<p2):
        cm += (cm//p1)*(p2-p1)
        p1 = p2 = a[i]
cm += (cm//p1)*(p2-p1)
print(cm)
exit()

cm = 1000
for i in range(0,40):
    st = cm//100
    cm -= st*100
    cm += st*200
print(cm)
print(M.log10(cm))
print(M.log2(10**16))
exit()

isPrime = [1]*101
isPrime[0]=isPrime[1]=0
for i in range(2,int(M.sqrt(101)+1)) :
    if not isPrime[i] : continue
    for j in range(i*i,101,i) :
        isPrime[j]=0

pa = 5
pb = 1
ctr= 0
for i in range(2,101) : 
    if not isPrime[i] : continue
    if i==5 : 
        ctr+=1
        continue
    if(ctr&1) : 
        pa *= i
    else : 
        pb *= i
    ctr+=1
print(pa,' ',pa<=2*(10**18))
print(pb,' ',pb<=2*(10**18))


#init pa = 5, pb = 1
#into b  2
#into a  3
#into a  7
#into b  11
#into a  13
#into b  17
#into a  19
#into b  23
#into a  29
#into b  31
#into a  37
#into b  41
#into a  43
#into b  47
#into a  53
#into b  59
#into a  61
#into b  67
#into a  71
#into b  73
#into a  79
#into b  83
#into a  89
#into b  97
#1931237034633205845   True
#1193829614179601806   True


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
vector<pint> G[110000];
bool c[110000], visited[110000];
void dfs(int idx, int par, bool color) {
    if (visited[idx]) { return; }
    visited[idx] = true;
    c[idx] = color;
    rep(i, G[idx].size()) {
        pint nxt = G[idx][i];
        if (nxt.second & 1) { dfs(nxt.first, idx, !color); }
        else { dfs(nxt.first, idx, color); }
    }
}
signed main() {
    cin >> N;
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    dfs(0, -1, 0);
    rep(i, N) { cout << c[i] << endl; }

}

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

int main(void){
	int N;
	ll K;
	cin >> N >> K;
	int P[N+1];
	rep(i,N) cin >> P[i+1];
	int C[N+1];
	rep(i,N) cin >> C[i+1];

	ll ans = -1e10;
	for (int i = 1; i <= N; i++) {
		ll tot = 0;
		int period = 0;
		int j = i;
		vector<int> v;
		while (1) {
			j = P[j];
			tot += C[j];
			v.push_back(C[j]);
			period++;
			if (j == i) break;
		}

		ll cand;
		ll tmp = 0;
		rep(j, v.size()) {
			if (j+1>K) break;
			tmp+=v[j];
			cand = tmp;
			if (tot>0) {
				cand += tot*((K-j-1)/period);
			}
			ans = max(ans, cand);
		}
	}

	cout << ans << endl;

return 0;
}

Measured memory_bytes: 3720
import sys

def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
mod = 10**9+7

a = M  # (M_P_N)**2
for i in range(1,N):
    a *= M-i
    a %= mod

# 包除原理
# 2つめの条件は常に成り立った状況で考える
# {1,…,N}の部分集合Sの元iに対してA_i=B_iが成り立つようなA_1,…,B_1,…の組の個数を考える
ans = a**2 % mod
r = ans
for i in range(1,N+1):
    r *= (N-i+1)*pow(i,mod-2,mod)*pow(M-i+1,mod-2,mod)*(-1)
    r %= mod
    ans += r
    ans %= mod

print(ans)

Measured memory_bytes: 68228
#include <iostream>
#include <string>
#include <vector>
#include <set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int x, y;
  cin >> x >> y;

  std::set<int> a = {1, 3, 5, 7, 8, 10, 12};
  std::set<int> b = {4, 6, 9, 11};
  if (x == y) cout << "Yes" << endl;
  else {
    if (a.find(x) != a.end() && a.find(y) != a.end()) cout << "Yes" << endl;
    else if (b.find(x) != b.end() && b.find(y) != b.end()) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a) {
    if (a == 2) return true;
    if (a <= 1 || a % 2 == 0) return false;

    for (int i = 3; i * i <= a; i += 2) {
        if (a % i == 0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> aaa;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (aaa[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1;  //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok =
        (int)aaa
            .size();  // 「index =
                      // a.size()-1」が条件を満たさないこともあるので、初期値は
                      // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

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

    int ans = 0;
    int mcnt = 0;
    rep(i, n + 1) {
        int ti = i;
        int cnt = 0;
        while (ti) {
            if (ti % 2 == 0) { cnt++; }
            ti /= 2;
        }
        if (mcnt <= cnt) {
            mcnt = cnt;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

A, V = ri_()
B, W = ri_()
T = ri()

if abs(A - B) <= (V - W) * T:
    print('YES')
else:
    print('NO')

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;


    ll n;

    cin >> n;


    ll a;



    ll sum = 0;



    for(int i=0; i<n; i++)
    {
        cin >> a;
        sum += (a-1);
    }

    cout << sum << endl;






    return 0;
}


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

long long N, K;

long long res;

int main(){
    cin >> N >> K;
    if (N >= K)
    {
        res = min(N - K * (N / K), abs(N - K * (N / K + 1)));
    }
    else{
        res = min(N, abs(N - K));
    }
    cout << res << endl;

}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        int cntW = 0;
        int cntR = 0;
        for (int i=0; i< arr.length; i++) {
            if (arr[i] == 'W') cntW++;
            else cntR++;
        }

//        System.out.println(cntW);
//        System.out.println(cntR);

        int res = 0;
        for (int i=0; i<cntR; i++) {
            if (arr[i] == 'W') res++;
        }

        System.out.println(res);


    }

}



Measured memory_bytes: 40996
<?php
error_reporting(E_ALL & ~E_NOTICE); // Noticeエラーを非表示に
define("MOD", 10 ** 9 + 7);

# 入力
fscanf(STDIN, '%s', $s);
$s = strrev($s);
$n = strlen($s);

$dp[0][0] = 1;
$mul = 1;
for ($i = 0; $i < $n; $i++) {
    if ($s[$i] === '?') {
        for ($j = 0; $j < 10; $j++) {
            $diff = $mul * $j;
            for ($k = 0; $k < 13; $k++) {
                $dp[$i + 1][($diff + $k) % 13] += $dp[$i][$k];
            }
        }
    } else {
        $j = (int)$s[$i];
        $diff = $mul * $j;
        for ($k = 0; $k < 13; $k++) {
            $dp[$i + 1][($diff + $k) % 13] = $dp[$i][$k];
        }
    }
    for($k = 0; $k < 13; $k++) {
        $dp[$i + 1][$k] %= MOD;
    }
    $mul *= 10;
    $mul %= 13;
}
echo $dp[$n][5].PHP_EOL;

Measured memory_bytes: 76276
#include <iostream>
int main(int argc, char const *argv[]) {
    int A,B,C;
    std::cin >> A>>B>>C;
    if (A<=C && C<=B) {
        std::cout << "Yes" << '\n';
    }
    else{
        std::cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)


def f1(n):
    divs = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divs.append(i)
            j = n // i
            if i != j:
                divs.append(j)
    return divs


N = int(input())

# N - 1
divs1 = f1(N - 1)
ans1 = len(divs1) - 1

# N
divs = f1(N)
ans2 = 0
for i in range(1, len(divs)):
    t = N
    d = divs[i]
    while t % d == 0:
        t //= d
    if t % d == 1:
        ans2 += 1

print(ans1 + ans2)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    vector<ll> B(N+1); repp(i,0,N+1) cin >> B[i];
    vector<ll> A(N); repp(i,0,N) cin >> A[i];
    ll res = 0;
    repp(i,0,N) {
        res += min(B[i], A[i]);
        if (B[i] < A[i]) {
            res += min(B[i+1], A[i] - B[i]);
            B[i+1] -= min(B[i+1], A[i] - B[i]);
        }
    }
    cout << res << endl;
}


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

int adj[100][100];
int vertex;
int ans;

int max(int a, int b)
{
    return (a > b ? a : b);
}

void dfs(int v, int num, int *vis)
{
    int i;
    int flag;
    
    flag = 0;
    for (i = 0; i < vertex; i++){
        if (adj[v][i] && vis[i] == 0){
            adj[v][i] =  0;
            vis[i] = 1;
            dfs(i, num + 1, vis);
            adj[v][i] = 1;
            vis[i] = 0;
          }
    }
    if (flag == 0){
        ans = ans > num ? ans : num;
    }
    return;
}

int main(void)
{
    int vis[100];
    int n;
    int i, j;
    int from, to;
    int count[100], u[100], mc;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        memset(count, 0, sizeof(count));
        memset(adj, 0, sizeof(adj));
        vertex = 0;
        
        for (i = 0; i < n; i++){
            scanf("%d%d", &from, &to);
            vertex = vertex < from ? from : vertex;
            vertex = vertex < to ? to : vertex;
            from--;
            to--;
            count[to]++;
            adj[from][to] = adj[to][from] = 1;
        }
        
        mc = 10000;
        for (i = 0; i < vertex; i++){
            if (count[i] != 0){
                mc = count[i] < mc ? count[i] : mc;
            }
        }
        ans = 0;
        memset(u, 0, sizeof(u));
        for (i = vertex - 1; i >= 0; i--){
            if (count[i] == mc && u[count[i]] <= 10){
                memset(vis, 0, sizeof(vis));
                vis[i] = 1;
                u[count[i]]++;
                dfs(i, 1, vis);
            }
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

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

typedef long long ll;

ll N;

int main() {
    cin >> N;

    string ans = "";
    while (N != 0) {
        if (N % 2 != 0) {
            N--;
            ans = "1" + ans;
        } else {
            ans = "0" + ans;
        }

        N /= -2;
    }

    if (ans == "") ans = "0";

    cout << ans << endl;
}

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

#define NMAX 10000

int main(void){
  int tbl[NMAX+1];
  int n;
  
  for (int i=0; i<=NMAX; i++) tbl[i] = 0;
  tbl[0] = tbl[1] = -1;
  for (int i=2; i<=NMAX; i++){
    if (tbl[i] == -1) continue;
    tbl[i] = 1;
    for (int j=2*i; j<=NMAX; j+=i) tbl[j] = -1;
  }
  
  while (cin >> n){
    int ans = 0;
    for (int i=1; i<=n; i++){
      if (tbl[i]==1 && tbl[n+1-i]==1) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    bool flag = true;
    vector<int> sc(3, -1);

    rep(i, M) {
        int s, c;
        cin >> s >> c;
        if (sc[s - 1] == -1 || sc[s - 1] == c) {
            sc[s - 1] = c;
        }
        else {
            flag = false;
        }
    }

    if (sc[0] == 0 && N >= 2) {
        flag = false;
    }

    if (flag) {
        if ((sc[0] == 0 || sc[0] == -1) && N == 1) {
            cout << 0 << endl;
            return 0;
        }
        else {
            rep(i, N) {
                if (i == 0) {
                    cout << (sc[i] == -1 ? 1 : sc[i]);
                }
                else {
                    cout << (sc[i] == -1 ? 0 : sc[i]);
                }
            }
            cout << endl;
            return 0;
        }
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256