akhauriyash/Code-Regression huggingface dataset:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
ans = 0
if 1 in A:
    num = A.index(1)
    ans += num
    A = A[num:]
else:
    print(-1)
    exit()
f = 0
#print(A,ans)
for i in range(2,n+1):
    try:
        d = A.index(i,f)
    except AttributeError:
        ans += len(A[f+1:])
        print(ans)
        exit()
    except ValueError:
        ans += len(A[f+1:])
        print(ans)
        exit()
    ans += d - f - 1
    f = d
print(ans)

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

struct StarrySkyTree{
	int seg;
	vector<int> segMin,segAdd;
	StarrySkyTree(int n) : seg(1){
		while(seg < n) seg *= 2;
		segMin.resize(seg * 2 - 1);
		segAdd.resize(seg * 2 - 1);
	}
	inline int getDat(int k){ return segMin[k] + segAdd[k]; }
	void add(int a,int b,int x,int k = 0,int l = 0,int r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(b <= l || r <= a) return;
		if(a <= l && r <= b){
			segAdd[k] += x;
			return;
		}
		add(a,b,x,k * 2 + 1,l,(l + r) / 2);
		add(a,b,x,k * 2 + 2,(l + r) / 2,r);
		segMin[k] = min(getDat(k * 2 + 1),getDat(k * 2 + 2));
	}
	int find(int x){
		int k = 0,l = 0,r = seg,sum = 0;
		while(r - l > 1){
			sum += segAdd[k];
			if(getDat(k * 2 + 2) + sum < x){
				k = k * 2 + 2;
				l = (l + r) / 2;
			}else{
				k = k * 2 + 1;
				r = (l + r) / 2;
			}
		}
		return l;
	}
};

string s;
set<int> rs;

void flip(int x,StarrySkyTree &seg){
	if(s[x] == '('){
		s[x] = ')';
		seg.add(x + 1,-1,-2);
		rs.insert(x);
	}else{
		s[x] = '(';
		seg.add(x + 1,-1,2);
		rs.erase(x);
	}
}

signed main(){
	int n,q;
	cin >> n >> q >> s;
	StarrySkyTree seg(n + 1);
	for(int i = 0;i < n;i++){
		if(s[i] == '(') seg.add(i + 1,-1,1);
		else{
			seg.add(i + 1,-1,-1);
			rs.insert(i);
		}
	}
	for(int i = 0;i < q;i++){
		int x,ans;
		cin >> x; x--;
		flip(x,seg);
		if(s[x] == ')') ans = *rs.begin();
		else ans = seg.find(2);
		flip(ans,seg);
		cout << ans + 1 << endl;
	}
}


Measured memory_bytes: 18468
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let d: u64 = input();
    match d {
        25 => println!("Christmas"),
        24 => println!("Christmas Eve"),
        23 => println!("Christmas Eve Eve"),
        22 => println!("Christmas Eve Eve Eve"),
        _ => println!("No")
    }
}


Measured memory_bytes: 2120
import sys
import fractions
input=sys.stdin.readline

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

ans = t[0]
for i in t:
    ans = lcm(ans, i)

print(ans)


Measured memory_bytes: 5048
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        l = sorted(list(map(int, input().split())))
        even = 0
        for i in range(3):
            if l[i] % 2 == 0:
                even += 1
        cnt = 0
        if even == 0 or even == 3:
            for i in range(3):
                cnt += (l[2]-l[i])//2
            return cnt
        elif even == 1:
            cnt += 1
            for i in range(3):
                if l[i] % 2 == 1:
                    l[i] += 1
            for i in range(3):
                cnt += (max(l)-l[i])//2
            return cnt
        else:
            cnt += 1
            for i in range(3):
                if l[i] % 2 == 0:
                    l[i] += 1
            for i in range(3):
                cnt += (max(l)-l[i])//2
            return cnt
    print(int(main()))


#
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}



const int MAX_N = 5e3 + 10;
ll d[MAX_N][MAX_N];


