akhauriyash/Code-Regression huggingface dataset:
import Data.List
import Control.Monad

main = do
    [n, k] <- map read . words <$> getLine
    abss <- replicateM n $ map read . words <$> getLine
    print . getIndex k $ sort abss

getIndex k ([a,b]:abss)
    | b >= k    = a
    | otherwise = getIndex (k - b) abss


Measured memory_bytes: 131452
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  int n;
  ll c;
  cin >> n >> c;
  vector<ll> migi(mx,0);
  vector<ll> hidari(mx,0);
  vector<ll> m_migi(mx,0);
  vector<ll> m_hidari(mx,0);
  vector<ll> x(mx,0);
  vector<ll> v(mx,0);
  for(int i=1; i<=n; i++){
    cin >> x[i] >> v[i];
  }
  x[n+1]=c;
  for(int i=1; i<=n; i++){
    migi[i] = migi[i-1]+v[i]-(x[i]-x[i-1]);
    hidari[i] = hidari[i-1]+v[n+1-i]-(x[n+2-i]-x[n+1-i]);
    m_migi[i] = max(migi[i],m_migi[i-1]);
    m_hidari[i] = max(hidari[i],m_hidari[i-1]);
  }
  ll ans = max(m_migi[n],m_hidari[n]);
  for(int i=1; i<=n; i++){
    ans = max(ans, migi[i] + m_hidari[n-i] -x[i]);
    ans = max(ans, hidari[i] + m_migi[n-i] -(c-x[n+1-i]));
//  cout << ans << endl;
  }
//  cout << endl;
  
/*  cout << m_migi[0] << endl;
  cout << m_migi[1] << endl;
  cout << m_migi[2] << endl;
  cout << m_migi[3] << endl;
  cout << endl;
  cout << m_hidari[0] << endl;
  cout << m_hidari[1] << endl;
  cout << m_hidari[2] << endl;
  cout << m_hidari[3] << endl;
  cout << endl;*/
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll MOD = 1000000007;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll a[200005];
int main() {
  IOS;
  int k, n;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  ll product = 1;
  if (a[n - 1] == 0 && (k & 1)) {
    cout << 0 << endl;
    return 0;
  } else if (a[n - 1] <= 0 && (k & 1)) {
    for (int i = n - 1; i >= n - k; i--)
      product = (product * a[i] + MOD) % MOD;
    cout << product << endl;
    return 0;
  }
  int i = 0, j = n - 1;
  if (k & 1) {
    product = (product * a[j] % MOD + MOD) % MOD;
    j--, k--;
  }
  k /= 2;
  for (int it = 0; it < k; it++) {
    ll lproduct = a[i] * a[i + 1];
    ll rproduct = a[j] * a[j - 1];
    // cout << lproduct << ' ' << rproduct << endl;
    if (lproduct > rproduct) {
      product = ((product * (lproduct % MOD + MOD) % MOD) % MOD + MOD) % MOD;
      i += 2;
    } else {
      product = ((product * (rproduct % MOD + MOD) % MOD) % MOD + MOD) % MOD;
      j -= 2;
    }
  }
  cout << (product + MOD) % MOD << endl;
}

Measured memory_bytes: 5208
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	a, b, c, x := oneInt(), oneInt(), oneInt(), oneInt()

	count := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}

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

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

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


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

bool water[3][3001], sugar[3][3001];

int main() {
  int a[2], c[2];
  int e,f;
  cin >> a[0] >> a[1] >> c[0] >> c[1] >> e >> f;

  water[0][0] = sugar[0][0] = true;
  for (int i = 1; i <= 2; ++i) {
    for (int j = 0; j <= f; ++j) {
      water[i][j] = water[i-1][j]; sugar[i][j] = sugar[i-1][j];
      if ((j-a[i-1]*100 >= 0) && (water[i-1][j-a[i-1]*100] || water[i][j-a[i-1]*100])) water[i][j] = true;
      if ((j-c[i-1] >= 0) && (sugar[i-1][j-c[i-1]] || sugar[i][j-c[i-1]])) sugar[i][j] = true;
    }
  }
  
  vector<int> vecw, vecs;
  rep(i, f+1) {
    if (water[2][i]) vecw.push_back(i);
    if (sugar[2][i]) vecs.push_back(i);
  }
  
  double bunbo = 100*a[0], bunsi = 0;
  for (int i = 0; i < vecw.size(); ++i) {
    double w = vecw[i];
    auto itr = upper_bound(vecs.begin(), vecs.end(), min(f-w, (double)e*w/100.0));
    if (itr == vecs.begin()) continue;
    double s = vecs[-1 + distance(vecs.begin(), itr)];
    if (bunsi/bunbo < s/(w+s)) {
      bunsi = s;
      bunbo = w+s;
    }
  }
  cout << (int)bunbo << " " << (int)bunsi << endl;
  return 0;
}

