akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;

ll T,n,s[N],t[N],A[N];

int bs(int idx){

  int l=idx,r=n;
  
  while(l<r){

    int m=(l+r)/2;

    ll tim=t[m];
    
    tim-=s[idx]-1;

    if(tim>T) r=m;
    else l=m+1;
    
  }

  return l;
}

int main(){

  cin>>T>>n;
  
  for(int i=0;i<n;i++){
    scanf("%lld %lld",&s[i],&t[i]);
    t[i]--;
  }
  
  A[0]=t[0]-s[0]+1;

  for(int i=1;i<n;i++)
    A[i]=A[i-1]+t[i]-s[i]+1;

  ll ans=0;
  
  for(int i=0;i<n;i++){

    int r=bs(i);

    ll a=0, b=0, c=0;
    
    if(r-1>=0) a=A[r-1];
    if(i-1>=0) b=A[i-1];
    if(r<n) c=max(0LL,T-(s[r]-s[i]));
    
    ans=max(ans,a-b+c);
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

LL calc(LL x) {
  if (x % 4 == 0) return x;
  if (x % 4 == 1) return 1;
  if (x % 4 == 2) return x + 1;
  if (x % 4 == 3) return 0;
}

int main() {
  LL A, B;
  cin >> A >> B;

  cout << (calc(A-1) ^ calc(B)) << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    string S,T;
    cin>>N>>S>>T;
    vector<string> ANS(2*N);
    rep(i,N){
        string A=S.substr(i,1);
        ANS[i*2]=A;
    }
    rep(i,N){
        string A=T.substr(i,1);
        ANS[i*2+1]=A;
    }
    string B;

    rep(i,2*N)B+=ANS[i];
    cout<<B<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll memo[444][444], a[444], sum[444];

ll dfs(ll le, ll ri) {
  if (memo[le][ri]) return memo[le][ri];
  if (le == ri) return 0;
  ll res = inf;
  FOR(i, le, ri) {
    ll temp = dfs(le, i) + dfs(i + 1, ri);
    temp += sum[ri];
    if (le) temp -= sum[le - 1];
    res = min(res, temp);
  }
  return memo[le][ri] = res;
}


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


  cin >> n;
  rep(i, n) cin >> a[i];
  sum[0] = a[0];
  FOR(i, 1, n) sum[i] = sum[i - 1] + a[i];
  cout << dfs(0, n - 1) << endl;




  return 0;
}

Measured memory_bytes: 1664
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int h = 0;
			int d = in.nextInt();
			for(int i=d; i<600; i=i+d){
				h = h+i*i;
			}
			System.out.println(h*d);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
    long long n,k;
    cin >> n >> k;
    while(1) {
        n = n % k;
        if(n < k){
            n = (n > abs(n-k))? abs(n-k): n; 
            break;
        }
    }
    cout << n << endl;
    return 0;
}


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

int compare(string s){
  int sum=0;
  for(int i=0;i<(int)s.size()/2;i++){
    if(s.at(i)!=s.at(s.size()-1-i)){
      sum++;
      break;
    }
  }
  return sum;
}
      
int main(){
 string S;
  cin>>S;
  int a;
  int N =(int)S.size();
  a=compare(S);
 int b=0;
  for(int i=0;i<N/4;i++){
    if(S.at(i)!=S.at(N/2-1-i)){
      b++;
      break;
    }
  }
  for(int i=0;i<N/4;i++){
    if(S.at((N+1)/2+i)!=S.at(N-1-i)){
      b++;
      break;
    }
  }
  if(a+b==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 3536
N = int(input())
c = [input() for i in range(N)]
num_AC = c.count('AC')
print('AC x {}'.format(num_AC))
num_WA = c.count('WA')
print('WA x {}'.format(num_WA))
num_TLE = c.count('TLE')
print('TLE x {}'.format(num_TLE))
num_RE = c.count('RE')
print('RE x {}'.format(num_RE))

Measured memory_bytes: 16152
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') a++;
        else b++;
    }
    
    cout << s.size() - abs(b - a) << endl;
    
}


Measured memory_bytes: 512
class RMQ():
    def __init__(self, array):
        k = 1
        while k < len(array):
            k <<= 1
        self.halflen = k
        self.tree = [0] * k + array + [10 ** 18] * (k - len(array))
        for i in reversed(range(k)):
            self.tree[i] = min(self.tree[i << 1], self.tree[(i << 1) | 1])

    def update(self, i, value):
        i |= self.halflen
        self.tree[i] = value
        i >>= 1
        while i:
            self.tree[i] = min(self.tree[i << 1], self.tree[(i << 1) | 1])
            i >>= 1

    def query_(self, i, left, right, l, r):
        if (left, right) == (l, r):
            return self.tree[i]
        ret = 10 ** 18
        m = (l + r) >> 1
        if left <  m:
            ret = min(ret, self.query_(i << 1, left, min(m, right), l, m))
        if right > m:
            ret = min(ret, self.query_((i << 1) | 1, max(left, m), right, m, r))
        return ret

    def query(self, left, right):
        return self.query_(1, left, right, 0, self.halflen)

n, q = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(q)]

