akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
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; }
typedef long long ll;

int main() {
  ll N,W;
  cin >> N >> W;
  ll INF = 100000000000000;
  vector<ll> weight(110);
  vector<ll> value(110);
  vector<vector<ll>> dp(110, vector<ll>(100100,INF));
  
  for(ll i = 0;i<N;i++){
    cin >> weight[i];
    cin >> value[i];
  }
dp[0][0] = 0;
  rep(i,N){
    rep(sum_v,100100){
      if(sum_v-value[i] >=0){
        chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i]);
      }
      chmin(dp[i+1][sum_v],dp[i][sum_v]);
    }
  }
    ll res = 0;
  for(ll sum_v = 0;sum_v<100100;sum_v++){
    if(dp[N][sum_v]<=W){
      res = max(res,sum_v);
    }
  }
  
cout << res << endl;
  
}


Measured memory_bytes: 87296
import java.util.Scanner;
import java.util.stream.IntStream;

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

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int[] a = new int[n];
			// left必ず達成できない、right必ず達成できる
			int left = 0, right = IntStream.range(0, n).map(i -> a[i] = scanner.nextInt()).max().getAsInt();
			while (right > left + 1) {
				int mid = (left + right) / 2;
				if (ok(n, k, a, mid)) {
					right = mid;
				} else {
					left = mid;
				}
			}
			System.out.println(right);
		}
	}

	/**
	 * 目標値をk回まで切ることで達成できるかを計算する
	 * 
	 * @param n      丸太の数
	 * @param k      切る回数の上限
	 * @param a      丸太の長さの配列
	 * @param target 目標値
	 * @return 目標値をk回のカットで達成できるか
	 */
	private static boolean ok(int n, int k, int[] a, int target) {
		return IntStream.range(0, n).map(i -> (a[i] + target - 1) / target - 1).sum() <= k;
	}
}


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

