akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt {
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M& set_v(uint _v)
	{
        v = (_v < MD) ? _v : _v - MD;
        return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M& r) const { return M().set_v(v + r.v); }
	M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M& r) const { return *this * r.inv(); }
	M& operator+=(const M& r) { return *this = *this + r; }
	M& operator-=(const M& r) { return *this = *this - r; }
	M& operator*=(const M& r) { return *this = *this * r; }
	M& operator/=(const M& r) { return *this = *this / r; }
	bool operator==(const M& r) const { return v == r.v; }
	M pow(ll n) const
    {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
	M inv() const { return pow(MD - 2); }
	friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt;
//head

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif
	int n, m;
	cin >> n >>m;
	vi a(n);
	int sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}

	int tt = sum / (4 * m);
	if (sum % (4 * m) > 0) tt++;

	int cnt = 0;
	rep(i, 0, n) {
		if (a[i] >= tt) cnt++;
	}

	if (cnt >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int[, ,] array = new int[4, 3, 10];
            int n, b, f, r, v;

            //配列初期化
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        array[i, j, k] = 0;
                    }
                }
            }

            //入居件数受け取り
            string str1 = Console.ReadLine();
            n = int.Parse(str1);

            //入居詳細受け取り、入居人数を配列に追加
            for (int h = 0; h < n; h++)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                b = int.Parse(str2[0]);
                f = int.Parse(str2[1]);
                r = int.Parse(str2[2]);
                v = int.Parse(str2[3]);

                switch (b)
                {
                    case 1:
                        array[b - 1, f - 1, r - 1] += v;
                        break;
                    case 2:
                        array[b - 1, f - 1, r - 1] += v;
                        break;
                    case 3:
                        array[b - 1, f - 1, r - 1] += v;
                        break;
                    case 4:
                        array[b - 1, f - 1, r - 1] += v;
                        break;
                }
            }
            
            //入居人数出力
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        if (array[i, j, k] == 0)
                        {
                            Console.Write(" 0");
                        }else if(array[i, j, k] != 0)
                            Console.Write(" " + array[i, j, k]);
                    }
                    Console.WriteLine("");
                }
                if(i < 3)
                {
                    Console.WriteLine("####################");
                }
                else
                {
                    break;
                }
            }
        }
    }



Measured memory_bytes: 9200
let read_lines n =
  let rec read_lines n acc =
    if n = 0 then List.rev acc
    else read_lines (pred n) ((read_line ()) :: acc) in
  read_lines n []

let rec solve () =
  let n_conversion_table = int_of_string @@ read_line () in
  if n_conversion_table = 0 then ()
  else
    let create_conversion_map pairs =
      let hash = Hashtbl.create n_conversion_table in
      List.iter
        (fun (from, to_) -> Hashtbl.add hash from to_)
        pairs;
      hash in
    let conversion_table =
      create_conversion_map
      @@ List.map
           (fun line ->
            Scanf.sscanf line "%c %c" (fun from to_ -> (from, to_)))
           (read_lines n_conversion_table) in
    let convert c =
      try Hashtbl.find conversion_table c with Not_found -> c in
    let n_input = int_of_string @@ read_line () in
    List.iter
      (fun line -> print_char @@ convert line.[0])
      (read_lines n_input);
    print_newline ();
    solve ()

let () = solve ()

