akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,buk[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		++buk[nxi()];
	}
	int ans=0,even=0;
	for(int i=1; i<N; ++i){
		if(buk[i]>1){
			ans+=buk[i]-1;
			even^=(buk[i]&1)==0;
		}
	}
	printf("%d\n",n-ans-even);
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int n, d[100];
	int i, j;
	int total;
	
	scanf("%d", &n);
	
	total=0;
	scanf("%d", &d[0]);
	
	for(i=1; i<n; i++){
		scanf("%d", &d[i]);
		
		for(j=0; j<i; j++){
			total += d[j] * d[i];
		}
	}
	
	printf("%d\n", total);
	
	return 0;
}

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

int main()
{
    int N,k;
    cin >> N >> k;
    int r = 0;
    int sum = 0;
    char a[N + 1];
    for (int i = 1; i <= N; i++)
        cin >> a[i];
    for (int i = 1; i <= N; i++)
    {
        if (a[i] == a[i + 1])
            sum++;
        if ((a[i + 1] != a[i]) && (i != N))
            r++;
    }
    if ((r + 1) / 2 > k)
        sum += k * 2;
    else
        sum = N - 1;
        
    cout << sum << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			long[] a = new long[n];
			// 正の数の配列
			long[] positives = IntStream.range(0, n).mapToLong(i -> a[i] = scanner.nextLong()).filter(l -> l > 0)
					.sorted().toArray();
			// 負の数の配列
			long[] negatives = Arrays.stream(a).filter(l -> l < 0).sorted().toArray();
			// 0の数
			int zeroCount = n - positives.length - negatives.length;
			if (k > (positives.length + negatives.length)) {
				System.out.println(0L);
				return;
			}
			long answer = 1L;
			if (n == k) {
				// ずべての数を使う場合
				for (int i = 0; i < n; i++) {
					answer = answer * a[i] % MOD;
				}
			} else if ((positives.length == 0) && (1 == (k & 1))) {
				// 正の数が存在しない、かつ、掛け算の数が奇数場合
				if (zeroCount > 0) {
					// 0が存在するなら、0
					answer = 0L;
				} else {
					// 0が存在しないなら、絶対値の小さい負の数をk個かける
					for (int i = negatives.length - k; i < negatives.length; i++) {
						answer = answer * negatives[i] % MOD;
					}
				}
			} else {
				int positiveIndex = positives.length - 1, negativeIndex = 0;
				while (k > 0) {
					if (1 == (k & 1)) {
						// kが奇数の場合、正の数の掛け算をする
						answer = answer * positives[positiveIndex--] % MOD;
						k--;
					} else {
						// kが偶数の場合、正の数か負の数を2つ掛け算する
						if ((positiveIndex > 0) && (negativeIndex < negatives.length - 1)) {
							if (positives[positiveIndex] * positives[positiveIndex - 1] >= negatives[negativeIndex]
									* negatives[negativeIndex + 1]) {
								answer = answer * positives[positiveIndex--] % MOD;
								answer = answer * positives[positiveIndex--] % MOD;
							} else {
								answer = answer * negatives[negativeIndex++] % MOD;
								answer = answer * negatives[negativeIndex++] % MOD;
							}
						} else if (positiveIndex > 0) {
							answer = answer * positives[positiveIndex--] % MOD;
							answer = answer * positives[positiveIndex--] % MOD;
						} else {
							answer = answer * negatives[negativeIndex++] % MOD;
							answer = answer * negatives[negativeIndex++] % MOD;
						}
						k -= 2;
					}
				}
			}
			answer = (answer + MOD) % MOD;
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 65820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		if(a == 0) {
			System.out.println(b / x + 1);
		} else {
			System.out.println((b / x + 1) - ((a - 1) / x + 1));
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;
using ll = unsigned long long;

const int INF = 1 << 25;

struct Graph {
    Graph(int N) : size(N) { path.resize(N); };
    void span(int u, int v) { path[u].push_back(v); }
    vector<int> operator[](int v) { return path[v]; };

    int size;
    vector<vector<int>> path;
};

int N;
Graph tree(0);

vector<int> bfs(vector<int> rs) {
    vector<int> dist(N, INF);
    queue<int> que;

    for (int r : rs) {
        dist[r] = 0;
        que.push(r);
    }

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : tree[v]) {
            if (dist[sv] <= dist[v]) continue;
            dist[sv] = dist[v] + 1;
            que.push(sv);
        }
    }
    return dist;
}