Measured memory_bytes: 256
import math

def enough(HP,A,B,X):
    q = 0
    for i in range(len(HP)):
        q += max(math.ceil((HP[i] - B * X) / (A - B)),0)
    if q <= X:
        return True
    else:
        return False
    

over = 10 ** 9
under = 0
HP = []
N,A,B = map(int,input().rstrip().split(" "))
for i in range(N):
    HP.append(int(input()))

while abs(over - under) > 1:
    mid = (over + under) // 2
    if enough(HP,A,B,mid):
        over = mid
    else:
        under = mid
print(over)


Measured memory_bytes: 13076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int countac(string a, int b, int c){
    int count = 0;
    b--;
    c--;
    rep(j, b, c){
        if(a[j] == 'A'&& a[j+1] == 'C')count++;
    }
    return count;
}

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int>l(q);
    vector<int>r(q);
    vector<int>aclength(n,0);
    rep(i, 0, q){
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }
    int cntac = 0;
    string temps;
    temps += s[0];
    rep(i, 1, n){
        temps += s[i];
        if(temps[i-1] == 'A' && temps[i] == 'C')cntac++;
        aclength[i] = cntac;
    }
    rep(i, 0, q){
        cout << aclength[r[i]] - aclength[l[i]] << endl;
    }
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	string str;
	cin>>str;
	vector<int>v1;
	vector<int>v2;
	int p =0;
	int p1 =0;
	for(int i=0;i<n;i++)
	{
		if(str[i] == '1')
		{
			if(p1 > 0){
				v2.push_back(p1);
				p1 =0;
			}
			p++;
		}
		else
		{
			if(p > 0){
				v1.push_back(p);
				p =0;
			}
			p1++;
		}
	}
	if(p!= 0)
	{
		v1.push_back(p);
	}
	if(p1 != 0)
	{
		v2.push_back(p1);
	}
	vector<int>ans1;
	vector<int>ans2;
	int s = 0;
	int l = v2.size();
	for(int i=0;i<min(k,l);i++)
	{
		s += v2[i];
	}
	ans1.push_back(s);
	int d =0;
	for(int i=k;i<v2.size();i++)
	{
		s -= v2[d];
		s += v2[i];
		d++;
		ans1.push_back(s);
	}
	int s1 = 0;
	int l1 = v1.size();
	int g ;
	if(str[0] == '1')
	{
		g = k+1;
	}
	else
	{
		g =k;
	}
	for(int i=0;i<min(g,l1);i++)
	{
		s1 += v1[i];
	}
	ans2.push_back(s1);
	int d1 =0;
	int f =0;
	if(g == k)
	{
		f=1;
	}
	for(int i=g;i<v1.size();i++)
	{
		 if(f==0)
	    {
	    	s1 -= v1[d1];
			d1++;	
		}
		if(f == 1)
		{
			f=0;
	    }
	   
		s1 += v1[i];
		ans2.push_back(s1);
	}
	if(ans2.size() != ans1.size())
	{
		if(s1 != v1[d1])
		{
			s1 -= v1[d1];
		}	
		ans2.push_back(s1);
	}
	int mx =0;
	for(int i=0;i<ans1.size();i++)
	{
		//cout<<ans1[i]<<" "<<ans2[i]<<endl;
		int a = ans1[i] + ans2[i];
		mx = max(mx,a);
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 2372
import math as m


def resolve():
    A, B, H, M = [int(i) for i in input().split()]
    x = abs(360 / 60 * M - (0.5 * (60 * H + M)))
    ans = m.sqrt((A)**2 + (B)**2 - (2 * A * B) * m.cos(m.radians(x)))
    print(ans)


resolve()


Measured memory_bytes: 9504
#include<bits/stdc++.h>
// O.o
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

const int N = 500000 + 105;
set<int>se[30];
int main(){
    int n;
    string s; cin>>n>>s;
    for(int i = 0; i < n; ++i){
        se[s[i] - 'a'].insert(i);
    }
    int m, op, l, r, sum = 0; cin>>m;
    char c;
    for(int i = 1; i <= m; ++i){
        cin>>op;
        if(op == 1){
            cin>>l>>c; --l;
            se[s[l] - 'a'].erase(l);
            se[c - 'a'].insert(l);
            s[l] = c;
        }
        else{
            cin>>l>>r; --l, --r; sum = 0;
            for(int j = 0; j < 26; ++j){
                auto flag = se[j].lower_bound(l);
                if(flag == se[j].end()) continue;
                if(*flag <= r) ++sum;
            }
            printf("%d\n", sum);
        }
    }
    // system("pause"); 0.0
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,w;
	cin>>n>>w;
	long long int   i,j;
	long long int  a[n],val[n],dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>val[i];
	}
	for(i=0;i<=w;i++)
	{
		dp[0][i]=0;
	}
	for(i=0;i<=n;i++)
	{
		dp[i][0]=1;
	}
	long long int inc=0,exc=0;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=0;
			}
			else
			{
			if(a[i-1]<=j)
			dp[i][j]=max(val[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j]);
			else
			dp[i][j]=dp[i-1][j];
			}
		}
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
//			cout<<dp[i][j]<<" ";
		}
