akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1e9+7;
 
int main(){
    int h,w;cin>>h>>w;
    int alp[26]={};
    rep(i,h){
        string s;cin>>s;
        rep(j,w){
            int tmp=s[j]-'a';
            alp[tmp]++;
        }
    }
    bool flag=0;
    if(h%2&&w%2){
        int four=0;
        int one=0;
        rep(i,26){
            four+=alp[i]/4;
            if(alp[i]%2)one++;
        }
        if(four>=(h*w-h-w+1)/4&&one==1)flag=1;
    }
    else if(!(h%2)&&!(w%2)){
        int four=0;
        int one=0;
        rep(i,26){
            four+=alp[i]/4;
            if(alp[i]%2)one++;
        }
        if(four>=h*w/4&&one==0)flag=1;
    }
    else{
        if(w%2)swap(h,w);
        int four=0;
        int one=0;
        rep(i,26){
            four+=alp[i]/4;
            if(alp[i]%2)one++;
        }
        if(four>=(h-1)*w/4&&one==0)flag=1;
    }
    cout<<(flag?"Yes":"No")<<endl;
}


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

const int MAX_N=110;

int s_sort(const int N,int A[]){
    int cnt_swap=0;
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[minj]>A[j]) minj=j;         
        }
        if(minj!=i){
            std::swap(A[i],A[minj]);
            cnt_swap++;
        }
    }
    return cnt_swap;
}

int main(void){
    int N;
    int A[MAX_N];
    std::cin>>N;
    for(int i=0;i<N;i++)
        std::cin>>A[i];
    int cnt_swap=s_sort(N,A);
    for(int i=0;i<N;i++){
        if(i) std::cout<<" ";
        std::cout<<A[i];
    }
    std::cout<<std::endl<<cnt_swap<<std::endl;
    return 0;
}


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

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const arr = n.split('\n');
    for(var i=0; i < arr.length; i++){
        if(arr[i]!=0){
            console.log(`Case ${i+1}: ${arr[i]}`);
        }
    }
})