Measured memory_bytes: 11072
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    InputStreamReader is = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(is);
    int num,i;
    int []S = new int[13];
    int []H = new int[13];
    int []C = new int[13];
    int []D = new int[13];

    for(i = 0;i < 13;i++){
      S[i] = 0;
      H[i] = 0;
      C[i] = 0;
      D[i] = 0;
    }
    num = sc.nextInt();
    for(i = 0;i < num;i++){
      char op = sc.next().charAt(0);
      int c = sc.nextInt();
      if(op == 'S'){
        S[c - 1] = 1;
      }
      else if(op == 'H'){
        H[c - 1] = 1;
      }
      else if(op == 'C'){
        C[c - 1] = 1;
      }
      else if(op == 'D'){
        D[c - 1] = 1;
      }
    }

    for(i = 0;i < 13;i++){
      if(S[i] == 0){
         System.out.println("S "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(H[i] == 0){
         System.out.println("H "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(C[i] == 0){
         System.out.println("C "+ (i + 1));
      }
    }
    for(i = 0;i < 13;i++){
      if(D[i] == 0){
         System.out.println("D "+ (i + 1));
      }
    }
  }
}

Measured memory_bytes: 26308
/*
    author  : real_rpg  
    country : India
    time    : 00:51:12 IST
*/
 
#include "bits/stdc++.h" 
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fld(i,a,b,c) for(ld i=a; i<b; i+=c)
#define fl(i,a,b,c) for(ll i=a; i<b; i+=c)
#define rfl(i,a,b,c) for(ll i=a; i>=b; i-=c) 
#define endt (double)(clock() - tStart)/CLOCKS_PER_SEC
#define rep(i,n) fl(i,0,n,1)
#define rrep(i,n) rfl(i,n-1,0,1)
#define sas int tt; cin >> tt; rep(tc,tt) 
#define pb  push_back
#define ep emplace_back
#define F first
#define S second
using namespace std; 
const int md = 1e9 + 7;
const int MAX = 1e5 + 5;
const int MAXN = 1e6 + 5;

void solve() {  
	ll n; cin>>n; cout<<(n/2)*((n+1)/2);
}

int main() {             
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL); 
    //clock_t tStart = clock(); 
    solve(); 
    //printf("\n%.6f\n", endt);
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
using namespace std;


    int main() {
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n) cin >> a.at(i);
    rep(i,m) cin >> b.at(i);
    sort(a.rbegin(),a.rend());
    sort(b.begin(),b.end());
       rep3(z,-100,100 ) {
        if(x < z && z <= y && a.at(0) < z && b.at(0) >= z) {
            cout << "No War" <<endl;
            return 0;
        }
    }
        cout << "War" << endl;
        return 0;
    }


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	long MOD = 1000000007;

	public void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int x[] = new int[n];
		for(int i=0; i<n; i++) {
			x[i]=sc.nextInt();
		}

		int y[] = new int[m];
		for(int i=0; i<m; i++) {
			y[i]=sc.nextInt();
		}

		long xx = 0;
		for(int k=0; k<n; k++) {

			xx += ((2*k-n+1) * (long)x[k]) % MOD;
			xx %= MOD;
			//xx = xx + (((2 * k  + n  + 1) * x[k]) % MOD) % MOD;
		}

		long yy = 0;
		for(int k=0; k<m; k++) {

			yy += ((2*k-m+1) * (long)y[k]) % MOD;
			yy %= MOD;
			//yy = yy + (((2*k-m-1) * y[k]) % MOD) % MOD;
		}

		System.out.println((xx * yy) % MOD);
		sc.close();
	}

}




Measured memory_bytes: 66296
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    nextInt()
    val a = listOfInt().sorted()

    val numList = listOf<Long>(1).toMutableList()
    val countList = listOf(a.size).toMutableList()

    var addNum = 1
    for (i in 0 until a.size){
        if (i < a.size-1 && a[i] == a[i+1]){
            addNum += 1
            continue
        }
        divisor(a[i].toLong()).filter { it > 1 }.forEach { divisor ->
            val index = numList.indexOf(divisor)
            if (index >= 0){
                countList[index] += addNum
            }else{
                numList.add(divisor)
                countList.add(addNum)
            }
        }
        addNum = 1
    }

    println(numList.filterIndexed { index, i ->
        countList[index] >= a.size-1
    }.max())
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

