akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(m) { 0 }
    val b = Array(m) { 0 }
    val c = Array(m) { mutableListOf<Int>() }
    val mask = Array(m) { 0 }
    for (i in 0 until m) {
        a[i] = sc.nextInt()
        b[i] = sc.nextInt()
        var tmp = 0
        for (j in 0 until b[i]) {
            val x = sc.nextInt() - 1
            c[i].add(x)
            tmp += 1.shl(x)
        }
        mask[i] = tmp
    }
    val size = 1.shl(n)
    val dp = Array(m + 1) { Array(size) { Int.MAX_VALUE } }
    dp[0][0] = 0
    for (i in 0 until m) {
        for (j in 0 until size) {
            dp[i + 1][j] = dp[i][j]
        }
        for (j in 0 until size) {
            if (dp[i][j] != Int.MAX_VALUE) {
                dp[i + 1][j or mask[i]] = Math.min(dp[i + 1][j or mask[i]], dp[i][j] + a[i])
            }
        }
    }
    val v = dp[m][size - 1]
    println(if (v == Int.MAX_VALUE) -1 else v)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 153940
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    k = int(input())
    a, b = map(int, input().split())

    t = k
    while t <= 1000:
        if t >= a and t <= b:
            print('OK')
            return
        t += k
    print('NG')


main()


Measured memory_bytes: 61640
s = input()
n = len(s)


for i in range(n):
    # i回の操作でそれぞれのアルファベットについて
    # 全て同じ文字にできるかどうか
    table = [[0]*(n-i) for _ in range(26)]

    for j in range(n):
        x = s[j]
        x = ord(x)-ord('a')
        L = max(0, j-i)
        if table[x][L]:
            L += 1
        R = min(j+1, L+i+1, n-i)
        for k in range(L, R):
            table[x][k] = 1

    if any(0 not in row for row in table):
        print(i)
        break


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() {
    int d,t,s; 
    cin >> d >> t >> s;
    if(d % s != 0){
      if( t > d/s){
        cout <<  "Yes" <<  endl;
      }
      else if( t <= d/s){
        cout <<  "No" <<  endl;
      }
      else{
      }
    }
     else if(d % s == 0){
      if( t >= d/s){
        cout <<  "Yes" <<  endl;
      }
      else if( t < d/s){
        cout <<  "No" <<  endl;
      }
      else{
      }
    }
 
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	char ld = (char)('C'+n/1000);
//	cout<<ld;
	cout<<("AB")<<ld;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x3 = x2 + (-1) * (y2 - y1);
        int y3 = y2 + (x2 - x1);
        int x4 = x3 + (-1) * (x2 - x1);
        int y4 = y3 + (-1) * (y2 - y1);
        System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
        
    }
}


Measured memory_bytes: 23252
l = list(map(int, input().split()))

a = l[0]
b = l[1]
k = l[2]

if (a + (k-1)) >= (b - (k-1)):
	for i in range(a, b+1):
		print(i)
else:
	for j in range(k):
		print(a + j)
	for m in range(k):
		print(b - k + 1 + m)

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

int main () {
  int N;
  cin >> N;
  
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  
  vector<int> dp(100010);
  
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  for (int i = 0; i < N; i++) {
    dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]));
  }
  cout << dp[N-1] <<endl;
  return 0;
}

Measured memory_bytes: 1024
n,a=int(input()),sorted(list(map(int,input().split())))
m=a[-1]+1
s=[0]*m
for i in a:s[i]+=1
for i in set(a):
	if s[i]:
		for j in range(i*2,m,i):s[j]=0
print(s.count(1))