r = RMQ([2 ** 31 - 1] * n)
for com, x, y in query:
    if com == 0:
        r.update(x, y)
    else:
        print(r.query(x, y+1))


Measured memory_bytes: 24684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

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

    sort(all(a));
    reverse(all(a));

    int64_t ans=0;
    n--;
    int cnt=0;
    ans+=(int64_t)a[cnt];
    n--;
    cnt++;
    while(n>0){
        ans+=(int64_t)a[cnt];
        n--;
        if(n==0) break;
        ans+=(int64_t)a[cnt];
        n--;
        cnt++;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 4016
#coding:utf-8

import sys

def calc(nums):
    a = nums[0]
    b = nums[1]
    c = nums[2]
    d = nums[3]
    e = nums[4]
    f = nums[5]

    val = 1 / (a * e - b * d)

    x = val * (e * c - b * f) + 0.
    y = val * (- c * d + a * f) + 0.

    return  "%0.3f" % round(x, 3), "%0.3f" % round(y,3)


if __name__ == '__main__':

    lines = []

    for line in sys.stdin:
        if line == "\n":
            break
        else :
            lines.append(line)

    for line in lines:
        x,y = calc([ int(item) for item in line.split(" ")])

        print(str(x) + " " + str(y))

Measured memory_bytes: 7560
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
struct UnionFind
{
    vector<int> par,num; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N),num(N,1)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        num[ry]+=num[rx];
    }

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    ll n,k,l;
    cin>>n>>k>>l;
    UnionFind tree(n);
    rep(i,k){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        tree.unite(x,y);
    }
    UnionFind tree2(n);
    rep(i,l){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        tree2.unite(x,y);
    }
    map<P,ll> mp;
    rep(i,n){
        mp[{tree.root(i),tree2.root(i)}]++;
    }
    rep(i,n){
        cout<<mp[{tree.root(i),tree2.root(i)}]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 15104
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8').split(/[ \n]/);
const h: number = +input[0];
const n: number = +input[1];

let a: number[] = [];

for (let i = 0; i < n; i++) {
  a[i] = +input[i + 2];
}

const result = a.reduce((prev, current) => prev + current, 0)

console.log((result >= h) ? 'Yes' : 'No');




Measured memory_bytes: 26700
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
P bingo1[1000001];
P bingo2[1000001];
int app1[1000001] = {};
int app2[1000001] = {};
int main() {
	int n, u, v, m; cin >> n >> u >> v >> m;
	int h1[500] = {}; int w1[500] = {}; int c1[2] = {}; int c2[2] = {};
	int h2[500] = {}; int w2[500] = {};
	int x;
	rep(i, n) {
		rep(j, n) {
			cin >> x; bingo1[x] = { i,j }; app1[x] = 1;
		}
	}
	rep(i, n) {
		rep(j, n) {
			cin >> x; bingo2[x] = { i,j }; app2[x] = 1;
		}
	}
	int cnt1 = 0; int cnt2 = 0;
	bool f = false;
	if (n == 1) {
		rep(i, m) {
			cin >> x;
			if (f)continue;
			if (app1[x])cnt1++;
			if (app2[x])cnt2++;
			if (cnt1 >= u && cnt2 >= v) {
				cout << "DRAW" << endl; f = true;
			}
			else if (cnt1 >= u) {
				cout << "USAGI" << endl; f = true;
			}
			else if (cnt2 >= v) {
				cout << "NEKO" << endl; f = true;
			}
		}
		if (!f) {
			cout << "DRAW" << endl;
		}
		return 0;
	}
	rep(i, m) {
		cin >> x;
		if (f)continue;
		if (app1[x]) {
			int x1 = bingo1[x].first; int y1 = bingo1[x].second;
			h1[x1]++; if (h1[x1] == n)cnt1++;
			w1[y1]++; if (w1[y1] == n)cnt1++;
			if (x1 == y1) {
				c1[0]++; if (c1[0] == n)cnt1++;
			}
			if (x1 + y1 == n - 1) {
				c1[1]++; if (c1[1] == n)cnt1++;
			}
		}
		if (app2[x]) {
			int x2 = bingo2[x].first; int y2 = bingo2[x].second;
			h2[x2]++; if (h2[x2] == n)cnt2++;
			w2[y2]++; if (w2[y2] == n)cnt2++;
			if (x2 == y2) {
				c2[0]++; if (c2[0] == n)cnt2++;
			}
			if (x2 + y2 == n - 1) {
				c2[1]++; if (c2[1] == n)cnt2++;
			}
		}
		if (cnt1 >= u && cnt2 >= v) {
			cout << "DRAW" << endl; f = true;
		}
		else if (cnt1 >= u) {
			cout << "USAGI" << endl; f = true;
		}
		else if (cnt2 >= v) {
			cout << "NEKO" << endl; f = true;
		}
	}
	if (!f) {
		cout << "DRAW" << endl;
	}
	return 0;
}


Measured memory_bytes: 26552
def minute(time)
  h, m = time.split(":").map(&:to_i)
  h*60 + m
end

N, T = gets.split.map(&:to_i)
from, start, to, arrive = gets.split
pre = minute(to)
count = 0
answer = Array.new
(N-1).times do
  from, start, to, arrive = gets.split
  if (dif = minute(from) - pre) >= T
    count += 1
    answer.push("#{start} #{dif}")
  end
  pre = minute(to)
end
puts count, answer

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
 
using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////


void solve(){
  ini(K);
  vl a(K); in(a);
//  trc(a);
  if(a.back() != 2) die(-1);
  ll l = 2 , r = 2;
  repr(i , K){
    ll x = a[i];
    // [l , r]の範囲内でxの倍数のmin/maxは？
    ll mi = (l + x - 1) / x * x;
    ll ma = r / x * x;
    trc(x , l , r , mi , ma);
    if(mi > ma) die(-1);
    l = mi , r = ma + x - 1;
  }
  out(l , r);
}

Measured memory_bytes: 1024
#include <stdio.h>

void main(){
    int N,K;
    scanf("%d%d",&N,&K);
    long long A[N];
    for(int i = 0;i < N;i++){
        scanf("%lld",A+i);
    }
    for(int i = 0;i < N-K;i++){
        if(A[i] < A[K+i]){printf("Yes\n");}
        else{printf("No\n");}
    }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
    ll N;
    cin>>N;
    ll five[10000];
    for(int i = 1;i<=30;i++){
        five[i] = pow(5,i)*2;
    }
    ll ans = 0;
    for(int i = 1;i<30;i++){
        ans += N/five[i];
    }
    if(N%2 == 1){
        cout << 0 << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

#define POW5(n) (n * n * n * n * n)

using namespace std;
int main(void) {
  lld a[200000], n, k, s = 0;
  cin >> n;
  unordered_map<lld, lld> m;
  for (lld i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    auto it = m.find(a[i]);
    if (it != m.end()) {
      it->second++;
    } else {
      m[a[i]] = 1;
    }
  }
  for (lld i = 0; i < n; i++) {
    k = -(a[i] + i) - i;
    auto it = m.find(k);
    if (it != m.end()) {
      s += it->second;
    }
  }
  cout << s << "\n";
}

Measured memory_bytes: 12416
#include<stdio.h>
int main(void){
    int i,d;
    d=0;
    char A[2];
    gets(A);
   for(i=0;i<3;i++){
       if(A[i]=='1'){
           d++;
       }
   }
   printf("%d\n",d);
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long a, b;
  char op;
  cin >> a >> op >> b;

  if (op == '+') {
    cout << a + b << endl;

  } else {
    cout << a - b << endl;
  }
}


Measured memory_bytes: 3584
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using ll=long long int;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
constexpr int INF=1<<30;
#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 RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

#define EVALe 1

#ifdef EVAL
#define LOG(i) 0
#else
#define LOG(i) cerr<<#i<<": "<<i<<endl
#endif

struct monst{ // also, attack.
	ll pos,hp;
};
auto M=vector<monst>(2e5);
void solve(){
	ll N,D,A,ans=0;
	cin>>N>>D>>A;
	ll X,H;
	REP(i,N){
		scanf("%lld%lld",&X,&H);
		M[i]={X,H};
	}
	sort(&M[0],&M[N],[](auto a,auto b){return a.pos<b.pos;});
	//REP(i,N)LOG(M[i].pos);
	queue<monst> atks;
	ll atk=0;
	REP(i,N){
		auto m=M[i];
		while(atks.size()>0&&atks.front().pos+D<m.pos){
			atk-=atks.front().hp;
			atks.pop();
		}
		if(m.hp>atk){
			ll neededbombs=(m.hp-atk+A-1)/A;
			ll bombhp=neededbombs*A;
			atk+=bombhp;
			atks.push({m.pos+D,bombhp});
			LOG(m.pos+D);
			LOG(bombhp);
			ans+=neededbombs;
		}
	}
	cout<<ans<<endl;
	//cout<<(H<=0?"Yes":"No")<<endl;
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
//use brackets before operations if taking MOD
//use map only when necessary
//give long long to arrays and variables properly
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	//a = (a%mod+mod)%mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}


int main() {
	fast();

	int n,m; cin>>n>>m;
	vector<string> s(n+1);
	for(int i = 1;i<=n;i++){
		cin>>s[i];
		s[i] = ' '+s[i]+' ';
	}
	vector<vector<int> > dp(n+1, vector<int> (m+1, INF));
	dp[1][1] = (s[1][1]=='#');
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=m;j++){
			// cout<<dp[i][j]<<' ';
			if(i+1<=n)
			dp[i+1][j] = min(dp[i][j]+(s[i][j]=='.' && s[i+1][j]=='#'), dp[i+1][j]);
			if(j+1<=m)
			dp[i][j+1] = min(dp[i][j]+(s[i][j]=='.' && s[i][j+1]=='#'), dp[i][j+1]);
		}
		// pl;
	}
	cout<<dp[n][m]<<endl;

	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
dp = [0] * (N+1)
dp[0] = 1
p = 10**9 + 7

for i in range(M):
  dp[int(input())] = -1

for i in range(N):
  if dp[i] == -1: continue
  a = dp[i] % p
  if dp[i+1] != -1: dp[i+1] += a
  if i+1 < N and dp[i+2] != -1: dp[i+2] += a

print(dp[-1] % p)

Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//制約上乗算するとオーバーフローしそう？
//あまりを使う？
int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    if(x < 0)x *= -1;
    ll t = min(x/d,k);
    x -= t * d;
    k -= t;
    if(!(k%2))cout << abs(x) << "\n";
    else cout << abs(x - d) << "\n";
    return 0;
}


Measured memory_bytes: 3552
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

string s;

int main() {
  cin >> s;
  int n = s.size();
  if (n & 1) puts("No");
  else {
    for (rint i = 0; i < n; i += 2) {
      if (s[i] != 'h' || s[i + 1] != 'i') {
        puts("No");
        return 0;
      }
    } 
    puts("Yes");
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ar = list(map(int,input().split()))
s = sum(ar)
av = s/(4*m)
ct = 0
for i in range(n):
  if(ar[i] >= av):
    ct += 1
if(ct >= m):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }

    println!("{}", max(max(a,b),c)*9+a+b+c);


}


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

int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  int x=max(a,c),y=min(b,d);
  int ans=max(0,y-x);
  cout<<ans<<endl;
}

Measured memory_bytes: 3520
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = a + a * a + a * a * a;

        // 出力
        System.out.println(result);
    }
}


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

