akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

fn count_bomb(map: &Vec<Vec<char>>, row: usize, col: usize) -> u32 {
    let mut count = 0;
    let shift_array: [i8; 3] = [-1, 0, 1];

    for row_shift in shift_array.iter() {
        for col_shift in shift_array.iter() {
            let row_coordinate = row as i64 + *row_shift as i64;
            let col_coordinate = col as i64 + *col_shift as i64;
            if 0 <= row_coordinate && row_coordinate < map.len() as i64 && 0 <= col_coordinate &&
                col_coordinate < map[0].len() as i64
            {
                if map[row_coordinate as usize][col_coordinate as usize] == '#' {
                    count += 1;
                }
            }
        }
    }

    count
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (h, w) = input!(usize, usize);
    let mut map = Vec::<Vec<char>>::new();

    for _ in 0..h {
        let (line,) = input!(String);
        map.push(line.chars().collect());
    }

    for i in 0..h {
        for j in 0..w {
            if map[i][j] == '#' {
                print!("#");
            } else {
                print!("{}", count_bomb(&map, i, j));
            }
        }
        println!("");
    }
}

fn main() {
    solve();
}



Measured memory_bytes: 4352
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    string S;  cin >> S;

    int m = stoi(S.substr(5, 2));

    string ans = m<=4 ? "Heisei" : "TBD";

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int cnt=0,f=0;
	for(int i=0;i<n;i++){
	    int a,b;
	    cin>>a>>b;
	    if(a == b){
	        cnt++;
	    }
	    else{
	        cnt=0;
	    }
	    if(cnt == 3){
	        f=1;
	    }
	}
	if(f == 1){
	    cout<<"Yes";
	}
	else{
	    cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

bool	is_prime(int num)
{
	if (num == 2)
		return (true);
	if (!(num % 2))
		return (false);
	int div = 3;
	int rt = sqrt(num);
	while (div <= rt)
	{
		if (!(num % div))
			return (false);
		div += 2;
	}
	return (true);
}

int		main(void)
{
	int x;
	cin >> x;
	while (true)
	{
		if (is_prime(x))
		{
			cout << x << endl;
			return (0);
		}
		x++;
	}
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
   
int main(){
   int N;
   std::cin >> N;

   int min = (1<<28);
   for(int i=1; i<N; ++i){
      int A = i;
      int B = N - A;
      int sum = A%10 + B%10;
      for(int j=0; j<4; ++j){
	 A /= 10;
	 B /= 10;
	 sum += A %10 + B%10;
      }
      if(min>sum) min = sum;
   }

   std::cout << min << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int max(int a, int b)                   //最大を求める
{  
  if(a>=b)
    return a;
  else
    return b;
}
    
int main(void)
{
  int K,N;
  int i;
  int a[200000];
  int dis[200000];
  int large=0;
  
  do {
 	 scanf("%d %d",&K,&N);
  } while((K < 2 || K > 1000000) || (N < 2 || N > 200000));
 
  for(i=0; N>i; i++){
     if(i == 0){
        do{
          scanf("%d ",&a[i]);
       } while(a[i] >= K);
     }
    else{
    	do{
          scanf("%d ",&a[i]);
    	} while(a[i] >= K || a[i] <= a[i-1]);
    }
  }
  for(i=0; N>i ; i++){
    if(N != i+1)                            //最後の引き算で距離がーになるのを防ぐ
      dis[i] = a[i+1] - a[i];
    else
      dis[i] = (K+a[0]) - a[i];
    large = max(large,dis[i]);
  }
    
  printf("%d",K-large);
  return 0;
}

Measured memory_bytes: 896
#include <set>
#include <cstdio>
#include <iostream>
#include <queue>
#include <sstream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

template<class T1, class T2>
string appop(T1 v1, char op, T2 v2){
  stringstream ss;
  ss << "(" << v1 << op << v2 << ")";
  return ss.str();
}

template<class T>
string neg(T a){
  return appop("", '~', a);
}

template<class T>
string toStr(T v){
  stringstream ss;
  ss << v;
  return ss.str();
}

int main(){
  int n = getInt();
  int x[n], y[n];

  REP(i,n){
    x[i] = getInt();
    y[i] = getInt();
  }

  string ans = "";
  REP(k,8){
    REP(i,n){
      if(y[i] & (1 << k)){
	vector<string> buff(k + 1);
	REP(j,k + 1){
	  string s;
	  if(x[i] & (1 << j)){
	    s = appop("x", '*', (1 << (k - j)));
	  }else{
	    s = appop(neg("x"), '*', (1 << (k - j)));
	  }
	  buff[j] = s;
	}
	string buff2 = buff[0];
	for(int j = 1; j < k + 1; j++){
	  buff2 = appop(buff2, '&', buff[j]);
	}
	buff2 = appop(buff2, '&', (1 << k));
	if(ans.size()){
	  ans = appop(ans, '|', buff2);
	}else{
	  ans = buff2;
	}
      }
    }
  }

  if(ans.size() == 0) ans = "0";
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	ll n, m,ans=0;
	cin >> n >> m;
	if (m - (n * 2) >= 0) {
		m = m - (n * 2);
		ans = n;
		ans += m / 4;
		cout << ans << endl;
		return 0;
	}
	else {
		cout << m / 2 << endl;
		return 0;
	}
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

X = inp()
dp = [False]*(X+200)

dp[0] = True

for i in range(X+10):
    if dp[i]:
        dp[i+100] = True
        dp[i+101] = True
        dp[i+102] = True
        dp[i+103] = True
        dp[i+104] = True
        dp[i+105] = True


if dp[X]:
    print(1)
else:
    print(0)


Measured memory_bytes: 4836
m,d=map(int,input().split())
c=0
for i in range(3,m):
  for j in range(19,d):
    if 2<=int(str(j+1)[-1]):
      if int(str(j+1)[0])*int(str(j+1)[1])==i+1:
        c+=1
print(c)

Measured memory_bytes: 2940
N,M=map(int,input().split())
A=sorted([int(i) for i in input().split()],reverse=True)
num=[6,2,5,5,4,5,6,3,7,6]
INF=10**15
dp=[-INF for i in range(N+1)];dp[0]=0
for i in range(1,N+1):
    for j in range(M):
        if N>=i-num[A[j]]>=0:
            dp[i]=max(dp[i],dp[i-num[A[j]]]+1)
K=N
i=0
ans=""
while(K>0):
    if not(N>=K-num[A[i]]>=0):
        i+=1
        continue
    if dp[K-num[A[i]]]==dp[K]-1:
        ans=ans+str(A[i])
        K-=num[A[i]]
    else:
        i+=1
print(ans)


Measured memory_bytes: 3316
chrdict = {}
for i, c in enumerate(range(97, 123), start=1):
    chrdict[chr(c)] = i
src1 = input()
src2 = input()
dst1, dst2 = [], []
for i in range(len(src1)):
    dst1.append(chrdict[src1[i]])
for i in range(len(src2)):
    dst2.append(chrdict[src2[i]])
dst1.sort()
dst2.sort(reverse=True)
dsted1 = 0
dsted2 = 0
maximum = max([len(dst1), len(dst2)])
for d1, d2 in zip(dst1, dst2):
    if d1 == d2:
        continue
    else:
        dst = "Yes" if d1 < d2 else "No"
        break
else:
    dst = "Yes" if len(src1) < len(src2) else "No"
print(dst)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << 0 << endl;
  string s; cin >> s;
  if(s == "Vacant") return 0;
  string even = "", odd = "";
  if(s == "Male"){
    even = "Male";
    odd = "Female";
  }else{
    even = "Female";
    odd = "Male";
  }
  int l = 0, r = n;
  while(l < r){
    int mid = (l+r)/2;
    cout << mid << endl; cin >> s;
    if(s == "Vacant") return 0;
    if(mid%2){
      if(odd == s) l = mid+1;
      else r = mid;
    }else{
      if(even == s) l = mid+1;
      else r = mid;
    }
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include<iterator>
#include<vector>
#include<algorithm>


#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned

#define mod 1000000007
#define MAXN 100000
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main() 
{ 
    string s;
    cin>>s;
    int a_count = 0;
    int b_count = 0;
    for(int i = 0 ; i <3 ; i++)
    {
        if(s[i] == 'A')
        a_count++;
        else
        b_count++;
    }
    if(a_count*b_count)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;    

}

Measured memory_bytes: 256
import java.util.*;

public class Main{  
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        Stack<Integer> sales = new Stack<>();
       
        
        while(sc.hasNext()){
            int a = sc.nextInt();
            
            if(a == 0){
                System.out.println(sales.pop());
            }else{
                sales.push(a);
            }
            
        }
    }
}


Measured memory_bytes: 26240
#include <iostream>
#include <algorithm>
#include <string>

struct {
	int parent;
	int left;
	int right;
} typedef node;


using namespace std;
const int NIL = -1;

node tree[100000];
int D[100000];
int H[100000];

// Calculate depth of nodes
void depth(int u, int p)
{
	D[u] = p;
	if (tree[u].right != NIL)
		depth(tree[u].right, p + 1);
	if (tree[u].left != NIL)
		depth(tree[u].left, p + 1);
}

// Calculate height of nodes
int height(int u)
{
	int h1, h2;
	h1 = h2 = 0;
	if (tree[u].left != NIL)
		h1 = height(tree[u].left) + 1;
	if (tree[u].right != NIL)
		h2 = height(tree[u].right) + 1;
	return H[u] = max(h1, h2);
}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].left = tree[i].parent = tree[i].right = NIL;
	}
	int degree;
	int v;
	int s;
	int pre;
	int l, r;
	for (int i = 0; i < n; i++) {
		cin >> v >> l >> r;
		tree[v].left = l;
		tree[v].right = r;
		tree[l].parent = v;
		tree[r].parent = v;
	}
	
	// Find root
	int root = 0;;
	while (tree[root].parent != NIL) {
		root = tree[root].parent;
	}
	// Calculate depth
	depth(root, 0);
	// Calculate height
	height(root);

	// Output
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ":" << " parent = " << tree[i].parent << ", ";
		// Out put sibling
		cout << "sibling = ";
		if (tree[i].parent == NIL)
			cout << -1;
		else if (tree[tree[i].parent].left != i)
			cout << tree[tree[i].parent].left;
		else
			cout << tree[tree[i].parent].right;
		// Output degree
		cout << ", degree = ";
		if (tree[i].left != NIL && tree[i].right != NIL)
			cout << 2;
		else if (tree[i].left == NIL && tree[i].right == NIL)
			cout << 0;
		else
			cout << 1;
		// Output depth
		cout << ", depth = " << D[i];
		// Output height
		cout << ", height = " << H[i];
		// Output type of node
		cout << ", ";
		if (tree[i].parent == NIL)
			cout << "root";
		else if (tree[i].left == NIL && tree[i].right == NIL)
			cout << "leaf";
		else
			cout << "internal node";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, i;
  cin >> N;
  vi A(N);
  unordered_map<i64, i64> As;
  REP(0, N, i) {
    cin >> A[i];
    if(As.find(A[i]) == As.end()) {
      As[A[i]] = 0;
    }
    As[A[i]]++;
  }

  i64 ans0 = 0;
  for(auto p: As) {
    i64 C = p.second;
    ans0 += C * (C - 1) / 2;
  }

  REP(0, N, i) {
    i64 C = As[A[i]];
    if(C >= 2)
      cout << ans0 - C * (C - 1) / 2 + (C - 1) * (C - 2) / 2 << endl;
    else
      cout << ans0 << endl;
  }

  return 0;
}


Measured memory_bytes: 9160
N=gets.to_i
edge=Array.new(N+1){Array.new}
(N-1).times do
    a,b,e=gets.split.map(&:to_i)
    edge[a] << [b,e]
    edge[b] << [a,e]
end
dist=Array.new(N+1)
checked=Array.new(N+1,false)
dist[1]=0
queue=[1]
until queue.empty?
    pres=queue.shift
    next if checked[pres]
    checked[pres]=true
    edge[pres].each do |v,d|
        if !dist[v]
            dist[v]=dist[pres]+d
            queue << v
        end
    end
end
dist[1..-1].each{|e|puts e.odd? ? 1 : 0} 


Measured memory_bytes: 28284
MODC = 1000000007
s = gets.strip.to_i
# fact initialize
$factm = [1,1,2]
3.upto(s) do |i|
  $factm[i] = $factm[i-1] * i % MODC
end

def combm(n,k)
  t = $factm[k] * $factm[n-k] % MODC
  $factm[n] * t.pow(MODC-2, MODC) # =n!/t
end

ans = 0
1.upto(s/3) do |l|
  ans += combm(s-2*l-1, l-1)
  ans %= MODC
end
p ans

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const ll INF = 1e12;
// typedef
typedef pair<int, int> P;
typedef tuple<int, int, int> P3;

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1; // exclude 1
}

