akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll x;
  cin >> x;

  ll ans = x / 11 * 2;
  x %= 11;

  if (x != 0) {
    if (x <= 6) {
      ans += 1;
    } else {
      ans += 2;
    }
  }

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


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

int main() {
  int m, n;
  while(cin >> m >> n){
    if(m==0) return 0;
    bool num[8000000]={};

    rep(i, n){
      while(num[m]==1) m++;
      for(int j=1; j*m<8000000; j++){
        num[j*m] = true;
      }
    }
    while(num[m]==1) m++;
    cout << m << endl;
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    int m=1;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(m==a[i]){
            m++;
        }
    }
    int ans = n-m+1;
    
    if(n == ans){
        ans = -1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> A(N + 1, 0);
  copy_n(istream_iterator<int>(cin), N, next(begin(A)));
  for (int i = 0; i < N; ++i) A[i + 1] = (A[i + 1] + A[i]) % K;
  for (int i = 0; i < N + 1; ++i) { 
  	A[i] -= i % K;
  	while (A[i] < 0) A[i] += K;
  }
  map<int, int> m;
  long long ans = 0;
  for (int i = 0; i < N + 1; ++i) {
  	if (i >= K) --m[A[i - K]];
  	auto& r = m[A[i]];
  	ans += r;
  	++r;
  }
  cout << ans << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll N,M; cin>>N>>M;
  vector<ll> H(N); rep(i,N)cin>>H[i];

  vector<ll> goodtower(N); rep(i,N)goodtower[i]=1;

  rep(i,M) {
    ll A,B; cin>>A>>B;
    --A;--B;
    if(H[A]<=H[B])goodtower[A]=0;
    if(H[A]>=H[B])goodtower[B]=0;
  }

  ll res = 0;
  rep(i,N)if(goodtower[i]==1)++res;

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 4784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		for(int i=0;i<N;i++) {
			ans  += sc.nextInt()-1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int tt;
int head[N],to[N*2],nxt[N*2],la[N],ans[N],f[N][11],g[N][11];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m,q;
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
	int x=gi(),y=gi();
	to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
	to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
    }
    cin>>q;
    for(int i=1;i<=q;i++) {
	int x=gi(),y=gi(),z=gi();
	g[x][y]=i,f[x][y]=z;
    }
    for(int t=10;~t;t--)
	for(int x=1;x<=n;x++)
	    if(g[x][t]) {
		if(g[x][t]>la[x]) la[x]=g[x][t],ans[x]=f[x][t];
		if(!t) continue;
		for(int i=head[x];i;i=nxt[i]) {
		    int y=to[i];
		    if(g[y][t-1]<g[x][t])
			g[y][t-1]=g[x][t],f[y][t-1]=f[x][t];
		}
	    }
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}

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

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

  bool conne = false;
  int hit=0;

  for(int i=0;i<count;++i){
    int i1, i2;
    cin >> i1 >> i2;
    if(i1 == i2){
      hit++;
    }else{
      hit=0;
    }
    if(hit == 3){
      conne = true;
    }
  }
  if(conne){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int u,v;
    int64 c;
}E[MAXN * 2]; 
int N,Q,tot;
int64 val[MAXN * 2];
int fa[MAXN];
int getfa(int x) {
    return x == fa[x] ? x : fa[x] = getfa(fa[x]);
}
void Solve() {
    read(N);read(Q);
    int a,b;int64 c;
    for(int i = 0 ; i < 2 * N ; ++i) val[i] = 1e18;
    for(int i = 1 ; i <= Q ; ++i) {
	read(a);read(b);read(c);
	E[++tot] = (node){a,b,c};
	val[a] = min(val[a],c + 1);
	val[b] = min(val[b],c + 2);
    }
    for(int i = 1 ; i < 2 * N ; ++i) {
	val[i] = min(val[i - 1] + 2,val[i]);
    }
    for(int i = 0 ; i < N ; ++i) {
	E[++tot] = (node){i,(i + 1) % N,min(val[i],val[i + N])};
    }
    sort(E + 1,E + tot + 1,[](node a,node b){return a.c < b.c;});
    for(int i = 0 ; i < N ; ++i) fa[i] = i;
    int64 ans = 0;
    for(int i = 1 ; i <= tot ; ++i) {
	if(getfa(E[i].u) != getfa(E[i].v)) {
	    fa[getfa(E[i].u)] = getfa(E[i].v);
	    ans += E[i].c;
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 13568
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long A,B,X;cin >> A >> B >> X;
    long long a = (A-1)/X + 1;
    if(A == 0) a = 0;
    long long b = B/X + 1;
    cout << b-a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


ll inf = 1000000000000000;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m),b(m);
	vector<int> c(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i);
		rep(j,b.at(i)){
			int k;cin >> k;
			c.at(i) |= (1 << (k - 1));
		}
	}
	vector<vector<ll>> dp(m+1,vector<ll>((1<<n),inf));
	dp[0][0] = 0;
	rep(i,m){
		rep(j,(1<<n)){
			dp[i + 1][j | c.at(i)] = min(dp[i + 1][j | c.at(i)], dp[i][j] + a.at(i));
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	if(dp[m][(1<<n)-1] == inf) cout << -1 << endl;
	else cout << dp[m][(1<<n)-1] << endl;
}


Measured memory_bytes: 32384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	map<int, int> M;
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		M[A[i]]++;
	}
	string ans = "YES";
	for (auto num : M) {
		if (num.second >= 2) ans = "NO";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13488
# Ref: https://atcoder.jp/contests/practice2/submissions/16814531
class SegTree():
    def __init__(self, a, func, idem):
        # the number of nodes is 2n - 1
        self.n = 1 << len(a).bit_length()
        self.size = len(a)
        self.func = func
        self.idem = idem # Identity element
        self.node = [idem] * (2 * self.n - 1)
        for i in range(len(a) + self.n - 2, -1, -1):
            if i >= self.n - 1:
                self.node[i] = a[i - self.n + 1]
            else:
                self.node[i] = self.func(self.node[2 * i + 1], self.node[2 * i + 2])
            
    def get(self, x):
        return self.node[x + self.n - 1]

    def set(self, x, val):
        x += self.n - 1
        self.node[x] = val
        while x > 0:
            x = (x - 1) >> 1
            self.node[x] = self.func(self.node[2*x+1], self.node[2*x+2])
        return
    
    def prod(self, l, r):
        L, R = l + self.n, r + self.n
        s_l, s_r = self.idem, self.idem
        while L < R:
            if R & 1:
                R -= 1
                s_r = self.func(self.node[R-1], s_r)
            if L & 1:
                s_l = s_l = self.func(s_l, self.node[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return self.func(s_l, s_r)

    def max_right(self, l, val):
        if l == self.size:
            return self.size
        L = l + self.n
        s = self.idem
        while 1:
            while L % 2 == 0:
                L >>= 1
            if not val(self.func(s, self.node[L - 1])):
                while L < self.n:
                    L <<= 1
                    if val(self.func(s, self.node[L-1])):
                        s = self.func(s, self.node[L-1])
                        L += 1
                return L - self.n
            s = self.func(s, self.node[L - 1])
            L += 1
            if (L & -L) == L:
                return self.size

    def min_left(self, r, val):
        if r == 0:
            return 0
        R = r + self.n
        s = self.idem
        while True:
            R -= 1
            while R > 1 and R % 2:
                R >>= 1
            if not val(self.func(self.node[R - 1], s)):
                while R < self.n:
                    R = (R << 1) + 1
                    if val(self.func(self.node[R - 1], s)):
                        s = self.func(self.node[R - 1], s)
                        R -= 1
                return R + 1 - self.n
            s = self.func(self.node[R - 1], s)
            if (R & -R) == R:
                return 0
            
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
A = list(map(int, input().split()))
st = SegTree(A, max, 0)
for _ in range(Q):
    t, x, y = map(int, input().split())
    if t == 1:
        st.set(x - 1, y)
    elif t == 2:
        print(st.prod(x - 1, y))
    else:
        print(st.max_right(x - 1, lambda z : z < y) + 1)

Measured memory_bytes: 95616
void main() {
    int x = readln.chomp.to!int;
    writeln(x == 7 || x == 5 || x == 3 ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll n,k;cin>>n>>k;
    ll a[n],b[n];
    ll c[500010];memset(c,0,500005);
    rep(i,0,n-1){
        cin>>a[i]>>b[i];
        c[a[i]]+=b[i];
    }
    ll an=0;
    rep(i,1,100000){
        an+=c[i];
        if(an>=k){
            cout<<i<<endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3072
var
m,n,i,j,k,x,y,z:longint;
s,t,r:ansistring;
begin
    readln(s);
    t:=s;
    for i:=2 to length(s) do
    begin
        if s[i]=t[i-1] then
        s[i]:='Q';
    end;
    x:=0;
    for i:=1 to length(s) do
    if s[i]='Q' then
    inc(x);
    writeln(length(s)-1-x);
end.

Measured memory_bytes: 384
import math
import sys
input = sys.stdin.readline
import heapq
def main():
    N,D,A=map(int,input().split())
    xh = [tuple(map(int,input().split())) for _ in range(N)]
    xh = sorted(xh, key = lambda x:x[0])
    x = [elem[0] for elem in xh]
    h = [elem[1] for elem in xh]
    res = 0
    buff = 0
    q = []
    heapq.heapify(q)
    for (X, H) in zip(x, h):
        while len(q)!=0:
            p = heapq.heappop(q)
            if p[0] < X:
                buff -= p[1]
            else:
                heapq.heappush(q,p)
                break
        nowhp = H - buff*A
        if nowhp <= 0:
            continue
        cnt = math.ceil(nowhp/A)
        res += cnt
        buff += cnt
        ins = (X+2*D, cnt)
        heapq.heappush(q,ins)
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 115624
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    s=parseMap(split(readline(),'/'))
    if s[1]<2019 || (s[2]<=4 && s[3]<=30)
        println("Heisei")
    else
        println("TBD")
    end
end
main()

Measured memory_bytes: 115756
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        long sum = 0;
        for(int i=0; i<a.length; i++) {
            if(i == a.length-1) break;
            if(a[i] > a[i+1]) {
                sum += a[i] - a[i+1];
                a[i+1] = a[i+1] + (a[i] - a[i+1]);
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 60092
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    mp[a[i]]++;
  }

  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = n-1; i >= 0; i--){
    if(mp[a[i]] == 0) continue;
    mp[a[i]]--;
    int Max = 2;
    while(Max <= a[i]) Max *= 2;
    auto p = *lower_bound(a.begin(),a.end(),Max - a[i]);
    if(p != Max - a[i] || mp[p] == 0) continue;
    mp[p]--;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14336
import math
a,b,kakudo = map(float,input().split())


c2 = a ** 2 + b ** 2 - 2*a*b*math.cos(math.radians(kakudo))
c = math.sqrt(c2)

S = a*b/2*math.sin(math.radians(kakudo))
L = a+b+c
h = S*2/a

print(S)
print(L)
print(h)



Measured memory_bytes: 5688
n, k = list(map(int, input().split()))
xs = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for y in a:
        xs[y - 1] += 1

print(sum([1 if x == 0 else 0 for x in xs]))


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

using uli = unsigned long int;
using lli = long long int;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define repa(a,i,x) for(int i=a;i<=x;i++)

int main(){
	int N,K;
	cin >> K >> N;
	
	int A[N];
	rep(i,N)cin>>A[i];
	
	int sub=0;
	repn(i,N-1){
		if(sub<A[i]-A[i-1])sub=A[i]-A[i-1];
	}
	if((K-A[N-1]+A[0])>sub)sub=K-A[N-1]+A[0];
	cout << K-sub << endl;
	
}

Measured memory_bytes: 1024
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int arr[100100];
multiset<int> ms;
multiset<int>::iterator it;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
        if(i == 1)
        {
            ms.insert(arr[i]);
        }
        else
        {
            it = ms.lower_bound(arr[i]);
            if(it == ms.begin())
            {
                ms.insert(arr[i]);
            }
            else
            {
                it--;
                ms.erase(it);
                ms.insert(arr[i]);
            }
        }
    }
    ans = (int)ms.size();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    ll N; cin>>N;
    string S; cin>>S;
    ll ans=0;
    char memory='!';
    for(int i=0;i<N;i++){
        if(S.at(i)!=memory) {ans++; memory=S.at(i);}
    }
    cout<<ans<<endl;


} 


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
    int a,b,i,d1,d2,d4,d5,cnt=0;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++){
        d5=i/10000;
        d4=(i%10000)/1000;
        d2=(i%100)/10;
        d1=i%10;
        if(d5==d1 && d4==d2){
            cnt++;
            //printf("%d %d %d %d %d\n",i,d5,d4,d2,d1);
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

using namespace std;

int n;
int b[110];
int main() {

    cin >> n;

    for (int i = 1; i < n; ++i) cin >> b[i];
    
    b[0] = b[n] = 1e9;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += min(b[i], b[i - 1]);
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int s,w;
    cin>>s>>w;
    cout<<(s>w?"safe":"unsafe")<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
int comp(string& a, string& b) {
  if(a.size() < b.size()) return 0;
  if(a.size() > b.size()) return 2;
  if(a < b) return 0;
  if(a > b) return 2;
  return 1;
}

int main() {
  string a, b;
  cin >> a >> b;
  const char* str[] = {"LESS", "EQUAL", "GREATER"};
  cout << str[comp(a, b)] << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  map<char,int>m;
  for(auto it:s)m[it]++;
  bool ok=true;
  if(m['N']==0&&m['S']!=0)ok=false;
  if(m['S']==0&&m['N']!=0)ok=false;
  if(m['W']==0&&m['E']!=0)ok=false;
  if(m['E']==0&&m['W']!=0)ok=false;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static String s;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.nextLine();
		sc.close();
		
		if("".equals(s)) {
			System.out.println("Cat");
			return;
		}
		
		boolean flag = true;
		while(flag) {
			flag = mewmew();
		}
		
		System.out.println(s.equals("@") ? "Cat" : "Rabbit");
		
	}
	
	public static boolean mewmew() {
		
		if(s.contains("mew")) {
			s = s.replaceAll("mew", "@");
			return true;
		}

		if(s.contains("m@e@w")) {
			s = s.replaceAll("m@e@w", "@");
			return true;
		}
		
		if(s.contains("m@ew")) {
			s = s.replaceAll("m@ew", "@");
			return true;
		}
		
		if(s.contains("me@w")) {
			s = s.replaceAll("me@w", "@");
			return true;
		}
		
		return false;
	}

}



Measured memory_bytes: 27352
#include<bits/stdc++.h>
using namespace std;
long long p,q,s,r,n;
int main()
{
    scanf("%d",&n); r=2e9;
    for (int i=0;i<n;i++)
    {
        scanf("%d%d",&p,&q);
        s+=p;if (p>q) r=min(r,q);
    }
    if (r<2e9) cout << s-r << endl; else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int sum=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3912
a, b, c, d, e, f = map(int, input().split())

a *= 100
b *= 100

#取りうる水の値をリスト化
wat = 0
wat_list = []
for i in range(f//a+1):
    for j in range(f//b+1):
        wat = a*i+b*j
        if 0 < wat <= f:
            wat_list.append(wat)

#水の量に対して砂糖の量をリストで計算
sug = 0
sug_max = 0
sug_list = []
conc_list = []
sug_wat_list = []
for k in wat_list:
    sug_max = k//100 * e
    for l in range(sug_max // c + 1):
        for m in range(sug_max //d + 1):
            sug = c*l+d*m
            if 0<= sug <= sug_max and k+sug <= f: #溶けること＋溢れないこと
                sug_list.append(sug)
                conc_list.append(sug/(sug+k)*100)
                sug_wat_list.append(sug+ k)

idx = conc_list.index(max(conc_list))
print(sug_wat_list[idx], sug_list[idx])

Measured memory_bytes: 80208
let a, b = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))
 
let () = if a mod 3 = 0 || b mod 3 = 0 || (a+b) mod 3 = 0 then
  print_endline "Possible"
else
  print_endline "Impossible"

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#define all(x) (x).begin(), (x).end()
#define MAX_N 101000
#define MAX_M 101000
using namespace std;
typedef long long ll;

int main() {
  ll N, M;
  scanf("%lld%lld", &N, &M);
  vector<ll> City[MAX_N];
  ll P[MAX_M], Y[MAX_M];
  for (int i = 0; i < M; i++) {
    scanf("%lld%lld", &P[i], &Y[i]);
    City[P[i]].push_back(Y[i]);
  }

  for (int i = 0; i < N; i++) sort(City[i + 1].begin(), City[i + 1].end());

  for (int i = 0; i < M; i++) {
    /*
    cout << setfiint('0') << right << setw(6) << P[i] << setfiint('0') << right
     << setw(6) << iter - City[P[i]].begin() << endl;
    */
    printf("%012lld\n",
           P[i] * 1000000 +
               int(upper_bound(all(City[P[i]]), Y[i]) - City[P[i]].begin()));
  }

  return 0;
}


Measured memory_bytes: 8576
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;
int main(){
    int X,Y;
    cin>>X>>Y;
    bool ans=false;
    for(int i=0;i<=X;i++){

            if(2*i+4*(X-i)==Y){ans=true;break;}
    }
    
    if(ans)cout<<"Yes";
    else cout<<"No";
return 0;
}

Measured memory_bytes: 3132
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

ll power(ll a, ll b){
  ll ans = 1;
  if(b%2==0){
    REP(i, b/2){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans;
  }else{
    b = b/2;
    REP(i, b){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans* a;
  }
}
int main(void){
  
  ll n;
  cin>>n;
  ll sum = 1;
  int piv = 0;

  REP(i, n){
    ll x;
    cin>>x;
    if(x==0){
      cout<<"0"<<endl;
      return 0;
    }

    if(log10(sum) + log10(x)>18.0){
      //cout<<log10(sum) + log10(x)<<endl;
      piv =1;
    }else sum *= x;
    //cout<<sum<<" "<<x<<endl;
  }
  if(piv==1 || sum>1000000000000000000) cout<<"-1"<<endl;
  else cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3868
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    double pi=3.14159;

double r;cin>>r;
cout<<2*pi*r<<endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  int A[300][300];
  int B[300][300];
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      std::cin >> A[i][j];
      B[i][j] = A[i][j];
    }
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) { continue; }
      for (int k = 0; k < N; ++k) {
        if (j == k) { continue; }
        if (A[i][j] + A[j][k] < A[i][k]) {
          std::cout << -1 << std::endl;
          return 0;
        }
        if (A[i][j] + A[j][k] == A[i][k]) {
          B[i][k] = 0;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      ans += B[i][j];
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int n,x,t; cin >> n >> x >> t;

    int cur = 0;
    for(int i=1;i<=10000;i++){
        if(i*x>=n){
            cout << i*t << "\n";
            return 0;
        }
    }



}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void){
	int n;
	int a[20], b[20], c[19];
	int sum=0;
	
	scanf("%d",&n);
	
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	for(int j=0; j<n; j++){
		scanf("%d", &b[j]);
	}
	
	for(int s=0; s<n-1; s++){
		scanf("%d", &c[s]);
	}
	
	for(int t=0; t<n; t++){
		sum += b[a[t]-1];
		
		if(a[t] - 1 == a[t-1]){
			sum += c[a[t-1]-1];
		}
	}
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#define rep(i,n) for(int i = 0; i < (long int)n; i++)
typedef long long ll;
using namespace std;

int main(){
  int x,a;
  cin >> x >> a;
  x < a ? cout << "0": cout << "10";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, A[100];
int solve(int i, int m);

int main(){
 	int i, m, N;
  	scanf("%d", &n);
  	for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  	scanf("%d", &m);
  	for ( i = 0; i < m; i++ ) {
    	scanf("%d", &N);
    	if ( solve(0, N) ) printf("yes\n");
    	else printf("no\n");
  	}
  	return 0;
}

int solve(int i, int m){
	if(m == 0) return 1;
  	if ( i >= n ) return 0;
  	if ( A[i] == m ) return 1;
  	if ( solve(i+1, m) || solve(i+1, m-A[i]) ) return 1;
  
  	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
	int N;
	cin >> N;
	ll count = 0;

	for (int i =1; i < N; i++) {
		for (int j = 1; j < (N - 1) / i + 1; j++) {
			if(i*j<=N-1){
				count++;
			}
			else { break; }
		}
	}

	cout << count << endl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  V<int> a(n);
  rep(i,n) cin >> a[i];
  sort(rall(a));
  priority_queue<int> q;
  q.push(a[0]);
  ll ans = 0;
  REp(i,n) {
    ans += q.top(); q.pop();
    rep(ci,2) q.push(a[i]);
  }
  cout << ans << endl;
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    if (A + K - 1 >= B - K + 1) {
        for (int i=A; i<=B; ++i) {
            cout << i << endl;
        } return 0;
    } else {
        for (int i=A; i<A+K; ++i) {
            cout << i << endl;
        }
        for (int i=B-K+1; i<=B; ++i) {
            cout << i << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

ll mod = 1e9 + 7;

void
solve() {
  string s;
  ll d;
  cin>>s>>d;

  vector<ll> dp(105, 0), temp(105, 0);
  ll last = 0, n = s.length();
  for (ll i=0; i<n; i++) {
    temp = vector<ll>(105, 0);
    if (i==0) {
      for (ll j=0; j<s[i]-'0'; j++) temp[j%d]++;
    }
    else {
      for (ll j=0; j<10; j++) {
        if (j < s[i]-'0') { 
          temp[(j+last)%d]++;
          temp[(j+last)%d] %= mod;
        }
        for (ll k=0; k<d; k++) {
          temp[(j+k)%d] += dp[k];
          temp[(j+k)%d] %= mod;
        }
      }
    }
    swap(dp, temp);
    last += s[i] - '0';

    //for (auto k : dp) cout<<k<<","; cout<<endl;
  }
  dp[last % d]++;
  cout<<(dp[0]-1 + mod) % mod<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map
#define mtv(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out( 
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cout << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    stringstream ss; ss << H;
    cout << args[idx] << "- " << ss.str() << ", ";
    debug_out(args, idx + 1, LINE_NUM, T...);
}


void doit(){
	ll n,i,x;
	cin >> n;
	vector< ll >v(n+2);
	rep(i,0,n-1){
		cin >> x;
		v[x] += 1;
	}
	rep(i,1,n+1)cout << v[i] << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4800
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	int n;
	cin >> n;
	int ma = INF;
	int cut = 0;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		if (ma > a) cut++;
		chmin(ma, a);
	}
	print(cut);
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll count = 0;
  rep(i, n-2) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import sys, heapq

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()

ln = a[0:n]
rn = [-x for x in a[2*n: 3*n]]
heapq.heapify(ln)
heapq.heapify(rn)
ls = sum(ln)
rs = sum(rn)

lb = [ls]
rb = [rs]
for i in range(1, n+1):
    heapq.heappush(ln, a[n-1+i])
    vl = heapq.heappop(ln)
    ls = ls - vl + a[n-1+i]
    lb.append(ls)

    heapq.heappush(rn, -a[2*n-i])
    vr = heapq.heappop(rn)
    rs = rs - vr - a[2*n-i]
    rb.append(rs)

ans = -float('inf')
for i in range(n+1):
    ans = max(ans, lb[i] + rb[n-i])

print (ans)

Measured memory_bytes: 39516
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS


ll mod = 1e9+7;
void solve(){
	int n;
	cin>>n;
	ll ans = 1;
	for(ll i=1;i<=n;i++){
		ans *= i;
		ans %= mod;
	}
	cout<<ans<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<"\n";
}

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

	int t=1;       
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define  ll long long int 
#define pb push_back 

ll arr[2][10000001]  , visi[2][1000000] ;
vector<ll> grr ;
ll  n ;

ll find(ll i , ll k) 
{
    if(visi[i][k]==1)
    {
        return arr[i][k] ;
    }
    
    
ll set = (i+1)%2 ;
for(ll j=0 ; j < n && grr[j] <= k ; j++)
{
    if(find((i+1)%2, k-grr[j]) == i )
    {
        set = i ;
        break ;
    }
}
arr[i][k] = set ;
visi[i][k] =1 ;
return set ;
    
    
}





int main()
{
    ll k ;
    cin >>n >> k ;
    for(ll i =0 ; i < n ;i++)
    {
        ll j ;
        cin>> j;
        grr.pb(j) ;
    }
    sort(grr.begin() , grr.end()) ;
    if(find(1 , k)==1)
    {
        cout<<"First" ;
    }else
    {
        cout<<"Second" ;
    }
    
    return 0 ;
    
 }

Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

struct edge{ ll to; ll num; };
void mainsolve(){
	ll n;
	cin >> n;

	vector<vector<edge>> to(n);
	rep(i,n-1){
		ll a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(edge{b,i});
		to[b].push_back(edge{a,i});
	}

	ll m;
	cin >> m;
	vector<P> ms(m);
	rep(i,m){
		ll u,v;
		cin >> u >> v;
		--u; --v;
		ms[i] = P(u,v);
	}

	vector<ll> memo1(m); // 制約mのパスで通る辺をmemo
	rep(i,m){
		// まずdepthを作成
		vector<ll> depth(n,-1);
		queue<ll> q;

		depth[ms[i].first] = 0;
		q.push(ms[i].first);
		while (!q.empty()) {
			ll cur_v = q.front();
			q.pop();
			for (edge e : to[cur_v]) {
				ll next_v = e.to;
				if (depth[next_v] == -1) {
					depth[next_v] = depth[cur_v] + 1;
					q.push(next_v);
				}
			}
		}

		// 次に、逆順にたどる
		q.push(ms[i].second);
		while (!q.empty()) {
			ll cur_v = q.front();
			if(depth[cur_v] == 0) break;
			q.pop();
			for (edge e : to[cur_v]) {
				ll next_v = e.to;
				if (depth[next_v] == depth[cur_v] - 1) {
					// 浅い方向に戻っていく。戻る際、通る辺をmemo
					q.push(next_v);
					memo1[i] |= (1ll<<(e.num));
					break;
				}
			}
		}		
	}


	vector<ll> memo(1<<m); // ビットで制約集合を管理。白く塗られる辺の本数が値になる。
	rep(i,1<<m){
		ll tmp = 0;
		rep(j,m){
			if((i>>j) & 1) tmp |= memo1[j];
		}

		memo[i] = __builtin_popcountll(tmp); 
	}

	ll cnt = 0; // 補集合の個数
	rep(i,1<<m){
		if(i==0) continue;

		ll bits = __builtin_popcountll(i);
		if(bits%2 == 1){
			cnt += (1ll<<(n-1-memo[i])); // n-1本から白であることが確定している本数を引く
		}
		else{
			cnt -= (1ll<<(n-1-memo[i]));
		}
	}

	cout << (1ll<<(n-1)) - cnt << endl; // 全集合から補集合を引く
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
#endif

    string s, t;
    cin >> s >> t;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] != t[i]) {
            ++ans;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
string s;
cin>>s;
if (s=="ABC")cout<<"ARC";
else if (s=="ARC")cout<<"ABC";


    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int main(){
    string s;cin>>s;int sum=0;
    for(int i=0;i<s.length();i++){
        int x=s[i]-'0';
        sum+=x;
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
} 

Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{
    
    class Program
    {

        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int cnt = 0;
            for(int i = 0; i < S.Length / 2; i++)
            {
                if (S[i] != S[S.Length - i - 1]) cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
	int n, m;
	int acc = 0;
	cin >> n >> m;
	unordered_map<int, long> mp;
	mp[0] = 1;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		acc = (acc + a) % m;
		int mod = acc % m;
		mp[mod]++;
	}
	long ans = 0;
	for(auto it = mp.begin(); it != mp.end(); ++it) {
		long k = it->second;
		ans += k * (k - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  set<int> quantity;
  for(int i = 0; i < n; i++){
    quantity.insert(d[i]);
  }
  
  cout << quantity.size() << endl;
  return 0;
}

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

#define ll long long

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

  for(int i=0; i<k; ++i) s+=p[i];
  cout << s;
}

Measured memory_bytes: 3560