int main(){
    int n, m;
    cin >> n >> m;
    vl a(n);
    vector<vl> b(m, vl(n));
    rep(i, n-1) cin >> a[i+1];
    rep(i, n) rep(j, m) cin >>b[j][i];

    rep(i, m) {
        auto& v = b[i];
        vi idx(n);
        rep(i, n) idx[i] = i;
        sort(all(idx), [&](int a, int b) {return v[a] > v[b];});
        set<int> st;
        for(const auto& id : idx) {
            int l = 0, r = n-1;
            auto pre = st.lower_bound(id);
            if(pre != st.begin()) {
                --pre;
                l = *pre;
                ++l;
            }
            auto nxt = st.upper_bound(id);
            if(nxt != st.end()) {
                r = *nxt;
                --r;
            }
            d[l][id] += v[id];
            d[l][r+1] -= v[id];
            d[id+1][id] -= v[id];
            d[id+1][r+1] += v[id];

            st.insert(id);
        }
    }
    rep(i, n) rep(j, n+1) {
        d[i+1][j] += d[i][j];
    }  
    rep(i, n+1) rep(j, n) {
        d[i][j+1] += d[i][j]; 
    }

    rep(i, n-1) {
        a[i+1] += a[i];
    }
    ll ans = 0LL;
    rep(i, n) REP(j, i, n) {
        ans = max(ans, d[i][j] - (a[j] - a[i]));
    } 
    cout << ans << endl;
    return 0;
}

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

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  cout << (c >= a && c <= b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, q;
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> q;
  while (q--) {
    cin >> n;
    ll k[n + 10] = {}, l[n + 10] = {}, r[n + 10] = {}, info_pos = 0;
    vector<P> info;
    pq que1, que2;
    ans = 0;
    rep(i, n) cin >> k[i] >> l[i] >> r[i], k[i]--;
    rep(i, n) {
      if (l[i] < r[i]) continue;
      ans += r[i];
      info.p_b({k[i], i});
    }
    sort(all(info));
    reverse(all(info));
    rrrep(i, n - 1, 0) {
      rrep(j, info_pos, Size(info)) {
        if (info[j].fi < i) {
          info_pos = j;
          break;
        } else
          que1.push(l[info[j].se] - r[info[j].se]), info_pos = j + 1;
      }
      if (Size(que1) != 0) {
        ans += que1.top();
        que1.pop();
      }
    }
    info.clear();
    info_pos = 0;
    rep(i, n) {
      if (l[i] >= r[i]) continue;
      ans += l[i];
      info.p_b({k[i], i});
    }
    sort(all(info));
    rep(i, n) {
      rrep(j, info_pos, Size(info)) {
        if (info[j].fi >= i) {
          info_pos = j;
          break;
        } else
          que2.push(r[info[j].se] - l[info[j].se]), info_pos = j + 1;
      }
      if (Size(que2) != 0) {
        ans += que2.top();
        que2.pop();
      }
    }
    Cout(ans);
  }
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll X;
    string S;
    cin >> X;

    if(X==7||X==5||X==3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3608
n, q = map(int, input().split())
s = input()
num = [list(map(int, input().split())) for i in range(q)]
arr = [0]
tmp = 0
for i in range(n):
    if s[i:i+2] == 'AC':
        tmp += 1
    arr.append(tmp)

for left, right in num:
    ans = arr[right - 1] - arr[left - 1]
    print(ans)

Measured memory_bytes: 31228
from sys import stdin
from math import cos, pi, sqrt
input = stdin.readline

A, B, H, M = map(int, input().split())

x = (M * pi) / 30

y = (H * pi) / 6 + (M * pi) / 360

theta = max(x, y) - min(x, y)

if theta > 180:
    theta -= 180

ans = A ** 2 + B ** 2 - 2 * A * B * cos(theta)

print(sqrt(ans))


Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
const double eps = 1e-9;

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

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#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>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
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, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.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; }

int main()
{
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif

    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> Count(N,0);
    for(int i=0;i<Q;i++){
        int A;
        cin >> A;
        A--;
        Count[A]++;
    }
    for(int i=0;i<N;i++){
        if(K-Q+Count[i]>0)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

int n, s, a[N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) s += a[i] * a[j];
	}
    cout << s << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

bool solve(string S, ll A, ll C)
{
    bool f = true;
    ll c = 0;
    REP(i,A,C) {
        if(S[i] == '#') ++c;
        else c = MAX(c-1,0);
        if(c == 2) {
            f = false;
            break;
        }
    }
    return f;
}


int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    S = "." + S;

    ll f;
    if(A < B && B < D && D < C) {
        f = false;
        ll b = 0;
        REP(i,B,D+1) {
            if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                f = true;
                S[i] = '#';
                b = i;
                break;
            }
            f &= solve(S, A, C);
            S[b] = '.';
            f &= solve(S, b, D);
        }
    }
    else {
        f = solve(S, B, D);
        f &= solve(S, A, C);
    }
    if(f) PR("Yes");
    else PR("No");
    

    return 0;
}