Measured memory_bytes: 59680
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    REP(i,h) cin >> v[i];
    vector<vector<int>> f(h,vector<int>(w,100000));
    f[0][0] = v[0][0] == '#' ? 1 : 0;
    set<pii> bfs; bfs.insert({0,0});
    while(!bfs.empty()) {
        set<pii> tmp;
        swap(bfs,tmp);
        for (auto p:tmp) {
            if (p.first != 0) {
                int x = f[p.first-1][p.second];
                if (v[p.first-1][p.second] == '.' && v[p.first][p.second] == '#') x++;
                f[p.first][p.second] = min(f[p.first][p.second],x);
                //cerr << "y:" << f[p.first][p.second];
            }
            if (p.second != 0) {
                int x = f[p.first][p.second-1];
                if (v[p.first][p.second-1] == '.' && v[p.first][p.second] == '#') x++;
                f[p.first][p.second] = min(f[p.first][p.second],x);
                //cerr << "x:" << f[p.first][p.second];
            }
            if (p.first+1 < h) bfs.emplace(p.first+1,p.second);
            if (p.second+1 < w) bfs.emplace(p.first,p.second+1);
            //cerr << p.first << " " << p.second << " " << f[p.first][p.second] << endl;
        }
    }

    OUT(f[h-1][w-1])


    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int main(){
    int K;
    int N;
    int arr[200002];
    cin>>K>>N;
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        cin>>arr[i];
    }
    sort(arr,arr+N);
    int k=arr[0];
    int res=0;
    for(int i=1;i<N;i++){
        res=max(res,(arr[i]-k));
        k=arr[i];
    }
    res=max(res,K-(arr[N-1]-arr[0]));
    cout<<K-res<<endl;
}

Measured memory_bytes: 1024
import math

n = int(input())
function = []
m = round(math.sqrt(n))

for i in range(1, m+1):
    a = i
    b = n / i
    if n % a == 0:
        b = int(b)
        a = str(a)
        b = str(b)
        f = max(len(a), len(b))
        function.append(f)

print(min(function))

Measured memory_bytes: 3060
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	ll N, K; cin >> N >> K;
	vector<double> p(N); rep(i, N)cin >> p[i];

	vector<double> c(N);//累積和
	vector<double> e(N);//各サイコロの出目の期待値
	rep(i, N) e[i] = (p[i] + 1) / 2.0;

	rep(i,N){
		if (i == 0) c[i] = e[i];
		else c[i] = e[i] + c[i - 1];
	}

	double mx = 0;
	for(int i = 0; i <= N - K; i++) {
		if (i == 0) mx = c[K - 1];
		else mx = max(mx, c[i + K - 1] - c[i-1]);
	}

	cout << setprecision(20) << mx << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;


int p[3][7]={{160,140,120,100,80,60,0},
			{25,20,15,10,5,2,0},
			{0,1600,1400,1200,1000,800,600}
		};