//		cout<<"\n";
	}
	cout<<dp[n][w];
}


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

def prime_factor(n):
    table = [0 for i in range(1000)]
    
    for x in range(2, N+1):
        for i in range(2, x+1):
            if i * i > x:
                break
            while x%i == 0:
                table[i] += 1
                x = x // i

        if x > 1:
            table[x] += 1
    return table
    
count = 1
    
res = prime_factor(N)

for r in res:
    count *= (r + 1)
    count %= 10**9+7
    
print(count)


Measured memory_bytes: 3060
# coding: utf-8
import collections

N,M,K=map(int,input().split())
F=[[] for i in range(N+1)]
Bl=[[] for i in range(N+1)]

par = [i for i in range(N+1)]
rank = [0 for i in range(N+1)]
 
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
 
def unite(x,y):
    rx=find(x)
    ry=find(y)

    if rx==ry:
        return
    
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx

    if rank[rx]==rank[ry]:
        rank[rx]+=1
 

def some(x,y):
    return find(x)==find(y)
 
for i in range(M):
    A,B=map(int,input().split())
    unite(A,B)
    F[A].append(B)
    F[B].append(A)

for i in range(K):
    C,D=map(int,input().split())
    Bl[C].append(D)
    Bl[D].append(C)

ans=[0 for i in range(N)]
for i in range(N):
    find(i+1)
c = collections.Counter(par)

for i in range(N):
    ans[i]+=c[find(i+1)]-1
    ans[i]-=len(F[i+1])
    for j in range(len(Bl[i+1])):
        if some(i+1,Bl[i+1][j]):
            ans[i]-=1
print(*ans)    


Measured memory_bytes: 49292
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int oddcnt = 0;
    for (int x; cin >> x; oddcnt += x%2);
    cout << (oddcnt%2==1 ? "NO\n" : "YES\n");
}


Measured memory_bytes: 256
import * as fs from 'fs'

const reader = (data: string) => parseInt(data, 10)

export function Main(input) {
  const N = reader(input)
  let prime = 0
  for (let i = 2; i * i <= N; i++) {
    if (N % i === 0) {
      prime = i
    }
  }

  console.log(prime ? prime - 1 + N / prime - 1 : N - 1)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

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

    cout << ((a * b >= c * d) ? a * b : c * d);
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public 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);
        DAlterAltar solver = new DAlterAltar();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAlterAltar {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] c = in.next().toCharArray();

            int[] w = new int[n + 1];
            for (int i = 0; i < n; i++) {
                w[i + 1] = w[i] + (c[i] == 'W' ? 1 : 0);
            }

            IntUnaryOperator moves = left -> {

                int wrongLeft = w[left];
                int wrongRight = (n - left) - (w[n] - w[left]);

                return wrongLeft + wrongRight - Math.min(wrongLeft, wrongRight);
            };

            int answer = BinarySearch.ternarySearch(moves, 0, n);
            out.println(moves.applyAsInt(answer));
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }

    static class BinarySearch {
        public static int ternarySearch(IntUnaryOperator f, int left, int right) {
            while (true) {
                int t = (right - left) / 3;
                if (t == 0) {
                    int answer = left;
                    int opt = f.applyAsInt(left);
                    for (int x = left + 1; x <= right; x++) {
                        int candidate = f.applyAsInt(x);
                        if (candidate < opt) {
                            answer = x;
                            opt = candidate;
                        }
                    }
                    return answer;
                }
                int a = left + t;
                int b = right - t;
                if (f.applyAsInt(a) > f.applyAsInt(b)) {
                    left = a;
                } else {
                    right = b;
                }
            }
        }

    }
}



