akhauriyash/Code-Regression huggingface dataset:
// finish date: 2019/3/17

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


//足し算
int add(int a, int b) {
    return (int) (((ll) a + b + bigmod) % bigmod);
}

//引き算
int sub(int a, int b) {
    return (int) (((ll) a - b + bigmod) % bigmod);
}

//掛け算
int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


int main() {
    int N;
    cin >> N;
    vi C;
    int c;
    cin >> c;
    c--;
    C.push_back(c);
    int ma = c;
    rep(i, N - 1) {
        cin >> c;
        c--;
        if (C[C.size() - 1] != c) C.push_back(c);
        ma = max(ma, c);
    }
    N = C.size();
    vi color(ma + 1, 0);
    vi cnt(N, 0);
    cnt[0] = 1;
    color[C[0]] = cnt[0];
    FOR(i, 1, N) {
        cnt[i] = add(cnt[i - 1], color[C[i]]);
        color[C[i]] = add(color[C[i]], cnt[i - 1]);
    }

    cout << cnt[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n, a, b;
vi h;

bool Can(ll w){
  ll add = 0;
  ll d = a - b;

  for(int i = 0;i < n;++i){
    ll have = h[i] - w * b;
    if(have <= 0) continue;
    add += (have + d - 1) / d;
    if(add > w) return false;
  }

  return add <= w;
}

int main(){
  scanf("%d%d%d", &n, &a, &b);
  h.resize(n);
  for(int& e : h) scanf("%d", &e);

  ll lo = 0, hi = 1, mid;
  while(!Can(hi)) hi <<= 1;
  for(;;){
    if(lo + 1 >= hi){
      if(Can(lo)) mid = lo;
      else mid = hi;
      break;
    }
    mid = (lo + hi) >> 1;
    if(Can(mid)) hi = mid;
    else lo = mid;
  }

  cout << mid << '\n';

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main() {
	char s[1200];
	scanf("%s", s);
	for (int i = 0; i < 1200; i++) {
		if (i == 0)
			continue;
		if (s[i] == NULL) {
			if (s[i - 1] == 's') {
				printf("%ses", s);
				break;
			}
			if (s[i - 1] != 's') {
				printf("%ss", s);
				break;
			}
		}
	}
}

Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef long long ll;
#define loop(n)      for(int i=0;i<(n);i++)
#define lp(x,s,e)    for(int x=(s);x<(e);x++)
#define lpe(x,s,e)    for(int x=(s);x<=(e);x++)
#define MP make_pair
#define PB push_back
#define all(a)  a.begin(),a.end()
#define clr(x,val) memset((x),(val),sizeof(x))
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int n=s.size();
    for(int i=1;i<n;i++){
    if(s[i]=='B'){
     s.erase(i-1,2);
     i=0;
     n-=2;
    }
    }
    string x="";
    for(int i=0;i<s.size();i++){
     if(s[i]=='B')
      continue;
     x+=s[i];
    }
    cout<<x;
    }




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

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

using namespace std;

int main(void)
{
    int n = 0; cin >> n;

    list<double> ls;

    double tmp = 0;

    rep(i, n) {
        cin >> tmp;
        ls.push_front(tmp);
    }

    ls.sort();

    while(ls.size() != 1) {
        tmp = ls.front(); ls.pop_front();
        ls.front() = (ls.front() + tmp) / 2.0;
    }

    cout << ls.front() << endl;

    return 0;
}


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

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

void Empty(int *, int *);
void swap(int *, int *);
int Cal();
int DFS(int, int, int, int, int);

int main(){
  int i, j, l;
  int x, y, a;

  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 4 ; j++){
      scanf("%d",&Puzzle[i][j]);
    }
  }

  Empty(&x,&y);

  for(l = 0 ; l < 100 ; l++){
    for(i = 0 ; i < 4 ; i++){
      for(j = 0 ; j < 4 ; j++){
	tmp[i][j] = Puzzle[i][j];
      }
    }

    a = DFS(x, y, -1, 0, l);
    if(a != -1){
      printf("%d\n",a);
      break;
    }

    for(i = 0 ; i < 4 ; i++){
      for(j = 0 ; j < 4 ; j++){
	Puzzle[i][j] = tmp[i][j];
      }
    }
    
    a = -1;
    if(l == 99) printf("%d\n",a);
  }

  return 0;
}

