akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;


int main()
{
	int h,w;
	cin>>h>>w;
vector<string> S(h);
rep(i,h){
  string temp;
  cin>>temp;
  S[i]=temp;
}
vector<vector<int>> H(h, vector<int> (w));
vector<vector<int>> W(h, vector<int> (w));

rep(i,h){
  int cnt=0;
  int lft=-1;
  rep(j,w){
  if (S[i][j]=='.') cnt++;
  else if (S[i][j]=='#') {

    for(int k=lft+1;k<j;k++){
      H[i][k]=cnt;
    }
    cnt=0;
    lft=j;
}
if (j==w-1 and S[i][j]=='.') {
  for(int k=lft+1;k<w;k++){
    H[i][k]=cnt;
  }
}

//  cout<<cnt<<endl;
}

}


rep(j,w){

  int cnt=0;
  int lft=-1;
  rep(i,h){
  //  cout<<i<<'i'<<j<<'j'<<endl;
  if (S[i][j]=='.') cnt++;
  else if (S[i][j]=='#') {

    for(int k=lft+1;k<i;k++){
      W[k][j]=cnt;
    }
    cnt=0;
    lft=i;
    }
    //cout<<i<<'i'<<j<<'j'<<cnt<<endl;
    //cout<<i<<'i'<<j<<'j'<<S[i][j]<<endl;
    if (i==h-1 and S[i][j]=='.') {
      for(int k=lft+1;k<h;k++){
        W[k][j]=cnt;


  }

}
}
}







//cout<<W[0][1]<<'t'<<endl;
int ans=0;
rep(i,h)rep(j,w){
  int temp=H[i][j]+W[i][j]-1;
//  cout<<temp<<endl;
  ans=max(ans,temp);
}

cout<<ans;


}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < (EPS))

#define COUNTER_CLOCKWISE (1)
#define CLOCKWISE (-1)
#define ONLINE_BACK (2)
#define ONLINE_FRONT (-2)
#define ON_SEGMENT (0)

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;
typedef Segment Line;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Line l, Point p)
{
  Vector base = l.p2 - l.p1;
  return (l.p1 + base * (dot(p - l.p1, base) / base.norm()));
}

Point reflect(Line l, Point p)
{
  return (-p + project(l, p) * 2.0);
}


int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  
  if(cross(a, b) > EPS) return (COUNTER_CLOCKWISE);
  if(cross(a, b) < -EPS) return (CLOCKWISE);
  if(dot(a, b) < -EPS) return (ONLINE_BACK);
  if(a.norm() < b.norm()) return (ONLINE_FRONT);
  
  return (ON_SEGMENT);
}

bool intersect(Point p1, Point p2, Point p3, Point p4)
{
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2)
{
  return (intersect(s1.p1, s1.p2, s2.p1, s2.p2));
}

double getDistanceLP(Line l, Point p)
{
  return (abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs()));
}

double getDistanceSP(Segment s, Point p)
{
  if(dot(s.p2 - s.p1, p - s.p1) < 0.0) return ((p - s.p1).abs());
  if(dot(s.p1 - s.p2, p - s.p2) < 0.0) return ((p - s.p2).abs());
  return (getDistanceLP(s, p));
}

double getDistance(Segment s1, Segment s2)
{
  double ans;

  if(intersect(s1, s2)) {
    ans = 0.0;
  } else {
    ans = min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2));
    ans = min(ans, min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)));
  }

  return (ans);
}


main()
{
  int n;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    Segment s1, s2;
    s1.input(); s2.input();
    printf("%.10f\n", getDistance(s1, s2));
  }

  return (0);
}

Measured memory_bytes: 3204
N, X = [int(line) for line in input().split()]
L = [int(line) for line in input().split()]

D = [0]#D1 = 0
for i in range(1,N+1):#座標Dの配列を作る
    Di = D[i-1] + L[i-1]
    D.append(Di)

ans = 0
for i in range(len(D)):#
    if D[i] <= X:
      ans += 1