tuple<int, int, int> diameter() {
    auto dist = bfs({0});
    int l = max_element(dist.begin(), dist.end()) - dist.begin();
    dist = bfs({l});
    int r = max_element(dist.begin(), dist.end()) - dist.begin();
    return make_tuple(dist[r], l, r);
}

// centerを根としたとき、必要な葉の数
ll leaf_num(vector<int> center) {
    auto dist = bfs(center);
    vector<ll> hie(N, 0);
    // 各深さでの、子の数の最大値

    for (int v = 0; v < N; ++v) {
        ll cnt = 0;
        for (int sv : tree[v]) {
            if (dist[sv] > dist[v]) ++cnt;
        }
        hie[dist[v]] = max(hie[dist[v]], cnt);
    }

    ll ret = center.size();
    for (int d = 0; d < N; ++d) {
        if (hie[d] == 0) break;
        ret *= hie[d];
    }
    return ret;
}

int main() {
    cin >> N;

    tree = Graph(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        tree.span(u, v);
        tree.span(v, u);
    }

    int D, l, r;  // 直径とその両端点
    tie(D, l, r) = diameter();
    cout << D / 2 + 1 << " ";

    // 両端点の距離から木の中心を求める
    auto ldist = bfs({l}), rdist = bfs({r});
    vector<int> center;
    for (int v = 0; v < N; ++v) {
        if (ldist[v] + rdist[v] == D && abs(ldist[v] - rdist[v]) <= 1) center.push_back(v);
    }

    ll ans = leaf_num(center);
    if (center.size() == 1) {
        // 中心が2つになるようにすると葉の数が減ることがある
        int c = center[0];
        for (int sv : tree[c]) {
            ans = min(ans, leaf_num({c, sv}));
        }
    }

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


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

ll MOD = 1e9 + 7;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val > MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

int N, K;
constexpr int maxN = 50;
constexpr int maxK = maxN * maxN;
Fp dp[maxN+1][maxK+1][maxN+1];

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N >> K;
  for (int k = 0; k <= K; k++)  dp[0][0][0] = 1;
  for (int n = 0; n < N; n++) {
    for (int k = 0; k <= K; k++) {
      for (int r = 0; r <= n; r++) {
	ll kP = k + 2*r;
	if (kP > K) continue;
	Fp x = dp[n][k][r];
	if (0 <= r-1 && n+1+r-1 <= N)  dp[n+1][kP][r-1] += Fp(r*r) * x;
	if (n+1+r   <= N)              dp[n+1][kP][r]   += Fp(2*r + 1) * x;
	if (n+1+r+1 <= N)              dp[n+1][kP][r+1] += x;
      }
    }
  }
  if (0) {
    for (int n = 0; n <= 3; n++) {
      for (int k = 0; k <= 4; k++) {
	for (int r = 0; r <= 3; r++) {
	  cout << "dp[" << n << "][" << k << "][" << r << "] = " << dp[n][k][r]
	       << endl;
	}
      }
    }
  }

  cout << dp[N][K][0] << endl;

  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String _n = sc.nextLine();
        String b = "";
        int num = -1;
        for (String s : _n.split("")) {
            if (!s.equals(b)) {
                b = s;
                num += 1;
            }
        }
        System.out.println(num);
    }
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = N / 10;
    ll tmp = 50;
    while (N >= tmp) {
        ans += N / tmp;
        tmp *= 5;
    }

    
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a),greater<int>());
    rep(i,0,k){
      if(i<n)
        a[i]=0;
    }
    ll x=0;
    rep(i,0,n)
      x+=a[i];
    cout<<x<<nl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
cout << (n-2)*180 << endl;}

