akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s, t;
  std::cin >> s >> t;
  std::cout << t << s << "\n";
}


Measured memory_bytes: 256
package main

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

func main() {
	io := newIo()
	defer io.Flush()
	H, W := io.NextInt(), io.NextInt()
	field := make([][]int, H+2)
	dxy := [4][2]int{[2]int{0, 1}, [2]int{0, -1}, [2]int{1, 0}, [2]int{-1, 0}}
	// 1< スタートからの距離(スタート1)
	// 0 移動可能未踏
	// -2 壁
	blockCount := 0
	for h := range field {
		field[h] = make([]int, W+2)
		if h == 0 || h == H+1 {
			for w := range field[h] {
				field[h][w] = -2
			}
		} else {
			field[h][0] = -2
			line := io.Next()
			for _w, s := range line {
				w := _w + 1
				if s == '#' {
					blockCount++
					field[h][w] = -2
				}
			}
			field[h][W+1] = -2
		}
	}
	q := [][2]int{}
	field[1][1] = 1
	q = append(q, [2]int{1, 1})

	qq := q[0]
	for {
		q = q[1:]
		y, x := qq[0], qq[1]
		for _, d := range dxy {
			dy, dx := d[0], d[1]
			if field[y+dy][x+dx] != 0 {
				continue
			}
			q = append(q, [2]int{y + dy, x + dx})
			field[y+dy][x+dx] = field[y][x] + 1
		}
		if len(q) == 0 {
			break
		}
		qq = q[0]
	}
	if field[H][W] == 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(H*W - field[H][W] - blockCount)
	}
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

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

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

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
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 768
#include<iostream>
#include<map>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	map<int,int> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	int ans=0;
	rep(i,n){
		if(mp[a[i]]!=a[i]){
			ans++;
			mp[a[i]]--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>

int main(void) {

    int n,y;

    std::cin >> n >> y;

    for(int n10000 = 0; n10000 <= n; n10000++) {

        if (!(n10000 <= n)) {
            break;
        }

        for(int n5000 = 0; n5000 <= n; n5000++) {

            if (!(n10000 + n5000 <= n)) {
                break;
            }

            int n1000 = n - n10000 - n5000;

/*
            for(int n1000 = 0; n1000 <= n; n1000++) {

                if (!(n10000 + n5000 + n1000 <= n)) {
                    break;
                }
*/

                if (y == 10000 * n10000 + 5000 * n5000 + 1000 * n1000) {
                    std::cout << n10000 << " " << n5000 << " " << n1000 << std::endl;
                    return 0;
                }
        }
    }

    std::cout << "-1 -1 -1" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x, a, b;
    scanf("%d", &x);
    if (x % 2 == 1)
    {
        a = x/2;
        b = a+1;
    }
    else{
        a = x/2;
        b = a;
    }
    printf("%d\n", a*b);
    return 0;
}

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

#define int long long
#define loop(i,n) for(int i=1;i<=n;i++)
int p[100002];
int a[100002];
int b[100002];
int c[100002];
int t[100002];

signed main() {
  int n,m;
  cin>>n>>m;
  loop(j,m)cin>>p[j];
  loop(i,n-1)cin>>a[i]>>b[i]>>c[i];
  loop(j,m){
    if(j==1)continue;
    int x=min(p[j-1],p[j]);
    int y=max(p[j-1],p[j]);
    while(x<y)t[x++]++;
  }
  int sum=0;
  loop(i,n-1){
    sum+=min(t[i]*a[i],t[i]*b[i]+c[i]);
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 7004
# include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
                sum=sum+(__gcd(k,__gcd(i,j)));
        }
    }
    cout<<sum;
}


Measured memory_bytes: 3620
use std::io::{Read, stdin};
use std::str::FromStr;


fn main() {
    let n: i64 = read();
    let y: i64 = read::<i64>() / 1000;
    let mut f = false;
    for i in 0..n+1 {
        for j in 0..n+1-i {
            if !f && (n - i - j) == y - i * 10 - 5* j {
                f = true;
                println!("{} {} {}", i, j, n-i-j);
                break;
            }
        }
    }
    if !f { println!("-1 -1 -1");}
}


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")
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll X; cin >> X;
    bool flg = false;
    REP2(B,-1000,1000){
      REP2(A,B,1000){
        if(flg) continue;
        if(X == pow(A,5) - pow(B,5)){
          cout << A << " " << B;
          flg = true;
        }
      }
    }
  	return 0;
}

