akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

// Graph Templates
using Weight = lint;
// using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    // Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
const Weight inf = numeric_limits<Weight>::max() / 8;

// add edge a <--(weight = w)--> b
void add_edge(Graph &g, int a, int b, Weight w) {
    g[a].push_back(Edge(a, b, w));
    g[b].push_back(Edge(b, a, w));
}

// add edge a --(weight = w)--> b
void add_arc(Graph &g, int a, int b, Weight w) { g[a].push_back(Edge(a, b, w)); }

// topological sort
// g : directed acyclic graph
// return : ord or empty vector array
vector<int> tsort(const Graph &g) {
    int n = g.size(), k = 0;
    std::vector<int> ord(n), in(n);
    for (auto &es : g)
        for (auto &e : es) in[e.dst]++;
    std::queue<int> q;
    for (int i = 0; i < n; ++i)
        if (in[i] == 0) q.push(i);
    while (q.size()) {
        int v = q.front();
        q.pop();
        ord[k++] = v;
        for (auto &e : g[v])
            if (--in[e.dst] == 0) q.push(e.dst);
    }
    return *std::max_element(in.begin(), in.end()) == 0 ? ord : std::vector<int>();
}

Graph gr;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int v, e;
    cin >> v >> e;
    int s, t;
    gr.resize(v);
    set<int> dst_nodes;
    for (int i=0; i<e; ++i){
        cin >> s >> t;
        s--;
        t--;
        dst_nodes.insert(t);
        add_arc(gr, s, t, 1);
    }
    vector<int> ts = tsort(gr);
    vector<int> dp(v, -1);
    for (int i=0; i<v; ++i){
        if(dst_nodes.find(i) == dst_nodes.end()){
            dp[i] = 0;
        }
    }
    int answer = -1;
    for (int i=0; i<(int)ts.size(); ++i){
        int prev = ts[i];
        for (int j=0; j<(int)gr[prev].size(); ++j){
            int next = gr[prev][j].dst;
            dp[next] = max(dp[next], dp[prev] + 1);
            // debugpair(i, j);
            // debug(dp[next]);
        }
    }
    for (int i=0; i<v; ++i){
        answer = max(answer, dp[i]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();

		int h, m, s;

		h = S / 3600;
		m = S / 60 % 60;
		s = S % 60;

		System.out.println(h + ":" + m + ":" + s);

		sc.close();

	}

}


Measured memory_bytes: 26420
#include<bits/stdc++.h>
using namespace std;
main(){
  int A,B;
  cin>>A>>B;
  auto f=[](int&x){x+=x==1?13:0;};
  f(A);
  f(B);
  if(A==B)
    cout<<"Draw"<<endl;
  else
    cout<<(A>B?"Alice":"Bob")<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int frag=1;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==0){
      if(A.at(i)%3!=0 && A.at(i)%5!=0){
        frag = 0;
      }
    }
  }
  if(frag == 1)
    cout << "APPROVED";
  else
    cout << "DENIED";
}

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

using namespace std;

#define  N 100200

const double PI = 3.14159265359;
typedef long long ll;

vector<int> d1(N, 1e6);
vector<int> d2(N, 1e6);
vector<int> g[N];

void dfs(int v, int p, vector<int> &d) {
    d[v] = d[p] + 1;
    for (auto x:g[v]) {
        if (x != p)dfs(x, v, d);
    }
}

