akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

ll a,b;

bool check(ll x, vector<ll>h){
    ll ans = 0;
    rep0(i, h.size()){
        if(h[i] <= x * b)break;
        ans += (h[i] - x * b + a - b - 1) / (a - b);
    }
    if(x >= ans)return true;
    else return false;
}

int main(){
    ll n;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep0(i, n)cin >> h[i];
    sort(all(h),greater<>());
    ll l = 1,r = 1e9;
    while (l != r) {
        ll x = (l + r) / 2;
        if(check(x, h))r = x;
        else l = x + 1;
    }
    pf(l);
    return 0;
}



Measured memory_bytes: 1792
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

long long int f2(long long int a, long long int b) {
	while (a % b != 0 && b % a != 0) {
		if (a >= b)
			a %= b;
		else
			b %= a;
	}
	return min(a, b);
}

long long int f1(long long int a, long long int b) {
	return a / f2(a, b) * b;
}

int main(int argc, char *argv[]) {
	long long int n, m;
	cin >> n >> m;
	vector<long long int> v;
	for (int i = 0; i < n; i++) {
		long long int t;
		cin >> t;
		v.push_back(t / 2);
	}
	long long int res = v[0];
	for (int i = 1; i < n; i++) {
		res = f1(res, v[i]);
		if (res > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (res / v[i] % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << 1 + (m - res) / (res * 2) << endl;
}









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

using namespace std;

#define ll long long
#define MAX 100005
#define INF 1e15
ll n, arr[MAX];

pair<ll, ll> intersect(ll x1, ll y1, ll x2, ll y2)
{
    ll maxs = max(x1, x2);
    ll mins = min(y1, y2);
    return make_pair(maxs, mins);
}

int main()
{
    //freopen("in.txt", "r", stdin);
    scanf("%lld", &n);
    for(ll i=0; i<=n; i++) scanf("%lld", &arr[i]);
    if(arr[0] > 1){
        cout <<-1 << endl;
        return 0;
    }
    else if(arr[0] == 1){
        if(n == 0) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(n == 0){
        if(arr[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    bool ok = true;
    vector<pair<ll, ll> > v;
    ll mins = arr[n], maxs = arr[n];
    v.push_back(make_pair(mins, maxs));
    for(ll i=n-1; i>=0; i--){
        ll leaf = arr[i];
        ll newMin = (mins+1)/2, newMax = maxs;
        newMax += leaf;
        v.push_back(make_pair(newMin, newMax));
        mins = newMin, maxs = newMax;
        if(mins > maxs) ok = false;
        if(i == 0){
            if(maxs < 1 || mins > 1) ok = false;
        }
    }
    reverse(v.begin(), v.end());
    //for(int i=0; i<=n; i++) cout << v[i].first << " " << v[i].second << endl;
    //cout << endl;
    ll tot = 1;
    ll last = 1;
    for(int i=1; i<=n; i++){
        ll leaf = arr[i];
        ll x1 = last, y1 = 2*last;
        ll x2 = v[i].first, y2 = v[i].second;
        pair<ll, ll> p = intersect(x1, y1, x2, y2);
        ll x = p.first, y = p.second;
        if(leaf > y || x > y){
            ok = false;
            break;
        }
        //cout << y << " " << leaf << endl;
        if(i == n){
            if(leaf < x || leaf > y){
                ok = false;
                break;
            }
            tot += leaf;
        }
        else {
            tot += y;
            last = y - leaf;
        }
    }
    if(ok == false){
        cout << -1 << endl;
        return 0;
    }
    cout << tot << endl;
}



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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for (ll i = 1; i * i <= m; i++) {
        if (m % i != 0) continue;
        ll j = m / i;
        if (j >= n) {
            cmax(ans, i);

        }
        if (i >= n) {
            cmax(ans, j);
        }
    }
    cout << ans << endl;

}

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

using namespace std;

#define rep(i,n) for(long long int i=0;i<n;i++)
#define rep1(i,n) for(long long int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(long long int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(long long int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define pf printf
#define sf scanf
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define vci(v) for(long long int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(long long int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mp make_pair
#define fir first
#define sec second
#define clr(arr) memset((arr),0,sizeof(arr))

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vb;
typedef vector<vector<double>> vvd;
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
typedef pair<int,int> pii;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)1e9+7;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> inline void Swap(T *x,T *y){ T tem=*x; *x=*y; *y=tem; }

inline long long int rem(long long int n,long long int m){
	if(!m) return 0;
	return (n<0?(n%m)+m:(n%m));
}

/*
int thre1,thre2;
vi v;

template<typename T> inline bool judge(T n){
	return (thre1<=v[n]&&thre2>=v[n]);
}

template<typename T> inline T BiS(T bottom,T ceiling,bool thretype){
	T upper=ceiling+thretype;
	T lower=bottom-(!thretype);
	while(upper-lower>1){
		T mid=(upper+lower)/2;
		if(judge(mid)) (thretype?lower:upper)=mid;
		else (thretype?upper:lower)=mid;
	}
	return (thretype?lower:upper);
}
*/

/* The main code follows below */

int main(){
	int X,A,B;
	cin>>X>>A>>B;
	cout<<(X-A)%B;
	return 0;
}

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

int main()
{
	long N,K;
	string result;

	vector<long long>A;

	cin >> N;

	result = "YES";

	for (int a = 0; a < N; a++) {
		long long newA;
		cin >> newA;
		A.push_back(newA);

	}
	sort(A.begin(), A.end());

	for (int a = 0; a < N-1; a++) {
		if (A[a] == A[a + 1]) {
			result = "NO";
			break;
		}
	}
	

	cout << result<<endl;
}



Measured memory_bytes: 2420
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B = LI()

    if 1 <= A <= 9 and 1 <= B <= 9:
        print(A * B)
    else:
        print('-1')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int count = 0;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      count++;
    }
  }
  if(count > 0){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Data.List (sort)

main :: IO ()
main = solve <$> readLn <*> (map read <$> words <$> getLine) >>= print

solve :: Int -> [Int] -> Int
solve n ps = maximum $ zipWith min [n, n-1 .. 1] (sort ps)



Measured memory_bytes: 4116
def main():
    a = int(input()) # 500
    b = int(input()) # 100
    c = int(input()) #  50
    x = int(input())

    ans = 0

    for i in range(a+1):
        I = i*500
        if I > x:
            break
        for j in range(b+1):
            J = j*100
            if I+J > x:
                break
            for k in range(c+1):
                K = k*50
                if I+J+K == x:
                    ans +=1

    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll x, y;
  x = N/(A+B); 
  y = N % (A+B);
  
  ll sum;
  if (A >= y) sum = A * x + y;
  else sum = A*x + A;
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> vec(N,0);
    int Ai, i, j;
    for (i=0;i<Q;i++){
        cin >> Ai;
        vec.at(Ai - 1) ++;
        
    }
    
    for (j=0;j<N;j++){
        if (K - Q + vec.at(j) > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

}

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

int n;
double ans;

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

	for(int i=0; i<n; i++) {
		double x;
		scanf("%lf", &x);

		ans += 1 / x;
	}

	printf("%.10f\n", 1/ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> a(n), flag(8, 0);
	int cnt = 0;
	rep(i,0,n) {
		cin >> a[i];
		if(a[i]<=399) flag[0] = 1;
		else if(a[i]<=799) flag[1] = 1;
		else if(a[i]<=1199) flag[2] = 1;
		else if(a[i]<=1599) flag[3] = 1;
		else if(a[i]<=1999) flag[4] = 1;
		else if(a[i]<=2399) flag[5] = 1;
		else if(a[i]<=2799) flag[6] = 1;
		else if(a[i]<=3199) flag[7] = 1;
		else cnt++;
	}
	int tot = accumulate(flag.begin(), flag.end(), 0);
	if (tot == 0 && cnt != 0) tot = 1, cnt--;
	cout << tot << " " << tot + cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }
/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+`]（ターミナル起動）ー＞[./a.out] */

//////////////////
//  A
/*int main(void){
    int n;cin>>n;
    n%=1000;
    if(n==0) cout<<0<<endl;
    else cout<<1000-n<<endl;
    return 0;
}*/
//////////////////
//  B
int main(void){
    int n;cin>>n;
    int a[n]={0,0,0,0};
    string b[4]={"AC","WA","TLE","RE"};
    rep(i,n){
        string tmp;
        cin>>tmp;
        if(tmp=="AC") a[0]++;
        else if(tmp=="WA") a[1]++;
        else if(tmp=="TLE") a[2]++;
        else if(tmp=="RE") a[3]++;
    }
    rep(i,4){
        cout<<b[i]<<" x "<<a[i]<<endl;
    }
    return 0;
}
//////////////////
//  C 
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 4028
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

order = []
for i in range(n):
    order.append([i, a[i]])

order = sorted(order, key=lambda a: a[1])

for i in range(len(order)):
    print("{} ".format(order[i][0]+1), end="")
print()


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

int main() {
    int n;
    cin >> n;
    vector <int> vec(n);
    vector <int> vec_2(n);
    for (int i = 0; i < n ; ++i) {
        cin >> vec.at(i);
        vec_2.at(i) = i + 1;
    }
    int count = 0;
    for (int j = 0; j < n ; ++j) {
        if (vec.at(j) != vec_2.at(j))
            count ++;
    }
    if (count <= 2)
        cout << "YES";
    else
        cout << "NO";
}


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int K, X;

int main(){
  cin >> K >> X;
  if(500 * K >= X){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    q, h, s, d = map(int, readline().split())
    n = int(readline())
    ans = min(8 * q, 4 * h, 2 * s, d) * (n // 2) + min(4 * q, 2 * h, s) * (n % 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61880
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005
#define inf 1e18+7
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}


int main()
{
	sup;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif*/
    ll n,m,a=0,w=0;
    cin>>n>>m;
    map<ll,ll>m1,m2;
    fab(i,0,m)
    {
        in(t); string s; cin>>s;
        if(s[0]=='A' && s[1]=='C')
            m1[t]=1;
        else if(m1[t]!=1)
            m2[t]++;
    }
    fab(i,0,n+1)
    {
        if(m1[i]==1)
            a++;
        if(m2[i]!=0 && m1[i]!=0)
            w+=m2[i];
    }
    prr(a,w);
    return 0;
}

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

int main(){
	int n,m;
	while(cin>>n>>m, n && m){
	bool visited[n+1];
	memset(visited,0,sizeof(visited));
	int j = n,index = m%n;
	if(index == 0)index = n;
	while(j>1){
		visited[index] = true;
		for(int x=0;x<m;++x){
			do{
				index++;
				if(index == n+1)index = 1;
			}while(visited[index]);
		}
		//cout<<index<<endl;
		//visited[index] = true;
		j--;

	}
	for(int x=1;x<=n;++x){
		if(!visited[x]){
			cout<<x<<endl;break;
		}
	}
	}
	return 0;
}

Measured memory_bytes: 1168
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
// #define modd 2019

#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>

#include <cassert>
// #include <algorithm>
#include <functional>
using namespace std;

int euk(int a, int b){
    if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
//   printf("最大公約数 = %d\n", b);
 
  return b;

}

int main(){
  string s;
  cin >> s;
  string t;
  cin >> t;
  
  int res = 0;
  rep(i,3){
    if(s[i] == t[i]) res++;
  }
  cout << res;
}


Measured memory_bytes: 256
#include <iostream>
int main() {
  int n,a,b,t,s=0;
  std::cin>>n>>a>>b;
  for(int i=1;i<n+1;++i) {
    t = i%10 + i/10%10 + i/100%10 + i/1000%10 +i/10000%10;
    s += (t>=a&&t<=b?i:0);
  }
  std::cout<<s<<"\n";
}

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

typedef long long lint; typedef pair<int, int> ii;
// const int MOD = 1'000'000'007, MOD2 = 1'000'000'009;
const int INF = 0x3f3f3f3f; const lint BINF = 0x3f3f3f3f3f3f3f3fLL;

int n, a[200005], p[200005];

int solve(){
	cin >> n; for (int i=0;i<n;i++) cin >> a[i], a[i]--, p[a[i]] = i;
	int cnt = 1, ans = 0;
	for (int i=1;i<n;i++) {
		if (p[i] > p[i-1])
			cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 1;
		}
	}
	ans = max(ans, cnt);
	cout << n - ans << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define meme(s) memset(s,1,sizeof(s))
#define rall(s) s.rbegin(),s.rend()
#define i(x) scanf("%lld",&(x))
typedef unordered_map<ll,ll> mll;
#define pb push_back
#define in2(x,y) i(x),i(y)
#define EL cout<<'\n'
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define all(s) s.begin(),s.end()
typedef unordered_map<ll,vll>circuit;
typedef unordered_map<ll,bool>is;
const ll MOD=1e9+7;
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define fr(n,x) for(int n=0;n<x;n++)
#define pf(x) printf("%lld\n",(x))
const  ll mx=2e5;
const int N = 1e6+6;
#define segtree ll L=2*node,R=L+1,mid=(l+r)/2
#define cs(n) printf("Case %lld: ",(n))
typedef pair<ll,ll> pll;


int main()
{
    ll x,sm=0;
    i(x);
	for(ll n=1;n<=x;n++)
	{
		for(ll a=1;a<=x;a++)
		{
			for(ll b=1;b<=x;b++)
			{
				sm+=__gcd(n,__gcd(a,b));
			}
		}
	}
	pf(sm);
}






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


int main()
{
  long long n;
  cin>>n;
  long long s=0;
  for(int i=1;i<=n;i++)
  {
      if(i%3 !=0 && i%5 !=0)
        s+=i;
  }
  cout<<s<<endl;
}

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

int main() {
    int X, Y;
    cin >> X >> Y;
    if (4*X >= Y && Y >= 2*X) {
        if((Y - 2*X) % 2 == 0 && (4*X - Y) % 2 == 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3668
N = int(input())
n = len(list(str(N)))
cnt = 0
if n==1:
    print(N)
else:
    for i in range(n//2):
        cnt += 9 * (10 ** (2 * i))  
    if n%2==1:
        cnt += N - (10 ** (2 * (n//2))) + 1
    print(cnt)

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int n, m;
int ans = 0;
vector<vector<int> > v(9);

void solve(int num, vector<int> root) {
  if (int(root.size()) == n) {
    ans++;
    return;
  } 

  for (auto x : v[num]) {
    auto itr = find(root.begin(), root.end(), x);
    if (itr == root.end()) {
      root.push_back(x);
      solve(x, root);
      root.pop_back();
    }
  }
};

int main(){
  cin >> n >> m;

  int a, b;
  REP (i, m) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<int> root;
  root.push_back(1);
  solve(1, root);
  cout << ans << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k,s = LI()
    if s == 10**9:
        a = [s]*k+[1]*(n-k)
        print(*a)
        return
    a = [s]*k+[s+1]*(n-k)
    print(*a)
    return
    return

#Solve
if __name__ == "__main__":
    solve()


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

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


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

    string S;
    cin >> S;

    REP(i, S.size()) cout << "x";
    cout << endl;

}


Measured memory_bytes: 256
def runlength(S):
    cnt = 1
    res = []
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            res.append(cnt)
            cnt = 1

    res.append(cnt)
    return res


def main():
    N, K = map(int, input().split())
    S = input()
    A = runlength(S)
    ans = 0
    for a in A:
        a -= 1
        ans += a
    ans = min(N-1, ans + 2 * K)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 45168
def main():
  n=int(input())
  s=t=input()
  a=0
  for i in range(n):
    c=0
    for v,w in zip(s,t):
      if v==w:c+=1
      else:c=0
      if c>i:break
      if c>a:a=c
    t=t[1:]
  print(a)
main()

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


int main(){
  
  string _Num;
  cin >> _Num;
  vector<int> Num(4);
  
  for(int i = 0; i < 4; i++){
    
    Num[i] = _Num[i] - '0';
  }
  
  
  //全ての組み合わせについて試す
  for(int bit = 0; bit < (1 << 4); bit++){
    
    
    int Sum  = Num[0];
    string S = ""; S = S + _Num[0];
    
    //1つの組み合わせパターンを計算
    for(int i = 0; i < 3; i++){
      if(bit & 1 << i){
        
        
        Sum += Num[i + 1];
        S   = S + "+" + _Num[i + 1];
      }else{
        
        Sum -= Num[i + 1];
        S   = S + "-" + _Num[i + 1];
      }
    }
    
    if(Sum == 7){
      cout << S + "=7" << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <string>
#define f first
#define s second
using namespace std;
int main(){

  string x; int y;
  int n,q,i,cnt=0;
  queue<pair <string,int> > a;

  cin>>n>>q;
  for(i=0;i<n;i++){
    cin>>x>>y;
    a.push(make_pair(x,y));
  }
  while(!a.empty()){
    cnt+=q;
    a.front().s-=q;
    if(a.front().s>0){
      a.push(a.front());      
      a.pop();
    } else {
      cnt+=a.front().s;
      cout<<a.front().f<<" "<<cnt<<endl;
      a.pop();
    }
  }
  return 0;
}



Measured memory_bytes: 6392
#include <iostream>

using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b && a!=c && b!=c)
{
    cout<<"No";
}
else
{
 if(a==b && b==c)
 {
    cout<<"No";    
 } 
 else
   {
    cout<<"Yes" ;
   }
}
    
    return 0;
}

Measured memory_bytes: 256
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K - 1])

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





#define rrep(i,a,b) for(int i=a;i>=b;i--)
int N, K, A[5050];
//-----------------------------------------------------------------------------------
int L[5010][5010], R[5010][5010];
void pre() {
	L[0][0] = 1;
	rep(i, 0, N) rep(j, 0, K) if (L[i][j]) {
		L[i + 1][j] = 1;
		if (j + A[i] < K) L[i + 1][j + A[i]] = 1;
	}

	R[N + 1][0] = 1;
	rrep(i, N, 1) rep(j, 0, K) if (R[i + 1][j]) {
		R[i][j] = 1;
		if (j + A[i - 1] < K) R[i][j + A[i - 1]] = 1;
	}

	// For optimized solution
	rep(i, 0, N + 2) {
		rep(j, 1, K) R[i][j] += R[i][j - 1];
	}
}
//-----------------------------------------------------------------------------------
int main() {
	cin >> N >> K;
	rep(i, 0, N) scanf("%d", &A[i]);
	sort(A, A + N);

	pre();

	int ans = 0;
	rep(i, 0, N) {
		if (K <= A[i]) continue;

		bool ok = true;
		
		/* // Naive
		rep(j, 0, K) rep(k, 0, K) if (L[i][j] && R[i + 2][k]) {
			if (K <= j + k + A[i] && j + k < K) ok = false;
		} */

		// Optimized
		rep(j, 0, K) if (L[i][j]) {
			int lo = max(K - j - A[i], 0);
			int hi = min(K - 1, K - j - 1);

			int sm = R[i + 2][hi];
			if (0 < lo) sm -= R[i + 2][lo - 1];
			if (sm != 0) ok = false;
		}
		
		if (ok) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 196224
F = [None] * 3

for i in range(3):
    F[i] = list(map(int, input().split()))

for a1 in range(F[0][0]+1):
    b1 = F[0][0] - a1

    b2 = F[0][1] - a1
    b3 = F[0][2] - a1

    a2 = F[1][0] - b1
    a3 = F[2][0] - b1

    for i, a in enumerate([a1, a2, a3]):
        for j, b in enumerate([b1, b2, b3]):
            if F[i][j] != a + b:
                break
        else:
            continue
        break
    else:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

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

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

	ll n, z, w;
	cin >> n >> z >> w;
	Array a(n, 0);
	REP(i, n) cin >> a[i];

	if (n == 1) {
		cout << abs(a[0] - w) << endl;
	}
	else {
		cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
	}

	return 0;
}


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

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
  	ll LCM = C/gcd(C, D)*D;
	ll ac = (A-1) / C;
	ll ad = (A-1) / D;
	ll bc = B / C;
	ll bd = B / D;
	ll acd = (A-1) / LCM;
	ll bcd = B / LCM;
	
	ll ans = B-A+1-bc+ac-bd+ad+bcd-acd;
  	cout << ans << endl;
}

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

using namespace std;

typedef pair<int,int>P;

//?????????????????????0?§???????
//????°????????±???????????????°??????(RMQ)
const int N = 1 << 17;	//10^5?¨????

//?????°???????????¨???????????°??????????????????

int n,n_,q,ad[2*N-1];

//?????????
//n_???x??\??????????°????2????????????
void init(int x)
{
	//?°????????????????????´???°???2???????????????
	n_=1;
	while(n_<x){
		n_*=2;
	}
}

int get(int k)
{
	int res;
	//????????????
	k += n_-1;
	res = ad[k];
	//?????????????????´??°
	while(k>0){
		k = (k-1)/2;
		res += ad[k];
	}
	return res;
}

//[a,b)???????°????????±??????????
//k??????????????????
//????????????query(a,b,0,0,n_)??¨???????????¶???(n_??¨???????????¨?????¨???)
void add(int a,int b,int k,int l,int r,int val)
{
	if(r <= a || b <= l){
		return;
	}
	if(a <= l && r <= b){
		ad[k] += val;
	}else{
		add(a,b,2*k+1,l,(l+r)/2,val);
		add(a,b,2*k+2,(l+r)/2,r,val);
	}
	return;
}

int main()
{
	scanf("%d%d",&n,&q);
	init(n);
	rep(i,q){
		int x;
		scanf("%d",&x);
		if(x == 0){
			int s,t,u;
			scanf("%d%d%d",&s,&t,&u);
			add(s-1,t,0,0,n_,u);
		}else{
			int s;
			scanf("%d",&s);
			printf("%d\n",get(s-1));
		}
	}
	return 0;
}

Measured memory_bytes: 3964
class UnionFind:
	def __init__(self, size):
		self.data = [-1] * size
	def find(self, x):
		if self.data[x] < 0:
			return x
		else:
			self.data[x] = self.find(self.data[x])
			return self.data[x]
	def union(self, x, y):
		x, y = self.find(x), self.find(y)
		if x != y:
			if self.data[y] < self.data[x]:
				x, y = y, x
			self.data[x] += self.data[y]
			self.data[y] = x
		return (x != y)
	def same(self, x, y):
		return (self.find(x) == self.find(y))

N, M = map(int, input().split())
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
	K, *L = map(int, input().split())
	for l in L:
		uf.union(i, l + N)

if all(uf.same(i, N) for i in range(1, N)):
	print("YES")
else:
	print("NO")

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

int main() {
char alphabet[27] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};	
int n=26;
char v;
cin>>v;
	for(int i=0;i<n;i++){
	    if(alphabet[i]==v){
	        if(alphabet[i]=='z'){
	        cout<<alphabet[0];
	        }
	        else{
	        cout<<alphabet[i+1];
	        }

	    
	    }

	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int s1, s2, s3;
	s1 = cin.get() - '0';
	s2 = cin.get() - '0';
	s3 = cin.get() - '0';
	cout << s1 + s2 + s3 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
MOD = 10**9+7
# MOD = 998244353

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()

ans = 1
for e in A:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 82972
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    var min = Int.MAX_VALUE
    for (a in 1 until n) {
        val b = n - a
        val sa = a.toString().map { it.toString().toInt() }.sum()
        val sb = b.toString().map { it.toString().toInt() }.sum()
        min = Math.min(min, sa + sb)
    }
    println(min)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 59140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
long long a,b,c,k;
int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if (a>=k) {printf("%lld\n",k); return 0;}
	k-=a;
	if (b>=k) {printf("%lld\n",a); return 0;}
	k-=b;
	printf("%lld\n",a-k);
return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
using namespace std;

typedef long long ll;
int modulo = 1000000007; // 10^9 + 7

// 最大公約数
long long gcd(long long a, long long b) { // a >= b;
	if (b == 0) return a;
	else return gcd(b, a%b);
}

// 最小公倍数を求める 
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b; // 桁あふれに気を付ける
}

int main() {
	int N; cin >> N;
	ll t[N]; for (int i = 0; i < N; i++) cin >> t[i];
	ll ans = 1;
	for (int i = 0; i < N; i++) ans = lcm(ans, t[i]);

	cout << ans << endl;

	return 0;
}

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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    bool left = true;
    bool right = true;
    bool top = true;
    bool bottom = true;

    if(x - r < 0) left = false;
    if(x + r > w) right = false;
    if(y - r < 0) bottom = false;
    if(y + r > h) top = false;

    cout << ((left & right & bottom & top) ? "Yes" : "No") << endl;
}




Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF -1
using namespace std;

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

int main() {

	int a, b,d;
	char c[10];

	cin >> a >> b >> d;

	if (a + b >= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}




Measured memory_bytes: 256
import itertools

n = int(input())
f = [list(map(int,input().split())) for i in range(n)]
p = [list(map(int,input().split())) for i in range(n)]

ans = -float("inf")
for pattern in itertools.product(range(2), repeat=10):
  if sum(pattern)==0:
    continue

  tmp_ans = 0
  for mise_i in range(n):
    tmp_cnt = 0
    for i,ptn in enumerate(pattern):
      if ptn == 1 and f[mise_i][i] == 1:
        tmp_cnt += 1
    tmp_ans += p[mise_i][tmp_cnt]
  if tmp_ans > ans:
    ans = tmp_ans
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    string S;
    cin >> S;
    cout << S << endl;
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;

// --------write my code!!!!!----------//

int main(){
    int N; cin >> N;
    int l[110];
    rep(i,N) cin >> l[i];
    sort(l,l+N);
    int sum=0;
    rep(i,N-1) sum+=l[i];
    if(sum>l[N-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
package main

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

type town struct {
	a int
	b int
}

func main() {
	n := readi()
	s := reads()
	if n >= len(s) {
		fmt.Println(s)
	} else {
		fmt.Printf("%v...\n", s[:n])
	}
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 1856
mod=1e9+7,dp[1<<21];
n,a,I,x,y,i,j;
main()
{
	for(*dp=scanf("%d",&n);~scanf("%d",&a);j=++j%n)
	{
		i+=!j;
		for(I=(1<<i)-1;I<1<<n;)
		{
			dp[I]=(dp[I]+!!(I&a<<j)*dp[I&~(1<<j)])%mod;
			x=I&-I,y=I+x;
			I=(I&~y)/x>>1|y;
		}
	}
	printf("%d",dp[I-y/2]);
}

Measured memory_bytes: 8320
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  Yn((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d);
  return 0;
}

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


int main() {
  string s, t;
  cin >> s >> t;
  vector<int> a(26), b(26);
  for(int i=0; i<s.size(); i++) a[s[i]-'a']++;
  for(int j=0; j<t.size(); j++) b[t[j]-'a']++;
  sort(rng(a));
  sort(rng(b));
  cout << (a==b? "Yes": "No") << endl;
  return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

template<int mod> struct ModInt{
    long long x=0; 
    constexpr ModInt(long long x=0):x((x%mod+mod)%mod){}
    constexpr ModInt operator+(const ModInt& r)const{return ModInt(*this)+=r;}
    constexpr ModInt operator-(const ModInt& r)const{return ModInt(*this)-=r;}
    constexpr ModInt operator*(const ModInt& r)const{return ModInt(*this)*=r;}
    constexpr ModInt operator/(const ModInt& r)const{return ModInt(*this)/=r;}
    constexpr ModInt& operator+=(const ModInt& r){ if((x+=r.x)>=mod) x-=mod; return *this;}
    constexpr ModInt& operator-=(const ModInt& r){ if((x-=r.x)<0) x+=mod; return *this;}
    constexpr ModInt& operator*=(const ModInt& r){ if((x*=r.x)>=mod) x%=mod; return *this;}
    constexpr ModInt& operator/=(const ModInt& r){ return *this*=r.inv();}
    ModInt inv() const {
        long long s=x,sx=1,sy=0,t=mod,tx=0,ty=1;
        while(s%t!=0){
            long long temp=s/t,u=s-t*temp,ux=sx-temp*tx,uy=sy-temp*ty;
            s=t;sx=tx;sy=ty;
            t=u;tx=ux;ty=uy;
        }
        return ModInt(tx);
    }
    ModInt pow(long long n) const {
        ModInt a=1;
        while(n>0){
            if(n&1) a*=*this;
            *this*=*this;
            n>>=1;
        }
        return a;
    }
    friend constexpr ostream& operator<<(ostream& os,const ModInt<mod>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<mod>& a) {return is >> a.x;}
};
using mint = ModInt<MOD>;

mint dp[105][100000];

int main(){
    int n,k;
    cin >> n >> k;
    int now = n;
    vector<mint> sz;
    int l = 1;
    while(l <= n){
        int r = n/(n/l) + 1;
        sz.push_back(r-l);
        l = r;
    }
    int m = (int)sz.size();
    rep(i,m) dp[0][i] = sz[i];

    for(int i=0;i<k-1;i++){
        mint res = 0;
        for(int j=0;j<m;j++){
            res += dp[i][j];
            dp[i+1][m-j-1] = res*sz[m-j-1]; 
        }
    }
    mint ans = 0;
    rep(i,m) ans += dp[k-1][i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53416
from sys import stdin


s = stdin.readline().rstrip()
s = [str(i) for i in s]

t = stdin.readline().rstrip()
t = [str(i) for i in t]

if s == t:
    print("No")
    exit()
s.sort()
t.sort(reverse=True)

ns = ""
nt = ""

for i in range(len(s)):
    ns += s[i]

for i in range(len(t)):
    nt += t[i]

li = [ns,nt]

lin = sorted(li)


if lin == li:
    print("Yes")
    exit()
print("No")

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

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

fn main() {
    let i: String = read();
    let s = i.chars().map(|x| if x == '9' { '1' } else {'9'}).collect::<String>();
    println!("{}", s);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	map<ll, ll> p;
	rep(i, n){
		ll temp; cin>>temp;
		p.ins(mp(temp, i));
	}

	multiset<ll> q;
	q.ins(-1); q.ins(-1);
	q.ins(n); q.ins(n);

	ll ans=0;
	for(int i=n; i>=1; i--){
		auto bs = q.lower_bound(p[i]);
		ll r1 = *bs; bs++;
		ll r2 = *bs; bs--; bs--;
		ll l2 = *bs; bs--;
		ll l1 = *bs;

		ans += i*(l2-l1)*(r1-p[i]);
		ans += i*(p[i]-l2)*(r2-r1);
		q.ins(p[i]);
	}

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

Measured memory_bytes: 11264