akhauriyash/Code-Regression huggingface dataset:
N,S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 153164
#include<cstdio>
#include<iostream>
#include<cstring>

int main() {
    bool A = false,B = false;
    for(int i = 1;i <= 3;i++) {
        char ch; std::cin >> ch;
        if(ch == 'A') A = true;
        else B = true;
    }
    if(A && B) std::puts("Yes");
    else std::puts("No");
    return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
listA = [[0 for i in range(b+1)] for j in range(a+1)]
for i in range(a):
    listA[i] = list(map(int, input().split()))

for i in range(a):
    s = sum(listA[i])
    listA[i].append(s)

for i in range(b):
    s = 0
    for j in range(a):
        s += listA[j][i]
    listA[a][i] = s

listA[a][b] = sum(listA[a])

for i in range(a+1):
    for j in range(b+1):
        if j == b:
            print(str(listA[i][j]))
        else:
            print(str(listA[i][j]) + ' ',end='')


Measured memory_bytes: 6296
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    string s;
    cin >> s;
    int ans=0;
    rep(i,s.size()) {
        if (s[i]=='+') ++ans;
        else --ans;
    }
    cout << ans << endl;
}

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

int main() {
  int N, M, L, R, nextL, nextR;
  cin >> N >> M;
  cin >> L >> R;
  int min = L, max = R;
  for(int i = 1; i < M; i++) {
    cin >> nextL >> nextR;
    if (nextL > max || nextR < min) {
      min = 0;
      max = -1;
      break;
    }
    if (nextL <= min && max <= nextR) {
      continue;
    }
    if (min < nextL) min = nextL;
    if (max > nextR) max = nextR;
  }
  cout << max - min + 1<< endl;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val T = Array(N) { nextLong() }
    val ans = T.reduce { acc, t -> lcm(acc, t)}
    println(ans)
}
fun gcd(a: Long, b: Long): Long = if (b > 0) gcd(b, a % b) else a
fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 33608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 愚直計算による二項係数計算
mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

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