Measured memory_bytes: 3568
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'


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

	int n;
	cin >> n;
	vi vec(n);
	rep(i, 0, n)
		cin >> vec[i];

	int mx = 0;

	rep(i, 0, n)
	{
		int j = i + 1;
		int cnt = 0;
		int prev = vec[i];
		while (j < n && vec[j] <= prev)
		{
			prev = vec[j];
			j++, cnt++;
		}
		mx = max(mx, cnt);
		i = j - 1;
	}

	cout << mx << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>=b)
    for(int i=0;i<a;i++)
      cout<<b;
  else
   for(int i=0;i<b;i++)
      cout<<a;
  cout<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
// #include<fstream>
// #include<iomanip>
using namespace std;

int main(){
    long long N, K, A;
    long long ans = 0, ans_1 = 0;
    long long champ = 0;
    double ok, ng, mid;
    long long tmp;
    long long sum = 0;
    std::cin >> N >> K;
    // ifstream ifs("./handmade11");
    // ifs >> N >> K;
    vector<long long> A_list(N);
    for(int i = 0; i < N; i++){
        std::cin >> A;
        // ifs >> A;
        A_list[i] =  A;
        sum = sum + A;
        if(A > champ){
            champ = A;
        }
    }
    // ifs.close();

    if(sum <= K){
        ans = 1;
        goto all_1;
    }
    //ここから二分探索
    ng = 0;
    ok = champ;

    while(ok - ng > 0.01){
        mid = (ok + ng)/2.0;
        // std::cout << std::setprecision(20) << ng << " " << ok << "\n";
        tmp = 0;
        for(long long i = 0; i < N; i++){
            tmp = tmp + ceil(A_list[i]/mid) - 1;
        }
        if(tmp <= K){
            ok = mid;
        }else{
            ng = mid;
        }
    }
        
    ans = (long long)ceil(ok);
    ans_1 = ans -1;
    tmp = 0;
    for(long long i = 0; i < N; i++){
        // std::cout << A_list[i] << " " << ceil(A_list[i]/((double)ans_1)) << "\n";
        tmp = tmp + round(ceil(A_list[i]/((double)ans_1))) - 1;
    }
    if(tmp <= K){
        // std::cout << "mmm";
        ans = ans_1;
    }
    all_1:

    
    
    std::cout << ans;


}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define SWAP(x, y) do { char z = y; y = x; x = z; } while (0)
int main(void)
{
    string t;
    cin >> t;
    string a = t;
    if (t.length() == 1) {
        if (t[0] == '?') t.replace(0,1,"D");
        cout << t << endl;
        return 0;
    }

    if (t[0] == '?')  {
        t.replace(0, 1, "D");
    }

    for (int i=1;i<t.length() - 1;i++) {
        if(t[i] == '?') {
            if(t[i - 1] == 'P') {
                t.replace(i, 1, "D");
            } else if (t[i+1] == 'D') {
                t.replace(i, 1, "P");
            } else t.replace(i, 1, "D");
        }
    }
    if (t[t.length()-1] == '?') {
        t.replace(t.length() - 1, 1, "D");
    }
    cout << t << endl;
}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b)  FOR(i,0,b)
#define X first
#define Y second
#define F first
#define S second
#define PB(a) push_back(a)
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef pair<ut,ut> pr;
typedef pair<pr,ut> ppr;
typedef priority_queue<ppr,vector<ppr> > PQ;
typedef vector<pr> Vpr;
typedef vector<int> VI;
const int SIZE=1<<17;
const LL INF=1LL<<60;
const LL def=-INF;
Vpr flor;
LL segA[SIZE<<1],segB[SIZE<<1];
PQ qu;
LL ans=0;
LL N,H;
LL get(int s,int e,int a,int b,int now){
	if(a<=s && e<=b) return segA[now]+segB[now];
	else if(e<a||b<s) return def;
	else
		return segA[now]+max(get(s,(s+e)/2,a,b,now*2),get((s+e+1)/2,e,a,b,now*2+1));
}
LL get(int a,int b){return get(1,SIZE,a,b,1);}
void add(int s,int e,int a,int b,LL p,int now){
	if(a<=s&&e<=b) segA[now]+=p;
	else if(e<a||b<s) return;
	else{
		add(s,(s+e)/2,a,b,p,now*2);
		add((s+e+1)/2,e,a,b,p,now*2+1);
		segB[now]=max(segA[now*2]+segB[now*2],segA[now*2+1]+segB[now*2+1]);
	}
}
void add(int a,int b,LL p){add(1,SIZE,a,b,p,1);}
void healing(int x){
	static int least=0;
	while(get(x,x)<=0 && !qu.empty()){
		
		int now=qu.top().F.S;
		LL potencial=qu.top().F.F;
		bool isLast=qu.top().S;
		qu.pop();
		if(least>now) continue;
		least=now;
		if(isLast){
			add(now,N,potencial);
			ans++;	

		} 
		else{
			LL times=min((H-get(now,now))/potencial,(-get(x,x)+potencial)/potencial);
			if(times==0) qu.push(ppr(pr(H-get(now,now),now),1));
			else{
				add(now,N,times*potencial);
				ans+=times;
				qu.push(ppr(pr(potencial,now),0));
			}
		}
	}
}
int main(){
	LL a,b;
	cin >> N >> H;
	add(1,N,H);
	FOR(i,1,N){
		scanf("%lld%lld",&a,&b);
		if(get(i,i)<=0)
			healing(i);
		qu.push(ppr(pr(b,i),0));
		add(i+1,N,-a);
	}
	if(get(N,N)<=0)
		healing(N);
	cout << ans << endl;

}

