akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int main()
{
  int result = 0;
  int n;
  std::cin >> n;

  std::vector<int> a(0, n);
  std::vector<int> b(0, n);
  std::vector<int> c(0, n-1);

  for (int i = 0; i < n; ++i)
  {
    int tmp = 0;
    std::cin >> tmp;
    a.push_back(tmp);
  }

  for (int i = 0; i < n; ++i)
  {
    int tmp = 0;
    std::cin >> tmp;
    b.push_back(tmp);
  }

  for (int i = 0; i < n-1; ++i)
  {
    int tmp = 0;
    std::cin >> tmp;
    c.push_back(tmp);
  }

  int food_num = -1;
  for (int i = 0; i < n; ++i)
  {
    result += b[a[i] - 1];

    if (food_num + 1 == a[i])
      result += c[food_num - 1];

    food_num = a[i];
  }

  std::cout << result << std::endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,a[N];
int dp[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;dp[0]=1;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    for(int j=10000;j>=a[i];j--){
      dp[j]|=dp[j-a[i]];
    }
  }
  int ans=0;
  for(int i=1;i<=10000;i++){
    if(i%10 && dp[i])ans=i;
  }
  cout<<ans<<'\n';
  return 0;
}

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

int main()
{
   int N = 0;
   int tmp = 0;
   cin >> N;
   for(int i = 0; i < N; i++)
   {
      int l_i, r_i;
      cin >> l_i >> r_i;
      tmp += r_i - l_i + 1;
   }
   cout << tmp << endl;
}

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

using ll = long long int;
using vi = vector<int>;
using vii = vector<vi>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll uf(ll a, int b){
  if(a % b == 0) return a / b;
  return (a / b) + 1;
}

int main(){
  int n;
  scanf("%d",&n);
  ll a = 1, b = 1;
  REP(i, n){
    int tmp1, tmp2;
    scanf("%d%d",&tmp1, &tmp2);
    ll u = MAX(uf(a, tmp1), uf(b, tmp2));
    a = u * tmp1;
    b = u * tmp2;
  }

  cout << a + b << "\n";
  return 0;
}

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

int gcd(int a, int b) {
  if(a<b) gcd(b,a);
  while(a%b){
    int r=a%b;
    a=b; b=r;
  }
  return b;
}

int main() {
  int n; cin >> n;
  vector<int> a(n, 0);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  int r=a[0];
  
  for (int i=0; i<n; i++){
    r = gcd(r, a[i]);
  }
  cout << r << endl;
}

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

using namespace std;

int main()
{
    int n,x,l[120],cnt=1,Di=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l[i];
        if(i) {
            Di+=l[i-1];
            if(Di<=x) cnt++;
        }
    }
    Di+=l[n-1];
    if(Di<=x) cnt++;

    cout <<cnt<<endl;

    return 0;
}



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in(),X=in();
	if(((X-A)<0) || ((X-A)>B)) out("NO");
	else out("YES");

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <math.h>
using namespace std;

typedef vector<int> vi;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
	float n,k;
	cin >> n >> k;
	cout << ceil((n-1)/(k-1)) <<endl;
}


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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;


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

	int n; cin >> n;
	string ans = !n ? "0" : "";
	while(n){
		ans += '0'+(n&1);
		if (n < 0 && n&1)  n = n/-2 + 1;
		else n /= -2;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
}

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

using namespace std;

