akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,t;
    vector<LL> a;
    Problem(LL n):n(n),a(n){};

    void solve(){
        cin >> t;
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        a.push_back(LINF);
        LL ans=0;
        for(int i=0; i<n; ++i){
            ans+=min(t,a[i+1]-a[i]);
        }
        cout << ans <<"\n";

    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <tuple>
#include <numeric>
#include <sstream>
#include <cassert>
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;
}

using namespace std;

int main() {
	double T;
	double X;

	cin >> T >> X;

	double ans = T / X;

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	stack<int> S;
	int n;
	while(cin >> n){
		if(n == 0){
			cout << S.top() << endl;
			S.pop();
		}else{
			S.push(n);
		}
	}
}


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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

int n, m; 

vector <int> g[125252]; 
int indeg[125252]; 
int len[125252], bef[125252]; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d%d", &n, &m); 
	REP(i, m)
	{
		int x, y; 
		scanf("%d%d", &x, &y); 
		x--; y--; 
		g[x].pb(y); 
		indeg[y]++; 
	}
	
	memset(bef, -1, n); 
	stack <int> S; 
	REP(i, n) if (indeg[i] == 0) S.push(i); 
	while (S.size())
	{
		int p = S.top(); 
		S.pop(); 
		REP(i, g[p].size())
		{
			int to = g[p][i]; 
			
			if (len[p] + 1 > len[to])
			{
				len[to] = len[p] + 1; 
				bef[to] = p; 
			}
			indeg[to]--; 
			if (indeg[to] == 0) S.push(to); 
		}
	}
	
	printf("%d\n", *max_element(len, len + n)); 
	
	return 0; 
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    vector<int> a(2);
    rep(i, 2) cin >> a[i];
    sort(all(a));
    if (a[0] == 1 && a[1] == 2) cout << 3 << endl;
    else if (a[0] == 2 && a[1] == 3) cout << 1 << endl;
    else cout << 2 << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll ans=-INF;
  chmax(ans,A*C);
  chmax(ans,A*D);
  chmax(ans,B*C);
  chmax(ans,B*D);
  co(ans);
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int MAXN=610;
bool vis[MAXN][MAXN];
int siz,dis1,dis2,n,n_,sum;
inline void color(int dis)
{
	int p2=0;
	while(!(dis&3)) dis>>=2,p2++;
	if(dis&1)
	{
		for(int i=0;i<n_;i++)
			for(int j=0;j<n_;j++)
				if(((i>>p2)+(j>>p2))&1) vis[i][j]=1;
	}
	else
	{
		for(int i=0;i<n_;i++)
			for(int j=0;j<n_;j++)
				if((i>>p2)&1) vis[i][j]=1;
	}
	return;
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>dis1>>dis2;
	n_=n<<1;
	color(dis1);
	color(dis2);
	for(int i=0;i<n_;i++)
		for(int j=0;j<n_;j++)
		{
			if(!vis[i][j]) cout<<i<<" "<<j<<"\n",sum++;
			if(sum==n*n) return 0;
		}
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep2(i,a,b) for(ll i=a; i<=b; i++)
#define drep2(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back


int main ()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) {
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A.begin(), A.end());
  ll ans = 0;
  ll mid = A[N/2];
  rep(i,N) {
    ans += abs(A[i] - mid );
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(a) begin(a),end(a)
#define INF 999999999
#define debug(x) cerr << #x << ":" << x << '\n'
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int  ui;

int main() {
	int abc[3], sum;
	cin >> abc[0] >> abc[1] >> abc[2];
	sort(abc, abc + 3);
	sum = abc[0] + abc[2]*10 + abc[1];
	cout << sum << '\n';
}


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

int main() {
	int n, b, f, r, v;
	int x[4][3][10] = {};

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		x[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for(int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << x[i][j][k];
			}
			cout << endl;
		}
		if(i < 3)	cout << "####################" << endl;
		//else cout << endl;

	}
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<pair<long long, int>> factorize(long long N)
{
  vector<pair<long long, int>> res;
  for (long long i = 2; i * i <= N; i++)
  {
    if (N % i != 0)
      continue;
    res.emplace_back(i, 0);
    while (N % i == 0)
    {
      N /= i;
      res.back().second++;
    }
  }
  if (N != 1)
    res.emplace_back(N, 1);
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, P;
  cin >> N >> P;
  vector<pair<ll, int>> res = factorize(P);
  ll ans = 1;
  if (N == 1)
    cout << P << endl;
  else
  {
    for (int i = 0; i < res.size(); i++)
    {
      if (res[i].second >= N)
        ans *= pow(res[i].first, res[i].second / N);
    }
    cout << ans << endl;
  }
  return 0;
}

// 素因数分解をしてfor文で先頭からN以上かを見ていく．N以上だった場合，それをNで割った切り捨て乗をansに掛けていくpow(res[i].first, res[i].second / N)
// N == 1だった場合はPで確定


Measured memory_bytes: 256
#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)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll n,x;
    cin>>n>>x;
    cout<<(n-__gcd(n,x))*3<<endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC121().SolveC(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

    class ABC121
    {
        public void SolveC(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var drinks = new Drink[n];
            for (int i = 0; i < n; i++)
            {
                drinks[i] = new Drink(cin.ReadInt, cin.ReadInt);
            }
            var sortedDrinks = drinks.OrderBy(x => x._a);
            long need = m;
            long sumPrice = 0;

            foreach (var drink in sortedDrinks)
            {
                //WriteLine($"必要個数={need} price={sumPrice} m={m}");
                if (drink._b < need)
                {
                    need -= drink._b;
                    sumPrice += drink._a * drink._b;
                }
                else
                {
                    sumPrice += drink._a * need;
                    need = 0;
                    break;
                }
            }
            WriteLine(sumPrice);
            ReadLine();
        }

        public struct Drink
        {
            public long _a { get; set; }
            public long _b { get; set; }
            public Drink(int a, int b)
            {
                _a = a;
                _b = b;
            }

        }
    }
}

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

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

    int s, k, c;
    while(n != 0 && m != 0){
        vector<int> mx(n, 0), mn(n, 0);
        for(int i = 0; i < m; i++){
            cin >> s >> k;

            for(int j = 0; j < k; j++){
                cin >> c;
                c--;
                mx[c] += s;
            }
            if(k == 1)mn[c] += s;
        }

        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j)continue;

                ans = max(ans, mx[i] - mn[j]);
            }
        }
        cout << ans + 1 << endl;

        cin >> n >> m;
    }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;

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