Measured memory_bytes: 4128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,d,a;
	cin>>n>>d>>a;
	vector<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		ll x,h;
		cin>>x>>h;
		h=(h+a-1)/a;
		ch.push_back(make_pair(x,h));
	}
	sort(ch.begin(),ch.end());
	ll nowx=ch[0].first+2*d;
	ll ans=0;
	ans+=ch[0].second;
	ll nowb=ch[0].second;
	queue<pair<ll,ll>>q;
	q.push(make_pair(nowx,nowb));
	for(ll i=1;i<n;i++){
//		cout <<ans<<" "<<nowb<<endl;
		ll nexx=ch[i].first;
		if(q.size()!=0){
			ll nowx=q.front().first;
			while(nowx<nexx){
				nowb-=q.front().second;
				q.pop();
				if(q.size()==0){
					break;
				}
				nowx=q.front().first;
			}
		}
		ll nexb=ch[i].second;
		if(nexb>nowb){
			ans+=nexb-nowb;
			q.push(make_pair(nexx+2*d,nexb-nowb));
			nowb=nexb;			
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 7836
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;

int main()
{

    fastio
int x;
cin>>x;
int arr[x];
int ans=0;
for( int i=0;i<x;i++)
{
    cin>>arr[i];
    ans=__gcd(ans,arr[i]);
}
cout<<ans<<endl;


    return 0;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;

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

int main(){
    int M,T,P,R;
    while(cin>>M>>T>>P>>R && M){
        vector<vector<vector<pair<int,bool>>>> v(T,vector<vector<pair<int,bool>>>(P));
        rep(i,R){
            int m,t,p,j;
            cin>>m>>t>>p>>j;
            t--,p--;
            v[t][p].push_back(make_pair(m,j==0));
        }
        // solved, time, id
        vvi rank(T);
        rep(i,T){
            int s = 0;
            int t = 0;
            rep(j,P)if(v[i][j].size()!=0 && v[i][j].back().second){
                s++;
                t+=v[i][j].back().first;
                t+=20*(v[i][j].size()-1);
            }
            rank[i] = vi{s,t,i+1};
        }
        sort(rank.begin(),rank.end(),[](const vi& a, const vi& b){
                if(a[0]!=b[0]) return a[0]>b[0];
                if(a[1]!=b[1]) return a[1]<b[1];
                else return a[2]>b[2];
            });
        cout << rank[0][2];
        rep(i,T-1){
            if(rank[i+1][0]==rank[i][0] && rank[i+1][1]==rank[i][1]){
                cout << "=";
            }
            else cout << ",";
            cout << rank[i+1][2];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1252
#include <iostream> //cout
#include <vector> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


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

    if(S > W){
        cout << "safe" << endl;
    }
    else{
        cout << "unsafe" << endl;
    }
    
    
}


Measured memory_bytes: 3624
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

ans = sum(b)
for i in range(n-1):
  if(a[i]+1==a[i+1]): ans+= c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int,input().split()))
memo = [-1 for i in range(n)]

def dp(i):
    if i == 0:
        return 0
    elif i >= 2:
        if memo[i] != -1:
            return memo[i]
        else:
            memo[i] = min(dp(i-2) + abs(h[i]-h[i-2]), dp(i-1) + abs(h[i]-h[i-1]))
            return memo[i]
    else:
        return abs(h[1]-h[0])

print(dp(n-1))

Measured memory_bytes: 57396
from collections import defaultdict

n = int(input())
A = list(map(int, input().split()))

accum = [0] * (n + 1)

for i in range(n):
  accum[i + 1] = accum[i] + A[i]
  
box = defaultdict(int)

for i in accum:
  box[i] += 1
  
ans = 0
for k, v in box.items():
  ans += v * (v -1) // 2
  
print(ans)

Measured memory_bytes: 41672
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
x=[]
di=[0,0,0,1,1,1,2,2,2]
dj=[0,1,2,0,1,2,0,1,2]
from collections import defaultdict,Counter
x=defaultdict(int)
for a,b in ab:
    for ti,tj in zip(di,dj):
        if 3<=a+ti<=h and 3<=b+tj<=w:
            x[(a+ti,b+tj)]+=1

c=Counter(x.values())
print((h-2)*(w-2)-sum(c.values()))
for i in range(1,10):
    print(c[i])
    

Measured memory_bytes: 170132
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int a; cin >> a;
  COUT(a + pow(a,2) + pow(a,3));
  return 0;
}

Measured memory_bytes: 4304
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int X = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    int B = int.Parse(input[2]);
    
    if ((B - A) <= 0) {
      Console.WriteLine("delicious");
    } else if ((B - A) < (X + 1)) {
      Console.WriteLine("safe");
    } else {
      Console.WriteLine("dangerous");
    }
  }
}