const int K = 303;
const int MOD = 998244353;
int dp[K][K][K];

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

    string s;
    cin >> s;
    int k;
    cin >> k;
    s = s + "0";
    vector<int> v;
    int cnt = 0;
    int tot = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0') {
            v.push_back(cnt);
            cnt = 0;
        } else {
            cnt++;
            tot++;
        }
    }

    if (k > tot) k = tot;

    int n = v.size();
    dp[k][n][0] = 1;
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        for (int bal = k; bal >= 0; bal--) {
            for (int left = k; left >= 0; left--) {
                dp[left][i][bal] += dp[left+1][i][bal+1];
                if (dp[left][i][bal] >= MOD) dp[left][i][bal] -= MOD;
                dp[left][i][bal] += dp[left][i+1][bal];
                if (dp[left][i][bal] >= MOD) dp[left][i][bal] -= MOD;
                //for (int diff = 0; diff <= k; diff++) {
                //    if (left+diff <= k && bal+diff <= k) {
                //        dp[left][i][bal] += dp[left+diff][i+1][bal+diff];
                //        if (dp[left][i][bal] >= MOD) dp[left][i][bal] -= MOD;
                //    }
                //}
            }
        }
        int x = v[i];
        for (int diff = -x; diff < 0; diff++) {
            for (int bal = -diff; bal <= k; bal++) {
                for (int left = 0; left <= k; left++) {
                    dp[left][i][bal] += dp[left][i+1][bal+diff];
                    if (dp[left][i][bal] >= MOD) dp[left][i][bal] -= MOD;
                }
                //cout << "dp[" << left << "][" << i << "][" << bal << "] = " << dp[left][i][bal] << endl;
            }
        }
    }
    for (int left = k; left >= 0; left--) {
        ans += dp[left][0][0];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 30808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)


int main(){
    int x,t;
    cin>>x>>t;

    cout<<max(x-t,0)<<endl;

    return 0;
}

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

// エラトステネスの篩的なことを配列に対して行う

const int M = 1000005;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> cnt(M, 0);
    for (int x : A)
    {
        if (cnt[x] != 0)
        {
            cnt[x] = 2; // 同じ値について同じことを繰り返さないように2をマーク
            continue;
        }
        for (int i = x; i < M; i += x)
            cnt[i]++; // xの倍数をマークする
    }

    int ans = 0;
    for (int x : A)
    {
        if (cnt[x] == 1)
            ans++;
    }

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

Measured memory_bytes: 8012
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B, C;
  cin >> A >> B >> C;
  COUT(A * B / 2);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int a[5000000];
int main()
{
    long long int i,n,m,j,k=0,l,r;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n);
    for(i=n;i>=2;)
    {
        if(a[i]==a[i-1])
        {
            if(k==0)
            {
                l=a[i];
            }else
            {
                r=a[i];
            }
            k++;
            i-=2;
        }else
        {
            i--;
        }
        if(k==2)
        {
            break;
        }
    }
    long long int s=l*r;
    if(k==2)
    {
        printf("%lld",s);
    }else
    {
        printf("0");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll inf = (1LL << 35);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const int MOD = 1000000007;
vector<vector<int>> a(200000);
vector<ll> cnt(200000);
void dfs(int n, int p) {
    rep(i,a[n].size()) {
        if (a[n][i] == p)continue;
        cnt[a[n][i]] += cnt[n];
        dfs(a[n][i], n);
    }
}
int main() {
    int n, q; cin >> n >> q;
    int b, c;
    rep(i, n - 1) {
        cin >> b >> c;
        a[b - 1].push_back(c - 1);
        a[c - 1].push_back(b - 1);
    }rep(i, q) {
        cin >> b >> c;
        cnt[b - 1] += c;
    }dfs(0, 0);
    rep(i, n) cout << cnt[i] << endl;
}

Measured memory_bytes: 24320
import heapq

n,m = map(int,input().split())

l = []
for i in range(n):
    ab = list(map(int,input().split()))
    l.append(ab)

l.sort()
q = []
ans = 0
cnt = 0
for i in range(1,m+1):
    while cnt < n and l[cnt][0] == i:
        heapq.heappush(q,-l[cnt][1])
        cnt += 1
    
    if len(q) != 0:
        ans += -heapq.heappop(q)

print(ans)

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

int stack[1000];
int top=0;

void push(int x){
  top=top+1;
  stack[top]=x;
}

int pop(){
  if(top==0){return 0;
  }
  top=top-1;
  return stack[top+1];
}


int main(){
  int x;
  char s[100];
  int a;
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop()+pop();
      push(a);
    } else if ( s[0] == '-' ){
      a=pop()-pop();
      push(-a);
    } else if ( s[0] == '*' ){
      a=pop()*pop();
      push(a);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 200005
const ll MOD = 1000000007;

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

	vector<int> p(MAX,1);
	p[0] = p[1] = 0;
	for(ll i=2;i<MAX;i++){
		if(p[i]){
			for(ll j=i*i;j<MAX;j+=i)
				p[j] = 0;
		}
	}

	ll x;
	cin>>x;
	while(p[x] == 0)
		++x;
	cout<< x <<endl;
}

Measured memory_bytes: 1024
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]