Measured memory_bytes: 4068
#include <stdio.h>

int main(){
  int k,x,i;
  scanf("%d",&k);
  scanf("%d",&x);
  i=x-k+1;
  if(i<-1000000) i=-1000000;
  for(;(i<=x+k-1)&(i<=1000000);i++){
    printf("%d ",i);
  }
  return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int MAX = 1000000007;

int dp[4000][4000];

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    string s, t;
    cin>>s>>t;
    int i, j;
    for(i=0;i<s.length();i++){
        for(j=0;j<t.length();j++){
            if(s[i]==t[j]&&i>=1&&j>=1)
                dp[i][j]=dp[i-1][j-1]+1;
            else if(i>=1&&j>=1){
                dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
            }
            else if(s[i]==t[j]){
                dp[i][j]=1;
            }
            else if(i>=1){
                dp[i][j]=dp[i-1][j];
            }
            else if(j>=1){
                dp[i][j]=dp[i][j-1];
            }
        }
    }
    i=s.length()-1;
    j=t.length()-1;
    string str="";
    for(;i>=0&&j>=0;){
        if(s[i]==t[j]){
            str+=s[i];
            i--;
            j--;
        }
        else if(i>0&&j>0&&dp[i-1][j]>dp[i][j-1])
            i--;
        else if(i>0&&j>0&&dp[i-1][j]<=dp[i][j-1])
            j--;
        else if(i==0)
            j--;
        else if(j==0)
            i--;
    }
    reverse(str.begin(), str.end());
    cout<<str<<endl;
    
}


Measured memory_bytes: 94208
#include <iostream>
#include <vector>
#include <numeric>
#include <limits>

using namespace std;

int solve() {
    int N, L; cin >> N >> L;
    vector<int> nums(N);
    iota(nums.begin(), nums.end(), L);
    int total = accumulate(nums.begin(), nums.end(), 0);
    
    int min_diff = numeric_limits<int>::max();
    int min_val{0};
    for (auto num : nums) {
        if (abs(num) < min_diff) {
            min_diff = abs(num);
            min_val = num;
        }
    }
    
    return total - min_val;
}