Measured memory_bytes: 34248
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int h,n;
    cin>> h>> n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    int sum = 0;
    REP(i,n) sum += a[i];

    if(sum >= h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll n;
	cin>>n;
	string s;
	map<string,int> ma;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		ma[s]++;
	}
	ll no_wa=0,no_ac=0,no_tle=0,no_re=0;
	for(auto it:ma)
	{
		if(it.first == "AC")
		{
			no_ac+= it.second;
		}
		if(it.first == "WA")
		{
			no_wa+= it.second;
		}
		if(it.first == "TLE")
		{
			no_tle+= it.second;
		}
		if(it.first == "RE")
		{
			no_re+= it.second;
		}
	}
	cout<<"AC "<<"x "<<no_ac<<"\n";
	cout<<"WA "<<"x "<<no_wa<<"\n";
	cout<<"TLE "<<"x "<<no_tle<<"\n";
	cout<<"RE "<<"x "<<no_re<<"\n";
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
    
    int i,j,a,b,c;
    cin >> a >> b >> c ;
    
    for(i = a ; i <= b ; i++){
        if((c%i) == 0){
            j = j + 1;
        }
    }
    
    cout << j << endl;
    
    
    
    
}


Measured memory_bytes: 3132
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import itertools
    
    mod=10**9+7
    N,M=MI()
    a=[0]*M
    b=[0]*M
    c=[]
    
    for i in range(M):
        a[i],b[i]=MI()
        cc=LI()
        for j in range(b[i]):
            cc[j]-=1
        c.append(cc)
        
    N2=pow(2,N)
    inf=10**10
    
    def encode(L):
        temp=0
        for i in range(len(L)):
            temp+=L[i]<<i
        return temp
            
    
    dp=[[inf]*N2 for _ in range(M+1)]
    # i番目の鍵までで状態jを達成できる最小値
    
    dp[0][0]=0
    for i in range(M):
        for ite in itertools.product([0,1], repeat=N):
            L=list(ite)
            j=encode(L)
            for k in c[i]:
                L[k]=1
            nj=encode(L)
            # print(i,ite,j,nj)
            if dp[i][j]!=inf:
                dp[i+1][j]=min(dp[i+1][j], dp[i][j])
                dp[i+1][nj]=min(dp[i+1][nj], dp[i][j]+a[i])
        
    ans=dp[-1][-1]
    if ans==inf:
        ans=-1
    print(ans)
    
    # for i in range(M+1):
    #     print(dp[i])
                
    

main()


Measured memory_bytes: 108100
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	string a,b,c;
	cin >> a >> b >> c;
	char win='n',turn=a[0],temp;
	a.erase(a.begin());
	while(win=='n'){
		if(turn=='a'){
			if(a.length()==0){
				win='A';
				break;
			}
			turn=a[0];
			a.erase(a.begin());
		}
		else if(turn=='b'){
			if(b.length()==0){
				win='B';
				break;
			}
			turn=b[0];
			b.erase(b.begin());
		}
		else if(turn=='c'){
			if(c.length()==0){
				win='C';
				break;
			}
			turn=c[0];
			c.erase(c.begin());
		}
	}
	cout << win << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
ll solve(ll n,ll x) {
	ll m=n/x-1; if(m<=0) return 0;
	if(x==n/m) return m;
	return 0;
}
int main() {
	ll n,ans=0; rd(n);
	for(ll i=1;i*i<=n;++i) if(n%i==0) {
		ans+=solve(n,i);
		if(i*i!=n) ans+=solve(n,n/i);
	}
	printf("%lld",ans);
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int M = s.nextInt();
		int[] H = new int[N];
		int[] A = new int[M];
		int[] B = new int[M];
		for(int i=0; i<N; i++) {
			H[i] = s.nextInt();
		}
		for(int i=0; i<M; i++) {
			A[i]=s.nextInt();
			B[i]=s.nextInt();
		}
		
		boolean[] N_baketu = new boolean[N];
		for(int i=0; i<N; i++) {N_baketu[i] = false;} //バケツの初期化
		int counter = 0;
		for(int i=0; i<M; i++) {
			if(H[A[i]-1] < H[B[i]-1] && !(N_baketu[A[i]-1])) {
				N_baketu[A[i]-1] =true; counter++;}
		
			else if(H[A[i]-1] > H[B[i]-1] && !(N_baketu[B[i]-1])) {
				N_baketu[B[i]-1] =true; counter++;}
			
			else if(H[A[i]-1] == H[B[i]-1] ){
				if(!(N_baketu[A[i]-1])) {N_baketu[A[i]-1] =true; counter++; }
				if(!(N_baketu[B[i]-1])) {N_baketu[B[i]-1] =true; counter++; }
	            }
			}
			
			

		System.out.println(N-counter);








   }

}


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