Measured memory_bytes: 22600
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<typename E>
struct SeqSearchTable {
	vector<E> v;
	vector<UL> t;
	SeqSearchTable(vector<E> seq) { init(move(seq)); }
	void init(vector<E> seq) {
		v = move(seq);
		t.resize(v.size());
		t[0] = (UL)-1;
		UL p = 1, q = -1;
		while (p < v.size()) {
			if (q == (UL)-1) { t[p] = 0; p++; q = 0; }
			else if (v[q] == v[p - 1]) { t[p] = t[p - 1] + 1; p++; q++; }
			else { q = t[q]; }
		}
	}
};
template<typename E>
struct SeqSearch {
	vector<UL> query(const vector<E> &seq, const SeqSearchTable<E> &tg) {
		vector<UL> f;
		UL p = 0, q = 0;
		while (p < seq.size()) {
			if (seq[p] == tg.v[q]) {
				p++; q++;
				if (q == tg.v.size()) {
					f.push_back(p - tg.v.size());
					q = tg.t[q - 1] + 1;
				}
			}
			else {
				q = tg.t[q];
				if (q == (UL)-1) { p++; q = 0; }
			}
		}
		return move(f);
	}
};

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N), B(N);
		rep(i, N) cin >> A[i];
		rep(i, N) cin >> B[i];
		vector<UL> Ap, Bp;
		rep(i, N) {
			if (i == 0) {
				Ap.push_back(A[N - 1] ^ A[0]);
				Bp.push_back(B[N - 1] ^ B[0]);
			}
			else {
				Ap.push_back(A[i] ^ A[i - 1]);
				Bp.push_back(B[i] ^ B[i - 1]);
			}
		}
		rep(i, N - 1) Ap.push_back(Ap[i]);
		vector<UL> f = move(SeqSearch<UL>().query(Ap, SeqSearchTable<UL>(Bp)));
		for (UL i : f) {
			cout << i << " " << (A[i] ^ B[0]) << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

    int ans = 0;

    for (int i = 0; i < n-1; ++i) {
        if (p[i] == i+1) {
            swap(p[i], p[i+1]);
            ++ans;
        }
    }

    if (p[n-1] == n) {
        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int K;
	cin >> K;
	int flower[K+1];

	for(int i=0; i<K; i++)
		cin >> flower[i];

	flower[K]=0;

	int count=0;
	int chk=-1;

	while(count!=chk){
		chk=count;
		int l=0;
		int r=0;
		for(int i=0; i<K+1; i++){
			if(flower[i]>0) continue;
			if(flower[i]==0){
				r=i;
				if(l!=r){
					for(int j=l; j<r; j++)
						flower[j] = flower[j]-1;
					count++;
				}
				l=i+1;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using  unll = unsigned long long ;

int main() {
  int h,a;
  cin >> h >> a;
  int cnt=0;
  while( h > 0 ){
    h -= a;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  int a,b;
  cin >>a >>b;

  vec<int> x(5);
  int ans=0;
  for(int i=a;i<=b;i++){
    int r = i;
    for(int j=0;j<5;j++){
      x[j] = r%10;
      r /= 10;
    }
    if(x[0] == x[4] && x[1] == x[3]) ++ans;
  }

  cout <<ans <<endl;
}


Measured memory_bytes: 256
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

H,N = nums()
A = nums()
print("Yes" if sum(A)>=H else "No")

Measured memory_bytes: 78660
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	string s, t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
		cout << "YES";
	else
		cout << "NO";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s;
    cin >> s;
    cout << "0 0 ";
    ll z = (int) sqrt(s);
    if(z * z < s) z += 1;
    ll x2 = z, y3 = z;
    ll x3 = 1, y2 = (z) * (z) - s;
    cout << x2 << " " << y2 << " " << x3 << " " << y3;
    return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> K;
    N = 50;
    cout << N << endl;
    A.resize(N,N-1+K/N-K%N);
    for(int i=0;i<K%N;i++) {
        A[i] += N+1;
        //cout << " " << A[i] << endl;
    }
    for(int i=0;i<N;i++) {
        cout << " " << A[i];
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
if n%2==1:
    print(0)
else:
    for i in range(1,n):
        if n>=2*(5**i):
            cnt += n//(2*(5**i))
        else:
            break
    print(cnt)

Measured memory_bytes: 10472
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    d = 0
    for k in range(D):
      d += (X[i][k] - X[j][k]) ** 2
    if int(math.sqrt(d)) ** 2 == d:
      ans += 1
print(ans)

Measured memory_bytes: 9120
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N, K;
    cin >> N >> K;
    set<char> dis;
    for (int i = 0; i < K; i++) {
        char c;
        cin >> c;
        dis.insert(c);
    }
    int ans = N;
    auto is_ok = [&] (int N) {
        for (auto c : to_string(N)) {
            if (dis.count(c)) return false;
        }
        return true;
    };
        
    while (true) {
        if (is_ok(ans)) break;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll l, r;
        cin >> l >> r;
        l += 1LL << 33, r += 1LL << 33;
        int ans = 0;
        for (int j = 0; j < 33 && l < r; ++j) {
            if(l&(1LL << j)) ans++, l += 1LL << j;
            if(r&(1LL << j)) ans++, r -= 1LL << j;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3080
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vector < vector < int >  > fact(1000001);
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                fact[j].pb(i);
            }
        }
    }
}
*/

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}


ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}

int arr[100005];

void solve(){
    int n,temp;in(n);
    ll sum = 0 , old ;
    f(i,n){
        in(temp);
        sum += temp;
        arr[temp]++;
    }
    old = sum;
    int q;
    in(q);
    while(q--){
        int a,b;
        in(a)>>b;
        if(arr[a] == 0){
            cout<<sum<<el;
            continue;
        }
        int val = arr[a]*(b-a);
        cout<< sum + val  <<el;
        sum += val;
        arr[b] += arr[a] ;arr[a] = 0;
    }
}
int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3884
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

char s[N];
int v[26];
int main(){
    int i,j,k,n,m;
    scanf("%s",s);
    n=strlen(s);
    rep(i,0,n){
        j=s[i]-'a';
        v[j]++;
    }
    ll ans=1LL*n*(n-1)/2+1;
    rep(i,0,26)if(v[i]){
        ans-=1LL*v[i]*(v[i]-1)/2;
    }
    printf("%lld\n",ans);
    return 0;
}




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

typedef pair<int, int> P;

string Plus(int x, int y){
  int a = x - y;
  int b = x + y;
  ostringstream oss1, oss2;
  oss1 << a;
  oss2 << b;
  string ret = oss1.str() + oss2.str();
  for(int i = 0 ; i < ret.size() ; i++){
    if(ret[i] != '0') break;
    else ret.erase(ret.begin()+i);
  }
  return ret;
}

int toInt(string s){
  istringstream iss(s);
  int ret;
  iss >> ret;
  return ret;
}

int main(){
  string a;
  cin >> a;
  vector<P> v;
  for(int i = 0 ; i < a.size()-1 ; i++){
    string s1 = a.substr(0, i+1);
    string s2 = a.substr(i+1);
    v.push_back(P(toInt(s1), toInt(s2)));
  }
  
  int ans = 0;
  
  for(int i = 0 ; i < v.size() ; i++){
    int t1 = (v[i].first + v[i].second) / 2;
    int t2 = v[i].second - t1;
    if(t1 < 0 || t2 < 0) continue;
    if(Plus(t1, t2) == a) ans++;
  }
  if(toInt(a) % 2 == 0) ans++;
  
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N, M;  //N個の店舗(値段と購入制限をのちに持たせる), M個のドリンクが欲しい
  cin >> N >> M;
  vector<int> A(N), B(N);  //Aは値段のみを格納, Bは購入制限のみを格納
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }

  //AとBをソートする
  //pair<int, int>は int2つの方
  vector<pair<int, int> > AB(N);
  for (int i = 0; i < N; i++){
    AB[i] = make_pair(A[i], B[i]);  //店の値段と購入制限をセットで管理
  }
  sort(AB.begin(), AB.end());  //デフォルトで最初の要素でソートするようになってる

  long long ans = 0;
  for (int i = 0; i < N; i++){
    //このお店で購入する数を決める
    int buy_amount = min(M, AB[i].second);  //残りの欲しい本数or購入制限分を購入する
    //欲しい本数揃っていればbuy_amountはそれ以降はずっと0

    //買った金額を加算する
    ans += (long long)buy_amount * AB[i].first;  //買った本数*値段
    //残り本数を減らす
    M -= buy_amount;  //欲しい本数を減らす
  }

  cout << ans << endl;

}

// """
// 補足：class Shopなどを定義すると賢くなる
// """


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>
using namespace std;

typedef pair<long, long> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

int N,M;
long A[100010], B[100010];


// void q_sort(long A[], long B[] int left, int right)
// {
//     int pivot, l_hold, r_hold;
//
//     l_hold = left;
//     r_hold = right;
//     pivot = A[left];
//     while (left < right)
//     {
//         while ((A[right] >= pivot) && (left < right))
//             right--;
//         if (left != right)
//         {
//           A[left] = A[right];
//           B[left] = B[right];
//
//             left++;
//         }
//         while ((A[left] <= pivot) && (left < right))
//             left++;
//         if (left != right)
//         {
//           A[right] = A[left];
//           B[right] = B[left];
//             right--;
//         }
//     }
//     A[left] = pivot;
//     pivot = left;
//     left = l_hold;
//     right = r_hold;
//     if (left < pivot)
//         q_sort(A, B, left, pivot-1);
//     if (right > pivot)
//         q_sort(A, B, pivot+1, right);
// }


int main() {


  cin >> N >> M ;
  int a,b;
  vector<P> v;
  for(int i=0;i<N;i++){
    cin >> a >> b;
    v.push_back(P(a,b));
  }


  sort(v.begin(), v.end(), pairCompare);
  // q_sort(A,B);
  // int tempa, tempb;
  // for(int i=0;i<N-1;i++){
  //   for(int j=N-1;j>i;j--){
  //     if(A[j-1]>A[j]){
  //       tempa = A[j-1];
  //       A[j-1] = A[j];
  //       A[j] = tempa;
  //       tempb = B[j-1];
  //       B[j-1] = B[j];
  //       B[j] = tempb;
  //     }
  //   }
  // }


  long long ans = 0;
  long long count = 0;

  int i;
  for(i=0;i<N;i++){
    ans += v[i].first*v[i].second;
    count += v[i].second;
    if(count > M){
      break;
    }
  }


  ans = ans - (count-M)*v[i].first;









  cout << ans << endl;
}


Measured memory_bytes: 2420
package main

import (
	"fmt"
	//"sort"
	//"strconv"
	//"strings"
	"bufio"
	"os"
	"strconv"
	//"math"
)

func main() {
	//input
	var n,k int
	fmt.Scan(&n,&k)

	var h []int

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		h = append(h,a)
	}

	//
	count := 0
	for i:=0;i<n;i++{
		if h[i] >= k{
			count++
		}
	}
	fmt.Print(count)
}

Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7;
const int larg = 1e5;

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

int main() {
	int H, W, white_point = 0;
	cin >> H >> W;
	char map[51][51];
	int count[51][51];
	rep(i, H){
		rep(j, W){
			cin >> map[i][j];
			count[i][j] = -1;
			if(map[i][j] == '.') white_point++; 
		}
	}
	int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
	queue<P> que;
	que.push(P(0,0));
	count[0][0] = 1;
	while(!que.empty()){
		P p = que.front(); que.pop();
		int x = p.first, y = p.second;
		rep(i, 4){
			int nx = x+dx[i], ny = y+dy[i];
			if(-1 < ny && ny < H && -1 < nx && nx < W && map[ny][nx] != '#' && count[ny][nx] == -1) {
				que.push(P(nx,ny));
				count[ny][nx] = count[y][x]+1;
			}
		}
	}
	if(count[H-1][W-1] == -1) cout << -1;
	else cout << white_point-count[H-1][W-1];
}

Measured memory_bytes: 256
/**
 *      purpose : CODE FESTIVAL 2017 Final A
 *      author  : kyomukyomupurin
 *      created : 2018-10-31 19:44:09
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S; cin >> S;
    if ((int) S.size() > 9){
        print("NO"); return 0;
    }

    if ((int) S.size() == 9){
        if (S == "AKIHABARA") print("YES");
        else print("NO");
    }
    else if ((int) S.size() == 8){
        if (S == "KIHABARA" || S == "AKIHBARA" || S == "AKIHABRA" || S == "AKIHABAR") print("YES");
        else print("NO");
    }
    else if ((int) S.size() == 7){
        if (S == "KIHBARA" || S == "KIHABRA" || S == "KIHABAR" || S == "AKIHBRA" || S == "AKIHBAR" || S == "AKIHABR") print("YES");
        else print("NO");
    }
    else if ((int) S.size() == 6){
        if (S == "AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA") print("YES");
        else print("NO");
    }
    else if ((int) S.size() == 5){
        if (S == "KIHBR") print("YES");
        else print("NO");
    }
    else print("NO");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX (int)1e5

using namespace std;

int main(void){
  int N,K;
  cin >> N >> K;
  char v[MAX];
  int LR=0;
  int RL=0;
  for(int i=0;i<N;i++){
    char c;
    cin >> c;
    v[i] = c;
  }
  // lrとrlの個数を数える
  char form = v[0];
  for(int i=1;i<N;i++){
    if(form == 'R' && v[i] == 'L'){
      RL++;
    }
    form = v[i];
  }
  int edge = 0;
  if(v[0] == 'L')
    edge++;
  if(v[N-1] == 'R')
    edge++;
  // 現在のスコアを数える
  int score = 0;
  form = v[0];
  for(int i=1;i<N;i++){
    if(form == 'R' && v[i] == 'R')
      score++;
    form = v[i];
  }
  // ギャク向き
  form = v[N-1];
  for(int i=N-2;0<=i;i--){
    if(form == 'L' && v[i] == 'L')
      score++;
    form = v[i];
  }
  if(RL <= 1 && edge == 0){
    cout << score+1 << endl;
    return 0;
  }
  if(RL > K){
    score = score + 2*K;
    cout << score << endl;
    return 0;
  }
  


  // RL <= KならまずRL回だけ2倍し edgeが非ゼロならまわす
  score = score + 2*RL;
  if(edge == 2 && RL + 1 <= K)
    score =score + 1;
  cout << score << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n >> k;
  int r=1;
  
  for (int i=0; i<n ;i++){
    r=min(r*2,r+k);
  }
  cout << r << endl;
  
}
      
        


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long i,n,m,s;
int main()
{
    cin>>n;
    for (i=1;i<=n;i++) cin>>s,m+=s;
    if (m%2)cout<<"NO"<<endl;else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())

ans=0
for i in range(n):
    if b[i]>a[i]:
        ans+=a[i]
        ans+=a[i+1]-max(0,a[i+1]-(b[i]-a[i]))
        a[i+1]=max(0,a[i+1]-(b[i]-a[i]))
    else:
        ans+=b[i]
print(ans)


Measured memory_bytes: 19116
#include <iostream>

using namespace std;

int main(void){
    int times[4];
	for (int i = 0; i < 4; i++) {
		cin >> times[i];
	}

	int totalTime = 0;
	for (int i = 0; i < 4; i++) {
		totalTime += times[i];
	}
	int totalM = 0, totalS = 0;
	totalM = totalTime / 60;
	totalS = totalTime % 60;

	cout << totalM << endl;
	cout << totalS << endl;
}

Measured memory_bytes: 1160
from collections import defaultdict
N,K = map(int,input().split())
K = bin(K)[2:]
A = list(map(lambda x:bin(int(x))[2:],input().split()))
count = defaultdict(lambda:0)
for i in range(N):
    for j in range(len(A[i])):
        if A[i][-j-1] == '1':
            count[j] += 1
def rec(x):
    if x=='':
        return 0
    if '0' not in x:
        res = 0
        for i in range(len(x)):
            res += max(count[i],N-count[i])*2**i
        return res
    if x[0] == '1':
        return max(rec('1'*(len(x)-1))+count[len(x)-1]*2**(len(x)-1),rec(x[1:])+(N-count[len(x)-1])*2**(len(x)-1))
    else:
        return rec(x[1:])+count[len(x)-1]*2**(len(x)-1)
ans = rec(K)
for i in range(len(K),41):
    ans += count[i]*2**i
print(ans)

Measured memory_bytes: 90216
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    ll N;
    cin >> N;
    VLL l(N), r(N);
    ll res = 0;
    REP(i, N){
        cin >> l[i] >> r[i];
        res += r[i] - l[i] + 1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int a, b;
  cin >> a >> b;
  if (a<=8 && b<= 8) {
    cout << "Yay!" <<endl;
  }
  else {
    cout << ":(" <<endl;
  }
} 


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

using namespace std;

using ll = long long;

int main(){
    ll n,T;cin>>n>>T;
    ll ans=0;
    ll start=0,end=T;
    for(int i=0;i<n;++i){
        ll t;
        cin>>t;
        if(i==0)continue;
        if(end>=t)end=t+T;
        else{
            ans+=end-start;
            start=t;end=t+T;
        }
    }
    ans+=end-start;
    cout<<ans<<endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	vector<int> sp(N);
	rep(i, N){
		cin >> p[i];
		sp[i] = p[i];
	}
	sort(sp.begin(), sp.end());
	int count = 0;
	rep(i, N){
		if(p[i] != sp[i]){
			count++;
		}
	}
	if(count <= 2){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    int d,x,y;
    cin>>d;
    
    cin>>x;
    char a[20];
    int p[20];
    rep(i,x)cin>>a[i]>>p[i];
    
    cin>>y;
    string bc[20];
    int q[20];
    rep(i,y)cin>>bc[i]>>q[i];

    
    int dp[50][50]={};
    rep(i,x){
        rep(j,d){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(a[i]=='D' && j+1<=d)
                dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+p[i]);
        }
    }
    for(int i=0;i<y;i++){
        rep(j,d){
            dp[x+i+1][j]=max(dp[x+i+1][j],dp[x+i][j]);
            if(bc[i]=="DD" && j+2<=d)
                dp[x+i+1][j+2]=max(dp[x+i+2][j+1],dp[x+i][j]+q[i]);
        }
    }
    
    int maxi=0;
    rep(i,20){
        rep(j,20){
            maxi=max(dp[i][j],maxi);
        }
    }
    cout<<maxi<<endl;
    
    return 0;
}

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

// Aにkeyがあるなら1，ないなら0を返す
int search(int A[],int n,int key){
  A[n] = key;
  for(int i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    }
  }
  return 0;
  /*
  while(A[i]!=key){
    i++;
  }
  return i!=n;
  */
}