int main() {
    cout << solve() << endl;
}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    int w, h;
    while(cin >> w >> h) {
        if(w == 0 and h == 0)
            break;
        Matrix c(h, Array(w));

        REP(i, h) {
            REP(j, w) {
                cin >> c[i][j];
            }
        }

        Matrix used(h, Array(w, false));

        auto dfs = [&](auto &&self, int i, int j) -> ll {
            used[i][j] = true;
            ll ret = 1;
            for(int ni = max(i - 1, 0); ni <= min(i + 1, h - 1); ni++) {
                for(int nj = max(j - 1, 0); nj <= min(j + 1, w - 1); nj++) {
                    if(used[ni][nj])
                        continue;
                    if(c[ni][nj])
                        ret += self(self, ni, nj) + 1;
                }
            }
            return ret;
        };

        ll ans = 0;
        REP(i, h) {
            REP(j, w) {
                if(!c[i][j] or used[i][j])
                    continue;
                dfs(dfs, i, j);
                ans++;
            }
        }
        cout << ans << en;
    }
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N,M,K,a;
    vector<ll> A,B;
    
    cin >> N >> M >> K;
    REP(i,N){cin >> a;A.push_back(a);}
    REP(i,M){cin >> a;B.push_back(a);}
    
    
    REP(i,N-1){
        A[i+1]+=A[i];
    }
    REP(i,M-1){
        B[i+1]+=B[i];
    }
    
    ll Ans=0;
    REP(i,N+1){
        ll num = i;
        ll key;
        if(i==0){
            key=0;
        }else{
            key=A[i-1];
        }
        if(key>K)continue;
        auto it = std::upper_bound(B.begin(), B.end(), K-key);
        //cout << num MM (it-B.begin()) << endl;
        num+=(it-B.begin());
        
        Ans=max(Ans,num);
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 7984
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N;

    std::cin >> N;

    cout << 2.0 * M_PI * N << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    int n, y;

    cin >> n >> y;

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= (n - i); j++)
        {
            if (y == 10000 * i + 5000 * j + 1000 * (n - i - j))
            {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn;--i)
#define xep(i,b) for(int i=0,nn=int(b);i<nn; ++i)

#define LB lower_bound
#define md 1000000007

const int N = 200100;

int v[N], w[N], vc[N], od[N];
int r[N], l[N], f[N],sk[N];
int vn, n;

char *cp=(char *)malloc(1<<15), *is=cp, *it=cp;
#define getc() (is==it&&(it=(is=cp)+fread(cp,1,1<<15,stdin),is==it)?0:*is++)

inline void in(int &x) {
	char c = getc(); int f=1;
	for (; c<'0'||c>'9';c=getc())
		f = (c=='-' ? -1:f);
	for (x=0; c>='0' && c<='9'; c=getc())
		x = x * 10 + c - 48;
	x *= f;
}

#define mo(x) x=(x>=md?x-md:(x<0?x+md:x))
bool cmpw(int a, int b) { return w[a] < w[b]; }

int main() {
	// freopen("a.in", "r", stdin);
	// freopen("a.out", "w", stdout);

	in(n);
	rep(i, 1, n) {
		in(w[i]), in(v[i]);
		vc[i] = v[i];
	}

	sort(vc+1, vc+1+n);
	vn = unique(vc+1, vc+1+n) - (vc+1);

	rep(i, 1, n) v[i] = LB(vc+1, vc+1+vn, v[i]) - vc;

	rep(i, 1, n) od[i] = i;
	sort(od+1, od+1+n, cmpw);

	int mxv = 0, x;
	rep(i, 1, n) {
		x = od[i];
		v[x] > mxv ? mxv = v[x] : 233;
		r[x] = mxv;
	}

	mxv = vn + 1;
	vep(i, n, 1) {
		x = od[i];
		v[x] < mxv ? mxv = v[x] : 233;
		l[x] = mxv;
	}

	// rep(i, 1, n) cout << l[i] << ' ' << r[i] << endl;
	int sm = 0, hd = 0, tp = 0;

	l[0] = 1, r[0] = 0;
	f[0] = 1, sk[tp++] = 0, sm = 1;

	++ n, l[n] =r[n] = n;
	od[n] = n;

	rep(i, 1, n) {
		x = od[i];
		while (hd < tp && l[x] > r[sk[hd]]+1)
			sm = sm-f[sk[hd]], mo(sm), ++hd;
		f[x] = sm;
		sm = sm + f[x], mo(sm);
		sk[tp ++] = x;
	}

	printf("%d\n", f[n]);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);



int main(){
  int N;
  cin >> N;
  VI col(3,0);
  mint ans=1;

  REP(i,N){
    int a;
    cin >> a;
    bool ok=false;
    mint cnt=0;
    REP(j,3){
      if(col[j] == a){
        cnt+=1;
        if(cnt.x==1)col[j]++;
        ok=true;
      }
    }
    if(ok=false){
      cout << 0 << endl;
      return 0;
    }
    ans *= cnt;

  }
  cout << ans.x << endl;
}



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

struct Query {
	int e, s, i;

	bool operator<(const Query &rhs) const { return e < rhs.e; }
};

const int MAX = 500100;
int n, m;
int nums[MAX];
int answer[MAX];
int last[500100];
vector<int> tree;
vector<Query> queries;

void add(int p, int val) {
	while (p < tree.size()) {
		tree[p] += val;
		p += (p & -p);
	}
}

int sum(int p) {
	int ret = 0;
	while (p > 0) {
		ret += tree[p];
		p -= (p & -p);
	}

	return ret;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> nums[i];
	}

	tree.resize(n + 1);

	queries.resize(m);
	for (int j = 0; j < m; ++j) {
		queries[j].i = j;
		cin >> queries[j].s >> queries[j].e;
	}

	sort(queries.begin(), queries.end());

	int pos = 1;
	for (int k = 0; k < m; ++k) {
		while (pos <= queries[k].e) {
			if (last[nums[pos]]) {
				add(last[nums[pos]], -1);
			}

			add((last[nums[pos]] = pos), 1);
			pos++;
		}

		answer[queries[k].i] = sum(queries[k].e) - sum(queries[k].s - 1);
	}

	for (int l = 0; l < m; ++l) {
		cout << answer[l] << "\n";
	}

}