int main(){
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0;i < M;++i) {
		cin >> B[i];
	}
	vector<vector<int>> A(N, vector<int>(M));
	int count = 0;
	for (int i = 0;i < N;++i) {
		int x = C;
		for (int j = 0;j < M;++j) {
			cin >> A[i][j];
			x += A[i][j] * B[j];
		}
		if (x > 0)count++;
	}
	cout << count << endl;
}

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

int main(void) {
  int n;
  int tanku[]={5,7,5,7,7};
  while (true) {
    cin >> n;
    if (n==0) {
      break;
    }
    string a;
    vector<int> w(n);
    for (int i=0; i<n; i++) {
      cin >> a;
      w[i]=a.size();
    }
    for (int i=0; i<n; i++) {
      int sum=0;
      int k=0;
      bool flag=false;
      for (int j=i; j<n; j++) {
        sum+=w[j];
        if (sum>tanku[k]) {
          break;
        }
        if (sum==tanku[k]) {
          k++;
          sum=0;
        }
        if (k==5) {
          flag=true;
          break;
        }
      }
      if (flag) {
        cout<<i+1<<endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3192
//https://atcoder.jp/contests/abc121/tasks/abc121_c
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main() {
    int N, M;
    cin>>N>>M;
    vector<pair<int, int> > AB(N);
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        AB[i]=make_pair(a , b);
    }
    sort(AB.begin(), AB.end());

    int now=0;
    long long ans = 0;
    while (M>0)
    {   
        ans+=AB[now].first;
        AB[now].second--;
        if(AB[now].second==0)now++;
        M--;
    }
    

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

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
 
    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] in1 = new String[n];
        String[] in2 = new String[n];
        String tmp;
        int minj;
        boolean flg = true;
        
        for(int i=0; i < n; i++){
            in1[i] = sc.next();
            in2[i] = in1[i];
            //System.out.print(in1[i] + " ");
        }

        //BubbleSort
        for(int i = 0; i < n; i++){
            for(int j = n-1; j > i; j--){
                if(in1[j].charAt(1) < in1[j-1].charAt(1)){
                    tmp = in1[j];
                    in1[j] = in1[j-1];
                    in1[j-1] = tmp;
                }
            }
        }
        
        //for(int i = 0; i < n; i++){
          //  System.out.print(in1[i] + " ");
        //}
    
        //selection sort
        for(int i = 0; i < n; i++){
            minj = i;
            for(int j = i; j < n; j++){
                if(in2[j].charAt(1) < in2[minj].charAt(1)){
                    minj = j;
                }
            }
            tmp = in2[i];
            in2[i] = in2[minj];
            in2[minj] = tmp;
        }

        for(int i = 0; i < n; i++){
            if(i < (n-1)){
                System.out.print(in1[i] + " ");
            }else{
                System.out.println(in1[i]);
            }
        }
        System.out.println("Stable");
        
        for(int i = 0; i < n; i++){
            if(i < (n-1)){
                System.out.print(in2[i] + " ");
            }else{
                System.out.println(in2[i]);
            }
        }
        
        for(int i = 0; i < n; i++){
            if(in1[i] != in2[i]){
                flg = false;
            }
        }
        
        if(flg){
            System.out.println("Stable");
        }else{
            System.out.println("Not stable");
        }
   }
}


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

public class Main {

    /**
     * 会津大学オンラインジャッジシステムのうち、<br>
     * volume 0のList Of Top 3 Hillsの問題の解答です。
     *
     * @param args
     */
    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] inputData = new String[10];

        try {
            for(int i = 0; i < 10; i++) {
                inputData[i] = in.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
                return;
            }
        }

        int firstHill = 0;
        int secondHill = 0;
        int thirdHill = 0;
        int nowHill = 0;

        for (String nowHillStr : inputData) {
            nowHill = Integer.parseInt(nowHillStr);
            if (nowHill > firstHill) {
                thirdHill = secondHill;
                secondHill = firstHill;
                firstHill = nowHill;
            } else if(nowHill > secondHill) {
                thirdHill = secondHill;
                secondHill = nowHill;
            } else if(nowHill > thirdHill) {
                thirdHill = nowHill;
            }
        }

        System.out.println(firstHill);
        System.out.println(secondHill);
        System.out.println(thirdHill);
    }
}