void Empty(int *x, int *y){
  int i, j;

  for(i = 0 ; i < 4 ; i++){
    for(j = 0 ; j < 4 ; j++){
      if(!Puzzle[i][j]){
	*x = j;
	*y = i;
	return;
      }
    }
  }
}

void swap(int *a, int *b){
  int tmp;
  
  tmp = *a;
  *a = *b;
  *b = tmp;
}


int Cal(){
  int i, a;
  int sum = 0;

  for(i = 0 ; i < 16 ; i++){
    a = Puzzle[i/4][i%4];
    if(a){
      a--;
      sum += abs(i/4 - a/4)  + abs(i%4 - a%4);
    }
  }

  return sum;
}

int DFS(int x, int y, int p, int dep, int limit){
  int i, h, nx, ny, res;

  h = Cal();
  
  if(h == 0) return dep;
  if(dep + h > limit) return -1;

  for(i = 0 ; i < 4 ; i++){
    nx = x + dx[i];
    ny = y + dy[i];

    if(~p && i == (p+2)%4) continue;
    if(!(0 <= nx && nx < 4 && 0 <= ny && ny < 4)) continue;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
    res = DFS(nx, ny, i, dep+1, limit);
    if(~res) return res;

    swap(&Puzzle[y][x], &Puzzle[ny][nx]);
  }

  return -1;
}