Measured memory_bytes: 17464
char W[9],V[9];Z[7*24*60],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.9f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?7:1;
		d=24*60*(*W=='A'?1:7);
		i=0;
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24*60;j++)Z[i*24*60+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12*60;j++)Z[(i*24+6)*60+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6*60;j++)Z[i*24*60+j]=Z[(i*24+18)*60+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k<24*60)l+=Z[(k+S)%(7*24*60)]&Z[k];
			k=(k+T)%(d);
		}
}exit(0);}

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

#define __INIT_CC__ ios::sync_with_stdio(false); \
	cin.tie(0);

#ifdef __WIN32__
	char getchar_unlocked() {return getchar();}
#endif

#define FOR(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<(_t);++(_i))
#define FORN(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<=(_t);++(_i))
#define FORD(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i>=(_t);--(_i))
#define RESET(_a,_value) memset(_a,_value,sizeof(_a))
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define mp make_pair
#define SIZE(_a) (int)_a.size()
#define VSORT(_a) sort(_a.begin(),_a.end())
#define SSORT(_a,_val) sort(_a,_a+(_val))
#define ALL(_a) _a.begin(),_a.end()
#define mt make_tuple
#define _get(_tuple,_i) get<_i>(_tuple)
#define eb emplace_back
 
using namespace std;

using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<ii>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vll = vector<ll>;
using pdd = pair<double,double>;
using vpdd = vector<pdd>;
template <typename T> using uset = unordered_set<T>;
template <typename T> using umultiset = unordered_multiset<T>;
template <typename K, typename V> using umap = unordered_map<K, V>;
template <typename K, typename V> using umultimap = unordered_multimap<K, V>;

const int dr[] = { 1, 0,-1, 0, 1, 1,-1,-1};
const int dc[] = { 0, 1, 0,-1, 1,-1,-1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const ll INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);