def calc(num, a):
    cnt = 0
    for i, h in enumerate(a):
        x = h - num * B
        x = (x - 1) // (A - B) + 1
        if x > 0:
            cnt += x
    if cnt <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H[:]):
        end = mid
    else:
        start = mid

print(end)


Measured memory_bytes: 106612
import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

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

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String as = fs.next(), bs = fs.next();
        BigInteger a = new BigInteger(as);
        BigInteger b = new BigInteger(bs);
        int comp = a.compareTo(b);
        String ans;
        if (comp == 0) {
            ans = "EQUAL";
        } else if (comp < 0) {
            ans = "LESS";
        } else {
            ans = "GREATER";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	vi u = v;
	sort(ALL(u));
	int cnt = 0;
	REP(i, n) {
		int p = lower_bound(ALL(u), v[i]) - u.begin();
		if (p % 2 == 1 && i % 2 == 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

inline int read() {
	int d = 0, f = 1; char ch = getchar(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) {d = d * 10 + ch - 48, ch = getchar();} return d * f;
}

void write(int x) {
	if(x >= 10) write(x / 10);
	putchar(x % 10 + 48);
}

int main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string A, B, C;
	cin >> A >> B >> C;
	cout << A[0] << B[1] << C[2] << endl;
}

Measured memory_bytes: 256
<?php

// START
$n = Util::input();
$map = [
    'AC' => 0,
    'WA' => 0,
    'TLE' => 0,
    'RE' => 0,
];
for ($i = 0; $i < $n; ++$i) {
    $s = Util::input();
    $map[$s] += 1;
}

foreach ($map as $k => $v) {
    echo sprintf("%s x %d" . PHP_EOL, $k, $v);
}
class Util
{
    public static function input($isSplitSpace = false)
    {
        $input = trim(fgets(STDIN));
        if (!$isSplitSpace) {
            return $input;
        }

        return explode(' ', $input);
    }

    public static function arrToStr($arr)
    {
        return implode(",", $arr);
    }
}



Measured memory_bytes: 16168
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main()
{
    long long int n,k;
    cin>>n>>k;
    vector<long long int> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    long long int s = 0;
    rep(i,n-k) s=s+v[i];
    cout<<s<<endl;
   
   return 0;
}

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

ll solve(vector<ll> &div)
{
  if(div.size()==1)
    return 1;

    ll i,j,k,flag=0;
    vector<ll> ext;
    ll cnt=0;

for(i=0;i<div.size();i++)
{
      ext.push_back(div[i]);
      for(j=0;j<ext.size();j++)
      {
        if(__gcd(ext[j],ext[ext.size()-1]) != 1 && j!=ext.size()-1)
        {
          flag=0;
          break;
        }
        else
        {
          flag=1;
        }
      }
      if(flag==1)
      {
        cnt++;
      }



}
  return cnt;


}
int main()
{

  ll a,b,i,j,k;
  cin>>a>>b;

  vector<ll> cdiv;
  ll n=__gcd(a,b);

  for(i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
        if(n/i==i)
        {
          cdiv.push_back(i);
        }
        else
        {
          cdiv.push_back(i);
          cdiv.push_back(n/i);
        }
    }

  }
  sort(cdiv.begin(),cdiv.end());
/*  for(i=0;i<cdiv.size();i++)
  {
    cout<<cdiv[i]<<" ";
  }*/
  ll ans=solve(cdiv);

  cout<<ans<<endl;




}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int h=50, w=100;

int main(){
    int a,b;
    cin >> a >> b;
    vector<vector<char> > fst(h, vector<char>(w, '#')), snd(h, vector<char>(w, '.'));
    for(int i=0; i<500; i++){
        if(i < a-1) fst[i/50*2][i%50*2] = '.';
        if(i < b-1) snd[i/50*2][i%50*2] = '#';
    }
    reverse(snd.begin(), snd.end());

    cout << h*2 << " " << w << endl;
    for(int r=0; r<2; r++){
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout << fst[i][j];
            }
            cout << endl;
        }
        swap(fst, snd);
    }
    return 0;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