int main(){
	int n,x,y,h,w;
	int b;
	int ans;
	while(cin>>n &&n>0){
		ans=0;
		rep(i,n){
			cin>>x>>y>>h>>w;
			b=x+y+h;
			rep(j,7){
				if(b>p[0][j]||w>p[1][j]){
					ans+=p[2][j];
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>

using namespace std;

int main(){

    string str;
    pair <pair<string,int>,int> p[110];
    int n;
    int i;

    cin >> n;

    for(i = 1; i<=n ; i++){
        int in;
        cin >> str >> in;
        p[i] = make_pair(make_pair(str,-in),i);
    }
    sort(p+1,p+n+1);

    for(i=1; i<=n ; i++){
        cout << p[i].second << endl; 
    }

    return 0;
}

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

int main(){
    int n,m;
    cin >>n>>m;
    priority_queue<ll> q;
    rep(i,n){
        int inp= 0;
        cin >> inp;
        q.push(inp);
    }

    int l = m;
    while(l>0){
             ll pp = 0;
             pp = q.top();
             q.pop();
             pp  = pp >> 1;
             q.push(pp);
            l--;
        }
    
    ll ans = 0;
    rep(i,n){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll N, W;
    cin >> N >> W;
    vector<ll> weight(N), value(N);
    for (ll i = 0; (i < N); ++i) {
        cin >> weight[i] >> value[i];
    }
    vector<vector<ll>> dp(N, vector<ll>(W+1, 0));
    for (ll wi = 0; (wi < W+1); ++wi) {
        if (wi >= weight[0]) dp[0][wi] = value[0];
    }
    for (ll i = 1; (i < N); ++i) {
        for (ll wi = 0; (wi < W+1); ++wi) {
            dp[i][wi] = dp[i-1][wi];
            if (wi - weight[i] >= 0) {
                dp[i][wi] = max(dp[i][wi], dp[i-1][wi-weight[i]] + value[i]);
            }
        }
    }
    cout << dp[N-1][W] << endl;
    return 0;
}


Measured memory_bytes: 79488
N,M = map(int,input().split())
ad = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1; b -= 1
    ad[a].append(b)
    ad[b].append(a)

ans = 0

def dfs(v=0,visited=[0]*N):
    visited[v] = 1
    if all(visited):
        global ans
        ans += 1
        return
    for nv in ad[v]:
        if visited[nv] == 1: continue
        dfs(nv,visited[:])

dfs()
print(ans)

Measured memory_bytes: 3064
#!python3.4
# -*- coding: utf-8 -*-
# abc160/abc160_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    a = N // 500
    b = N % 500 // 5
    print(a * 1000 + b * 5)
    return

main()


Measured memory_bytes: 3064
def d_grid_epainting(H, W, S):
    INF = float('inf')
    white = 0  # 全マスのうち白マスの数
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                white += 1

    def bfs():
        # スタート座標は(0,0)とする
        queue = [(0, 0)]
        dist = [[INF for _ in range(W)] for _ in range(H)]  # スタートからの距離
        dist[0][0] = 0  # スタート地点には0歩で到達可能とする
        while len(queue):
            i, j = queue.pop()
            if i == H - 1 and j == W - 1:
                # ゴール座標と一致するなら
                break
            for k in range(4):
                nh, nw = i + [1, 0, -1, 0][k], j + \
                    [0, 1, 0, -1][k]  # (i,j)の右、上、左、下
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] != '#' and dist[nh][nw] == INF:
                    # (nh,nw)が迷路内であり、黒マスでなく、まだ距離が確定していないとき
                    queue.insert(0, (nh, nw))  # 次に探索する座標
                    dist[nh][nw] = dist[i][j] + 1
        return dist[H - 1][W - 1]

    tmp = bfs()
    if tmp == INF:
        ans = -1
    else:
        # tmp+1個の白マス(スタートとゴールを含む)を踏んでゴールに最短でたどり着いた。
        # それらのマスは黒にできないので、すべての白マス数から引く
        ans = white - (tmp + 1)
    return ans

H,W = [int(i) for i in input().split()]
S = [input().strip() for j in range(H)]
print(d_grid_epainting(H, W, S))

Measured memory_bytes: 3064
def digits_sum(n):
    s = 0
    while True:
        n, t = divmod(n, 10)
        s = s + t
        if n == 0:
            break
    return s


N, A, B = list(map(int, input().split()))

answer = 0
for i in range(1, N+1):
    s = digits_sum(i)
    if A <= s and s <= B:
        answer = answer + i
print(answer)

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    B_accum = []
    B_accum_inv = [0] * N

    for b in B:
        c_idx = binary_search(C, b)
        B_accum.append(N-c_idx-1)

    tmp_sum = 0
    for i in range(len(B_accum)):
        tmp_sum += B_accum[N-i-1]
        B_accum_inv[N-i-1] = tmp_sum

    sum_ans = 0
    for a in A:
        b_idx = binary_search(B, a)
        if b_idx+1 < N:
            sum_ans += B_accum_inv[b_idx+1]

    print(sum_ans)


def binary_search(A, x):
    ok = -1
    ng = len(A)
    while abs(ok-ng) > 1:
        mid = (ok+ng) // 2
        if A[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok


if __name__ == '__main__':
    main()

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int X;

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

  std::cin >> X;

  int res = 0;
  res += X / 500 * 1000;
  X -= X / 500 * 500;
  res += X / 5 * 5;

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}


int main() {

	ll a, b, k;
	cin >> k >> a >> b;
	if ((a - 1) / k == b / k) {
		cout << "NG" << endl;
		return 0;
	}
	cout << "OK" << endl;

	return 0;
}


Measured memory_bytes: 3100
from itertools import product

S = input()
ans = 0
for i in product([0,1],repeat=len(S)-1):
    check = S[0]
    for s,flag in zip(S[1:],i):
        if flag:
            check += '+' + s
        else:
            check += s
    ans += eval(check)
print(ans)

Measured memory_bytes: 8996
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    int a[4];
    for (int i = 0; i < 3; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + 3);
    printf("%d\n", a[2] - a[0]);
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var s string

	fmt.Scan(&s)

	var stack = []byte{}

	var sum = 0
	for i := 0; i < len(s); i++ {
		if count(stack) == 0 {
			stack = push(stack, s[i])
			continue
		}

		if peek(stack) == s[i] {
			stack = push(stack, s[i])
			continue
		}

		sum += 2
		stack, _ = pop(stack)
	}

	fmt.Println(sum)
}

func push(s []byte, a byte) []byte {
	return append(s, a)
}

func pop(s []byte) ([]byte, byte) {
	if len(s) == 0 {
		panic("cant pop from empty stack")
	}

	return s[:len(s)-1], s[len(s)-1]
}

func peek(s []byte) byte {
	if len(s) == 0 {
		panic("cant peek from empty stack")
	}
	return s[len(s)-1]
}

func count(s []byte) int {
	return len(s)
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
random_device rnd;
double dist(double x,double y,double a,double b){
    return sqrt((x-a)*(x-a)+(y-b)*(y-b));
}
void Main(){
    ll n;cin>>n;
    vector<double> x(n),y(n);
    For(i,0,n) cin>>x[i]>>y[i];
    double xmin=10000,xmax=-10000,ymin=10000,ymax=-10000;
    For(i,0,n){
        xmin=min(xmin,x[i]);
        xmax=max(xmax,x[i]);
        ymin=min(ymin,y[i]);
        ymax=max(ymax,y[i]);
    }
    double xdist=(xmax-xmin)/400,ydist=(ymax-ymin)/400;
    vector<pair<double,pair<double,double>>> plot;
    For(i,0,400){
        For(j,0,400){
            double X=xmin+i*xdist;
            double Y=ymin+j*ydist;
            double R=0;
            For(k,0,n){
                R=max(R,dist(X,Y,x[k],y[k]));
            }
            plot.push_back(make_pair(R,make_pair(X,Y)));
        }
    }
    sort(ALL(plot));
    int count=0;
    random_device seed_gen;
    mt19937 engine(seed_gen());
    uniform_real_distribution<> dist1(-0.001, 0.001);
    uniform_real_distribution<> dist2(-0.001, 0.001);
    count=0;
    while(true){
        count++;
        double X=0,Y=0;
        For(i,0,1){
            X+=plot[i].second.first;
            Y+=plot[i].second.second;
        }
        X+=dist1(engine);
        Y+=dist2(engine);
        double R=0;
        For(k,0,n){
            R=max(R,dist(X,Y,x[k],y[k]));
        }
        double D=plot[0].first-R;
        if(D>0) plot[0]=make_pair(R,make_pair(X,Y));
        if(count>4000000) break;
    }
    cout<<fixed<<setprecision(12)<<plot[0].first<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 8428
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete

list = runSTArray $ do
    arr <- newArray (-2,32) 0 :: ST s (STArray s Int Integer)
    writeArray arr 0 1
    forM_ [1..30] $ \i -> forM_ [1..3] $ \j -> (+) <$> readArray arr i <*> readArray arr (i-j) >>= writeArray arr i
    return arr

main = takeWhile (/=0) . map readInt . lines <$> getContents >>= mapM_ (print . flip divCeil 365 . flip divCeil 10 . (list!))
    



Measured memory_bytes: 4040
//HOME- DSL-DSL_1-A

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

struct List {
  int num;
  int type;
};

int main(void) {
  int n, q, com, x, y, i, j;

  cin >> n >> q;

  List l[n];

  for(i = 0; i < n; i++) {
    l[i].num = i;
    l[i].type = i;
  }

  for(i = 0; i < q; i++) {
    cin >> com >> x >> y;

    if(com)
      if(l[x].type == l[y].type)
	printf("1\n");
      else
	printf("0\n");
    else {
      int s, t;
      s = min(l[x].type, l[y].type);
      t = max(l[x].type, l[y].type);
      for(j = 0; j < n; j++)
	if(l[j].type == t)
	  l[j].type = s;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
import math
A, B = map(int, input().split())

Amin = A / 0.08
Amax = (A + 0.999999) / 0.08

Bmin = B / 0.10
Bmax = (B + 0.999999) / 0.10

Aset = set(list(range(math.ceil(Amin), math.floor(Amax))))
Bset = set(list(range(math.ceil(Bmin), math.floor(Bmax))))

result_set = Aset & Bset

if len(result_set) == 0:
    print(-1)
else:
    print(min(list(result_set)))

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

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

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

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

	vi ans(n);

	rep(i, n) {
		if (c[i] >= 1 && a[i] >= 1 && n_[i] >= 1) {
			int tmp = min(c[i], min(a[i], n_[i] ));
			ans[i] += tmp;
			c[i] -= tmp;
			a[i] -= tmp;
		}
		
		if (c[i] >= 2 && a[i] >= 1) {
			int tmp = min(c[i] / 2, a[i]);
			ans[i] += tmp;
			c[i] -= tmp * 2;
		}

		if (c[i] >= 3) {
			ans[i] += c[i] / 3;
		}
	}

	rep(i, n) cout << ans[i] << endl;
}


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

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  C[0]--;
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=0;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

int main(){
    int N;
    cin >> N;
    unordered_map<int,int> mp;
    int mx = 0;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        mx = max(mx,x);
        mp[x]++;
    }
    int ans = 0;
    for(int i=0;i<=mx;i++){
        int cnt = mp[i-1]+mp[i]+mp[i+1];
        ans = max(ans,cnt);
    }
    cout << ans << endl;

}


Measured memory_bytes: 4388
n=int(input())
s=input()

r=list(s).count('R')
g=list(s).count('G')
b=list(s).count('B')

ans=r*g*b
for i in range(n):
    for j in range(i+1,n):
        k=j+(j-i)
        if(k<n and s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]):
#            print(i,j,k)
            ans-=1
print(ans)


Measured memory_bytes: 9184
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func linearSearch(a, b []string) int {
	var n int
	for _, v := range b {
		for _, v1 := range a {
			if v == v1 {
				// fmt.Printf("%s = %s\n", v, v1)
				n++
				break
			}
		}
	}
	return n
}

func main() {
	scan := bufio.NewScanner(os.Stdin)
	if scan.Scan() {
		scan.Text()
	}
	var nums []string
	if scan.Scan() {
		nums = strings.Split(scan.Text(), " ")
	}
	if scan.Scan() {
		scan.Text()
	}
	var nums2 []string
	if scan.Scan() {
		nums2 = strings.Split(scan.Text(), " ")
	}
	// fmt.Println(len(nums), len(nums2))
	fmt.Println(linearSearch(nums, nums2))
}



Measured memory_bytes: 1376
N = int(input())
p_list = list(map(int, input().split()))

a_list = p_list.copy()
a_list.sort()

ans = 0

for i in range(N):
    p = p_list[i]
    a = a_list[i]
    if p != a:
        ans += 1

if ans == 2 or ans == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int n; 
	cin >> n;
	vl v(n);
	bool hasZero=false;
	for(int i=0; i<n; ++i) {
		cin >> v[i];
		if(v[i]==0) hasZero=true;
	}
	
	if(hasZero) cout << "0\n";
	else {
		
		ll ans=1;
		for(int i=0; i<n; ++i) {
			if(ll(1e18)/v[i]>=ans) ans*=v[i];
			else {
				cout << "-1\n";
				return 0;
			}
		}
		
		cout << ans << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3964
import sys
input = sys.stdin.readline
li = [int(i) for i in input().split()]
li.sort()
dk = li[2] - li[1]
dl = li[2] - li[0]
sum = dk
dl -= dk
while dl > 0 :
    if dl == 1 :
        sum+=2
        dl = 0
    else :
        dl -=2
        sum+=1
print(sum)

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll num = N/K;
    ll rem = N%K;
    
    ll count = 0;
    count += pow(num, 3);

    if (K % 2 == 0) {
        if (rem >= K/2) num ++;
        count += pow(num, 3);
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(a+b-1)/b;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[6];
  scanf("%s",s);
  if(s[0]=='S')
    printf("Cloudy");
  else if(s[0]=='C')
    printf("Rainy");
  else if(s[0]=='R')
    printf("Sunny");
  return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
from bisect import bisect_right

balls_count = defaultdict(int)

N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
ans = 0
beki_list = [pow(2, i) for i in range(1, 32)]
for a in A:
    balls_count[a] += 1

for a in A:
    if balls_count[a] == 0:
        continue
    balls_count[a] -= 1
    index = bisect_right(beki_list, a)
    pair = beki_list[index] - a
    if balls_count[pair] > 0:
        balls_count[pair] -= 1
        ans += 1
print(ans)

Measured memory_bytes: 138156
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    boolean[][] a = new boolean[h+2][w+2];
    for(int i = 1; i <= h; i++){
      String str = sc.next();
      for(int j = 1; j <= w; j++){
        a[i][j] = (str.charAt(j-1) == '#');
      }
    }
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        if(!a[i][j]){
          continue;
        }
        if(a[i-1][j] || a[i+1][j] || a[i][j-1] || a[i][j+1]){
          continue;
        }else{
          System.out.println("No");
          System.exit(0);
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 23636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N == 1){
      System.out.println("Hello World");
    }else{
      int A = sc.nextInt();
      int B = sc.nextInt();
      System.out.println(A+B);
    }
  }
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(void){

int a,b,c,j=0,i;

scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

for(i=a;i<=b;i++){
	if(c%i==0){
		j++;}
}
printf("%d\n",j);

return 0;
}
		

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

const int MAXN = 2005;

vector<int> g[MAXN];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, x, y;
	cin >> n >> x >> y;
	x--, y--;
	g[x].push_back(y);
	g[y].push_back(x);
	for(int i = 0; i < n-1; i++) {
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	vector<int> ans(n), inq(n), q;
	for(int i = n-1; i >= 0; i--) {
		q.clear();
		inq.assign(n, false);
		q = {i};
		inq[i] = true;
		int d = 0;
		for(int j = 0; j < (int) q.size(); ) {
			int sz = q.size();
			for(; j < sz; j++) {
				int u = q[j];
				for(int v : g[u]) {
					if(!inq[v]) {
						inq[v] = true;
						ans[d]++;
						q.push_back(v);
					}
				}
			}
			d++;
		}
	}
	
	
	for(int i = 0; i < n-1; i++) {
		cout << ans[i]/2 << "\n";
	}
}


Measured memory_bytes: 512
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ls <- replicateM n $ map read . words <$> getLine
  forM_ ls $ \(x1:y1:x2:y2:x3:y3:x4:y4:_) -> do
    putStrLn $ if cross (x2-x1) (y2-y1) (x4-x3) (y4-y3) == 0
      then "YES"
      else "NO"

cross :: Float -> Float -> Float -> Float -> Float
cross x1 y1 x2 y2 = x1*y2-y1*x2

Measured memory_bytes: 4292
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <set>
#include <string>
#include <cstring>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define MAX 100
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 1e9
#define ll long long
#define vi vector<int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define ull unsigned long long


using namespace  std;
const int N = 1e3 + 5;

void solve(){
    int n;
    cin >> n;
    int ans = 0;
    set<string>res;
    while(n--) {
        string s;
        cin >> s;
        res.insert(s);
    }
    cout << res.size();

}
int main() {
    fast;
    solve();

}



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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 1e4 + 5, inf = 2e9, mod = 1e9 + 7;

// Base case:
// states:
// transitions:

string s;
int d, dp[N][2][102];

int solve(int idx, bool less, int sum)
{
    if (idx == s.size())
        return sum % d == 0? 1: 0;
    if (dp[idx][less][sum] != -1)
        return dp[idx][less][sum];
    int ans = 0;
    for (int i = 0; i <= 9; i++)
    {
        if (less)
            ans += solve(idx + 1, less, (sum + i) % d);
        else
        {
            if (i < s[idx] - '0')
                ans += solve(idx + 1, true, (sum + i) % d);
            else if (i == s[idx] - '0')
                ans += solve(idx + 1, false, (sum + i) % d);
        }
        ans %= mod;
    }
    return dp[idx][less][sum] = ans;
}

int main()
{
    VIC
    memset(dp, -1, sizeof dp);
    cin >> s >> d;
    cout << (solve(0, false, 0) - 1 + mod) % mod;
    return 0;
}


Measured memory_bytes: 9216
import sys
W, H, N= map(int, sys.stdin.readline().rstrip().split())
bucket = [[1 for j in range(W)] for i in range(H)]
for i in range(N):
    x, y, a = map(int, sys.stdin.readline().rstrip().split())
    if a == 1:
        for i in range(H):
            for j in range(0,x):
                bucket[i][j] = 0
    elif a == 2:
        for i in range(H):
            for j in range(x,W):
                bucket[i][j] = 0
    elif a == 3:
        for i in range(0,y):
            for j in range(W):
                bucket[i][j] = 0
    else:
        for i in range(y,H):
            for j in range(W):
                bucket[i][j] = 0
sum = sum(map(sum, bucket))
print(sum)

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int a, b;
  cin >> a >> b;
  int bigger = max(a,b);
  ll ans = bigger;
  while(ans%a!=0 || ans%b!=0) {
    ans += bigger;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll a, b;
  std::cin >> a >> b;

  bool judge = (a * b) % 2 == 0;
  if (judge) {
    print("Even");
  } else {
    print("Odd");
  }
  return 0;
}


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

int main() {
	int h, n, sum = 0;

	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum += a;
	}
	if (h <= sum)
		cout << "Yes";
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int num=0;
		int m=n;
		boolean checker=false;
		while(m!=0){
		num=m%10;
		if(num==7) {checker = true;break;}
		m=m/10;
		}
		System.out.println(checker==true?"Yes":"No");

	}

}


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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  long long ans = 1000000000;
  long long price;
  for ( int i = 0; i <= 100000; i++){
    price = c * 2 * i + a * max(x - i, 0) + b * max(y - i, 0);
    ans = min(ans, price);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll m = max(a, max(b, c));
    ll ans = a + b + c - m;
    for(int i = 0; i < k; ++i){
        m *= 2;
    }
    ans += m;
    cout << ans << endl;
    return 0;
}


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

#define INF 1234567890
#define ll long long

const int SZ = 524288;
int N, K;
int A[300301], dp[300301];
int seg[1050000];

void Update(int n, int val) // 1-based
{
	n += SZ-1;
	seg[n] = max(seg[n], val);
	for(n>>=1; n; n>>=1) seg[n] = max(seg[n<<1], seg[n<<1|1]);
}

int Query(int L, int R) // 1-based
{
	if (L < 1) L = 1;
	if (R > 300001) R = 300001;
	if (L > R) return 0;
	L += SZ-1; R += SZ;
	int ret = 0;
	for(; L<R; L>>=1, R>>=1)
	{
		if (L&1) ret = max(ret, seg[L++]);
		if (R&1) ret = max(ret, seg[--R]);
	}
	return ret;
}

int main()
{
	scanf("%d %d", &N, &K);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &A[i]);
		A[i]++; // 1-based
	}

	int res = 0;
	for(int i=1; i<=N; i++)
	{
		dp[i] = Query(A[i]-K, A[i]+K)+1;
		Update(A[i], dp[i]);
		res = max(res, dp[i]);
		//printf("%d : %d\n", i, dp[i]);
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 8536
#include<iostream>
using namespace std;
int main()
{
	int n,a[200],i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0)
			{
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a%b==0) {
    	cout<<-1<<endl;
    } else {
    	cout<<a<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        	return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}
typedef unsigned long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

LL cnt[12];

map<pii, int> mp;

int main() {
	LL n, m, K;
	cin >> n >> m >> K;
	cnt[0] = (n - 3 + 1) * (m - 3 + 1);
   	while(K --) {
		int x, y;
		RD(x), RD(y);
		for(int i = 0; i < 3; i ++)
			for(int j = 0; j < 3; j ++) {
				int nx = x - i, ny = y - j;
				if(nx > 0 && ny > 0 && nx + 2 <= n && ny + 2 <= m) {
					int c = mp[pii(nx, ny)] ++;
					cnt[c] --;
					cnt[c + 1] ++;
				}
			}
	}	
	for(int i = 0; i <= 9; i ++) printf("%lld\n", cnt[i]);
}


Measured memory_bytes: 56448