int main()
{
    ll n, sum = 0;
    cin >> n;
    
    ll a[n];
    for(ll i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    for(int i = 1; i < n; ++i)
    {
        sum += a[i];
    }
    
    ll tmp = a[0];
    ll ans = abs(tmp - sum);
    
    for(ll i = 1; i < n - 1; ++i)
    {
        tmp += a[i];
        sum -= a[i];
        ans = min(ans, abs(tmp - sum));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

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

    if(A<=C && B<=C){
        System.out.println("0");
    }else if(A<=C && B<=D){
        System.out.println(B-C);
    }else if(A<=C && B>D){
        System.out.println(D-C);
    }else if(A>C && D<=A){
        System.out.println("0");
    }else if(A>C && B>=D){
        System.out.println(D-A);
    }else{
        System.out.println(B-A);
    }
    }
}


Measured memory_bytes: 35728
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

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

    std::reverse(std::begin(S), std::end(S));

    cerr << S << " ";
    while (S.size() != 0) {
        if (boost::algorithm::starts_with(S, "resare")) {
            S.erase(0, 6);
        }
        else if (boost::algorithm::starts_with(S, "esare")) {
            S.erase(0, 5);
        }
        else if (boost::algorithm::starts_with(S, "remaerd")) {
            S.erase(0, 7);
        }
        else if (boost::algorithm::starts_with(S,"maerd")) {
            S.erase(0, 5);
        }
        else {
            cerr << S << " ";
            std::cout << "NO" << std::endl;
            return 0;
        }
        cerr << S << " ";
    }

    std::cout << "YES" << std::endl;

    return 0;
}