#????????¢?´¢
#???????????§???????????°????????????????????¢?????´????????????????????????????????¢?????´???????????¨????????????????????????
def binary_search(list_1, list_2):
    count = 0

    for b in list_2:
        left_index = 0
        right_index = len(list_1)
        
        while left_index < right_index:
            center = int((left_index + right_index) / 2)
            if list_1[center] == b:
                count += 1
                break
            elif b < list_1[center]:
                right_index = center
            elif b > list_1[center]:
                left_index = center + 1
                
    return count

if __name__ == "__main__":
    n_listA = int(input())
    a = sorted(set([n for n in input().split()]))
    n_listB = int(input())
    b = set([n for n in input().split()])
    print(binary_search(a,b))

Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

vector<ll> sum;
void pre_process(vector<ll> &a, vector<ll> &s)
{ //累積和のvector
    ll n = (ll)a.size();
    s.assign(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        s[i + 1] = s[i] + a[i];
    }
}
ll query(ll i, ll j, vector<ll> &s)
{ //区間[i,j]の和
    return (s[j] - s[i]);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = INF;
    pre_process(a, sum);

    for (ll i = 1; i <= n - 1; i++)
    {
        chmin(ans, abs(query(0, i, sum) - query(i, n, sum)));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6400
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int d;
    int index;
    vector<int> a(n);
    rep(i, k){
        cin >> d;
        rep(j, d){
            cin >> index;
            a[index-1]++;
        }
    }

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

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        long vMax = 0;
        for (int i = 0; i < 30; i++) {
            long vCur = 0;
            if (i == 0) {
                for (int j = 0; j < N; j++) {
                    if ((~K & a[j]) == 0) {
                        vCur += b[j];
                    }
                }
            } else if ((K >> i & 1) == 1) {
                for (int j = 0; j < N; j++) {
                    if (((~(K >> i & ~1) << i) & (a[j] >> i << i)) == 0) {
                        vCur += b[j];
                    }
                }
            }
            vMax = Math.max(vMax, vCur);
        }
        System.out.println(vMax);
    }
}


Measured memory_bytes: 87204
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    int n;
    cin>>n;
    ll a[n];
    inp_arr(a,n);

    ll ans = 0;
    for(int i=1;i<n;++i) {
        if(a[i-1] > a[i]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1]; 
        }
    }
    cout<<ans<<"\n";

    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    int ans = 0;
    int A[N], B[N], C[N - 1];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    rep(i, N) {
        if (i != N - 1) {
            if (A[i] + 1 == A[i + 1]) {
                ans += C[A[i] - 1];
            }
        }
        ans += B[A[i] - 1];
    }

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

Measured memory_bytes: 256
s = list(input())
k = int(input())

if s[0] == '1' and len(s) == 1:
  print(1)
  exit()
elif s[0] != '1':
  print(s[0])
  exit()

if k > 100:
  for i in s:
    if i != '1':
      print(i)
      exit()
  print(1)
  
