akhauriyash/Code-Regression huggingface dataset:
# abc114_b.py
# https://atcoder.jp/contests/abc114/tasks/abc114_b

# B - 754 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 数字 1, 2, ..., 9 からなる文字列 S があります。 
# ダックスフンドのルンルンは、S から連続する 3 個の数字を取り出し、 1 つの整数 Xとしてご主人様の元に持っていきます。
# （数字の順番を変えることはできません。）
# ご主人様が大好きな数は 753で、これに近い数ほど好きです。 X と 753の差（の絶対値）は最小でいくつになるでしょうか？

# 制約
#     Sは長さ 4 以上 10以下の文字列である。
#     Sの各文字は 1, 2, ..., 9 のいずれかである。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Xと 753の差としてありうる最小値を出力せよ。

# 入力例 1
# 1234567876

# 出力例 1
# 34

# 7文字目から 9 文字目までを取り出すと X=787 となり、これと 753 との差は 787−753=34 です。
# Xをどこから取り出しても、差をより小さくすることはできません。
# なお、数字の順番を変えることはできません。例えば、567 を取り出して 765 に並び変えてはいけません。
# また、Sから連続していない 3 文字を取り出すこともできません。
# 例えば、7 文字目の 7、9 文字目の 7 と 10文字目の 6 を取り出して 776 としてはいけません。

# 入力例 2
# 35753

# 出力例 2
# 0

# 753 そのものを取り出すことができる場合、答えは 0です。

# 入力例 3
# 1111111111

# 出力例 3
# 642

# どこから 3文字を取り出しても X=111 となり、差は 753−111=642 です。


def calculation(lines):
    X = lines[0]
    # X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))

    dif = None

    for i in range(len(X)-2):
        tmp = abs(int(X[i:i+3]) - 753)
        # print(f'tmp=[{tmp}]')
        # print(f'dif=[{dif}]')
        if dif is None:
            dif = tmp
        elif dif > tmp:
            dif = tmp

    return [dif]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1234567876']
        lines_export = [34]
    if pattern == 2:
        lines_input = ['35753']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['1111111111']
        lines_export = [642]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
#include <iostream>
// #include <algorithm>
// #include <set>
// #include <map>
using namespace std;

