akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

const int MAX = 100001;
int n,k,white;
bool data[MAX];

void solve(){
  int st = 0,en = 0,wi = 0,ans = 0;
  
  while(1){
    ans = max(ans,en-st);
    if(wi <= white && en < n && data[en+1]){
      en++;
    }else if(wi < white && en < n){
      en++;
      if(!data[en]) wi++;
    }else{
      st++;
      if(!data[st]) wi--;
    }
    //  cout << "st " << st << " en " << en << endl;
    if(en == n && st == n) break;
  }
  cout << ans << endl;
}

int main(){

  while(cin >> n >> k && n+k){
    fill(data,data+MAX,false);
    white = 0;

    for(int i = 0; i < k; i++){
      int in;
      cin >> in;
      if(in == 0) white++;
      data[in] = true;
    }
    solve();
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  ll x;
  cin >> x;
  ll ans=0;
  ans=(x/500)*1000 + ((x%500)/5)*5;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  cin >> n >> m;
  vec a(n),b(m);
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<m;i++) cin >> b[i];
  mat dp(n+1,vec(m+1)),ans(n+1,vec(m+1));
  for(ll i=0;i<n;i++) {
    map<ll,ll> cnt;
    for(ll j=0;j<m;j++) {
      ans[i+1][j+1]=(ans[i+1][j]+ans[i][j+1]-ans[i][j]+mod)%mod;
      if(a[i]==b[j]) {
        dp[i+1][j+1]=ans[i][j]+1;
        (ans[i+1][j+1]+=dp[i+1][j+1])%=mod;
      }
    }
  }
  cout << (ans[n][m]+1)%mod << endl;
}