Measured memory_bytes: 512
n,m=(int(i) for i in input().split())
a=[0 for i in range(n+2)]
r=[0 for i in range(n+2)]
for i in range(m):
  b=int(input())
  a[b]=1
if a[0]==0:
  r[0]=1
elif a[1]==0:
  r[1]=1
for i in range(n):
  if a[i+1]==0:
    r[i+1]=r[i+1]+r[i]
  if a[i+2]==0:
    r[i+2]=r[i+2]+r[i]
print(r[n]%(10**9+7))

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

int main() {
  int n;
  cin >> n;
  int count = n;
  unsigned long int a,b;
  unsigned long int v[n];
  for (size_t i = 0; i < count; i++) {
    cin >> v[i];
  }
  sort(v, v+n, greater<int>());
  for (int i = 1; i < count; i++) {
    if (i == count - 1) {
      a = v[0];
      b = v[i];
      cout << v[0] << ' ' << v[i] << endl;
      return 0;
    } else if (v[i] <= v[0]/2) {
      if (v[0]/2 - v[i] < v[i-1] - v[0]/2) cout << v[0] << ' ' << v[i] << endl;
      else cout << v[0] << ' ' << v[i-1] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S, T;
  cin >> S;
  cin >> T;
  int ans = 0;
  rep(i, 3){
    if (S[i] == T[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int N, digits[9] = {0};
    int temp;

    cin >> N;
 
    temp = N;
    for(int i = 0, j = 100000000; i < 9; i++, j /= 10)
    {
        digits[8 - i] = temp / j;
        temp -= digits[8 - i]*j;
    }

    temp = 0;
    for(int i = 0; i < 9; i++)
    {
        temp += digits[i];
    }

    if(N % temp == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

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

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	if(n<=1&&m<=1){
		cout<<"0"<<endl;
	}else{
		
	
	int res = n*(n-1)/2;
	int ans = m*(m-1)/2;
	cout<<res+ans<<endl;
}
	return 0;
} 

Measured memory_bytes: 256
from bisect import *
import sys
n = int(input())
ss = []
color = {}
cnt = 0
for _ in range(n):
    a, b, *c = map(int,sys.stdin.readline().split())
    if a == 0:
        if b not in color:
            insort_left(ss,b)
            color[b] = 1
            cnt += 1
        else:
            color[b] += 1
            cnt += 1
        print(cnt)
    elif a == 1:
        print(color[b] if b in color else 0)
    elif a == 2:
        if b in color:
            cnt -= color[b]
            color[b] = 0
    else:
        L = bisect_left(ss,b)
        R = bisect(ss,c[0])
        for i in range(L,R):
            for _ in range(color[ss[i]]):
                print(ss[i])


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

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

  ll sum = 0;
  ll A[100010] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    A[a]++;
  }

  int q;
  cin >> q;

  ll s = sum;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;

    s += (c-b) * A[b];
    cout << s << endl;

    A[c] += A[b];
    A[b] = 0;
  }
  return 0;
}


Measured memory_bytes: 4396
h,w = map(int, input().split(" "))
temp = [list(input()) for i in range(h)]

a = [["." for i in range(w + 2)] for j in range(h + 2)]
for i in range(h):
  for j in range(w):
    a[i + 1][j + 1] = temp[i][j]

for i in range(1, h + 2):
  for j in range(1, w + 2):
    if a[i][j] == "#":
      if a[i - 1][j] != "#" and a[i + 1][j] != "#" and a[i][j - 1] != "#" and a[i][j + 1] != "#":
        print("No")
        break
  else:
    continue
  break
else:
  print("Yes")

Measured memory_bytes: 9092
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == "#")
            return 0;

        int n = s.size();
        int ret[2] = {0};
        for(int i=0; i<2; ++i){
            bool left = i % 2;
            for(int j=1; j<n; ++j){
                int a = (s[j-1] - '1') % 3;
                int b = (s[j] - '1') % 3;
                if(left){
                    if(b < a)
                        ++ ret[i];
                    else
                        left = false;
                }else{
                    if(b > a)
                        ++ ret[i];
                    else
                        left = true;
                }
            }
        }

        cout << min(ret[0], ret[1]) << endl;
    }
}