int main()
{
  // 整数の入力
  int A, B;
  cin >> A >> B;

  int count = 0;
  for (int i = 0; i < 2; i++)
  {
    if (A > B)
    {
      count += A--;
    }
    else
    {
      count += B--;
    }
  }
  cout << count;

  // cin >> a;
  // N分、入力を取る
  // int N;
  // cin >> N;
  // int d[100];
  // for (int i = 0; i < N; i++) cin >> d[i];
  // スペース区切りの整数の入力
  // int b, c;
  // cin >> b >> c;
  // 文字列の入力
  // string s;
  // cin >> s;
  // 出力
  // cout << (a + b + c) << " " << s << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author apurba_debnath
 */

#include <bits/stdc++.h>

#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl

using namespace std;

class BMultipleOf9 {
public:
    bool divisible_by_9(string &s) {
        ll len = s.length();
        ll sum = 0;
        for (ll i = 0; i < len; ++i) {
            sum += s[i] - '0';
        }
        return sum % 9 == 0;
    }

    void solve(std::istream &in, std::ostream &out) {
        string s;
        in >> s;
        if (divisible_by_9(s))
            out << "Yes";
        else
            out << "No";
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    BMultipleOf9 solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);

    return 0;
}


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

using namespace std;

int main()
{
    int n,i,j;
    cin >> n;
    vector<string> s(n);
    for (i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    
    sort(s.begin(),s.end());

    int ans = 1;
    for (i = 0; i < n - 1; i++)
    {
        if(s[i] != s[i + 1])ans++;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 9612
N = int(input())
a = input()
inp = a.split()
inp = [int(i) for i in inp]

cnt = 0

for index, now in enumerate(inp):
	flag = 0
	for j in range(index):
		#注目の山より西の山の方が高い場合フラグを1にする
		if inp[j] > now:
			flag = 1
	#すべての西の山が低い場合カウントを増やす
	if flag == 0:
		cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	long long int h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
		return 0;
	}
	long long int w1 = w / 2 + w % 2, w2 = w / 2;
	cout << h / 2 * w1 + h / 2 * w2 + h % 2 * w1 << endl;
}









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

const int INF = numeric_limits<int>::max();

struct Graph {
    enum Color {WHITE, GRAY, BLACK};
    vector<vector<int>> cost;
    vector<Color> color;
    vector<int> mincost;
    Graph(int n) {
        cost.assign(n, vector<int>(n, INF));
        color.assign(n, WHITE);
        mincost.assign(n, INF);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> g.cost[i][j];
            g.cost[i][j] = g.cost[i][j] == -1 ? INF : g.cost[i][j];
        }
    }
    
    int ans = 0;

    // Prim
    g.mincost[0] = 0;
    while (true) {
        int u = -1;
        for (int v = 0; v < n; v++) {
            if (g.color[v] == Graph::WHITE && (u == -1 || g.mincost[v] < g.mincost[u])) {
                u = v;
            }
        }
        if (u == -1) break;
        g.color[u] = Graph::BLACK;
        ans += g.mincost[u];
        for (int v = 0; v < n; v++) {
            g.mincost[v] = min(g.mincost[v], g.cost[u][v]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3164
# coding: utf-8
# 整数の入力
#a = int(raw_input())
# スペース区切りの整数の入力
import numpy as np
import itertools

A, B, C = raw_input().split()
if (A[len(A) - 1] == B[0] and B[len(B)-1] == C[0]):
    print "YES"
else:
    print "NO"


Measured memory_bytes: 19396
N,A,B,C,D = map(int,input().split())
ans = False
E = abs(B-A)
for i in range(N):
    j = N-1-i
    m = C*i - D*j
    M = D*i - C*j
    ans = m<=E<=M
    if ans:break
print("YES" if ans else "NO")

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

using namespace std;

const int INF = 1 << 28;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W;
  cin >> H >> W;
  vector<vector<int>> C(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> C[i][j];
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int a;
      cin >> a;
      res += a == -1 ? 0 : C[a][1];
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n)	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;

ll v[100100];

int main(){
    fastio;
    ll n, k;
    cin >> n >> k;
    fr(i,n){
        ll a, b;
        cin >> a >> b;
        v[a] += b;
    }
    ll soma = 0;
    frr(i,100100 - 1){
        soma += v[i];
        if(soma >= k){
            cout << i << endl;
            break;
        }
    }
    
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
par = list(range(n))


def find(x):
    while par[x] != x:
        par[x] = par[par[x]]
        x = par[x]
    return x


def union(x, y):
    x1 = find(x)
    y1 = find(y)
    if x1 != y1:
        par[x1] = y1


for j in range(m):
    a, b = map(int, input().split())
    union(a - 1, b - 1)

s = [0 for i in range(n + 1)]

for k in range(n):
    s[find(k)] += 1


print(max(s))


Measured memory_bytes: 18420
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    long x=1;
    long y=pow(10,9)+7;
    for(int i=1;i<=n;i++){
        x=x*i;
        x=x%y;
    }
    
    cout <<x <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<queue>
#include<map>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);

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

map<ll, ll> prime_factor(ll n){
    map<ll, ll> res;
    for (ll i = 0; i * i <= n; i++){
        while (n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

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

int main(){
    ll n, ans, tmp1, tmp2; sc(n)
    string s;
    ans = 20;
    vector<ll> vec = divisor(n);
    for (int i = 0; i < vec.size(); i++){
        tmp1 = to_string(vec[i]).size();
        tmp2 = to_string(n / vec[i]).size();
        tmp1 = max(tmp1, tmp2);
        ans = min(ans, tmp1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, A[100];

void Out() {
	cout << A[0];
	for (int i = 1; i < N; i++)
		cout << ' ' << A[i];
	cout << endl;
}

void InsertionSort() {
	for (int i = 1; i < N; i++) {
		int v = A[i], j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		Out();
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	Out();
	InsertionSort();
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define ll long long
using namespace std;


int main() {
    int N;
    cin>>N;
    int d1=N/100;
    int d2=(N/10)%10;
    int d3=N%10;
    if (d1==d3) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, m, k := io.NextInt(), io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	b := io.NextInts(m)
	// ans := solve(k, a, b)
	ans := solve2(k, a, b)
	io.Println(ans)
}

// O(n log m)

// O(n+m): two pointers (尺取法)
func solve2(k int, a, b []int) (maxCount int) {
	sum, j := 0, 0
	for j < len(b) && sum+b[j] <= k {
		sum += b[j]
		j++
	}
	j--
	maxCount = j + 1
	for i := 0; i < len(a); i++ {
		sum += a[i]
		for j >= 0 && sum > k {
			sum -= b[j]
			j--
		}
		if sum > k {
			break
		}
		count := i + j + 2
		if count > maxCount {
			maxCount = count
		}
	}
	return maxCount
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 28936
def main():
    n = int(input())
    hList = list(map(int,input().split()))

    if n == 1:
        print('0')
        return

    point = 1
    score = 0
    maxScore = 0

    while(point < n):
        if hList[point] <= hList[point-1]:
            score += 1
        else:
            score = 0
        if score > maxScore:
            maxScore = score
        point += 1
    
    print(maxScore)

main()

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

class Program
{
    static void Main(string[] args)
    {
        var Ns = sc.ReadIntArray(4);
        var ok = Ns.Contains(1) && Ns.Contains(9) && Ns.Contains(7) && Ns.Contains(4);
        Console.WriteLine(ok ? "YES" : "NO");
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 13268
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        HashMap<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long x = in.nextLong();
            if (map.get(x) != null) {
                map.put(x, map.get(x) + 1);
            } else map.put(x, 1);
        }
        ArrayList<Long> v = new ArrayList<>();
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            if (entry.getValue() >= 4) {
                v.add(entry.getKey());
                v.add(entry.getKey());
            }
            else if (entry.getValue() > 1) {
                v.add(entry.getKey());
            }
        }
        if (v.size() > 1) {
            Collections.sort(v);
            out.println(v.get(v.size() - 1) * v.get(v.size() - 2));
        }
        else out.println(0);
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 43116
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
a = LI()
b = [a[i] for i in range(n)]
ans = 0
k = a[0]
if a[0] == 0:
    a[0] = 1
    ans = 1
    k = 1
for i in range(1,n):
    if k*(k+a[i]) >= 0:
        if k < 0:
            ans += abs(1-k-a[i])
            a[i] = 1-k
            k = 1
        else:
            ans += abs(-1-k-a[i])
            a[i] = -1-k
            k = -1
    else:
        k += a[i]
if b[0] >= 0:
    ans2 = b[0]+1
    k = -1
    b[0] = -1
else:
    ans2 = 1-b[0]
    k = 1
    b[0] = 1
for i in range(1,n):
    if k*(k+b[i]) >= 0:
        if k < 0:
            ans2 += abs(1-k-b[i])
            b[i] = 1-k
            k = 1
        else:
            ans2 += abs(-1-k-b[i])
            b[i] = -1-k
            k = -1
    else:
        k += b[i]
print(min(ans,ans2))

#D
"""
x,y = LI()
if abs(x-y) <= 1:
    print("Brown")
else:
    print("Alice")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 60116
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    int n;
    cin >> n;
    int64 ans = 0;
    for (int num = 1; num <= n; num++) {
        if (num % 3 != 0 && num % 5 != 0) {
            ans += num;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
//メモ化で
ll dp[(ll)1e6+10]={-1};
int main() {
    ll h;
    cin>>h;
    ll n=h,i=0;
    vector<ll> v,ans;
    v.push_back(n);
    ans.push_back(1);
    while(n!=1){
        n=floor((double)n/2);
        v.push_back(n);
        ans.push_back(1);
    }
    REP(i,v.size()-1){
        ans[ans.size()-i-2]=1+2*ans[ans.size()-i-1];
    }
    cout<<ans[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    if (k == 1) {
        cout << "0\n";
    }
    else {
        cout << n - k << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  for(;;) {
    int a, b = 0;
    scanf("%d%d", &a, &b);

    if (!(a >= 1 && b <= 10000)) {
      printf("Invalid value: a=%d, b=%d\n",a ,b);
      printf("a >= 1, b <= 10,000 is valid.\n");
      continue;
    }

    if(((a * b) % 2) == 0) {
      printf("Even\n");
    } else {
      printf("Odd\n");
    }
    break;
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans[4][n];
    int o[4][3] = {{1,1, 1},{0,1,0}, {1,0,0}, {0,0,1}};
    int x[4][3] = {{1,1, 0},{0,1,1}, {1,0,1}, {0,0,0}};
    if(s[0]=='o'){
        REP(i,4){
            ans[i][0] = o[i][1];
            ans[i][1] = o[i][2];
            ans[i][n-1] = o[i][0];
        }
    }else{
        REP(i,4){
            ans[i][0] = x[i][1];
            ans[i][1] = x[i][2];
            ans[i][n-1] = x[i][0];
        }

    }
    
    FOR(i,1,n-2){
        if(s[i]=='o'){
            REP(j,4){
                if(ans[j][i-1]* 2 + ans[j][i] == 3){
                    ans[j][i+1] =  1;
                }else if(ans[j][i-1]* 2 + ans[j][i] == 1){
                    ans[j][i+1] =  0;
                }else if(ans[j][i-1]* 2 + ans[j][i] == 2){
                    ans[j][i+1] =  0;
                }else{
                    ans[j][i+1] =  1;
                }
            }
        }else{
            REP(j,4){
                if(ans[j][i-1]* 2 + ans[j][i] == 3){
                    ans[j][i+1] =  0;
                }else if(ans[j][i-1]* 2 + ans[j][i] == 1){
                    ans[j][i+1] =  1;
                }else if(ans[j][i-1]* 2 + ans[j][i] == 2){
                    ans[j][i+1] =  1;
                }else{
                    ans[j][i+1] =  0;
                }
            }
        }
    }
    bool ok[4][2];
    REP(i,4){
        REP(j,2){
            ok[i][j] = false;
        }
    }
    REP(t,2){
        REP(i,4){
            if(s[n-2+t] == 'o'){
                REP(j,4){
                    int count = 0;
                    REP(k,3){
                        if(ans[i][(n-3+k+t)%n] == o[j][k]) count++;
                    }
                    if (count == 3){
                        ok[i][t] = true;
                    }
                }
            }else{
                REP(j,4){
                    int count = 0;
                    REP(k,3){
                        if(ans[i][(n-3+k+t)%n] == x[j][k]) count++;
                    }
                    if (count == 3){
                        ok[i][t] = true;
                    }
                }
            }
        }
    }
    bool printed = false;
    REP(i,4){
        if(ok[i][0] && ok[i][1]){
            REP(k,n){
                if(ans[i][k] == 1){
                    cout << 'S';
                }else{
                    cout << 'W';
                }

            }
            cout << endl;
            printed = true;
            break;
        }
    }
    if(!printed){
        cout << -1 << endl;
    }


}

Measured memory_bytes: 2176
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 200009;

int n;
int a[N], b[N];

int main()
{
  cin >> n;
  int x = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    x ^= a[i];
  }
  for(int i = 0; i < n; i++)
    cout << (x ^ a[i]) << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 4384
mod = 10 ** 9 + 7
inf = float("inf")

s = list(input())
n = len(s)

dp = [[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    c = inf
    if s[i] == "?":
        c = -1
    else:
        c = ord(s[i]) - ord('0')
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    for j in range(13):
        dp[i + 1][j] %= mod
        
print(dp[n][5])

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int n;
    cin >> n;
    int sum = 0;

    rep1(i, n + 1)
    {
        int s = n / i;
        sum += i * (s * (s + 1) / 2);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}

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

	map<int, int> attendanceNums;

	for (int i = 1; i <= N; i++)
	{
		int ai;
		cin >> ai;
		attendanceNums[ai] = i;
	}

	int i = 1;
	for (auto const& entry : attendanceNums)
	{
		if (i == N)
		{
			cout << entry.second << endl;
		}
		else
		{
			cout << entry.second << " ";
		}
		i++;
	}
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x + r <= W) {
		if (y - r >= 0 && y + r <= H)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 3092
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

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

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

#define MAXN ((int)15+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,m,x;
int ans = INF;
int d[MAXN][MAXN];
int c[MAXN];

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i)
	{
		cin >> c[i];
		for (int j = 0; j < m; ++j)
			cin >> d[i][j];
	}

	for (int i = 1; i < (1<<n); ++i)
	{
		int total[13] = {0};
		int cost = 0;
		for (int j = 0; j < n; ++j)
			if((i & (1<<j)))
			{
				cost += c[j];
				for (int k = 0; k < m; ++k)
					total[k] += d[j][k];
			}
		bool ok = true;
		for (int k = 0; k < m; ++k)
			if(total[k] < x)
			{
				ok = false;
				break;
			}

		if(ok)
			ans = min(ans, cost);
	}
	if(ans == INF)
		ans = -1;
	
	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

int main()
{
    string S;
    cin >> S;
    bool b = S[0] != S[1];
    b = b && S[1] != S[2];
    b = b && S[2] != S[3];
    cout << (b ? "Good"s : "Bad"s) << endl;
}


Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n; cin>>n;

    int ans = n/500;
    n = n%500;
    ans = 1000*ans + (n/5)*5;
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    char a[100005];
    int n,j,i;
    while(~scanf("%s",a)){
        n=strlen(a);i=0;
        while(i<n){
            if(a[i]=='d'&&a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m'){
                if(a[i+5]=='e'&&a[i+6]=='r'&&(a[i+7]=='e'||a[i+7]=='d'||a[i+7]=='\0')){
                    i=i+7;
                }
                else{
                    i=i+5;
                }
            }
            else if(a[i]=='e'&&a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e'){
                if(a[i+5]=='r'){
                    i=i+6;
                }
                else{
                    i=i+5;
                }
            }
            else{
                break;
            }
        }
        if(i>=n){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//???a???¨?b???????????¢?????¢???????±???????????????°??????
public class Main{


	public static void main(String[] args){

		//?¨??????\???
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();

		System.out.println(area(a,b)+" "+circuit(a,b));


	}

	//????????¢?????¢???????±?????????????????????????
	private static int area(int a, int b){
		return a*b;
	}
	private static int circuit(int a, int b){
		return 2*a+2*b;
	}


}

Measured memory_bytes: 26152
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";

	static void solve()
	{
		int n = ni();

		int[] a = new int[n];
		int[] b = new int[n];

		long ans = 0;
		long t;

		for(int i=0; i<n; i++){
			a[i] = ni();
			b[i] = ni();
		}

		for(int i=n-1; i>=0; i--){
			t = a[i] + ans;
			if(t % b[i] == 0) continue;
			ans += b[i] - t % b[i];
		}

		System.out.println(ans);
	}

	public static void main(String[] args) throws Exception
	{
		long S = System.currentTimeMillis();
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;

	private static int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private static double nd() { return Double.parseDouble(ns()); }
	private static char nc() { return (char)skip(); }

	private static String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private static int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private static int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b, ans;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b = a;
    reverse(b.begin(), b.end());
    map<int,int> cnta, cntb;
    set<int> dif;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            cnta[a[i]]++;
            cntb[b[i]]++;
            if(cnta[a[i]]==cntb[a[i]]) dif.erase(a[i]);
            else dif.insert(a[i]);
            if(cnta[b[i]]==cntb[b[i]]) dif.erase(b[i]);
            else dif.insert(b[i]);
        }
        if(dif.empty()){
            ans.push_back(i+1);
        }
    }
    for(int i=0;i<int(ans.size());i++){
        cout << ans[i] << " \n"[i+1==ans.size()];
    }
    return 0;
}



Measured memory_bytes: 9460
MOD = 2019

l, r = map(int, input().split())
ret = MOD
upperBound = min(r, l + MOD)
for i in range(l, upperBound):
    for j in range(i + 1, upperBound + 1):
        ret = min(ret, (i * j) % MOD)
print(ret)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

Measured memory_bytes: 256
X,Y,Z,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
D=[]
for i in A:
  for j in B:
    D.append(i+j)
D=sorted(D)[::-1]
if X*Y>K:
  D=D[:K]
E=[]
for i in D:
  for j in C:
    E.append(i+j)
E=sorted(E)[::-1]
E=E[:K]
for i in E:
  print(i)

Measured memory_bytes: 226716
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if ((n % 1000) % 111 == 0) {
    cout << "Yes" << endl;
  }else if ((n /10) % 111 == 0) {
    cout << "Yes" << endl;
  }else
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DUMP(x) cout << #x << " = " << (x) << endl
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

int digitSum(int x) {
  int res = 0;
  while (x > 0) {
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  int ans = 0;
  REP(i, n) {
    int d = digitSum(i + 1);
    if (d >= a and d <= b) {
      ans += i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, span = map(int, input().split())
s = input()

nums = []
now, cnt = 1, 0
for i in range(n):
    if s[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1-now
        cnt = 1

if cnt != 0:
    nums.append(cnt)

if len(nums) % 2 == 0:
    nums.append(0)

rsw = [0]
for i in range(len(nums)):
    rsw.append(nums[i]+rsw[i])

span = 2*span+1

ans = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(i+span, len(nums))
    tmp = rsw[right]-rsw[left]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<char> s(4);
  for(int i=0;i<4;i++) cin >> s[i];
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

ll Q,H,S,D,N;

ll calc(ll v) {
  ll mini = Q * v * 4;
  mini = min(mini,H * v * 2);
  mini = min(mini,S * v);
  return mini;
}

void compute() {
  ll mini = calc(N);
  ll v = N / 2LL;
  ll w = N - v * 2LL;
  mini = min(mini,v*D+calc(w));
  cout << mini << endl;
}

int main() {
  cin >> Q >> H >> S >> D >> N;
  compute();
  return 0;
}


Measured memory_bytes: 256
/**
 * @author      : omgursocute
 * @created     : 20/01/2020
 * @task        : C
 */

// ===== TEMPLATE STARTS HERE ===== //

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define FORa(i, a, b) for(ll i = (a); i <= (b); ++i)
#define FORb(i, a, b, c) for(ll i = (a); i <= (b); i += (c))
#define FORn(i, n) for(ll i = 0; i < (n); ++i)
#define FORra(i, a, b) for(ll i = (a); i >= (b); --i)
#define FORrb(i, a, b, c) for(ll i = (a); i >= (b); i -= (c))
#define FORrn(i, n) for(ll i = ((n)-1); i >= 0; --i)
#define NUMARGC(_1, _2, _3, _4, NAME, ...) NAME
#define FOR(...) NUMARGC(__VA_ARGS__, FORb, FORa, FORn)(__VA_ARGS__)
#define RFOR(...) NUMARGC(__VA_ARGS__, FORrb, FORra, FORrn)(__VA_ARGS__)

#define XFOR(i, x) for(__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define RXFOR(i, x) for(__typeof((x).rbegin()) i = (x).rbegin(); i != (x).rend(); ++i)

#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range(x, a, b) ((x).begin()+a), ((x).begin()+b)
#define pb push_back

#define sqr(x) 1ll*(x)*(x)
#ifndef ONLINE_JUDGE
#define debug(x) cerr << '[' << #x << ']' << " = " << x << '\n'
#else
#define debug(x) "cute"
#endif

namespace io {
	void Speed() {
		ios::sync_with_stdio(false);
		cin.tie(NULL); cout.tie(NULL);
	}
#ifndef ONLINE_JUGDE
	void In(string s) {freopen(s.c_str(), "r", stdin);}
	void Out(string s) {freopen(s.c_str(), "w", stdout);}
	void setIO(string s) {In(s + ".inp"); Out(s + "out");}
#endif
}

// ======= TEMPLATE ENDS HERE ======= //

int main() {
	io::Speed();
	
	int n;
	cin >> n;
	vi a(n);
	FOR(i, n) cin >> a[i];
	
	int m = a[0];
	int ct = 1;
	FOR(i, 1, n-1) {
		m = min(m, a[i]);
		if(m == a[i]) ++ct;
	}
	
	cout << ct;

	return 0;
}



Measured memory_bytes: 1024
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())
	s = rll()[0]
	ans = 0
	A = [c for c in s]
	W = deque()
	for i, c in enumerate(A):
		if c == "W":
			W.append(i)
	for i in range(len(A)-1, -1, -1):
		if A[i] == "R" and W and W[0] < i:
			W.append(W.popleft())
			ans += 1
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 89500
#include <set>
#include <map>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cstring>
#include <algorithm>
#define mp std::make_pair
#define pr std::pair<int,int>
#define pc putchar
#define gc() getchar()
typedef long long LL;
const int N=2e5+5;

char s[N];

inline int read()
{
	int now=0,f=1;register char c=gc();
	for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now*f;
}

int main()
{
	scanf("%s",s+1); int n=strlen(s+1);
	LL ans=0,t=0;
	for(int i=1; i<=n; ++i)
		if(s[i]=='B') ++t;
		else ans+=t;
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 384
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; ; i++)
            {
                int answer = 0;
                string[] inputString = Console.ReadLine().Split();
                if (inputString[1] == "?")
                {
                    break;
                }
                if (inputString[1] == "+")
                {
                    answer = int.Parse(inputString[0]) + int.Parse(inputString[2]);
                }
                if (inputString[1] == "-")
                {
                    answer = int.Parse(inputString[0]) - int.Parse(inputString[2]);
                }
                if (inputString[1] == "*")
                {
                    answer = int.Parse(inputString[0]) * int.Parse(inputString[2]);
                }
                if (inputString[1] == "/")
                {
                    answer = int.Parse(inputString[0]) / int.Parse(inputString[2]);
                }

                Console.WriteLine(answer);
            }

        }
    }
}



Measured memory_bytes: 15948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;


int main() {
  int n;
  cin >> n;
  vector<P> a(n);
  map<P, int> mp;
  rep(i, n){
    int x, y;
    cin >> x >> y;
    a[i] = {x, y};
  }
  rep(i, n){
    for (int j = i + 1; j < n; j++){
      int x = a[j].first - a[i].first;
      int y = a[j].second - a[i].second;
      mp[{x, y}]++;
      mp[{-x, -y}]++;
    }
  }
  int ans = n;
  int mx = 0;
  for(auto num : mp){
    mx = max(mx, num.second);
  }
  ans -= mx;
  cout << ans << endl;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
    FLASH
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if(s[i] != t[i])
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3788
/**************************************************
  Solution to: REwrite of ABC 174 B - Distance
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,d;
int cnt=0;
int main(){
	cin>>n>>d;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3688
c = input()
d = input()
roll_c = []
roll_d = []
for i in range(len(c)):
  roll_c.append(c[-(i+1)])
  roll_d.append(d[-(i+1)])
if list(c) == roll_d and list(d) == roll_c:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, C = map(int, read().split())

ans = max(B + C - A, 0)
print(ans)


Measured memory_bytes: 3060