int main(){
  int n,q;
  scanf("%d",&n);
  int S[n+1];
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int t;
  int sum=0;
  for(int i=0;i<q;i++){
    scanf("%d",&t);
    if(search(S,n,t)){
      sum++;
    }
  }
  printf("%d\n",sum);

}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 5e5 + 7;
int n, q;
int len[N];
int mn[N << 2];
void build(int v, int tl, int tr) {
    if (tl == tr) {
        mn[v] = len[tl];
        return;                        
    }   
    int tm = (tl + tr) >> 1;
    build(v * 2 + 1, tl, tm);
    build(v * 2 + 2, tm + 1, tr);
    mn[v] = min(mn[v * 2 + 1], mn[v * 2 + 2]);
}   
int getr(int v, int tl, int tr, int i, int x) {
    if (tl > i || mn[v] > x)
        return -1;
    if (tl == tr)
        return tl;
    int tm = (tl + tr) >> 1;
    int t = getr(v * 2 + 2, tm + 1, tr, i, x);
    if (t != -1)
        return t;
    else
        return getr(v * 2 + 1, tl, tm, i, x);        
}   

struct Edge {
    int v, x, y, f;
};  

vector <Edge> g[N];
vector <ii> rg[N];
map <ii, int> num;
int ptr = 0;
ii state[N];