// make vector of divisor O(sqrt(n))
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> div = divisor(n);
    ll ans = INF;
    for (auto e : div) {
        ans = min(ans, ((e - 1) + (n / e - 1)));
    }
    out(ans);
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();

    long sum = 0;
    long check = 1000000007;

    for (int i=k; i<=n+1; i++){
      sum = (sum + 1 + ((long) i*(n-i+1)) ) % check;
    }

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


Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k; 
ll a[2005];
ll ansm, kk, kkk;
ll const BAD = 1e9+7;
ll add(ll x, ll y){
	ll a = (x%BAD + y%BAD)%BAD;
	return a;
	
	}
ll multiply(ll x, ll y){
	ll b = (x * y);
	return b;
	}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	kkk = multiply(k, k+1)/2;
	kk = multiply(k-1, k)/2;
	for (ll i = 0 ; i < n; i++){
		cin >> a[i];
		
		}
		for (ll i= 0; i < n; i++){
			for (ll j = 0; j <n; j++){
				
				if (a[j] < a[i]){
					if (j > i){
						//coming after
						ansm = add(ansm, kkk);
						
						}else {
							ansm = add(ansm, kk);
							}
					
					
					
					}
				}
		}

			
			//if (a[n-1] < a[0]){
				
			//	ansm = add(ansm, kk);
			//	}
				ansm = add(ansm, 0);
				
