akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  bool b[101] = {};
  rep(i,0,3){
    int a;
    cin >> a;
    //P("done 1");
    b[a] = true;
  }
  
  //P("done 2");
  int sum = 0;
  
  rep(i,0,101){
    //P("done 3");
    if(b[i])
      sum++;
  }

  P(sum);
  
  ret 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>

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

void dfs ( int s, vector<vector<int>> &g, vector<int> &ans, int pre = -1 ) {
    for ( auto u : g[s] ) {
        if ( u == pre ) continue;
        ans[u] += ans[s];
        dfs(u, g, ans, s);
    }
    return;
}

int main(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans(n, 0);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
//    rep(i, n) cout << ans[i] << " ";
//    cout << endl;
    dfs(0, g, ans);
    rep(i, n) {
        if ( i >= 1 ) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 29696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace AtCoderProject
{
    static class Program
    {
        static void Main(string[] args)
        {
            var N = ReadLineInt32();
            double res = 0;
            foreach (var line in RepeatReadLinesSplit(N))
            {
                var x = double.Parse(line[0]);
                var type = line[1];

                res += type == "BTC" ? 380000 * x : x;
            }
            WriteLine(res);
        }

#if DEBUG
        private static string _ReadLineImpl() => queue.Dequeue();
        private static Queue<string> queue = new Queue<string>
        {
            "5",
            "10 BTC",
            "10 JPY",
            "10 BTC",
            "10 BTC",
            "10 BTC"
        };
#else
        private static string _ReadLineImpl() => Console.ReadLine();
#endif
        static string ReadLine() => _ReadLineImpl();
        static int ReadLineInt32() => int.Parse(ReadLine());
        static string[] ReadLineSplit(char c = ' ') => ReadLine().Split(c);
        static int[] ReadLineSplitInt32(char c = ' ') => ReadLine().Split(c).Select(s => int.Parse(s)).ToArray();
        static long[] ReadLineSplitInt64(char c = ' ') => ReadLine().Split(c).Select(s => long.Parse(s)).ToArray();
        static IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        static IEnumerable<string[]> RepeatReadLinesSplit(int count, char c = ' ')
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit(c);
        }

        static void Add<T>(this Queue<T> queue, T value) => queue.Enqueue(value);
    }
}


Measured memory_bytes: 13140
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"AtCoder"# => r#"AC"#,
r#"ACoder"# => r#"WA"#,
r#"AcycliC"# => r#"WA"#,
r#"AtCoCo"# => r#"WA"#,
r#"Atcoder"# => r#"WA"#,
r#"AaCa"# => r#"AC"#,
r#"ApproaCh"# => r#"AC"#,
}

// S の先頭の文字は大文字の A である。
// S の先頭から 3 文字目と末尾から 2 文字目の間（両端含む）に大文字の C がちょうど 1 個含まれる。
// 以上の A, C を除く S のすべての文字は小文字である。

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }

    let cnt_low = s.iter().filter(|c| c.is_lowercase()).count();

    // println!("{}", s[0]);
    // println!("{:?}", &s[2..s.len() - 1]);

    if s[0] == 'A' &&
       s[2..s.len() - 1].iter().filter(|&&c| c == 'C').count() == 1 &&
       cnt_low == s.len() - 2 {
           "AC"
    } else {
           "WA"
    }.to_string()
}

Measured memory_bytes: 4352
/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define N 100000
using namespace std;
int parent[N];
int rankParent[N];
void makeSet(ll n)
{
    ll i;
    for(i=1;i<=n;i++)
    {
        parent[i]=i;
        rankParent[i]=0;
    }
}
ll findParent(ll x)
{
    if(x!=parent[x])
    {
        return parent[x]=findParent(parent[x]);
    }
    else
    {
        return x;
    }
}
void makeUnion(ll a,ll b)
{
    ll pa=findParent(a);
    ll pb=findParent(b);
    if(pa==pb)
        return;
    if(rankParent[pa]<rankParent[pb])
    {
        parent[pa]=pb;
    }
    else if(rankParent[pa]>rankParent[pb])
    {
        parent[pb]=pa;
    }
    else
    {
        parent[pb]=pa;
        rankParent[pa]++;
    }
}
struct cell
{
    ll u;
    ll v;
    ll w;
};
vector<cell>v;
bool vis[N];
bool cmp(cell &a,cell &b)
    {
        return a.w<b.w;
    }