/*



*/

Measured memory_bytes: 3800
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();

		long result = 0;
		for (long i = 1; i < n; i++) {
			result += i;
		}
		System.out.println(result);

	}
}


Measured memory_bytes: 21204
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#define  ll long long
using namespace std;
long long N,A,B,C,D;
int main()
{
	while(~scanf("%ld %ld %ld %ld %ld",&N,&A,&B,&C,&D))
	{
		int flag=0;
		//cout<<N<<endl;
		for(int i=0;i<=N-1;i++)
		{
			long long low=A+i*C-(N-1-i)*D;
			long long high=A+i*D-(N-i-1)*C;
			if(low>high)
			swap(low,high);
			if(B>=low&&B<=high)
			{
				//cout<<"up: "<<i<<"down: "<<N-1-i<<endl;
				//cout<<low<<' '<<high<<endl;
			  flag=1;
			  break;
			}
		}
		if(flag)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
arr = [0]+list(map(int,input().split()))
g = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int, input().split())
  g[a].append(b)
  g[b].append(a)
  
ans = 0

for v in range(1, n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
    
print(ans)

Measured memory_bytes: 29344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll K=1000000007;

int main (){
    int N;
  	cin>>N;
    vector<ll> Vec(N);
    for(int i=0; i<N; i++){
        cin>>Vec.at(i);
    }
    ll Kake=1;
    vector<ll> Hanoi(3);
  	for(int i=0; i<3; i++){
      	Hanoi.at(i)=0;
    }
    for(int i=0; i<N; i++){
        int Count=0;
        bool t=true;
        for(int j=0; j<3; j++){
          	//cout<<"!"<<endl;
            if(Vec.at(i)==Hanoi.at(j)){
                Count ++;
              	//cout<<'!'<<endl;
                if(t){
                    Hanoi.at(j) ++;
                    t=false;
                }
            }
        }
      	//cout<<Count<<endl;
      	//cout<<11111<<endl;
        Kake*=Count;
        Kake%=K;
    }
    cout<<Kake<<endl;

}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		}
		UnionFindTree uft = new UnionFindTree(n + 1);
		for (int i = 0; i < m; i++) {
		    uft.unite(sc.nextInt(), sc.nextInt());
		}
		int count = 0;
		for (int i = 1; i <= n; i++) {
		    if (uft.same(i, arr[i])) {
		        count++;
		    }
		}
	    System.out.println(count);
   }
   
   static class UnionFindTree {
       int[] parents;
       
       public UnionFindTree(int size) {
           parents = new int[size];
           for (int i = 0; i < size; i++) {
               parents[i] = i;
           }
       }
       
       public int find(int x) {
           if (parents[x] == x) {
               return x;
           } else {
               return parents[x] = find(parents[x]);
           }
       }
       
       public boolean same(int x, int y) {
           return find(x) == find(y);
       }
       
       public void unite(int x, int y) {
           int xx = find(x);
           int yy = find(y);
           if (xx == yy) {
               return;
           }
           parents[xx] = yy;
       }
   }
}