cout << ansm;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<double,int> Pdi;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
priority_queue<Pdi,vector<Pdi>,greater<Pdi>> que;
vector<Pli> v[18];
P2 xy[MAX_N]={};
ll dp[1<<18]={};
string str[100000];
int main() {
	ll n,k;
	cin>>n>>k;
	ll c=k/2;
	ll ans;
	if(k%2==0){
		ll g=n/c;
		ll l=g/2;
		if(g%2==0)ans=l*l*l*2;
		if(g%2==1)ans=l*l*l+(l+1)*(l+1)*(l+1);
	}else{
		c=k;
		ll g=n/c;
		ans=g*g*g;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const int INF=1001001001001001001ll;

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

signed main(){
	scanf("%lld",&N);
	rep(i,N)scanf("%lld",&A[i]);
	rep(i,N)scanf("%lld",&B[i]);


	priority_queue<int,vint,greater<int>>que;
	que.push(0);
	int b=0;
	int h=0;


	int num=0;
	rep(i,N){
		if(i){
			if(num>0){que.push(-b);que.push(-b);}
			if(que.size()>1)que.pop();
			
			h+=-(que.top()+b);
		}

		int s=A[i]-B[i];
		if(s>0){
			int tmp=que.top();
			if(que.size()>1)que.pop();
		
			que.push(tmp-s);
			b+=s;
		}
		else if(s<0){
			b-=(-s);
		}
		num+=s;
	}


	int cur=que.top()+b;
	int r=-1;
	que.push(-b);
	while(cur<0){
		int x=que.top();
		que.pop();
		h+=(x+b-cur)*r;
		r++;
		cur=x+b;
	}
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 2936
let s = read_line ()
let f s = let n = String.length s in String.sub s 0 @@ n / 2 = String.sub s (n / 2) @@ n - n / 2
let _ = for i = String.length s - 1 downto 0 do if f @@ String.sub s 0 i then (Printf.printf "%d\n" @@ i; exit 0) done

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n, K;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> K;

	int lim = (n - 1) * (n - 2) / 2;

	if (K > lim) {
		cout << -1 << endl;
		return 0;
	}

	int m = n - 1 + lim - K;
	cout << m << endl;

	for (int i = 2; i <= n; ++i)
		cout << "1 " << i << endl;

	m -= n - 1;

	int u = 1;
	while (m > 0) {
		++u;
		for (int v = u + 1; v <= n && m > 0; ++v) {
			cout << u << " " << v << endl;
			--m;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int N;
	int K;
	char name[50];
	
	scanf("%d %d", &N, &K);
	scanf("%s", &name);

	int B = K-1;
	int C = name[B]+32;
	
	name[B] = C;
	
	printf("%s", name);
	
	
	
	return 0;
}

Measured memory_bytes: 1708
#include<stdio.h>
#define ll long long
int main()
{
    ll w,h,x,y;
    double ans1=0;
    scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
    ans1=(double)((w*h)/2.0);
    if(w==2*x&&h==2*y){
        printf("%.6lf 1\n",ans1);
    }
    else{
       printf("%.6lf 0\n",ans1);
    }
}


Measured memory_bytes: 128
//{
#include<bits/stdc++.h>
using namespace std;
 
#define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}


string solve(ll n) {
    string st = "";
    
    while(n > 0) {
        ll tp = n % 26;
        char tps;
        if(tp == 0 and n > 0)
            tps = 'z';
        else
            tps = (tp - 1) + 'a';
        st = tps + st;
        // deb(n);
        if(tp == 0)
            n = n / 26 -1;
        else
            n = n / 26;
    }
    
    return st;
}

void Input() {
    rd1(ll, n);
    cout << solve(n);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

Measured memory_bytes: 3648
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
  u64 a;

public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
  constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
  constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
  constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
  constexpr bool operator==(const modint rhs) const noexcept { return modint(*this).val() == rhs.val(); }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) a -= Modulus;
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) a += Modulus;
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<mod>;
//}}}

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

  map<int, int> mp;
  mint ans = 1;

  mp[0] = 3;
  rep(i, N){
    int A;
    cin >> A;
    ans *= mp[A];
    mp[A]--;
    mp[A + 1]++;
  }
  cout << ans.val() << endl;
  return 0;
}


Measured memory_bytes: 4992
k = int(input())
v = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]

print(v[k-1])

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String S) {
        Set<Integer> seen = S.chars().boxed().collect(Collectors.toSet());

        return IntStream.rangeClosed('a', 'z').filter(ch -> !seen.contains(ch))
                .mapToObj(ch -> String.valueOf((char) ch)).findAny().orElse("None");
    }
}