Measured memory_bytes: 0
from decimal import Decimal, ROUND_HALF_UP
import numpy as np
n = int(input())
x = np.array(input().split(), int)

m = Decimal(np.sum(x) / n)
mq = int(m.quantize(0, rounding=ROUND_HALF_UP))

s = np.sum((x-mq)**2)
print(s)

Measured memory_bytes: 13284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iX = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "NO";
            if (iA <= iX && iX <= iA + iB) { sOut = "YES"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	s = reverse(s)
	t = reverse(t)

	for i := 0; i < len(s); i++ {
		ok := true
		for j := 0; j < len(t); j++ {
			if len(s) <= i+j {
				ok = false
				break
			}
			tt := t[j]
			ss := s[i+j]
			if !(ss == tt || ss == '?') {
				ok = false
				break
			}
		}
		if ok {
			ans := ""
			for j := 0; j < len(s); j++ {
				c := s[j]
				if i <= j && j < i+len(t) {
					c = t[j-i]
				} else if c == '?' {
					c = 'a'
				}
				ans += string(c)
			}
			fmt.Println(reverse(ans))
			return
		}
	}
	fmt.Println("UNRESTORABLE")
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 512
void main(){
	int[] ab = _scanln();
	ab.sort!("a>b")();
	int ans; ans += ab[0];
	ab[0]--;
	ans += max(ab[0], ab[1]);
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main() {
    string s;
    long long Q;
    cin >> s >> Q;
    deque<char> S(s.begin(), s.end());

    int re = 0;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 2) {
            int F;
            char C;
            cin >> F >> C;

            if (F == 1) {
                if (re % 2 == 0) {
                    S.push_front(C);
                } else {
                    S.push_back(C);
                }
            } else {
                if (re % 2 == 0) {
                    S.push_back(C);
                } else {
                    S.push_front(C);
                }
            }
        } else {
            re++;
        }
    }
    if (re % 2 == 1) {
        reverse(S.begin(), S.end());
    }
    for (auto c : S) {
        cout << c;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97} ;
	map<ll,ll> m ;
	for(int i=0;i<p.size();i++){
		ll num = p.at(i) ;
		m[p.at(i)] = 0 ;
		while(num<=n){
			m[p.at(i)] += n/num ;
			num *= p.at(i) ;
		}
	}
	vll cnt(100,0) ;
	for(int i=0;i<p.size();i++) cnt.at(m[p.at(i)])++ ;
	for(int i=cnt.size()-2;i>=0;i--) cnt.at(i) += cnt.at(i+1) ;
//	for(auto i:cnt) cout << i << " " ; cout << endl ;
//	cout << m[31] << endl ;
	ll ans = 0 ;
	ans += cnt.at(74) ;
	ans += cnt.at(24)*(cnt.at(2)-1) ;
	ans += cnt.at(14)*(cnt.at(4)-1) ;
	ans += cnt.at(4)*(cnt.at(4)-1)*(cnt.at(2)-2)/2 ;
	cout << ans << endl ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n,m,sum=0;
    cin>>n>>m;
    ll int a[m];
    for(ll int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
    {
        cout<<-1;
        return 0;
    }
    else
    {
        cout<<(n-sum);
    }

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    int INF = 1001001001;
    vector<int> ans(n, -1);
    vector<int> d(n, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, 0));
    d[0] = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int dist = p.first;
        int v = p.second;
        if(d[v] < dist)continue;
        for(int t : to[v]){
            if(d[t] <= dist + 1)continue;
            d[t] = dist + 1;
            ans[t] = v;
            que.push(make_pair(dist + 1, t));
        }
    }

    bool v = true;
    for(int i = 1; i < n; i++)if(ans[i]==-1)v = false;
    
    if(v){
        cout << "Yes" << endl;
        for(int i = 1; i < n; i++)cout << ans[i] + 1 << endl;
    }else cout << "No" << endl;
    
}