Measured memory_bytes: 11092
#入力
l = input()
w,h,x,y,r = list(map(int, l.split()))


#水平方向、垂直方向を同時に判定
if x - r >= 0 and x + r <= w and y - r >= 0 and y + r <= h:
    print("Yes")
 
else:
    print("No")



Measured memory_bytes: 5596
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[20];
int dp[20][110000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)scanf("%d",c+i);
		int L=0;
		int R=110000;
		while(L+1<R){
			int M=(L+R)/2;
			for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)
				dp[i][j]=99999999;
			dp[0][0]=0;
			for(int i=0;i<a;i++)for(int j=0;j<=b;j++){
				if(dp[i][j]>9999999)continue;
				if(dp[i][j]<M&&j+c[i]<=b)dp[i][j+c[i]]=min(dp[i][j+c[i]],dp[i][j]+1);
				dp[i+1][j]=0;
			}
			if(dp[a][b]<9999999){
				R=M;
			}else L=M;
		}
		printf("%d\n",R);
	}
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
long long n,k,anss,qwq;
int main()
{
	cin>>n>>k;
	anss=0;
	qwq=n/k;
	anss+=qwq*qwq*qwq;
	if(k%2==0)
	{
		qwq=(n+(k/2))/k;
		anss+=qwq*qwq*qwq;
	}
	cout<<anss;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

using ll = long long;

int main() {
    ll sum = 0;

    int n;

    cin >> n;

    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  sort(va.begin(), va.end());
  cout << va.back() - va.front() << '\n';

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	
	int c[100005]={};//from -1

	for(int i=1;i<=n;i++)
	{
		int a;
		cin >> a;
		for(int i=1;i<=3;i++)
			c[a+i-2]++;
	}

	sort(c,c+100005);
	cout << c[100004] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


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


    ll n,m,x;
    cin>>n>>m>>x;
    ll ans = 1e18;
    ll c[n],a[n][m];
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int bit=0;bit<(1<<n);bit++){
        ll ret = 0;
        ll now[m]={};
        for(int i=0;i<n;i++){
            if((1<<i) & bit){
                ret += c[i];
                for(int j=0;j<m;j++){
                    now[j] += a[i][j];
                }
            }
        }
        bool pos = 1;
        for(int i=0;i<m;i++){
            if(now[i] < x)pos=false;
        }
        if(pos)chmin(ans,ret);
    }
    if(ans > 1e15)ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 3644
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = int.Parse(line[1]);
        var e = int.Parse(line[2]);
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var s = Array.ConvertAll(line2, int.Parse);
        for (int i = 0; i < n; i++)
        {
            var a0 = Math.Max((t - e) / s[i], 1);
            var a1 = (t + e) / s[i] + 1;
            for (int j = a0; j <= a1; j++)
                if (s[i] * j >= t - e && s[i]  * j<= t + e) { Console.WriteLine(i + 1); goto end; }
        }
            Console.WriteLine(-1);
            end:;
    }
}

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

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

  if(W>=S){
    out("unsafe");
  }
  else{
    out("safe");
  }

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll a,b,n;
  cin>>a>>b>>n;

  auto calc = [&](ll x){
    return a*x/b-a*(x/b);
  };

  ll ans = 0;
  if(n>=b){
    ans = calc(b);
    for(ll i=1;i<1e4&&i+b<=n;++i)chmax(ans,calc(b+i));
    for(ll i=1;i<1e4&&b-i>=0;++i)chmax(ans,calc(b-i));
  }else{
    ans = calc(n);
    for(ll i=1;i<1e6&&b-i>=0;++i)chmax(ans,calc(n-i));
  }
  cout<<(ans)<<endl;

}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;
typedef long long ll;