void add_edge(int u, int v, int x, int y, int f) {
    g[u].app({v, x, y, f});
    rg[v].app(mp(u, f));
}
void gen(int i, int pref) {
    if (pref == 0)
        return;
    if (num.find(mp(i, pref)) != num.end())
        return;

    state[ptr] = mp(i, pref);
    int u = num[mp(i, pref)] = ptr++;

    if (i == 0)
        return;

    int j = getr(0, 0, q, i - 1, pref);
    j = max(j, 0ll);
    gen(j, len[j]);
    gen(j, pref % len[j]);

    int v1 = num[mp(j, len[j])];
    add_edge(u, v1, pref, len[j], pref/len[j]);
    int v2 = num[mp(j, pref%len[j])];
    add_edge(u, v2, pref, pref%len[j], 1);
}   
int root;
int dp[N];
bool used[N];
void dfs(int u) {
    used[u] = 1;

    if (u == root) {
        dp[u] = 1;
        return;
    }   

    dp[u] = 0;
    for (auto e : rg[u]) {
        int v = e.f, k = e.s;
        if (!used[v]) {
            dfs(v);
        }   
        dp[u] += dp[v] * k;
    }   
}   
int ans[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> q;
    len[0] = n;
    for (int i = 1; i <= q; ++i)
        cin >> len[i];
    build(0, 0, q);
    gen(q, len[q]);
    root = num[mp(q, len[q])];
    for (int i = 0; i < ptr; ++i) {
        if (!used[i]) {
            dfs(i);
        }   
    }   
    for (int i = 0; i < ptr; ++i) {
        if (state[i].f == 0) {
            ans[state[i].s] += dp[i];
        }   
    }   
    for (int i = n; i; --i) {
        ans[i] += ans[i + 1];
    }   
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << ' ';
    cout << endl;
    #ifdef HOME
    cerr << Time << endl;
    #endif
}

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

