akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long i64;
typedef pair <i64, i64> Line;
const int NMAX = 200010;

namespace Batch {
    Line lines[NMAX];
    i64 when[NMAX];
    int cnt;

    i64 intersect(Line & a, Line & b) {
        return (b.second - a.second) / (a.first - b.first);
    }

    void add_line(Line l) {
        /// dreapta ax + b

        i64 d;
        while (cnt >= 2 && (d = intersect(l, lines[cnt - 1])) < when[cnt - 2])
            cnt--;
        if (cnt)
            when[cnt - 1] = intersect(l, lines[cnt - 1]);
        lines[cnt++] = l;
        when[cnt - 1] = 1e18;
    }

    i64 query(i64 x) {
        /// valoarea minima pt un x
        int poz = lower_bound(when, when + cnt, x) - when;
        return x * lines[poz].first + lines[poz].second;
    }
}

/*
    dp[i] = min dp[j] + C + (h[i] - h[j]) ^ 2
    dp[i] = h[i]^2+C + min (-2*h[j]) * h[i] + (h[j]^2+dp[j])

    -> vreau sa fac un batch de minime cu drepte care se adauga, cu pantele din ce in ce mai mici

*/
int main()
{
    int n;
    i64 C;
    scanf("%d%lld", &n, &C);

    i64 dp;
    for (int i = 1; i <= n; i++) {
        int h;
        scanf("%d", &h);
        dp = 0;
        if (i != 1)
            dp = C + 1LL * h * h + Batch::query(h);

        Batch::add_line(make_pair(-2 * h, 1LL * h * h + dp));
    }

    printf("%lld\n", dp);

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define one(x) cout<<#x<<" : "<<x<<endl;
#define two(x,y) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;


signed main()
{
    int n , k , i , j;
    cin >> k >> n;
    vector< int > v(n+1) , dis(n+1);
    for(i=0 ; i<n ;i++)
    {
        cin >> v[i];
    }
    for(i=0 ; i<n-1 ; i++)
    {
       dis[i] = abs(v[i+1] - v[i]);
    }
    dis[n-1] = abs ( v[0] + abs(v[n-1]   - k))  ;
    int mx = 0;
    for(i=0 ; i<n ; i++)
    {
//        cout<<dis[i]<<endl;
        mx = max(dis[i] , mx);
    }
    cout<<k - mx<<endl;
}




Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	ll ans = 0;
	ll cnt = 0;
	for(int i = n-1; i >= 0; i--){
		if(s[i]=='W') cnt++;
		else ans += cnt;
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  if (n == 0)
    cout << n << endl;
  else if(n % 2 == 1)
    cout << n / 2 + 1 << endl;
  else 
    cout << n/2 << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);


int main(){
  int N; scanf("%d", &N);
  for (int i = 0; i < N; i++){
    int A; scanf("%d", &A);
    if (A % 2 != 0){
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  
  return 0;
}


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

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

    int h = S / (60 * 60);
    int m = (S - h * (60 * 60)) / 60;
    int s = S % 60;

    cout << h << ':' << m << ':' << s << '\n';


    //scanf("%d %d", &a, &b);
    //cin >> a >> b;
    //c = a + b;
    //cout << a << " + " << b << " = " << c << '\n';
    //printf("%d %d\n", a * b, 2 * (a + b));

    return 0;
}

Measured memory_bytes: 1164
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let M: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (d, c): (Vec<usize>, Vec<usize>) = {
        let (mut d, mut c) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            d.push(iter.next().unwrap().parse().unwrap());
            c.push(iter.next().unwrap().parse().unwrap());
        }
        (d, c)
    };

    let k = c.iter().sum::<usize>() - 1;
    let s = (0..M).map(|i| d[i] * c[i]).sum::<usize>();
    let ans = if s <= 0 { k } else { k + (s - 1) / 9 };

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e5+5;
int parent[N];
int size[N];

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(int v) {
    parent[v] = v;
    size[v] = 1;
}

void union_sets(int a, int b) {
    a=find_set(a);
    b=find_set(b);
    if (a != b) {
        if (size[a] < size[b])
            swap(a, b);
        parent[b] = a;
        size[a] += size[b];
    }
}

int32_t main(){
	IOS;
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<N;i++) make_set(i);
	vi v[n];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
		union_sets(x,y);
	}
	for(int i=0;i<k;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i=0;i<n;i++){
		int x=find_set(i);
		int ans=size[x];
		ans--;
		for(int j=0;j<v[i].size();j++){
			if(find_set(v[i][j])==x) ans--;
		}
		cout<<ans<<" ";
	}
}