Measured memory_bytes: 2104
n = int(input())
C = list(input())
l, r, c = 0, n-1, 0
while l < r:
    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: 10676
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int sum = 0;
	vector<int> s( N );
	for( auto& v: s ) {
		cin >> v;
		sum += v;
	}

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

	for( int i = 0; i < N && sum % 10 == 0; ++i ) {
		if( (sum - s[i]) % 10 ) {
			sum -= s[i];
			break;
		}
	}

	if( sum % 10 == 0 ) {
		cout << "0\n";
	}
	else {
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cctype>

int main()
{
    std::string s;
    std::cin >> s;
    int n{std::stoi(s)};
    int digits_sum{std::accumulate(s.begin(), s.end(), 0, [](int sum, char c) { return sum += (std::isdigit(c) ? (c - '0') : 0); })};
    std::cout << ((n % digits_sum) ? "No" : "Yes") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N, Y;
    cin >> N >> Y;
    int ans1 = -1;
    int ans2 = -1;
    int ans3 = -1;
    for(int i = 0;i <= N;i++){
        for(int x = 0;x <= N - i;x++){
            int z = N - i - x;
            if(i * 10000 + x * 5000 + z * 1000 == Y){
                ans1 = i;
                ans2 = x;
                ans3 = z;
                goto finish;
            }
        }
    }
    finish:
    cout << ans1 << " " << ans2 << " " << ans3 << endl;   
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int p,q,r;
  int t;
  scanf("%d %d %d",&p,&q,&r);
  if(p<q){
    t=p;
    p=q;
    q=t;
  }
  if(q<r){
    t=q;
    q=r;
    r=t;
  }
  if(p<q){
    t=p;
    p=q;
    q=t;
  }
  printf("%d",q+r);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 10005
#define PI 3.14159265358979323846264338327950
#define ll signed long long int
using namespace std;
ll t , n, c[MAXX];
vector<ll> adj[MAXX];
bool used[MAXX];


signed main()
{
	FAST;
	ll a, b, r;
	cin >> t >> n;
	ll mx = 1, mn = t;
	for(ll i = 0; i < n; i++){
		cin >> a >> b;
		mx = max(a, mx);
		mn = min(b, mn);
	}
	mx = mn - mx + 1;
	if(mx > 0){
		cout << mx;
		return 0;
	}
	cout << 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
ll n,x;
ll ans=0;
int main()
{
	cin>>n>>x;
	ans+=n;
	ll a=max(x,n-x),b=min(x,n-x);
	while(a%b!=0)
	{
		ans+=2*(a/b)*b;
		a=a%b;
		swap(a,b);
	}
	ans+=2*(a/b)*b-b;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>b(n-1); for(auto&&i:b)cin>>i;
	int ans=b.front()+b.back();
	for(int i=1;i<b.size();++i){
		ans+=min(b.at(i-1),b.at(i));
	}
	cout<<ans<<"\n"s;
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    ll v;
    if(a>=k)v = k;
    else if(a+b>=k)v = a;
    else if(a+b+c>=k)v = a -(k-a-b);
    cout<<v<<endl;

}



Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> dp(3, 0);
    while (n--) {
        int a, b, c; cin >> a >> b >> c;
        vector<int> dp2(3);
        dp2[0] = max(dp[1], dp[2]) + a;
        dp2[1] = max(dp[0], dp[2]) + b;
        dp2[2] = max(dp[0], dp[1]) + c;
        swap(dp, dp2);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
/*input
1000 1 1000
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
}


Measured memory_bytes: 3604
from collections import defaultdict
N, M=map(int, input().split())
A=list(map(int, input().split()))
B=[0]*N
B[0]=A[0]%M
C=defaultdict(int)
for i in range(1, N):
  B[i]=(B[i-1]+A[i])%M
  
for b in B:
  C[b]+=1
  
ans=C[0]
for key in C.keys():
  t=C[key]
  ans+=t*(t-1)//2
  
print(ans)

Measured memory_bytes: 16556
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 1000000001
#include<iostream>
#include<vector>
using ll = long long;

int main()
{    

    ll N,M;
    std::cin >> N >> M ;
    std::vector<std::pair<ll,ll>> shop;
    for(ll i = 0; i < N; ++i){
        ll a,b;
        std::cin >> a >> b;
        shop.push_back({a,b});
    }
   std::sort(shop.begin(), shop.end());
   ll count = 0;
   ll sum = 0;
   ll i = 0;
   while(count < M){
    if(count + shop[i].second <= M){
        count += shop[i].second;
        sum += shop[i].first * shop[i].second;
        i++;
        continue;
    }
    sum += shop[i].first*(M - count);
    count = M;
    break;
   }

    std::cout <<  sum << std::endl; 

    return 0;
}



Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
int Hiuwen(int n)
{
    int m[10],ii=0,f=0;
    while(n!=0)
    {
        m[ii++]=n%10;
        n=n/10;
    }
    if(m[0]==m[ii-1]&&m[1]==m[ii-2])
        f=1;
    return f;
}
int main()
{
    int a,b,c=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        Hiuwen(i);
        if(Hiuwen(i)==1)
            c++;
    }
    printf("%d\n",c);
    return 0;
}


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

#define llint long long int

using namespace std;

int main(){
    string S, T;

    cin >> S >> T;

    if(S + T[T.length() - 1] == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;



int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int i,a[10];
	for(i=0;i<10;i++)
		scanf(" %d",&a[i]);
	sort(a,a+10);
	printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
	
	return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#define _USE_MATH_DEFINES
#include <cmath>
#include <memory>
#include <iomanip>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
namespace mp = boost::multiprecision;
int main(){
    cout << std::setprecision(10);
    long double  a,b,x;
    cin>>a>>b>>x;
    if(a*a*b/2>x){
        cout << 180.000*atan2(b, 2*x / (b * a))/M_PI << endl;
    }else{
        long double c = a * a * b - x;
        cout << 180 * atan2(2 * c / (a * a), a)/M_PI << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string s;
	in(s);

	if ("SUN" == s) {
		outn(7);
	}
	else if ("MON" == s) {
		outn(6);
	}
	else if ("TUE"==s) {
		outn(5);
	}
	else if ("WED" == s) {
		outn(4);
	}
	else if ("THU" == s) {
		outn(3);
	}
	else if ("FRI" == s) {
		outn(2);
	}
	else {
		outn(1);
	}

	return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

// 変な入力を想定して，剰余をちゃんとやると，結構重いので，mulとか適宜省くとよい
struct Matrix
{
    using vec = std::vector<lint>;
    using mat = std::vector<vec>;
    mat X;
    lint MOD;

    static inline mat mul(const mat &A, const mat &B, lint M)
    {
        unsigned H = A.size(), W = B[0].size(), K = B.size();
        mat C(H, vec(W));
        REP(i, H) REP(j, W)
        {
            REP(k, K) C[i][j] += A[i][k] * B[k][j];
            C[i][j] %= M;
        }
        return C;
    }

    Matrix(const mat &matrix, lint mod) : X(matrix), MOD(mod) {}

    Matrix power(lint n)
    {
        int m = X.size();
        mat B(m, vec(m));
        mat C = X;
        REP(i, m) B[i][i] = 1;
        while (n > 0)
        {
            if (n & 1) B = mul(B, C, MOD);
            C = mul(C, C, MOD);
            n >>= 1;
        }
        return Matrix(B, MOD);
    }

    vec dot(const vec &v)
    {
        vec ans(X.size());
        REP(i, X.size())
        {
            REP(j, v.size()) ans[i] += X[i][j] * v[j];
            ans[i] %= MOD;
        }
        return ans;
    }
};

int N, M;
vector<lint> X;
constexpr lint MOD = 1000000007;


int main()
{

    vector<vector<lint>> trans{
        {1, 1, 2, 1},
        {1, 1, 2, 1},
        {1, 0, 1, 1},
        {1, 0, 0, 1}};

    Matrix M1(trans, MOD);

    cin >> N >> M;

    X.resize(M + 1);
    REP(i, M) cin >> X[i + 1];
    X.push_back(N);

    vector<lint> st{1, 0, 0, 0};
    FOR(i, 1, X.size())
    {
        st = M1.power(X[i] - X[i - 1]).dot(st);
        st[0] = 0;
    }

    cout << st[1] << endl;
}


Measured memory_bytes: 1792
N = int(input())

mycnt = 0
flag = 0
for n in range(N):
    a, b = map(int, input().split())
    if a == b:
        mycnt += 1
        if mycnt >= 3:
            flag = 1
    else:
        mycnt = 0
if flag == 1:
    print('Yes')
else:
    print('No')

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

int main()
{
	int32_t N, M;
	cin >> N >> M;

	vector<pair<int64_t, int64_t>> v(N);
	for (int32_t i = 0; i < N; i++) {
		int32_t A, B;
		cin >> A >> B;
		v[i] = make_pair(A, B);
	}
	sort(v.begin(), v.end());

	int64_t res = 0;
	for (int32_t i = 0; i < N && M > 0; i++) {
		if (v[i].second < M) {
			res += v[i].second * v[i].first;
			M -= v[i].second;
		} else {
			res += M * v[i].first;
			M = 0;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
// ABC106-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> info(510,vector<int>(510,0));
    vector<vector<int>> yoko(510,vector<int>(510,0));
    vector<vector<int>> tate(510,vector<int>(510,0));
    rep(i,m){
        int l,r;
        cin>>l>>r;
        info[l][r]++;
    }
    for(int i=1;i<=500;i++){
        for(int j=1;j<=500;j++){
            yoko[i][j]=yoko[i][j-1]+info[i][j];
        }
    }
    for(int i=1;i<=500;i++){
        for(int j=1;j<=500;j++){
            tate[i][j]=tate[i-1][j]+yoko[i][j];
        }
    }
    rep(i,q){
        int ll,rr;
        cin>>ll>>rr;
        int ans=tate[rr][rr]-(tate[rr][ll-1]+tate[ll-1][rr]-tate[ll-1][ll-1]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6376
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-09-20 16:32:54
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , P[MAXN] , ind[MAXN] , par[MAXN] , sz[MAXN];
set<pii> st;

int Find(int v){
	return (par[v] == -1 ? v : par[v] = Find(par[v]));
}

void Union(int v , int u){
	v = Find(v) , u = Find(u);
	if(u == v)	return;
	if(sz[u] > sz[v])	swap(v , u);
	par[u] = v;
	sz[v] += sz[u];
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	fill(par , par + MAXN , -1);
	fill(sz , sz + MAXN , 1);

	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		int x , y;
		cin >> x >> y;
		P[x] = y;
		ind[i] = x;
	}
	for(int i = 1 ; i <= n ; i++){
		int mn = P[i];
		while(SZ(st)){
			pii A = (*st.begin());
			if(A.X > P[i])	break;
			st.erase(A);
			mn = min(mn , A.X);
			Union(i , A.Y);
		}
		st.insert({mn , i});
	}
	for(int i = 1 ; i <= n ; i++){
		cout << sz[Find(ind[i])] << endl;
	}

    return 0;
}
/*

*/


Measured memory_bytes: 18428
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int a,b,c,d;
        a=input.nextInt();
        b=input.nextInt();
        c=input.nextInt();
        d=input.nextInt();

        if(a!=c){

            System.out.println(1);

        } else{
            System.out.println(0);
        }





    }

}

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

signed main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	reverse(all(a));
	int ans = 0;
	rep(i, k) ans += a[i];
	cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
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; }

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    vector<ll> dp(N+1, INF);
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll fen[100005];
ll n;
void increase(ll i, ll delta)
    {
        for (; i < n; i |= i + 1)
            fen[i] += delta;
    }
ll sum(ll ind)
    {
        ll sumer = 0;
        while (ind>=0)
        {
            sumer += fen[ind];
            ind &= ind + 1;
            ind--;
        }
        return sumer;
    }
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n;
    cin>>n;
    cout<<((n*(n-1))/2LL);
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
 
typedef struct{
  char c;
  int n;
}back;
 
int main()
{
  back card1[36],card2[36],tmp[36],temp;
  char c;
  int minj,i,j,a,N;
 
  scanf("%d",&N);
   
  for(i=0;i<N;i++){
    scanf(" %c%d",&card1[i].c,&card1[i].n);
    scanf("%c",&c);
  }
 
  for(j=0;j<N;j++){
    card2[j]=card1[j];
  }
 
  a=0;
   
  for(i=1;i<10;i++){
    for(j=0;j<N;j++){
      if(card1[j].n==i){
    tmp[a]=card1[j];
    a++;
      }
    }
  }
 
  for(i=0;i<N;i++){
    for(j=1;j<N;j++){
      if(card1[j].n<card1[j-1].n){
    temp=card1[j];
    card1[j]=card1[j-1];
    card1[j-1]=temp;
      }
    }
  }
 
  for(i=0;i<N;i++){
    if(i!=N-1) printf("%c%d ",card1[i].c,card1[i].n);
    else printf("%c%d\n",card1[i].c,card1[i].n);
  }
 
  a=0;
 
  for(i=0;i<N;i++){
    if(card1[i].c!=tmp[i].c){
      printf("Not stable\n");
      a++;
      break;
    }
  }
  if(a==0) printf("Stable\n");
 
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(card2[j].n<card2[minj].n) minj=j;
    }
    temp=card2[i];
    card2[i]=card2[minj];
    card2[minj]=temp;
  }
 
  for(i=0;i<N;i++){
    if(i!=N-1) printf("%c%d ",card2[i].c,card2[i].n);
    else printf("%c%d\n",card2[i].c,card2[i].n);
  }
 
  a=0;
 
  for(i=0;i<N;i++){
    if(card2[i].c!=tmp[i].c){
      printf("Not stable\n");
      a++;
      break;
    }
  }
  if(a==0) printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	AB := sc.nextInts()
	A := AB[0]
	B := AB[1]

	if A <= B*2 {
		fmt.Println(0)
	} else {
		fmt.Println(A - B*2)
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;

class MaxFlow {
	struct edge {
		int to, cap, rev;
		edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level;
	vector<int> iter;

	void BFS(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

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

public:
	MaxFlow(int _V) : V(_V), G(_V), level(_V), iter(_V) {}
	void add(int from, int to, int cap) {
		G[from].push_back(edge(to, cap, G[to].size()));
		G[to].push_back(edge(from, 0, G[from].size() - 1));
	}
	int Dinic(int s, int t) {
		int flow = 0;
		while (true) {
			BFS(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = DFS(s, t, INF)) > 0) {
				flow += f;
			}
		}
	}
};

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	MaxFlow mf(H * W * 2 + 2);
	for (int i = 0; i < H * W; i++) {
		if (S[i % H][i / H] == '.') {
			mf.add(i, i + H * W, 1);
		}
		else {
			mf.add(i, i + H * W, INF);
			mf.add(i + H * W, H * W * 2 + 1, INF);
		}
		if (i % H == 0 || i % H == H - 1 || i / H == 0 || i / H == W - 1) {
			mf.add(H * W * 2, i, INF);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 4; k++) {
				int tx = i + dx[k], ty = j + dy[k];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W) {
					mf.add(j * H + i + H * W, ty * H + tx, INF);
				}
			}
		}
	}
	int res = mf.Dinic(H * W * 2, H * W * 2 + 1);
	cout << (res < INF ? res : -1) << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;