using namespace std;

const int N = 1e5 + 5;

int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> ranges;
  for (int i = 0; i < n; ++i) {
    int x, l;
    scanf("%d %d", &x, &l);
    ranges.emplace_back(x-l, x+l);
  }
  sort(ranges.begin(), ranges.end());
  int now = ranges[0].first;
  int ans = 0;
  for (auto it : ranges) {
    if (now <= it.first) {
      ++ans;
      now = it.second;
    }
    else
      now = min(now, it.second);
  }
  printf("%d\n", ans);
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > using Vec = vector< T >;

class UnionFind {
private:
	Vec< int > data;
	int num_of_g;
	
public:
	UnionFind(int n) : data(n, -1), num_of_g(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		--num_of_g;
		
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int getNumOfG() { return num_of_g; }
};

struct Edge {
	int u, v, c;
	bool operator < (const Edge& e) const { return c < e.c; }
};

int n, m;
Vec< Edge > edge;

bool check(int i, int j) {
	UnionFind uf(n);
	for_(k,i,j) uf.unionSet(edge[k].u, edge[k].v);
	return uf.getNumOfG() == 1;
}

void solve() {
	sort(edge.begin(), edge.end());
	int ans = 1L << 30, i = 0, j = 0;
	while (i < m) {
		while (j < m && !check(i, j)) ++j;
		if (check(i, j)) ans = min(ans, edge[j-1].c - edge[i].c);
		++i;
	}
	cout << (ans == 1L << 30 ? -1 : ans) << endl;
}

int main() {
	while (cin >> n >> m, n != 0) {
		edge = Vec< Edge >();
		for_(i,0,m) {
			int u, v, c;
			cin >> u >> v >> c;
			--u; --v;
			edge.push_back(Edge{u,v,c});
		}
		solve();
	}
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi a(n);
    vi b(n);
    vi c(n-1);
    cin>>a>>b>>c;
    int ans=0;
    REP(i,n){
        ans+=b[a[i]-1];
        if(i&&a[i]-a[i-1]==1){
            ans+=c[a[i-1]-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
E = 10**-10
for i in range(n):
	xa,ya,ra,xb,yb,rb = [float(i) for i in input().split()]
	x = ((xb-xa)**2 + (yb-ya)**2)**0.5
	xmax = x+rb
	xmin = x-rb
	if ra - xmax > E:
		print(2)
	elif xmin - (-ra) < -E:
		print(-2)
	elif xmin - ra > E:
		print(0)
	else:
		print(1)


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

int main(){
	int N, K, ans=0;
  	cin >> N >> K;
  	bool check[N];
  	for(int i=0; i<N; i++){
    	check[i] = false;
    }
  	for(int i=0; i<K; i++){
    	int d;
      	cin >> d;
      	for(int j=0; j<d; j++){
        	int A;
          	cin >> A;
          	check[A-1]=true;
        }
    }
  	for(int i=0; i<N; i++){
    	if(check[i]==false){
        	ans++;
        }
    }
  	cout << ans << endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

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

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define MAX_M 100'000
#define INF 1152921504606846976

using P = pair<i64, i64>;

i64 N, M, S, T;
vector<i64> G[MAX_N];
i64 d[MAX_N][3];

int main() {
    cin >> N >> M;
    i64 u, v;
    REP(i, M) {
        cin >> u >> v;
        u--; v--;
        G[u].pb(v);
    }
    cin >> S >> T;
    S--; T--;

    REP(i, N) REP(j, 3) d[i][j] = INF;
    queue<P> que;
    que.push({S, 0});
    d[S][0] = 0;
    i64 cnt = 0;
    while (!que.empty()) {
        if (++cnt > 3 * N) break;

        P p = que.front(); que.pop();
        for (i64 v : G[p.first]) {
            i64 nd = p.second + 1;
            if (d[v][nd % 3] != INF) continue;
            d[v][nd % 3] = nd;
            que.push({v, nd});
            if (v == T && d[T][0] != INF) break;
        }
    }
    if (d[T][0] == INF) {
        cout << -1 << endl;
    } else {
        cout << d[T][0] / 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 8064
import sys
n=int(input())
h=list(map(int,input().split()))
if n==2:
  print(abs(h[1]-h[0]))
  sys.exit()
c=[float('inf')]*n
c[0]=0
c[1]=abs(h[1]-h[0])
for i in range(n-2):
  c[i+2]=min(c[i]+abs(h[i+2]-h[i]),c[i+1]+abs(h[i+2]-h[i+1]))
print(c[n-1])

  
  



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

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

  int total = 0;

  for(int i=0;i<s.size()/2;i++) {
    if(s[i] == s[s.size()-1-i]) {
      continue;
    } else {
      total++;
    }
  }

  cout << total << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

int N;
std::vector<int> primes;
bool used[55560];

void sieve( int x = 55555 )
{
  used[0] = used[1] = true;

  repi( i, 2, x+1 )
  {
    if( !used[i] )
    {
      if( i%5 == 1 )
        primes.emplace_back( i );

      for( int j = i; j <= x; j += i )
        used[j] = true;
    }
  }

  return;
}

int main()
{
  scanf( "%d", &N );

  sieve();
  
  rep( i, N )
    printf( "%d%c", primes[i], i==N-1?'\n':' ' );

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000001
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<pll,ll>
#define vplll vector<plll>
#define vpll vector<pll>
using namespace std;
using namespace std::chrono; 
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);


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

    ll n,val;
    cin>>n;
    ll root=sqrt(n);
    for(ll i=root;i>=1;i--)
    {
        if(n%i==0)
        {
            val=i;
            break;
        }
    }
    ll sum=n/val;
    sum+=val;
    sum-=2;
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);

		boolean[] isPrimes=new boolean[50000];
		for(int i=2; i<isPrimes.length; i++)
			isPrimes[i]=isPrime(i);

		for(;;){
			int n=sc.nextInt();
			if(n==0)
				break;
			int ans=0;
			if(n%2==1){
				ans=isPrimes[n-2]?1:0;
			}else{
				for(int i=2; 2*i<=n; i++)
					if(isPrimes[i]&&isPrimes[n-i])
						ans++;
			}
			println(ans+"");
		}
		sc.close();
	}

	boolean isPrime(int n){
		int m=(int)sqrt(n);
		for(int i=2; i<=m; i++)
			if(n%i==0)
				return false;
		return true;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 13000
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  count = zeros(Int,N)
  a = 0
  b = 0
  
  for i in 1:M
    (a,b) = map(x -> parse(Int,x), split(readline()))
    count[a] += 1
    count[b] += 1
  end
  
  for i in 1:N
    println(count[i])
  end
  
end

main()

Measured memory_bytes: 173448
#include "bits/stdc++.h"
using namespace std;

int x[3];
set <int> s;

int main()
{
	for(int i=0;i<3;i++)
	{
		cin>>x[i];
		s.insert(x[i]);
	}

	if(s.size()==2) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
           if(i*i != n){
               ret.push_back(n/i);
           }
       }
   }
   return ret;
}

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  using P = pair<int, int>;
  int n;
  vector<int> f, primes; //f.at(x)はxの最小素因数
  Sieve(int n=1):n(n), f(n+1) {
  f[0] = f[1] = -1;
  for (ll i = 2; i <= n; ++i) {
    if (f[i]) continue; //ここでf[i]==0なら素数
    primes.push_back(i);
    f[i] = i;
    for (ll j = i*i; j <= n; j += i) {
  if (!f[j]) f[j] = i;
    }
  }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) { //xの素因数を小さい順に列挙
  vector<int> res;
  while (x != 1) {
    res.push_back(f[x]);
    x /= f[x];
  }
  return res;
  }
  vector<P> factor(int x) {
  vector<int> fl = factorList(x);
  if (fl.size() == 0) return {};
  vector<P> res(1, P(fl[0], 0));
  for (int p : fl) { //ここでランレングス圧縮
    if (res.back().first == p) {
  res.back().second++;
    } else {
  res.emplace_back(p, 1);
    }
  }
  return res;
  }
};
// Sieve sieve(N);でN以下の各自然数の最小素因数を調べ上げる
// sieve.factor(M)でMの素因数分解

int main()
{
    ll N;
    cin >> N;
    Sieve sieve(N);
    ll ans = 0;
    rep2(i, 1, N){
        vector<pair<int, int>> P = sieve.factor(N-i);
        ll c = 1;
        rep(j, sz(P)){
            c *= (P.at(j).second+1);
        }
        ans += c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7768
w, h,  x,  y = map(int, input().split())

if h % 2 == 0 and h // 2 == y and w % 2 == 0 and w // 2 == x:
    print('{:.10}'.format(h * w / 2), 1)
else:
    print('{:.10}'.format(h * w / 2), 0)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n),b(n),c(31);
  rep(i,n) cin >> a[i] >> b[i];
  vector<vector<int>> d(n,vector<int>(31));
  rep(i,31){
      c[i]=k%2;
      k/=2;
  }
  rep(i,n){
      rep(j,31){
      d[i][j]=a[i]%2;
      a[i]/=2;
      }
  }
    ll ans=0;
    for (int i=30;i>=0;i--){
        ll u=0;
        if (c[i]==0) continue;
        rep(j,n){
            bool t=true;
            for (int ii=30;ii>i;ii--){
                if (c[ii]==0 && d[j][ii]==1) t=false;
            }
            if (d[j][i]==1) t=false;
            if (t) u+=b[j];
        }
        ans=max(ans,u);
    }
    ll y=0;
    rep(i,n){
        bool t=true;
        rep(j,31){
            if (c[j]==0 && d[i][j]==1) t=false;
        }
        if (t) y+=b[i];
    }
    ans=max(ans,y);
    cout << ans << endl;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    vector <ll> arr(n);
    for (int z=0;z<k;z++){
        ll d;
        cin >> d;
        for (int x=0;x<d;x++){
            ll temp;
            cin >> temp;
            temp--;
            arr[temp]++;
        }
    }
    ll ans = 0;
    for (int z=0;z<n;z++){
        if (arr[z] == 0) ans ++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3620