Measured memory_bytes: 17052
unittest
{
	assert( [ "2 3", "7 9" ].solve == 4 );
	assert( [ "3 0", "3 4 5" ].solve == 5 );
	assert( [ "10 10", "158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202" ].solve == 292638192 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto as = input.front.split.to!( real[] );
	
	// 最小の長さを決め打ちして、それをK回の切断で達成できるかを二分探索
	auto f( real x )
	{
		auto t = 0L;
		foreach( a; as )
		{
			t += cast( long ) ceil( a / x ) - 1;
			if( k < t ) return false;
		}
		return true;
	}
	return cast( long ) ceil( bisect!f( 0.0L, as.reduce!max ) );
}

// 単調増加or減少関数の二分探索
auto bisect( alias pred )( real ng, real ok )
if( is( typeof( pred( ng ) ) : bool ) )
{
	foreach( i; 0 .. 200 )
	{
		auto x = ( ok + ng ) / 2;
		if( pred( x ) ) ok = x;
		else            ng = x;
	}
	return ok;
}


Measured memory_bytes: 13432
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int N=s.length();
        int mid=N/2;
        boolean flag=true;
        for(int i=0;i<=mid;i++){
            if(s.charAt(i)!=s.charAt(N-1-i)){
                flag=false;
                break;
            }
        }
        int mid1=mid/2;
        for(int i=0;flag && i<=mid1;i++){
            if(s.charAt(i)!=s.charAt(mid-1-i)) flag=false;
        }
        int mid2=mid/2+mid+1;
        for(int i=mid+1;flag && i<=mid2;i++){
            if(s.charAt(i)!=s.charAt(2*mid-i)) flag=false;
        }
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

using ll=long long;
using P=pair<ll,ll>;
#define mod 1000000007

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

ll modpow(ll n,ll m=mod-2){
  ll r=1;
  while(m) r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
  return r;
}

int main(){

  int n;
  cin >> n;

  map<P,P> mp;
  long long zero=0;
  ll sum = 1;

  for(int i=0;i<n;i++){
    ll a,b;
    cin >> a >> b;
    if(a==0 && b==0) zero++;
    else if(a==0){
      mp[{1,0}].first++;
    }else if(b==0){
      mp[{1,0}].second++;
    }else{
      ll g = gcd(a, b);
      a=a/g;
      b=b/g;
      if(mp[{b,-a}].first>0) mp[{b,-a}].second++;
      else if(mp[{-b,a}].first>0) mp[{-b,a}].second++;
      else mp[{a,b}].first++;
    }
  }

  for(auto p:mp){
    ll s = p.second.first%mod;
    ll t = p.second.second%mod;
    ll now = 1;
    now += modpow(2,s)-1;
    now += modpow(2,t)-1;
    sum *= now;
    sum = sum%mod;
  }

  cout << (sum+zero-1+mod)%mod << endl;

}

Measured memory_bytes: 50440
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265

int main()  
{     
    IOS;
    ll n;
    cin>>n;
    vector<ll>  v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];
    ll ans=1e18;
    for(ll i=-10000;i<=10000;i++)
    {
        ll tmp=0;
        for(ll j=0;j<n;j++)
            tmp+=(v[j]-i)*(v[j]-i);
        ans=min(ans,tmp);
    }
    cout<<ans;
}

Measured memory_bytes: 256
N = int(input()) #1行目のNを取得する
s = [list(input().split()) for i in range(N)] #複数行の数値の入力を取得

n_list = []
for i in range(N):
  if(s[i][0] == s[i][1]):
    n_list.append(1)
  elif(s[i][0] != s[i][1]):
    n_list.append(0)
    
ans = []
for i in range(N - 2):
  if(n_list[i] == 1 and n_list[i + 1] == 1 and n_list[i + 2] == 1):
    ans.append("Yes")
    break
  else:
    ans.append("No")
    