Measured memory_bytes: 11124
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int calc(int i){
    int tmp = 0;
    int x = i;
    while(x!=0){
        tmp += x%10;
        x/=10;
    }
    return tmp;
}

int main(){
    int n;
    cin >> n;
    int mi = 1000000000;
    for(int i=1;i<n;i++){
        int k = n-i;
        mi = min(mi,calc(i)+calc(k));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> cs(N-1), ss(N-1), fs(N-1);
  for (auto i = 0; i < N-1; i++) {
    cin >> cs[i] >> ss[i] >> fs[i];
  }

  for (auto i = 0; i < N-1; i++) {
    ll sum = 0;
    ll cur = 0;
    for (auto j = i; j < N-1; j++) {
      ll t;
      if (cur <= ss[j]) t = ss[j] - cur;
      else if ((cur - ss[j]) % fs[j] == 0) t = 0;
      else t = fs[j] - (cur - ss[j]) % fs[j];
      t += cs[j];
      cur += t;
    }
    cout << cur << endl;
  }
  cout << 0 << endl;

  return 0;
}


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

int main(){
    string n;
    cin>>n;
    int mod=0;
    for(int i=0;i<n.size();i++){
        int tmp = n[i]-'0';
        mod = (mod+tmp)%9;
    }
    if(mod==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3728
import Data.List
main = do
 n <- readLn::IO Int
 print $ g [n]

maxpower::Int->Int->Int
maxpower n x
    |x<n = 1
    |otherwise = n * maxpower n (x `div` n)
f [] = []
f (x:xs) = nub((x - maxpower 6 x ):(x - maxpower 9 x):(f xs))
g::[Int]->Int
g xs
    |0 `elem` xs =0
    |otherwise =(g (f xs)) + 1

Measured memory_bytes: 1020
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N = int(input())
h = list(map(int, input().split()))

ans = h[0]
base = h[0]
for i in range(1,N):
    ans += max(h[i]-base,0)
    base = h[i]

print(ans)

Measured memory_bytes: 20300
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

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

  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> X(M);
  for (int64_t i = 0; i < M; ++i) {
    cin >> X[i];
  }
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

  sort(X.begin(), X.end());
  vector<Pair> ds(M - 1);
  for (int64_t i = 1; i < M; ++i) {
    ds[i - 1].first = X[i] - X[i - 1];
    ds[i - 1].second = i;
  }
  sort(ds.begin(), ds.end());
  reverse(ds.begin(), ds.end());

  vector<int64_t> starts;
  starts.emplace_back(0);
  for (const auto a : ds) {
    if (static_cast<int64_t>(starts.size()) >= N) {
      break;
    }
    starts.emplace_back(a.second);
  }
  sort(starts.begin(), starts.end());

  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    if (i == N - 1) {
      result += X[M - 1] - X[starts[i]];
    } else {
      result += X[starts[i + 1] - 1] - X[starts[i]];
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6376
int main(){
int W,H,x,y,r;
scanf("%d%d%d%d%d", &W, &H,&x,&y, &r);
if((y+r)>H || (x-r)<0 || (y-r)<0 || (x+r)>W){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}

Measured memory_bytes: 584
#include <iostream>
using namespace std;
#define MAX 100

int taro[MAX+1];
int hana[MAX+1];

int main(int argc, char const *argv[]){
	int n, m;
	int card1, card2;

	while(cin>>n>>m && (n || m) ){
		int sum1 = 0;
		int sum2 = 0;
		bool flag = false;
		for (int i = 0; i < n; i++){
			cin>>taro[i];
			sum1 += taro[i];
		}
		for (int i = 0; i < m; i++){
			cin>>hana[i];
			sum2 += hana[i];
		}

		int d = (sum2-sum1 == 1) ?  1 : (sum2 - sum1) / 2;
		taro[n] = 101; hana[m] = 101;
		card1 = n; card2 = m;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				int tmp1 = sum1 - taro[i] + hana[j];
				int tmp2 = sum2 + taro[i] - hana[j];
				if (tmp1 == tmp2){
					if ( (hana[j] + taro[i]) < (hana[card2] + taro[card1])){
						card1 = i;
						card2 = j;
						flag = true;
					}
				}
			}
		}
		if (!flag) cout<<"-1"<<endl;
		else cout<<taro[card1]<<" "<<hana[card2]<<endl;

	}
	
	return 0;
}

Measured memory_bytes: 3068
def main():
    N = int(input())
    mod = 10 ** 9 + 7
    mod_1 = 1
    mod_2 = 1
    mod_3 = 1
    for _ in range(N):
        mod_1 = (mod_1 * 10) % mod
        mod_2 = (mod_2 * 9) % mod
        mod_3 = (mod_3 * 8) % mod
    v = mod_1 - 2 * mod_2 + mod_3
    if v < 0:
        v *= -1
        v = ((v // mod) + 1) * mod - v
    print(v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62912
$N=<>;
($a,$b,$c)=glob(<>),$$a{$b}=$$b{$a}=$c for 2..$N;
($Q,$K)=glob<>;
$d[$K]=0;
@s=$K;
map{$d[$_]or$d[$_]=$d[$u]+$$u{$_},push@s,$_}keys%$u while$u=pop@s;
/ /,print$d[$`]+$d[$'],$/for<>

Measured memory_bytes: 118912
#include<stdio.h>

int main()
{
    int i,j;

    for (i = 1; i <= 9; i++)

    {
        for(j = 1; j <= 9; j++)
        {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  REP(i,M){
    int A;
    cin>>A;
    N-=A;
  }
  cout<<max(-1,N)<<endl;
  return 0;
}


Measured memory_bytes: 3636
using System;

class Program{
	public static void Main(string[] args){
    	string[] input = Console.ReadLine().Split(' ');
      	int A = int.Parse(input[0]);
      	int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);
      
      	if(B/A > C)Console.WriteLine(C);
      	else Console.WriteLine(B/A);
    }
}

Measured memory_bytes: 13140