Measured memory_bytes: 11264
#include <iostream>

using namespace std;

int main (int argc, char const* argv[])
{
	int s = 0;
	for (unsigned int i = 0; i < 10; i += 1)
	{
		int pt;
		cin >> pt;
		s += pt;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
int main()
{
    int a, b;
    char op[10];
    scanf("%d %s %d", &a, op, &b);
    while (strcmp(op, "?") != 0) {
        if (strcmp(op, "+") == 0) {
            printf("%d\n", a + b);
        } else if (strcmp(op, "-") == 0) {
            printf("%d\n", a - b);
        } else if (strcmp(op, "*") == 0) {
            printf("%d\n", a * b);
        } else if (strcmp(op, "/") == 0) {
            printf("%d\n", a / b);
        } else {
            break;
        }
        scanf("%d %s %d", &a, op, &b);
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i,n) for (int i=0; i< (n); ++i)
typedef pair<int, int> P;

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
  
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  int ans = 0;
  rep(i,h) cin >> s[i];
  rep(si,h)rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j));
    };
    update(si,sj,0);
    while(!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(dir,4) {
	int ni = i+di[dir];
	int nj = j+dj[dir];
	if (ni<0 || ni>=h || nj<0 || nj >=w) continue;
	if (s[ni][nj] == '#') continue;
	update(ni, nj, dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		if(ii % 2)
		{
			if(ss[ii] != 'L' && ss[ii] != 'U' && ss[ii] != 'D')
			{
				puts("No");
				return 0;
			}
		}
		else
		{
			if(ss[ii] != 'R' && ss[ii] != 'U' && ss[ii] != 'D')
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

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

using namespace std;

int main(void) {
  int Q; cin >> Q;
  multiset<long long> R;
  multiset<long long, greater<long long>> L;
  long long B = 0, C = 0, l = 0, r = 0;

  for (int i = 0; i < Q; i++) {
    int q; cin >> q;

    if (q == 1) {
      long long a, b; cin >> a >> b;
      if (R.empty()) {
        R.insert(a);
        L.insert(a);
        l += a;
        r += a;
        
      } else {
        if (*L.begin() > a) {
          L.insert(a);
          L.insert(a);
          R.insert(*L.begin());
          L.erase(L.begin());
          l += 2*a - *R.begin();
          r += *R.begin();
        } else if (*R.begin() >= a) {
          L.insert(a);
          R.insert(a);
          l += a;
          r += a;
        } else {
          R.insert(a);
          R.insert(a);
          L.insert(*R.begin());
          R.erase(R.begin());
          r += 2*a - *L.begin();
          l += *L.begin();
        }
      }
      B += b;
      C++;
    } else {
      cout << *L.begin() << " ";
      
      if (C % 2 == 0) {
        cout << abs(l/2 - *L.begin() * C/2) + abs(r/2 - *L.begin() * C/2) + B << endl;
      } else {
        cout << abs((l-*L.begin())/2 - *L.begin() * (C/2)) + abs((r-*L.begin())/2 - *L.begin() * (C/2)) + B << endl;
      }
    }
  }

  return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,C;
    cin >> N >> C;

    vector<i64> x(N),v(N);
    rep(i,0,N) cin >> x[i] >> v[i];

    i64 ans=0;
    vector<i64> a(N),b(N),s(N),t(N);
    {
        i64 tmp=v[0]-x[0];
        a[0]=s[0]=tmp;
        ans=max(ans,tmp);
        rep(i,1,N){
            tmp-=x[i]-x[i-1];
            tmp+=v[i];
            a[i]=tmp;
            s[i]=max(s[i-1],tmp);
            ans=max(ans,tmp);
        }
    }
    {
        i64 tmp=v[N-1]-(C-x[N-1]);
        b[N-1]=t[N-1]=tmp;
        ans=max(ans,tmp);
        for(int i=N-2; i>=0; --i){
            tmp-=x[i+1]-x[i];
            tmp+=v[i];
            b[i]=tmp;
            t[i]=max(t[i+1],tmp);
            ans=max(ans,tmp);
        }
    }

    rep(i,0,N-1) ans=max(ans,a[i]-x[i]+t[i+1]);
    rep(i,1,N) ans=max(ans,b[i]-(C-x[i])+s[i-1]);

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;
using ll = long long;
const int MOD = 1000000007;

class mint {
public:
    ll value;
    
    mint(ll a = 0) : value((a % MOD + MOD) % MOD) {}
    bool operator < (mint a) { return this->value < a.value; }
    bool operator > (mint a) { return this->value > a.value; }
    bool operator <= (mint a) { return this->value <= a.value; }
    bool operator >= (mint a) { return this->value >= a.value; }
    mint& operator += (const mint& a) { if ((this->value += a.value) > MOD) this->value -= MOD; return *this; }
    mint& operator -= (const mint& a) { if ((this->value -= a.value) < 0ll) this->value += MOD; return *this; }
    mint& operator *= (const mint& a) { (this->value *= a.value) %= MOD; return *this; }
    mint operator + (const mint a) const { mint ret(this->value); return ret += a; }
    mint operator - (const mint a) const { mint ret(this->value); return ret -= a; }
    mint operator * (const mint a) const { mint ret(this->value); return ret *= a; }
    mint pow(ll times) const {
        if (!times) return 1;
        mint ret = pow(times >> 1); 
        ret *= ret;
        if (times & 1) ret *= *this;
        return ret;
    }   
    mint inv() const { return pow(MOD - 2); }
    mint& operator /= (const mint& a) { return (*this) *= a.inv(); }
    mint operator / (const mint a) const { mint ret(this->value); return ret /= a; }
    friend ostream& operator << (ostream& os, const mint& m) { os << m.value; return os; }
};

int main() {
  int n, k; cin >> n >> k;
  vector<ll> as(n, 0);
  for (auto& a : as) cin >> a;
  sort(as.begin(), as.end());
  reverse(as.begin(), as.end());
  mint prod = 1;
  if (k % 2 == 1) {
    if (as[0] < 0) {
      for (int i = 0; i < k; i++) {
        prod *= as[i];
      }
      cout << prod << endl; return 0;
    }
    prod *= as[0];
  }
  for (int i = n - 1, index = k - 1; i > 0 && index > 0; i -= 2, index -= 2) {
  	if (as[i - 1] < 0 && as[i] * as[i - 1] > as[index] * as[index - 1]) {
      prod *= as[i];
      prod *= as[i - 1];
    }
    else {
      prod *= as[index];
      prod *= as[index - 1];
    }
  }
  cout << prod << endl;
}

Measured memory_bytes: 4704
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll N,A,B;
ll sup=0,inf=0;
int h[100000];

bool enough(ll k){
	ll cnt=0;
	rep(i,N){
		if(h[i]>k*B)cnt += ceil(double(h[i]-k*B)/(A-B));
	}
	if(cnt<=k){
		return true;
	}else{
		return false;
	}
}

int main(void){
	cin>>N>>A>>B;
	rep(i,N){
		cin>>h[i];
		if(sup<h[i])sup=h[i];
	}
	sup = sup/B+1;
	while(1){//２分探索で0点を求める
		if(sup-inf<=1)break;
		if(enough((sup+inf)/2)){
			sup=(sup+inf)/2;
		}else{
			inf=(sup+inf)/2;
		}
		// cout<<sup<<","<<inf<<endl;
	}
	cout<<sup<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int i;
  char s[4];
  scanf("%s",s);
  for(i=0;i<3;i++){
    if(s[i]=='1')
      printf("9");
    else if(s[i]=='9')
      printf("1");
    else
      printf("%c",s[i]);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int a[5],k,i,f=1;
    for(i=0;i<5;i++){
        cin >> a[i];
    }
    cin >> k;
    if(a[4]-a[0]<=k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int k = sc.nextInt();
        int x = sc.nextInt();

        for (int i = x - (k - 1); i < x + k; i++) {
            System.out.print(i + " ");
        }
    }
}

Measured memory_bytes: 21972
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

llong LIST[3] = {3, 5, 7};
llong dfs(vector<llong> &A, llong maxv){
    llong final_ans=0;
    llong table[3] = {0, 0, 0};
    llong ans=0;
    char flg=0;
    if(A.size()==10){
        return 0;
    }
    for(int i=0; i<A.size(); i++){
        ans = ans + A[i]*pow(10, i);
        if(A[i]==7){
            table[2] = 1;
        }else if(A[i]==5){
            table[1] = 1;
        }else{
            table[0] = 1;
        }
    }
    if(ans<=maxv){
        for(int i=0; i<3; i++){
            if(table[i]==0){
                flg = 1;
                break;
            }
        }
        if(flg==0){
            final_ans++;
        }
    }
    
    for(int i=0; i<3; i++){
        A.push_back(LIST[i]);
        final_ans += dfs(A, maxv);
        A.pop_back();
    }
    return final_ans;
}

int main(){
    llong N;
    cin >> N;
    vector<llong> A;
    cout << dfs(A,N) << endl;
    return 0;
}


Measured memory_bytes: 3540
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let s: Vec<String> = (0..n).map(|_| input()).collect();
    println!(
        "{}",
        if s.contains(&"Y".to_string()) {
            "Four"
        } else {
            "Three"
        }
    );
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var ls = new List<Hoge>();
            for (int i = 0; i < n; i++)
            {
                string[] inp = ReadLine().Split(' ');
                string s = inp[0];
                int t = int.Parse(inp[1]);
                ls.Add(new Hoge(s, t));
            }
            string x = ReadLine();
            long ans = 0;
            bool tmp = false;
            for (int i = 0; i < n; i++)
            {
                if (tmp) ans += ls[i].Len;
                if (ls[i].Name == x)
                {
                    tmp = true;
                }
            }
            WriteLine(ans);
        }
    }
    class Hoge
    {
        public Hoge(string name, int len)
        {
            Name = name;
            Len = len;
        }

        public string Name { get; set; }
        public int Len { get; set; }

    }
}

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


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n+1; i++){
        int d = n/i;
        ans += ((d*(d+1))/2)*i;
    }
    cout <<ans;
    return 0;
}

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

#define len(s) int(s.size())
#define res(x) cout<<((x)?"Yes\n":"No\n")
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef long double ld;

ll mod = 1e9+7;

void solution() {
	string s, t;
	cin >> s >> t;

	bool ans = true;
	for(int i = 0; i < len(s); ++i) {
		if(s[i] != t[i]) {
			ans = false;
		}
	}

	res(ans);
	
}

int main(){
	
	int t = 1;
	//cin >> t;
	
	while(t--)
		solution();
	
	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        int x = i;
        if(i % 3 == 0)
            printf(" %d",i);
        else 
            do{
                if(x % 10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /= 10;
            }   while (x);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans = 1;
  cin >> N;
  vector <int> num(N);
  for(int i = 0;i<N;i++){
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  for(int i = 0;i<N;i++){
    if(i != N-1){
      if(num.at(i)<num.at(i+1)){ans++;}
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 3010
#define p 1000000007
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,m,ans;
int f[maxn][maxn],g[maxn][maxn];
int main()
{
	read(n),read(m),g[0][0]=1;
	for(int i=1;i<=n;++i) f[0][i]=1;
	for(int i=1;i<=m;++i)
	{
		for(int j=0;j<=n;++j)
		{
			f[i][j+1]=(f[i][j+1]+f[i-1][j]*(j<n))%p;
			g[i][j+1]=(g[i][j+1]+g[i-1][j]*(j<n))%p;
			f[i][j]=(f[i][j]+f[i-1][j]*(j<n))%p;
			g[i][j]=(g[i][j]+g[i-1][j]*(j<n))%p;
			if(j)
			{
				g[i][j-1]=(g[i][j-1]+g[i-1][j]*(j>=1))%p;
				g[i][j]=(g[i][j]+g[i-1][j]*(j>=1))%p;
				f[i][j-1]=(f[i][j-1]+f[i-1][j]*(j>=2))%p;
				f[i][j]=(f[i][j]+f[i-1][j]*(j>=2))%p;
				g[i][j-1]=(g[i][j-1]+f[i-1][j]*(j==1))%p;
				g[i][j]=(g[i][j]+f[i-1][j]*(j==1))%p;
			}
		}
	}
	for(int i=0;i<=n;++i) ans=(ans+g[m][i])%p;
	printf("%d",ans);
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n,k; cin >> n >> k;
  string s; cin >> s;
  int cnt = 1; //グループの数
  rep(i,n-1){
    if(s[i] != s[i+1])cnt++;
  }

  rep(i,k){
    cnt -= 2;
    cnt = max(cnt,1);
  }
  out(n-cnt);
}

Measured memory_bytes: 512
n, m, c =map(int, input().split())
b = [int(x) for x in input().split()]
a = [[int (x) for x in input().split()] for _ in range(n)]

ans = 0
for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += a[i][j] * b[j]
    
    cnt += c
    
    if 0 < cnt:
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<tuple<int, int, int>> v;
    set<int> s;
    for(int i=0; i<N; i++){
        int S, T, X;
        cin >> S >> T >> X;
        v.push_back(make_tuple(S-X, 1, X));
        v.push_back(make_tuple(T-X, -1, X));
    }
    sort(v.begin(), v.end());
    vector<int> D(Q);
    for(int i=0; i<Q; i++)
        cin >> D[i];

    int cur = 0;
    for(int i=0; i<Q; i++){
        while(cur < v.size() && get<0>(v[cur]) <= D[i]){
            if(get<1>(v[cur]) == 1)
                s.insert(get<2>(v[cur]));
            else
                s.erase(get<2>(v[cur]));
            cur++;
        }
        if(s.empty())
            cout << -1 << endl;
        else
            cout << *s.begin() << endl;
    }
    return 0;
}

Measured memory_bytes: 16236
n = int(input())
C = list(input())
l, r, c = 0, n-1, 0
while l < r:
    if C[l] != 'W' and C[r] != 'R': l += 1; r -= 1; continue
    if C[l] != 'W': l += 1; continue
    if C[r] != 'R': r -= 1; continue
    l += 1
    r -= 1
    c += 1
print(c)


Measured memory_bytes: 10732
x=[]
y=[]
result=[]
num=input().split(' ')
for i in range(0,int(num[0]),1):
    num1=input().split(' ')
    x.append(num1)
for j in range(0,int(num[1]),1):
    num2=input().split(' ')    
    y.append(num2)
for k in range(0,int(num[0]),1):
    a=[]
    for j in range(0,int(num[2]),1):
        a.append(0)
    result.append(a)    
for i in range(len(x)):  
   for j in range(len(y[0])):  
       for k in range(len(y)):  
            result[i][j] +=int(x[i][k]) * int(y[k][j])
for r in range(0,int(num[0]),1):
    for j in range(0,int(num[2]),1):
        if j==int(num[2])-1:
            print(result[r][j])
        else:    
           print(result[r][j],end=" ")
    if r==int(num[0])-1:
        break
    


Measured memory_bytes: 7548
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	long long x,y;
	cin>>x>>y;
	int ans=0;
	for (long long a=x;a<=y;a*=2){
		ans++;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = sorted([''.join(sorted(input())) for _ in range(N)])
chk = {}
for i in range(N):
    if s[i] in chk:
        chk[s[i]] += 1
    else:
        chk[s[i]] = 1
print(sum([v*(v-1)//2 for k, v in chk.items()]))

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

int main(){
    int n=0,m=0,p=0,Asum=0,Nsum=0;
    string s;
    map<int,int>  res;
    set<int>      solved;
    cin >> n>>m ;
    while(m--){
        cin >> p >> s;
        if(s == "WA"){
            res[p]++;
        }else if(solved.count(p) == 0){
                // First AC
                solved.insert(p);
                Nsum+=res[p];
        }
    }

    cout << solved.size() << " " << Nsum<< endl;
    return 0;
}


Measured memory_bytes: 9600
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
int mod(int a,int b){ 
	return (a%b+b)%b; 
}
int f(int m,int D){ 
	int last=D/10; 
	int ct=0; 
	for(int j=2;j<last;j++){ 
	       for(int i=2;i<10;i++){ 
		       if((i*j)==m){ 
			       ct++;
		       } 
	       } 
	} 
	if(last>=2){ 
	       for(int j=2;j<=(D%10);j++){ 
	       		if((last*j)==m){ 
		 		ct++; 
			}		
	       } 
	}
	       			       
	return ct; 
}	

int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int M,D; 
	cin>>M>>D; 
	int ct=0; 
	for(int i=1;i<=M;i++){ 
		ct+=f(i,D); 
	} 
	cout<<ct<<endl; 


	
	return 0;
} 



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

int main() {
int N,L;
cin>>N>>L;
vector  <string> a(N);
for(int i=0;i<N;i++){
cin>>a.at(i);
}
sort(a.begin(),a.end());
for(int i=0;i<N;i++){
cout <<a.at(i);
}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(int n, vector<pair<int, int> >& xy, vector<pair<int, int> >& xz, vector<pair<int, int> >& yz)
{
    int ret = (xy.size() + xz.size() + yz.size()) * n;

    vector<vector<int> > cross(n, vector<int>(n, 0));
    for(unsigned i=0; i<xz.size(); ++i){
        for(unsigned j=0; j<xy.size(); ++j){
            if(xz[i].first == xy[j].first){
                -- ret;
                ++ cross[xy[j].second][xz[i].second];
            }
        }
    }

    for(unsigned i=0; i<yz.size(); ++i){
        for(unsigned j=0; j<xy.size(); ++j){
            if(yz[i].first == xy[j].second)
                -- ret;
        }
        for(unsigned j=0; j<xz.size(); ++j){
            if(yz[i].second == xz[j].second)
                -- ret;
        }
        ret += cross[yz[i].first][yz[i].second];
    }

    return n * n * n - ret;
}

int main()
{
    for(;;){
        int n, h;
        cin >> n >> h;
        if(n == 0)
            return 0;

        vector<pair<int, int> > xy, xz, yz;
        for(int i=0; i<h; ++i){
            string s;
            int a, b;
            cin >> s >> a >> b;
            -- a;
            -- b;
            if(s == "xy")
                xy.push_back(make_pair(a, b));
            else if(s == "xz")
                xz.push_back(make_pair(a, b));
            else
                yz.push_back(make_pair(a, b));
        }
        cout << solve(n, xy, xz, yz) << endl;
    }
}

Measured memory_bytes: 0
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

/*全てのライブラリをインクルード*/
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n;
    cin >> n;
    ll x;
    ll y;
    cin>>x>>y;
    rep(i,n-1)
    {
        ll t,a;
        cin>>t>>a;
        ll c = max((x+t-1)/t,(y+a-1)/a);
        x = t * c;
        y = a * c;
    }
    cout << x + y << endl;
    return 0;
}

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

int main()
{
  int N; cin >> N;
  vector<bitset<10>> F(N);
  for (int i = 0; i < N; ++i) {
    string tmp = "";
    for (int j = 0; j < 10; ++j) {
      string f; cin >> f;
      tmp += f;
    }
    F[i] = bitset<10>(tmp);
  }

  vector<vector<ll>> P(N, vector<ll>(11));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 11; ++j) {
      cin >> P[i][j];
    }
  }

  ll ans = -1e9;
  for (int j = 1; j < (1<<10); ++j) {
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
      bitset<10> tmp = bitset<10>(j) & F[i];
      sum += P[i][tmp.count()];
    }

    ans = max(ans, sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 1; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;

ll e_gcd(ll a, ll b) {
  if(a < b) return e_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll n;
    ll sum=0;
    cin>>n;
    

    rep(i,n+1){
        rep(j,n+1){
            rep(k,n+1){
                sum+=e_gcd(e_gcd(i,j),k);
            }
        }
    }
cout<<sum;
} 


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec t(n);
  ll ti=0;
  for(ll i=0;i<n;i++) {
    cin >> t[i];
    ti+=t[i];
  }
  ll m;
  cin >> m;
  vec p(m),x(m);
  for(ll i=0;i<m;i++) cin >> p[i] >> x[i];
  for(ll i=0;i<m;i++) {
    cout << ti-t[p[i]-1]+x[i] << endl;
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	//static int mod = 1000000007;

    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] v = new int[n];
        int[] w = new int[n];
        
        for(int i=0;i<n;i++){
        	v[i] = sc.nextInt();
        	w[i] = sc.nextInt();
        }

        System.out.println(knapsack(w,v,m));
    }

	static int knapsack(int[] weight, int[] value, int capacity){
		int n = weight.length;
		int[][] dp = new int[2][capacity+1]; //dp[i+1][w]が品物0から品物iまでを用いた重さ制限wの問題の解
		
		//%2は配列再利用
		for(int i=0;i<n;i++){
			for(int w=1;w<=capacity;w++){
				if(w>=weight[i]){
					dp[(i+1)%2][w] = Math.max(dp[i%2][w-weight[i]]+value[i],dp[i%2][w]);
				}
				else{
					dp[(i+1)%2][w] = dp[i%2][w];
				}
			}
		}
		
		return dp[n%2][capacity];
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 25372
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

/*
型を使いたいように合わせる！！！！！！！！！！！！！！！！！！！！！！！！！！！！
*/
bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //turn a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<pair<ll,ll>> p(n);
    rep(i,n)   {
        cin>>a>>b;
        p[i]=make_pair(a+b,a-b);
    }
    sort(all(p),comp);
    rep(i,n){
      //  cout<<p[i].first<<" "<<p[i].second<<endl;
    }
    ll left=-INF;
    rep(i,n){
        if(left>p[i].second) {
            sum++;
        }else{
            left=p[i].first;
        }
    }
    cout<<n-sum<<endl;

    return 0;
}

Measured memory_bytes: 4756
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <int> Vl;
int in[2050];
int main() {
	int N, K, Q, i, j, k;
	scanf("%d %d %d", &N, &K, &Q);
	for (i = 1; i <= N; i++) {
		scanf("%d", &in[i]);
		Vl.push_back(in[i]);
	}
	sort(all(Vl));
	Vl.erase(unique(all(Vl)), Vl.end());

	int ans = INF;
	for (i = 0; i < Vl.size(); i++) {
		int st = i, en = (int)Vl.size() - 1, mi, rv = Vl.size();
		while (st <= en) {
			mi = (st + en) / 2;

			int mn = Vl[i], mx = Vl[mi];
			int p = 1;
			int cnt = 0;
			for (j = 1; j <= N; j++) {
				if (in[j] < mn) {
					p = j + 1;
					continue;
				}
				if (j == N || in[j + 1] < mn) {
					int c1 = 0, c2 = 0;
					for (k = p; k <= j; k++) {
						c1++;
						if (in[k] <= mx) c2++;
					}
					int cc = min(c1 - K + 1, c2);
					if (cc >= 0) cnt += cc;

					p = j + 1;
				}
			}
			if (cnt >= Q) {
				rv = mi;
				en = mi - 1;
			}
			else st = mi + 1;
		}
		if (rv != Vl.size()) ans = min(ans, Vl[rv] - Vl[i]);
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
/*
	只关注最小的异色生成树
	那么思路就来了, 先建出最小生成树
	设最 MST 的权值为 c
	1. c > x : 显然无解
	2. c = x : 边都随意啦, 要注意的是边都同色的情况要考虑换上其他的边 
	3. c < x : 最小生成树上的边必须全部都同色, 然后看换上其他边行不行 
*/
#include <bits/stdc++.h>
#define N 1005
#define M 2005

using namespace std;

const int mod = 1e9 + 7;

int n, m;
long long lim;
int val[N], fa[N], dep[N];
int head[N], nex[N << 1], to[N << 1], eVal[N << 1], cntE;

struct edge {
	int u, v, w;
}e[M];
bool cmpEdge(const edge &lhs, const edge &rhs) {
	return lhs.w < rhs.w;
}

namespace UFS {
	int fa[N];
	inline void init() { for(int i = 1; i <= n; ++i) fa[i] = i; }
	inline int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }
}

inline int fpm(int x, int y) {
	int re = 1;
	while(y) {
		if(y & 1) re = 1LL * re * x % mod;
		x = 1LL * x * x % mod, y >>= 1;
	}
	return re;
}
inline void addE(int u, int v, int w) {
	to[++cntE] = v, eVal[cntE] = w;
	nex[cntE] = head[u], head[u] = cntE;
}

void dfs(int u) {
	dep[u] = dep[fa[u]] + 1;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(v == fa[u]) continue;
		val[v] = eVal[i], fa[v] = u;
		dfs(v);
	}
}
inline int getMax(int u, int v) {
	int mVal = 0;
	if(dep[u] < dep[v]) swap(u, v);
	while(dep[u] > dep[v]) {
		mVal = max(mVal, val[u]);
		u = fa[u];
	}
	while(u != v) {
		mVal = max(mVal, val[u]);
		mVal = max(mVal, val[v]);
		u = fa[u];
		v = fa[v];
	}
	return mVal;
}

int main() {
	scanf("%d %d %lld", &n, &m, &lim);
	for(int i = 1, u, v, w; i <= m; ++i) {
		scanf("%d %d %d", &u, &v, &w);
		e[i] = (edge){u, v, w};
	}
	
	long long c = 0;
	sort(e + 1, e + m + 1, cmpEdge);
	UFS::init();
	for(int i = 1, u, v; i <= m; ++i) {
		u = UFS::find(e[i].u), v = UFS::find(e[i].v);
		if(u == v) continue;
		UFS::fa[u] = v;
		addE(e[i].u, e[i].v, e[i].w);
		addE(e[i].v, e[i].u, e[i].w);
		c += e[i].w;
	}
	
	if(c > lim) {
		puts("0");
		return 0;
	}
	
	dfs(1);
	
	int lower(0), equal(0), upper(0);
	for(int i = 1; i <= m; ++i) {
		long long tmp = c - getMax(e[i].u, e[i].v) + e[i].w;
		if(tmp < lim) {
			++lower;
		} else if(tmp == lim) {
			++equal;
		} else if(tmp > lim) {
			++upper;
		}
	}
	
	int ans = 0;
	if(c == lim) {
		ans = (fpm(2, n - 1) + mod - 2LL) * fpm(2, m - (n - 1)) % mod;
		ans = (ans + 2LL * 
		(fpm(2, equal - (n - 1)) - 1) * fpm(2, upper)) % mod;
	} else {
		ans = 2LL * (fpm(2, equal) - 1) * fpm(2, upper) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  int count=0;
  for(int i=0;i<N;i++){
    cin>>h[i];
    if(h[i]>=K) count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	char s[12];
	scanf("%s", &s);

	if (s[a] != '-') {printf("No"); return 0;}
	for (int i = 0; i < a + b; i++) {
		if (i != a && s[i] == '-') {printf("No"); return 0;}
	}

	printf("Yes");

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  F0R(i, M) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    G[s].push_back(t);
  }

  double result = N;
  vector<double> ds(N);
  ds.back() = 0.0;

  RF0(j, N-1) { // 通路を塞ぐ部屋

    RF0(i, N - 1) {
      double sum = 0, high = 0;
      for (auto c : G[i]) {
        double d = ds[c] + 1.0;
        sum += d;
        chmax(high, d);
      }
      if (i == j && G[i].size() > 1) {
        ds[i] = (sum - high) / (G[i].size() - 1);
      }
      else {
        ds[i] = sum / G[i].size();
      }
    }

    chmin(result, ds[0]);
  }

  cout << std::fixed << std::setprecision(15);
  cout << result;
}
#endif


Measured memory_bytes: 1408
program main
  implicit none

  integer :: n, a(100000), i,j

  read(*,*)n
  read(*,*)(a(i), i = 1, n)
  
  do i = 1, n - 1
    if ((a(i) - a(i+1)) > 0) then
      do j = i+1, n
        if ((a(i) - a(j)) >= 2) then
          write(*,*)"No"
          stop
        end if
      end do
    end if
  end do 
  write(*,*)"Yes"

end program main

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

int main() {
  int N, A, B, C, D;

  std::cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;

  std::vector<bool> rocks(N);

  for (int i=0; i<N; i++) {
    char c;
    std::cin >> c;
    rocks[i] = c == '#';
  }

  for (int i=A+1; i<std::max(C, D); i++) {
    if (rocks[i-1] && rocks[i]) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  bool ans = false;

  if (C < D) {
    // C < D なら追い抜きはいらない
    ans = true;
  } else {
    // D < C なら A はとちゅうで B を追い抜くスペースがいる
    int avail = 0;
    for (int i=B-1; i<D+2; i++) {
      if (rocks[i]) {
        avail = 0;
      } else {
        avail++;
        if (avail > 2) {
          ans = true;
          break;
        }
      }
    }
  }

  std::cout << (ans?"Yes":"No") << std::endl;

  return 0;
}


Measured memory_bytes: 256