int main(void){
  int number, manipulate_number;
  cin >> number >> manipulate_number;

  string s;
  cin >> s;

  vector<int> nums;
  int now = 1;
  int cnt = 0;
  for(int i = 0; i < number; i++){
    if(s[i] == (char)('0' + now)) cnt++;
    else{
      nums.emplace_back(cnt);
      now ^= 1;
      cnt = 1;
    }
  }
  if(cnt != 0) nums.emplace_back(cnt);

  if(nums.size() % 2 == 0) nums.emplace_back(0);


  int add_range = 2 * manipulate_number + 1;
  int ans = 0;

  int left = 0;
  int right = 0;
  int tmp = 0;
  for(int i = 0; i < nums.size(); i += 2){
    int next_left = i;
    int next_right = min(i + add_range, (int)nums.size());
    while(next_left > left){
      tmp -= nums[left];
      left++;
    }

    while(next_right > right){
      tmp += nums[right];
      right++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    string s;cin>>s;
    vector<ll>a(4);
    rep(i,s.size()){
        if(s[i]=='N')a[0]=1;
        else if(s[i]=='S')a[1]=1;
        else if(s[i]=='W')a[2]=1;
        else a[3]=1;
    }
    if(a[0]==a[1]&&a[2]==a[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
    string a;
    int ans = 0;
    cin >> a;
    for (int i = 0; i < 4; i++) {
        if (a[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans;
    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 each(itr,v) for(auto itr:v)
#define pb push_back
#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 INT_MAX/3

ll n;
ll a[101010];

int main(){
	cin>>n;
  rep(i,n)cin>>a[i];
  reverse(a,a+n);
  if(a[0]!=2){
    cout<<-1<<endl;
    return 0;
  }
  ll lo=2,hi=2;
  rep(i,n-1){
    {
      ll ub=((lo/a[i])+1)*a[i]-1;
      ll lb=lo;
      ll nlb=((lb+a[i+1]-1)/a[i+1])*a[i+1];
      ll nub=(ub/a[i+1])*a[i+1];
      lo=nlb;
    }
    {
      ll ub=((hi/a[i])+1)*a[i]-1;
      ll lb=hi;
      ll nlb=((lb+a[i+1]-1)/a[i+1])*a[i+1];
      ll nub=(ub/a[i+1])*a[i+1];
      hi=nub;
    }
  }
  {
    ll ub=((hi/a[n-1])+1)*a[n-1]-1;
    ll lb=hi;
    hi=ub;
  }
  if(lo>hi)cout<<-1<<endl;
  else cout<<lo<<" "<<hi<<endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
    s = input()
    t = input()
    sn = len(s)
    tn = len(t)
    dp = [[0] * (tn + 1) for _ in range(sn + 1)]
    for i in range(1, sn + 1):
        for j in range(1, tn + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1)
            else:
                dp[i][j] = max(dp[i][j], dp[i - 1][j])
                dp[i][j] = max(dp[i][j], dp[i][j - 1])
    ans = []
    i, j = sn, tn
    while i > 0 and j > 0:
        if dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j]:
            i -= 1
        else:
            ans.append(s[i - 1])
            i -= 1
            j -= 1
    print(''.join(ans[::-1]))

if __name__ == '__main__':
    main()


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

#define N 100

int main() {
	static char s[N + 1];
	int n, i, j, ans;

	scanf("%s", s);
	n = strlen(s);
	ans = 0;
	for (i = 0, j = n - 1; i < j; i++, j--)
		if (s[i] != s[j])
			ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

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

int n;
cin>>n;

ll ans=0;
for(int i=1;i<=n;i++)
{
    if(i%3!=0&&i%5!=0)ans+=i;
}
cout<<ans<<endl;
return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int w,a,b;
	cin>>w>>a>>b;
	if(a>b)swap(a,b);
	int dist = b-(a+w);
	if(dist<=0)cout<<0;
	else cout<<dist;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3528
/* Author rumoisen */
/* created 2018/10/07 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int ketanowa(int n)
{
    int s=0;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    return s;
}
int main()
{
    int n;
    cin>>n;
    if(n%ketanowa(n)==0) yes();
    else no();
    return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int calc(void){
  int n;
  scanf("%d",&n);
  int *cnt=(int *)calloc(n,sizeof(int));
  int kind=0;
  int min=n;
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(cnt[a]==0) kind++;
    cnt[a]++;
    min=MIN(min,a);
  }
  if(kind>2) return 0;
  if(kind==1){
    return min==n-1 || 2*min<=n;
  }
  if(cnt[min]+cnt[min+1]<n) return 0;
  int one=cnt[min];
  int two=cnt[min+1];
  if(min+1<one+1 || two<2 || min+1>one+two/2) return 0;
  return 1;
}

void run(void){
  puts(calc()?"Yes":"No");
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
using System;

namespace ABC173_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int yen = 1000;
            int back=0;
            while (N > yen)
            {
                yen = yen + 1000;
            }
            back = yen - N;

            Console.WriteLine(back);
        }
    }
}

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

    template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
    char try_out(...);

    struct debug {
    #ifdef LOCAL
    template<class c, class d> debug& operator << (pair<c, d> e) {
        return *this << "(" << e.first << ", " << e.second << ")";
    }
    template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
        cerr << boolalpha << a;
        return *this;
    }
    template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
        *this << "[";
        for (auto it = a.begin(); it != a.end(); ++it)
            *this << ","[1 - (it != a.begin())] << *it;
        return *this << "]";
    }
    #else
    template<class c> debug& operator << (c) {
        return *this;
    }
    #endif
    };

    #define aty(x) " [" << #x ": " << x << "] "

    using ll = long long;




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


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long LL;
int main(){
	LL n,m;
	while(~scanf("%lld%lld",&n,&m)){
		cout<<abs(m*n-m*2-n*2+4)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long n=0,m,a[100100];
	string s,s1;
	cin>>s>>s1;
	for(int i=0;i<3;i++)
		if(s[i]==s1[i])
			n++;
	cout<<n<<endl;		
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  else if(s=="MON") cout<<6<<endl;
  else if(s=="TUE") cout<<5<<endl;
  else if(s=="WED") cout<<4<<endl;
  else if(s=="THU") cout<<3<<endl;
  else if(s=="FRI") cout<<2<<endl;
  else if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
x=0
for i in range(n+1):
  if x==1:
    break
  for j in range(n-i+1):
    if y==i*10000+j*5000+(n-i-j)*1000:
      print(i,j,n-i-j)
      x=1
      break
if x==0:print(-1,-1,-1)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long

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

  string ans;

  //ファーストの文字
  if(T[0] == '?') {
    //後ろを見る
    // if(T[1] == 'P') {
    //   ans = 'D';
    // } else {
    //   ans = 'P';
    // }
    ans = 'D';
  } else {
    ans = T[0];
  }

  long i = 1;
  for(i = 1; i < long(T.size()); i++) {
    if(T[i] == '?') {
      //一個前がPならDになる
      if(ans[ans.size() - 1] == 'P') {
        ans += 'D';
      }
      //一個前がDなら後ろを見る
      else if(ans[ans.size() - 1] == 'D') {
        // if(T[i + 1] == 'P') {
        //   ans += 'D';
        // } else if(T[i + 1] == 'D' || T[i + 1] == '?') {
        //   ans += 'P';
        // }
        ans += 'D';
      }
    } else {
      ans += T[i];
    }
  }

  // //ラストの文字
  // if(T[T.size() - 1] == '?') {
  //   ans += 'D';
  // } else {
  //   ans += T[T.size() - 1];
  // }

  cout << ans;

  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int n = s.length();
    bool ans = true;

    for(int i = 0; i <n; i++){
        if(s[i] != s[n-1-i]) ans = false;
    } 

    
    int l = (n-1)/2;
    for(int i = 0; i < l; i++){
        if(s[i] != s[l-1-i]) ans = false;
    }
   
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    


    return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = gets.to_i
a = gets.split.map(&:to_i)

inv = Array.new(n+1)
inv[1] = 1
fac = Array.new(n+1)
fac[0] = fac[1] = 1
# f_inv = Array.new(n + 1)
# f_inv[0] = f_inv[1] = 1
(2..n).each do |i|
  inv[i] = inv[MOD%i] * (MOD - MOD/i) % MOD
  fac[i] = fac[i-1] * i % MOD
  # f_inv[i] = f_inv[i - 1] * inv[i] % MOD
end

#累積和
(1..n-1).each do |i|
  inv[i+1] = (inv[i+1] + inv[i]) % MOD
end

p_inv = 0
n.times do |i|
  m = inv[i+1] + inv[n-i] - inv[1]
  p_inv = (p_inv + m * a[i] % MOD) % MOD
end
 
puts p_inv * fac[n] % MOD

Measured memory_bytes: 10124
#include<stdio.h>
int main(void)
{
  int s[4];
  int a=0,b;
  int i;
  
  scanf("%d",&b);
  
  s[0]=b/1000;
  s[1]=b/100-s[0]*10;
  s[2]=b/10-s[0]*100-s[1]*10;
  s[3]=b/1-s[0]*1000-s[1]*100-s[2]*10;
  
  if(s[0]==s[1])
    a=1;
  if(s[1]==s[2])
    a=1;
  if(s[2]==s[3])
    a=1;
  if(a==1)
    printf("Bad");
  else
    printf("Good");
  
 
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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 all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    cout << (D2 == 1 ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> N;
	cout << N/3 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	string s;cin>>s;
	string ans = "Sunny";
	if(s[0] == 'C')ans = "Rainy";
	if(s[0] == 'S')ans = "Cloudy";
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,p;
	p=0;
	string s;
	cin >> s;
	for(i=0;i<4;i++){
		if(s[i]=='+'){
			p++;
		}
		else{
			p--;
		}
	}
	cout << p << endl;
}


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

using namespace std;

int n, k;
int a[100010];
int all, bll;
int ch[100010];
int ans;

int main(void)
{
	scanf("%d %d", &n, &k);
	
	for(int i = 1 ; i <= n ; i++)
		scanf("%d", &a[i]);
	
	for(int i = 0 ; i < k ; i++)
	{
		scanf("%d %d", &all, &bll);
		
		if(a[all] <= a[bll])
			ch[all] = 1;
		if(a[bll] <= a[all])
			ch[bll] = 1;
	}
	
	for(int i = 1 ; i <= n ; i++)
		ans += 1 - ch[i];
	
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 4536
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long int n, m;
  long int ans = 0;
  long int l[100001];
  long int r[100001];
  

  scanf("%ld%ld", &n, &m);

  for(long int i = 0; i < m; i++){
    scanf("%ld%ld", &l[i], &r[i]);
  }

  qsort(l, m, sizeof(long int), compare_int);
  qsort(r, m, sizeof(long int), compare_int_small);
  
  fprintf(stderr, "l[0] = %ld  r[0] = %ld\n", l[0], r[0]);
  
  ans = r[0] - l[0] + 1;
  if(ans < 0){
    ans = 0;
  }

  printf("%ld\n", ans);
  
  return 0;
}


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

int main(){
	int N, i, j;
	scanf("%d", &N);
	for(i = 1; i <= 9; i++){
		for(j = 1; j <= 9; j++){
			if(i * j == N){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i%2==0 && a[i]%2==1) ans++;
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int t; cin >> t; for(int cs = 1; cs <= t; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

//input space ---> scanf("%[^\n]%*c",s);

char a[1005][1005];
int n,m,dp[1005][1005];

int main() {
	IOS
	cin >> n >> m;
	fori(i,1,n,1) {
		fori(j,1,m,1) {
			cin >> a[i][j];
		}
	}
	fori(i,1,n,1) {
		if(a[1][i] != '#')
			dp[1][i] = 1;
		else
			break;
	}
	fori(i,1,m,1) {
		if(a[i][1] != '#')
			dp[i][1] = 1;
		else
			break;
	}
	fori(i,2,n,1) {
		fori(j,2,m,1) {
			if(a[i][j] != '#') {
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			} else {
				dp[i][j] = 0;
			}
		}
	}
	cout << dp[n][m] << endl;
}


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

int main() {
    int h,w;
    while(1) {
        scanf("%d%d",&w,&h);
        if(w==0 && h==0) break;
        for(int i=0; i<w; i++) {
            for(int j=0; j<h; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;

}



Measured memory_bytes: 3148
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Str;
		WriteLine(2 * S.Count(c => c == '+') - 4);
	}
}


Measured memory_bytes: 11220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A > 8 || B > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


Measured memory_bytes: 21716
N = int(input())
arr = list(map(int,input().split()))
mins = 10**10
csum = [0 for _ in range(N)]
csum[0] = arr[0]
for i in range(1,N):
    csum[i] = csum[i-1] + arr[i]    
for i in range(N-1):
    cards = abs(csum[N-1]-2*csum[i])
    if cards < mins:
        mins = cards
print(mins)

Measured memory_bytes: 23792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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 ll INF = 1LL << 60;
int a[3][3];
bool ok[3][3];
int main(){
    rep(i,3)rep(j,3) cin >> a[i][j];
    int n; cin >> n;
    rep(_,n){
        int b;
        cin >> b;
        rep(i,3)rep(j,3) {
            if(b==a[i][j]) ok[i][j] = true;
        }
    }
    bool yes = false;
    rep(i,3){
        if((ok[0][i]&&ok[1][i]&&ok[2][i]) || (ok[i][0]&&ok[i][1]&&ok[i][2])) yes = true;
    }
    if(ok[0][0]&&ok[1][1]&&ok[2][2]) yes = true;
    if(ok[2][0]&&ok[1][1]&&ok[0][2]) yes = true;
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

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

  int A;
  int ans = N;
  rep(i, M) {
    cin >> A;
    ans -= A;
    if (ans < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % 2 == 0) {
      System.out.println(n / 2);
    } else {
      System.out.println((n / 2) + 1);
    }
  }
}

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

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

    scanf("%d%d%d%d",&a,&b,&c,&d);
    
    if( abs(a-c) <= d ){
        printf("Yes\n");
        return 0;
    }else{
        if( (abs(a-b) <= d) && (abs(b-c) <= d) ){
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int num[1000000]={1,1};

int main (void){

    int n;
    int i,j;

    while(scanf("%d",&n)!=EOF){

        int prime=0;
        for(i=2;i*2<=n;i++){
            num[i*2]=1;
        }

        for(i=3;i<=n/2;i+=2){
            if(num[i]==0){
                for(j=3;i*j<=n;j+=2){
                    num[i*j]=1;
                }
            }
        }

        for(i=2;i<=n;i++){
            //printf("-%d-\n",num[i]);
            if(num[i]==0){
                prime++;
            }
        }
        printf("%d\n",prime);

    }

    return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string N;
  cin >> N;
  int siz=N.size(),sum=0;
  rep(i,siz) sum+=N[i]-'0';
  
  if(sum%9) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

struct Problem {

	void Solve() {
		UL N; cin >> N;
		string S; cin >> S;
		vector<UL> W(N + 1), B(N + 1);
		rep(i, N) {
			if (S[i] == '.') W[i] = 1;
			else B[i + 1] = 1;
		}
		rep(i, N) {
			B[i + 1] += B[i];
			W[N - i - 1] += W[N - i];
		}
		UL ans = 10000000;
		rep(i, N + 1) {
			ans = min(ans, W[i] + B[i]);
		}
		cout << ans << endl;
	}

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

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

int main() {
	
	int k, x;
	cin >> k >> x;
	string ans = "No";
	if(k*500 >= x) ans = "Yes";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007
#define rep(x, s, t) for(llint x = s; x <= t; x++)

using namespace std;

llint n, m;
vector<llint> G[1005], revG[1005];
bool used[1005], cycle[1005];
llint pre[1005];
bool out[1005];
llint dp[1005];
vector<llint> cvec, tvec;

llint dfs(llint v){
	used[v] = true;
	llint u = G[v][0];
	if(used[u]){
		cycle[v] = true;
		cvec.push_back(v);
		if(u == v) return -1;
		return u;
	}
	llint res = dfs(u);
	if(res != -1) cycle[v] = true, cvec.push_back(v);
	if(res == v) res = -1;
	return res;
}

llint id;
void dfs2(llint v)
{
	used[v] = true;
	tvec.push_back(v); 
	pre[v] = id, id++;
	rep(i, 0, (int)revG[v].size()-1){
		llint u = revG[v][i];
		if(G[v][0] == u) continue;
		if(cycle[u]) continue;
		dfs2(u);
	}
	out[id] = true;
	tvec.push_back(v); id++;
	
}

llint calc(llint v)
{
	tvec.clear();
	tvec.push_back(0), id = 1;
	dfs2(v);
	
	llint n = (int)tvec.size()-1;
	rep(i, 0, n) dp[i] = 0;
	dp[0] = 1;
	
	rep(i, 1, n){
		llint u = tvec[i];
		if(out[i]){
			dp[i] = dp[pre[u]] + dp[i-1];
			dp[i] %= mod;
		}
		else dp[i] = dp[i-1];
	}
	dp[n] += mod-1, dp[n] %= mod;
	return dp[n];
}

llint solve(llint r)
{
	cvec.clear();
	dfs(r);
	
	//rep(i, 0, (int)cvec.size()-1) cout << cvec[i] << ' '; cout << endl;
	
	llint ret = 1;
	rep(i, 0, (int)cvec.size()-1){
		ret *= calc(cvec[i]), ret %= mod;
	}
	ret += 1, ret %= mod;
	//cout << r << ' ' << ret << endl;
	return ret;
}

int main(void)
{
	cin >> n >> m;
	llint u, v;
	rep(i, 1, m){
		cin >> u >> v;
		G[u].push_back(v);
		revG[v].push_back(u);
	}
	rep(i, 1, n){
		if(G[i].size() == 0) G[i].push_back(i);
	}
	
	llint ans = 1;
	rep(i, 1, n){
		if(!used[i]) ans *= solve(i), ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    rep (i, s.length())
        if (s[i] != t[i]) {
            print("No");
            return 0;
        }
    print("Yes");

    return 0;
}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

#define MAXN 100005

vi adjList[MAXN];

int PD[MAXN];

int pd(int a){
	int &mem = PD[a];
	if(mem != -1) return mem;
	mem = 0;
	for(int b : adjList[a]){
		mem = max(mem, 1 + pd(b)); 
	}
	return mem;
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	FOR(i, 0, m){
		int a,b;
		scanf("%d%d", &a, &b);
		adjList[a].pb(b);
	}
	int ans = 0;
	memset(PD, -1, sizeof(PD));
	FOR(i, 1, n+1){
		ans = max(ans, pd(i));
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string S;
  bool n=false,s=false,e=false,w=false; cin>>S;
  for(int i=0;i<S.size();i++){
    if(S[i]=='S')s=true;
    else if(S[i]=='N')n=true;
    else if(S[i]=='W')w=true;
    else if(S[i]=='E')e=true;
  }
  if(n==s && e==w){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int N,K;
  cin>>N>>K;
  if(N%2==0){
    if(N/2>=K){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }else{
    if(N/2+1>=K){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }

  


}


  

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        long[] a = sc.nextLongArray(n);
        long[] dp = new long[n];
        dp[0] = 1000;
        for(int i = 0; i < n; i++){
            long count = dp[i]/a[i];
            for(int j = i+1; j < n; j++){
                dp[j] = Math.max(dp[j-1], dp[i]+(a[j]-a[i])*count);
            }
        }
        pw.println(dp[n-1]);
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

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

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

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

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

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


Measured memory_bytes: 25356
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <bitset>
#include <cmath>
#include <time.h>
using namespace std;

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

	for (int bit = 0; bit < (1 << 3); bit++) {

		bitset<3> b(bit);
		int s = 0;

		s += a.at(0) - '0';
		for (int j = 0; j < 3; j++) {
			if (b.test(j) == 1) {
				s -= a.at(j + 1) - '0';

			}
			else {
				s += a.at(j + 1) - '0';
			}

		}

		if (s == 7) {
			cout << a.at(0);
			for (int j = 0; j < 3; j++) {
				if (b.test(j) == 1) {
					cout << "-" << a.at(j + 1);
				}
				else {
					cout << "+" << a.at(j + 1);;
				}

			}
			cout << "=7" << endl;
			return 0;
		}

	}
			
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, D, A;
    cin >> N >> D >> A;
    vector<pll> enemys;
    for (int i = 0; i < N; i++)
    {
        ll X, H;
        cin >> X >> H;
        ll bombs = H / A;
        if (H % A)
        {
            bombs++;
        }
        enemys.emplace_back(X, bombs);
    }
    sort(enemys.begin(), enemys.end());
    vector<int> rightEnemyIndexes(N); //半界区間
    int j = 1;
    for (int i = 0; i < N; i++)
    {
        ll rightBorder = enemys.at(i).first + (ll)2 * D;
        while (j < N)
        {
            if (enemys.at(j).first > rightBorder)
            {
                break;
            }
            j++;
        }
        rightEnemyIndexes.at(i) = j;
    }
    ll answer = 0;
    vector<ll> imos(N + 1);
    ll currentBombs = 0;
    for (int i = 0; i < N; i++)
    {
        currentBombs += imos.at(i);
        ll needBomb = max((ll)0, enemys.at(i).second - currentBombs);
        answer += needBomb;
        currentBombs += needBomb;
        imos.at(rightEnemyIndexes.at(i)) -= needBomb;         
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 6636
n= int(input())
a = list(map(int,input().split()))


def division2(n,count):
  if n%2 == 0:
    count += 1
    return division2(n//2,count)
  else:
    return count

ans = 0
for i in range(n):
  ans += division2(a[i],0)

print(ans)

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

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << "\t";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    const int N = 13;
    const int mod = (int) 1e9+7;
    vi dp(N,0);
    dp[0] = 1;

    int mul = 1;
    RREP(i,S.length()-1) {
        vi nextDP(N,0);
        char c = S[i];
        if (c == '?') {
            REP(k,10) REP(j,N){
                assert(INRANGE((k*mul+j) % N,0,12));
                nextDP[(k*mul+j) % N] += dp[j];
                nextDP[(k*mul+j) % N] %= mod;
            }
        } else {
            int k = (int) (S[i]-'0');
            REP(j,N){
                assert(INRANGE((k*mul+j) % N,0,12));
                nextDP[(k*mul+j) % N] += dp[j];
                nextDP[(k*mul+j) % N] %= mod;
            }
        }

        mul *= 10;
        mul %= N;

        //printv(dp);
        dp = nextDP;
    }
    //printv(dp);

    cout << dp[5] << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char* argv[])
{
    set<int> color;
    for (int i = 0; i < 3; i++) {
        int c; cin >> c;
        color.insert(c);
    }

    cout << color.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{
    int n,x,y;
    int ans[2005]={0};
    scanf("%d%d%d",&n,&x,&y);
    int t1,t2,t3,t4,t5;
    for(int i=1;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            t1=j-i;
            t2=abs(x-i);
            t3=abs(y-i);
            t4=abs(x-j);
            t5=abs(y-j);
            if(i==x)
            {
                if(j==y) ans[1]++;
                else
                {
                    t1=min(j-i,abs(y-j)+1);
                    ans[t1]++;
                }
                continue;
            }
            if(i==y)
            {
                ans[t1]++;
                continue;
            }
            if(j==y)
            {
                t1=min(j-i,abs(x-i)+1);
                ans[t1]++;
                continue;
            }

            t1=min(t1,t2+t4);
            t1=min(t1,t3+t5);
            t1=min(t1,t3+t4+1);
            t1=min(t1,t2+t5+1);
            ans[t1]++;
        }
    }
    for(int i=1;i<=n-1;i++)
        printf("%d\n",ans[i]);
    return 0;
}


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

int main() {
  string s;
  int q;
  cin>>s>>q;
  int swa=0;
  string a=s;
  for(int i=0;i<q;i++){
    int t,f;
    char c;
    cin>>t;
    if(t==1) swa++;
    else{
      cin>>f>>c;
      if((f==2 && swa%2==0) || (f==1 && swa%2==1)){
        s.append(1,c);
        a.insert(a.begin(),c);
      }
      else{
        s.insert(s.begin(),c);
        a.append(1,c);
      }
    }
  }
  if(swa%2==0) cout<<s<<endl;
  else{
    reverse(s.begin(),s.end());
    cout<<s<<endl;
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pb(a) push_back(a)
#define arr(a) new ll int[a]
#define INF 1000000000000000000
#define MOD 4222236787
//ll int composite[15125];
const int N = 1e5 + 2;
ll fact[N];
void factorial(){
    fact[0] = fact[1] = 1;
    for(ll i = 2; i < N; i++)
        fact[i] = (fact[i-1] * i) % MOD;
}
ll power(ll a, ll b, ll mod){
	ll x = 1, y = a;
	while (b > 0){
		if (b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}
ll modular_inverse(ll n, ll mod){
	return power(n, mod-2, mod);
}
ll nCr(ll n, ll k, ll mod){
	return (fact[n]*((modular_inverse(fact[k],MOD)*modular_inverse(fact[n-k],MOD))%mod))%mod;
}
//ll int arr1[10001];
//ll int arr1[25];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,temp=0,a,b;
    cin>>n;
    bool res=false;
    while(n--)
    {
        cin>>a>>b;
        if(a==b)
        {
            temp++;
        }
        else temp=0;
        if(temp>=3)res=true;
    }
    if(res)cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 3652
main = do
  [a, b, c] <- map read . words <$> getLine
  putStr . show $ f a b c

f a b c
  | mod a 2 == 1 = 0
  | mod b 2 == 1 = 0
  | mod c 2 == 1 = 0
  | a == b && b == c = -1
  | otherwise = 1 + f (div (b+c) 2) (div (c+a) 2) (div (a+b) 2)

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i,N) {
        int t;
        cin >> t;
        A[i] = t % M;
    }
    ll sum = 0;
    map<ll,ll> mp;
    mp[sum] = 1;
    REP(i,N) {
        sum += A[i];
        sum %= M;
        if (mp.find(sum) != mp.end()) {
            mp[sum] ++;
        }
        else {
            mp[sum] = 1;
        }
    }
    ll ans = 0;
    for (auto t : mp) {
        ans += t.se * (t.se - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int num[110];

int main(void){
	int n;
	cin >> n;
	rep(i,n){
		int in;
		cin >> in;
		num[in]++;
	}
	
	int diameter=0;
	rep(i,n) if(num[i]) diameter=i;

	bool ok=true;
	const int radius=(diameter+1)/2;
	rep(i,radius+1,diameter+1) if(num[i]<2) ok=false;


	if(radius>0){
		if(diameter%2==0){
			if(num[radius]!=1) ok=false;
		}else{
			if(num[radius]!=2) ok=false;
		}
	}

	if(ok)
		puts("Possible");
	else
		puts("Impossible");

	return 0;
}

Measured memory_bytes: 384