ll N,K;
cin >> N >> K;
rrep(i,K) {
    cout << com(N-K+1, i) * com(K-1, i-1) << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vl a(n);
    ll sum = 0; 
    REP(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sum %= MOD;
    ll ans = 0;
    REP(i, n) {
        sum = (sum + MOD - a[i]) % MOD;
        ans += a[i] * sum;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4780
<?php
$n = trim(fgets(STDIN));

for ($cake = 0; $cake <= floor($n / 4); $cake++) {
    for ($donut = 0; $donut <= floor($n / 7); $donut++) {
        if ($n - ( $cake * 4 + $donut * 7 ) === 0) {
            print 'Yes';
            exit();
        }
    }
}

print 'No';



Measured memory_bytes: 4604
mod = 1000000007
    
n=int(input())

t = list(map(int,input().split()))

if n%2==0:
    memo = [0]*n
    for i in t:
        memo[i] += 1
    for j in range(n):
        if j%2==1 and memo[j] != 2:
            print(0)
            exit()
    print((2**(n//2))%mod)  
else:
    memo = [0]*n
    for i in t:
        memo[i] += 1
    if memo[0] != 1:
        print(0)
        exit()
    memo[0]+=1
    for j in range(n):
        if j%2==0 and memo[j] != 2:
            print(0)
            exit()
    print((2**((n-1)//2))%mod) 

Measured memory_bytes: 52844
#include<bits/stdc++.h>
using namespace std;
int sol[100010],wor[100010];
int main()
{
    int n,m,p;
    char s[5];
    cin>>n;
    cin>>m;
    int c1=0,c2=0;
    for(int i=1; i<=m; i++)
    {
        cin>>p>>s;
        if(strcmp("WA",s)==0)
        {
            if(wor[p]>=0)
            {
                wor[p]++;
            }
        }
        if(strcmp("AC",s)==0)
        {
            if(wor[p]>=0 && sol[p]==0)
            {
                c1++;
                wor[p]=-wor[p];
                sol[p]++;
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(wor[i]<0)
        {
           wor[i]=-wor[i];
           c2+=wor[i];
        }
    }
    cout<<c1<<endl;
    cout<<c2<<endl;
}


Measured memory_bytes: 1024
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")

N = gets.chomp.to_i
word = gets.chomp.split("")

word.each_with_index do |e,i|
  ind = alpha.index(e)
  if ind + N < 26
	  word[i] = alpha[ind + N]
  else
    word[i] = alpha[ind + N - 26]
  end
end

puts word.join("")

Measured memory_bytes: 2172
def gcd(a, b):
    if b > a:
        gcd(b, a)
    while b:
	    a, b = b, a % b
    return a

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

l = n * m // gcd(n, m)
a = l // n
b = l // m
#print(a, b)
#a(i-1) = b(j-i) -> ai = bj + (a-b)
res = False
clear_all = True
for i in range(1,n+1):
    if (a*i - (a-b)) % b == 0:
        j = (a * i - (a-b)) // b
        if not s[i-1] == t[j-1]:
            clear_all = False
if clear_all:
    res = True
if res:
    print(l)
else:
    print(-1)
        

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;

    vector<int> A(N);
    REP0(i, N)
    {
        cin >> A[i];
    }

    vector<int> B(N);
    REP0(i, N)
    {
        cin >> B[i];
    }

    vector<int> C(N);
    REP0(i, N)
    {
        cin >> C[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    LL ans = 0;

    REP0(j, N)
    {
        auto it_a = lower_bound(A.begin(), A.end(), B[j]);
        LL a_num = it_a - A.begin();

        auto it_b = upper_bound(C.begin(), C.end(), B[j]);
        LL c_num = C.end() - it_b;

        ans += a_num * c_num;
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>

int main(){
	int N;
	std::cin >> N;
	int min, max, a;
        long long sum = 0;
	for (int i = 0; i < N; i++){
		std::cin >> a;
		if (i == 0){
			min = a;
			max = a;
		}
		if (max < a){
			max = a;
		}
		if (min > a){
			min = a;
		}
		sum += a;
	}
	std::cout << min << " " << max << " " << sum << std::endl;
	return 0;
}


Measured memory_bytes: 3116
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b = nm()
    for c in range(1, 4):
        if a * b * c % 2 == 1:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
import sys
input = sys.stdin.readline
#str 注意
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    ans = 10**10
    for i in range(-100,101):
        can = 0
        for j in range(n):
            can += (ls[j]-i)**2
        if can<=ans:
            ans = can
    
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 38768
main(){double a,b,c,d,e,f;for(;~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c-b*d)/a,d=(a*f-c*d)/(a*e-b*d)));}

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

int main() {
	int a, b;
	cin >> a >> b;
	int ret = a - 1;
	if (a > b) {
		cout << ret << endl;
		return 0;
	}
	cout << (ret + 1) << endl;
	return 0;
}



Measured memory_bytes: 256
x=1000
while True:
    y=int(input())
    if y>0:
        a=(x-y)//500
        b=(x-y)%500//100
        c=(x-y)%100//50
        d=(x-y)%50//10
        e=(x-y)%10//5
        f=(x-y)%5
        print(a+b+c+d+e+f)
    else:
        break
    


Measured memory_bytes: 5592
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<functional>
#include<string.h>
#include<set>

const int MAXN = 1e4;

int degree[MAXN];
int V, E;
std::vector<int> digrath[MAXN];

void init() {
	memset(degree, 0, sizeof(int) * V);
}

void input() {
	scanf("%d%d", &V, &E);
	init();
	for (int i = 0; i < E; i++) {
		int s, t;
		scanf("%d%d", &s, &t);
		digrath[s].push_back(t);
		degree[t]++;
	}
}

void output() {
	std::queue<int> q;
	for (int i = 0; i < V; i++) {
		if (degree[i] == 0) {
			q.push(i);
		}
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		printf("%d\n", u);
		for (std::vector<int>::iterator it = digrath[u].begin(); it != digrath[u].end(); it++) {
			degree[*it]--;
			if (degree[*it] == 0) {
				q.push(*it);
			}
		}
	}
}

int main() {
	input();
	output();
	return 0;
}


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

void print_array(vector<int> &A) {
    for (int i = 0; i < (int)A.size(); i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertion_sort(vector<int> &A) {
    int N = (int)A.size();
    for (int i = 1; i < N; i++) {
        int key = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > key) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = key;
        print_array(A);
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    print_array(A);
    insertion_sort(A);

    return 0;
}


Measured memory_bytes: 3104
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <ctime>
#include <iomanip>
#include <set>
#include <iterator>
#include <map>
using namespace std;

#define pb push_back

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)

typedef vector<int> vi;

const int INF = 1e9 + 5;


int main()
{
	int n;
	cin >> n;
	vi h(n);
	for (int& x : h)
		cin >> x;
	vi dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j : {i + 1, i + 2})
			if (j < n)
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
"""
 // Author : snape_here - Susanta Mukherjee

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading


# For getting input from input.txt file 
#sys.stdin = open('input.txt', 'r')  
  
# Printing the Output to output.txt file 
#sys.stdout = open('output.txt', 'w') 

def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def main():
    
    a,b=mi()
    print(max(a+b,a-b,a*b))
        
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 29292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int x;
            cin>>x;
            x--;
            s[i].push_back(x);
        }
    }
    int p[m];
    rep(i,m) cin>>p[i];

    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        bool ok=true;
        rep(i,m){
            int cnt=0;
            rep(j,s[i].size()){
                if(bit & 1<<s[i][j]) cnt++;
            }
            if(cnt%2!=p[i]){
                ok=false;
                break;
            }
        }
        if(ok) ans++;
    }

    cout<<ans<<endl;
    
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	double D, T, S;
	cin >> D >> T >> S;
	cout << (D / S <= T ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    var a = int.Parse(aho[0]);
    var b = int.Parse(aho[1]);
    double hati = 0.08;
    double juu = 0.1;
    for(int i = 0;i<=1000;i++){
      int c = (int)(i*hati);
      int d = (int)(i*juu);
      if(c == a&&d == b){
        Console.WriteLine(i);
        return;
      }
    }
    Console.WriteLine("-1");
  }
}
 

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

int main() {
    int N,count;
    count =0;
    cin >> N;
    vector<int> data(N);
    for(int i=0; i<N; i++){
        cin >> data.at(i);
    }
    while(true){
        bool judge = false;
        for(int i=0; i<N; i++){
            if(data.at(i) %2 != 0){
                judge = true;
            }
        }
        if(judge) break;
        for(int i=0; i<N; i++){
            data.at(i) /= 2;
        }
        count++;
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    ll N, K; cin >> N >> K;

    N %= K;

    cout << min(N, K - N) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int X = Integer.parseInt(tokens[0]);
		int A = Integer.parseInt(tokens[1]);
		in.close();
		if (X < A) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}

}

Measured memory_bytes: 21204
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    string s, ans=""; cin >> s;
    int n = s.length();
    ans += s[0];
    ans += to_string(n-2);
    ans += s[n-1];
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

//#define FILE_IO

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

int N;
pii v[100005];
LL f[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        int x;
        scanf("%d", &x);
        v[i] = {x, i};
    }

    sort(v + 1, v + N + 1);

    int id = N + 1;
    for(int i = N; i >= 1; i--)
    {
        if(id > v[i].second)    id = v[i].second;
        f[ id ] += 1LL * (v[i].first - v[i - 1].first) * (N - i + 1);
    }

    for(int i = 1; i <= N; i++)
        printf("%lld\n", f[i]);

    return 0;
}


Measured memory_bytes: 2688
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    util::get::<usize>();
    let a: Vec<usize> = util::gets();

    let le_red = a.iter()
        .filter(|&&r| r < 3200)
        .map(|r| r / 400)
        .collect::<HashSet<_>>()
        .len();
    let g_red = a.iter().filter(|&&r| r >= 3200).count();

    println!("{} {}",
             if le_red == 0 { min(g_red, 1) } else { le_red },
             le_red + g_red);
}


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

class dice{
    private:
        int order[6];
    public:
        void roll_N(){
            int tmp;
            tmp = order[0];
            order[0] = order[1];
            order[1] = order[5];
            order[5] = order[4];
            order[4] = tmp;
        }
        void roll_S(){
            int tmp;
            tmp = order[0];
            order[0] = order[4];
            order[4] = order[5];
            order[5] = order[1];
            order[1] = tmp;
        }
        void roll_W(){
            int tmp;
            tmp = order[0];
            order[0] = order[2];
            order[2] = order[5];
            order[5] = order[3];
            order[3] = tmp;
        }
        void roll_E(){
            int tmp;
            tmp = order[0];
            order[0] = order[3];
            order[3] = order[5];
            order[5] = order[2];
            order[2] = tmp;
        }
        void setOrder(int i, int ord){order[i] = ord;}
        int getOrder(int i){return order[i];}
        
        bool isSameDice(int inputed[]){
            dice tmp;
            for(int i=0;i<6;i++){
                tmp.setOrder(i,inputed[i]);
            }
            bool ch = false;
            for(int i=0;i<6;i++){
                if(i<4){
                    tmp.roll_N();
                }else if(i==4){
                    tmp.roll_W();
                    tmp.roll_N();
                }else{
                    tmp.roll_N();
                    tmp.roll_N();
                }
                for(int j=0;j<4;j++){
                    tmp.roll_W();
                    for( int k=0;k<6;k++){
                        if(order[k]!=tmp.getOrder(k)) break;
                        if(k==5) ch=true;
                    }
                    if(ch) break;
                }
                if(ch) break;
            }
            return ch;
        }
};


int main(void){

    int n;
    cin >> n;
    string out="Yes";
    int tmp[6];
    dice d[n];
    for(int i=0;i<n;i++){
        cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3] >> tmp[4] >> tmp[5];
        
        dice A;
        for(int j=0;j<6;j++){
            A.setOrder(j,tmp[j]);
        }
        d[i]=A;
        
        for(int j=0;j<i;j++){
            if(d[j].isSameDice(tmp)) out="No";
        }
        if(out=="No") break;

    }
    
    cout << out << endl;
}



Measured memory_bytes: 3216
#include <assert.h>
#include <stdio.h>

int main() {
  int n, m, a[100], r = 0, sum = 0, min;
  assert(scanf("%d %d", &n, &m) == 2);
  for (int i = 0; i < n; i++) {
    assert(scanf("%d", &a[i]) == 1);
    sum += a[i];
  }
  min = (sum + 4 * m - 1) / (4 * m);
  for (int i = 0; i < n; i++) {
    if (a[i] >= min) {
      r++;
    }
    if (r >= m) {
      break;
    }
  }
  puts(r >= m ? "Yes" : "No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

bool func(){
	int n;
	cin >> n;
	int bh = -INF;
	rep(i,n){
		int d;
		cin >> d;
		if(bh<=d-1){
			bh = d - 1;
		}else if(bh<=d){
			bh = d;
		}else{
			return false;
		}
	}
	return true;
}
int main(){
	cout << (func()?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
set<long long> b;
long long s, x, y, n, tmp;
int main()
{
    scanf("%lld", &n);
    for (long long i = 1; i <= n; i++)
        scanf("%lld", &tmp), a.push_back(tmp), s += tmp;
    x = a[0], y = s - a[0], b.insert(abs(x - y));
    for (long long i = 1; i < n - 1; i++)
        x += a[i], y -= a[i], b.insert(abs(x - y));
    printf("%lld\n", *b.begin());
    return 0;
}

Measured memory_bytes: 11120
/* Author rumoisen */
/* created 2018/11/17 */

#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 REV(c) reverse((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);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

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

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(b<=a)
        cout << "delicious" << endl;
        else if(b-a<=x)
            cout << "safe" << endl;
            else if(b-a>=x+1)
                cout << "dangerous" << endl;
            return 0;
}

Measured memory_bytes: 256
def main():
    import math
    n = int(input())
    inlis = list(map(int, input().split()))
    indic = dict()
    total = 0

    for num in inlis:
        if num in indic:
            indic[num] += 1
        else:
            indic[num] = 1
    
    for k, v in indic.items():
        total += int(v * (v-1) / 2)
    
    for num in inlis:
        print(total - indic[num] + 1)





if __name__ == "__main__":
    main()

Measured memory_bytes: 32188
#include<stdio.h>
int p[55],c[55];
int main(){
	int i,j,n,r,x;
	while(1){
		scanf("%d%d",&n,&r);
		if(n==0)break;
		for(i=0;i<r;i++)scanf("%d%d",&p[i],&c[i]);
		x=1;
		for(i=r-1;i>=0;i--){
			if(x<=c[i]){
				x=p[i]+x-1;
			}else if(c[i]<x && x<c[i]+p[i]){
				x-=c[i];
			}
			//printf(" %d\n",x);
		}
		printf("%d\n",n-x+1);
	}
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    ll N;
    cin >> N;

    unordered_set<ll> s;

    for(int i = 1; i < 10; i++ ){
       for(int j = 1; j < 10; j++ ){
            s.insert(i*j);
       }
    }

    if( s.find(N) == s.end() ){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


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

typedef long long ll;
ll n, x, a, s1, s2, mn = -2e9;
vector<ll> b, c[2];
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a);
		if (i % 2 == 0) s1 += max(a, 0LL);
		else s2 += max(a, 0LL);
		if (a > 0) {
			c[i % 2].push_back(i);
		}
		if (a > mn) {
			x = i;
			mn = a;
		}
	}
//	for (i =0; i < c[1].size(); i++) {
//		cout << c[1][i] << endl;
//	}
	if (s1 == 0 && s2 == 0) {
		for (i = 0; i < x; i++) {
			b.push_back(1);
		}
		for (i = n - x; i > 1; i--) {
			b.push_back(i);
		}
		cout << mn << endl;
		cout << b.size() << endl;
		for (i = 0; i < b.size(); i++) {
			printf("%lld\n", b[i]);
		}
	} else {
		if (s1 > s2) x = 0;
		else x = 1;
		for (i = n; i > c[x][c[x].size() - 1] + 1; i--) b.push_back(i);
		for (i = 0; i < c[x][0]; i++) b.push_back(1);
		for (i = 1; i < c[x].size(); i++) {
			for (j = (c[x][i] - c[x][i - 1]) / 2 + 1; j >= 2; j--) b.push_back(j);
		}
		cout << max(s1, s2) << endl;
		cout << b.size() << endl;
		for (i =0; i < b.size(); i++) {
			printf("%lld\n", b[i]);
		}
	}
    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,p;
    string s; cin >> s;
    n = s.length();
    p = 2019;
    ll ans = 0;
    if(p==5 || p==2){
        ll cnt = 1;
        rep(i,0,n)if((s[i]-'0')%p==0)ans +=i+1;
    }else{
        vector<int> pnum(p,0);
        pnum[0] = 1;
        int base = 1;
        int sum=0;
        rel(i,n,0){
            sum = (sum + base * (s[i]-'0')) % p;
            ans += pnum[sum]++;
            base = base * 10 % p;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll pri[1000007],h[1000007];
int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    // str st,s;
    cin >> n;
    pri[1]=1;
    for(i=2;i<=1000002;i++)
    {
        if(pri[i]==0)
        {
            pri[i]=i;
            for(j=i*i;j<=1000002;j+=i)
            {
                pri[j]=i;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        cin >> a;
        set <ll> s;
        while(a!=1)
        {
            s.insert(pri[a]);
            a/=pri[a];
        }
        for(auto it:s)
        {
            h[it]++;
        }
    }
    m=0;
    for(i=2;i<=1000002;i++)
    {
        if(pri[i]==i && h[i]>=n)
        {
            m=2;
            break;
        }
        else if(pri[i]==i && h[i]>=2)
        {
            m=1;
        }
    }
    if(m==2)
    {
        cout << "not coprime\n";
    }
    else if(m==1)
    {
        cout << "setwise coprime\n";
    }
    else
    {
        cout << "pairwise coprime\n";
    }
    return 0;
}

Measured memory_bytes: 19172
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int a, b;
	char op;
	while (cin >> a >> op >> b) {
		if (op == '?')
			break;
		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else
			cout << a / b << endl;
	}
}


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

bool isPrime(int n){
	if( n < 2 )return false;

	for(int i=2;i*i<=n;i++)
		if( n%i== 0 )
			return false;

	return true;
}

int main(){
  while(1){
  int n,count=0,s;
  cin >> n;
  if(n==0) break;
  for(int i=n+1; i<=2*n; i++){
	s=0;
	if( isPrime( i ) ) count++;
  }
  cout << count << endl;
  }
 return 0;
}




Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;
map<ll, ll> vis;

int main()
{
    ll k; cin >> k;
    int res = 0;
    ll nowmod = 0;
    while(!vis[nowmod])
    {
        vis[nowmod] = 1;
        nowmod = nowmod * 10 + 7;
        nowmod %= k;
        res++;
    }
    if(nowmod) cout << -1 << endl;
    else cout << res << endl;

}

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

int main(){
    int N,K;
    double A[210000];
    cin >> N >> K;
    rep(i,N) cin >> A[i];
    rep(i,N) A[i] = (1+A[i])/2;

    double sum[210000];
    sum[0] = A[0];
    for(int i = 1; i < N; i++) sum[i] = sum[i-1] + A[i];

    double max = sum[K-1];

    for(int i = K; i < N; i++){
        double tmp = sum[i] - sum[i-K];
        if(tmp > max) max = tmp;
    }

    printf("%f",max);
 }

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define NUMBER 1000000007
ll N, A, B;
ll squaring(ll x, ll n)
{
    if (n == 1)
        return x % NUMBER;
    if (n % 2 == 0)
    {
        ll t = squaring(x, n / 2);
        return (t * t) % NUMBER;
    }
    else
    {
        return (x * squaring(x, n - 1)) % NUMBER;
    }
}
void func()
{
    cin >> N >> A >> B;
    if (N == 2)
    {
        cout << '0' << endl;
        return;
    }
    ll max = squaring(2, N) - 1, tmp1(1), tmp2(1);
    // cout << max << endl;
    for (int i = 1; i <= A; ++i)
    {
        tmp1 *= (((N - i + 1) * squaring(A - i + 1, NUMBER - 2)) % NUMBER);
        tmp1 %= NUMBER;
    }
    for (int i = 1; i <= B; ++i)
    {
        tmp2 *= (((N - i + 1) * squaring(B - i + 1, NUMBER - 2)) % NUMBER);
        tmp2 %= NUMBER;
    }
    max -= (tmp1 + tmp2);
    while (max < 0)
        max += NUMBER;
    cout << max << endl;
}
int main()
{
    func();
}

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

#define int long long
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
int R,C,K,r,c,v,d[3123][3123],memo[3123][3123][5];
int f(int y,int x,int cnt){
  if(cnt<0||y<0||x<0)return -1e18;
  if(~memo[y][x][cnt])return memo[y][x][cnt];
  int res=f(y,x,cnt-1);
  chmax(res,f(y-1,x,3));
  if(cnt)chmax(res,f(y-1,x,3)+d[y][x]);
  chmax(res,f(y,x-1,cnt));
  chmax(res,f(y,x-1,cnt-1)+d[y][x]);
  return memo[y][x][cnt]=res;
}

signed main(){
  memset(memo,-1,sizeof(memo));
  memo[0][0][0]=0;
  cin>>R>>C>>K;
  while(K--){
    cin>>r>>c>>v;
    d[r][c]=v;
  }
  cout<<f(R+1,C+1,0)<<endl;
}


Measured memory_bytes: 458752
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long N,D,A;cin >> N >> D >> A;
    vector<P> monster(N);
    vector<long long> zahyou(N);
    for(int i = 0;i<N;i++){
        cin >> monster.at(i).first >> monster.at(i).second;
        zahyou.at(i) = monster.at(i).first;
    }
    sort(monster.begin(),monster.end());
    sort(zahyou.begin(),zahyou.end());
    //どのモンスターを何回攻撃したかをimos法的に保存する
    vector<long long> attackCount(N*5,0);
    
    long long ans = 0;
    for(int i = 0;i<N;i++){
        long long needtoDestroy = 0;
        if(monster.at(i).second % A == 0) needtoDestroy = monster.at(i).second/A;
        else needtoDestroy = monster.at(i).second/A + 1;
        if(i > 0) attackCount.at(i) += attackCount.at(i-1);
        needtoDestroy -= attackCount.at(i);
        if(needtoDestroy < 0) continue;
        //計算してモンスターを、捌いていくぅ！
        long long X = monster.at(i).first;
        auto ite = upper_bound(zahyou.begin(),zahyou.end(),X + 2*D);
        long long canCombo = distance(zahyou.begin(),ite);
        attackCount.at(i) += needtoDestroy;
        attackCount.at(canCombo) -= needtoDestroy;
        ans+=needtoDestroy;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=a;i<(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
using namespace std;

int main(){
    string St;
    cin >> St;
    bool N = false, S = false, E = false, W = false;
    REP(i,St.size()){
        char c = St[i];
        if(c == 'N'){N=true;}
        if(c == 'S'){S=true;}
        if(c == 'E'){E=true;}
        if(c == 'W'){W=true;}
    }
    bool ret = (N==S)&(E==W);
    cout << (ret ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int h = 0;
      int m = 0;
      int s = 0;
     
       if( S <= 86400 ){
           s = S % 60;
           h = ((S - s) / 60) / 60;
           m = ((S - s) / 60) % 60;
       }
     
       System.out.printf("%d:%d:%d\n", h, m, s);
   }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
pair<int ,int > a[10005];
int n,dp[100005];
int f(int h)
{
	if(h<=0)
		return 0;
	if(dp[h]!=-1)
		return dp[h];
	int ans=mod;
	int i;
	for(i=0;i<n;i++)
		ans=min(ans,a[i].second+f(h-a[i].first));
	return dp[h]=ans;
}
int main()
{fast
	int i,h;
	memset(dp,-1,sizeof(dp));
	cin>>h>>n;
	for(i=0;i<n;i++)
	cin>>a[i].first>>a[i].second;
	cout<<f(h)<<endl;
}

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

int main(){
    unsigned N, M;
    scanf("%u %u", &N, &M);
    pair<unsigned, unsigned> p[N];
    for (size_t i = 0; i < N; i++){
        scanf("%u %u", &p[i].first, &p[i].second);
    }
    sort(p, p + N);
    unsigned it = 0, answer = 0;
    priority_queue<unsigned> pq;
    for (size_t days_until = 1; days_until <= M; days_until++){
        while(it < N && p[it].first == days_until){
            pq.push(p[it].second);
            it++;
        }
        if(!pq.empty()){
            answer += pq.top();
            pq.pop();
        }
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> V(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> V[i];
    }

    ll ans = 0;
    int mm = min(N, K);
    // mm 取り出す個数
    for ( int m = 0; m <= mm; m++ ) {
        // j 左から取り出す個数
        for ( int j = 0; j <= m; j++ ) {
            priority_queue<ll, vector<ll>, greater<ll>> nv;
            ll s = 0;
            for ( int h = 0; h < j; h++ ) {
                s += V[h];
                if ( V[h] < 0 ) nv.push(V[h]);
            }
            for ( int h = N - (m - j) ; h < N; h++ ) {
                s += V[h];
                if ( V[h] < 0 ) nv.push(V[h]);
            }
            // K 操作回数
            for ( int h = 0; h < K - m && !nv.empty(); h++ ) {
                s -= nv.top();
                nv.pop();
            }
            if ( ans < s ) ans = s;
        }
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,y=0;
    cin>>x>>y;
    for(int i=0;i<=x;++i)
    {
    	if(2*i+4*(x-i)==y)
    	{
    		cout<<"Yes"<<endl;
    		return 0;
    	}
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int hpa = sc.nextInt(), ata = sc.nextInt(), hpb = sc.nextInt(), atb = sc.nextInt();

		while(true) {
			hpb -= ata;
			if(hpb <= 0) {
				System.out.println("Yes");
				break;
			}
			hpa -= atb;
			if(hpa <= 0) {
				System.out.println("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 35644
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int N;
    cin >> N;
    vector<int> A;
    vector<int> B;
    rep(i, N)
    {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    int max_n = (((N - 1) % 2 == 0) ? N - 1 : N - 2);
    for (int i = max_n; i >= 0; i -= 2)
    {
        B.push_back(A[i]);
    }
    max_n = (((N - 1) % 2 == 1) ? N - 1 : N - 2);
    for (int i = 1; i <= max_n; i += 2)
    {
        B.push_back(A[i]);
    }

    if (N % 2 == 0)
    {
        reverse(B.begin(), B.end());
    }
    rep(i, N)
    {
        cout << B[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3828