Measured memory_bytes: 27288
//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }


int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        int n,k;
        cin >> n >> k;
        int arr[n+5];
        int ev=0,od=0;
        for(int i=0;i<n;i++)	
        {
        	cin >> arr[i];
        	if(arr[i]%2==0)	ev++;
        	else 			od++;
        }
        sort(arr,arr+n);
        if(k>arr[n-1])	
        {
        	cout << "IMPOSSIBLE\n";
        	return 0;
        }
        else 
        {
        	int gcd = __gcd(arr[1],arr[0]);
        	for(int i=2;i<n;i++)
        	{
        		gcd = __gcd(gcd,arr[i]);
        	}
        	if(gcd!=1 and abs(arr[0]-k)%gcd==0)	cout << "POSSIBLE\n";
        	else if(gcd==1)						cout << "POSSIBLE\n";
        	else								cout << "IMPOSSIBLE\n";
        }
    }
    return 0;
}




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

int main() {
  int N;
  cin >> N;
  vector<int> value(N);
  for (int i = 0; i < N; i++){
    cin >> value.at(i);
  }
  vector<int> cost(N);
  for (int i = 0; i < N; i++){
    cin >> cost.at(i);
  }
  int price = 0;
  for (int i = 0; i < N; i++){
    if (value.at(i) > cost.at(i)){
      price += value.at(i) - cost.at(i);
    }
  }
  cout << price << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int a,b,a2,b2;
    int lcm,gcd;
    while(cin >> a >> b){
        a2=a;
        b2=b;
        while(a != b){
        if(a>b){a = a-b;}
        else{b=b-a;}
        }
        lcm = a;
        gcd=a2 / lcm * b2;
        cout << lcm << " " << gcd << endl;
    }

}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define I inline int
#define V inline void
#define ll long long int
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define ROF(i,a,b) for(rnt i=a;i>=b;i--)
const int N=5e5+100,INF=0x3f3f3f3f;
I min(const int&x,const int&y){return x>y?x:y;}
char a[N];
int n,s[N];
ll ans;
int main(){
//	freopen("test.in","r",stdin);
	scanf("%s",a+1),n=strlen(a+1)+1,a[0]='>',a[n]='<';
	rnt p,val;
	FOR(i,1,n)if(a[i-1]=='>'&&a[i]=='<'){
		val=1,p=i;
		while(--p&&a[p]=='>')s[p]=min(s[p],val++);
		val=1,p=i;
		while(++p<=n&&a[p-1]=='<')s[p]=min(s[p],val++);
	}
	FOR(i,1,n)ans+=s[i];
	cout<<ans;
	return 0;
}

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

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int x=0;
  int ans=0;
  for(auto c:S){
    if(c=='I')x++;
    else x--;
    if(x>ans)ans=x;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b == 15)
		cout << "+" << endl;
	else if (a * b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        lit_by: [usize1; n], 
    }
    let mut seen = vec![-1; n];
    let mut now_on = 0usize;
    for i in 0.. {
        let dist = seen.get_mut(now_on).unwrap();
        if *dist != -1 { break; }
        *dist = i;
        if now_on == 1 { break; }

        now_on = *lit_by.get(now_on).unwrap();
    }
    println!("{}", seen[1]);
}


