akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int n, d1, d2;
char col[601][601];

int color(int x, int y, int d)
{
  if (d % 2 == 1) {
    return (x + y) % 2;
  }
  if (d % 4 == 2) {
    return x % 2;
  }
  return color(x/2, y/2, d/4);
}

int main()
{
  cin >> n >> d1 >> d2;

  for (int x = 0; x < 2*n; x++)
    for (int y = 0; y < 2*n; y++)
      col[x][y] = 0;

  for (int x = 0; x < 2*n; x++) {
    for (int y = 0; y < 2*n; y++) {
      col[x][y] = color(x, y, d1) | (color(x, y, d2) << 1);
    }
  }

  int c[4] = {};
  for (int x = 0; x < 2*n; x++)
    for (int y = 0; y < 2*n; y++)
      c[(int)col[x][y]]++;

  int v = max_element(c, c+4) - c;
  int k = 0;
  for (int x = 0; x < 2*n; x++)
    for (int y = 0; y < 2*n; y++) {
      if (k == n*n) return 0;
      if (v == col[x][y]) {
        cout << x << " " << y << endl;
        k++;
      }
    }

  return 0;
}


Measured memory_bytes: 1280
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, K, S; cin >> N >> K >> S;
    vector<ll> ans;
    for(int i=0; i<K; i++) ans.emplace_back(S);
    for(int i=0; i<N-K; i++) ans.emplace_back(1e9 - (S == 1e9));
    for(int i=0; i<N; i++) cout << ans[i] << " \n"[i + 1 == N];
    return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<int> a(N);
    int res = 0;
    REP(i, N) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] % 2 == 1) {
            ++res;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

s=input().rstrip()
if s=="ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 9376
s = str(input())
ans = 0
num = 0
for i in s:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        num += 1
    else :
        ans = max(num,ans)
        num = 0
ans = max(num,ans)
print(ans)


Measured memory_bytes: 2940
S=`dd`
n=S.size
c=0
a=0
(n-1).downto(0){|i|(S[i]=="A"&&a+=c)||(i>0&&S[i-1]=="B"&&S[i]=="C"&&c+=1)||S[i]=="B"&&S[i+1]=="C"||c=0}
p a

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

int main() {
	int n; cin >> n;
	vector<int> h(n); rep(i, n) { cin >> h[i]; }
	if (n == 1) { cout << "Yes" << endl; return 0; }

	for (int i = n - 1; i >= 1; i--) {
		if ((h[i - 1] - h[i]) == 1) {
			h[i - 1]--;
		}
		else if ((h[i - 1] - h[i]) > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 640
n=int(input())

flg=0
for i in range(0,n//4+1):
  for j in range(0,n//7+1):
    if(i*4+j*7==n):
      flg=1
      break
  else:
    continue
  break
  
if(flg==1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c; cin >> a >> b>>c;
	//string s; cin >> s;
	if ((b - a) == (c - b))cout << "YES";
	else cout << "NO";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
int Per[2000010];
int Pow(int a,int n){
    if(n==0)return 1;
    int res=1;
    if(n%2==1)res*=a;
    return ((res*Pow(a,n/2))%mod)*Pow(a,n/2)%mod;
}
int In(int a){
    return Pow(a,mod-2);
}
int Com(int a,int b){
    return (Per[a]*In(Per[b]))%mod*In(Per[a-b])%mod;
}
signed main(void){
    Per[0]=1;
    rep(i,2000009)Per[i+1]=(Per[i]*(i+1))%mod;
    
    int x,y;cin>>x>>y;
    if(2*y-x<0||(2*y-x)%3!=0||(2*x-y)<0||(2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int a=(2*y-x)/3,b=(2*x-y)/3;
    cout<<Com(a+b,a)<<endl;
    
    
}
        

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define endl "\n"

using namespace std;

int n;
double a, s;

int main(){
    // vector<double> v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        s = s + 1/a;
    }

    cout << 1/s;






}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	int mod = (int)1e9+7;
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	int[] fact;
	private void run_case() {
		int n = reader.ni();
		int[] arr = new int[n];
		for (int i=0; i<n; i++) arr[i] = reader.ni();

		Map<Integer, Integer> map = new HashMap<>();
		for (int i=0; i<n; i++) {
			map.putIfAbsent(arr[i], 0);
			map.put(arr[i], map.get(arr[i]) + 1);
		}

		fact = new int[101];
		fact[0] = 1;
		for (int i=1; i<101; i++) {
			fact[i] = fact[i-1] * i;
		}

		long res = 0;
		for (int u : map.values()) {
			res += nCr(u, 2);
		}

		long[] resArr = new long[n];
		Arrays.fill(resArr, res);

		for (int i=0; i<n; i++) {
			resArr[i] -= (map.get(arr[i]) - 1);
		}

		for (int i=0; i<n; i++) {
			System.out.println(resArr[i]);
		}
		return;

	}

	private long nCr(int n, int r) {
		if (n < r) return 0;
	    // return fact[n] / fact[n - r] / fact[r];
		long res = 1;
		for (long i=n-r+1; i<=n; i++) {
			res *= i;
		}
		res /= 2;
		return res;
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 73016
N = int(input())
S = list(input())

# N=O(10^5)なのでO(N)で解く
# 同じ文字を1つのグループと見るときに、何グループできるか？
# 文字が変化する点に着目すればよい。するとグループ数は（変化点+1）個と求まる！

ans=1
for i in range(N-1):
  if S[i] != S[i+1]: ans += 1

print(ans)

Measured memory_bytes: 9956
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int SIZE=105;

int x[SIZE],y[SIZE],h[SIZE];

int main(){
    int n;
    scanf("%d",&n);
    int ok=0;
    for(int i=0;i<n;i++){
        scanf("%d%d%d",x+i,y+i,h+i);
        if(h[i]!=0) ok=i;
    }
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            int H=h[ok]+abs(cx-x[ok])+abs(cy-y[ok]);
            bool o=true;
            for(int i=0;i<n;i++){
                if(max(0,H-abs(cx-x[i])-abs(cy-y[i]))!=h[i]){
                    o=false;
                    break;
                }
            }
            if(o){
                printf("%d %d %d\n",cx,cy,H);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy 
 
def convolve(g, h):
  s=len(g)+len(h)+1
  n=1
  while n<s:
    n*=2
  gg=numpy.fft.fft(g+[0]*(n-len(g)))
  hh=numpy.fft.fft(h+[0]*(n-len(h)))
  ff=[gg[i]*hh[i] for i in range(n)]
  ff=numpy.fft.ifft(ff)
  ans=[int(ff[i].real+0.5) for i in range(n)]
  return ans

p=200003
n=int(input())
arr=list(map(int,input().split()))
pos={}
tmp=1
for i in range(p):
  pos[tmp]=i
  tmp*=2
  tmp%=p
cnt1=[0]*p
cnt2=[0]*p
for val in arr:
  if val!=0:
    cnt1[pos[val]]+=1
    cnt2[pos[val]]+=1
ans=convolve(cnt1,cnt2)
for val in arr:
  if val!=0:
    ans[pos[val]*2]-=1
total=0
for i in range(len(ans)):
  if ans[i]!=0:
    total+=(ans[i]//2)*pow(2,i,p)
print(total)

Measured memory_bytes: 138204
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
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;}
typedef pair<ll,ll> P;


int main(){
   int a,b;
   cin >> a >> b;
   cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3652
def is_prime(N):
    if N == 2:
        return True
    i = 2
    while i * i <= N:
        if N % i == 0:
            return False
        i += 1
    return True


def resolve():
    N = int(input())
    ans = 0
    for _ in range(N):
        ans += 1 if is_prime(int(input())) else 0
    print(ans)


resolve()



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

int main() {
	int H;
	cin >> H;
	int W;
	cin >> W;
	vector<string> s;
	for (int i = 0; i < H; i++) {
		string _s;
		cin >> _s;
		s.push_back(_s);
	}
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (s[h].at(w) == '#') {
				continue;
			}
			int count = 0;
			if (h - 1 >= 0 && w - 1 >= 0) {
				if (s[h - 1].at(w - 1) == '#') {
					count++;
				}
			}
			if (h - 1 >= 0) {
				if (s[h - 1].at(w) == '#') {
					count++;
				}
			}
			if (h - 1 >= 0 && w + 1 < W) {
				if (s[h - 1].at(w + 1) == '#') {
					count++;
				}
			}
			if (w - 1 >= 0) {
				if (s[h].at(w - 1) == '#') {
					count++;
				}
			}
			if (w + 1 < W) {
				if (s[h].at(w + 1) == '#') {
					count++;
				}
			}
			if (h + 1 < H && w - 1 >= 0) {
				if (s[h + 1].at(w - 1) == '#') {
					count++;
				}
			}
			if (h + 1 < H) {
				if (s[h + 1].at(w) == '#') {
					count++;
				}
			}
			if (h + 1 < H && w + 1 < W) {
				if (s[h + 1].at(w + 1) == '#') {
					count++;
				}
			}
			s[h].at(w) = '0' + count;
		}
	}

	for (int i = 0; i < H; i++) {
		cout << s[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>
#include <unordered_map>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



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

    unordered_map<int,int> tasu, hiku;
    for (int i = 0; i < N; i++)
    {
        tasu[i + 1 + A[i]]++;
        hiku[i + 1 - A[i]]++;
    }

    ll ans = 0;
    for (auto [k, v] : hiku)
    {
        ans += (ll)hiku[k] * tasu[k];
    }
    cout << ans << endl;
}


Measured memory_bytes: 27164
#!/usr/bin/env python3
import sys


def solve(s: int):
    nums = set([s])
    patterns = f(s, nums)

    print(len(patterns) + 1)
    return


def f(n: int, nums: set):
    before_size = len(nums)
    if n % 2 == 0:
        n = n / 2
    else:
        n = 3 * n + 1
    nums.add(n)
    if len(nums) == before_size:
        return nums

    return f(n, nums)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    s = int(next(tokens))  # type: int
    solve(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){ init(n); }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){ return root(x) == root(y); }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  i64 N, K, S;
  cin >> N >> K >> S;
  i64 x;
  if(S==1000000000) x = 1;
  else x = 1000000000;

  vi ans(N,x);
  rep(i,K) ans[i] = S;
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n;
    in>>n;
    ll ans=LLONG_MAX;
    for(ll i=1;i*i<=n;++i) if(n%i==0) ans=min(ans,i+n/i-2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.text.*;
public class Main {
  public static void main(String[] args) throws ParseException {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    char[] words = line.toCharArray();
    int count = 0;
    for (int i = 0; i < line.length(); i++) {
      for (int j = 1; j < line.length() - i; j++) {
        if (words[i] == words[i + j]) {
          count++;
        }
      }
    }
    if (count == 0) {
      System.out.println("yes");
    } else {
      System.out.println("no");
    }
  }
}

Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define F0r(i, a, b) for(int i=a; i<(b); i++)
#define For(i, a)    for(int i=0; i<(a); i++)
#define F0rd(i,a,b)  for(int i = (b)-1; i >= a; i--)
#define Ford(i,a)    for(int i = (a)-1; i >= 0; i--)

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int n,m;
	cin >> n >> m;
	vi arr(n);
	For(i,n){
		cin >> arr[i];
	}
	sort(all(arr));
	int sum = 0;
	For(i,m){
		sum += arr[i];
	}
	cout << sum << nl;
	return 0;
}


Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, r = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))

Measured memory_bytes: 38256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int R, G, B, N; std::cin >> R >> G >> B >> N;

  int cnt = 0;
  for (int r = 0; r <= N/R; ++r) {
    for (int g = 0; g <= N/G; ++g) {
      int b = N - R*r - G*g;
      if (b < 0) break;
      if (b % B == 0) {
        ++cnt;
      }
    }
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let mut h: Vec<i32> = (0..n).map(|_| input()).collect();
    h.sort();

    let ans = h.windows(k).map(|h| h[k - 1] - h[0]).min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for j in range(N)]
#print(F, P)
m = -float("INF")
for i in range(1,1024):
    n = 0
    for j in range(N):
        c = 0
        for k in range(10):
            if i >> k & 1:
                if F[j][k] == 1:
                    c += 1
        n += P[j][c]
    m = max(m, n)
print(m)


Measured memory_bytes: 3064
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  ll n,m;
  cin >> n >> m;
  ll ac = 0;
  ll wa = 0;
  ll table[n+1];
  ll p;
  string s;
  for(int i=0;i<n+1;i++) table[i] = 0;

  for(int i=0;i<m;i++){
    cin >> p >> s;
    if(s == "WA" && table[p]>=0) table[p]++;
    if(s == "AC" && table[p]>=0){
      wa += table[p];
      ac++;
      table[p] = -1;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 1024
/*
ID: c4ts0up
LANG: C++
TASK: C - Fennec vs Monster
URL: 
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int n, k;
priority_queue <ll> arr;

int main() {
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		ll aux;
		cin >> aux;
		arr.push(aux);
	}
	
	while (!arr.empty() && k > 0) {
		arr.pop();
		k--;
	}
	
	ll res = 0;
	while (!arr.empty()) {
		res += arr.top();
		arr.pop();
	}
	
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2420
n=int(input())

a=[int(input()) for i in range(n)]

dic={}

for i in range(n):
    if a[i] not in dic:
        dic[a[i]]=1
    else:
        dic[a[i]]+=1

ans=0

for val in dic.values():
    if val%2==1:
        ans+=1

print(ans)

Measured memory_bytes: 59736
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
	using namespace std;

	string s;
	cin >> s;

	auto ans{ 0_sz };

	for (int i = 0; i < s.size(); ++i)
	{
		for (int len = 1; len <= s.size(); ++len)
		{
			auto sub = s.substr(i, len);
			if (all_of(sub.cbegin(), sub.cend(), [](char c)
				{return c == 'A' || c == 'T' || c == 'G' || c == 'C'; }))
			{
				ans = max({ ans, sub.size() });
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    char str[20001];
    int m, tmp, length;
    while(true){
        scanf("%s", str);
        if(str[0] == '-') break;
        length = 0;
        for(int k = 0; str[k] != '\0';k++) length++;
        scanf("%d", &m);
        int index = 0;
        for(int i = 0; i < m; i++){
            scanf("%d", &tmp);
            for(int j = 0; j < tmp; j++){
                str[index+length] = str[index];
                index++;
            }
        }
        for(int p = 0; p < length; p++){
            printf("%c", str[index+p]);
        }
        printf("\n");
    }
    return 0;
}



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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    ll s; cin >> s;
    ll x1 = 0, y1 = 0, x2 = 1, x3 = 1e9, y2 = s / x3 + 1, y3 = x3 - s % x3;
    if(y3 == x3) y3 -= x3, y2--;
    cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;	
	return 0;
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
@m=[]
def solve(cal,a,len,x)
  return if(a[x] == nil)
  ans = (cal == "+")? 0 : 1
  while(a[x].size >= len)
  if((a[x][-1] == "+" or a[x][-1] == "*") and a[x].size == len)
    @m.push(a[x][-1])
    ans += solve(a[x][-1],a,len+1,x+1) if(cal == "+")
    ans *= solve(a[x][-1],a,len+1,x+1) if(cal == "*")
  else
    if cal == "+"
      ans += (a[x].size == len)?  a[x][-1].to_i : 0
    else
      ans *= (a[x].size == len)?  a[x][-1].to_i : 1  
    end
  end
  x+=1
  break if(a[x] == nil)
  end
  return ans
end
while((n = inp[0])!=nil)
  if(n == 1)
    puts inp[0]
    next
  end
  tab = []
  n.times do 
    tab.push(gets.chomp)
  end
  ans = solve(tab[0],tab,1,0) 
  if(ans == nil)
    exit
  end
  p ans 
end

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

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool flag = true;
	while(true) {
		if(flag) {
			c-=b;
			if(c<=0) {
				cout <<"Yes";
				return 0;
			}
			flag = false;
		} else {
			a-=d;
			if(a<=0) {
				cout << "No";
				return 0;
			}
			flag = true;
		}
	}
	return 0; 	
}

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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
#ifdef SunWalker
    //read;
   //write;
#endif

int k,x;
cin>>k>>x;
FOR1(i,(x-k)+1,x-1)
{
     cout<<i<<" ";
}
FOR1(i,x,(x+k)-1)
{
     cout<<i<<" ";
}

cout<<"\n";
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    int hash[26]= {0};
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            ans++;
    }

  
    cout << ans;
}

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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
using ll = long long;

const int INF = 1e8+10;

int n;
int a[3];
vector<int> v,ans(3,INF);

bool ok(int i,int j,int k){
	for(int u=0;u<n;++u){
		bool x = (((1<<u)&i) != 0);
		bool y = (((1<<u)&j) != 0);
		bool z = (((1<<u)&k) != 0);
		if((x&&y) || (x&&z) || (y&&z))
			return false;
	}
	return true;
}

int main(){
	fastIO;
	cin >> n;
	for(int i=0;i<3;++i) cin >> a[i];
	v = vector<int>(n);
	for(int &x:v) cin >> x;
	for(int i=1;i<(1<<n);++i){
		int mp_a=0,sz_a=0,qtd_a=-1;
		for(int u=0;u<n;++u){
			if(((1<<u)&i) != 0){
				qtd_a++;
				sz_a+=v[u];
			}
		}
		mp_a = 10*qtd_a;
		for(int j=1;j<(1<<n);++j){
			int mp_b=0,sz_b=0,qtd_b=-1;
			for(int u=0;u<n;++u){
				if(((1<<u)&j) != 0){
					qtd_b++;
					sz_b+=v[u];
				}
			}
			mp_b = 10*qtd_b;
			for(int k=1;k<(1<<n);++k){
				int sz_c=0,mp_c=0,qtd_c=-1;
				for(int u=0;u<n;++u){
					if(((1<<u)&k) != 0){ 
						qtd_c++;
						sz_c+=v[u];
					}
				}
				int nums = qtd_a+qtd_b+qtd_c;
				if(!ok(i,j,k) || nums > n){
					continue;
				}
				mp_c = 10*qtd_c;
				ll ans_a = abs(a[0]-sz_a)+mp_a;
				ll ans_b = abs(a[1]-sz_b)+mp_b;
				ll ans_c = abs(a[2]-sz_c)+mp_c;
				ll n_ans = ans_a + ans_b + ans_c;
				ll old_ans = ans[0]+ans[1]+ans[2];
				//cout << "n_ans = " << n_ans << " old_ans = " << old_ans << endl;
				if(n_ans < old_ans){
					ans[0] = ans_a;
					ans[1] = ans_b;
					ans[2] = ans_c;
				}
			}		
		}
	}
	int xd = ans[0]+ans[1]+ans[2];
	cout << xd << '\n';
	return 0;
}

Measured memory_bytes: 256
<?php

myMain($argv);

class Util
{
    private static $isDebug = false;
    private static $startTime;

    public static function input($isSplitSpace = false)
    {
        $input = trim(fgets(STDIN));
        if (!$isSplitSpace) {
            return $input;
        }

        return explode(' ', $input);
    }

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

    public static function enablingDebug()
    {
        self::$isDebug = true;
        self::$startTime = time();
    }

    public static function DebugLog($text, $isReturn = true)
    {
        if (self::$isDebug) {
            echo $text;
            if ($isReturn) {
                echo PHP_EOL;
            }
        }
    }

    public static function varDump($obj)
    {
        if (self::$isDebug) {
            var_dump($obj);
        }
    }

    public static function arrFirst($arr)
    {
        if (empty($arr) || !is_array($arr)) {
            return null;
        }

        return current($arr);
    }

    public static function printBench()
    {
        if (!self::$isDebug) {
            return;
        }

        echo sprintf(" Time: %.3f s" . PHP_EOL, time() - self::$startTime);
    }
}

function myMain($argv)
{
    if (!empty($argv[1])) {
        Util::enablingDebug();
    }

    // START
    list($n) = Util::input(true);

    // init
    $a = new Point(0, 0);
    $b = new Point(100, 0);

    Point::stackPoint($a);
    koch($n, $a, $b);
    Point::stackPoint($b);

    Point::printPointList();

    // bench
    Util::printBench();
}

class Point
{
    public $x;
    public $y;

    /** @var Point[] */
    private static $_pointList = [];

    public static function stackPoint(Point $p)
    {
        self::$_pointList[] = $p;
    }

    public static function printPointList()
    {
        foreach (self::$_pointList as $p) {
            echo $p->x . " " . $p->y . PHP_EOL;
        }
    }

    public function __construct($x, $y)
    {
        $this->x = $x;
        $this->y = $y;
    }
}

function koch($n, Point $a, Point $b)
{
    if ($n <= 0) {
        return;
    }

//    $s = new Point(
//        abs($b->x - $a->x) / 3 * 1 + $a->x,
//        abs($b->y - $a->y) / 3 * 1 + $a->y
//    );
//
//    $t = new Point(
//        abs($b->x - $a->x) / 3 * 2 + $a->x,
//        abs($b->y - $a->y) / 3 * 2 + $a->y
//    );

    $s = new Point(
        (2.0 * $a->x + 1.0 * $b->x) / 3,
        (2.0 * $a->y + 1.0 * $b->y) / 3
    );

    $t = new Point(
        (1.0 * $a->x + 2.0 * $b->x) /3,
        (1.0 * $a->y + 2.0 * $b->y) /3
    );

    $u = round60($s, $t);

    koch($n - 1, $a, $s);
    Point::stackPoint($s);

    koch($n - 1, $s, $u);
    Point::stackPoint($u);

    koch($n - 1, $u, $t);
    Point::stackPoint($t);

    koch($n - 1, $t, $b);
}

// $a を起点として、$bを60度回転させた座標を返す
function round60(Point $a, Point $b)
{
    $rad60 = pi() / 3;
    $cx = ($b->x - $a->x) * cos($rad60) - ($b->y - $a->y) * sin($rad60) + $a->x;
    $cy = ($b->x - $a->x) * sin($rad60) + ($b->y - $a->y) * cos($rad60) + $a->y;

    return new Point($cx, $cy);
}


Measured memory_bytes: 11104
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)

typedef long long ll;

const int N = 4e5 + 5;

ll n, p, ans = 1, a[N];
int tot, b[N];

int main()
{
	std::cin >> n >> p;
	int i, j, S = sqrt(p);
	For (i, 2, S)
	{
		if (p % i) continue;
		a[++tot] = i;
		while (p % i == 0) p /= i, b[tot]++;
	}
	if (p > 1) a[++tot] = p, b[tot] = 1;
	For (i, 1, tot) For (j, 1, b[i] / n)
		ans *= a[i];
	std::cout << ans << std::endl;
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);
int fun(int n )
{
	int res = 0;
	int x = 5;
	while(x <= n)
	{
		res += n/x;
		x = x*5;
	}
	return res;
}

int fun1(int n ) // 2
{
	int res = 0;
	int x = 2;
	while(x <= n)
	{
		res += n/x;
		x = x*2;
	}
	return res;
}
int32_t main(){
	fast;
	int n;
	cin >> n;
	int ans;
	int two = 0;
	int five = 0;
	if(n%2==0)
	{
		two = 1 + fun1(n/2);
		five = fun(n/2);
	}
	else
	{
		cout << 0;
		return 0;
	}
	ans = max(0LL,min(two,five));
	cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,ans=-(1<<30),c,d;
  cin>>n;
  int f[n][10],p[n][11];
  rep(i,n){
    rep(j,10){
      cin>>f[i][j];
    }
  }
  rep(i,n){
    rep(j,11){
      cin>>p[i][j];
    }
  }
  for(int b=1;b<1024;b++){
    d=0;
    rep(i,n){
      c=0;
      rep(j,10){
        if((b>>j&1)&&f[i][j]){c++;}
      }
      d+=p[i][c];
    }
    ans=max(d,ans);
  }
  cout<<ans;
}

Measured memory_bytes: 256
from numba import njit
import numpy as np


def main(A, B, C, K):
    if K < A:
        return K
    if K > A+B:
        return A-(K-A-B)
    else:
        return A


A, B, C, K = map(int, input().split())
ans=main(A, B, C, K)
print(ans)


Measured memory_bytes: 91872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    map<char, int> ma;
    for(int i = 0; i < s.size(); ++i){
        ma[s[i]]++;
    }
    for(char c = 'a'; c <= 'z'; c++){
        if(ma[c] == 0){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    VP X(N); 
    VL XX(N);
    rep(i, 0, N){
        ll x, h;
        cin >> x >> h;
        h = (h+A-1)/A;
        X[i] = {x, h};
        XX[i] = x;
    }
    sort(ALL(X));
    sort(ALL(XX));

    ll ans = 0;
    VL imos(N+1, 0);
    rep(i, 0, N){
        imos[i+1] += imos[i];
        X[i].second += imos[i];
        if(X[i].second <= 0) continue;
        ans += X[i].second;
        if(i == N-1) break;
        auto itr = upper_bound(XX.begin()+i, XX.end(), X[i].first+2*D);
        auto pos = distance(XX.begin(), itr);
        if(pos-1 > i){
            imos[i+1] -= X[i].second;
            imos[pos] += X[i].second;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, h, ans = 0, m = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> h;
		ans += h >= m;
		m = max(m, h);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n, number;
  char picture;
  int cards[4][13] = {0};
  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf(" %c %d", &picture, &number);
    if(picture == 'S'){
      cards[0][number-1] = 1;
    }else if(picture == 'H'){
      cards[1][number-1] = 1;
    }else if(picture == 'C'){
      cards[2][number-1] = 1;
    }else if(picture == 'D'){
      cards[3][number-1] = 1;
    }
  }

  for(int i = 0; i < 13; i++){
    if(cards[0][i] != 1){
      printf("S %d\n", i+1);
    }
  }
  for(int i = 0; i < 13; i++){
    if(cards[1][i] != 1){
      printf("H %d\n", i+1);
    }
  }
 for(int i = 0; i < 13; i++){
    if(cards[2][i] != 1){
      printf("C %d\n", i+1);
    }
  }
 for(int i = 0; i < 13; i++){
    if(cards[3][i] != 1){
      printf("D %d\n", i+1);
    }
  }
}



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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}


/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

constexpr int mod = 1e9+7;
//constexpr int inf = 1<<30;

signed main(){
  int n;
  cin >> n;

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

  vi cnt(61);
  rep(i, 0, n){
    rep(j, 0, 61){
      cnt[j] += (a[i]>>j & 1);
    }
  }

  int ans = 0;
  rep(i, 0, 61){
    ans += (1LL<<i)%mod*cnt[i]%mod*(n-cnt[i])%mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){
  
  int n,m;
  cin >> n >> m;
  
  bool start[n+1],goal[n+1];
  
  REP(i,n+1) {
    start[i] = false;
    goal[i] = false;
  }
  
  REP(i,m){
    int x,y;
    cin >> x >> y;
    if(x == 1) start[y] = true;
    if(y == n) goal[x] = true;
  }
  
  bool f = false;
  REP(i,n)
    if(start[i] && goal[i]) f = true;
  
  if(f) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
 
 return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){

  vector <int> G[56];

  int n,m;

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

  int i;
  for(i = 0;i < m;i++){
    int a,b;
    scanf("%d %d", &a, &b);

    G[a].push_back(b);
    G[b].push_back(a);
  }

  for(i = 1;i <= n;i++) {
    int ans;
    ans = G[i].size();
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define o(s) cout<< s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int n[4]={}; rep(i,4)cin>>n[i];
   sort(n,n+4);
   cout<<(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9?"YES":"NO")<<endl;
}


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

struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1){
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i, n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x){
    if (x == par[x]) return x;
    return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
  }

  // 二つのデータx, yが属する木をマージする
  void unite(int x, int y){
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y)  return;

    // xの木がyの木より大きくなるようにする

    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];

  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y){
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};


struct Edge
{
  int a, b, cost;
  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }

};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n; //頂点数
  vector<Edge> es; //辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal(){
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()){
      Edge& e = es[ei];
      if(!uf.same(e.a, e.b)){
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

Graph input_graph(int k, int l){
  Graph g;
  int m;
  g.n = k;
  m = l;
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    g.es.push_back(e);
  }
  return g;

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  Graph g;
  while((cin >> n >> m) && n){
    g = input_graph(n, m);
    cout << g.kruskal() << endl;
  }

  

}


Measured memory_bytes: 3068
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        int count = 0;
        while (a <= b)
        {
            if (c % a == 0)
            {
                ++count;
            }
            a++;
        }
        Console.WriteLine("{0}" ,count);
    }
}


Measured memory_bytes: 9136
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    a,b := nextInt(), nextInt()
    if b%a == 0 {
        fmt.Println(a + b)
    } else {
        fmt.Println(b - a)
    }
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



Measured memory_bytes: 640
def MultipleOf9():
    
    num = str(input())

    count = 0

    for i in range(len(num)):
        
        count = count + int(num[i])
        
    if count % 9 == 0:
        print('Yes')
        
    else:
        print('No')
        
if __name__ == '__main__':
    MultipleOf9()



Measured memory_bytes: 9276
[n, k] = map(int, input().split(' '))
wi = list(map(int, [input() for i in range(n)]))

def isAllocatable(p):
  kw, ki = 0, 1
  for w in wi:
    if w > p: return False
    kw += w
    if kw <= p: continue
    ki += 1
    if k < ki: return False
    kw = w
  return True

l = 0
r = sum(wi)
while l + 1 < r:
  p = int((l + r) / 2)
  if isAllocatable(p): r = p
  else: l = p
print(r)



Measured memory_bytes: 15824