akhauriyash/Code-Regression huggingface dataset:
// D - 2017-like Number

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

const int MAX_N = 100000;

int prime[MAX_N];
bool is_prime[MAX_N + 1];
int cumulative_2017like[MAX_N + 1];

// n以下の素数をエラトステネスの篩で求めてその個数を返す
// 素数は prime[] に格納される
// iが素数であるかどうかは is_prime[i]に格納される
int sieve(int n) {
	int p = 0;

	for (int i=0; i<=n; i++) {
		is_prime[i] = true;
	}

	is_prime[0] = is_prime[1] = false;

	for (int i=2; i<=n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j=2*i; j<=n; j+=i) {
				is_prime[j] = false;
			}
		}
	}

	return p;
}

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

	sieve(MAX_N);

	for (int i=1; i<=MAX_N; i++) {
		if (is_prime[i] && is_prime[(i+1) / 2]) {
			cumulative_2017like[i] = cumulative_2017like[i-1] + 1;
		} else {
			cumulative_2017like[i] = cumulative_2017like[i-1];
		}
	}

	int l, r;
	vector<int> ans_list;
	for (int i=0; i<Q; i++) {
		cin >> l >> r;
		int ans = cumulative_2017like[r] - cumulative_2017like[l-1];
		ans_list.push_back(ans);
	}

	for (int ans : ans_list) {
		cout << ans << endl;
	}

	return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	REP(i,s.size()-1){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
	}
	REP(i,s.size()-2){
		if(s[i] == s[i+2]){
			cout << i+1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;

}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    string x_string, y_string, z_string ;
    int x_counter, y_counter ;

    cin >> x_string >> y_string >> x_counter >> y_counter >> z_string ;

    if(z_string==x_string)
    {
        --x_counter ;
    }
    else
        --y_counter ;

    cout << x_counter << " " << y_counter  ;

    return 0  ;
}
///||


Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    D, G = NMI()
    pc = [NLI() for _ in range(D)]
    ans = 1000
    
    bit_len = D
    for i in range(2**bit_len):
        ls = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                ls[j] = 1
        
        point = 0
        solved = 0
        half_way = ""
        
        for n in range(D):
            if ls[n] == 1:
                solved += pc[n][0]
                point += pc[n][0]*100*(n+1) +pc[n][1]
            else:
                half_way = n
        
        if G > point:
            if half_way != "":
                remain = int(math.ceil((G-point)/((half_way+1)*100)))
                if remain <pc[half_way][0]:
                    solved += remain
                    ans = min(ans,solved)
        else:
            ans = min(ans,solved)
        
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;


ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////

map < pii , bool > vis;
int a[5], b[5];

int solve(){
	int ret = 0;
	while(1){
		sort(a,a+3);
		if(vis[MP(a[0], a[1])]) return -1;
		vis[MP(a[0], a[1])] = true;
		FOR(i,3){
			if(a[i] % 2 == 1) return ret;
			b[i] = a[i] / 2;
			a[i] = 0;
		}
		FOR(i,3){
			FOR(j,3){
				if(i == j) continue;
				a[i] += b[j];
			}
		}
		ret++;
	}
	return -1;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	FOR(i,3) cin >> a[i];
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

inline int max(int a, int b)
{
	return (a > b ? a : b);
}

inline int max(int a, int b, int c)
{
	return max(max(a, b), c);
}

inline int min(int a, int b)
{
	return (a < b ? a : b);
}

inline int min(int a, int b, int c)
{
	return min(min(a, b), c);
}

int main()
{
	int H, W, max_ = 0;

	scanf("%d", &H);
	scanf("%d", &W);

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &c[i][j]);

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1;

				max_ = max(dp[i][j], max_);
			}
		}
	}

	printf("%d\n", max_ * max_);

	return 0;
}

Measured memory_bytes: 16316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll n;
cin>>n;
ll a[n+1],b[n];
ll sum=0,newsum=0;
for(int i=0;i<n+1;i++){
    cin>>a[i];
    sum+=a[i];
}
for(int i=0;i<n;i++){
   cin>>b[i];
   a[i+1]=seinomi(a[i+1]-seinomi(b[i]-a[i]));
   a[i]=seinomi(a[i]-b[i]);
}
for(auto f:a){
    newsum+=f;
}
cout<<sum-newsum<<endl;

}