Measured memory_bytes: 40236
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
map<string,int> mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<ll> a(n),sum(n+1,0);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++)sum.at(i+1)=a.at(i)+sum.at(i);
vector<ll> tmp;
for(int i=1;i<n+1;i++){
    for(int j=0;j<i;j++){
        tmp.push_back(sum.at(i)-sum.at(j));
    }
}
ll ans;
for(ll bit=60;bit>=0;bit--){
    vector<ll> res;
    for(int i=0;i<tmp.size();i++){
        if(tmp.at(i)&(1ll<<bit))res.push_back(tmp.at(i));
    }
    if(res.size()>=k){
           tmp=res;
    }
}
ans=tmp.at(0);
for(int i=1;i<tmp.size();i++){
    ans&=tmp.at(i);
}
cout<<ans<<endl;
}


Measured memory_bytes: 6256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main(void) {
  int N,L;

  scanf("%d %d",&N,&L);
  int sum=0;
  int min=INT_MAX;
  int array[N+1];
  int idx=0;
  for (int i=1;i<=N;i++){
    array[i]=i-1+L;
    if (abs(array[i])<min) {min=abs(array[i]);
                            idx = i;           }
  }
  if (array[idx]<0) min=-min;
  for (int i=1;i<=N;i++){
   if (array[i]!=min)
    sum+=array[i];
  }
  printf("%d",sum);
 return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
using namespace std;
const int N=233333,MOD=998244353;
int n,k,l[N],r[N],tr[N<<2],dp[N];
void modify(int x,int val,int l,int r,int p){
	if(l==r){tr[p]+=val;return;}
	int mid=l+r>>1;
	if (x<=mid)modify(x,val,l,mid,ls(p));
	else modify(x,val,mid+1,r,rs(p));
	tr[p]=(tr[ls(p)]+tr[rs(p)])%MOD;
}
int getans(int ql,int qr,int l,int r,int p){
	if(ql<=l&&r<=qr)return tr[p];
	int mid=l+r>>1,ans=0;
	if(ql<=mid)ans=getans(ql,qr,l,mid,ls(p));
	if(qr>mid)ans=(ans+getans(ql,qr,mid+1,r,rs(p)))%MOD;
	return ans;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>k;
    for (int i=1;i<=k;i++)cin>>l[i]>>r[i];
    modify(1,dp[1]=1,1,n,1);
    for(int i=2;i<=n;modify(i,dp[i],1,n,1),i++)
    	for(int j=1;j<=k;j++)
    		if(i>l[j])dp[i]=(dp[i]+getans(max(1ll,i-r[j]),max(1ll,i-l[j]),1,n,1))%MOD;
    printf("%lld\n",dp[n]);
}

Measured memory_bytes: 9432
n, a, b, c = gets.split.map(&:to_i)
l = n.times.map {gets.to_i}

ans = 1 << 31
(4 ** n).times do |i|
    x = [0, 0, 0]
    sum = 0
    i = i.to_s(4).rjust(n, ?0)

    i.each_char.with_index do |j, k|
        j = j.to_i
        if j != 3
            x[j] += l[k]
            sum += 10
        end
    end

    next if x.include?(0)
    sum += (x[0] - a).abs + (x[1] - b).abs + (x[2] - c).abs - 30
    ans = sum if ans > sum
end

puts ans

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = begin(v); it != end(v); ++it) {
    if (it != begin(v)) os << " ";
    os << *it;
  }
  return os;
}

const string ln = "\n";
template <class T>
ostream &operator,(ostream &os, const T &v) { return os << " " << v; }
ostream &operator,(ostream &os, const string &s) {
  return (s == ln ? os << endl : os << " " << s);
}

// =============================================================================

int main() {
  cout << setprecision(12) << fixed << boolalpha;
  int N, M;
  cin >> N >> M;
  vector<int> a(N, 1);
  vector<int> b(N, 0);
  b[0] = 1;
  REP(i,M) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    --a[x];
    ++a[y];
    if (b[x]) b[y] = 1;
    if (a[x] == 0) b[x] = 0;
  }
  int sum = accumulate(ALL(b), 0);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/numeric>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0);

const int MAXN = 3003;
int n, T;
pair<int, int> arr[MAXN];
int memo[MAXN][MAXN];