/* constant */
const ll inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}




signed main(){

    int a, b, x;
    cin >> a >> b >> x;

    if(a <=x and a + b >= x){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
        
    }



    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  int n,x;cin>>n>>x;
  int a[100];rep(i,n)cin>>a[i];
  sort(a,a+n);
  int ans = 0;
  rep(i,n){
    x -= a[i];
    if(x>=0 && i!=n-1)ans++;
    else if(x == 0 && i == n-1)ans++;
    else break;
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))

c = collections.Counter(a).most_common()
cnt = len(c)
i = 1
ans = 0
while cnt > k:
    cnt -= 1
    ans += c[-i][1]
    i += 1

print(ans)


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

using namespace std;

long d[11111][111], e[11111][111];
int p = 1e9 + 7;
int main() {
	string k;
	int D;
	cin >> k >> D;
	d[k.length()][0] = e[k.length()][0] = 1;
	for (int i = k.length(); i--;) {
		for (int j = 0; j < D; j++) {
			int m = k[i] - '0';
			d[i][(j + m) % D] = (d[i][(j + m) % D] + d[i + 1][j]) % p;
			while (m--)
				d[i][(j + m) % D] = (d[i][(j + m) % D] + e[i + 1][j]) % p;
			for (m = 10; m--;)
				e[i][(j + m) % D] = (e[i][(j + m) % D] + e[i + 1][j]) % p;
		}
	}
	cout << (d[0][0] - 1 + p) % p << endl;
	return 0;
}