Measured memory_bytes: 1792
N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

for Cx in range(101):
    flg = True

    for Cy in range(101):

        for i in range(N):
            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if flg:
                    H = h
                    flg = False
                else:
                    if (H != h):
                        flg = True
                        break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 2e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


ll n, a[N], ans=1;

void solve()
{
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
        sort(a,a+n);
    for (int i=0; i<n; i++) {
        if (ans==0) {
            nout(0);return;
        }
        if (a[i] > INF / ans) {
            nout(-1); return;
        }ans*=a[i];
    }nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4360
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int N;
    scanf("%d",&N);
    if(N%10==9 ||N/10==9){
        printf("Yes\n");
    }
        else{
            printf("No\n");
              }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
using namespace std;
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 3005;
int n, m;
string s, t;
int dp[maxn][maxn];

void ReadInput()
{
    cin >> s >> t;
    n = s.length(); m = t.length();
    s = " " + s; t = " " + t;
}

void Solve()
{
    fill_n(&dp[0][0], sizeof(dp) / sizeof(dp[0][0]), 0);
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            if(s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }

    vector<char> ans;
    int i = n, j = m;
    while(i > 0 && j > 0)
    {
        if(s[i] == t[j])
        {
            ans.push_back(s[i]);
            --i; --j;
        }
        else
        {
            if(dp[i][j] == dp[i - 1][j]) --i;
            else --j;
        }
    }
    reverse(ans.begin(), ans.end());
    for(char c: ans)
        cout << c;
    cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


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

int main() {
  int n, m, f = 1, b, e, o = -1;
  scanf("%d %d", &n, &m);
  vector<int> s(m), c(m), d(n);
  for(int i = 0; i < m; i++) { scanf("%d %d", &s[i], &c[i]); }
  if(n == 1) b = 0, e = 10;
  if(n == 2) b = 10, e = 100;
  if(n == 3) b = 100, e = 1000;
  for(int i = b; i < e; i++) {
    int t = i;
    for(int j = n - 1; j >= 0; j--) {
      d[j] = t % 10;
      t /= 10;
    }
    int f = 1;
    for(int i = 0; i < m; i++)
      if(d[s[i] - 1] != c[i]) f = 0;
    if(f) {
      o = i;
      break;
    }
  }
  printf("%d\n", o);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct UnionFind{
    vector<int> Parent;
    vector<int> sizes;
    UnionFind(int n):Parent(n),sizes(n,1){ rep(i,n)Parent[i]=i; }
    //find the root of x
    int root(int x){
        if(x!=Parent[x]){
        Parent[x] = root(Parent[x]);
        }
        return Parent[x];
    }
    //merge x and y
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        Parent[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return root(x) == root(y); }
    int size(int x){ return sizes[root(x)]; }
};

/*~使い方講座~
まず、main関数内で 
    UnionFind uni(N);
と呼び出します（これでUnionFind木のuniちゃんが呼び出されます）。
uniちゃんの中には、NodeがN個あり、
それぞれの親とそれが属する集合の数（size）が定義されています。
    ①二つのNode xとy が同じ集合に属するか確認するとき
    uni.same(x, y);
    とすることで、それらが同じかどうかをtrue/falseで返す
    ②あるNode x が含まれる集合の大きさを知りたいとき
    uni.size(x);
    ③二つのNode xとyを同じ集合に属させたいとき
    uni.unite(x, y);
    ④あるNode xの根を知りたいとき
    uni.root(x);
*/
/*~UnionFind木が出題された問題~
①D-Decayed Bridges
https://beta.atcoder.jp/contests/abc120
UnionFind木は繋がりを断つことはできないが、
構成することはできるので、逆からやるやつ。
②D-Equals
https://beta.atcoder.jp/contests/abc097
swapすればそれらは行き来可能になるので、実質パイプ。
③B-Union Find
https://beta.atcoder.jp/contests/atc001
典型問題。uniteして、繋がってるか聞かれたら答えるだけ。
④B-道路工事
https://beta.atcoder.jp/contests/arc032/
すべての点に対して根を考えることで、
グループが幾つに分かれているかを知ることができる
⑤D-連結
https://beta.atcoder.jp/contests/abc049
二つのUnionFind木を管理して、
同時に繋がっていることを根のPairを持って
mapで管理すると良い
[解説]http://drken1215.hatenablog.com/entry/2019/06/29/182300
⑥D - Friend Suggestions
[問題]https://atcoder.jp/contests/abc157/tasks/abc157_d
[提出]https://atcoder.jp/contests/abc157/submissions/10460043
友達関係のグルーピングに使う
sizeも用いた
*/
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,M;
    cin>>N>>M;
    vector<int> X(M),Y(M),Z(M);
    UnionFind Trees(N);
    rep(i,M){
        cin>>X[i]>>Y[i]>>Z[i];
        X[i]--;Y[i]--;
        Z[i] %= 2;
        Trees.unite(X[i], Y[i]);

    }
    print(X);print(Y);print(Z);
    set<int> roots;
    rep(i,N){
        roots.insert(Trees.root(i));
    }
    cout<<roots.size()<<endl;
}

Measured memory_bytes: 6912
using System;

namespace _2
{
    class Program
    {
        static void Main()
        {
            //入力
            var nk = Console.ReadLine().Split(' ');
            var N = int.Parse(nk[0]);
            var K = int.Parse(nk[1]);

            //配列生成
            int[] input;
            input = new int[N];


            for (int i = 1; i <= N; i++)
            {

                input[i - 1] = int.Parse(Console.ReadLine());
            }

            Array.Sort(input, (a, b) => b - a);      //降順の並び替え

            int A = input[0];

            for (int i = 0; i < N+1-K; i++)
            {

                if (A > input[i] - input[i + (K - 1)])
                    {
                        A = input[i] - input[i + (K- 1)];
                    }

                if (A == 0)
                {
                    break;
                }
            }

            Console.WriteLine(A);

        }
    

    }
}


Measured memory_bytes: 15452
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define ELM 100001 //問題によっては1000000001に変更

//限定
using namespace std;

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a>>b;
    vector<int> v = {a+b,a*b,a-b};
    Pr(*max_element(v.begin(), v.end()));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M, X;
  cin >> N >> M >> X;
  vll C(N);
  vvll A(N, vll(M));
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
    for(int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
    }
  }
  ll ans = INF;
  for(int bit = 0; bit < (1<<N); bit++){
    vll p(M, 0LL);
    ll price = 0LL;
    for(int i = 0; i < N; i++){
      if((bit>>i) & 1){
        price += C.at(i);
        for(int j = 0; j < M; j++){
          p.at(j) += A.at(i).at(j);
        }
      }
    }
    sort(ALL(p));
    if(p.at(0) >= X) chmin(ans, price);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

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

// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

using pll = pair<long long, long long>;
int N;
long long D, A;
vector<long long> X, H;

long long solve() {
    // モンスターを X が小さい順に
    vector<int> ids(N);
    for (int i = 0; i < N; ++i) ids[i] = i;
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j]; });
    vector<long long> nX(N), nH(N);
    for (int i = 0; i < N; ++i) nX[i] = X[ids[i]], nH[i] = H[ids[i]];
    X = nX, H = nH;

    // BIT で処理していく
    BIT<long long> bit(N+10);
    for (int i = 0; i < N; ++i) bit.add(i+1, i+2, H[i]); // 初期化
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        long long cur = bit.sum(i+1, i+2);
        if (cur <= 0) continue;

        // モンスター i を倒すのに必要な回数
        long long need = (cur + A - 1) / A;

        // X[i] を左端とした爆発が届く範囲を求める
        long long right = X[i] + D * 2;
        int id = upper_bound(X.begin(), X.end(), right) - X.begin();

        // 爆発させる
        bit.add(i+1, id+1, -need * A);
        res += need;
    }
    return res;
}