int solve(int idx, int t) {
//    cout << idx << ' ' << t  << endl;
    if (idx == n || t >= T)
        return 0;
    int &ret = memo[idx][t];
    if (~ret)
        return ret;
    ret = solve(idx + 1, t);
    ret = max(ret, solve(idx + 1, t + arr[idx].first) + arr[idx].second);
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("friday.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

    int n;
    string s;
    cin >> n >> s;

    string str1;
    str1 = s.substr(0, (n + 1) / 2);
    string str2;
    str2 = s.substr((n + 1) / 2);

//    cout << str1 << ' ' << str2 << '\n';


    if (str1 == str2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

tot=A[0]
b=True
if (0 in A)==True:
    print(0)
    b=False
a=True
if b==True:
    for i in range(1,N):
        tot=tot*A[i]
        if tot>10**18:
            print(-1)
            a=False
            break
    if a==True:
        print(tot)


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


int main()
{
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	ll ans=0;
	rep(r,(N/R)+1)
	{
		rep(g,(N/G)+1)
		{
			if(r*R+g*G>N) continue;
			if((N-(r*R+g*G))%B==0) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    vector<int> h(0), w(0);
    for (int i=0; ; i++)
    {
        h.push_back(0);
        w.push_back(0);
        cin>>h[i]>>w[i];
        if (h[i]==0 && w[i]==0) break;
    }
    for (int i=0; i<h.size()-1; i++)
    {
        for (int j=0; j<h[i]; j++)
        {
            for (int k=0; k<w[i]; k++)
            {
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 2976
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun nextPermutation(array: MutableList<Int>): Boolean {
    var tmp = 0
    for (i in array.size-2 downTo 0) {
        if (array[i] < array[i+1]) {
            for (j in array.size-1 downTo i+1) {
                if (array[j] > array[i]) {
                    tmp = array[i]
                    array[i] = array[j]
                    array[j] = tmp

                    val tmpArray = array.takeLast(array.size-(i+1)).sorted()
                    tmpArray.forEachIndexed { index, e ->
                        array[i+1+index] = e
                    }

                    return true
                }
            }
        }
    }

    return false
}

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val adj = Array(n) { mutableSetOf<Int>() }
    for (i in 0 until m) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        adj[u].add(v)
        adj[v].add(u)
    }
    var p = (0 until n).toMutableList()
    var count = 0
    do {
        if (p[0] != 0) continue
        var ok = true
        for (i in 0 until n - 1) {
            if (!adj[p[i]].contains(p[i + 1])) {
                ok = false
                break
            }
        }
        if (ok) count++
    } while (nextPermutation(p))
    println(count)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 48412
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    h, w = intin()
    alistlist = []
    for i in range(h):
        alistlist.append(intina())

    anslist = []

    for i in range(h):
        for j in range(w):

            if i >= h - 1 and j >= w - 1:
                continue

            if alistlist[i][j] & 1:
                alistlist[i][j] -= 1
                dst_x = i+(j+1)//w
                dst_y = min(j+1, w-1)
                alistlist[dst_x][dst_y] += 1
                anslist.append((i+1, j+1, dst_x+1, dst_y+1))

    print(len(anslist))
    for ans in anslist:
        print('%d %d %d %d' % ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26684
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a1 := nextInt()
	max, min := a1, a1
	for i := 1; i < n; i++ {
		a := nextInt()
		if a > max {
			max = a
		} else if a < min {
			min = a
		}
	}
	fmt.Println(max - min)
}


Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    g[u - 1].append(v - 1)
    g[v - 1].append(u - 1)
from collections import defaultdict
import bisect
def dfs(u):
    ans = [-1]*n # 各最長増加部分列の長さ
    stack = [u] # u: 頂点
    operation = defaultdict(list) # 行った操作
    used = [False]*n # 1回目: False 2回目: True
    dp = [float("inf")]*n
    dp[0] = a[u]
    used[u] = False
    length = 1
    operation[0] = [0, float("inf"), 0]
    ans[0] = 1
    while stack:
        # print(dp)
        u = stack[-1]
        if used[u] == False:
            used[u] = True
            idx = bisect.bisect_left(dp, a[u])
            operation[u] = [idx, dp[idx], length]
            dp[idx] = a[u]
            length = max(length, idx + 1)
            ans[u] = length
            for i in g[u]:
                if ans[i] > 0:
                    continue
                stack.append(i)
        else:
            idx, value, length = operation[u]
            dp[idx] = value
            stack.pop()
    return ans, used, dp
ans, used, dp = dfs(0)
print(*ans, sep="\n")
# print(used, dp)
                
            

Measured memory_bytes: 173032
n = int(input())
import math as ms
dic = []
for i in range(1,ms.floor(ms.sqrt(n)) + 1):
    if n % i == 0:
        dic.append([i,n // i]) 
f = []
for i in range(len(dic)):
    a = ms.floor(ms.log10(dic[i][0])) + 1
    b = ms.floor(ms.log10(dic[i][1])) + 1
    f.append(max(a,b))
    
print(min(f))
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    string S; cin >> S;
    ll len = S.size();
    vector<string> result;
    vector<ll> lindex;
    ll li = 0;
    ll l = 0;
    REP (r, len-1) {
        li++;
        if (S[r] == 'L' && S[r+1] == 'R') {
            result.push_back(S.substr(l, r-l+1));
            l = r+1;
            li = 0;
        }
        if (S[r] == 'R' && S[r+1] == 'L') {
            if (li>0) lindex.push_back(li-1);
            else lindex.push_back(li);
        }
        if (r==len-2) {
            result.push_back(S.substr(l, r-l+2));
            li = 0;
        }
    }

    vector<ll> ans;
    ll el=0, er=0;
    for (ll gi=0; gi<result.size(); ++gi) {

        // cout << result[gi] << "("<<gi<<")" <<":";

        ll ri = lindex[gi];
        ll rsum = 0;
        ll lsum = 0;
        for (ll i=0; i<result[gi].size(); i++) {
            if ((ri-i)%2==0) rsum++;
            else lsum++;
        }
        for (ll i=0; i<result[gi].size(); i++) {
            if (i==ri) {
                ans.push_back(rsum);
            } else if (i==ri+1) {
                ans.push_back(lsum);
            } else {
                ans.push_back(0);
            }
        }
    }
    //for (ll gi=0; gi<result.size(); ++gi)
    //    cout << lindex[gi] << ":";
    //cout << endl;

    for (ll i = 0; i<ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << '\n';

    return 0;
}




Measured memory_bytes: 4672
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define MOD 1000000007
#define INF MOD
#define ALL(x) std::begin(x), std::end(x)


class node_t {
public:
  node_t(int dd = -INF, int nn = 0) : d(dd), n(nn) {};

public:
  bool operator>(const node_t& x) const {
    if (d > x.d)
      return true;

    return n > x.n;
  };

public:
  int d;
  int n;
};

const int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};


node_t dp[11111];


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, a[11];

  std::cin >> N >> M;

  for (int i = 0; i < M; i ++)
    std::cin >> a[i];

  dp[0] = node_t(0, 0);

  for (int i = 0; i < N + 11; i ++) {
    if (dp[i].d < 0)
      continue;

    for (int j = 0; j < M; j ++) {
      node_t n(dp[i].d + 1, a[j]);

      int c = i + cost[a[j]];

      if (n > dp[c])
        dp[c] = n;
    }
  }

  assert(dp[N].d >= 0);

  std::string s;

  for (int i = N; i > 0; ) {
    s.push_back(dp[i].n + '0');
    
    i -= cost[dp[i].n];
  }

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 384
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

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


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    cout<<(1000-(n%1000))%1000<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);
	
	int N;
	cin >> N;
	int F[100][10],P[100][11];
	for(int i=0; i<N; i++){
		for(int j=0; j<10; j++){
			cin >> F[i][j];
		}
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<11; j++){
			cin >> P[i][j];
		}
	}
	
	int ans = INT_MIN;
	for(int i=1; i<(1<<10); i++){
		int tmp = 0;
		for(int j=0; j<N; j++){
			int c = 0;
			for(int k=0; k<10; k++){
				if((i>>k)%2 == 1 && F[j][k] == 1) c++;
			}
			tmp += P[j][c];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
AB_list = [list(map(int, input().split())) for _ in range(N)]
AB_list = sorted(AB_list, key=lambda x: x[0])

sum_cost = 0
n_drink = 0
for AB in AB_list:
    A, B = AB
    if n_drink + B < M:
        n_drink += B
        sum_cost += A * B
    elif n_drink + B >= M:
        sum_cost += A * (M - n_drink)
        print(sum_cost)
        exit()

Measured memory_bytes: 29796
//#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
vector<pair<int, int>> v;

int main(){
	int n,m; cin >> n >> m;
	priority_queue<int> que;
	FOR(i,1,n){
		int a,b; cin >> a >> b;
		v.push_back(MP(a,b));
	}
	sort(ALL(v));
	int cur = 0;
	ll ans = 0;

	FOR(i,1,m){
		while(v[cur].first<=i && cur <= n-1){
			que.push(v[cur].second);
			cur++;
		}
		if(!que.empty()){
			ans += que.top(); que.pop();
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1908
import java.util.*;

public class Main {

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

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        List<Integer> prices = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            prices.add(scanner.nextInt());
        }

        Collections.sort(prices);
        int sum = 0;
        for (int i = 0; i < k; i++) {
            sum += prices.get(i);
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 39412
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=0;
        int mx=(int)1e6+1;
        int arr[]=new int[mx];
        Arrays.fill(arr,0);
        for(int i=1;i*i<mx;i++)
        {
            for(int j=i*i;j<mx;j+=i)
            {
                arr[j]+=2;
                if(j/i==i)
                arr[j]--;
            }
        }
        for(int i=1;i<=n-1;i++)
        ans+=arr[i];
        System.out.println(ans);
    }
}

Measured memory_bytes: 39672
macro_rules! input {
    ( $( $var:ident : $t:tt ),* ) => {
        use std::io::{stdin, Read};
        let mut bytes = stdin().bytes();
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        $(let $var = read_value!(next, $t);)*
    };

    ( $( $var:ident : $t:tt ),+ ,) => {
        input!{ $($var : $t),* }
    };
}

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

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

fn main() {
    input! {
        n: u32
    };

    println!("{}", ((n + 1) / 2) as f32 / (n as f32));
}

Measured memory_bytes: 4352
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += Ai[i]
  else:
    Bob += Ai[i]
print(Alice - Bob)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		HashMap<String , Integer> hm = new HashMap<>();
		hm.put("AC", 0);
		hm.put("WA", 0);
		hm.put("TLE", 0);
		hm.put("RE", 0);
		while(n-->0) {
			String input = sc.next();
			hm.put(input, hm.get(input)+1);
		}
		
//		for(Map.Entry<String, Integer> entry:hm.entrySet()) {
			System.out.println("AC x " +hm.get("AC"));
			System.out.println("WA x " +hm.get("WA"));
			System.out.println("TLE x " +hm.get("TLE"));
			System.out.println("RE x " +hm.get("RE"));

			
//		}
	}

}


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

int main()
{
    int n;
    cin >> n;
    double p;
    if (n == 1) {
        p = 1.0;
    }
    else if ((n%2) == 0) {
       p = 0.5;
    }
    else {
        int m = n/2 + 1;
        p = double(m)/n;
    }
    cout << p << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np

n = int(stdin.readline().rstrip())
    
li = list(map(int,stdin.readline().rstrip().split()))
lin = list(map(int,stdin.readline().rstrip().split()))
ma = 0
for i in range(n):
    ma = max(sum(li[:i+1]+lin[i:]),ma)

print(ma)

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> v(m);
  for(int i=0;i<m;i++){
    cin >> v.at(i);}
  
  int sum = 0;
  for(int i=0;i<m;i++){
    sum += v.at(i);}
  if(n-sum>=0){cout << n -sum << endl;}
  else{cout << -1 << endl;}
  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a;scanf("%d",&a);
	int x=0;
	int y=0;
	int t=0;
	for(int i=0;i<a;i++){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		if(ABS(q-x)+ABS(r-y)>p-t||(ABS(q-x)+ABS(r-y))%2!=(p-t)%2){
			printf("No\n");return 0;
		}
		x=q;y=r;t=p;
	}
	printf("Yes\n");
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int n;
vector<int> f;
vector<vector<long>> p;

long eval(int x){
    long e=0;
    for(int i=0;i<n;i++){
        int _e=f[i]&x;
        int count=0;
        while(_e>0){
            if(_e%2==1){
                count++;
            }
            _e/=2;
        }
        e+=p[i][count];
    }
    return e;
}

long search(){
    long max=eval(1);
    for(int i=2;i<(1<<10);i++){
        max=std::max(max,eval(i));
    }
    return max;
}

int main(){
    cin >> n;
    f=vector<int>(n);
    for(int i=0;i<n;i++){
        int _f=0;
        for(int j=0;j<10;j++){
            int x;
            cin >> x;
            _f=_f*2+x;
        }
        f[i]=_f;
    }

    p=vector<vector<long>>(n,vector<long>(11));
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin >> p[i][j];
        }
    }

    int result=search();

    cout << result << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;
    int ans = 0;
    
    rep(i, n) {
        if (p[i] != i) {
            continue;
        }
        
        if (i == (n - 1)) {
            p[i] = p[i - 1];
            p[i - 1] = i;
            ans++;
            continue;
        }
        
        p[i] = p[i + 1];
        p[i + 1] = i;
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"d={i:list(input())for i in'abc'};i='a'\n"
"while d[i]:i=d[i].pop(0)\n"
"print(i.upper())\n"
"\"";
  system(s);
  return 0;
}            

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

int main() {
	int n, a, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a;
		if ((i&1) && (a&1)) ans ++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int n;
int l[maxn];
int r[maxn];
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    n = readint();
    repd(i, 1, n)
    {
        l[i] = readint();
        r[i] = readint();
    }
    sort(l + 1, l + 1 + n);
    sort(r + 1, r + 1 + n);
    int L, R;
    if (n & 1)
    {
        L = l[(n + 1) >> 1];
        R = r[(n + 1) >> 1];
    } else
    {
        L = l[(n) >> 1] + l[((n) >> 1) + 1];
        R = r[(n) >> 1] + r[((n) >> 1) + 1];
    }
    printf("%d\n", R - L + 1 );
    return 0;
}




Measured memory_bytes: 5264
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
struct rect {
	int height, pos;
};
int main() {
	int n;
	cin >> n;
	vi list(n);
	rep(i, 0, n)cin >> list[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int num = list[i];
		if (num < 2)continue;
		if (num == 2) {
			ans++;
		}
		else {
			bool f = false;
			for (int j = 2; j <= sqrt(num); j++)
			{
				if (num%j==0) {
					f = true;
				}
			}
			if (!f)ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String tmp = scan.nextLine();
		System.out.println(CaseReverse(tmp));
		// int length = tmp.split(",").length;
		// for (int i = 0; i < length; i++) {
			// System.out.print(CaseReverse(tmp.split(",")[i]));
			// if(i != length - 1){
			// 	System.out.print(".");
			// }else{
				// System.out.print(",");
			// }
		// }
	}

	static String CaseReverse(String s) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (Character.isUpperCase(c)) {
				c += 32;
				sb.append(c);
			} else if(Character.isLowerCase(c)) {
				c -= 32;
				sb.append(c);
			} else {
				sb.append(c);
			}
		}
		return sb.toString();
	}
}



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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
  
using namespace std;                           

int a, b, c;

int main(){
	cin >> a >> b >> c;
	if( a + b + c < 22){
		cout << "win";
	}
	else {
		cout << "bust";
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main() {
        int h, w;

        while(true) {
                cin >> h >> w;
                if(h == 0 && w == 0) break;
                for(int i = 0; i < h; i++) {
                        for(int n = 0; n < w; n++) {
                                printf("#");
                        }
                        cout << endl;
                }
                cout << endl;
        }

        return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  Int ans=0;
  for(Int i=1;i<n;i++) ans+=as[i-1]<as[i];
  cout<<ans<<endl;
  return 0;
}



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int dp[100010];

signed main()
{
  int n; cin>>n;
  dp[0]=0;
  for(int i=1; i<=n; i++){
    dp[i]=INF;
    int power=1;
    while(power <= i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power *= 6;
    }
    power=1;
    while(power <= i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power *= 9;
    }
  }
  cout<<dp[n]<<endl;
}


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

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<char> ans;
  while (true) {
    --n;
    ans.emplace_back(n % 26 + 'a');
    n /= 26;
    if (n == 0) break;
  }
  for (auto iter = ans.rbegin(); iter != ans.rend(); ++iter) {
    std::cout << *iter;
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3564
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]


def main():
    def cmb(n, r, MOD):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % MOD

    N = 10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % MOD )
        inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
        g2.append( (g2[-1] * inverse[-1]) % MOD )

    x, y = LI()
    if (x + y) % 3 != 0:
        print(0)
        return

    sum_ = (x + y) // 3
    tmp_x = 2 * sum_
    if sum_ > x or sum_ > y:
        print(0)
        return

    if tmp_x > x:
        c_y = tmp_x - x
        c_x = sum_ - c_y
    else:
        c_y = -(tmp_x - x)
        c_x = sum_ - c_y

    print(cmb(sum_, c_x, MOD))


if __name__ == '__main__':
    main()

Measured memory_bytes: 128012
#include <cstdio>
#include <cmath>
using namespace std;
long long n;
double ans;
int main() {
	scanf("%lld", &n);
	for (long long i = sqrt(n); i; i--) {
		if (n % i == 0) {
			ans = n / i;
			break;
		}
	}
	printf("%d\n", (int)(log10(ans) + 1));
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
#define ll long long int 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define f first
#define s second

const ll mod = 1000000007;
const ll N = 1e6;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,k;cin >>k >> a >> b;
	for(int i = a; i <= b ; i++){
		if(i%k==0){
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
 	return 0;
}

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

#define N 200005
#define maxN 1000000007
#define PI 3.14159265358979
#define bb __builtin_popcount
#define ll long long
int x, y, m, n;
int a[N], b[N];
void solve() {
    cin >> m >> n >> x >> y;
    for (int i = 1; i <= m; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    bool ans = false;
    for (int k = x; k <= y; k++) {
        if (x < k && k <= y) {
            bool p = true;
            for (int i = 1; i <= m; i++)
                if (a[i] >= k) p = false;
            for (int i = 1; i <= n; i++)
                if (b[i] < k) p = false;
            if (p) {
                ans = true;
                break;
            }
        }
    }
    if (ans) cout << "No War";
    else cout << "War";
}
int main() {
    //freopen("main1.in", "r", stdin);
    //freopen("main.in", "w", stdout);
    //freopen("main.out", "w", stdout);
    solve();
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}
///Hamita


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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << a.at(0) << b.at(0) << c.at(0) << endl;  
  return 0;
}


Measured memory_bytes: 256