void solve() {
    int n, u, v;
    cin >> n >> u >> v;

    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    d1[u] = -1;
    d2[v] = -1;
    dfs(u, u, d1);
    dfs(v, v, d2);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (d1[i] == d2[i]) {
            if (d1[i] + d2[i] == d1[v]) {
                ans = max(ans, d2[i]);
            }
        }
        if (d1[i] < d2[i]) {
            ans = max(ans, d2[i] - 1);
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef qwerty
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif


    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, x;
    cin >> n >> x;
    int c = 1;
    int t = 0;
    int l;
    REP(i, n) {
        cin >> l;
        t += l;
        if (t > x) {
            break;
        }
        c++;
    }
    cout << c << endl;
}



Measured memory_bytes: 256
h, n = map(int, input().split())
ab = list(list(map(int, input().split())) for _ in range(n) )

dp = [0] * (h + max(list( node[0] for node in ab )))

for i in range(1, len(dp)):
  dp[i] = min(list(dp[i - a] + b for a, b in ab))
print(dp[h])

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define MOD (long long)(1e9+7)
typedef long long int ll;
typedef unsigned long long int ull;

ll modularExponentiation(ll x, ll y, ll  p){
  ll res = 1;
  x = x % p;
  while (y > 0){
      if (y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
  }
  return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t=1;
  // cin>>t;
  while(t--){
    ll k, n;
    cin>>k>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(), a.end());
    ll _max=INT_MIN;
    for(int i=0;i<n-1;i++){
      _max=max(_max, a[i+1]-a[i]);
    }
    if(a[0]==0) _max=max(_max, abs(k-a[n-1]));
    else _max=max(_max, a[0]+abs(k-a[n-1]));
    cout<<k-_max<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import           Data.List

main :: IO ()
main = do
    [k, t] <- readInts
    as     <- readInts
    print $ solve k t as

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve k t as | x - sum xs <= 1 = 0
             | otherwise       = x - sum xs - 1
    where (x : xs) = sortBy (flip compare) as

Measured memory_bytes: 892
import sys

def input():
    return sys.stdin.readline()[:-1]

N,M,L = list(map(int,input().split()))

e_list = [[] for i in range(N)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = [[float("inf") for i in range(N)] for i in range(N)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(M):
    x,y,z = list(map(int,input().split()))
    if z<=L:
        d[x-1][y-1] = z
        d[y-1][x-1] = z

for i in range(N):
    d[i][i] = 0 #自身のところに行くコストは０

d = warshall_floyd(d)

e_list = [[] for i in range(N)]

d2 = [[float("inf") for i in range(N)] for i in range(N)]

for i in range(N):
    for j in range(i+1,N):
        if d[i][j] <= L:
            d2[i][j] = 1
            d2[j][i] = 1

d2 = warshall_floyd(d2)

Q = int(input())
for i in range(Q):
    s,t = list(map(int,input().split()))
    s,t = s-1,t-1
    if d2[s][t]>10**9:
        print(-1)
    else:
        print(d2[s][t]-1)


Measured memory_bytes: 126684
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int n, x;
    cin >> n >> x;
    vi as;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    sort(as.begin(), as.end());
    i64 sum = 0;
    for (int i = 0; i < n; i++) {
        sum += as[i];
        if (sum > x) {
            sum -= as[i];
            for (int j = i + 1; j < n; j++) {
                if (sum + as[j] == x) {
                    cout << i + 1 << endl;
                    return 0;
                }
            }
            cout << i << endl;
            return 0;
        }
        if (sum == x) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    if (sum < x) {
        cout << n - 1 << endl;
        return 0;
    }
    return 1;
}


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

#define N 8
#define FREE -1
#define N_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE,col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%s",((row[i]==j) ? "Q" :"."));
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(N_FREE==col[j]||N_FREE==dpos[i+j]||N_FREE==dneg[i-j+N-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=N_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;
  initialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=false;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=true;
  }
  recursive(0);
  return 0;
}

Measured memory_bytes: 600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		List<Long> que = new ArrayList<>();
		for(int i = 1; i < 10; i++) {
			que.add((long) i);
		}
		for(int i = 0; i < k - 1; i++) {
			long val = que.get(i);
			if(val % 10 != 0)
				que.add(10 * val + val % 10 - 1);
			que.add(10 * val + val % 10);
			if(val % 10 != 9)
				que.add(10 * val + val % 10 + 1);
		}
		System.out.println(que.get(k - 1));

	}

}


Measured memory_bytes: 32340
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h := intScanner()
	w := intScanner()
	n := intScanner()
	r, c := intScanner()-1, intScanner()-1
	s := Scanner()
	t := Scanner()
	left, right := 0, w
	if string(s[n-1]) == "L" {
		left++
	} else if string(s[n-1]) == "R" {
		right--
	}
	lr := true
	for i := n - 2; i >= 0; i-- {
		if string(t[i]) == "L" {
			right = smaller(right+1, w)
		} else if string(t[i]) == "R" {
			left = larger(left-1, 0)
		}
		if string(s[i]) == "L" {
			left++
		} else if string(s[i]) == "R" {
			right--
		}
		if left >= right {
			lr = false
		}
	}
	if c < left || right <= c {
		lr = false
	}
	left, right = 0, h
	if string(s[n-1]) == "U" {
		left++
	} else if string(s[n-1]) == "D" {
		right--
	}
	ud := true
	for i := n - 2; i >= 0; i-- {
		if string(t[i]) == "U" {
			right = smaller(right+1, h)
		} else if string(t[i]) == "D" {
			left = larger(left-1, 0)
		}
		if string(s[i]) == "U" {
			left++
		} else if string(s[i]) == "D" {
			right--
		}
		if left >= right {
			ud = false
		}
	}
	if r < left || right <= r {
		ud = false
	}
	if lr && ud {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2720
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nm = IO.RSLong;
            var abs = new List<KeyValuePair<long, long>>();
            for (int i = 0; i < nm[0]; i++)
            {
                var tmp = IO.RSLong;
                var kv = new KeyValuePair<long, long>(tmp[0], tmp[1]);
                abs.Add(kv);
            }

            abs.Sort((a, b) => (int)a.Key - (int)b.Key);
            long ans = 0;
            long nowStock = abs[0].Value;
            long price = abs[0].Key;
            int now = 0;
            while (nm[1] > 0)
            {
                if (nowStock > 0)
                {
                    ans += price;
                    nowStock--;
                    nm[1]--;
                }
                else
                {
                    now++;
                    nowStock = abs[now].Value;
                    price = abs[now].Key;
                    ans += price;
                    nowStock--;
                    nm[1]--;
                }
            }
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }
    }
}

Measured memory_bytes: 19256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    if n == 1 {
        println!("Hello World");
    } else {
        let a: usize = read();
        let b: usize = read();
        println!("{}", a + b);
    }
}