Measured memory_bytes: 1152
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N,X,T;
  cin >> N >> X >> T;
  if (N % X == 0) {
    cout << T * N / X << endl;
  } else {
    cout << T * (N/X + 1) << endl;
  }
  return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

// ax + by = gcd(a, b) となるような (x, y) を求める
// a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰
    y -= a / b * x;
    return d;
}


// 負の数に対応した mod
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}


// 逆元計算 (a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // x % m だが、x が負かもしれないので
}

int main() {
    int n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    vector<ll> plus, minus, zero;
    rep(i,n){
        if(a[i] > 0)plus.push_back(a[i]);
        if(a[i] < 0)minus.push_back(a[i]);
        if(a[i] == 0)zero.push_back(a[i]);
    }
    n = plus.size();
    int m = minus.size();
    int w = zero.size();
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());

    ll ans = 1;
    ll MOD = 1e9+7;

    if(n + m < k){
        cout << 0 << endl;
        return 0;
    }

    else if(n == 0){
        if(k % 2 == 0){
            rep(i,k){
                ans *= abs(minus[i]);
                ans %= MOD;
            }
        }else if(w > 0){
            ans = 0;
        }else{
            rep(i,k){
                ans *= abs(minus[m-1-i]);
                ans %= MOD;
            }
            ans = MOD - ans;
        }
    }

    else if(n + m == k && w == 0){
        rep(i,n){
            ans *= plus[i];
            ans %= MOD;
        }
        rep(i,m){
            ans *= MOD + minus[i];
            ans %= MOD;
        }
    }

    else if(k == n + m + w){
        ans = 0;
    }

    else{ // 最初にn,m,kをすべて偶数にしてしまう.
        if(k % 2 == 0){
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }else{
            ans *= plus[0];
            plus.erase(plus.begin());
            n--;
            k--;
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }
        vector<ll> v;
        rep(i,n/2){
            v.push_back(plus[i*2] * plus[i*2+1]);
        }
        rep(i,m/2){
            v.push_back(minus[i*2] * minus[i*2+1]);
        }
        sort(v.begin(), v.end(), greater<ll>());
        rep(i,k/2){
            ans *= v[i] % MOD;
            ans %= MOD;
        }
    }


    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8176