else:
  for i in s[:k]:
    if i != '1':
      print(i)
      exit()
  print(1)
  exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;
  vector<pair<long long,long long>> R(N);
  for(int i = 0;i < N;i++) {
    long long x,l;
    cin >> x >> l;
    R.at(i) = make_pair(x+l,x-l);
  }

  sort(R.begin(),R.end());
  int num = 0;
  long long cur = -1e9;
  for(int i = 0;i < N;i++) {
    if(cur <= R.at(i).second) {
      num++;
      cur = R.at(i).first;
    }
  }

  cout << num << endl;

  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int length[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i, M) cin >> A[i];
    sort(ALL(A)); reverse(ALL(A)); 
    // priv(A);
    vector<int> dp(N + 1, -INF);
    dp[0] = 0;
    FOR(i, 1, N) {
        REP(j, M) {
            if(i < length[A[j]]) continue;
            if(dp[i-length[A[j]]] == -INF) continue;
            dp[i] = max(dp[i], dp[i-length[A[j]]] + 1);
        }
    }
    // priv(dp);
    while(N > 0) {
        REP(j, M) {
            if(N < length[A[j]]) continue;
            if(dp[N-length[A[j]]] + 1 == dp[N]) {
                cout << A[j];
                N -= length[A[j]];
                // cerr << N << " " << A[j] << endl;
                break;        
            }
        }
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	final static int vmax = 10000;
	final static int max = 1000;
	
	int n, s;
	int[] w;
	
	int[] B = new int[max];
	int[] T = new int[vmax+1];
	
	//入力
	public void input() {
		n = sc.nextInt();
		w = new int[n];
		s = vmax;
		for(int i=0; i<n; i++) {
			w[i] = sc.nextInt();
			s = Math.min(s, w[i]);
		}
	}
	
	//出力
	public void conan() {
		int ans = solve();
		System.out.println( ans );
	}
	
	//解を求める
	public int solve() {
		int ans = 0;
		boolean[] V = new boolean[n];
		for(int i=0; i<n; i++) {
			B[i] = w[i];
			V[i] = false;
		}
		//配列Bをソートする
		//開始と終了のインデックスを指定する
		Arrays.sort(B,0,n);
		
		for(int i=0; i<n; i++) { T[ B[i] ] = i; }
		
		for(int i=0; i<n; i++) {
			if( V[i] ) continue;
			int cur = i;
			int S = 0;
			int m = vmax;
			int an = 0;
			while( true ) {
				V[cur] = true;
				an++;
				int v = w[cur];
				m = Math.min(m, v);
				S += v;
				cur = T[v];
				if( V[cur] ) break;
			}
			ans += Math.min( S+(an-2)*m, m+S+(an+1)*s );
		}
		return ans;
	}
	
	public static void main(String[] args) {
	    Main obj = new Main();
		obj.input();
		obj.conan();
	}
}