Measured memory_bytes: 2156
#include <iostream>
using namespace std;
int a[200006];
int main() {
	int N;
	cin >> N;
	int cnt=0;
	for (int i=0; i<N; i++) {
		char x;
		cin >> x;
		if (x=='R') {
			a[i]=1;
			cnt++;
		}
	}
	int ans=0;
	for (int i=0; i<cnt; i++) {
		if (a[i]==0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4424
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

template <typename T>
class compress {
private:
    map<T, size_t> zipped;
    vector<T> unzipped;

public:
    compress(vector<T> &X) {
        sort(begin(X), end(X));
        X.erase(unique(begin(X), end(X)), end(X));
        unzipped.resize(X.size());
        for(size_t i=0; i<X.size(); ++i) {
            zipped[X[i]] = i;
            unzipped[i] = X[i];
        }
    }

    size_t size() { return zipped.size(); }
    size_t zip(T x) { return zipped[x]; }
    T unzip(size_t x) { return unzipped[x]; }
};


#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> x1(N), y1(N), x2(N), y2(N);
    for(int i=0; i<N; ++i) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];

    vector<int> X(x1);
    copy(begin(x2), end(x2), back_inserter(X));
    vector<int> Y(y1);
    copy(begin(y2), end(y2), back_inserter(Y));

    compress<int> xc(X), yc(Y);

    vector<vector<int>> accum(xc.size(), vector<int>(yc.size(), 0));
    for(int i=0; i<N; ++i) {
        accum[xc.zip(x1[i])][yc.zip(y1[i])] += 1;
        accum[xc.zip(x1[i])][yc.zip(y2[i])] -= 1;
        accum[xc.zip(x2[i])][yc.zip(y1[i])] -= 1;
        accum[xc.zip(x2[i])][yc.zip(y2[i])] += 1;
    }

    for(int i=0; i<xc.size(); ++i) {
        for(int j=1; j<yc.size(); ++j) {
            accum[i][j] += accum[i][j - 1];
        }
    }

    for(int i=1; i<xc.size(); ++i) {
        for(int j=0; j<yc.size(); ++j) {
            accum[i][j] += accum[i - 1][j];
        }
    }

    long long ans = 0;
    for(int i=0; i+1<xc.size(); ++i) {
        for(int j=0; j+1<yc.size(); ++j) {
            if(accum[i][j] > 0) {
                ans += 1LL * (xc.unzip(i + 1) - xc.unzip(i)) * (yc.unzip(j + 1) - yc.unzip(j));
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 66252
#include <bits/stdc++.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <fstream>

//#define _debug
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back
//#define _online_judge

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = static_cast<const int>(1e4 + 5);
const int MOD = 1000000007;



int main(){
    FASTIO;
#ifdef _online_judge
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif

    ll n,k,x,y;cin >> n >> k >> x >> y;
    cout << min(n,k)*x + max(0ll,n-k)*y;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
//static const int INFTY = (1<<20);


//ABC150_c
int main() {
	int n;
	cin >> n;

	vector<int> v(n);
	vector<int> va(n);
	vector<int> vb(n);

	rep(i, n) v.at(i) = i+1;
	rep(i, n) cin >> va.at(i);
	rep(i, n) cin >> vb.at(i);

	int cnt_a = 0;
	int cnt_b = 0;
	do {
		if (v == va) break;
		cnt_a++;
	} while (next_permutation(v.begin(), v.end()));
	sort(v.begin(), v.end());
	do {
		if (v == vb) break;
		cnt_b++;
	} while (next_permutation(v.begin(), v.end()));
	cout << abs(cnt_b - cnt_a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main()
{
    int d,g;
    cin>>d>>g;
    vin p(d),c(d);
    rep(i,d)cin>>p[i]>>c[i];
    int inf=10000;
    vin ans(1100);
    rep(i,1100)ans[i]=inf;
    int l=0;
    rep(i,1<<d){
        bitset<10> a(i);
        ll sum=0;
        int total=0;
        rep(j,d){
            if(a.test(j)){
                sum+=(ll)(100*(j+1)*p[j]+c[j]);
                total+=p[j];
            }
        }
        if(sum>=g){
            ans[l]=total;
            l++;
        }
        else{
            for(int k=d-1;k>-1;k--){
                if(!(a.test(k))){
                    if(g-sum<=100*(k+1)*(p[k]-1)){
                        if((g-sum)%(100*(k+1))==0){
                            total+=(g-sum)/(100*(k+1));
                            ans[l]=total;
                            l++;
                        }
                        else{
                            total+=(g-sum)/(100*(k+1))+1;
                            ans[l]=total;
                            l++;
                        }
                    }
                    break;
                }
            }
        }
    }
    sort(all(ans));
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val tokenizer = StringTokenizer(readLine()!!)
    val h = tokenizer.nextToken().toInt()
    val w = tokenizer.nextToken().toInt()
    val a = tokenizer.nextToken().toInt()
    val b = tokenizer.nextToken().toInt()
    for (y in 0 until h) {
        println(String(CharArray(w) { x -> if (y < b == x < a) '1' else '0' }))
    }
}

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

using namespace std;

typedef long long ll;

ll pet[4];
ll a[4] = {25,50,100,200};

ll q,h,s,d,n;
int main() {
  cin >> pet[0] >> pet[1] >> pet[2] >> pet[3] >> n;
  
  n *= 100;

  for(int i = 1; i < 4; i++) {
    pet[i] = min(pet[i],pet[i-1]*2);
  }

  ll k = 3;
  ll ans = 0;
  while(n > 0) {
    ll tmp = n / a[k];
    ans += tmp * pet[k];
    n -= tmp * a[k];
    k--;

  }

  cout << ans << endl;
}
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i, j;
	string s;
	cin >> n;
	cin >> s;
  
	ll ans = 0;
	int cnt[26];
	fill(cnt, cnt + 26, 0);
	for(i = 0; i < n; i++) {
		for(j = i + 1; j < n; j++) {
			if(s[i] == s[j]) continue;
			ans += i - cnt[s[i] - 'A'] - cnt[s[j] - 'A'];
			
			int df = j - i;
			if(i - df >= 0) {
				if(s[i] != s[i - df] && s[j] != s[i - df])
				--ans;
			}
		}
		cnt[s[i] - 'A']++;
	}
	cout << ans;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
  int a,b,c,mon=0,k[10][10];
  cin>>a>>b;
  for(int i=0;i<=9;++i){
    for(int j=0;j<=9;++j){
      cin>>k[i][j];
    }
  }
  
  for(int i=0;i<=9;++i){
    for(int j=0;j<=9;++j){
      for(int kk=0;kk<=9;++kk){
        if(k[j][kk]>k[j][i]+k[i][kk]){
          k[j][kk]=k[j][i]+k[i][kk];
        }
      }
    }
  }
  
  for(int i=0;i<a;++i){
    for(int j=0;j<b;++j){
      cin>>c;
      if(c!=-1) mon+=k[c][1];
    }
  }
  
  cout<<mon<<endl;
}

Measured memory_bytes: 256
from math import cos, sqrt, radians

def main():
    A, B, H, M = map(int, input().split())
    small = 360 * (M / 60)
    big = 360 * (H/12) + 30 * (M/60)
    deg = small - big
    rad = radians(deg)
    d2 = A**2.0 + B**2.0 - 2*A*B*cos(rad)
    print(sqrt(d2))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9568
#include <stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a==b&&c==d||a==d&&b==c){
		printf("yes\n");
	}
	else{
		printf("no\n");
	}
	return 0;
}


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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    ll n;
    cin >> n;

    vector<ll> over_lines;

    {
        vector<ll> ts(n);
        vector<ll> vs(n);
        rep(i, n) {
            cin >> ts[i];
        }
        rep(i, n) {
            cin >> vs[i];
        }

        ll ts_sum = 0;
        for (ll i : ts) {
            ts_sum += i;
        }
        over_lines.resize(ts_sum + 2, 0);

        ll index = 1;
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < ts[i]; j++) {
                over_lines[index] = vs[i];
                index++;
            }
        }

    }
    rep(i, 30) {
        for (ll i = 1; i < over_lines.size(); i++) {
            over_lines[i] = min(over_lines[i], over_lines[i - 1] + 1);
        }

        for (ll i = over_lines.size() - 2; i >= 0; i--) {
            over_lines[i] = min(over_lines[i], over_lines[i + 1] + 1);
        }
    }
    ll ans = 0;

    for (ll i = 1; i < over_lines.size() - 1; i++) {
        ll a = over_lines[i - 1];
        ll b = over_lines[i];
        ll c = over_lines[i + 1];
        assert(b > 0);
        assert(abs(a - b) <= 1);
        assert(abs(b - c) <= 1);
        if (a == b && b == c) {
            ans += b * 100ll;
        } else if (a > b && b < c) {
            ans += b * 100ll;
        } else if ((a > b && b == c) || (a == b && b < c)) {
            ans += b * 100ll;
        } else if ((a == b && b > c) || (a < b && b == c)) {
            ans += ((b - 1) * 100ll) + 50;
        } else if (a < b && b > c) {
            ans += ((b - 1) * 100ll) + 25;
        } else if ((a < b && b < c) || (a > b && b > c)) {
            ans += ((b - 1) * 100ll) + 50;
        } else {
            assert(false);
        }
    }

    cout << setprecision(10)<< ((long double) ans) / 100 << endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = getInputInteger(sc);
 
        // programming
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = getInputInteger(sc);
        }
        int[] a_sort = sort(a, false);
        for (int i = 0; i < a_sort.length; i++) {
            if (i % 2 != 0) {
                a_sort[i] *= -1;
            }
        }
        int sum = sum(a_sort);
        output(String.valueOf(sum));
	}

	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}

    public static int[] toIntegerList(String s) {
        int[] ret = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            ret[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
        }
        return ret;
    }

    public static int sum(int[] vals) {
        int sum = 0;
        for (int val : vals) {
            sum += val;
        }
        return sum;
    }

    public static int[] sort(int[] vals, boolean isAsc) {
        Arrays.sort(vals);
		if (isAsc) {
			return vals;
		}
        int[] ret = new int[vals.length];
        for (int i = 0; i < vals.length; i++) {
            ret[vals.length - i - 1] = vals[i];
        }
		return ret;
	}
}