import math
MAX = 55555

n = int(input())
lst = [1 for i in range(MAX)]
lst[0] = lst[1] = 0
for i in range(int(math.sqrt(MAX)) + 1):
  if lst[i]:
    for j in range(i * i, MAX, i):
      lst[j] = 0
primes = [i for i in range(MAX) if lst[i]]
ans = [11,31,41,61,71]
count = n - 5
if count > 0:
  for i in range(101,MAX + 1,5):
    if i in primes:
      ans.append(i)
      count -= 1
      if count == 0:
        break
print(" ".join(list(map(str,ans))))

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios {
    fast_ios() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    };
} fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end)                                                     \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &v : vec)
        is >> v;
    return is;
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    cin >> P;
    vector<int> Pinv(N + 1);

    REP(i, N) Pinv[P[i]] = i;
    multiset<int> shown;
    shown.insert(-1);
    shown.insert(-1);
    shown.insert(N);
    shown.insert(N);
    ll ret = 0;
    IFOR(i, 1, N + 1) {
        ll now = Pinv[i];
        ll r = *shown.lower_bound(now);
        ll rr = *next(shown.lower_bound(now));
        ll l = *prev(shown.lower_bound(now));
        ll ll = *prev(shown.lower_bound(now), 2);
        ret += ((rr - r) * (now - l) + (l - ll) * (r - now)) * i;
        // dbg((vector<ll>{ll, l, r, rr}));
        shown.insert(now);
    }
    cout << ret << endl;
}


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

int main(int argc, char const *argv[])
{
	char str1[11], str2[12];
	scanf("%s %s", &str1, &str2);
	str2[strlen(str2) - 1] = '\0';
	if(strcmp(str1, str2) == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0&&W%w==0){
		cout<<"No"<<endl;
		return 0;
	}else{
		cout<<"Yes"<<endl;
	}
	int s1=H/h*W/w*2;
	int s2=-s1*(w*h-1)-1;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(i%h||j%w){
				cout<<s1;
			}else{
				cout<<s2;
			}
			if(j==W){
				cout<<endl;
			}else{
				cout<<" ";
			}
		}
	}	
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;

int dp[5010], nxt[5010];

signed main(){
    int n;
    cin >> n;
    vector<int> h(n), p(n);
    vector<P> d(n); 
    for(int i = 0; i < n; i++){
        cin >> h[i] >> p[i];
        d[i] = {h[i] + p[i], i};
    }
    sort(d.begin(), d.end());
    for(int i = 0; i <= n; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++) nxt[j] = dp[j];
        for(int j = 0; j < n; j++){
            if(dp[j] == INF) continue;
            int id = d[i].second;
            if(dp[j] <= h[id]){
                nxt[j + 1] = min(nxt[j + 1], dp[j] + p[id]);
            }
        }
        swap(dp, nxt);
    }
    int ans = 0;
    for(int i = 0; i <= n; i++){
        if(dp[i] != INF) ans = i;
    }
    cout << ans << endl;
}

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