if "Yes" in ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9208
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n; cin>>n; int k; cin>>k; int h[n];
     for(int i=0;i<n;i++) cin>>h[i];


     int f[n];
     for(int i=0;i<n;i++) f[i]=0;

     f[0]=0;
     for(int i=1;i<n;i++)
     {
         int mini_mouse=INT_MAX;
         for(int j=1;j<=k;j++)
         {
             if(i-j>=0)
              mini_mouse=min(mini_mouse,f[i-j]+abs(h[i]-h[i-j]));
         }
       f[i]=mini_mouse;
     }
      cout<<f[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
bool skill_check(vector<int> &skill, int desire) {
    for (int s : skill) {
        if (s < desire) {
            return false;
        }
    }
    return true;
}

int main(void){
    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<int>> A(N, vector<int>(M, 0));
    vector<int> C(N, 0);
    for (int i = 0; i < N; i++)  {
        cin >> C.at(i);
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }
    
    
    int min_price = -1;
    for (int tmp = 0; tmp < (1 << N); tmp++) {
        int tmp_price = 0;
        vector<int> skill(M, 0);
        bitset<12> s(tmp);
        for (int i = 0; i < N; i ++) {
            if (s.test(i)) {
                tmp_price += C.at(i);
                transform(skill.begin(), skill.end(), A.at(i).begin(), skill.begin(), plus<int>());
            }
        }
        
        if (skill_check(skill, X) && (min_price > tmp_price || min_price == -1)) {
            min_price = tmp_price;
        }
    }
    
    cout << min_price << endl;
        
}


Measured memory_bytes: 3636
//
// Created by yamunaku on 2019/11/05.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    ll n;
    cin >> n;
    ll ans = LINF;
    for(int i=1;i<=sqrt(n)+1;i++){
        if(n%i==0){
            ans = min(ans,i+n/i);
        }
    }
    cout << ans-2 << endl;
    return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i,T x=1){
        for(i++;i<=n;i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++;i;i-= i&-i) {
            x += d[i];
        }
        return x;
    }
    // 下の2個の操作を使う時は上の2個の操作が使えない事に注意
    T getmax(int i){ // get max(d[i]) for i = 0,1,...,i-1,i
        T x = 0;
        for(i++;i;i-=i&-i) {
            x = max(x, d[i]);
        }
        return x;
    }
    void setmax(int i, int v){ // set d[i] = max(d[i], v)
        for(i++;i<=n;i+=i&-i){
            d[i] = max(d[i], v);
        }
    }
};

vector<int> pos(500005,-1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,q;
    cin >> n >> q;
    BIT<int> bit(500005);
    vector<int> c(n),ans(q);
    rep(i,n){
        cin >> c[i];
    }
    vector<tuple<int,int,int>> p;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        p.push_back({l,r,i});
    }
    sort(ALL(p),[](auto a,auto b){
        return get<1>(a) < get<1>(b);
    });
    int nowpos = 0;
    rep(i,q){
        int ret = 0;
        int l = get<0>(p[i]);
        int r = get<1>(p[i]);
        for(int j=nowpos;j<r;j++){
            int now = c[j];
            if(pos[now] == -1){
                pos[now] = j;
            }
            else {
                bit.add(pos[now]+1,-1);
                pos[now] = j;
                
            }
            bit.add(j+1,1);
        }
        nowpos = r;
        ans[get<2>(p[i])] = bit.sum(r) - bit.sum(l-1);
    }
    for(int i=0;i<q;i++)cout << ans[i] << endl;
}

Measured memory_bytes: 17532
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
double a[51];
priority_queue<double, vector<double>, greater<double> >pq;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pq.push(a[i]);
	}
	if(n==2)
	{
		cout<<(a[1]+a[2])/2.0;
		return 0;
	}
	n--;
	while(n--)
	{
		double t=pq.top();
		pq.pop();
		t+=pq.top();
		pq.pop();
		pq.push(t/2.0);
	}
	cout<<pq.top();
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    i = 0
    d = {"Vacant": 2, "Male": 0, "Female": 1}
    print(i)
    s = d[input()]
    if s == 2:
        return 0
    lower = 0
    upper = n - 1
    while True:
        mid=lower+(upper-lower)//2
        print(mid)
        s2 = d[input()]
        if s2 == 2:
            return 0
        if mid > i:
            if abs(mid - i) % 2 == (s != s2):
                lower = mid+1
            else:
                upper = mid
        else:
            if abs(mid - i) % 2 == (s != s2):
                upper = mid
            else:
                lower = mid+1
        i = mid
        s=s2