print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  long long int n; cin >> n;
  if( n%2 == 0 ) cout << n << endl;
  else cout << n*2 << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
num = list(map(int,input().split()))

ans = 10000
for i in range(n):
  substr1 = num[0:i+1]
  substr2 = num[i+1:n]
  sum1 = sum(substr1)
  sum2 = sum(substr2)
  ans = min(ans,abs(sum1-sum2))
  
print(ans)

Measured memory_bytes: 3064
readlines.each do |l|
  xa,ya,xb,yb,xc,yc,xd,yd = l.split(",").map(&:to_f)
  v1x,v1y = xb-xa, yb-ya
  v2x,v2y = xd-xa, yd-ya
  v3x,v3y = xc-xa, yc-ya
  t = (v3x*v2y - v3y*v2x)/(v1x*v2y - v1y*v2x)
  u = (v3x*v1y - v3y*v1x)/(v2x*v1y - v2y*v1x)
  puts t>0 && u>0 && t+u>1 ? "YES" : "NO"
end

Measured memory_bytes: 6128
from itertools import permutations

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    perm = list(permutations(sorted(a)))

    for i in range(len(perm)):
        if a == list(perm[i]):
            if 0<i:print (' '.join(map(str,perm[i-1])))
            print (' '.join(map(str,perm[i])))
            if i<len(perm)-1:print (' '.join(map(str,perm[i+1])))

if __name__ == '__main__':
    main()




Measured memory_bytes: 52372
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  vector<int> vec;
  // vec : vec[i] <= K && vec[i]の0のbitのいずれを1にしてもKを超えてしまうもの
  int N; ll K;
  cin >> N >> K;
  ll A[N],B[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  ll KK = K;
  ll s = 0;
  for (int i = 0; i < 30; i++) {
    if (KK < (1 << i+1) - 1) {
      s = i;
      break;
    }
  }
  vec.push_back((1 << s) - 1);
  ll now = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (KK > (1 << bit)) {
      KK -= (1 << bit);
      now += (1 << bit);
      int a = -1;
      for (int i = 0; i < 30; i++) {
        if (KK < (1 << i+1) - 1) {
          a = i;
          break;
        }
      }
      vec.push_back((1 << a) - 1 + now);
    }
  }
  ll ans = 0;
  for (int i = 0; i < (int)vec.size(); i++) {
    ll res = 0;
    for (int j = 0; j < N; j++) {
      bool in = true;
      for (int bit = 0; bit < 30; bit++) {
        if (vec[i] & (1 << bit)) {
          
        } else {
          if (A[j] & (1 << bit)) {
            in = false;
          }
        }
      }
      if (in) {
        res += B[j];
      }
    }
    ans = max(ans,res);
  }
  cout << ans << endl;
  return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int h,w;
string s;
vector <string> v;

void printSharp() {
  REP (i, w + 2) printf("#");
  printf("\n");
}

int main(){
  cin >> h >> w;
  REP (i, h) {
    cin >> s;
    v.push_back(s);
  }

  printSharp();
  for (auto itr = v.begin(); itr != v.end(); itr++) {
    cout << "#" << *itr << "#" << "\n";
  }
  printSharp();
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, K := nextInt(), nextInt()
	An := make([]int, N)
	sortedAn := make([]int, 0)
	Revisit := make([]int, N+1)
	for i := range Revisit {
		Revisit[i] = -1
	}
	// var start, last int
	for i := range An {
		An[i] = nextInt()
	}
	cur := 1
	for Revisit[cur] == -1 {
		Revisit[cur] = len(sortedAn)
		sortedAn = append(sortedAn, cur)
		cur = An[cur-1]
	}
	looplength := len(sortedAn) - Revisit[cur]
	if K <= Revisit[cur] {
		fmt.Println(sortedAn[K])
	} else {
		K -= Revisit[cur]
		K %= looplength
		fmt.Println(sortedAn[K+Revisit[cur]])
	}
	// fmt.Println(K, cur, looplength, sortedAn, Revisit)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 13932
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main() {
	int n,a=0,u=0,count=0;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "A") a++;
		if (s == "Un") {
			a--;
			if (a < 0)count = 1;
		}
			
		
	}
	if (a != 0) count = 1;
	if (count == 1) {
		cout <<"NO"<< endl;
	}
	else cout << "YES" << endl;
}