template <typename T> T take(queue<T> &O) {T tmp=O.front();O.pop();return tmp;}
template <typename T> T take(stack<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T> T take(priority_queue<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T>
inline bool inRange(const T& z, const T& a, const T& b){return a <= z && z <= b;}

void OPEN(const string& in = "input.txt", const string& out = "output.txt")
{
	freopen(in.c_str(), "r", stdin);
	freopen(out.c_str(), "w", stdout);
	return ;
}

//using sokokaleb's template v4.0

deque<int> DQ;
int n, a;
int rev;

vi ans;

int main(int argc, char** argv) {
	__INIT_CC__
	cin >> n;
	rev = 0;
	FOR (i, 0, n) {
		cin >> a;
		if (rev ^ 1) {
			DQ.pb(a);
		} else {
			DQ.pf(a);
		}
		rev ^= 1;
	}

	if (rev ^ 1) {
		ans.assign(DQ.begin(), DQ.end());
	} else {
		ans.assign(DQ.rbegin(), DQ.rend());
	}

	bool first = 1;
	for (const auto& a : ans) {
		if (first) first = 0;
		else cout << " ";
		cout << a;
	}
	cout << "\n";
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <regex>
using namespace std;
typedef long long ll;

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n, m;
	cin >> n >> m;
	cout << (n * n - m) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>

#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define FOR1(i,n)     for(ll i=1;i<=n;i++)
#define FORran(i,a,b) for(ll i=a;i<=b;i++)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;

int main()
{
    string s,t;
    ll sl,tl,cnt,ans=20000;
    cin>>s>>t;
    sl=s.length();
    tl=t.length();
    FOR(i,sl-tl+1)
    {
        cnt=0;
        FOR(j,tl)
        {
            if(s[i+j]!=t[j])
                cnt++;
        }
   //     cout<<cnt<<endl;
        ans=min(ans,cnt);
    }
    ptl(ans);
    return 0;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    rep(i, n) cout << s[i] ;
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const double EPS = 1e-9;
const int N = 1000000;

template <class T> T gcd(T a, T b) {
	if (b == 0) { return a; }
	return gcd(b, a % b);
}

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}



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

	int n;
	string s;
	cin >> n >> s;
	int l = 0, r = n - 1;
	int ans = 0;

	while (l < r) {
		if (s[l] == 'W'
			&& s[r] == 'R') {
			swap(s[l], s[r]);
			++ans;
		}
		if(s[l] == 'R') ++l;
		if(s[r] == 'W')  --r;
	}

	cout<<ans<<'\n';
}


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

int64_t dp[3300][3300];

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    rep(i,n) dp[i][i] = 0;
    for (int width = 1; width <= n; width++) {
        for (int lef = 0; lef + width <= n; lef++) {
            int rig = lef + width;
            if (width % 2 == n % 2) {
                dp[lef][rig] = max(dp[lef+1][rig] + a[lef], dp[lef][rig-1] + a[rig-1]);
            }
            else {
                dp[lef][rig] = min(dp[lef+1][rig] - a[lef], dp[lef][rig-1] - a[rig-1]);
            }
        }
    }
    cout << dp[0][n] << endl;
}

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

#include <bits/stdc++.h>
using namespace std;

/* TYPES */
#define long int64_t
#define all(v) v.begin(), v.end()
#define fs first
#define sc second
typedef pair<int,int> pii;
typedef pair<int64_t,int> pli;
typedef pair<int64_t,int64_t> pll;
typedef vector<int> vi;
typedef vector<int64_t> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<int64_t, int64_t> > vpl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<vector<int64_t> > vvl;

/* CONSTANTS */
const long P1 = 31, P2 = 37, MOD1 = 1e9+7, MOD2 = 1e9+9, LINF = 1e18 + 1e16;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

/* FUNCTIONS */
template<typename T, typename U> inline void setMin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void setMax(T &x, U y) { if(x < y) x = y; }
template<typename T>
inline T gcd(T a, T b) {
    T c;
    while(b) c = b, b = a % b, a = c;
    return a;
}
template<typename T>
inline T square(T a) { return a*a; }
inline long modPow(long b, long e, long mod) {
    if (e == 0) return 1ll;
    if (e == 1) return b;
    return modPow(b * b % mod, e >> 1, mod) * modPow(b, e & 1, mod) % mod;
}

class TaskE {

    int N;
    long P;

    vl gen_hashes (string s) {
        vl h(s.length() + 1);
        long p10 = 1;
        for (int i = s.length() - 1; i >= 0; --i) {
            h[i] = ((s[i] - '0') * p10 + h[i + 1]) % P;
            p10 *= 10;
            p10 %= P;
        }
        return h;
    }

    long calculate_combinations(vl proc_h) {
        unordered_map<long, int> cnt;
        long ans = 0;
        for (long h : proc_h) {
            ans += cnt[h];
            ++cnt[h];
        }
        return ans;
    }

public:
    void solve(istream &cin, ostream &cout) {
        cin >> N >> P;
        string s;
        cin >> s;
        long ans;
        if (P == 2 or P == 5) {
            long ans = 0;
            for (int i = 0; i < s.length(); i++) {
                if ((s[i] - '0') % P == 0) {
                    ans += i + 1;
                }
            }
            cout << ans << endl;
        } else {
            cout << calculate_combinations(gen_hashes(s)) << endl;
        }
    }
};


class Solver {
public:
    void solve(std::istream& in, std::ostream& out) {
        TaskE *obj = new TaskE();
        obj->solve(in, out);
        delete obj;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    Solver solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 2580
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
    while(true){
      String a = sc.next();
      if(a.equals("-")){break;}
      int n = sc.nextInt();
      for(int j=0;j<n;j++){
        int h = sc.nextInt();
        a = a.substring(h) + a.substring(0,h);
      }
      System.out.println(a);
}
    }
  }
}