int main(){
	int N, i, ans = 1;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	int now = 0;
	for(i = 1; i < N; i++){
		if(now == 0){
			if(A[i] > A[i - 1]){
				now = 1;
			}
			else if(A[i] < A[i - 1]){
				now = -1;
			}
		}
		else if(now == 1){
			if(A[i] < A[i - 1]){
				ans++;
				now = 0;
			}
		}
		else{
			if(A[i] > A[i - 1]){
				ans++;
				now = 0;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



int main() {
	int n,k,a[55];

	cin >> n>>k;
	FORI(0,n)
		cin>>a[i];

	sort(a,a+n);
	int ans=0;
	FORI(0,k){
		ans+=a[n-k+i];

	}
	cout << ans << endl;
	
	return 0;
}




Measured memory_bytes: 256
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    //test
    {
        int n;
        string s1,s2;
        cin>>n;
        cin>>s1>>s2;
        for(int i=0;i<n;i++)
        {
            cout<<s1[i]<<s2[i];
        }
    }

End;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    int b = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'R') r++;
        else b++;
    }
    if(r > b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>

using namespace std;

char str[100];
int n;

int main()
{
	cin.getline(str, 100);
	n = strlen(str);

	int l1 = 0, r1 = (n - 1) / 2;
	int l2 = (n + 3) / 2, r2 = n;
	bool flag = true; 

	for (int i = l1; i < r1 / 2; i++)
	{
		if (str[i] != str[r1 - i - 1])
		{
			flag = false;
			break;
		}
	}
	
	for (int i = l2; i < r2; i++)
	{
		if (str[i] != str[r2 - i - 1])
		{
			flag = false;
			break;
		}
	}

	cout << (flag == true ? "Yes\n" : "No\n");
	return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int n, m;
vector<int> dp;
vector<vector<int> > g;

int rec(int i) {
    if (dp[i] != -1) return dp[i];
    int res = 0;
    rep (j, g[i].size()) {
        res = max(res, rec(g[i][j]) + 1);
    }
    return dp[i] = res;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    dp.resize(n, -1);
    g.resize(n);
    rep (i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
    }
    int ans = 0;
    rep (i, n) {
        ans = max(ans, rec(i));
    }
    cout << ans << endl;
    
    return 0;
}



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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c,d;
    int e,f;
    cin >> a >> b >> c >> d;
    rep(i,1000){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        } 
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

#define cmax(_a, _b) (_a < (_b) ? _a = (_b), 1 : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b), 1 : 0)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))

#define maxn 100010
#define lowbit(_x) ((_x) & (-(_x)))
typedef long long ll;
typedef double db;

const ll inf = 0x7ffffffffff;
ll f[maxn];
int x[maxn], hash[maxn], hcnt;
ll tr1[maxn], tr2[maxn];
void modify1(int pos, ll val)
{
	for (; pos <= hcnt; pos += lowbit(pos)) cmin(tr1[pos], val);
}
void modify2(int pos, ll val)
{
	for (; pos; pos -= lowbit(pos)) cmin(tr2[pos], val);
}
ll query1(int pos)
{
	ll ret = inf;
	for (; pos; pos -= lowbit(pos)) cmin(ret, tr1[pos]);
	return ret;
}
ll query2(int pos)
{
	ll ret = inf;
	for (; pos <= hcnt; pos += lowbit(pos)) cmin(ret, tr2[pos]);
	return ret;
}
int main()
{
	int n, E, T; scanf("%d%d%d", &n, &E, &T);
	for (int i = 1; i <= n; ++i) scanf("%d", x + i);
	for (int i = 0; i <= n; ++i) hash[++hcnt] = 2 * x[i];

	memset(tr1, 63, sizeof (tr1));
	memset(tr2, 63, sizeof (tr2));
	f[0] = 0;
	modify1(2, -2 * x[1]);
	modify2(2, 0);
	for (int i = 1; i <= n; ++i)
	{
		f[i] = inf;

		int pos = std::upper_bound(hash + 1, hash + hcnt + 1, 2 * x[i] - T) - hash - 1;
//		printf("pos %d\n", pos);
		ll tmp = query1(pos) + 3ll * x[i];
		cmin(f[i], tmp);
//		printf("tmp %lld\n", tmp);

		pos = std::lower_bound(hash + 1, hash + hcnt + 1, 2 * x[i] - T) - hash;
//		printf("pos %d\n", pos);
		tmp = query2(pos) + T + x[i];
		cmin(f[i], tmp);
//		printf("tmp %lld\n", tmp);
		
		modify1(i + 2, f[i] - 2ll * x[i + 1] - x[i]);
		modify2(i + 2, f[i] - x[i]);
		
//		printf("f[%d] = %lld\n", i, f[i]);
	}
	printf("%lld\n", f[n] + E - x[n]);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int N,L;
char str[100][101];

int cmpstr(const void * s1,const void * s2){
    
    if(strcmp(str[*(int *)s1],str[*(int *)s2])>0)
	return 1;
    else if(strcmp(str[*(int *)s1],str[*(int *)s2])<0)
	return -1;
    else 
	return 0;
}

int main()
{
    int strnum[100]={0};
    scanf("%d %d",&N,&L);
    for(int i=0;i<N;i++)
	scanf("%s",str[i]);
    for(int i=0;i<N;i++)
	strnum[i]=i;

    qsort(strnum,N,sizeof(int),cmpstr);

    for(int i=0;i<N;i++)
	printf("%s",str[strnum[i]]);
    printf("\n");
    return 0;
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1};
int dy[]={0,1,0,-1,1,1,};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vi a(n+1);
  rep(i,n+1) cin>>a[i];
  int sum=0;
  rep(i,n+1) sum+=a[i];

  if(n==0){
    if(a[0]==1) cout<<1<<endl;
    else cout<<-1<<endl;
    return 0;
  }
  //n>0, 

  if(a[0]>0){
    cout<<-1<<endl;
    return 0;
  }


  vi node(n+1);
  node[0]=1;
  int cnt=0;

  FOR(i,1,n){
    int k=node[i-1]-a[i-1]; //一つ上の、つないでいいところ
    // node[i]=k+min(k,sum-cnt-k);

    if(sum-cnt<2*k){ //ふえすぎ注意
      node[i]=sum-cnt;

    }else if(sum-cnt==2*k){//ちょうど
      node[i]=2*k;

    }else{//少なすぎ、がんがんふやす
      node[i]=2*k;

    }
    cnt+=a[i];

    //あきらかにふやしがまにあわない
    if(node[i]<a[i]){
      cout<<-1<<endl;
      return 0;
    }

  }

  int ans=0;
  rep(i,n+1){
    ans+=node[i];
  }
  cout<<ans<<endl;

  // if(n==2){
  //   rep(i,n+1){
  //     cout<<node[i]<<endl;
  //   }
  // }

  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  vector<int> vec(3);
  cin >> A >> B;
  
  int AA,AB,AC;
  vec.at(0) = A + B;
  vec.at(1) = A - B;
  vec.at(2) = A * B;
  
  int max = 0;
  if(vec.at(0) >= vec.at(1)){
  	max = vec.at(0);
  }else{
  	max = vec.at(1);
  }
  
  if(max >= vec.at(2)){
  	max = max;
  }else{
  	max = vec.at(2);
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  int cnt = 0;
  cin >> a >> b ;
  for(int i = 0;i < 20;i++){
    cnt = i;
    if (b <= (a - 1) * cnt + 1) {
      break;
    }
  }
  cout << cnt << "\n" ;
  return 0;
}

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

int ma[5000][5000] = {};

int main(){
    int n, m;
    cin >> n >> m;
    while(m-- > 0){
        int a, b, x;
        cin >> a >> b >> x;
        a--, b--;
        ma[a+x][b] = max(ma[a+x][b], x+1);
    }
    int ans = 0;
    for(int i = n-1;; i--){
        int val = 0;
        for(int j = 0; j <= i; j++){
            val = max(val, ma[i][j]);
            if(val > 0) ans++;
            val--;
        }
        if(i == 0)  break;
        for(int j = 0; j <= i-1; j++){
            ma[i-1][j] = max(ma[i-1][j], ma[i][j]-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 69832
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	unsigned long long n;
	cin >> n;
	unsigned long long arr[n], sum = 0;
	unordered_map<unsigned long long, unsigned long long> ma;
	for (unsigned long long i = 0; i < n; i++)
	{
		cin >> arr[i];
		ma[arr[i]]++;
		sum += arr[i];
	}
	///cout << sum << "\n";
	unsigned long long q;
	cin >> q;
	for (unsigned long long k = 0; k < q; k++)
	{
		unsigned long long a, b, temp;
		cin >> a >> b;
		///if(ma.find(a))
		temp = ma[a];
		sum -= (temp * a);
		sum += (temp * b);

		if (ma.find(b) != ma.end())
			ma[b] = ma[b] + temp;
		else
			ma.insert({b, temp});
		ma.erase(a);
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 7516
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();
        int c = sc.nextInt();
        int count = 0;


       for(int x = a ; x <= b ; x++){
    	   if(c % x == 0)
    		   count++;

       }


    		   System.out.println(count);


    	   }


}




Measured memory_bytes: 26328
# -*- coding:utf-8 -*-

def solve():
    A, B = list(map(int, input().split()))
    S = input()

    for i in range(len(S)):
        if i == A:
            if S[A] == "-":
                continue
            print("No")
            return 
        try:
            int(S[i])
        except:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N, K;
	ll sum=0;
	cin >> N >> K;
	vector<int> H(N);
	rep(i, N) cin >> H.at(i);
	sort(H.begin(), H.end(), greater<int>());
	rep(i, N)
	{
		if(K==0) sum += H.at(i);
		else K--;
	}
	
	cout << sum << endl;
	return 0;
}


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

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

  if (a > d) cout << '0' << endl;
  else if (b < c) cout << '0' << endl;
  else if (a >= c && a <= d && b >= d) cout << d - a << endl;
  else if (b >= c && b <= d && a <= c) cout << b - c << endl;
  else if (a < c && b > d) cout << d - c << endl;
  else if (a > c && b < d) cout << b - a << endl;

  return 0;
}

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

struct Node {
    int p, bro, l, r;
    bool ok;
};
Node u[26];
int n;
int pre, ino, pos;
void preorder(int node){
    if(pre == n){
        printf("\n");
        rep(i,n)u[i].ok = 0;
        return ;
    }

    if(!u[node].ok){
        //cout << "x";
        printf(" %d", node);
        u[node].ok = 1;
        pre++;
    }
    int left = u[node].l, right = u[node].r;
    if(left != -1 && !u[left].ok){
        //cout << "y";
        preorder(u[node].l);
    }
    else if(right != -1 && !u[right].ok){
        preorder(u[node].r);
    }
    else if(u[node].p != -1)preorder(u[node].p);
    else {
        printf("\n");
        rep(i,n)u[i].ok = 0;
        return;
    }
}
void inorder(int node){
    if(ino == n){
        rep(i,n)u[i].ok = 0;
        return;
    }

    if(u[node].l != -1 && !u[u[node].l].ok)inorder(u[node].l);
    else if(u[node].r != -1 && !u[u[node].r].ok){
        printf(" %d", node);
        u[node].ok = 1;
        ino++;
        inorder(u[node].r);
    }
    else {
        if(!u[node].ok){
            printf(" %d", node);
            u[node].ok = 1;
            ino++;
        }

        if(u[node].p != -1)inorder(u[node].p);
        else {
            rep(i,n)u[i].ok = 0;
            return;
        }
    }
}
void postorder(int node){
    if(pos == n){
        printf("\n");
        return;
    }
    if(u[node].l != -1 && !u[u[node].l].ok)postorder(u[node].l);
    else if(u[node].r != -1 && !u[u[node].r].ok)postorder(u[node].r);
    else if(u[node].bro != -1){
        printf(" %d", node);
        u[node].ok = 1;
        pos++;
        if(!u[u[node].bro].ok)postorder(u[node].bro);
        else postorder(u[node].p);
    }
    else {
        printf(" %d", node);
        u[node].ok = 1;
        pos++;
        if(u[node].p != -1)postorder(u[node].p);
        else {
            printf("\n");
            return;
        }
    }
}
int main(){
    cin >> n;
    rep(i,n){
        u[i].p = u[i].bro = -1;
        u[i].ok = 0;
    }

    rep(i,n){
        int id, left, right;
        cin >> id >> left >> right;
        u[id].l = left;
        u[id].r = right;
        if(left != -1){
            u[left].p = id;
            u[left].bro = right;
        }
        if(right != -1){
            u[right].bro = left;
            u[right].p = id;
        }
    }

    int root;
    rep(i,n)if(u[i].p == -1)root = i;

    printf("Preorder\n");
    preorder(root);
    printf("Inorder\n");
    inorder(root);
    printf("\n");
    printf("Postorder\n");
    postorder(root);

    return 0;
}


Measured memory_bytes: 3160
#pragma comment(linker, "/STACK: 2000000")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define double long double
#define x first
#define y second
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
#define PI 3.14159265358979
const ll mod=1000000007;
int n, ans[10020];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    for(int i=1; i<=100; i++){
        for(int j=1; j<=100; j++){
            for(int k=1; k<=100; k++){
                int val=(i*i+j*j+k*k+i*j+j*k+k*i);
                if(val<=10000) ans[val]++;
            }
        }
    }
    cin>>n;
    for(int i=1; i<=n; i++) cout<<ans[i]<<" ";
}



Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main(){
    string c;
    cin>>c;
    string a="a";
    string e= "e";
    string i= "i";
    string o= "o";
    string u= "u";
    if (c==a||c==e||c==i||c==o||c==u){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }   
}
    





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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,K;
    Scd2(N,K);

    double ans = 0.0;
    Repe(i,N+1,1){
        double tmp = 1.0;
        double po = 1.0;
        while( i * po < K ){
            po *= 2.0;
        }
        ans += tmp/po;
    }

    double n = N;
    ans /= n;
    printf ("%1.12lf\n", ans);

    return 0;
}



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

int main(){
    string s; cin >> s;
    int cnt0=0, cnt1=0;
    for(int i = 0; i < s.length(); i++){
        if(i%2){
            if(s[i]=='0') cnt0++;
            else cnt1++;
        }else{
            if(s[i]=='0') cnt1++;
            else cnt0++;
        }
    }
    cout << min(cnt0, cnt1) << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  long long int a[n],s[n];
  long long int cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    s[0]=a[0];
    if(i)
      s[i]=s[i-1]+a[i];
    if(s[i]==0)
      cnt++;
  }
  
  
  sort(s,s+n);
  long long int same=0;
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
      same++;
      cnt+=same;
    }
     else same=0;
    
  }
  
  cout<<cnt<<endl;
  
  
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
    // Here your code !
    int n;
    int Min = 1000000;
    int Max = -1000000;
    long int Sum = 0;
    int a;
    int i;
    scanf("%d", &n);
    for( i = 0; i < n; ++i){
        scanf("%d", &a);
        if( a < Min){
            Min = a;
        }
        if( a > Max){
            Max = a;
        }
        Sum += a;
    }
    printf("%d %d %ld\n", Min, Max, Sum);
    return 0;
}

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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  if ( B-A+1 >= 2*K ) {
    for ( int i = 0; i < K; i++ ) {
      cout << A+i << endl;
    }
    for ( int i = K-1; i >=0 ; i-- ) {
      cout << B -i << endl;
    }
  }else {
    for ( int i = A; i <= B; i++ ) {
      cout << i << endl;
    }
  }
  return 0;
}


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