Measured memory_bytes: 3144
#include <stdio.h>
int N = 100;
int main(void){
    int M[N][N];
    int n,u,k,v;
    int i,j;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) M[i][j] = 0;
    }
    
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(j>0) printf(" ");
            printf("%d",M[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2104
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

safeHead [] = Nothing
safeHead (x:_) = Just x

-- 
--
--

main = do
    [h,_] <- getIs
    inps <- replicateM h getLine
    forM inps (replicateM 2 . putStrLn) >> return ()


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  int a,b;
  cin>>a>>b;
  rep(i,1e7){
    if(i*8/100==a&&i/10==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}


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

#define INF 1e6


int main() {
    int n; cin >> n;
    vector<char> s(n); for(int i = 0; i < n; i++) cin >> s[i];
    vector<int> west(n, 0), east(n, 0);

    west[0] = (s[0] == 'W' ? 1 : 0);
    east[0] = (s[0] == 'E' ? 1 : 0);
    for(int i = 1; i < n; i++) {
        int w = (s[i] == 'W' ? 1 : 0);
        int e = (s[i] == 'E' ? 1 : 0);
        west[i] = west[i - 1] + w;
        east[i] = east[i - 1] + e;
    }

    int ans = east[n - 1] - east[0];
    for(int i = 1; i < n; i++) {
        int tmp = west[i - 1] + (east[n - 1] - east[i]);
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}



Measured memory_bytes: 2944
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	string s;
	cin >> s;
	int len = s.length(),count = 0;

	FOR(0, len / 2)
	{
		if (s[i] != s[len - i - 1])count++;
	}
	
	cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 1e10

struct D {
    vector<double> l, r;
    D() : l(3, INF), r(3, -INF) {}

    void add(double x, int v) {
        v++;
        l[v] = min(l[v], x);
        r[v] = max(r[v], x);
    }

    double get(double t) {
        double nl = INF, nr = -INF;
        REP(i, 3) {
            nl = min(nl, l[i] + i * t);
            nr = max(nr, r[i] + i * t);
        }
        return nr - nl;
    }

    vector<double> events() {
        vector<double> ret;
        FOR(i, 1, 3) REP(j, i) {
            double t = (l[j] - l[i]) / (i - j);
            if (t > 0) ret.push_back(t);
            t = (r[j] - r[i]) / (i - j);
            if (t > 0) ret.push_back(t);
        }
        return ret;
    }
};

int main() {
    int N;
    cin >> N;
    D xd, yd;
    REP(i, N) {
        int x, y;
        char d;
        cin >> x >> y >> d;
        switch (d) {
            case 'L': xd.add(x, -1), yd.add(y, 0); break;
            case 'R': xd.add(x, 1), yd.add(y, 0); break;
            case 'U': xd.add(x, 0), yd.add(y, 1); break;
            case 'D': xd.add(x, 0), yd.add(y, -1); break;
        }
    }

    vector<double> ts;
    ts.push_back(0);
    ts.push_back(INF);

    vector<double> nts = xd.events();
    ts.insert(ts.end(), ALL(nts));
    nts = yd.events();
    ts.insert(ts.end(), ALL(nts));
    sort(ALL(ts));

    double ans = 1e18;
    for (auto t : ts) {
        ans = min(ans, xd.get(t) * yd.get(t));
    }
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

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

  if(a>b)std::swap(a,b);

  if((b-a)%2==0){
    std::cout<<std::abs(a-b)/2<<"\n";
    return 0;
  }else{
    std::cout<<std::min(a+(b-a-1)/2,n-b+1+(b-a-1)/2)<<"\n";
  }

  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, m, k;
int MOD = 998244353;
i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}
const int MAX = 404040;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
	inv[0] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long C(i64 n, i64 k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	/*i64 res = 1;
	for(int i = 1; i <= k; i++){
		res *= n-i+1;
		res %= MOD;
		res *= inv[i];
		res %= MOD;
	}
	return res;
	*/
}
void solve(){
	cin >> n >> m >> k;
	
	i64 ans = 0;
	COMinit();
	for(int i = 0; i <= k; i++){
		ans += m*mod_pow(m-1,n-i-1,MOD)%MOD * C(n-1,i) %MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 13124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

LL n,x,ans;
void gcd(LL x,LL y)
{
	if(x<y)swap(x,y);
	if(y==0)return;
	if(x%y==0)ans-=y;
	ans+=(x/y)*y*2;
	gcd(y,x%y);
}
int main()
{
	cin>>n>>x;
	gcd(x,n-x);
	ans+=n;
	printendl(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
 
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}
 
ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
/*long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}*/
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return 
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}
 
 
 
/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

#define int ll
const int MX = 1e3 +9;

int32_t main(){
    IO;
	string s;
	cin>>s;
	bool a, b;
	a = b = 0;
	for(char c : s){
		if(c == 'A') a =1;
		else b = 1;
	}
	if(a && b) cout<<"Yes";
	else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
int head[maxn], nxt[maxn * 2], a[maxn * 2], edge, dis[maxn];
void create(int u, int v)
{
	edge++; a[edge] = v; nxt[edge] = head[u]; head[u] = edge;
}
void dfs(int u, int fa)
{
	dis[u] = dis[fa] + 1;
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = a[i];
		if (v != fa) dfs(v, u);
	}
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n - 1; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		create(u, v); create(v, u);
	}
	dfs(1, 0);
	int rt = 1;
	for (int i = 2; i <= n; i++)
		if (dis[i] > dis[rt]) rt = i;
	dfs(rt, 0);
	int mx = 0;
	for (int i = 1; i <= n; i++)
		mx = max(mx, dis[i]);
	if (mx % 3 == 2) puts("Second");
	else puts("First");
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 100010;
int p[MX];
int root(int x){
	if(x == p[x]) return x;
	return p[x] = root(p[x]);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi v(n); rep(i, n) cin >> v[i];
	
	rep(i, n) p[i] = i;
	
	rep(i, m){
		int a, b; cin >> a >> b;
		a = root(a - 1);
		b = root(b - 1);
		if(a != b) p[b] = a;
	}
	
	vector<vi> A(n), B(n);
	rep(i, n){
		A[root(i)].pb(v[i] - 1);
		B[root(i)].pb(i);
	}
	int cnt = 0;
	rep(i, n){
		sort(all(A[i])); sort(all(B[i]));
		for(int j = 0, k = 0; j < A[i].size(); j++){
			while(k < B[i].size() && A[i][j] > B[i][k]) k++;
			if(k < B[i].size() && A[i][j] == B[i][k]) cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 12032
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 300;

inline void Max(int &a, int b) {
  a = b > a ? b : a;
}

int n, m;
char s[maxn + 1];
int dp[maxn + 1][maxn + 1][maxn + 1];

int main(void) {
  scanf("%s%d", s, &m);
  n = strlen(s);
  for (int k = 0; k <= m; ++k) {
    for (int l = 0; l <= n; ++l) {
      for (int r = n; r >= l; --r) {
        if (l > 0) {
          Max(dp[l][r][k], dp[l - 1][r][k]);
        }
        if (r < n) {
          Max(dp[l][r][k], dp[l][r + 1][k]);
        }
        if (l > 0 && r < n) {
          int cost = !(s[l - 1] == s[r]);
          if (k >= cost) {
            Max(dp[l][r][k], dp[l - 1][r + 1][k - cost] + 1);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int mid = 0; mid < n; ++mid) {
    Max(ans, dp[mid][mid + 1][m] * 2 + 1);
    Max(ans, dp[mid][mid][m] * 2);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 106624
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo=1000000007;
lint kai[114514],rkai[114514],zyo[114514];
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint co(int a,int b){
	if(a<0 || b<0) return 0;
	return ((kai[a+b]*rkai[b])%mo*rkai[a])%mo;
}
lint cal(int n,int m){
	lint ret=0;
	rep(i,n+1){
		int x=i,y=n-i;
		if(y-x>m) continue;
		if(y<=m){
			ret+=zyo[y]*co(x,y);ret%=mo;
		}
		else{
			ret+=(co(x,y)-co(y-m-1,x+m+1))*zyo[y];ret%=mo;
		}
	}
	ret%=mo;
	if(ret<0) ret+=mo;
	return ret;
}
int main()
{
	int n;string s;cin>>n;cin>>s;
	zyo[0]=kai[0]=rkai[0]=1;
	rep(i,114510){
		zyo[i+1]=zyo[i]*2;zyo[i+1]%=mo;
		kai[i+1]=kai[i]*(i+1);kai[i+1]%=mo;
		rkai[i+1]=rkai[i]*invMod(i+1,mo);rkai[i+1]%=mo;
	}
	lint out=cal(n,s.size())-cal(n,s.size()-1);
	out*=invMod(zyo[s.size()],mo);out%=mo;out+=mo;
	cout<<out%mo<<endl;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start()
        {
            var line = Console.ReadLine().Split(' ');
            Int64 N = Int64.Parse(line[0]), M = Int64.Parse(line[1]);
            var input = new List<List<Int64>>();
            Int64 count = 0;
            Int64 yen = 0;

            for (int i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(Int64.Parse);
                input.Add(new List<Int64>(tmp));
            }

            var after = input.OrderBy(x => x[0]).ToArray();

            for (int i = 0; count < M;i++){
                //Console.WriteLine(after[i][0]);

                if(count + after[i][1] <= M) {
                    count += after[i][1];
                    yen += after[i][0] * after[i][1];
                } else {
                    var tmp = M - count;
                    count += tmp;
                    yen += tmp * after[i][0];
                }

                //Console.WriteLine(count);
            }

            Console.WriteLine(yen);
        }
    }
}




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

int dp[111111],n,m,a[111];

int main(){
  while(cin>>n>>m,n){
    vector<int>v;
    r(i,n)cin>>a[i];
    r(i,(1<<n)){
      int f=0;
      r(j,n)if(i&(1<<j))f+=a[j];
      v.push_back(f);
    }
    r(i,111111)dp[i]=1e9;
    dp[0]=0;
    r(i,m+1){
      r(j,(1<<n)){
        if(i+v[j]>=m+100)continue;
        dp[i+v[j]]=min(dp[i+v[j]],dp[i]+1);
      }
    }
    cout<<dp[m]<<endl;
  }
}


Measured memory_bytes: 3540
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    while a[i]%2 == 0:
        a[i]//=2
        cnt+=1
print(cnt)

Measured memory_bytes: 4636
#include<stdio.h>
typedef long long LL;
LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  LL N=IN();int sz=0,str[12];
  while(N){N--;str[sz++]='a'+N%26;N/=26;}
  for(int i=0;i<sz;i++)printf("%c",str[sz-i-1]);
}

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

int main() {
	int	N;
	cin >> N;
	vector<int> vec(N);
	rep(i, N)
		cin >> vec.at(i);
	int	Q;
	cin >> Q;
	rep(i, Q)
	{
		int	k;
		cin >> k;
		cout << distance(vec.begin(), partition_point(vec.begin(), vec.end(), [k](const int& e){return (e < k);})) << ' ' << distance(vec.begin(), partition_point(vec.begin(), vec.end(), [k](const int& e){return !bool(k < e);})) << endl;
		/* cout << distance(vec.begin(), lower_bound(vec.begin(), vec.end(), k)) << ' ' << distance(vec.begin(), upper_bound(vec.begin(), vec.end(), k)) << endl; */
	}
}



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

int main(){
int n,m,b,ans=0,s=0;
double sum=0;
cin>>n>>m;
vector<int> a(n);
for(int i=0; i<n; i++){
cin>>a[i];
sum+=a[i];
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for(int i=0; i<m; i++){
if(a[i]>=sum/(4*m)){
  ans++;
}
}
if(ans==m){
  cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int digit(int n) {
	int ret = 0;
	while (n > 0) {
		ret++;
		n /= 10;
	}
	return ret;
}

signed main() {
	int n;
	cin >> n;
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (digit(i) % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void printArray(int var[], int num) {
  int i;
  for (i = 0; i < num; i++) {
      if (i > 0) printf(" ");
      printf("%d", var[i]);
  }
  printf("\n");
}

void selectionSort(int var[], int num) {
  int i, j;
  int iMin;
  int tmp;
  int counter = 0;
  for (i = 0; i < num; i++) {
    iMin = i;

    for (j = i; j < num; j++) {
      if (var[j] < var[iMin]) {
        iMin = j;
      }
    }
    if (iMin != i) counter++;
    tmp = var[i];
    var[i] = var[iMin];
    var[iMin] = tmp;
  }
  printArray(var, num);
  printf("%d\n", counter);

}

int main(void) {
    int i, num;
    scanf("%d", &num);
    int var[num];
    for (i = 0; i < num; i++) scanf("%d", &var[i]);

    selectionSort(var, num);

    return 0;
}


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

int dp[30][1<<16];

int main(){
  int n,m;
  while(cin >> n >> m && (n|m)){
    int a[30],b[30],ans = 0;
    fill(a,a+30,0);
    fill(b,b+30,0);
    fill(dp[0],dp[30],-1);
    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
        int x;
        cin >> x;
        a[i] |= (x << j);
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<16;j++){
        int x;
        cin >> x;
        b[i] |= (x << j);
      }
    }

    dp[0][0] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
        if(dp[i][j] >= 0){
          for(int k=0;k<m;k++){
            int c = j | a[i];
            int d = c & b[k];
            if(i < n - 1) dp[i+1][c^d] = max(dp[i+1][c^d],dp[i][j] + __builtin_popcount(d));
            else ans = max(ans,dp[i][j] + __builtin_popcount(d));
          }
        }
      }
    }
    cout << ans << endl;
  }
}

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

int N;
multiset<int> S, t, c;

int main() {
  cin >> N;
  rep(i, (1 << N)) {
    int j;
    cin >> j;
    S.insert(j);
  }

  t.insert(*S.rbegin());
  S.erase(*S.rbegin());

  rep(i, N) {
    c = multiset<int>(t);
    for (auto e : t) {
      auto it = S.lower_bound(e);
      if (it == S.begin()) {
        cout << "No" << endl;
        return 0;
      }
      c.insert(*prev(it));
      S.erase(prev(it));
    }
    t = c;
  }

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


Measured memory_bytes: 24832
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int x;
    cin >> x;
    vector<bool> dp(x+1, false);
    dp[0] = true;

    for(int a=100; a<=105; ++a){
        for(int i=0; i<=x-a; ++i){
            if(dp[i])
                dp[i+a] = true;
        }
    }

    if(dp[x])
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define pii pair<int,int>
using namespace std;
char Ch[65], p[200], Res[200], RC;
int DEB = 0, DCK;
char RR[200];
int PV, C[65], n, T[100];
void Clear(){
    PV = 0;
}
void Add(int a){
    p[PV++] = Ch[a];
}
int Query(){
    p[PV] = 0;
    if(!DEB)printf("? %s\n",p);
    fflush(stdout);
    int a;
    if(!DEB){
        scanf("%d",&a);
    }
    else{
        if(DCK){
            int c=0;
            for(int i=0;i<PV;i++){
                if(p[i]!=RR[i])c++;
            }
            a=c;
            printf("%s %d\n",p,a);
        }
        else{
            int s=0;
            for(int i=0;RR[i];i++)if(RR[i]==p[0])s++;
            a=128-s;
        }
    }
    PV = 0;
    return a;
}
int S[62][150], C1[62], C2[62];
int Count(int a, int b, int e){
    return S[a][e]-S[a][b-1];
}
void Do(int b, int e, vector<pii>V){
    if(DEB){
        for(auto &t : V){
            printf("%c %d\n",Ch[t.first], t.second);
        }
    }
    if(V.size()==1){
        for(int i=0;i<V[0].second;i++)Res[RC++] = Ch[V[0].first];
        return;
    }
    int m = (b+e)>>1;
    int pv = V[0].first;
    int i, sz = V.size(), j, sum = 0;
    for(i=1;i<sz;i++){
        for(j=1;j<=m;j++)Add(V[i].first);
        for(j=m+1;j<=n;j++)Add(pv);
        T[i] = n - Query() - Count(V[i].first, 1, b-1) - Count(pv, e+1, n);
    }
    T[0] = V[0].second;
    for(i=0;i<sz;i++)sum+=T[i];
    for(i=0;i<62;i++)C1[i]=C2[i]=0;
    //printf("%d %d %d\n",sum, m-b+1, sz);
    C2[pv] = (sum - (m-b+1)) / sz;
    C1[pv] = V[0].second - C2[pv];
    for(i=1;i<sz;i++){
        C1[V[i].first] = T[i] - C2[pv];
        C2[V[i].first] = V[i].second - C1[V[i].first];
    }
    for(i=0;i<62;i++){
        S[i][m] = S[i][b-1] + C1[i];
    }
    vector<pii>V1,V2;
    for(i=0;i<62;i++){
        if(C1[i])V1.push_back({i,C1[i]});
        if(C2[i])V2.push_back({i,C2[i]});
    }
    Do(b,m,V1);
    Do(m+1,e,V2);
}
int main(){
    if(DEB){
        scanf("%s",RR);
    }
    int i, c=0, j;
    for(i='a';i<='z';i++)Ch[c++]=i;
    for(i='A';i<='Z';i++)Ch[c++]=i;
    for(i='0';i<='9';i++)Ch[c++]=i;
    vector<pii>V;
    int s=0;
    for(i=0;i<62;i++){
        for(j=0;j<128;j++)Add(i);
        C[i] = 128-Query();
        s+=C[i];
        if(C[i])V.push_back({i,C[i]});
    }
    DCK=1;
    n = s;
    for(i=0;i<62;i++){
        S[i][n] = C[i];
    }
    Do(1, n, V);
    printf("! %s\n",Res);
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

bool isDone(vector<int> box)
{
    for (int i = 0; i < box.size(); i++)
    {
        if (box[i] != 0)
        {
            return false;
        }
    }
    return true;
}

bool isZero(vector<int> box)
{
    for (int i = 0; i < box.size(); i++)
    {
        if (box[i] == 0)
        {
            return true;
        }
    }
    return false;
}

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

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    int cnt = 0;
    while (isDone(h) == false)
    {
        if (isZero(h) == false)
        {
            // -1 from every pos
            for (int i = 0; i < N; i++)
            {
                h[i]--;
                // printf("%d ", h[i]);
            }
            // printf("\n");
        }
        else
        {
            bool start_found = false;
            bool goal_found = false;
            for (int i = 0; i < N; i++)
            {
                if (h[i] > 0)
                {
                    start_found = true;
                    h[i]--;
                }
                else if (h[i] == 0 && start_found == true)
                {
                    goal_found = true;
                }
                if (start_found == true && goal_found == true)
                {
                    break;
                }
            }
        }
        // for (int i = 0; i < N; i++)
        // {
        //     printf("%d ", h[i]);
        // }
        // printf("\n");
        cnt++;
    }
    cout << cnt << endl;
    return (0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;  cin >> s;
    vector<int> pos(n), t(n);
    FOR(i, 1, n) {
      if (s[i - 1] == 'A' && s[i] == 'C') {
        pos[i - 1] = 1;
      }
    }
    t[0] = pos[0];
    FOR(i, 1, n) {
      t[i] = pos[i - 1] + t[i - 1];
    }
    rep(i, q) {
      int l, r;
      cin >> l >> r;
      cout << t[r - 1] - t[l - 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<30;
int V,match[MAX];
vector<int> G[MAX];
bool used[MAX];

void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        int u=G[v][i],w=match[u];
        if(w<0||(!used[w]&&DFS(w))){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    memset(match,-1,sizeof(match));
    for(int v=0;v<V;v++){
        if(match[v]<0){
            memset(used,0,sizeof(used));
            if(DFS(v)) res++;
        }
    }
    return res;
}

int main(){

    int Y,E;cin>>V>>Y>>E;
    for(int i=0;i<E;i++){
        int a,b;cin>>a>>b;
        add_edge(a,100+b);
    }
    
    cout<<bipartite_matching()<<endl;
    
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int K;
  cin >> K;
  
  if (K%2 == 0) {
    cout << (K/2)*(K/2) << endl;
  }
  else {
    cout << (K/2+1)*(K/2);
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef char str255[256];

#define A 0
#define B 1
#define C 2
#define NUM_PERSON 3
#define FIRST_ONE A

str255 S[NUM_PERSON];
int ptr[NUM_PERSON];
int len[NUM_PERSON];
int next_one;

void Solve()
{
	next_one = FIRST_ONE;
	while(1){
		if (ptr[next_one] > len[next_one])
			break;
		char c = S[next_one][ptr[next_one]++];
		switch(c){
			case 'a': next_one = A; break;
			case 'b': next_one = B; break;
			case 'c': next_one = C; break;
		}
	}
	switch(next_one){
		case A: puts("A"); break;
		case B: puts("B"); break;
		case C: puts("C"); break;
	}
}

void Init()
{
	scanf("%s", S[0]); scanf("%s", S[1]); scanf("%s", S[2]);
	ptr[A] = ptr[B] = ptr[C] = 0;
	for (int i = 0; i < NUM_PERSON; ++i)
		len[i] = strlen(S[i]);
}

void Clean(){}
int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 128
<?php
 
fscanf(STDIN, "%d %d %d %d %d", $x1, $x2, $x3, $x4, $x5);
 

if ($x1 == 0) {
  echo(1);
} elseif ($x2 == 0) {
  echo(2);
} elseif ($x3 == 0) {
  echo(3);
} elseif ($x4 == 0) {
  echo(4);
} elseif ($x5 == 0) {
  echo(5);
}


Measured memory_bytes: 16048
#include <stdio.h>

int main(){
  int i,j,flag=1,count=0,len,array[100],num;

  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&array[i]);
  }
  i=0;
  while(flag){
      flag=0;
      for(j=len-1;j>=i+1;j--){
	if(array[j]<array[j-1]){
	  num=array[j];
	  array[j]=array[j-1];
	  array[j-1]=num;
	  count++;
	  flag=1;
	}
      }
      i++;
  }
  for(i=0;i<len;i++){
    printf("%d",array[i]);
    if(i==len-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",count);
  return 0;
}	



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

int main()
{
    int  x,y,z,f,t;
    while(~scanf("%d",&x))
    {
        if(x<3)
        {
            printf("0\n");
        }
        if(x>=3)
        {

                printf("%d\n",x/3);

        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t A,B,C,K; cin>>A>>B>>C>>K;

    int64_t ans=0;
    ans+=min(A,K);
    if(A<K){
        K-=A;
        K-=B;

        if(K>0) ans-=K;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int arr[100005], dp[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	dp[0] = 0; dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; ++i)
		dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
	cout << dp[n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 1024