ll kruskal(ll n)
{
    makeSet(n);
    sort(v.begin(),v.end(),cmp);
    ll dis=0,i;
    for(i=0;i<v.size();i++)
    {
        if(findParent(v[i].u)!=findParent(v[i].v))
        {
            makeUnion(parent[v[i].u],parent[v[i].v]);
            dis+=v[i].w;
        }
    }
    return dis;
}
int main()
{
    fast;
    ll n,a,b,i,e,c;
    cin>>n>>e;
    for(i=0;i<e;i++)
    {
        cin>>a>>b>>c;
        v.pub({a,b,c});
    }
    ll ans=kruskal(n);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 6044
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=r.split("\n"),n=t(e[0].split(" ").map(function(r){return Number(r)}),2),o=n[0],u=n[1],i=[],f=[],l=0;l<o;l++){var a=e[l+1].split("");i.push(a);for(var c=0;c<u;c++)"#"==a[c]&&f.push({x:c,y:l})}for(var s=[1,-1,0,0],p=[0,0,1,-1];f.length>0;){for(var d=f.shift(),y=!1,v=0;v<4;v++){var b=d.x+s[v],m=d.y+p[v];b>=0&&b<u&&m>=0&&m<o&&"#"==i[m][b]&&(y=!0)}if(!y)return void console.log("No")}console.log("Yes")}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(){
	int i,j,last,base;
	int N,Q,L;
	int x[100001];
	int b[100001];
	int ans[100001];
	int c[100001];
	int d[100001];
	int jumb1000[100001];
		
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",&x[i]);
	}
	
	scanf("%d",&L);
	i=1;j=1;
	for(;i<=N;){
		for(;j<=N;){
			if((x[j]-x[i]<=L)){
				last = j;
				j++;
				
			}else{
				b[i]=last;
				i++;
			}
		}
		if(last==N){
			b[i]=last;
			i++;
		}
	}
	
	for(i=1;i<=N;i++){
		
		base = i;
		for(j=1;j<101;j++){
			if(b[base]<N&&base<N){
				base=b[base];
			}
			else{
				jumb1000[i] =N+1;
				break;
			}
		}
		if(jumb1000[i] !=N+1 )
			jumb1000[i] =base;
	}
	
	scanf("%d",&Q);
	for(i=1;i<=Q;i++){
		scanf("%d",&c[i]);
		scanf("%d",&d[i]);
	}
	for(i=1;i<=Q;i++){

		if(c[i]>d[i]){
			j=c[i];c[i]=d[i];d[i]=j;
		}

//		if(L==1){
//			ans[i]=d[i]-c[i];continue;
//		}
		
		j=1;
		
		while(b[c[i]]<d[i]){
			
			if(jumb1000[c[i]]<d[i]){
				j+=100;c[i]=jumb1000[c[i]];
				continue;
			}
			c[i]=b[c[i]];
			j++;
		}
		ans[i]=j;
	}
	for(i=1;i<=Q;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
#define int long long
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int Q;

void solve(){
	int a,b,c,d;
	read(a);read(b);read(c);read(d);
	int k = (a+b)/(min(a,b)+1);
	int l = 0,r = a+1;
	while(l+1!=r){
		int mid = (l+r)/2;
		int lb = (mid-1)/k;
		int remb = b-lb,rema = a-mid;
		//cout<<l<<' '<<r<<' '<<remb<<' '<<rema<<endl;
		if(remb<0 || rema<0 || (rema+1)*k<remb){
			r = mid;
		}else{
			l = mid;
		}

	}
	//cout<<l<<' '<<r<<endl;
	int lefcont = l+(l-1)/k;
	
	int rcont = (k+1)*(a-l);
	//cout<<lefcont<<' '<<rcont<<endl;
	for(int i=c;i<=d;i++){
		if(i<=lefcont){
			if(i%(k+1) == 0)cout<<'B';
			else cout<<'A';
		}else{
			if((a+b+1-i)<=rcont){
				if((a+b+1-i)%(k+1) == 0)cout<<'A';
				else cout<<'B';
			}else{
				cout<<'B';
			}
		}
	}
	cout<<endl;
}

signed main() {
	read(Q);
	while(Q--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N,Q; cin >> N >> Q;
    vector<vector<ll> > g(N);
    vector<ll> weight(N,0);
    for (int i = 0; i < N-1; i++){
        ll a,b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < Q; i++){
        ll p,x; cin >> p >> x; p--;
        weight[p] += x;
    }
    queue<ll> que;
    que.push(0);
    vector<bool> visited(N,0);
    visited[0] = true;
    while (que.size()){
        int top = que.front();
        visited[top] = true;
        que.pop();
        for (auto e : g[top]){
            if (visited[e] == true) continue;
            weight[e] += weight[top];
            que.push(e);
        }
    }
    for (int i = 0; i < N; i++){
        cout << weight[i] << " ";
    }
    cout << endl;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int 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;
}

int H, W, K;
int ans[301][301];
int c[301];

int fl(int x, int y) {
    if (y > H) return 0;
    if (ans[y][x] == 0) {
        ans[y][x] = fl(x, y + 1);
    }
    return ans[y][x];
}

int fl2(int x, int y) {
    if (y < 0) return 0;
    if (ans[y][x] == 0) {
        ans[y][x] = fl2(x, y - 1);
    }
    return ans[y][x];
}

signed main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    rep(i, N - 1) {
        ans *= K - 1;
    }
    cout << ans << endl;
}


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	stack<char> st;
	rep (i, (int)s.length()){
		if (s[i] != 'B'){
			st.push(s[i]);
		}else
		if (!st.empty()){
			st.pop();
		} // end if
	} // end rep

	string res = "";
	while(!st.empty()){
		res += st.top();
		st.pop();
	} // end while
	
	if (!res.empty()){
		reverse(ALL(res));
	} // end if
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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 $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize, m: usize,
        py: [(usize, usize); m],
    }
    let mut py_ = vec![];

    for i in 0..m {
        let (p, y) = py[i];
        py_.push((p, y, i))
    }
    py_.sort();

    let mut cnt = vec![0; n + 1];
    let mut ans = vec![];
    for i in 0..m {
        let (p, y, i) = py_[i];
        ans.push((i, format!("{: >06}{: >06}", p, cnt[p] + 1)));
        cnt[p] += 1;
    }
    ans.sort();
    for i in 0..m {
        println!("{}", ans[i].1);
    }
}