void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,k;
  scanf("%d%d",&n,&k);

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

  for(int i=0;i<n-k;i++){
    if(A[i]<A[i+k]){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }

  return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = a[0];
  reps1(i, n) {
    ll b = a[i];
    while (true) {
      ll tmp = b;
      b = ans % b;
      ans = tmp;
      if (b == 0) break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
    v = input().strip()
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] not in ('R', 'U', 'D'):
                print('No')
                return
        elif i % 2 == 1:
            if v[i] not in ('L', 'U', 'D'):
                print('No')
                return
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  scanf("%d\n", &n);
  vector<double> p(n);
  rep(i, n) {
    scanf("%lf", &p[i]);
  }

  vector<vector<double>> dp(n+1, vector<double>(n+1));

  dp[0][0] = 1;

  rep(i, n) {
    rep(j, i+1) {
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double ans = 0;
  rep(i, n+1) {
    if (i > n-i) {
      ans += dp[n][i];
    }
  }

  printf("%.10lf\n", ans);
}


Measured memory_bytes: 70784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.IntPredicate;

public class Main {

    static int A;
    static int B;
    static int C;

    public static void main(String[] args) {
        FastScanner fc = new FastScanner(System.in);
        A = fc.nextInt();
        B = fc.nextInt();
        C = fc.nextInt();

        System.out.println(solve());
    }

    static long solve() {
        if( A % 2 == 0 || B % 2 == 0 || C % 2 == 0 ) {
            return 0;
        } else {
            long ab = (long)A * B;
            long ac = (long)A * C;
            long bc = (long)B * C;
            return Math.min(Math.min(ab, ac), bc);
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204