Measured memory_bytes: 30184
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	int h, w;
	char moji[27][27][6];
	char alfa;
	cin >> h >> w;
	FOR(i, 1, h) {
		FOR(t, 1, w) {
			cin >> moji[i][t];
		}
	}
	FOR(i, 1, h) {
		FOR(t, 1, w) {
			if (strcmp(moji[i][t], "snuke")==0) {
				alfa = 'A' + t - 1;
				cout << alfa << i << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include <ctype.h>
#include <string>
typedef long long ll;
using namespace std;


void dfs(vector <bool>&seen, vector<vector<int>> &pair, vector<int> &sum, vector<int> &ans, int k){
  seen[k]=true;
  for(int i : pair[k]){
    if(seen[i]==true) continue;
    else {
      ans[i]=ans[k] + sum[i];
      dfs(seen, pair, sum, ans, i);
    }
  }
}

int main(){
  int n,m;
  cin>>n>>m;
  vector <vector<int>> pair(n);
  rep(i,n-1) {
    int a,b;
    cin>>a>>b;
    pair[a-1].push_back(b-1);
    pair[b-1].push_back(a-1);
  }
  vector<bool> seen (n,false);

   vector<int> sum(n,0);
  rep(i,m){
    int p,x;
    cin>>p>>x;
    sum[p-1]+=x;
  }
  vector<int> ans(n);
  ans[0]= sum[0];

  dfs(seen, pair, sum, ans, 0);

 
  rep(i,n){
    cout<<ans[i]<<" ";
  }

  

}

Measured memory_bytes: 31464
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c;
  cin >> a >>b>>c;
  cout << c << " " << a << " " << b << "\n";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int k,s,ans,ij;
int main()
{
    cin>>k>>s;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
        {
            ij=s-i-j;
            if(ij<=k && ij >=0)ans++;
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define N 20000
#define pi M_PI
 
typedef struct Data{
    int area,pos;
}D;
D t[N];
int u[N],n,i,T,U,ans,A;
char str[N+1];
D X,Y;
 
void Dpush(D data){
    t[T++]=data;
}
 
D Dpop(){
    return t[--T];
}
 void push(int x){
     u[U++]=x;
 }
 int pop(){
     return u[--U];
 }
 void init(){
     ans=U=T=0;
 }
 D makeD(int x,int y){
     D res;
     res.area=x;
     res.pos=y;
     return res;
 }
int main(){
  init();
  scanf("%s",str);
  n=strlen(str);
   
  for(i=0;i<n;i++){
   
    if(str[i]=='/'){
      if(U==0)
    continue;
    A=pop();
    X=makeD(i-A,A);
    ans+=i-A;
    while(T>0){
      Y=Dpop();
      if(Y.pos<A){
        Dpush(Y);
        break;
      }
      X.area+=Y.area;
      if(Y.pos<X.pos)
        X.pos=Y.pos;
    }
    Dpush(X);
    }
    else if(str[i]=='\\'){
      push(i);
    }
  }
  printf("%d\n%d",ans,T);
  for(i=0;i<T;i++){
    printf(" ");
    printf("%d",t[i].area);
  }
  printf("\n");
  return 0;
}


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

multiset<int> st;
int A[200009];

int main() {
    int N; scanf("%d",&N);
    for(int i=0; i<N; i++) {
        scanf("%d",&A[i]);
        st.insert(A[i]);
    }
    int x = 1 << 30, ans = 0;
    while(x) {
        vector<int> stk;
        for(auto& it: st) stk.push_back(it);
        for(auto& it: stk) {
            auto y = st.find(it);
            if(y == st.end()) continue;
            st.erase(y);
            auto z = st.find(x - it);
            if(z != st.end()) {
                ++ans;
                st.erase(z);
            }
            else st.insert(it);
        }
        x /= 2;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 13448
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int n;
bool g[102][102];
bool vis[102];
vector<int> matched(102,0);
bool pd(int x)
{
	for(int j=1;j<=n;j++)
	{
		if(g[x][j] and !vis[j])
		{
			vis[j]=1;
			if(matched[j]==0 or pd(matched[j]))
			{
				matched[j]=x;
				return 1;
			}
		}
	}
	return 0;
}
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w",stdout);
	#endif
	cin>>n;
	vector<int> x(n+1),y(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
	}

	int a,b;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		for(int j=1;j<=n;j++)
		{
			if(a>x[j] and b>y[j])g[i][j]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof vis);
		if(pd(i))ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A, B = MAP()
P = LIST()

a = [0]*3

for x in P:
	if x <= A:
		a[0] += 1
	elif B < x:
		a[2] += 1
	else:
		a[1] += 1

print(min(a))


Measured memory_bytes: 5400
#include<stdio.h>
#include<math.h>
int main() {
	int x;
	while (scanf("%d", &x) != EOF) {
		int t = sqrt(x);
		int ans = 1;
		for (int i = 2; i <= t; i++) {
			int cnt = i * i;
			while (cnt <= x) {
				cnt *= i;
			}
			cnt /= i;
			if (cnt > ans) ans = cnt;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 int A[1000000],n;
int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    else if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



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

int main(void)
{
    char s[11];
    char t[12];
    int flag=0;

    scanf("%s",s);
    // printf("s=%s\n",s);
    scanf("%s",t);
    // printf("t=%s\n",t);

    for (int i=0;i<strlen(s);i++){
        if (s[i]!=t[i])
            flag=1;
    }

    if (flag==0)
        printf("Yes");
    else
        printf("No");
    
    return 0;
    

}

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

using namespace std;

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

int main() {
	int n;
	cin >> n;
	int ans = n * 800;
	int y = n / 15;
	ans -= y * 200;
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int n, m, ans;
vector<int> edge[110000];
bool done[110000];
queue<int> q;

bool bfs(int s) {
  done[s] = true;
  q.push(s);
  while (!q.empty()) {
    int u = q.front(); 
    q.pop();
    for (int v: edge[u]) {
      if (done[v]) continue;
      done[v] = true;
      q.push(v);
    }
  }
}

int main() {
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  
  for (int i = 0; i < n; i++) {
    if (done[i]) continue;
    bfs(i);
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,h;cin>>n>>h;
int a[n+1],b[n+1];
for(int i=0;i<n;i++)
{
cin>>a[i];
b[i]=0;
}
while(h--)
{
for(int i=0;i<n;i++)
{
int p=max(0,i-a[i]);
b[p]+=1;
p=min(n-1,i+a[i]);
b[p+1]-=1;
}
for(int i=1;i<n;i++)
{
b[i]+=b[i-1];
}
int f=1;
for(int i=0;i<n;i++){
a[i]=b[i];
b[i]=0;
if(a[i]!=n)
f=0;
}
if(f==1)
break;
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}

Measured memory_bytes: 5148
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S[3];

int main(){
    rep(i,3){
        cin>>S[i];
    }
    rep(i,3){
        printf("%c",S[i][i]);
    }
    out("");
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  double rad = c * M_PI / 180;
  double h = sin(rad) * b;
  double S = a * h /2;
  double L = a + b + (sqrt(pow(a,2) + pow(b,2) - (2 * a * b * cos(rad))));
  printf("%lf %lf %lf\n", S, L, h);
  return 0;
}



Measured memory_bytes: 3372
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int fairfield(int y,int m,int d)
{
	if(m<=2){
		y--;
		m+=12;
	}
	return 365*y+y/4-y/100+y/400+153*(m+1)/5+d-428;
}

int main()
{
	for(int y1,m1,d1,y2,m2,d2;cin>>y1>>m1>>d1>>y2>>m2>>d2,~(y1|m1|d1|y2|m2|d2);){
		cout<<fairfield(y2,m2,d2)-fairfield(y1,m1,d1)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll m = n, sum = 0;
  while (m > 0) {
    sum += m % 10;
    m /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int na,a=0,b=0,o=0,ab=0;
  char t[3];
  while(scanf("%d,%s",&na,t)!=EOF){
    if(t[0]=='A'){
      if(t[1]=='B')
	ab++;
      else
	a++;
    }
    if(t[0]=='B')
      b++;
    if(t[0]=='O')
      o++;
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
ll X[MAX_N];
ll H[MAX_N];
ll Y[MAX_N];
pair<ll, ll> ps[MAX_N];

int main2() {

  CLR(X, 0);
  CLR(H, 0);
  CLR(Y, 0);

  int N = nextInt();
  ll D = nextInt();
  ll A = nextInt();
  REP(i, N) {
    ll x = nextInt();
    ll h = nextInt();
    ps[i] = {x, h};
  }
  sort(ps, ps + N);
  REP(i, N) {
    X[i+1] = ps[i].first;
    H[i+1] = ps[i].second;
    H[i+1] = (H[i+1] + A - 1) / A;
  }
  ll ans = 0;
  ll cur = 0;
  int right = 0;
  for (int i = 0; i <= N; i++) {
    cur += Y[i];
    ll s = cur + H[i];
    if (s > 0) {
      while (right <= N && X[right] - X[i] <= D*2) right++;
      ans += s;
      Y[i] -= s;
      Y[right] += s;
      cur -= s;
      // cout << "i=" << i << ", right="<< right << endl;
    }
    // pv(H, H+N+1);
    // pv(Y, Y+N+1);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	long long int a, total=0;
	cin >> a;
	for(int i=1; i<=a; i++)
	{
		if(i%3 !=0 && i%5 != 0)
		{
			total += i;
		}
	}
	cout << total;
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main() {
  int n; cin >> n;
  vector<int>L(n+1);
  rep(i,n) cin >> L[i];
  L[n] = INF;
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i=0; i<=n-3; i++){
    for (int j=i+1; j<=n-2; j++){
      int search = L[i] + L[j];
      auto itr = lower_bound(L.begin(), L.end(), search);
      if (itr != L.end()){
        int index = itr - L.begin();
        ans += index-j-1;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3596