int main() {
    cin >> N >> D >> A;
    X.resize(N); H.resize(N);
    for (int i = 0; i < N; ++i) cin >> X[i] >> H[i];
    cout << solve() << endl;
}


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

int main() {
  vector<int> n(3);
  for (int i=0; i<3; i++) {
    cin >> n.at(i);
  }
  sort(n.begin(),n.end());
  cout << 10*n.at(2)+n.at(1)+n.at(0) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
using namespace std;

int main() {

	queue< pair<string, int> > que;
	string name;
	int n, q, t;
	cin >> n >> q;

	for(int i = 0; i < n; i++) {
		cin >> name >> t;
		que.push(make_pair(name, t));
	}

	pair<string, int> u;
	int elapse = 0, a;

	while(!que.empty() ) {
		u = que.front(); que.pop();
		a = min(u.second, q);
		elapse += a;
		u.second -= a;
		if(u.second > 0) que.push(u);
		else cout << u.first << " " << elapse <<endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include <stdio.h>

int main(){
  	int A, B = 0;
  	scanf("%d %d",&A ,&B);
  	if(0 <= A && A < 6){
    	B = 0;
    }else if(6 <=A  && A <= 12){
    	B /= 2;
    }else{
    
    }
  
  	printf("%d\n",B);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	string S;
	while( getline( cin, S ) )
	{
		string res;
		REP( i, (int) S.size() )
		{
			if( S[ i ] == '@' )
			{
				int N = S[ i + 1 ] - '0';
				REP( j, N )
				{
					res += S[ i + 2 ];
				}
				i += 2;
				continue;
			}
			res += S[ i ];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define pb push_back 
#define ff first 
#define ss second
#define all(c) c.begin(), c.end()
#define sz(z) (int)z.size()
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; i--)
//Debugging tools 
#define debug(v) cout<<#v<<endl;for(ll i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define debugn(v,n) cout<<#v<<endl;for(ll i=0; i<n; i++) cout<<v[i]<<" "; cout<<endl;
#define deb(sum) cout<<#sum<<" = "<<sum<<endl;
//Predefined values
#define INF (ll)1e18
#define endl "\n"
#define pi 3.142857142857143
const ll MOD = 1e9 + 7;


int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.in","r",stdin);
        freopen("output.in","w",stdout);
    #endif
    int t=1;    
    //cin>>t;
    while(t--){
        string n;
        cin>>n;
        ll sm = 0;
        rep(i,0,sz(n)){
            sm += n[i] - '0';
        }
        if(sm%9==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        
    }
  return 0;
 }

















Measured memory_bytes: 3696
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

using ll = long long int;

ll arr[300010] = {};

ll resL[100010] = {};

int main(void){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k,sum = 0,result = 0;
    cin >> k;
    
    priority_queue<ll, vector<ll>, greater<ll> > que;
    
    for(int i = 0; i < 3*k; i++){
        cin >> arr[i];
    }
    
    //init
    
    for(int i = 0; i < k; i++){
        sum += arr[i];
        que.push(arr[i]);
    }
    
    resL[0] = sum;
    
    for(int i = 0; i < k; i++){
        
        que.push(arr[i+k]);
        ll a = que.top();
        que.pop();
        
        sum += arr[i+k]-a;
        
        resL[i+1] = sum;
    }
    
    /// left
    
    priority_queue<ll> que1;
    sum = 0;
    
    for(int i = 1; i <= k; i++){
        sum += arr[3*k-i];
        que1.push(arr[3*k-i]);
    }
    
    result = resL[k] - sum;
    
    for(int i = 1; i <= k; i++){
        
        que1.push(arr[2*k-i]);
        ll a = que1.top();
        que1.pop();
        
        sum += arr[2*k-i]-a;
        
        result = max(resL[k-i] - sum,result);
    }
    
    /// right
    
    cout << result << endl;
}


Measured memory_bytes: 5748
import java.io.*;
import java.lang.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		int n, i;
		int sum, min = 0, max = 0, tmp = 0;

		for(;;){
			sum = 0;
			n = sc.nextInt();
			if(n == 0){
				return;
			}
			for(i = 0; i < n; i++){
				tmp = sc.nextInt();
				sum += tmp;
				if(i == 0){
					max = tmp;
					min = tmp;
				} else{
					if(tmp > max){
						max = tmp;
					}
					if(tmp < min){
						min = tmp;
					}
				}
			}
			sum -= min;
			sum -= max;

			sum /= n - 2;

			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 29168
S = list(input())
T = list(input())

d = {}
d2 = {}

for i in range(len(S)):
    if S[i] not in d: d.update({S[i]: T[i]})
    elif d[S[i]]==T[i]: pass
    else:
        print('No')
        exit()

    if T[i] not in d2: d2.update({T[i]: S[i]})
    elif d2[T[i]]==S[i]: pass
    else:
        print('No')
        exit()
print('Yes')


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  rep(i, n) {
    ll s = lower_bound(all(a), b[i]) - a.begin();
    ll t = n - (upper_bound(all(c), b[i]) - c.begin());
    ans += s * t;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
from collections import defaultdict
n, m, k = list(map(int, input().split()))
ns = defaultdict(set)
bs = defaultdict(set)
for i in range(m):
    a,b = list(map(int, input().split()))
    ns[a-1].add(b-1)
    ns[b-1].add(a-1)
for i in range(k):
    c,d = list(map(int, input().split()))
    bs[c-1].add(d-1)
    bs[d-1].add(c-1)
    
s = [0]
start = 0
parent = [None] * n
starts = defaultdict(int)
starts[0] = 0
notdone = set(list(range(n)))
notdone.remove(start)
while notdone or s:
    u = s.pop()
    parent[u] = start
    starts[start] += 1
    for v in ns[u]:
        if v in notdone:
            s.append(v)
            notdone.remove(v)
    if not s and notdone:
        start = notdone.pop()
        parent[start] = start
        s.append(start)
ans = [None] * n
for u in range(n):
    val = starts[parent[u]] - 1 - len(ns[u])
    for v in bs[u]:
        if parent[v]==parent[u]:
            val -= 1
    ans[u] = val
print(" ".join(map(str, ans)))

Measured memory_bytes: 128376
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int x, t; readV(x, t);
  writeln(max(0, x-t));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}

const int N = 200010, M = 400010, MOD = (int)(1e9 + 7);
struct edge {
  int la,b,v;
} con[M << 1];
int tot,fir[N],n,m;
void add(int from,int to,int val) {
  con[++tot] = (edge) {fir[from], to, val};
  fir[from] = tot;
}
struct data {
  int a,b,v;
} dat[M];
struct cmp {
  bool operator () (const pli& a, const pli& b) {
    return a > b;
  }
};
void dijkstra(int st, ll* dis, int* dp) {
  static priority_queue<pli, vector<pli>, cmp> q;
  while (!q.empty()) q.pop();
  memset(dis,0x3f,sizeof(ll) * (n + 5));
  memset(dp, 0, sizeof(int) * (n + 5));
  dis[st] = 0;
  dp[st] = 1;
  q.push(pli(0, st));
  for (int pos ; !q.empty() ; ) {
    pos = q.top().sec;
    if (q.top().fir != dis[pos]) {
      q.pop();
      continue;
    }
    q.pop();
    for (int i = fir[pos] ; i ; i = con[i].la) {
      if (dis[con[i].b] > dis[pos] + con[i].v) {
        dis[con[i].b] = dis[pos] + con[i].v;
        dp[con[i].b] = dp[pos];
        q.push(pli(dis[con[i].b], con[i].b));
      } else if (dis[con[i].b] == dis[pos] + con[i].v) {
        dp[con[i].b] += dp[pos];
        if (dp[con[i].b] >= MOD) dp[con[i].b] -= MOD;
      }
    }
  }
}
ll dis[2][N], len;
int dp[2][N],st,en,ans;
int main() {
  read(n), read(m);
  read(st), read(en);
  for (int i = 1, a, b, v ; i <= m ; ++ i) {
    read(a), read(b), read(v);
    add(a,b,v);
    add(b,a,v);
    dat[i] = (data) {a,b,v};
  }
  dijkstra(st, dis[0], dp[0]);
  dijkstra(en, dis[1], dp[1]);
  len = dis[0][en];
  // cerr << len << endl;
  ans = 1ll * dp[0][en] * dp[0][en] % MOD;
  for (int i = 1, a, b ; i <= m ; ++ i) {
    a = dat[i].a, b = dat[i].b;
    if (dis[0][a] > dis[0][b]) swap(a, b);
    if (dis[0][a] + dat[i].v + dis[1][b] > len) continue;
    if (dis[0][a] * 2 < len && dis[0][b] * 2 > len) {
      // cerr << a << ' ' << b << endl;
      int tmp = 1ll * dp[0][a] * dp[1][b] % MOD;
      ans -= 1ll * tmp * tmp % MOD;
      if (ans < 0) ans += MOD;
    }
  }
  for (int i = 1 ; i <= n ; ++ i) {
    if (dis[0][i] + dis[1][i] > len) continue;
    if (dis[0][i] * 2 == len) {
      // cerr << i << endl;
      int tmp = 1ll * dp[0][i] * dp[1][i] % MOD;
      ans -= 1ll * tmp * tmp % MOD;
      if (ans < 0) ans += MOD;
    }
  }
  ans = (ans % MOD + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 17652
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/

	long long n, t; cin >> n >> t;
	
	long long ans = t;
	vector<long long> a(n);
	for(long long i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(long long i = 0; i < n - 1; i++){
		long long x1 = a[i], y1 = a[i] + t, x2 = a[i + 1], y2 = a[i + 1] + t;
		if(x2 < y1){
			ans += x2 - x1;	
		}
		else {
			ans += t;
		}
	}
	
	cout << ans;
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
char c;
int main() {
	cin >> c;
	if (c >= 'A'&&c <= 'Z')puts("A");
	else puts("a");
	return 0;
}

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

int main(){

    ll n;
    cin >> n;

    vector<ll> a(n),b(n),c(n);

    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans=0;
    rep(i,n){
        ll at,ct;
        auto it1=lower_bound(a.begin(),a.end(),b[i]);
        auto it2=upper_bound(c.begin(),c.end(),b[i]);
        ll t1=distance(a.begin(),--it1)+1;
        ll t2=distance(it2,c.end());
        ans+=(t1*t2);
    }
    cout << ans << endl;

    return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int A[N], B[N], C[N];

bool CMP(int i, int j) { return A[i] + B[i] > A[j] + B[j]; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i] >> B[i], C[i] = i;
	sort(C, C + n, CMP);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) ans -= B[C[i]];
		else ans += A[C[i]];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 10 == 3 || (i/10)%10 == 3 || (i/100)%10== 3 || (i/1000)%10==3){
            printf(" %d", i);
        }
    }
    puts("");
}



Measured memory_bytes: 2728
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;


int main() {
	int N, M, i;
	cin >> N >> M;
	vector<int> a(M), b(M), c(N, 0);
	for (i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		c[a[i] - 1]++;
		c[b[i] - 1]++;
	}
	for (i = 0; i < N; i++) {
		cout << c[i] << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    cout << ((a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll p = 1000000007;

int main(){
  ll h,w;
  cin >> h >> w;
  char a[h][w];
  REP(i,h) REP(j,w) cin >> a[i][j];
  ll dp[h+1][w+1];
  REP(i,h+1){
    REP(j,w+1){
      if(i==0||j==0) dp[i][j] = 0;
      else if(i==1&&j==1) dp[i][j] = 1;
      else if(a[i-1][j-1]=='#') dp[i][j] = 0;
      else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%p;
    }
  }
  cout << dp[h][w] << endl;
  return 0;
}


Measured memory_bytes: 9088
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[-1] >= y[0]:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3060
#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> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//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()) ;}

int main(){
	ll n ; cin >> n ;
	vll p(1,2) ;
	for(int i=3;i<=n;i++){
		bool ok = true ;
		for(int j=0;j<p.size();j++){
			if(i%p.at(j)==0){
				ok = false ;
				break ;
			}
		}
		if(ok) p.push_back(i) ;
	}
	ll ans = 1 ;
	ll mod = 1e+9+7 ;
	for(int i=0;i<p.size();i++){
		ll x = n ;
		ll cnt = 0 ;
		while(x>0){
			cnt += x/p.at(i) ;
			x /= p.at(i) ;
		}
		ans = ans*(cnt+1)%mod ;
//		cout << p.at(i) << " " << cnt << endl ;
	}
	cout << ans << endl ;
}


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

int main() {
  int N,K,A;
  cin >> N >> K;
  A=1;
  for (int i=0;i<N;i++){
   if (A < K) 
    A *= 2;
   else
   A += K;
  }
  cout << A << endl;
}

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



int main() {
int N;
cin >> N;
int candy[2][100];
for(int i = 0; i < N; i++)cin >> candy[0][i];
for(int i = 0; i < N; i++)cin >> candy[1][i];
int ans = 0;
for(int i = 0; i < N; i++){
int check = 0;
int kari = 0;
for(int j = 0; j < N; j++){
kari += candy[check][j];
if(j == i)check = 1, kari+=candy[1][j];

}
ans = max(ans, kari);

}
cout << ans << endl;

}


Measured memory_bytes: 256
<?php

  fscanf(STDIN, "%d %d %d", $n,$c,$k);

  $t =array();

  $min = 0;
  $customer_num = 0;
  $bus = 0;

  for($i = 0;$i < $n;$i++){
    fscanf(STDIN, "%d" ,$t[$i]);
    $customer_num++;
  }

  sort($t);

  $bus_rider = 0;

  for($i = 0;$i < $n; $i++){
    $bus_rider++;
    if($t[$i] > $t[$min] + $k){
      $bus++;
      $bus_rider = 1;
      $min = $i;
      if($n-1 == $i) $bus++;
    }elseif($bus_rider == $c){
      $bus_rider = 0;
      $bus++;
      $min = $i+1;
    }else{
      if($n-1 == $i) $bus++;
    }
  }


  echo $bus;


Measured memory_bytes: 18932
#include <stdio.h>
int main (void)
{
	int n;
	scanf("%d", &n);
	int h, m, s;
	h=n/3600;
	m=(n%3600)/60;
	s=n%60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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

using namespace std;
int n,len;
vector<int> edges[100008];
int vertex_type[100008];
int getpath(int now,int frm) {
	vertex_type[now]=-1;
	for(auto i:edges[now]) {
		if(i!=frm) {
			int temp=getpath(i,now);
			if(temp>=0) vertex_type[now]=temp+1;
		}
	}
	if(now==n) vertex_type[now]=0;
	return vertex_type[now];
}
int bfs(int now,int frm,int mode) {
	int size=1;
	for(auto i:edges[now]) {
		if(i!=frm) {
			if(vertex_type[i]<0) {
				size+=bfs(i,now,mode);
			} else {
				if(mode) {
					if(vertex_type[i]*2<len) size+=bfs(i,now,mode);
				} else {
					if(vertex_type[i]*2>=len) size+=bfs(i,now,mode);
				}
			}
		}
	}
	return size;
}
int main() {
	cin >> n;
	for(int i=1;i<n;i++) {
		int va,vb;
		cin >> va >> vb;
		edges[va].push_back(vb);
		edges[vb].push_back(va);
	}
	len=getpath(1,-1);
	int tFen=bfs(1,-1,0);
	int tSnu=bfs(n,-1,1);
	if(tFen>tSnu) {
		cout << "Fennec" << endl;
	} else {
		cout << "Snuke" << endl;
	}
	return 0;
}


Measured memory_bytes: 10752
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int a,b;

int main(){
    cin>>a>>b;
    if(a>=10||b>=10)out(-1);
    else out(a*b);
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define OP_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i = a; i < b; i++)
#define foi(i,a,b) for(int i = a; i>=b; i--)
#define fi first
#define si second
#define pb push_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

//const ll INF = 1e18L + 5;
//const int MAXN = 1005;
const ll modn = 1e9+7;

void add_self(ll &a, ll b){
  a += b;
  if (a >= modn){
    a -= modn;
  }
}

void sub_self(ll &a, ll b){
  a -= b;
  if (a < 0){
    a += modn;
  }
}

ll solve(vll &inp, ll n, ll k){
  vll dp(k+1, 0);
  dp[0] = 1;
  fo(i, 0, n){
    ll up_to = inp[i];
    vll fake(k+1, 0);
    foi(used, k, 0){
      ll tmp = dp[used];
      ll L = used + 1;
      ll R = used + min(k - used, up_to);
      if(L <= R){
	add_self(fake[L], tmp);
	if(R+1 <= k){
	  sub_self(fake[R+1], tmp);
	}
      }
      
    }
    ll prefix_sum = 0;
    fo(j, 0, k+1){
      add_self(prefix_sum, fake[j]);
      add_self(dp[j], prefix_sum);
    }
    //cout<<prefix_sum<<endl;
  }
  return dp[k];
}

int main(){
  OP_IO;
  ll N,K;
  cin>>N>>K;
  vll inp(N);
  fo(i, 0, N){
    cin>>inp[i];
  }
  cout<<solve(inp,N,K)<<endl;
  return 0;
}


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

long lcm(long a, long b)
{
    long product = a * b;
    if (a < b)
    {
        long tmp;
        tmp = a;
        a = b;
        b = tmp;
    }

    long r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return product / b;
}

int main()
{
    long N, M;
    cin >> N >> M;
    long a[N];
    long current_lcm = 1;
    long a_max = -1;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a_max = max(a_max, a[i]);
        current_lcm = lcm(current_lcm, a[i]);
    }
    long min_X = -1;
    for (int i = a_max / 2; i <= M; i += a_max)
    {
        for (int j = 0; j < N; j++)
        {
            if ((i - a[j] / 2) % a[j] != 0)
            {
                goto out;
            }
        }
        min_X = i;
        break;
    out:;
    }
    if (min_X == -1)
        cout << 0 << endl;
    else
        cout << (long)((M - min_X) / current_lcm + 1) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int N, P[101], i, num=-1, check[101], j, k;
    string S[101], T;

    cin >> N;

    for(i=1; i<=N; i++){
        check[i] = 0;
    }

    T = '}';

    for(i=1; i<=N; i++){
        cin >> S[i] >> P[i];
    }

    /*sort(S+1, S+N+1);

    for(i=1; i<=N; i++){
        cout << S[i] << " ";
    }
    cout << endl;*/

    for(k=1; k<=N; k++){
        num = -1;
        T = '}';
        for(i=1; i<=N; i++){
            if(check[i] == 0 && (S[i]<T || (S[i]==T && P[i] > num))){
                T = S[i];
                num = P[i];
                j = i;
            }
        }
        check[j] = 1;
        cout << j << endl;
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int x[N];
    int y[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
        y[i]=x[i];
    }
    sort(y,y+N);
    for(int i=0;i<N;i++){
        if(y[N/2]>x[i]){
            cout << y[N/2] << endl;
        }else{
            cout << y[N/2-1] << endl;
        }
    }
}

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a == b && a != c) {
        cout << "Yes" << endl;
    } else if (a == c && a != b) {
        cout << "Yes" << endl;
    } else if (b == c && a != c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define N 100005
#define mod 1000000007


int main()
{
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll pre[n]={0};
    for(ll i=1;i<n;i++)
    {
        pre[i]=(pre[i-1]+a[i-1])%mod;
    }
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        ans+=(a[i]*pre[i])%mod;
    }
    cout<<ans%mod;
    return 0;
}

Measured memory_bytes: 6704
h,w = map(int,input().split())
s = []

for i in range(h):
    a =list(input())
    s.append(a)

#print(s)

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            c = 0
            if  i-1 >= 0 and i-1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
               if s[i-1][j-1] == '#':
                 c += 1
            if  i >= 0 and i <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i][j-1] == '#':
                     c += 1
            if   i+11 >= 0 and i+1 <= h-1 and j-1 >= 0 and j-1 <= w-1:
                if s[i+1][j-1] == '#':
                    
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j >= 0 and j <= w-1:
                if s[i-1][j] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j >= 0 and j <= w-1:
                if s[i][j] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j >= 0 and j <= w-1:
                if s[i+1][j] == '#':
                    c += 1
            if i-1 >= 0 and i-1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i-1][j+1] == '#' :
                    c += 1
            if   i >= 0 and i <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i][j+1] == '#':
                    c += 1
            if  i+1 >= 0 and i+1 <= h-1 and j+1 >= 0 and j+1 <= w-1:
                if s[i+1][j+1] == '#':
                    c += 1
            s[i][j] = str(c)

for i in range(h):
    k = ''
    for j in range(w):
       
        k += s[i][j]
    print(k)

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

int main()
{
    int m, d; cin>>m>>d;
    int res=0;
    for(int i=1; i<=m; ++i) {
        for(int j=20; j<=d; ++j) {
            if (j%10>1 and j/10*(j%10)==i) ++res;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256