Measured memory_bytes: 26748
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
int A,B,C,D;
int cou = 0;
cin >> A >> B >> C >> D;
if(A > B)cou += B;
else cou += A;
if(C > D)cou += D;
else cou += C;
cout << cou << endl;
        return 0;
}

Measured memory_bytes: 256
import itertools
N= input()
Number=int(N)
count=[]
x=0
n=3
count=0
def check (S):
    S=str(S)
    if S.count('3')!=0 and S.count('5')!=0 and S.count('7')!=0 and int(S)<=Number:
        return 1

def dfs(x):
    global count
    if check(x)==1:
        count+=1
    if x<=Number:
        dfs(10*x+3)
        dfs(10*x+5)
        dfs(10*x+7)


dfs(0)
print(count)


Measured memory_bytes: 3064
#include <cstdint>

#include <iostream>

template <std::uint_fast64_t MOD> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  ModInt(const u64 val = 0) { value = val % MOD; }

  bool operator==(const ModInt &rhs) const { return value == rhs.value; }
  bool operator!=(const ModInt &rhs) const { return !(*this == rhs); }
  bool operator<(const ModInt &rhs) const { return value < rhs.value; }
  bool operator>(const ModInt &rhs) const { return value > rhs.value; }
  bool operator<=(const ModInt &rhs) const { return !(*this > rhs); }
  bool operator>=(const ModInt &rhs) const { return !(*this < rhs); }

  ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }

  ModInt &operator+=(const ModInt rhs) {
    value += rhs.value;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator-=(const ModInt rhs) {
    if (value < rhs.value) {
      value += MOD;
    }
    value -= rhs.value;
    return *this;
  }

  ModInt &operator*=(const ModInt rhs) {
    value = value * rhs.value % MOD;
    return *this;
  }

  ModInt &operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }

  ModInt &operator++(int n) {
    value++;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator--(int n) {
    if (value == 0) {
      value += MOD;
    }
    value--;
    return *this;
  }

  ModInt inv() { return ModInt::pow(*this, MOD - 2); }

  static ModInt pow(ModInt base, long long int n) {
    ModInt res = ModInt(1);
    while (n) {
      if (n & 1) {
        res *= base;
      }
      base *= base;
      n /= 2;
    }
    return res;
  }

  static ModInt comb(ModInt n, ModInt r) { return comb(n.value, r.value); }

  static ModInt comb(int n, int r) {
    if (n < r)
      return ModInt(0);
    ModInt res = ModInt(1);
    for (int i = 0; i < r; i++) {
      res *= ModInt(n - i);
    }

    ModInt inv = ModInt(1);
    for (int i = 0; i < r; i++) {
      inv *= ModInt(r - i);
    }
    return res / inv;
  }

  u64 getValue() const { return value; }

private:
  u64 value;
};

// ここを問題ごとのMODに書き換える
using mint = ModInt<1000000007>;