Measured memory_bytes: 23764
def bubbleSort(l):
    k = 1
    count = 0
    for j in range(len(l)-1):
        for i in range(len(l)-k):
            if l[i] > l[i+1]:
                a = l[i]
                l[i] = l[i+1]
                l[i+1] = a
                count += 1
        k += 1

    ans_l = map(str,l)
    return ans_l,count

n = int(input())
l = list(map(int,input().split()))
ans_l,ans_count = bubbleSort(l)
print(' '.join(ans_l))
print(ans_count)



Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main()
{
int a,b,c;
for(int i=1;i<=1000;i++)
{cin >> a >> b >> c;
if(a==-1 && b==-1)
{cout << "";}
else if(a==-1)
{cout << "F" << endl;}
else if(b==-1)
{cout << "F" << endl;}
else if(a+b<30)
{cout << "F" << endl;}
else if(a+b<50)
{if(c>=50)
{cout << "C" << endl;}
else
{cout << "D" << endl;}
}
else if(a+b<65)
{cout << "C" << endl;}
else if(a+b<80)
{cout << "B" << endl;}
else
{cout << "A" << endl;}
}
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;
bool comp(pair<int,int>f,pair<int,int>g){
        return f.second<g.second;
}
void solve(){
  int n,m;
  cin>>n>>m;
  pair<int,int> A[m];
  int a,b;
  for(int i=0;i<m;i++){
     cin>>A[i].first>>A[i].second;
  }
  sort(A,A+m,comp);
  int c=0;
  int u=0;
  for(int i=1;i<m;i++){
       if(A[u].second<=A[i].first){
           c++;
           u=i;
       }
  }
   cout<<c+1;
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){

	int A,B,C,D,X,Y;
	scanf("%d %d %d %d",&A,&B,&C,&D);

	if(A > B) X = B;
	else X = A;
	if(C > D) Y = D;
	else Y = C;

	printf("%d",X+Y);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,y;cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k=(y-10000*i-5000*j)/1000;
            if(i+j+k==n && 0<=k && k<=n){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 3628
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(y%2!=0)
	cout<<"No"<<endl;
	else
	{
	int r=y/4;
	y=y%4;
	int l=y/2;
	if(l+r<=x&&l+2*r>=x)
	{
	cout<<"Yes"<<endl;
	}
	
	else
	cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    ll INF = 1e15;
    vector<ll> dp(n);
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    rep(i, n)rep(j, 3){
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 4772
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << std::max<i64>(0, A - 2 * B) << std::endl;
  return 0;
}

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

#define swap(type, x, y)  do {type t = x; x = y; y = t;} while (0)

void bubble(int a[], int n)
{
    int k = 0;
    while (k < n - 1) {
        int j;
        int last = n - 1;
        for (j = n - 1; j > k; --j) {
            if (a[j - 1] > a[j]) {
                swap(int, a[j - 1], a[j]);
                last = j;
            }
        }
        k = last;
    }
}

void quick(int a[], int left, int right)
{
    int pl = left;
    int pr = right;
    int x = a[(pl + pr) / 2];
    do {
        while (a[pl] < x) ++pl;
        while (a[pr] > x) --pr;
        if (pl <= pr) {
            swap(int, a[pl], a[pr]);
            ++pl;
            --pr;
        }
    } while (pl <= pr);
    if (left < pr) quick(a, left, pr);
    if (pl < right) quick(a, pl, right);
}

int main(void)
{
    int n, i, j;
    scanf("%d", &n);

    int *x, *y;
    x = calloc(n, sizeof(int));
    y = calloc(n, sizeof(int));
    for (i = 0; i < n; ++i) {
        scanf("%d", x + i);
        y[i] = x[i];
    }

    quick(y, 0, n - 1);
    int ans1 = y[n / 2 - 1];
    int ans2 = y[n / 2];

    for (i = 0; i < n; ++i) {
        if (x[i] <= ans1) printf("%d\n", ans2);
        else printf("%d\n", ans1);
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
const int N=20,S=27e4;
int f[N][S][N],n,i,j,k,l,a[2][N],cnt[S],val[N][N],ans;
inline void upi(int&a,const int&b){a>b?a=b:0;}
int main(){
	scanf("%d",&n);
	for(i=1;i<1<<n;++i)cnt[i]=cnt[i>>1]+(i&1);
	for(j=0;j<2;++j)for(i=0;i<n;++i)scanf("%d",a[j]+i);
	memset(f,1,sizeof f);for(i=0;i<n;++i)f[0][1<<i][i]=0;ans=1<<25;
	for(i=0;i<n;++i)for(j=0;j<n;++j)val[i][j]=a[(i^j)&1][j];
	for(i=0;i+1<n;++i)for(j=0;j<1<<n;++j)if(cnt[j]==i+1)for(k=0;k<n;++k)if(j>>k&1)
		for(l=0;l<n;++l)if(!(j>>l&1) && val[i][k]<=val[i+1][l])
			upi(f[i+1][j|(1<<l)][l],f[i][j][k]+cnt[j&~((1<<l)-1)]);
	for(i=0;i<n;++i)upi(ans,f[n-1][(1<<n)-1][i]);
	if(ans>114514)ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 423168
def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime=get_sieve_of_eratosthenes_new(2160)

def ind(b,n):
    res=0
    while n%b==0:
        res+=1
        n//=b
    return res

import sys

input=sys.stdin.readline

N=int(input())
dic={}
inverse={}
for i in range(N):
    s=int(input())
    news=1
    invs=1
    for p in prime:
        a=ind(p,s)
        s//=p**a
        news*=p**(a%3)
        invs*=p**((-a)%3)
    if s==1 or int(s**0.5)**2!=s:
        news*=s
        invs*=s**2
        if news not in dic:
            dic[news]=0
            inverse[news]=0
        dic[news]+=1
        inverse[news]=invs
    else:
        news*=s
        invs*=int(s**0.5)
        if news not in dic:
            dic[news]=0
            inverse[news]=0
        dic[news]+=1
        inverse[news]=invs

one=0
double=0
for i in dic:
    if i!=1:
        if inverse[i] in dic:
            double+=max(dic[i],dic[inverse[i]])
        else:
            one+=dic[i]

double//=2
ans=one+double
if 1 in dic:
    ans+=1
print(ans)

Measured memory_bytes: 87516
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

int p[N];
 
signed main(){
    fastio;
    int i,n,ans=0,mn=inf;
    cin>>n;
    for(i=0;i<n;++i){
        cin>>p[i];
        mn=min(mn,p[i]);
        if(mn>=p[i]) ++ans;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans, cnt;
  scanf("%lld%lld", &n, &k);
  ans = n;
  ll a[n];
  bool dpf[n + 1][k], dpb[n + 1][k];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i <= n; ++i) for(j = 0; j < k; ++j) dpf[i][j] = dpb[i][j] = false;
  dpf[0][0] = dpb[n][0] = true;
  for(i = 0; i < n; ++i) {
    for(j = 0; j < k; ++j) dpf[i + 1][j] = dpf[i][j];
    for(j = 0; j + a[i] < k; ++j) if(dpf[i][j]) dpf[i + 1][j + a[i]] = true;
  }
  for(i = n; i; --i) {
    for(j = 0; j < k; ++j) dpb[i - 1][j] = dpb[i][j];
    for(j = 0; j + a[i - 1] < k; ++j) if(dpb[i][j]) dpb[i - 1][j + a[i - 1]] = true;
  }
  for(i = 0; i < n; ++i) {
    if(a[i] > k) {
      ans--;
      continue;
    } else {
      cnt = 0;
      for(j = k - a[i]; j < k; ++j) cnt += dpb[i + 1][j] ? 1 : 0;
      if(cnt) {
        ans--;
        continue;
      }
      for(j = 1; j < k; ++j) {
        cnt -= dpb[i + 1][k - j] ? 1 : 0;
        if(k - j - a[i] >= 0) cnt += dpb[i + 1][k - j - a[i]] ? 1 : 0;
        if(dpf[i][j] && cnt) {
          ans--;
          break;
        }
      }
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 49152
#s = gets.chomp!
#n = gets.chomp.to_i
#arr = gets.chomp.split(" ").map{|i|i = i.to_i}

x,y,z,k = gets.chomp.split(" ").map{|i|i = i.to_i}
a = gets.chomp.split(" ").map{|i|i = i.to_i}.sort.reverse
b = gets.chomp.split(" ").map{|i|i = i.to_i}.sort.reverse
c = gets.chomp.split(" ").map{|i|i = i.to_i}.sort.reverse
#puts "a=#{a}"
#puts "b=#{b}"
#puts "c=#{c}"
result_arr = []
a.length.times do|a_i|
  b.length.times do|b_i|
    c.length.times do|c_i|
      if ((a_i+1)*(b_i+1)*(c_i+1))>k then
        break
      end
      result_arr << (a[a_i]+b[b_i]+c[c_i])
    end
  end
end


result_arr.sort!.reverse!
#puts "result_arr = #{result_arr}"
k.times do|i|
  puts result_arr[i]
end




#pp s







Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a, b;
  cin >> x >> a >>b;
  
  if ( a >= b){
    cout << "delicious" << endl;
  }
  
  else if ( b - a <= x){
    cout << "safe" << endl;
  }
  
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

vi occ[maxN];
int ile[maxN];
set<pii, greater<pii>> s;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int h, w, m;
	cin >> h >> w >> m;
	RI(i, w) s.insert({0, i});
	REP(_, m) {
		int r, c;
		cin >> r >> c;
		occ[r].pb(c);
		s.erase(s.find({ile[c], c}));
		ile[c]++;
		s.insert({ile[c], c});
	}
	int ans = 0;
	RI(i, h) {
		int sum = sz(occ[i]);
		for (auto x: occ[i]) {
			s.erase(s.find({ile[x], x}));
			ile[x]--;
			s.insert({ile[x], x});
		}
		// for (auto z: s) {
			// cout << z.st << " " << z.nd << endl;
		// }
		sum += s.begin()->st;
		// cout << i << " " << s.begin()->nd << endl;
		for (auto x: occ[i]) {
			s.erase(s.find({ile[x], x}));
			ile[x]++;
			s.insert({ile[x], x});
		}
		ans = max(ans, sum);
	}
	cout << ans;
	return 0;
}
 


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

int main(){
  int N,M;
  cin>>N;
  vector<int> T(N);
  rep(i,N) cin>>T[i];
  cin>>M;
  vector<int> P(M);
  vector<int> X(M);
  rep(i,M) cin>>P[i]>>X[i];
  int sum=0;
  int E;
  rep(i,M){
    sum=0;
    E=T[P[i]-1];
    T[P[i]-1]=X[i];
    rep(j,N) sum+=T[j];
    cout<<sum<<endl;
    T[P[i]-1]=E;
  }
}

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

n,m,c = map(int,input().split())
b = tuple(map(int,input().split()))
res = 0
for i in range(n):
    s = 0
    a = tuple(map(int,input().split()))
    for i in range(m):
        s += a[i]*b[i]
    s += c
    if s > 0:
        res += 1
print(res)

Measured memory_bytes: 3064