Measured memory_bytes: 90588
N, Q = map(int, input().split())
S = input()

dp = [0] * (N + 1)
for i in range(N):
    if S[i : i + 2] == 'AC':
        dp[i + 1] += 1
        
for i in range(1, N + 1):
    dp[i] += dp[i - 1]
    
for i in range(Q):
    l, r = map(int, input().split())
    print(dp[r - 1] - dp[l - 1])

Measured memory_bytes: 9460
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a, b;
	string s;
	bool f = 0;
	cin >> a >> b >> s;
	for (int i = 0; i < a; i++)if (s[i] == '-')f = 1;
	if (s[a] != '-')f = 1;
	for (int i = a + 1; i < a + b + 1; i++)if (s[i] == '-')f = 1;
	cout << (f ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Integer a = sc.nextInt();
        Integer b = sc.nextInt();
        Integer c = sc.nextInt();
        Integer k = sc.nextInt();
        Integer res = 0;
        
        if(a>=k){
            res += k;
            System.out.println(res);
        }
        else {
            res += a;
            k = k-a;
            if(b>=k){
                System.out.println(res);
            }
            else{
                k = k-b;
                res -= k;
                System.out.println(res);
            }
        }


    }
}


Measured memory_bytes: 27076
import java.util.Scanner;

public class Main {
	public static final String AC = "AC";
	public static final String WA = "WA";
	public static final String TLE = "TLE";
	public static final String RE = "RE";
			
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		int numAc = 0;
		int numWa = 0;
		int numTle = 0;
		int numRe = 0;
		for(int i = 0; i < num; i++) {
			String res = sc.next();
			switch (res) {
			case AC:
				numAc++;
				break;
			case WA:
				numWa++;
				break;
			case TLE:
				numTle++;
				break;
			case RE:
				numRe++;
				break;
			}
		}
		System.out.println(AC + " x " + numAc);
		System.out.println(WA + " x " + numWa);
		System.out.println(TLE + " x " + numTle);
		System.out.println(RE + " x " + numRe);
	}
}


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

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int A_int;
    int B_int;
    int C_int;

    cin >> A_int;
    cin >> B_int;
    

    C_int = 0;
    if(A_int > B_int){
        C_int = C_int + A_int;
        A_int = A_int - 1;
    }else{
        C_int = C_int + B_int;
        B_int = B_int - 1;
    }

    if(A_int > B_int){
        C_int = C_int + A_int;
        A_int = A_int - 1;
    }else{
        C_int = C_int + B_int;
        B_int = B_int - 1;
    }

    cout << C_int;
    

}

Measured memory_bytes: 256
# B - Easy Linear Programming
def main():   
    a, b, _, k = map(int, input().split())
    ans = 0
    ans += min(a, k)
    
    if (a+b)>=k:
        print(ans)
        exit()
    
    k -= (a+b)
    
    print(ans-k)

if __name__ == '__main__':
    main()

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

char r[11] = { 'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm' };

bool isRight( char c ){
    REP( i, 11 ){
        if( c == r[i] ) return true;
    }
    return false;
}