Measured memory_bytes: 17800
#!/usr/bin python3
# -*- coding: utf-8 -*-

x = int(input())
if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, 0, n) cin >> p[i];

    // initialize range minimum/maximum dequeue
    deque<pii> max_dque;
    deque<pii> min_dque;
    rep(i, 0, k)
    {
        while (max_dque.size() > 0 and max_dque.back().second < p[i])
            max_dque.pop_back();
        max_dque.push_back(make_pair(i, p[i]));
        while (min_dque.size() > 0 and min_dque.back().second > p[i])
            min_dque.pop_back();
        min_dque.push_back(make_pair(i, p[i]));
    }

    // calc increasing length
    vector<int> num_increase(n, 1);
    rep(i, 1, n)
    {
        if (p[i-1] <= p[i])
            num_increase[i] = num_increase[i-1]+1;
    }

    bool org_flag = true;
    int cnt = 1;
    if (k <= num_increase[k-1])
        org_flag = false;
    
    rep(i, k, n)
    {
        bool is_same = false;
        if (max_dque.front().second <= p[i] and min_dque.front().second == p[i-k])
            is_same = true;

        // erase old elements
        if (max_dque.front().first == i-k)
            max_dque.pop_front();
        if (min_dque.front().first == i-k)
            min_dque.pop_front();

        // insert new element
        while (max_dque.size() > 0 and max_dque.back().second < p[i])
            max_dque.pop_back();
        while (min_dque.size() > 0 and min_dque.back().second > p[i])
            min_dque.pop_back();
        max_dque.push_back(make_pair(i, p[i]));
        min_dque.push_back(make_pair(i, p[i]));
        
        // counting
        if (k <= num_increase[i])
        {
            if (org_flag)
                ++cnt, org_flag = false;
            continue;
        }
        if (!is_same)
            ++cnt;

        // cout << i << ' ' << cnt << endl;
    }
    cout << cnt << endl;
    return 0;
}

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