main()

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int mn[N][20],mx[N][20],n,k,a[N],lg2[N],st[N],tp=0;
bool vis[N];

int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) a[i]=mx[i][0]=mn[i][0]=gi();
	for(int i=2;i<=n;i++) lg2[i]=lg2[i>>1]+1;
	for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i+(1<<j)-1<=n;i++) {
			mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
			mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]);
		}
	int ans=0;
	for(int i=n;i;i--) {
		while(tp&&a[st[tp]]<a[i]) --tp;
		st[++tp]=i;
		if(!(tp>=k&&st[tp-k+1]==i+k-1)) vis[i]=1;
		else ans=1;
	}
	for(int i=1;i<=n-k+1;i++) if(vis[i]) ++ans;
	for(int i=1;i<=n-k;i++) {
		int l=i,r=i+k,p=lg2[r-l+1];
		if(!vis[l]||!vis[l+1]) continue;
		if(min(mn[l][p],mn[r-(1<<p)+1][p])==a[l]&&max(mx[l][p],mx[r-(1<<p)+1][p])==a[r]) --ans;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 34048
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
	string s;

	cin >> s;

	ll ans = 0;
	int n = s.length();

	for (int i = 0; i < (1 << (n - 1)); i++) {
		ll tmp = 0;
		for (int j = 0; j < n; j++)
		{
			tmp = tmp * 10 + (int)(s[j] - '0');
			if ((i >> j) & 1 || j == n - 1)
			{
				ans += tmp;
				tmp = 0;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>

int d,g;
int p[11],c[11];

int f(int k){
  int sum=0;
  int res=0;
  int t=-1;
  rep(i,d){
    if(k&(1<<i)){
      sum+=p[i]*100*(i+1);
      sum+=c[i];
      res+=p[i];
    }else{
      t=i;
    }
  }

  //cout<<k<<' '<<sum<<' '<<t<<endl;

  if(sum+p[t]*100*(t+1)<g) return INF;

  if(sum>=g) return res;

  return res+(g-sum+100*(t+1)-1)/(100*(t+1));

}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>d>>g;
  rep(i,d){
    cin>>p[i]>>c[i];
  }

  int ans=INF;

  rep(i,1<<d){
    ans=min(ans,f(i));
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x


using namespace std;

int main() {
    ll n;
    cin>>n; ll a[n+1];
    ll mn,ans=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0) mn=a[i];
        else
        {
            if(a[i]>=mn) mn=max(mn,a[i]);
            else ans+=(mn-a[i]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int> a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(), (a).end()

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

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

ll keta(ll n)
{
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind
{
public:
  vi Parent;
  UnionFind(int n)
  {
    Parent = vi(n, -1);
  }

  int root(int a)
  {
    if (Parent[a] < 0)
      return a;
    else
      return Parent[a] = root(Parent[a]);
  }

  int size(int a)
  {
    return -Parent[root(a)];
  }

  bool merge(int a, int b)
  {
    a = root(a);
    b = root(b);
    if (a == b)
      return false;

    if (size(a) < size(b))
      swap(a, b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial
{
public:
  vl Fac;
  Factrial(int MAX)
  {
    Fac = vl(MAX + 1);
    rep(i, MAX)
    {
      if (i == 0)
        Fac[i + 1] = 1;
      else
        Fac[i + 1] = ((i + 1) * Fac[i]) % MOD;
    }
  }
};


bool check(int X){
  for(int i = 2; i*i <= X; i++) {
    if(X%i == 0) return false;
  }
  return true;
}

int main(){
  int X; cin >> X;
  int ans;
  for(int i = X;; i++) {
    if(check(i)){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll pdiv = 1000000007LL;

// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n, 0));
    REP(i, n) REP(j, n) {
        cin >> a[i][j];
    }
    
    vector<ll> dp(1LL << n, 0);
    dp[0] = 1;
    REP(i, 1LL << n) {
        ll m = popcountll(i);
        if (m == n) continue;
        REP(f, n) {
            if (a[m][f] && !(i & (1LL << f))) {
                ll i2 = i | (1LL << f);
                dp[i2] += dp[i];
                while (dp[i2] >= pdiv) dp[i2] -= pdiv;
            }
        }
    }
    cout << dp[(1LL << n) - 1] << endl;

}

Measured memory_bytes: 16640