int main()
{
    int k;
    cin>>k;
    ll i = 1;
    ll t = 7;
    while(i<=1000000){
        if(t % k == 0){
            cout<<i<<endl;
            return 0;
        }
        t = (t*10+7)%k;
        i++;
    }
    cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n,0);
    for (int i = 0; i<k; i++){
        int d;
        cin >> d;
        for (int j = 0; j < d; j++){
            int x;
            cin >> x;
            if (vec[x-1] == 0){
                vec[x-1] = 1;
            }            
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (vec[i] == 0){
            ans++;
        }
        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3624
def solve():
    k = int(input())
    x, y = map(int, input().split())
    if k % 2 == 0 and (x + y) % 2 == 1:
        print(-1)
        return 0
    if x < 0:
        flipX = -1
        x = -x
    else:
        flipX = 1
    if y < 0:
        flipY = -1
        y = -y
    else:
        flipY = 1
    if x < y:
        flipXY = True
        x, y = y, x
    else:
        flipXY = False
    x, y = x - y, x + y
    ans = [(x, y)]
    while y - k >= k:
        y = y - k
        if x > k:
            x = x - k
        else:
            x = 0
        if (x + y) % 2:
            x = 1
        ans.append((x, y))
    if y != k:
        if y % 2 == 1: # k odd
            if x < k:
                x += k
                y += 1
            else:
                x -= k
                y += 1
            ans.append((x, y))
        ans.append((k, y - k))
    ans = map(lambda z: ((z[0] + z[1]) // 2, (-z[0] + z[1]) // 2) , reversed(ans))
    if flipXY:
        ans = map(lambda z: (z[1], z[0]), ans)
    ans = list(map(lambda z: (flipX * z[0], flipY * z[1]), ans))
    print(len(ans))
    for x, y in ans:
        print(x, y)
    return 0
solve()

    #ans = [(x, y)]
#while x + y > 2 * k:
#    if x - k >= y:
#        x = x - k
#    elif x <= y - k:
#        y = y - k
#    else:
#        s = x + y - k
#        x, y = s // 2, (s + 1) // 2
#    ans.append((x, y))
#
#r = []
#if x < y:
#    x, y = y, x
#    flipr = True
#else:
#    filpr = False
#if x + y == k:
#    r.append((0, 0))
#elif k % 2 == 0:
#    if (x + y) % 2 == 1:
#        print(-1)
#        exit()
#    if x + y < k:
#        t = (y - x) // 2
#        r.append((k - t, t))
#        r.append((0, 0))
#    else:
#


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int H,W,h,w;

void input() {
	cin>>H>>W>>h>>w;
}

void solve() {
	cout<<(H-h)*(W-w)<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long int i, s = 0;
string a;

   cin>>a;
   for(i=0;i<a.length();i++){
    s=s+(a[i]-48);
   }

   if(s%9==0){
    cout<<"Yes"<<endl;
   }
   else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> x(n); for (int i = 0; i < n; i++) cin >> x[i];
  int m; cin >> m;
  lint k; cin >> k;
  V<> a(m); for (int i = 0; i < m; i++) cin >> a[i], a[i]--;
  V<> p(n - 1); iota(p.begin(), p.end(), 0);
  for (int i = 0; i < m; i++) swap(p[a[i] - 1], p[a[i]]);
  V<> to(n - 1);
  V<bool> chk(n - 1);
  for (int i = 0; i < n - 1; i++) if (!chk[i]) {
    V<> b;
    chk[i] = true;
    b.push_back(i);
    int t = p[i];
    while (t != i) {
      chk[t] = true;
      b.push_back(t);
      t = p[t];
    }
    lint c = b.size();
    for (int i = 0; i < c; i++) to[b[i]] = b[(i + k) % c];
  }
  V<lint> d(n - 1);
  for (int i = 0; i < n - 1; i++) d[i] = x[to[i] + 1] - x[to[i]];
  for (int i = 0; i < n - 1; i++) x[i + 1] = x[i] + d[i];
  for (int i = 0; i < n; i++) cout << x[i] << '\n';
}

Measured memory_bytes: 4208
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a/b + " " + a%b + " " + BigDecimal.valueOf((double)a/b).toPlainString());

	}

}



Measured memory_bytes: 26680
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin >> x;
    
    int a = (x / 500) *1000;
    
    int b = (x % 500) / 5 * 5;
    
    cout << a + b << endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll gcd (ll x, ll y) { return y ? gcd(y,x%y) : x; }

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,x;
  cin >> n >> x;
  vector<ll> a(n);
  ll ans = 0;
  rep(i,n) {
    cin >> a[i];
    ans = gcd(ans, abs(a[i]-x));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pa pair<int,int>
using namespace std;
priority_queue<pa> qwq;
int a[200005],b[200005],N;
int main(){
	scanf("%d",&N);
	long long ans=0;
	for (int i=1;i<=N;i++)
		scanf("%d",&b[i]);
	for (int i=1;i<=N;i++){
		scanf("%d",&a[i]);
		qwq.push(make_pair(a[i],i));
	}
	while (!qwq.empty()){
		pa now=qwq.top();
		qwq.pop();
		if (b[now.second]>now.first) {
			puts("-1");
			return 0;
		}
		if (b[now.second]==now.first) continue;
		int Ned=now.first-b[now.second];
		int tmp=a[now.second-1]+a[now.second+1];
		if (now.second==1) tmp+=a[N];
		if (now.second==N) tmp+=a[1];
		if (tmp>Ned){
			printf("-1\n");
			return 0;
		}
		int tmp1=Ned/tmp;
		ans+=tmp1;
		a[now.second]-=tmp1*tmp;
		now.first=a[now.second];
		qwq.push(now);
	}
	cout<<ans;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<string> S;
	for(int i=0;i<N;i++){
		string tmp;
		cin >> tmp;
		S.push_back(tmp);
	}
	sort(S.begin(), S.end());
	int ans = 1;
	for(int i=1;i<N;i++){
		if(S[i] != S[i-1])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11576
#include<stdio.h>
#include<string.h>
int main(){
  char k[14];
  int n=0;
  gets(k);
  for(int i=0;k[i];i++){    
    if(k[i]=='x'){
      n++;
    }
    else{
    }
  }
  if(n>7){
    printf("NO");
  }
  else printf("YES");
    
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1234567;
map<int,bool> m;
int main(){
//	freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int tm;
	while(n--){
		cin>>tm;
		m[tm]=!m[tm];
	}
	int s = 0;
	for(auto v:m){
		if(v.second)s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n  =sc.nextInt();

        int d = n % 10;
        if (Arrays.asList(2, 4, 5, 7, 9).contains(d)) {
            out.println("hon");
        } else if (Arrays.asList(0, 1, 6, 8).contains(d)) {
            out.println("pon");
        } else {
            out.println("bon");
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 25412
import Data.List

solve :: Int -> [Int] -> Int
solve n = f . sort
  where
    f [a,b,c]
      | a == b && b == c = n
      | a == b = solve (n+1) [a+1, b+1, c]
      | otherwise = solve (n+1) [a+2, b, c]

main :: IO ()
main = do
    xs <- map read . words <$> getLine :: IO [Int]
    print $ solve 0 xs


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

int main(){
    int n,m;
    cin >> n >> m;
    int matrix[n][m];
    int identityMatrix[m];
    int outMatrix[n];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> matrix[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> identityMatrix[i];
    }
    for(int i=0; i<n; i++){
        outMatrix[i]=0;
        for(int j=0; j<m; j++){
            outMatrix[i]+=matrix[i][j]*identityMatrix[j];
        }
        cout << outMatrix[i] << endl;
    }
}



Measured memory_bytes: 3136
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int DP[n];
    DP[0]=0;
    DP[1]=abs(arr[0]-arr[1]);
    for (int i =2;i<n;i++)
    {
        DP[i]=min(abs(arr[i-1]-arr[i])+DP[i-1],abs(arr[i-2]-arr[i])+DP[i-2]);
    }
    cout<<DP[n-1];
    return 0;
}


Measured memory_bytes: 4340