const int INF = 1 << 30;

int main() {
	int N;
	scanf("%d", &N);
	long long sum = 0;
	int mini = INF;
	while (N--) {
		int a, b;
		scanf("%d%d", &a, &b);
		sum += a;
		if (a > b)
			mini = min(mini, b);
	}
	
	printf("%lld\n", mini == INF ? 0 : sum - mini);
	
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var stdin = '';
process.stdin.on('data', function (chunk) {
  stdin += chunk;
}).on('end', function() {
  var lines = stdin.trim().split('\n');
  var numStr = lines[0].split(' ');
  var numbers = numStr.map((num) => {
    return Number(num);
  })
  var total = numbers.reduce((a, b) => {
    return a * b
  })
  if(total % 2 === 0) {
    console.log('Even');
  }
  if(total % 2 !== 0) {
    console.log('Odd');
  }
});


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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 int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};


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

    int ans=0;
    while(N > 0){
        if(N%10==2) ans++;
        
        N /= 10;
    }

    pl(ans)

    return 0;
}

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


int main()
{
  char s[4];
  int a, b, c, d;

  cin >> s;
  a = s[0]-'0';
  b = s[1]-'0';
  c = s[2]-'0';
  d = s[3]-'0';

  if ( a-b-c-d==7 ) cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
  else if ( a-b-c+d==7 ) cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
  else if ( a-b+c-d==7 ) cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
  else if ( a+b-c-d==7 ) cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
  else if ( a-b+c+d==7 ) cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
  else if ( a+b-c+d==7 ) cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
  else if ( a+b+c-d==7 ) cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
  else if ( a+b+c+d==7 ) cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(Q):
  ta,tb,tc,td=map(int,input().split())
  a+=[ta]
  b+=[tb]
  c+=[tc]
  d+=[td]
maxs=0
A=[0 for i in range(10)]
for i in range(M):
  for j in range(i,M):
    for k in range(j,M):
      for l in range(k,M):
        for m in range(l,M):
          for n in range(m,M):
            for o in range(n,M):
              for p in range(o,M):
                for q in range(p,M):
                  for r in range(q,M):
                    A[0]=i
                    A[1]=j
                    A[2]=k
                    A[3]=l
                    A[4]=m
                    A[5]=n
                    A[6]=o
                    A[7]=p
                    A[8]=q
                    A[9]=r
                    su=0
                    for z in range(Q):
                      if A[b[z]-1]-A[a[z]-1]==c[z]:
                        su+=d[z]
                    if su>maxs:
                      maxs=su
print(maxs)


Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, y;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> y;
  y /= 1000;
  FOR(i, 0, y/10+1){
    int r = y-i*10;
    FOR(j, 0, r/5+1){
      if(i + r - j*4 == n){
        cout << i << " " << j << " " << r - j*5 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

int main(){
  
  long long a,sum=0,n,t;
  
  cin>>t>>n;
  for(int i=0;i<n;i++){
    cin>>a;sum+=a;
  }
  if(sum>=t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

int main()
{
  std::string sa, sb;
  std::cin >> sa >> sb;
  sa += sb;
  int a = atoi(sa.c_str());
  float f = sqrt((float)a);
  if (std::floor(f) == std::ceil(f)) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    ll dp[n+1],h[n+1];
    for(i=1;i<=n;i++)
    {
    	cin>>h[i];
    }
    dp[0]=0;
    dp[1]=0;
    dp[2]=fabs(h[2]-h[1]);
    for(i=3;i<=n;i++)
    {
    	dp[i]=min(dp[i-1]+fabs(h[i]-h[i-1]),dp[i-2]+fabs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<"\n";
	return 0;
}

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

using namespace std;
typedef long long ll;

int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

bool srt(int a , int b){
    return a > b ;
}


int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n,a;
    cin>>n>>a;
    n%=500;
    if(a>=n)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int N;
    long long sum=0;
    string S;
    cin >> N;
    cin >> S;
    vector<int> R,G,B;

    for(int i=0; i<S.length(); ++i){
        if(S[i]=='R'){
            R.push_back(i);
        }
        else if(S[i]=='G'){
            G.push_back(i);
        }
        else if(S[i]=='B'){
            B.push_back(i);
        }
    }
    
    for(int i=0; i<R.size(); ++i){
        for(int j=0; j<G.size(); ++j){
            sum += B.size();
            int ii=R[i]-G[j]>0? G[j]:R[i] , jj=R[i]-G[j]>0? R[i]:G[j];
            if((ii+jj)%2==0&& S[(ii+jj)/2]=='B'){
                sum--;
            }
            if((2*jj-ii<=N)&&S[2*jj-ii]=='B'){
                sum--;
            }
            if((2*ii-jj>=0)&&S[2*ii-jj]=='B'){
                sum--;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, d[max];
    int ans=0;
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%d", &d[i]);
    }
    
    qsort(d, n, sizeof(int), down_comp);
    
    rep(i, n-1){
        if (d[i]!=d[i+1]) {
            ans++;
        }
    }
    
    printf("%d", ans+1);
    
    return 0;
}


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

int main(){
  ll R,G,B,n;
  cin >> R >> G >> B >> n;
  ll i=0,j=0,a=0;
  
  while(R*i<=n){
    j=0;
    while(R*i+G*j<=n){
      if((n-R*i-G*j)%B==0){
        a++;
      }
      j++;
    }
    i++;
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3608
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


a, b = read_ints()

if b < a:
    a, b = b, a

print(str(a) * b)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int h, w;
    cin >> h >> w;
    int a[h], b[h];
    rep(i, h) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    set<pair<int, int>> S;  // {現在の位置, 始めの位置}
    multiset<int> M;        // 現在の位置 - 始めの位置
    for (int i = 0; i < w; i++) {
        S.emplace(i, i);
        M.emplace(0);
    }
    rep(i, h) {
        int mx = -1;
        auto itr = S.lower_bound({a[i], 0});
        while (itr != S.end() &&
               itr->first <= b[i]) {  // 現在の位置が範囲内にある
            mx = max(mx, itr->second);
            M.erase(M.find(itr->first - itr->second));
            itr = S.erase(itr);  // set::eraseの返り値は次のイテレータ
        }
        if (mx != -1 &&
            b[i] + 1 <
                w) {  // 始めの位置が最も右にある点だけ残す(ただし、範囲外にでるときは残さない)
            S.emplace(b[i] + 1, mx);
            M.emplace(b[i] + 1 - mx);
        }
        if (M.empty()) {
            cout << -1 << endl;
            continue;
        }
        cout << *M.begin() + i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 23948
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define sz(x)	(ll)x.size()
#define present(c,x) ((c).find(x) != (c).end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
	ll n;
	cin>>n;
	double arr[n+5],dp[n+5][2],dp2[n+5][2],sum=0;
	dp[0][0]=1;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=1;i<=n;i++)
	{
		dp[0][1]=0;
		for(ll j=1;j<=i;j++)
		{
			dp[j][1]=dp[j-1][0]*arr[i];
			dp[j-1][1]+=dp[j-1][0]*(1-arr[i]);
		}
		for(ll j=0;j<=i;j++)
			dp[j][0]=dp[j][1];
	}
	for(ll i=1;i<=n;i++)
	{
		if(i>n/2)
			sum+=dp[i][0];
	}
	cout<<fixed<<setprecision(10)<<sum<<endl; 
}

int main()
{
	boost
	ll t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int n, k;
    cin >> n >> k;
    auto h = IntsIn(n);
    sort(ALL(h));
    Int ans = 0;
    for (Int i = 0; i < max(0LL, n - k); i++) {
        ans += h[i];
    }
    PUTS(ans);
}


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  ll x,y;
  cin >> x >> y;
  ll ans=1;
  while(2*x<=y){
    x *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long a[100007]={};
int main(){
  long N,K,sum=0;
  cin >> N >> K;
  for(long i=0;i<N;i++){
    long b,c;
    cin >> b >> c;
    a[b] += c;
  }
  for(long i=1;i<100007;i++){
    if(sum + a[i]<K)
      sum += a[i];
    else{
      cout << i << endl;
      break;
    }
  }
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */
int h, w, k;
vector<int> s[15];

int main(){
    cin >> h >> w >> k;
    rep(i, h){
        string st; cin >> st;
        rep(j, w) s[i].push_back(st[j] - '0');
    }

    rep(i, h-1) rep(j, w){
        s[i+1][j] += s[i][j];
    }

    int M = (1 << (h-1)); int ans = 1e8;
    rep(m, M){
        vector<int> cut;
        rep(i, h-1){
            if(m & (1 << i)) cut.push_back(i);
        }
        cut.push_back(h-1);

        int l = cut.size();
        vector<int> vec(l);
        rep(i, l) vec[i] = 0;
        int count = 0;
        
        rep(j, w){
            vector<int> buf(l);
            buf[0] = s[cut[0]][j];
            rep(x, l-1) buf[x+1] = s[cut[x+1]][j] - s[cut[x]][j];
            
            bool isok = true;
            rep(x, l){
                if(buf[x] > k){
                    isok = false; break;
                }
            }
            if(!isok){
                count = 1e8; break;
            }

            isok = true;
            rep(x, l){
                if(vec[x] + buf[x] > k){
                    isok = false; break;
                }
            }
            

            if(isok){
                rep(x, l) vec[x] += buf[x];
            }
            else{
                count++;
                rep(x, l) vec[x] = buf[x];
            }
        }
        ans = min(ans, count+l-1);
    }

    out(ans);
}

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

int main() {
  int N;
  int min;
  int ans = 1;
  cin >> N >> min;

  for(int i=0;i<N-1;++i){
    int s; cin >> s;
    if(s < min){
      ans += 1;
      min = s;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
 int n, m;
  cin >> n >> m;
  long long ans=0;
  
  ans += (n * (n-1)) / 2;
  ans += (m * (m-1)) / 2;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> res(2 * N - 1);
    if(x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
        return 0;
    }
    res[N - 2] = 1;
    res[N] = 2 * N - 1;
    res[N - 1] = x;
    int num = 1;
    for(int i = 0; i < 2 * N - 1; i++) {
        if(res[i] == 0) {
            while(num == 1 || num == x)
                num++;
            res[i] = num;
            num++;
        }
    }
    cout << "Yes" << endl;
    rep(i, 2 * N - 1) { cout << res[i] << endl; }

    return 0;
}

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

using namespace std;

int main() {
    int k=0,n,i;
    char s[101];
    cin.getline(s,101) ;/////citirea unui sir de caractere
    n=strlen(s); ///retin lungimea sirului 
    for(i=0;i<=n/2-1;i++){
        if(s[i]!=s[n-i-1]){
            k++;
        }
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 384
n=int(input())
info=[]
for i in range(n):
    info.append(list(input().split()))                
total=0

for i in range(n):
    if info[i][1]=="JPY":
        total+=eval(info[i][0])
    else:
        total+=(eval(info[i][0])/0.00000001)*0.0038
print(total)

Measured memory_bytes: 3060
N = int(input())
X = []
for i in range(N):
    xi,yi = map(int,input().split())
    X.append([xi,yi])

L = []
d = {}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
    
        x,y = X[i][0]-X[j][0],X[i][1]-X[j][1]
        #L.append([x,y])
        if not x in d:
            d[x] = {}
        if not y in d[x]:
            d[x][y] = 1
        else:
            d[x][y] += 1
m = 0
for k in list(d.keys()):
    for kk in list(d[k].keys()):
        m = max(m,d[k][kk])
print(N-m)


Measured memory_bytes: 41584
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,tax[4],vis[310][310][310];
double dp[310][310][310];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

double dfs(int x,int y,int z) 
{
	if (vis[x][y][z]) return dp[x][y][z];
	int sum=x+y+z;dp[x][y][z]=(double)n/sum;vis[x][y][z]=1;
	if (x>0) dp[x][y][z]+=dfs(x-1,y,z)*x/sum;
	if (y>0) dp[x][y][z]+=dfs(x+1,y-1,z)*y/sum;
	if (z>0) dp[x][y][z]+=dfs(x,y+1,z-1)*z/sum;
	return dp[x][y][z];
}

int main()
{
	n=read();
	rep(i,1,n) tax[read()]++;
	vis[0][0][0]=1;
	dfs(tax[1],tax[2],tax[3]);
	printf("%0.12lf",dp[tax[1]][tax[2]][tax[3]]);
	return 0;
}


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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

pair<int, int> arr[maxn];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);   
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i].ff >> arr[i].ss;
  }
  sort(arr + 1, arr + 1 + n);
  priority_queue<int> pq;
  int idx = 1, ans = 0;
  for (int i = 1; i <= m; ++i) {
    while (idx <= n && arr[idx].ff <= i) {
      pq.push(arr[idx].ss);
      idx++;
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main(void) {
    
    int array[110];
    int n;
    int count;
    int i, j;

    scanf("%d", &n);

    for (i=0; i< n; i++) {
        scanf("%d", &array[i]);
    }

    for (i = 0; i < n; i++) {
        bool can = true;
        for (j = i+1; j < n; j++) {
            if (array[i] == array[j]) {
                can = false;
            }
        }
        if (can) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    String S = sc.next();
    
   // System.out.println(S.length());
    if( S.length() <= K )
      System.out.println(S);
    else
      System.out.println( S.substring(0,K) + "..." );
  }
}

Measured memory_bytes: 38556
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    cin >> N;
    vector<ll> A(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i + 1);
    }
    for (int i = 0; i < N; i++) {
        A[i + 1] += A[i];
    }

    ll ans = INF;
    for (int i = 0; i < N; i++) {
        chmin(ans, abs(A[N] - A[i] * 2));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i=1; i<N; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i=1; i<=N; i++) {
        int time = 0;
        int now = i;
        while(now < N) {
            while(time < S[now] || time % F[now]) {
                ++time;
            }
            time += C[now];
            ++now;
        }
        cout << time << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 /* int n, i;
	double array[1000];
	double array2[1000];
	double sum;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%lf", &array[i]);
	}

	for (i = 1; i <= n; i++) {
		scanf("%lf", &array2[i]);
	}

	//p=1
	sum = 0;

	for (i = 1; i <= n; i++) {
		sum += fabs(array[i] - array2[i]);
	}
	printf("%llf\n", sum);

	sum = 0;
	//p=2
	for (i = 1; i <= n; i++) {
		sum += pow(array[i] - array2[i], 2);
	}
	printf("%llf\n", pow(sum, 0.5));

	sum = 0;
	//p=3
	for (i = 1; i <= n; i++) {
		sum += pow(fabs(array[i] - array2[i]), 3);
	}
	printf("%llf\n", pow(sum, 1.0 / 3));

	//p=∞
	double max = 0;
	for (i = 1; i <= n; i++) {
		if (fabs(array[i] - array2[i])>max) {
			max = fabs(array[i] - array2[i]);
		}
	}
	printf("%llf\n", max);*/
	int i, n, x[100], y[100];
	double p_1 = 0, p_2 = 0, p_3 = 0, p_0 = 0;

	scanf("%d", &n);

	for (i = 0; i<n; i++)
		scanf("%d", &x[i]);
	for (i = 0; i<n; i++)
		scanf("%d", &y[i]);

	for (i = 0; i<n; i++) {

		//p=1
		p_1 += abs(x[i] - y[i]);

		//p=2
		p_2 += pow(fabs((double)x[i] - y[i]), 2.0);

		//p=3
		p_3 += pow(fabs((double)x[i] - y[i]), 3.0);

		//p=endless
		if (p_0 < abs(x[i] - y[i])) p_0 = abs(x[i] - y[i]);

	}

	printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2, 1.0 / 2), pow(p_3, 1.0 / 3), p_0);

    return 0;
}


Measured memory_bytes: 2108