Measured memory_bytes: 65896
h, w = [int(item) for item in input().split()]
field = ["%" * (w+2)] + ["%" + input() + "%" for _ in range(h)] + ["%" * (w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        count = 0
        if field[i][j] == ".":
            for k in [-1,0,1]:
                for l in [-1,0,1]:
                    if field[i+k][j+l] == "#":
                        count += 1
            field[i] = field[i][:j] + str(count) + field[i][j+1:]

for line in field[1:h+1]:
    for c in line:
        if c !="%":
            print(c, end="")
    print("")

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 4 * 1e18;
/* -- template -- */

#define max max<ll>
#define min min<ll>

int main() {
    int N, K; cin >> N >> K;
    vector<ll> xx(N), yy(N);
    rep(i, N) cin >> xx[i] >> yy[i];
    vector<ll> x(N), y(N);
    x = xx, y = yy;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = (x[N - 1] - x[0]) * (y[N - 1] - y[0]);
    for(int xi = 0;xi < N;++xi) {
        for(int xj = xi + 1; xj < N;++xj) {
            for(int yi = 0;yi < N;++yi) {
                for(int yj = yi + 1;yj < N;++yj) {
                    int count = 0;
                    ll xl = x[xi], xr = x[xj];
                    ll yl = y[yi], yr = y[yj];

                    for(int i = 0;i < N;++i) {
                        if(xl <= xx[i] && xx[i] <= xr && yl <= yy[i] && yy[i] <= yr)
                            ++count;
                    }
                    if(count >= K)
                        ans = min(ans, 1LL * (xr - xl) * (yr - yl));
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int count=0,ans=INT_MAX;
  string s;
  cin >> s;
  for (int i=0;i<26;i++){
    string ss=s;
    bool goal=true;
    for (int j=0;j<ss.size();j++){
        if (ss[j]!='a'+i)goal=false;
    }
    while (!goal){
      count++;
      string sss=ss;
      for(int j=0;j<ss.size();j++){
        if(ss[j]=='a'+i || ss[j+1]=='a'+i)sss[j]='a'+i;
      }
      sss.pop_back();
      ss=sss;
      goal=true;
      for (int j=0;j<ss.size();j++){
        if (ss[j]!='a'+i)goal=false;
      }
    }
    ans=min(ans,count);
    count=0;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int n,d,D,ans;
    cin>>n>>d;
    D = d * 2 + 1;
    ans = n / D;
    if(n % D == 0)
    {
        cout<<ans;
    }
    else
    {
        cout<<ans + 1;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B___Bitter_Alchemy
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = input[0];
            var X = input[1];
            var list = new List<int>();
            for (int i = 0; i < N; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }
            var nokori = X - list.Sum();
            var result = list.Count() + nokori / list.Min();
            Console.Write(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    cout << d[n/2] - d[n/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

int A,B,ans;
int data[4];

void solve(){
  for(int i = 1; i <= A; i++)
    if(A%i == 0)
      for(int j = 1; j <= B; j++)
	if(B%j == 0){
	  data[0] = i;
	  data[1] = A/i;
	  data[2] = j;
	  data[3] = B/j;
	  sort(data,data+4);


	  int sum = 0;
	  for(int i = 1; i < 4; i++)
	    sum += (data[i]-data[i-1])*(data[i]-data[i-1]);
	  
	  if(ans == -1) ans = sum; 
	  else ans = min(ans,sum);
	  
	}

  cout << ans << endl;
}

int main(){
  while(cin >> A >> B && A+B){
    ans = -1;
    solve();
  }

  return 0;
}

Measured memory_bytes: 1176
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE FlexibleContexts #-}
module Main (main) where
import Data.List
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.Vector ((!))
import Control.Applicative
getInts :: IO [Int]
getInts = unfoldr (B8.readInt . B8.dropWhile (==' ')) <$> BS.getLine
data Edge = Edge {to :: !Int,revIx :: !Int,capIx :: !Int}
  deriving (Show,Eq)
type Graph = V.Vector (V.Vector Edge)

printGraph :: Show a => V.Vector (V.Vector a) -> IO ()
printGraph = V.mapM_ (\i -> V.mapM (putStr . (' ':) . show) i >> putStrLn "")

printCap :: MV.IOVector Int -> IO ()
printCap v = print =<< V.freeze v
      
getGraph :: IO (Graph,MV.IOVector Int)
getGraph = do
  v:e:_ <- getInts
  cap <- MV.new (e*2)
  g <- MV.replicate v []
  forM_ [0..e-1] $ \i -> do
    u:v:c:_ <- getInts
    MV.write cap i c
    MV.write cap (i + e) 0
    us <- MV.read g u
    vs <- MV.read g v
    MV.write g u $ Edge v (e+i) i: us
    MV.write g v $ Edge u i (e+i): vs
    return ()
  g' <- V.map (V.fromList . reverse) <$> V.freeze g
  return (g', cap)

main :: IO ()
main = do
  (g,cap) <- getGraph
  -- printGraph g
  -- printCap cap
  r <- maxFlow 0 (V.length g - 1) g cap
  print r
  return ()

untilJustM :: Monad m => (a -> m (Maybe b)) -> V.Vector a -> m (Maybe b)
untilJustM act xs
  | V.null xs = return Nothing
  | otherwise = let v = V.head xs
                in do
      x <- act v
      case x of
        Nothing -> untilJustM act (V.tail xs)
        Just _ -> return x
      
maxFlow :: Int -> Int -> Graph -> MV.IOVector Int -> IO Int
maxFlow s t g cap = loop 0
  where
    loop f = do
      used <- MV.replicate (V.length g) False
      df <- dfs maxBound s t g cap used
      if df == 0
        then return f
        else loop (f + df)

dfs :: Int -> Int -> Int -> Graph
  -> MV.IOVector Int
  -> MV.IOVector Bool
  -> IO Int
dfs f v t g cap used
  -- | traceShow v False = undefined
  | v == t = return f
  | otherwise = do
      MV.write used v True
      fromMaybe 0 <$> untilJustM act (g ! v)
  where
    act :: Edge -> IO (Maybe Int)
    act e@Edge {to = to,capIx = ci, revIx = ri} = do
      c <- MV.read cap ci
      isUsed <- MV.read used to
      if c > 0 && not isUsed
      then do
        d <- dfs (min f c) to t g cap used
        if d > 0
        then do
          modifyCap cap e d
          return (Just d)
        else return Nothing
      else return Nothing

modifyCap :: MV.IOVector Int -> Edge -> Int -> IO ()
modifyCap cap Edge {capIx = ci, revIx = ri} d
  = do
  cv <- MV.read cap ci
  cr <- MV.read cap ri
  MV.write cap ci $ cv - d
  MV.write cap ri $ cr + d

Measured memory_bytes: 6724
N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
if N%2==0:
    cnt = A[0]
    for i in range(1,N//2):
        cnt += 2*A[i]
    print(cnt)
else:
    cnt = A[0]
    for i in range(1,N//2):
        cnt += 2*A[i]
    cnt += A[N//2]
    print(cnt)

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

int main() {
  vector<string> ts = {"dream", "dreamer", "erase", "eraser"};
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  rep(i,(int)ts.size()) reverse(ts.at(i).begin(), ts.at(i).end());
  
  for (int i = 0; i < s.size();) {
    bool match = false;
    rep(j,(int)ts.size()) {
      if(s.substr(i, ts.at(j).size()) == ts.at(j)) {
        match = true;
        i += ts.at(j).size();
        break;
      }
    }
    
    if (!match) {
      cout << "NO" << endl;
      return 0;
    }
    
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3752
<?php

fscanf(STDIN, "%d %d", $n, $m);
if ($n == 1 && $m == 1) {
    echo 1, PHP_EOL;
    return;
}
if ($n == 1) {
    echo $m - 2, PHP_EOL;
    return;
}
if ($m == 1) {
    echo $n - 2, PHP_EOL;
    return;
}
if ($n == 2 || $m == 2) {
    echo 0, PHP_EOL;
    return;
}

echo ($n - 2) * ($m - 2), PHP_EOL;


Measured memory_bytes: 16040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200011;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n , p[N] , ans[N], root;
vector<int> g[N];
pii E;
int dsu[N];
int find(int u){
	return dsu[u]==u?u:dsu[u]=find(dsu[u]);
}

bool check() {
	g[E.x].pb(E.y);
	bool can = true;
	for (int i = 1; i <= n; ++i) {
		set<int> st;
		int cnt = 0;
		for (auto j : g[i]) {
			st.insert(ans[j]);
		}
		while(st.count(cnt))++cnt;
		if(ans[i] != cnt)can = false;
	}
	if (can) {
		puts("POSSIBLE");
		exit(0);
	}

}
int dfs(int u , int p) {
	set<int> st;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v == p)continue;
		st.insert(dfs(v, u));
	}
	int cnt = 0;
	while (st.count(cnt))++cnt;
	if(ans[u] == -1){
		ans[u] = cnt;
	}
	return ans[u];
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n ; ++i) {
		scanf("%d", &p[i]);
		dsu[i]=i;
	}
	for (int i = 1; i <= n; ++i){
		if(find(p[i])!=find(i)){
			g[p[i]].pb(i);
			dsu[find(p[i])]=find(i);
		}else{
			E = mp(p[i],i);
		}
	}
	root = E.second;
	
	memset(ans, -1, sizeof ans);
	dfs(root, -1);
	check();
	int cnt = 0;
	set<int> st;
	for (auto j : g[p[root]]) {
		st.insert(ans[j]);
	}
	g[E.first].pop_back();	
	while (st.count(cnt))++cnt;
	memset(ans, -1, sizeof ans);
	ans[E.first] = cnt;
	dfs(root, -1);
	check();


	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 33920
n,p=map(int,input().split())
d=dict()
for i in range(2,int(p**0.5)+1):
    d[i]=0
    while p%i==0:
        d[i]+=1
        p//=i
if p!=1:d[p]=1
ans=1
for i in d.keys():
    ans*=i**(d[i]//n)
print(ans)

Measured memory_bytes: 99040
//Rooted Trees
#include <iostream>

using namespace std;

struct Node {
    int p = -1, l = -1, r = -1, d = 0;
};

void setDepth(Node N[], int u, int d) {
    N[u].d = d;
    if(N[u].r != -1) setDepth(N, N[u].r, d);
    if(N[u].l != -1) setDepth(N, N[u].l, d + 1);
}

int main() {
    int n;
    cin >> n;
    Node N[n];
    for(int i = 0; i < n; i++) {
        int id, k;
        cin >> id >> k;
        if(k > 0) {
            int c[k];
            for(int j = 0; j < k; j++) cin >> c[j];
            N[id].l = c[0];
            for(int j = 0; j < k; j++) {
                N[c[j]].p = id;
                if(k - j > 1) N[c[j]].r = c[j + 1];
            }
        }
    }

    for(int i = 0; i < n; i++) {
        if(N[i].p == -1) {setDepth(N, i, 0); break;}
    }

    for(int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << N[i].p << ", depth = " << N[i].d << ", ";
        if(N[i].p == -1) cout <<"root, ";
        else if(N[i].l == -1) cout << "leaf, ";
        else cout << "internal node, ";
        int n = N[i].l;
        cout << "[";
        while(n != -1) {
            cout << n;
            n = N[n].r;
            if(n != -1) cout << ", ";
        }
        cout << "]" << endl;
    }
}


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

#define ull unsigned long long int
#define ll long long

using namespace std;

long long A[100000+1];

int main() {

    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        A[a]+=b;
    }
    
    for(int i=1; i<=100000; i++)
    {
        if(k <= A[i])
        {
            cout<<i<<"\n";
            return 0;
        }
        k-=A[i];
    }
    
    return 0;
}

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

using namespace std;


int main()
{
    long long int n=0,fact=1,m=1000000007,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        
        fact=(fact*i)%m;
    }
    
    cout<<fact;
    
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

dp = [[0] * (W + 1) for _ in range(H + 1)]

dp[1][1] = 1

for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        if A[i][j] == '.':
            dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD

print (dp[H][W])

# for tmp in dp:
#     print (tmp)

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
queue<int> Q[6];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  if (N == 3) {
    cout << "2 5 63\n";
    return 0;
  }
  if (N == 4) {
    cout << "2 5 20 63\n";
    return 0;
  }
  // 2,4,3,0
  for (int x=2; x<=30000; x++) if ((x%2 == 0) || (x%3 == 0)) {
    Q[x%6].push(x);
  }
  //cout<<Q[2].size()<<"*"<<Q[4].size()<<"*"<<Q[3].size()<<"\n";
  for (int two=1; two<=Q[2].size(); two++) {
    for (int four=0; four<=Q[4].size() && two+four<=N; four++) {
      if ((2*two+4*four)%6) continue;
      int three = min((int)Q[3].size(), N-(two-four));
      if (three%2) three--;
      if (three == 0) continue;
      //for (int three=0; three<=Q[3].size() && two+four+three<=N; three+=2) {
        int zero = N-(two+four+three);
        if (zero > Q[0].size()) continue;

        rep(_, two) { cout << Q[2].front() << " "; Q[2].pop(); }
        rep(_, four) { cout << Q[4].front() << " "; Q[4].pop(); }
        rep(_, three) { cout << Q[3].front() << " "; Q[3].pop(); }
        rep(_, zero) { cout << Q[0].front() << " "; Q[0].pop(); }
        cout << "\n";
        return 0;
      //}
    }
  }
  abort();
  return 0;
}


Measured memory_bytes: 512
tmp = list(map(int,input().split()))
h, w = tmp[0],tmp[1]
maze = []
for i in range(h):
    maze.append([i for i in input()])
maze[0][0] = 0
i = 0
def change(data,p,q,i):
    if data[p][q] == ".":
        data[p][q] = i+1

def makechange(data,j,k,i):
    if j != h-1:
        change(data,j+1,k,i)
    if k != w-1:
        change(data,j,k+1,i)
    if j != 0:
        change(data,j-1,k,i)
    if k != 0:
        change(data,j,k-1,i)

while(True):
    ifhenka = False
    newmaze = [i for i in maze]
    for j in range(h):
        for k in range(w):
            if maze[j][k] == i:
                makechange(maze,j,k,i)
    if maze[h-1][w-1] != ".":
        break
    if i == 2500:
        print(-1)
        quit()
    i += 1

ans = 0
for i in maze:
    ans += i.count("#")
print(h*w - ans - maze[h-1][w-1] - 1)


Measured memory_bytes: 3064
// ref: https://img.atcoder.jp/arc091/editorial.pdf
// ref: https://twitter.com/task4233/status/973160336474828800/photo/1

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 max(const int64 lhs, const int64 rhs){ return lhs>rhs?lhs:rhs; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int64 N, K; cin >> N >> K;
    if(K==0){ cout << N*N << endl; return 0; }
    
    int64 sum=0;
    for(int b=1; b<=N; ++b){
        int64 div = (N+1)/b;
        int64 mod = (N+1) - div*b; // int64 mod = (N+1)%b;
        
        sum += max(0ll,   b-K) * div;
        sum += max(0ll, mod-K);
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long A, long long B){
    if(B % A == 0)
        cout << A+B << endl;
    else
        cout << B-A << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> cnt(26, 1);
    for (char c : s) {
        ++cnt[c - 'a'];
    }
    ll ans = 1;
    for (ll c : cnt) {
        ans *= c;
        ans %= 1000000007LL;
    }
    cout << ans - 1 << endl;
    return 0;
}

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


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int d = 0;
  if(a == b) d++;
  if(a == c) d++;
  if(b == c) d++;
  
  if (d == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region MODint
template<int MOD> struct Fp
{
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD)
	{
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept
	{
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept
	{
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept
	{
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept
	{
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept
	{
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b)
		{
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept
	{
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept
	{
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept
	{
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
	{
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

const int MOD = 1000000007;
using mint = Fp<MOD>; 
#pragma endregion

vector<vector<int>> v(2001001);
vector<int> childNum(2001001, 1);
vector<int> depth(2001001, 0);

int dfs(int now, int p, int d)
{
	depth[now] = d;
	for (int next : v[now])
	{
		if (next == p)continue;
		childNum[now] += dfs(next, now, d + 1);
	}
	return childNum[now];
}

int main()
{
	int n; cin >> n;
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		--a, --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0, -1, 0);
	mint x = modpow(mint(2), n);
	mint y = 0;
	rep(i, n)
	{
		if (v[i].size() == 1)continue;
		mint tmp = modpow(mint(2), n - 1) - 1;
		int par = n - 1;
		for (int child : v[i])
		{
			if (depth[child] < depth[i])continue;
			tmp -= modpow(mint(2), childNum[child]) - 1;
			par -= childNum[child];
		}
		tmp -= modpow(mint(2), par) - 1;
		y += tmp;
	}
	mint res = y / x;
	cout << res << endl;
}

Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		int d = scan.nextInt();
		int n = scan.nextInt();
		if(n == 100) n++;
		System.out.println((int)Math.pow(100, d) * n);
	}
}


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

const ll dv = 1000000007;

// sのt乗 mod dv
ll pow2( ll s, ll t ){
  if( t < 0 ) return 0;
  if( t == 0 ) return 1;
  if( t == 1 ) return s;
  ll tmp = pow2(s,t/2);
  if( t%2 == 0 ){
    return tmp%dv*tmp%dv;
  }else{
    return tmp%dv*tmp%dv*s%dv;
  }
}

int main(){
  ll n;cin >> n;
  ll ans = pow2(10,n) - pow2(9,n)*2 + pow2(8,n);
  ans %= dv;
  while( ans < 0 )
    ans += dv;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
eval"N,K,*A="+`dd`.split*?,
S=->a{a.reduce:+}
s,*l=S[A]
1.upto(3e4){|i|s%i<1&&l<<i<<s/i}
p l.select{|d|a=A.map{|a|a%d}.sort
S[a[0..-S[a]/d-1]]<=K}.max

Measured memory_bytes: 9856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public final class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] in = br.readLine().split(" ");
		int n = Integer.parseInt(in[0]);
		int x = Integer.parseInt(in[1]);
		int[] arr = new int[n];
		in = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(in[i]);
		}
		long a = new Solver().solve(arr, x);
		System.out.println(a);
	}
}

class Solver {

	long solve(int[] a, int x) {
		long res = 0;
		if (a[0] + a[1] - x > a[1]) {
			res += (a[0] + a[1] - x - a[1]);
			a[0] -= (a[0] + a[1] - x - a[1]);
		}
		for (int i = 1; i < a.length; i++) {
			if (a[i] + a[i - 1] > x) {
				res += (a[i] + a[i - 1] - x);
				a[i] -= (a[i] + a[i - 1] - x);
			}
		}
		return res;
	}
}


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

const int N = 2005;

struct BIT{
    int d[2 * N];
    void i(){ fill(d + 1, d + 2 * N, 0); }
    void u(int x){ for(; x < 2 * N; x += x & -x) d[x]++; }
    void r(int x){ for(; x < 2 * N; x += x & -x) d[x]--; }
    int g(int x){ int r = 0; for(; x; x -= x & -x) r += d[x]; return r; }
} B;

int n, b[N], w[N], d[N][N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= 2 * n; i++){
        char s[3]; int x;
        scanf("%s%d", s, &x);
        if(s[0] == 'B') b[x] = i;
        else w[x] = i;
    }
    for(int i = 0; i <= n; i++) fill(d[i], d[i] + n + 1, 4 * N * N);
    d[0][0] = 0;
    for(int i = 0; i <= n; i++){
        B.i();
        for(int k = i + 1; k <= n; k++) B.u(b[k]);
        for(int k = 1; k <= n; k++) B.u(w[k]);
        for(int j = 0; j <= n; j++){
            if(i < n) d[i + 1][j] = min(d[i + 1][j], d[i][j] + B.g(b[i + 1] - 1));
            if(j < n) d[i][j + 1] = min(d[i][j + 1], d[i][j] + B.g(w[j + 1] - 1));
            if(j < n) B.r(w[j + 1]);
        }
    }
    printf("%d\n", min(d[n][n - 1], d[n - 1][n]));
}

Measured memory_bytes: 16000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int l025 = nextInt();
        int l05 = nextInt();
        int l1 = nextInt();
        int l2 = nextInt();

        long n = nextInt();

        if (n == 1) {
            // 0.25２個と0.5どっちがやすい
            int l025_2 = l025 * 2;
            int price1 = l05;

            if (l025_2 < l05) {
                price1 = l025_2;
            }

            int price1_2 = price1 * 2;
            if (price1_2 < l1) {
                out(price1_2);
            } else {
                out(l1);
            }

            return;

        } else if (n % 2 == 0) {
            // 全部2L値段にスル
            long l025_2 = l025 * 8L;
            long l05_2 = l05 * 4L;
            long l1_2 = l1 * 2L;

            // 一番安い奴つかう
            long[] parr = new long[] {l025_2, l05_2, l1_2, l2};
            Arrays.sort(parr);

            out(parr[0] * (n / 2));
            //out(l2 * (n / 2));
        } else {
            // 全部2L値段にスル
            long l025_2 = l025 * 8L;
            long l05_2 = l05 * 4L;
            long l1_2 = l1 * 2L;

            // 一番安い奴つかう
            long[] parr = new long[] {l025_2, l05_2, l1_2, l2};
            Arrays.sort(parr);

            // 1L値段も
            long l025_1 = l025 * 4L;
            long l05_1 = l05 * 2L;

            // 一番安い奴つかう
            long[] parr1l = new long[] {l025_1, l05_1, l1};
            Arrays.sort(parr1l);


            out((parr[0] * (n / 2)) + parr1l[0]);
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                int sumab = 500 * i + 100 * j;
                int remain = x - sumab;
                if (remain < 0) continue;
                if (remain <= 50 * c) count++;
            }
        }
        System.out.println(count);
    }
}


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

int main(){
    string s;
    cin >> s;

    int n = s.size();

    string ans = "keyence";
    if(s == ans){
        cout << "YES"<< endl;
        return 0;
    }

    for(int i = 0;i < n;i++){
        for(int j = i;j < n;j++){
            string t;
            for(int k = 0;k < n;k++){
                if(!(i <= k && k <= j)){
                    t.push_back(s[k]);
                }
            }
            if(t == ans){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(a+b-n,0LL)<<"\n";
    return 0;
}


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

n2_list = [2, 4, 8, 16, 32, 64]

if n >= 64:
    print(64)
elif n >= 32:
    print(32)
elif n >= 16:
    print(16)
elif n >= 8:
    print(8)
elif n >= 4:
    print(4)
elif n >= 2:
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		if(a!=1){System.out.println(""+1);}
		else if(b!=2){System.out.println(""+2);}
		else if(c!=3){System.out.println(""+3);}
		else if(d!=4){System.out.println(""+4);}
		else if(e!=5){System.out.println(""+5);}
}
}

Measured memory_bytes: 35764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	set<ll>st;
	ll s,cnt;
	cin>>s;
	cnt=1;
	while(st.find(s)==st.end()){
		st.insert(s);
		if(s%2){
			s=s*3+1;
		}else{
			s/=2;
		}
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ForYellow
{
    class AGC014_D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            HashSet<int>[] graph = new HashSet<int>[n];
            for(int i = 0; i < n; i++)
            {
                graph[i] = new HashSet<int>();
            }
            for (int i = 0; i < n - 1; i++)
            {
                int[] ab = ReadInts();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }

            int[] parents = new int[n];
            var que = new Queue<int>();
            var stk = new Stack<int>();
            que.Enqueue(0);
            stk.Push(0);
            parents[0] = -1;
            while (que.Count > 0)
            {
                int now = que.Dequeue();
                foreach(int to in  graph[now])
                {
                    if (to==parents[now])
                    {
                        continue;
                    }

                    parents[to] = now;
                    que.Enqueue(to);
                    stk.Push(to);
                }
            }

            while (stk.Count > 0)
            {
                int now = stk.Pop();
                if (graph[now].Count == 0)
                {
                    continue;
                }

                if (parents[now] == -1 || graph[parents[now]].Count == 0)
                {
                    WriteLine("First");
                    return;
                }

                graph[parents[now]].Clear();
            }

            WriteLine("Second");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 66336
H, W = map(int,input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
    ans.append(list(row))

for h in range(H):
    for w in range(W):
        count = 0
        # １．ドットの値だった時の処理で、
        if ans[h][w] == ".":
            for i in range(-1,2,1):
                for j in range(-1,2,1):
                    # ２．前後左右斜めをドットの位置を起点にして-1,0,1まで繰り返し値を取得を試みる
                    target_h = h+i
                    target_w = w+j
                    # ３．指定されたマスの範囲を超える場合は算出しないようにして、#の値をカウントする
                    if target_h >= 0 and target_h <= H-1 and target_w >= 0 and target_w <= W-1:
                        if ans[target_h][target_w] == "#":
                            count += 1
            ans[h][w] = count
# print(ans)
for row in ans:
    # リストをjoinでstringへ結合、それを行ごとに繰り返す
    print(''.join(list(map(str,row))))

Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(M1,D1);
    Cinii(M2,D2);
    if(M2-M1==1 || (M2==1 && M1==12) ){
        cout << 1 << nn;
    }else{
        cout << 0 << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll a, b;
    cin>>a>>b;
    cout<<(a>b ? a-1 : a)<<endl;
    return 0;
}


Measured memory_bytes: 3572
#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 rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vector<double> p(n),sum(n+1,0);
    rep(i,n) {
        int np;
        cin >> np;
        p[i] = (np+1)/2.0;
    }
    rep(i,n) sum[i+1] = sum[i]+p[i];
    double ans = 0;
    rep(i,n-k+1) {
        chmax(ans,sum[i+k]-sum[i]);
    }
    printf("%.8f",ans);
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){   
    int h,a;
    cin>>h>>a;
    int ans = 0;
    while(ans * a < h)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s;
    cin>>s;
    int k=s.size();
    char b[k];
    rep(i,s.size()){
        b[i]=s[i];
    }
    sort(b,b+k);
    int p=0,n=0,con=0;
    rep(i,k-1){
        if(b[i]!=b[i+1]){
            if(con==0){
                p=i-0+1;
                con++;
            }
            else{
                n=i-p+1;
            }
        }
    }
    int kn=k-p-n;
    int w=min({p,n,kn});
    if(p-w>1||n-w>1||kn-w>1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    //a,b,c,a,b,c,
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        long layers[], patties[];
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt();
            long X = in.nextLong();
            layers = new long[N + 1];
            patties = new long[N + 1];

            layers[0] = 1;
            patties[0] = 1;
            for (int i = 1; i < N; i++) {
                layers[i] = 2 * layers[i - 1] + 3;
                patties[i] = 2 * patties[i - 1] + 1;
            }

            out.println(f(N, X));
        }

        long f(int n, long x) {
            if (n == 0) {
                return 1;
            } else if (x == 1) {
                return 0;
            } else if (x <= layers[n - 1] + 1) {
                return f(n - 1, x - 1);
            } else if (x == layers[n - 1] + 2) {
                return f(n - 1, x - 1) + 1;
            } else if (x == 2 * layers[n - 1] + 3) {
                return 2 * patties[n - 1] + 1;
            } else {
                return patties[n - 1] + 1 + f(n - 1, x - layers[n - 1] - 2);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return  Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22996
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(s):
        t = [int(c) for c in S()]
        a = [t[ord(c) - ord('a')] if c in 'abcd' else c for c in s]

        def ff(a):
            if len(a) == 1:
                return a[0]
            l = len(a)
            for i in range(l-4):
                if a[i] == '[' and a[i+4] == ']':
                    op = a[i+1]
                    b = a[i+2]
                    c = a[i+3]
                    t = -1
                    if op == '+':
                        t = b | c
                    elif op == '*':
                        t = b & c
                    elif op == '^':
                        t = b ^ c
                    return ff(a[:i] + [t] + a[i+5:])
            return -1

        r = ff(a)
        c = 0
        for k in range(10000):
            tt = [k//(10**i)%10 for i in range(4)]
            aa = [tt[ord(c) - ord('a')] if c in 'abcd' else c for c in s]
            kk = ff(aa)
            if kk == r:
                c += 1
        return '{} {}'.format(r,c)

    while 1:
        n = S()
        if n == '.':
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))


print(main())



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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    std::cout<<std::fixed<<std::setprecision(10);
    ll W,H,x,y;
    cin >> W >> H >> x >> y;
    double area = (double)(W*H)/2;
    bool flag = false;
    if (W%2 == 0 && H%2 == 0) {
        if (W/2 == x && H/2 == y) flag = true;
    } 
    cout << area << " ";
    if (flag) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		long num = sc.nextLong();
		long ans = 0;

		ans += (num / 500) * 1000;
		num = num % 500;

		ans += (num / 5) * 5;
		num = num % 5;

		System.out.println(ans);

	}
}

Measured memory_bytes: 35552