Measured memory_bytes: 18688
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() { 
    ll t;
    std::cin >> t;
    for (int ii = 0; ii < t; ii++) {
        ll a,b,c,d;
        std::cin >> a>>b>>c>>d;
        
        if(a<b){
            std::cout << "No" << std::endl;
            continue;
        }
        
        if(b>d){
            std::cout << "No" << std::endl;
            continue;
        }
        
        if(b<=c){
            std::cout << "Yes" << std::endl;
            continue;
        }
        if( b-gcd(b,d)+a%gcd(b,d) >c%b ){
            std::cout << "No" << std::endl;
        }else{
            std::cout << "Yes" << std::endl;
        }
    }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static int[] counter=new int[26];
	private static ArrayList<String> str=new ArrayList<String>();
	public static void main(String[] args){
		try{
			while(true){
				str.add(sc.next());
			}
		}catch(NoSuchElementException e){}
		for(int i=0;i<str.size();i++){
			getchar(str.get(i));
		}
		show();
	}
	private static void getchar(String s){
		for(int i=0;i<s.length();i++){
			countup(s.charAt(i));
		}
	}
	private static void countup(char c){
		if(Character.isLowerCase(c)){
			int num=c-'a';
			counter[num]++;
		}
		if(Character.isUpperCase(c)){
			char ch=Character.toLowerCase(c);
			int num=ch-'a';
			counter[num]++;
		}
	}
	private static void show(){
		for(int i=0;i<26;i++){
			System.out.println((char)(i+'a')+" : "+counter[i]);
		}
	}
}

Measured memory_bytes: 26048
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0;
string s;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  ll a[5];
  double x;

  cin >> n;

  a[3] = n - (n / 10) * 10;
  a[2] = (n - (n / 100) * 100 - a[3]) / 10;
  a[1] = (n - (n / 1000) * 1000 - a[3] - a[2] * 10) / 100;
  a[0] = n / 1000;

  FOR(i, 0, 2) {
	FOR(j, 0, 2) {
	  FOR(k, 0, 2) {
		sum = 0;
		sum += a[0];
		if (i) { sum += a[1]; }
		else { sum -= a[1]; }
		if (j) { sum += a[2]; }
		else { sum -= a[2]; }
		if (k) { sum += a[3]; }
		else { sum -= a[3]; }
		if (sum == 7) {
		  cout << a[0];
		  if (i) { cout << "+" << a[1]; }
		  else { cout << "-" << a[1]; }
		  if (j) { cout << "+" << a[2]; }
		  else { cout << "-" << a[2]; }
		  if (k) { cout << "+" << a[3]; }
		  else { cout << "-" << a[3]; }
		  cout << "=7" << endl;
		  return 0;
		}
	  }
	}
  }
  
  return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<long long>data(N);
  for(int i=0; i<N; i++) {
    cin >> data.at(i);
  }
  for(int i=0; i<N-K; i++) {
    if (data.at(i) >= data.at(i+K)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 4816
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  static int a[100000],A[100000];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    A[i]=a[i];
  }
  sort(A,A+n);
  int b=0,c=0;
  for(int i=0;i<n;i++){
    int k=lower_bound(A,A+n,a[i])-A;
    if(i%2==0&&k%2==1){
      b++;
    }
    if(i%2==1&&k%2==0){
      c++;
    }
  }
  printf("%d\n",min(b,c));
  return 0;
}



Measured memory_bytes: 896
import sys
rline = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(rline())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b, c = map(int, rline().split())
    a -= 1
    b -= 1
    graph[a].append([b, c])
    graph[b].append([a, c])
to_k = [0] * N


def dfs(node, parent, dist):
    to_k[node] = dist
    
    for child, d in graph[node]:
        if child != parent:
            dfs(child, node, dist + d)


def solve():
    Q, K = map(int, rline().split())
    K -= 1
    dfs(K, -1, 0)
    for _ in range(Q):
        x, y = map(lambda z: int(z) - 1, rline().split())
        print(to_k[x] + to_k[y])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 211632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char S[12];

int main() {
  scanf("%s", S);

  Int res = 0;
  int n = strlen(S);
  for (int i = 0; i < (1 << (n - 1)); ++i) {
    Int cur = 0;
    for (int j = 0; j < n; ++j) {
      cur = cur * 10 + S[j] - '0';
      if (i & (1 << j)) {
        res += cur;
        cur = 0;
      }
    }
    res += cur;
  }

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

  return 0;
}


Measured memory_bytes: 764
input = chomp(readline())

function isbase(c)
    if c == 'A'
        true
    elseif c == 'C'
        true
    elseif c == 'G'
        true
    elseif c == 'T'
        true
    else
        false
    end
end

xs = zeros(Int, length(input))
n = length(xs)