std::ostream &operator<<(std::ostream &out, const mint &m) {
  out << m.getValue();
  return out;
};

std::istream &operator>>(std::istream &in, mint &m) {
  uint_fast64_t i;
  in >> i;
  m = mint(i);
  return in;
}

// verify https://atcoder.jp/contests/abc127/tasks/abc127_e
int main() {
  mint n, m, k;
  std::cin >> n >> m >> k;
  mint ans = mint(0);
  mint kumi = mint::comb(n * m - mint(2), k - mint(2));
  for (int d = 1; d < (int)n.getValue(); d++) {
    ans += (mint(d) * (n - mint(d)) * m * m * kumi);
  }
  for (int d = 1; d < (int)m.getValue(); d++) {
    ans += (mint(d) * (m - mint(d)) * n * n * kumi);
  }
  std::cout << ans << std::endl;
}


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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 2 && b % 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}



Measured memory_bytes: 256
#include <iostream>
     
    using namespace std;
     
    int main()
    {
    	long long a, b;
    	cin >> a >> b;
     
    	int cnt = 0;
     
    	while(a <= b)
    	{
    		cnt++;
    		a *= 2;
    	}
     
    	cout << cnt;
     
     
    	return 0;
    }


// #include <iostream>

// using namespace std;

// void try_cover(const string &s, int x)
// {

// }

// int main()
// {
// 	string s;

// 	cin >> s;

// 	int p = (1 << 20);
// 	int res = 0;

// 	while(p)
// 	{
// 		if(p + res <= s.size() && try_cover(s, p + res) == true)
// 		{
// 			res += p;
// 		}
// 		p /= 2;
// 	}

// 	cout << res << "\n";

// 	return 0;
// }

Measured memory_bytes: 256
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(a == b && b != c)  cout<<"Yes";
    else if(a == c && b != c)   cout<<"Yes";
    else if(b == c && b != a)   cout<<"Yes";
    else    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << "\n";
    return 0;
}

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

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }

  int sum = 0;
  for (int i = 0; i < N-1; i++) {
    if (t[i+1] > t[i] + T) {
      sum += T;
    } else {
      sum += t[i+1] - t[i];
    }
  }
  sum += T;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))

base = np.zeros(n)
for i in range(n):
  base[a[i]-1] += 1
  
seen = np.where(base>0,1,0)
num = np.sum(seen) - k

if num <= 0:
  ans = 0
elif num > 0:
  base.sort()
  count = 0
  ans = 0
  for i in range(n):
    if base[i] != 0:
      ans += base[i]
      count += 1
      
    if count == num:
      break
    
print(int(ans))