signed main(){

    string s;
    while( cin >> s, s != "#" ){
        int ans = 0;

        REP( i, s.size() - 1 ){
            ans += isRight( s[i] ) ^ isRight( s[i + 1] );
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3192
import numpy as np

n = int(input())
a1 =0
a2 = 0
b1 = 0
b2 = 0

# print(np.sqrt(n))
# print(n)

temp = np.round(np.sqrt(float(n)))
temp = int(temp)
if n == temp*temp:
    a1 = temp
    b2 = temp
    a2 = 0
    b1 = 0
else:
    a1 = temp +1
    b2 = temp +1
    over = a1*b2
    diff = over -n

    if diff > 1e9:
        a1 = temp
        over = a1 * b2
        diff = over - n

    if diff > 1e9:
        b2 = temp
        over = a1 * b2
        diff = over - n
    a2 = 1
    b1 = int(diff)

print("0 0 "+str(a1)+" "+str(a2)+" "+str(b1)+" "+str(b2))
# print(abs(a1*b2-a2*b1))
# print(len(str(n)))
# print(len(str(a1)))
# print(len(str(a2)))
# print(len(str(b1)))
# print(len(str(b2)))



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

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AStudyScheduling {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int h1, m1, h2, m2, K;
        in>>h1>>m1>>h2>>m2>>K;
        int x1 = h1 * 60 + m1;
        int x2 = h2 * 60 + m2;
        out<<x2-K-x1<<'\n';
    }
};


int main() {
	AStudyScheduling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)

int n , m , k ;
vector < ll > a,b;





int main() {

    cin >> n >> m >> k;
    vector < ll > sumA(n+1),sumB(m+1);

    for( int i = 0 ; i < n ; i++ ){
        ll x ;
        cin >> x;
        a.pb(x);
    }
    for( int i = 0 ; i < m ; i++ ){
        ll x ;
        cin >> x;
        b.pb(x);
    }

    for( int i = 0 ; i < n  ; i++ ){
        sumA[i+1] = sumA[i] + a[i];
    }
    for( int i = 0 ; i < m  ; i++ ){
        sumB[i+1] = sumB[i] + b[i];
    }

    ll mx = 0 ;
    ll total = 0 ;
    for( int i = 0 ; i <= n ; i++ ){

        ll taken = sumA[i];
        ll rem = k - sumA[i];
        if(rem<0)continue;
        ll j = lower_bound(sumB.begin(),sumB.end(),rem)-sumB.begin();
        if( j > m || sumB[j] > rem ){
            j--;
        }

        total = max( total , i + j );


    }

    cout << total << endl;








    return 0;
}

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

int main() {
	cout << fixed << setprecision(15);

	int N, M, K;
	cin >> N >> M >> K;
	vector<int> viA, viB;
	int tmp;
	rep (i, N) {
		cin >> tmp;
		viA.push_back(tmp);
	}
	rep (i, M) {
		cin >> tmp;
		viB.push_back(tmp);
	}

	int numA = 0;
	int numB = 0;
	int64 tmpSum = 0;
	int64 ans = 0;
	rep (i, N) {
		if (tmpSum + viA[i] <= K) {
			tmpSum += viA[i];
			++numA;
		}
		else break;
	}

	rep (i, M) {
		if (tmpSum + viB[i] <= K) {
			tmpSum += viB[i];
			++numB;
		}
		else break;
	}

	if (ans < numA + numB) ans = numA + numB;

	int a = numA;
	rep (i, a) {
		--numA;
		tmpSum -= viA[numA];

		while (numB < M && tmpSum + viB[numB] <= K) {
			tmpSum += viB[numB];
			++numB;
		}

		if (ans < numA + numB) ans = numA + numB;
	}

	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 5616
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = LONG_LONG_MAX / 2;
const ll MAX_COST = 1000 * 1000 * 1000;

static ll do_solve(map<ll, ll> &dp, const ll n, const ll A, const ll B, const ll C, const ll D) {
    if (dp.find(n) != dp.end()) {
        return dp[n];
    }

    ll ans = INF;

    vector<ll> muls = {2, 3, 5};
    vector<ll> costs = {A, B, C};
    for (int i = 0; i < (int) muls.size(); i++) {
        const ll mul = muls[i];
        {
            const ll next = n / mul;
            if (next == 0) continue;
            ll cand = 0;
            cand += D * (abs(next * mul - n));
            cand += costs[i];
            cand += do_solve(dp, next, A, B, C, D);
            chmin(ans, cand);
        }
        {
            ll next = (n + mul - 1) / mul;
            ll cand = 0;
            cand += D * (abs(next * mul - n));
            cand += costs[i];
            cand += do_solve(dp, next, A, B, C, D);
            chmin(ans, cand);
        }
    }

    /*
     *  Two ways to judge whether applying D by n times.
     */

    // (1) When n > 2 * MAX_COST, it is always better to apply x2, x3, or x5 even if D == 1 and A, B, C == 10 ^ 9.
    // if (n <= 2 * MAX_COST) {
    //     chmin(ans, n * D);
    // }
    // (2) `ans` must be less than INF, so skip it if n * D > INF
    if (n <= INF / D) {
        chmin(ans, n * D);
    }

    dp[n] = ans;
    return ans;
}

ll solve(const ll N, const ll A, const ll B, const ll C, const ll D) {
    map<ll, ll> dp;
    dp[0] = 0;
    dp[1] = D;
    return do_solve(dp, N, A, B, C, D);
}

int main(void) {
    int T;
    cin >> T;

    while (T-- > 0) {
        ll N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;

        cout << solve(N, A, B, C, D) << endl;
    }

    return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int p[100];

int find(int x){
	return x == p[x] ? x : (p[x] = find(p[x]));
}
int merge(int x,int y){
	x=find(x),y=find(y);
	if( x == y ) return 0;
	p[y] = x;
	
	return 1;
}

int main(){
	int n,m;
	while(cin >> n >> m && n){
		for(int i = 0 ; i < n ; i++) p[i] = i;
		vector< pair<int,pair<int,int> > > e;
		for(int i = 0 ; i < m ; i++){
			int a,b,c;
			cin >> a >> b >> c;
			e.push_back(make_pair(c,make_pair(a,b)));
		}
		int ans = 0;
		sort(e.begin(),e.end());
		for(int i = 0 ; i < m ; i++){
			if( merge(e[i].second.first,e[i].second.second) ){
				ans += e[i].first;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class ABC144_D // ←Class名変更！！    Program
{
    public static void Main()
    {
        var n = Rda();
        var a = n[0];
        var b = n[1];
        var xTaiseki = n[2];

        var menseki = xTaiseki / a;

        var cc = b;

        if (menseki<a*b /2)
        {
            a= 2 * menseki / b;
        }
        else
        {
            var mizu_takasa = xTaiseki / (a * a);
            cc = (b - mizu_takasa) * 2;
        }


        //angle = Math.PI * a / 180.0;
        //C#ビギナー 三角関数のアークタンジェントは、MathメンバのMath.Atanを使う http://20100718seko.blog130.fc2.com/blog-entry-147.html
        var r = Math.Atan(cc / a) * 180.0 / Math.PI;

        WriteLine($"{r:F10}");  //小数点以下10桁
        return;

    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static double Rd() { return double.Parse(ReadLine()); }


    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
    public static double[] Rda() { return Array.ConvertAll(ReadLine().Split(' '), double.Parse); }

} // Class


Measured memory_bytes: 13268
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j,cc=0;
    cin>>n>>j;
    for(i=0;i<n;i++){
        ll x;cin>>x;
        if(x>=j)cc++;
    }
    cout<<cc<<endl;
    
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

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

int N, Q, u, v;
vector<int> g[200005];
int counts[200005];
int p[200005];
int visited[200005];

int dfs(int node) {
  counts[node] += p[node];
  visited[node] = 1;

  for (auto const& neigh : g[node]) {
    if (visited[neigh]) continue;
    counts[neigh] += counts[node];
    dfs(neigh);
  }
}


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

  for (int i = 0; i < N-1; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  for (int i = 0; i < Q; i++) {
    cin >> u >> v;
    p[u] += v;
  }

  dfs(1);
  for (int i = 1; i <= N; i++) {
    cout << counts[i] << " ";
  }
  cout << endl;
}


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


int main() {
  int N; cin >> N;
  vector<int> card(N);
  for (int i = 0; i < N; i++) cin >> card[i];

  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());

  int aScore, bScore = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      aScore += card.at(i);
    } else {
      bScore += card.at(i);
    }
  }

  cout << aScore - bScore << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
   string s,t;
   cin>>s>>t;
   int a,b;
   cin>>a>>b;
   string u;
   cin>>u;
   if(s==u){
    a--;
   }
 else if(t==u){
   b--;
 }
 cout<<a<<" "<<b<<endl;
 return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,m,to[100010],st[100010];
long long a[100010],b[100010],k;
bool used[100010];
int main()
{
	scanf("%d",&n);
	long long lst=0;
	for (int i=1;i<=n;i++)
	{
		long long x;
		scanf("%lld",&x);
		a[i]=x-lst;
		lst=x;
		to[i]=i;
	}
	scanf("%d%lld",&m,&k);
	for (int i=0;i<m;i++)
	{
		int x;
		scanf("%d",&x);
		swap(to[x],to[x+1]);
	}
	for (int i=1;i<=n;i++)
	{
		if (used[i])
		{
			continue;
		}
		int cnt=0,now=i;
		while (!used[now])
		{
			used[now]=true;
			st[cnt]=now;
			cnt++;
			now=to[now];
		}
		long long q=k%cnt;
		for (int j=0;j<cnt;j++)
		{
			to[st[j]]=st[(j-q+cnt)%cnt];
		}
	}
	for (int i=1;i<=n;i++)
	{
		b[to[i]]=a[i];
	}
	long long now=0;
	for (int i=1;i<=n;i++)
	{
		now+=b[i];
		printf("%lld.0\n",now);
	}
    return 0;
}
//月上柳梢头，人约黄昏后。
//——欧阳修《生查子·元夕》

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int n,ans=0;
    cin>>n;
    string s;
    map<string, int> m;
    rep(i, n) {
        cin>>s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    for(auto&& p: m) {
        int a = p.second;
        ans += a * (a - 1) / 2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
#define eps 1e-10
#define inf 1e9
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{if(c=='-')	f=-1;c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
const int N=(1<<20);
int n,m,e[30][30],in[N],to[N][30],dp[N][30];
int x,y,z;
int main()
{
	n=read();m=read();
	For(i,1,m)
	{
		x=read();y=read();z=read();
		e[x][y]=e[y][x]=z;
	}
	int mx=(1<<(n+1))-1;
	For(i,1,mx)
		For(j,1,n)
			if((i&(1<<j)))	For(k,j+1,n)	if((i&(1<<k)))	in[i]+=e[j][k];
	For(i,1,mx)
		For(j,1,n)
		{
			For(k,1,n)
				if(i&(1<<k))	
					to[i][j]+=e[j][k];
		}
	For(i,0,mx)	For(j,0,n)	dp[i][j]=-1;
	dp[2][1]=0;
	For(i,2,mx)
		For(j,1,n)// dp[i][j] to update
			if(dp[i][j]>=0)
				if(i&(1<<j))
				{
					For(k,1,n)
						if(i&(1<<k))	continue;
						else
							if(e[j][k])	dp[i|(1<<k)][k]=max(dp[i|(1<<k)][k],dp[i][j]+e[j][k]);
					int Cu=mx-i;
					for(int tmp=mx-i;tmp;tmp=(tmp-1)&Cu)
					{
						dp[i|tmp][j]=max(dp[i|tmp][j],dp[i][j]+to[tmp][j]+in[tmp]);
					}
				}
	printf("%d\n",in[mx]-dp[mx][n]);
}

Measured memory_bytes: 18688
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	set<int> s;
	rep(i,n){
		int d;
		cin >> d;
		rep(j,d){
			int a;
			cin >> a;
			s.insert(a);
		}
	}
	int ans = n - s.size();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	//cout<<s<<" "<<t<<endl;
	if(s<t){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    const [a, b, c, k] = lines[0].split(" ").map(e => parseInt(e));
    //lines.shift();
    const t = k - (a + b);
    console.log( t <= 0 ? k - a <= 0 ? k : a : (a - t));
});

Measured memory_bytes: 30272
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#pragma GCC optimize("O3")
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int n,a[200005],rs,x[200005];


int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=1;i<=n;i++){
        x[a[i]]=x[a[i]-1]+1;
        rs=max(rs,x[a[i]]);
    }
    rc(n-rs);


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  ll n;
  cin>>n;
  ll cu=n/11;
  cu*=2;
  ll k=n%11;
  if(k==0){
  }
  else if(k<=6){
    cu++;
  }
  else{
    cu+=2;
  }
  COUT(cu);
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                putchar((i + j) % 2 == 0 ? '#' : '.');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
     
    using namespace std;
    const int MAXN = 350;
    string s1[MAXN];
    int arr[MAXN][MAXN];
    int cnt;
    bool filledrow[MAXN];
    int main(){
        int h,w,k;
        cin>>h>>w>>k;
        for(int i=1;i<=h;i++){
            cin>>s1[i];
            s1[i] = '.'+s1[i];
            for(int j=1;j<=w;j++){
     
                if(s1[i][j] == '#'){
                    filledrow[i] =true;
                    cnt++;
                    arr[i][j] = cnt;
                    for(int x=j-1;x>=1;x--){
                        if(arr[i][x]){
                            break;
                        }
                        arr[i][x] = cnt;
                    }
                    for(int x=j+1;x<=w;x++){
                        if(s1[i][x] == '#'){
                            break;
                        }
                        arr[i][x] = cnt;
                    }
     
                }
            }
            if(!filledrow[i]){
                for(int j=1;j<=w;j++){
                    arr[i][j] = arr[i-1][j];
                }
            }
        }
     
            if(!filledrow[1]){
                    int ptr = 1;
                    while(!filledrow[ptr]){
                        ptr++;
                    }
                    for(int i=ptr-1;i>=0;i--){
                        for(int j=1;j<=w;j++){
                            arr[i][j] = arr[i+1][j];
                        }
                    }
                }
     
        for(int i=1;i<=h;i++){
     
            for(int j=1;j<=w;j++){
                cout<<arr[i][j]<<" ";
            }
            cout<<endl;
        }
     
    }

Measured memory_bytes: 1280
#include <iostream>

int main()
{
	long long dogs, monkeys;
	const long long mod7 = 1000000007;

	std::cin >> dogs >> monkeys;

	if (dogs > monkeys + 1 || monkeys > dogs + 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long ans = 1;
	if (dogs == monkeys) {
		for (long long i = 1; i <= monkeys; i++) {
			ans = (ans * i) % mod7;
			ans = (ans * i) % mod7;
		}
		ans = (ans * 2) % mod7;
	} else {
				for (long long i = 1; i <= monkeys; i++) {
			ans = (ans * i) % mod7;
		}
		for (long long i = 1; i <= dogs; i++) {
			ans = (ans * i) % mod7;
		}
	}

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

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int N; cin >> N; int origN; origN = N;
  vector<int> div;
  for(int i=2; i * i <= N; i++){
    if(N % i == 0){
      div.push_back(i);
      while(N % i == 0) N /= i;
    }
  }
  if(N != 1) div.push_back(N);
  
  int M = div.size(), ans = 0;
  for(int bit=1; bit < (1 << M); bit++){
    int popcnt = __builtin_popcount(bit);
    int mul = 1;
    rep(i, M){
      if(bit >> i & 1) mul *= div[i];
    }

    if(popcnt % 2 == 1) ans += origN / mul;
    else                ans -= origN / mul;
  }

  // DEBUG(ans);

  cout << origN - ans << endl;
}  



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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	if(abs(a-b) <= d && abs(b-c) <= d){
		cout << "Yes" << endl;
	}else if(abs(a-c) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
		}
}

Measured memory_bytes: 764
A, B, C, X, Y = map(int, input().split())

res = 0

is_lower_a = True
if X > Y:
    is_lower_a = False

if A + B >= 2 * C:
    if is_lower_a:
        res += 2 * C * X
    else:
        res += 2 * C * Y
    if X != Y:
        if is_lower_a:
            if 2 * C <= B:
                res += (Y - X) * 2 * C
            else:
                res += (Y - X) * B
        else:
            if 2 * C <= A:
                res += (X - Y) * 2 * C
            else:
                res += (X - Y) * A
else:
    res += A * X
    res += B * Y
print(res)


Measured memory_bytes: 61872