Measured memory_bytes: 6396
n, m = map(int, input().split())

lst = [list(map(int, input().split()))[1:] for _ in range(n)]

ans = 0
for i in range(1, m+1):
    val = True
    for l in lst:
        if i not in l:
            val = False
    if val:
        ans += 1
print(ans)


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

bool prime(int n) {
    for ( int i = 2; i <= sqrt(n); i++ ) {
        if ( n % i == 0 ) return false;
    }
    return true;
}

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

    for ( int i = 0; i < N; i++ ) {
       if ( prime(A[i]) ) {
           cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}



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

int main() {
  int N;
  cin >> N;
  bool a = false;
    
  for(int i=0;i<N;i++){
    string op;
    cin >> op;
    if(op=="Y"){
      a=true;
      break;
    }
  }
  
  if(a){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> h(n), w(n); for (int i = 0; i < n; ++i) cin >> h[i] >> w[i];
  V<string> s(4); for (auto&& e : s) cin >> e;
  V<> d(1 << 16, -1);
  queue<int> que;
  d[0] = 0;
  que.push(0);
  while (!que.empty()) {
    int bit = que.front(); que.pop();
    if (bit == ~(~0 << 16)) return cout << d.back() << '\n', 0;
    for (int k = 0; k < n; ++k) {
      for (int x = 1 - h[k]; x < 4; ++x) for (int y = 1 - w[k]; y < 4; ++y) {
        int nbit = bit;
        int r = 0, g = 0, b = 0;
        for (int i = max(x, 0); i < min(x + h[k], 4); ++i) for (int j = max(y, 0); j < min(y + w[k], 4); ++j) {
          if (bit >> i * 4 + j & 1) continue;
          r += s[i][j] == 'R';
          g += s[i][j] == 'G';
          b += s[i][j] == 'B';
          nbit |= 1 << i * 4 + j;
        }
        if (d[nbit] == -1 and r + g + b and max({r, g, b}) == r + g + b) {
          d[nbit] = d[bit] + 1;
          que.push(nbit);
        }
      }
    }
  }
}


Measured memory_bytes: 3448
from decimal import *
getcontext().prec = 30000
a, b, c = map(int, input().split())
# if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
if a + b + 2 * Decimal(a * b).sqrt() < c: 
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5204
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int N; LL M; int A[101010];

LL Count(int tot) {
	LL count = 0;
	for (int i = 0; i < N; ++i) {
		int Ay = tot - A[i];
		int idx = std::lower_bound(A, A + N, Ay) - A;
		count += N - idx;
	}
	return count;
}

LL Sum(int tot) {
  LL As[101010];
	for (int i = 0; i < N; ++i)    As[i] = A[i];
	for (int i = N-2; i >= 0; --i) As[i] += As[i + 1];

	LL sum = 0;
  for (int i = 0; i < N; ++i) {
		int Ay = tot - A[i];
		int idx = std::lower_bound(A, A + N, Ay) - A;
		int cnt = N - idx;
		sum += 1LL * A[i] * cnt;
		sum += As[idx];
	}
	return sum;
}

int main() {
  std::cin >> N >> M;
	for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A, A + N);

	int l = 0, r = 2 * A[N-1] + 1;
	while (l + 1 != r) {
		int mid = (l + r) / 2;
		if (M <= Count(mid)) l = mid;
		else r = mid;
	}

	LL ans = (M - Count(l + 1)) * l + Sum(l + 1);
  std::cout << ans << std::endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    int A, B, C, D;
    io.read(A, B, C, D);
    cout << ((A * B < C * D)? C * D : A * B);
    return 0;
}

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

using namespace std;
using ll = long long;
#define MOD 1000000007

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto& a : A) cin >> a;
  ll ans = 0;
  for (int k = 0; k < 63; k++) {
    ll c = 0;
    for (auto a : A)
      if (a >> k & 1) c++;
    ll x = c * (N - c) % MOD;
    for (int i = k; i--;) x = x * 2 % MOD;
    ans += x;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int sum=0;
    for(int i = 0; i < n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(),a.end());
    if(a.at(n-m)*4*m >= sum){
        cout << "Yes" << endl; 
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}


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

int main() {
  int k,s;
  ll ans = 0;
  cin >> k >> s;
  rep(i,k+1){
    rep(j,k+1){
      int z = s-i-j;
      if(0 <= z && z <= k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  int32_t K, S;
  cin >> K >> S;

  uint64_t count = 0;
  for (int32_t i = 0; i <= K; i++) {
    for (int32_t j = 0; j <= K; j++) {
      int32_t rest = (S - i - j);
      if ((0 <= rest) && (rest <= K)) {
        count++;
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}

ll Xor(ll n)
{
    if(n%4==0)
    return n;
    if(n%4==1)
    return 1;
    if(n%4==2)
    return n+1;
    if(n%4==3)
    return 0;
}
int main(){
	
	ll a,b;
	cin>>a>>b;
	//if(a == b) {cout<<0<<"\n"; return 0;}
	cout<<abs(Xor(b)^Xor(a-1))<<"\n";
	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;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  int t=k;
  while(t<=n){
    t *= k;
    ans++;
  }
  cout << ans << endl;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int A, B, C;
    cin >> A >> B >> C;

    int ans = A + B + C + 9 * max({ A, B, C });
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int x,a,b,c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &x);
	int count = 0;
	int i, j, k;
	for (i = 0; i <= a; i++) {
		if (500 * i > x) break;
		for (j = 0; j <= b; j++) {
			if (500 * i + 100 *j > x) break;
			for (k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) count++;
				else if (500 * i + 100 * j + 50 * k > x) break;
			}
		}
	}
	printf("%d", count);
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
  for j in range(1, K + 1):
    if i + j < N: dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[-1])

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

const int INF = 1e9;

vector<int> make_numbers(int a, int b, int c) {
  vector<int> v;
  for(int i=0;i<a;i++){
    v.push_back(3);
  }
  for(int i=0;i<b;i++){
    v.push_back(5);
  }
  for(int i=0;i<c;i++){
    v.push_back(7);
  }
  return v;
}
int vec_to_int(vector<int> v) {
  int ans = 0;
  for(int a: v) {
    ans = 10*ans + a;
  }
  return ans;
}
int main() {
  int n;
  cin>>n;

  int digits = (int)(log10((double)n)) + 1;
  int ans=0;
  for(int i=3;i<=digits;i++){
    for(int j=1;j<i-1;j++){
      for(int k=1;k<i-j;k++){
        vector<int> numbers=make_numbers(j,k,i-j-k);
        do {
          if (vec_to_int(numbers)<=n) {
            ++ans;
          }
        } while(next_permutation(numbers.begin(), numbers.end()));
      }
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define k 10000
  int A[2000000];
  int B[2000000];
int main(){
  int i,n,j;
  int C[k+1];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  

  for(i=0;i<k;i++){
    C[i]=0;
  }
  /* for(i=0;i<n-1;i++){
    printf("%d ",B[i]);
    }
    printf("%d\n",B[n-1]);
  */
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
  for(i=1;i<k;i++){
    C[i]= C[i] + C[i-1];
  }
  for(j=n;j>=0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }

  for(i=0;i<n-1;i++){
    printf("%d ",B[i]);
      }
  printf("%d\n",B[n-1]);
  return 0;
}



Measured memory_bytes: 17460
#include <string>
#include <vector>
#include <iostream>

#pragma warning(disable : 4996)

#define mod 100000

using namespace std;

int H, W, dp[2][1 << 19][2][2]; string M[20];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) cin >> M[i];

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < (1 << (W - 1)); j++)
		{
			dp[(i + 1) % 2][j][0][0] = 0;
			dp[(i + 1) % 2][j][0][1] = 0;
			dp[(i + 1) % 2][j][1][0] = 0;
			dp[(i + 1) % 2][j][1][1] = 0;
		}

		for (int j = 0; j < (1 << (W - 1)); j++)
		{
			char c = M[(i + 1) / W][(i + 1) % W];

			int nxt = (j << 1) % (1 << (W - 1));

			int sum0 = (dp[i % 2][j][0][0] + dp[i % 2][j][1][0]) % mod;
			int sum1 = (dp[i % 2][j][0][1] + dp[i % 2][j][1][1]) % mod;

			if (c == 'J' || c == '?')
			{
				dp[(i + 1) % 2][nxt][0][0] += sum0;
				dp[(i + 1) % 2][nxt][0][1] += sum1;

				dp[(i + 1) % 2][nxt][0][0] %= mod;
				dp[(i + 1) % 2][nxt][0][1] %= mod;
			}

			if (c == 'O' || c == '?')
			{
				if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
				{
					dp[(i + 1) % 2][nxt + 1][1][0] += dp[i % 2][j][0][0];
					dp[(i + 1) % 2][nxt + 1][1][1] += dp[i % 2][j][0][1];

					dp[(i + 1) % 2][nxt + 1][1][0] %= mod;
					dp[(i + 1) % 2][nxt + 1][1][1] %= mod;

					dp[(i + 1) % 2][nxt][1][0] += (sum0 - dp[i % 2][j][0][0] + mod);
					dp[(i + 1) % 2][nxt][1][1] += (sum1 - dp[i % 2][j][0][1] + mod);

					dp[(i + 1) % 2][nxt][1][0] %= mod;
					dp[(i + 1) % 2][nxt][1][1] %= mod;
				}
				else
				{
					dp[(i + 1) % 2][nxt][1][0] += sum0;
					dp[(i + 1) % 2][nxt][1][1] += sum1;

					dp[(i + 1) % 2][nxt][1][0] %= mod;
					dp[(i + 1) % 2][nxt][1][1] %= mod;
				}
			}

			if (c == 'I' || c == '?')
			{
				if (j & (1 << (W - 2)))
				{
					dp[(i + 1) % 2][nxt][1][1] += sum0;
				}
				else
				{
					dp[(i + 1) % 2][nxt][1][0] += sum0;
				}

				dp[(i + 1) % 2][nxt][1][1] += sum1;

				dp[(i + 1) % 2][nxt][1][0] %= mod;
				dp[(i + 1) % 2][nxt][1][1] %= mod;
			}
		}
	}

	int ret = 0;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		ret += dp[(H * W - 1) % 2][i][0][1];
		ret += dp[(H * W - 1) % 2][i][1][1];

		ret %= mod;
	}

	printf("%d\n", ret);

	return 0;
}

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

int main(){
    int student[50]={0},cut=0;
    int n;
    for(int i=1;i<29;i++){
        cin >>n;
        student[n]=1;
    }
    for(int i=1;i<31;i++){
        if(student[i]!=1)cout <<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A;
  cin>>A;
  
  cout<<A*A*3<<endl;
}


Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc146/tasks/abc146_b"

#include<bits/stdc++.h>

using namespace std;

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

    string s;
    cin>>s;

    int i;
    for(i=0;i!=s.size();i++)
        s[i] = (char)((s[i]-'A'+n)%26 + 'A');

    cout<<s;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256