for (i, c) in enumerate(input)
    if isbase(c)
        xs[i] = 1
    end
end

ys = Int[]

val = 0
for i = 1:n
    if xs[i] == 1
        val += 1
        if i+1 > n || xs[i+1] == 0
            push!(ys, val)
            val = 0
        end
    else
        if i+1 > n
            push!(ys, val)
            val = 0
        end
    end
end

print(max(ys...))

Measured memory_bytes: 109788
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
  // freopen("input.txt","r",stdin);
    long long int n1,m1,t;
 //   cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=1,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m,l=0,r=0,k,min1=10000000000000,max2=-100;
 cin>>n>>k;
 vector<pair<long long int,long long int>>v;
 for(i=0;i<n;i++)
 {
 	cin>>p>>l;
 	v.push_back(make_pair(p,l));
 }
 sort(v.begin(),v.end());
 for(i=0;i<n;i++)
 {
 	if(v[i].second<=k)
 	break;
 }
 if(i==n)
 cout<<"TLE";
 else
 cout<<v[i].first;
 
 
    }
 return 0;
}


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

using namespace std;

//#define MD 100010

int main(){
    long int n,x;
    cin>>n>>x;
    vector<long int> v(n);
    long int ans=n;
    for(int i=0;i<n;i++){
        cin>>v[i];
        x-=v[i];
    }
    sort(v.begin(),v.end());
    while(1){
        x-=v[0];
        if(x>=0){
            ans++;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
ll a[101010];
ll sum,res;

int main(){
	cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  rep(i,n)sum+=a[i];
  for(ll i=0;i<n;i+=2)res+=a[i];
  cout<<abs(2*res-sum)<<endl;
	return 0;
}


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

int main() {
  int a;
  cin >> a;
  int k=-1;
  for(int i=1;i<10;i++){
    if(a%i == 0 && a/i <10){
      cout << "Yes" << endl;
      k = 0;
      break;
    }
  }
  if(k == -1){
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main()
{

    int N;
    cin >> N;
    string S;
    cin >> S;
    long long  ans = 0;
    deque<long> R(N), G(N), B(N);
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'R')
        {
            R[i]++;
        }
        else if (S[i] == 'G')
        {
            G[i]++;
        }
        else
        {
            B[i]++;
        }
    }

    for (int i = N - 1; i > 0; i--)
    {
        R[i - 1] = R[i] + R[i - 1];
        G[i - 1] = G[i] + G[i - 1];
        B[i - 1] = B[i] + B[i - 1];
    }

    for (int i = 0; i < N ; i++)
    {

        for (int j = i + 1; j < N ; j++)
        {
            if (S[j] != S[i])
            {
                if (S[i] == 'R' && S[j] == 'G' || S[i] == 'G' && S[j] == 'R')
                {
                    ans += B[j];
                    if (S[j + (j - i)] == 'B')
                    {
                        ans--;
                    }
                }
                else if (S[i] == 'R' && S[j] == 'B' || S[i] == 'B' && S[j] == 'R')
                {
                    ans += G[j];
                    if (S[j + (j - i)] == 'G'){
                        ans--;
                    }
                }
                else
                {
                    ans += R[j];
                    if (S[j + (j - i)] == 'R'){ 
                        ans--;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
	int a = 0, n = 0, x = 0;
	
	while (1) {
		cin >> n >> x;
		
		if (n == 0 && x == 0)
			break;
		
		for (int i = 1;i <= n;i++) {
			for (int j = i+1;j <= n;j++) {
				for (int k = j + 1;k <= n;k++) {
					if (i + j + k == x)
						a++;
				}
			}
		}
		cout << a << endl;
		a = 0;
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    long long div = 1;
    while (div < k) div = div << 1;
    long long ans = 0;
    long long tmp;
    for (int i = 1; i<=n; i++){
        tmp = 1;
        while (tmp * i < k) tmp = tmp << 1;
        ans += div / tmp;
    }
    div *= n;
    cout << setprecision(11) << (double)(1.0f*(double)ans/(double)div) << endl;
}



Measured memory_bytes: 256