Measured memory_bytes: 34152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	string s, t;
	cin >> s >> t;
	int n = s.size();
	int ans = 0;
	rep(i, n) if (s[i] != t[i]) ans++;
	cout << ans << '\n';
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2")

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n, a = INT_MAX, count = 0;
	
	cin >> n;
	
	for(int k = 0; k < n; ++k) {
	
		int x;
		
		cin >> x;
		
		if(x < a) ++count;
		
		a = min(x, a);
	}
	
	cout << count << '\n';
	
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> V { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int K;
    cin >> K;

    cout << V.at(K - 1) << endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 200 + 6;

i64 n;
string s;

inline void ins(set<i64>& q, i64 v) {
    if (0 > v || v >= n) {
        return;
    }
    if (s[v] != 'B') {
        return;
    }
    q.insert(v);
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> s;

    i64 c = 0;
    for (i64 b = 0; b < n; b++) {
        if (s[b] != 'B') {
            continue;
        }
        c += 1;
    }

    i64 R = 0;
    for (i64 r = 0; r < n; r++) {
        if (s[r] != 'R') {
            continue;
        }
        for (i64 g = 0; g < n; g++) {
            if (s[g] != 'G') {
                continue;
            }
            set<i64> q;
            ins(q, r + abs(r - g));
            ins(q, r - abs(r - g));
            ins(q, g + abs(r - g));
            ins(q, g - abs(r - g));
            i64 t = (r + g) / 2;
            if (max(r, g) - t == t - min(r, g)) {
                ins(q, t);
            }
            R += c - q.size();
        }
    }

    cout << R << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<limits.h>
int main(){
    int a, b, c, d, e, k;
    int min, max;
    scanf("%d %d %d %d %d %d",&a, &b, &c, &d, &e, &k);
    min = max = a;
    if(b > max){
        max = b;
    }
    if(c > max){
        max = c;
    }
    if(d > max){
        max = d;
    }
    if(e > max){
        max = e;
    }
    if(b < min){
        min = b;
    }
    if(c < min){
        min = c;
    }
    if(d < min){
        min = d;
    }
    if(e < min){
        min = e;
    }
    if(max - min > k){
        printf(":(\n");
    }else{
        printf("Yay!");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int x, y, a,b,c, w;
    while(cin>>x>>y>>a>>b>>c){
        ll ans = 0 ;
        vector<pii> app;
        forn(i,a){
            cin>>w;
            app.push_back({w,1});
        }
        forn(i,b){
            cin>>w;
            app.push_back({w,2});
        }

        forn(i,c){
            cin>>w;
            app.push_back({w,3});
        }

        sort(all(app), [&](pii &p1, pii &p2){
            return p1.first>p2.first;
        });
        // for(auto x: app)
            // cout<<x.first<<" "<<x.second<<endl;
        

        ll sum = 0;
        int t = x+y;
        // deb2(a,b);
        // deb(t);
        int ca(0), cb(0), co(0);
        for(int i=0; i<app.size(); ++i){
            int cur_c = app[i].second;
            int cur_v = app[i].first;
            
            if(cur_c == 1 && ca<x){
                sum+=cur_v; ca++; 
                // deb3(cur_v, cur_c,ca);
                --t;
            }else if(cur_c==2 && cb<y){
                sum+=cur_v; cb++;
                --t;
                // deb3(cur_v, cur_c,cb);
            }else if(cur_c==3){

                sum+=cur_v; co++;
                --t;
                // deb3(cur_v, cur_c, co);
            }

            

            if(t==0) break;
        }
        cout<<sum<<endl;
    } 
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020];
set<ll> st;
ll i,j,k;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        if(st.find(A[i])!=st.end())
            break;
        st.insert(A[i]);
    }
    if(i==N){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <climits>
#include <stack>
#include <string>
#include <random>
#include<set>
#include <iomanip>
#include <climits>
long long int min(const std::vector<int> &series, const int left, const int right, std::vector<std::vector<long long int>> &memo);
long long int max(const std::vector<int> &series, const int left, const int right, std::vector<std::vector<long long int>> &memo) {
	if (left == right) {
		return series[left];
	}
	else if (memo[left][right - left] != LLONG_MIN) return memo[left][right - left];
	else {
		return memo[left][right - left] = std::max(min(series, left + 1, right, memo) + series[left], min(series, left, right - 1, memo) + series[right]);
	}
}
long long int min(const std::vector<int> &series, const int left, const int right, std::vector<std::vector<long long int>> &memo) {
	if (left == right) {
		return -series[left];
	}
	else {
		return std::min(max(series, left + 1, right, memo) - series[left], max(series, left, right - 1, memo) - series[right]);
	}
}
long long int solve(const std::vector<int> &series) {
	std::vector<std::vector<long long int>> memo(series.size());
	for (auto i = 0; i < memo.size(); ++i) {
		memo[i] = std::vector<long long int>(series.size() - i, LLONG_MIN);
	}
	return max(series, 0, series.size() - 1, memo);
}
int main() {
	int n; std::cin >> n;
	std::vector<int> series(n);
	for (auto &s : series) std::cin >> s;
	std::cout << solve(series) << std::endl;
}

Measured memory_bytes: 35712