akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int X;
    cin >> X;
   if(X >= 30){
    cout << "Yes";
}
    else{
        cout << "No";
    }

}

Measured memory_bytes: 3568
/******************************************
* AUTHOR : SHUBHAM KUMAR *
* NICK : { "CODECHEF" : "SCHELEON",
           "CODEFORCES" : "SCH3130N" } *     
* INSTITUTION : BIT MESRA *
******************************************/
 
#include "bits/stdc++.h"
 
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define pds(x) printf("%lld ", x)
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end())  
 
template <typename T> void max_self(T& a, T b) {
    a = max(a, b);
}
 
using ll = long long int;
using ull = unsigned long long int;
 
ll ModE(ll x, ull y, ll p = MOD) 
{ 
    ll res = 1;
    x = x % p;    
    while (y > 0) 
    {   if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}
 
ll a[100];
int solve(ll stones, ll n, int dp[]){
    if(stones == 0)
        return 0;
    if(dp[stones] != -1)
        return dp[stones];
    rep0(jj, n){
        if(stones > a[jj]){
            dp[stones] = solve(stones - a[jj], n, dp);
            if(!dp[stones])
                return 1;
        }
        else if(stones == a[jj])
            return 1;            
    }
    return 0;
}
 
int main() {
    #ifdef M_DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio
    ll n,k;
    cin>>n>>k;
    rep0(i, n)
        cin>>a[i];
    int dp[k+1];
    rep1(i, k)
        dp[i] = -1;
    dp[0]=0;
    rep1(ii, k)
        dp[ii] = solve(ii, n, dp);
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

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

using namespace std;

vector< pair<int,int> >g[100005];
int l[100005], dis[100005], vis[100005], f;

void dfs(int u,int d) {
    if(vis[u] == 0) {
        vis[u]=1;
        dis[u]=d;
    } else {
        if(dis[u] != d) f=1;
        return;
    }
    for(pair<int,int> i : g[u]) {
        int v = i.first;
        int w = i.second;

        dfs(v, d+w);
    }
}

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

    int n, m;
    cin >> n >> m;

    for(int i=1; i<=m; i++) {

        int u, v, w;
        cin >> u >> v >> w;
        g[u].push_back({v, w});
        l[v]++;
    }

    for(int i=1; i<=n; i++) {
        if(!l[i]) {
            dfs(i, 0);
        }
    }

    for(int i=1; i<=n; i++) if(!vis[i]) f=1;

    if(f) cout<<"No"<<endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 9984
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,A,B;R(N,A,B);W(min(N*A,B));
    return 0;
}


Measured memory_bytes: 256
inp = int(input())
count = 0
serch = 1


for i in range(1,inp + 1):
	a = i
	j = 1
	while j <= i:
		if a % 2 != 0:
			if j - 1 > count:
				count = j - 1
				serch = i
			break
		a = a / 2
		j += 1


print(serch)

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

int main(){
  int n,i;
  cin >> n;
  vector<int> p(n);
  for(i=0;i<n;i++){
    cin >> p.at(i);
  }
  
  int s=0;
  for(i=1;i<n-1;i++){
    if((p.at(i-1)-p.at(i))*(p.at(i+1)-p.at(i))<0){
      s++;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
typedef long double ld;
typedef vector<vector<int> > matrix;
typedef vector<int> arr;
typedef vector<string> vs;
typedef vector<pair<int,int> > pv;
#define test() int t;cin>>t;while(t--)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};
//=================================================================//
int n;
int dp[3001][3001][2];
int solve(int i, int j, int turn, int *arr) {
    if(i>j) return 0;

    int &ans = dp[i][j][turn];
    if(ans != -1) return ans; 

    if(turn) {
        return ans = max(arr[i] + solve(i+1, j, 0, arr), arr[j] + solve(i,j-1, 0, arr));
    }
    else {
        return ans = min(solve(i+1, j, 1, arr), solve(i,j-1, 1, arr));
    }
}
#undef int
int main(){
#define int long long 
    fast;
    cin>>n;
    int arr[n];
    int sum = 0;
    FOR(i,0,n-1) cin>>arr[i], sum+=arr[i];
    memset(dp, -1, sizeof dp);
    int x = solve(0,n-1,1,arr);
    int y = sum - x;
    cout<<x - y;
    return 0;
}

Measured memory_bytes: 141184
n = gets.to_i
t, x, y = [0], [0], [0]
n.times do
  a, b, c = gets.split.map(&:to_i)
  t << a
  x << b
  y << c
end
(0...n).each do |i|
  if (dxy = (x[i+1]-x[i]).abs + (y[i+1]-y[i]).abs) <= (dt = t[i+1]-t[i]) && dxy % 2 == dt % 2
    next
  else
    puts 'No'
    exit
  end
end
puts 'Yes'

Measured memory_bytes: 4300
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
    int a, b; cin >> a >> b;
	for(int i = 1; i <= 12000; ++i) {
        if(floor(0.08 * (ld)i) == a && floor(0.10 * (ld)i) == b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    int64_t c=0, w;
    cin >> n >> k;
    priority_queue<int64_t> hs;
    for(int i=0; i<n; i++){
        cin >> w;
        hs.push(w);
    }
    if (k >= n){
        cout << c << '\n';
        return 0;
    }
    n -= k;
    for(int i=0; i<k; i++){
        hs.pop();
    }
    for(int i=0; i<n; i++){
        c += hs.top();
        hs.pop();
    }
    cout << c << '\n';
    return 0;
}

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;

int main(){
	setIO();
	string s = "ACL";
	int n; cin >> n;
	for (int i = 0; i < n; i++) cout << s;
	cout << endl;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl

li n, t;
pt arr[200001];

int main () {
    cin >> n;
    for (li i=0; i<n; i++) cin >> arr[i].se >> arr[i].fi;
    sort(arr, arr+n);
    t=0;
    for (li i=0; i<n; i++) {
        t+=arr[i].se;
        if (t>arr[i].fi) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

const int NMAX = 2e5 + 5;
int n, a[NMAX], sum_xor;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum_xor ^= a[i];
    }
    for(int i = 1; i <= n; i++) {
        cout << (sum_xor ^ a[i]) << ' ';
    }
    return 0;
}


Measured memory_bytes: 4260
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll a,b,c;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>a>>b>>c;
    Vi v;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(all(v));
    bool ans = false;
    if(v[0]==v[1] || v[1]==v[2]){
        if(v[0]!=v[2]){
            ans = true;
        }
    }
    Yes(ans);
    return 0;
}

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

int main() {
    int n, m, a;
    while (cin >> n >> m >> a, (n or m or a)) {
        a--;
        vector< pair<int, int> > amida[n];

        rep(i, m) {
            int h, p, q;
            cin >> h >> p >> q; p--; q--;
            amida[p].push_back({h, q});
            amida[q].push_back({h, p});
        }

        rep(i, n) {
            sort(amida[i].begin(), amida[i].end(), greater< pair<int, int> >());
        }

        int now_h = 1e8;
        bool update = true;
        while (update) {
            update = false;
            for (auto & t : amida[a]) {
                if (now_h > t.first) {
                    now_h = t.first;
                    a = t.second;
                    update = true;
                    break;
                }
            }
        }

        cout << a + 1 << endl;
    }
}

Measured memory_bytes: 3140
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        t = L[i] + L[j]
        idx = bisect.bisect_left(L, t)
        ans += max(0, idx-j-1)
print(ans)


Measured memory_bytes: 43500
N = int(input())
X_list = list(map(int, input().split()))
X_list_copy = X_list.copy()
X_list_copy.sort()

median_idx = int(N / 2)
left_num = X_list_copy[median_idx - 1]
right_num = X_list_copy[median_idx]

for x in X_list:
    if x < right_num:
        print(right_num)
    else:
        print(left_num)


Measured memory_bytes: 25620
using System;
using System.Linq;

class MainClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        int evenNum = N / 2;

        var oddNum = N - evenNum;

        double answer = (double)oddNum / N;

        Console.WriteLine(answer);
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <queue>

using namespace std;
long long ans;

int main(){
  int i,n,m, x;
  cin>>n>>m;
  //vector<int> A;
  priority_queue<int> pq;
  for(i = 0; i<n; i++){
    cin>>x;
    //A.push_back(x);
    pq.push(x);
    ans += x;
  }
  for(i = 0; i<m; i++){
    x = pq.top();
    pq.pop();
    ans -= x - (x >> 1);
    pq.push(x>>1);
  }
  cout<<ans<<endl;
}


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

int main()
{
    int s,a,b,c,d;
    cin>>s;
    a=s/1000;
    b=(s/100)%10;
    c=(s/10)%10;
    d=s%10;
    if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<time.h>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
long long int a[110000];
int main()
{
	long long int n,i;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
	}
	a[0] = 0;
	sort(a+1, a+1 + n);
	long long int sum = 0;
	for (i = 1; i <= n / 2; i++)
	{
		sum += a[n - i + 1]-a[i-1]+a[n-i+1]-a[i];
	}
	sum = sum - a[n];
	if (n % 2 != 0)
	{
		long long int  maxs=max(a[n] - a[i], a[i] - a[i - 1]);
		maxs = max(maxs, a[n] - a[i + 1] + a[i] - a[i - 1]);
		sum += maxs;
	}
	else
	{
		sum += a[n] - a[n/2+1];
	}
	printf("%lld", sum);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int a,b; cin >> a >> b;
	if( a>9 || b>9 ) out(-1);
	else out(a*b);

}




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

using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

constexpr int INF = 2000000000;
constexpr ll LLINF = 9000000000000000000;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin >> N;
	
	vi B(N+N, 0LL);
	int l = N, r = N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (l <= r)
			B[r++] = a;
		else
			B[--r] = a;
		swap(l, r);
	}
	
	if (l > r) {
		swap(l, r);
		reverse(B.begin()+l, B.begin()+r);
	}
	for (int i = l; i < r; ++i)
		cout << B[i] << " \n"[i+1==r];
	
	return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,l;
  int x=0;
  int y;
cin >> n >> l;
vector<int> d(n);
  
  for(int i=0;i<n;i++){
    d[i]=l+i;
    x +=d[i];
  }
  int a=500;
  for(int i=0;i<n;i++){
    if(abs(d[i])<=a){
    a=abs(d[i]);
      y=d[i];
  }
  }
    cout<< x-y << endl;
}
    
  

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    vec v={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int K; cin>>K;
    cout<<v[--K]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,num;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
  	if(i%10==i/10000%10 && i/10%10==i/1000%10) num++;
  }
  cout<<num<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * 2
for i in range(2):
    A[i] = list(map(int, input().split()))
C_max = 0
for i in range(N):
    C = sum(A[0][0:i+1]) + sum(A[1][i:N])
    C_max = max(C,C_max)
print(C_max)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>

using namespace std;

typedef struct Task {
	Task(int _i, int _j, int _k){ i = _i; j = _j; k = _k; }
	int i, j, k;
} Task;

int main(){
	while(true){
		int status[301] = { 0 };
		int a, b, c, n;
		cin >> a >> b >> c;
		if(a == 0 && b == 0 && c == 0){ break; }
		cin >> n;
		queue<Task> q, p;
		while(n--){
			int i, j, k, r;
			cin >> i >> j >> k >> r;
			if(r == 0){
				q.push(Task(i, j, k));
			}else{
				status[i] = status[j] = status[k] = 1;
			}
		}
		queue<Task> &f = q, &g = p;
		int count = f.size();
		while(!f.empty()){
			Task t = f.front();
			f.pop();
			if(status[t.i] > 0 && status[t.j] > 0){
				status[t.k] = -1;
			}else if(status[t.i] > 0 && status[t.k] > 0){
				status[t.j] = -1;
			}else if(status[t.j] > 0 && status[t.k] > 0){
				status[t.i] = -1;
			}else{
				g.push(t);
			}
			if(f.empty()){
				if(g.size() == count){ break; }
				queue<Task> &tmp = g;
				g = f;
				f = tmp;
				count = f.size();
			}
		}
		for(int i = 1; i <= a + b + c; i++){
			switch(status[i]){
				case  0: puts("2"); break;
				case  1: puts("1"); break;
				case -1: puts("0"); break;
			}
		}
	}
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(all(A));
  string ans = "YES";
  REP(i, N - 1) {
    if(A[i] == A[i + 1]) ans = "NO";
  }
  cout << ans << endl;
}


Measured memory_bytes: 4784
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  string s;
  cin >> s;
  vector<bool> v(s.size());
  REP(i,(ll)s.size()) v[i] = (s[i]=='B'?true:false);
  ll ans = 0,count = 0;
  REP(i,(ll)v.size()){
    if(!v[i]){
      ans += i-count;
      count++;
    }
  }
  // REP(i,(ll)v.size()-1) {
  //   if(v[i]&&!v[i+1]){
  //     v[i] = false;
  //     v[i+1] = true;
  //     ans++;
  //   }
  // }
  // for(int i=(ll)v.size()-1;i>=1;--i){
  //   if(v[i-1]&&!v[i]){
  //     v[i-1] = false;
  //     v[i] = true;
  //     ans++;
  //   }
  //}
  cout << ans << endl;
}




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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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


int main(){
  int n,m;
  int sum=0;
  cin>>n>>m;
  int a[n];
  REP(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  if(sum%(4*m)==0){
  if(sum/(4*m)<=a[n-m]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}else{
  if(sum/(4*m)<a[n-m]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

}


Measured memory_bytes: 256
n,m = map(int,input().split())
ls = list(map(int,input().split()))
di = [list(map(int,input().split())) for _ in range(m)]
fi = []
for i,j in di:
    fi.append([j,i])
for k in ls:
    fi.append([k,1])
fi.sort(reverse=True)
ans = 0
cnt = 0
how = 0
while True:
    if how + fi[cnt][1] < n:
        how += fi[cnt][1]
        ans += fi[cnt][1]*fi[cnt][0]
    else:
        ans += (n-how)*fi[cnt][0]
        break
    cnt += 1
print(ans)



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

int main()
{
    int n;
   double x, sum = 0;
    string u;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        sum += (u == "JPY") ? x : x * 380000.0;
    }
    cout << sum << endl;
}

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

using namespace std;

int main()
{
  int k;
  string s;
  cin>>k>>s;
  
  if(s.length()<=k)
    cout<<s;
  
  else
  {
    string str=s.substr(0,k);
    cout<<str<<"...";
  }
  
  return 0;
}

Measured memory_bytes: 3628
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    if n == 1:
        print('Hello World')
    else:
        a = int(input())
        b = int(input())
        print(a + b)
if __name__ =='__main__':
    main()   


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

#define lb(x) x & -x
const int _ = 3e5 + 7; int N , arr[_];
void add(int x){while(x <= N){++arr[x]; x += lb(x);}}
int qry(int x){int sum = 0; while(x){sum += arr[x]; x -= lb(x);} return sum;}

#define ll long long
ll c(vector < int > p){
	ll sum = 0; memset(arr , 0 , sizeof(arr)); while(!p.empty()){sum += qry(p.back()); add(p.back()); p.pop_back();} return sum;
}

int main(){
	bool flg = 1; vector < int > p1 , p2 , p3; cin >> N;
	for(int x , i = 1 ; i <= N ; ++i){cin >> x; p1.push_back(x); (i & 1 ? p2 : p3).push_back(x); flg &= !((i ^ x) & 1);}
	puts(flg & (c(p1) == 3 * (c(p2) + c(p3))) ? "Yes" : "No"); return 0;
}


Measured memory_bytes: 6260
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	static Queue<String> queue=new LinkedList<>();
	//static int[] c;
	static Map<String, Integer> map=new HashMap<>();
	static String str;
	static int[][] d= {{0, 1, 4}, {-1, 1, 4}, {-1, 1, 4}, {-1, 0, 4}, {0, 1, -4}, {-1, 1, -4}, {-1, 1, -4}, {-1, 0, -4}};
	
	
	static void bfs() {
		while(! queue.isEmpty()) {
			String str1=queue.remove();
			//int point=c[Integer.parseInt(str1)];
			int point = map.get(str1);
			//System.out.println("str1="+str1+" point:"+point);
			String str2="";
//			if(str1.equals(str)) {
//				queue.clear();
//				break;
//			}
			for(int i=0; i<8; i++) {
				if(str1.charAt(i)=='0') {
					for(int j=0; j<3; j++) {
						//System.out.println(i+" "+(i+d[i][j]));
						char change=str1.charAt(i+d[i][j]);
						str2=str1.replace('0', '9');
						str2=str2.replace(change, '0');
						str2=str2.replace('9', change);
						//if(c[Integer.parseInt(str2)]==0) {
						if(map.get(str2)==null) {
							//c[Integer.parseInt(str2)]=point+1;
							map.put(str2, point+1);
							queue.add(str2);
						}
					}
					break;
				}
			}
		}
	}
	
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			queue.add("01234567");
			map.put("01234567", 0);
			//c[Integer.parseInt("01234567")]=0;
			bfs();
			while(sc.hasNext()) {
				String s=sc.nextLine();
				String[] token=s.split(" ");
				str="";
				//c=new int[76543211];
				for(String t:token) {
					str+=t;
				}
				//System.out.println(c[Integer.parseInt(str)]);
				System.out.println(map.get(str));
			}
			
		}
	}
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

bool checkConnection(int n, vector<int> *g)
{
    bool res = true;
    // 任意の1つの頂点を始点として調べる(全ての頂点を始点として調べる必要はない)
    int st = 0;
    bool visited[n] = {false};
    queue<int> bfsQ;

    visited[st] = true;
    bfsQ.push(st);
    while (!bfsQ.empty())
    {
        int now = bfsQ.front();
        bfsQ.pop();
        for (int j = 0; j < g[now].size(); ++j)
        {
            int next = g[now][j];
            if (!visited[next])
            {
                visited[next] = true;
                bfsQ.push(next);
            }
        }
    }

    REP(j, n)
    {
        if (!visited[j])
        {
            res = false;
            break;
        }
    }

    return res;
}

int main()
{
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    REP(i, M)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;
    REP(i, M)
    {
        vector<int> G[N];
        REP(j, M)
        {
            if (i != j)
            {
                G[a[j]].push_back(b[j]);
                G[b[j]].push_back(a[j]);
            }
        }
        // Gが連結であるか調べる
        if (!checkConnection(N, G))
        {
            ans++;
        }
     }

    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
s = list(input() for _ in range(n))
m = int(input())
t = list(input() for _ in range(m))

res = Counter(s)
for i in range(m):
    if t[i] in res:
        res[t[i]] -= 1

ans = 0
for v in res.values():
    ans = max(ans, v)

print(ans)

Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			ArrayList<HashSet<Integer>> adj = new ArrayList<HashSet<Integer>>();
			for(int i = 0; i < N; i++) { adj.add(new HashSet<Integer>()); }
			
			for(int i = 0; i < M; i++) {
				final int A = sc.nextInt() - 1;
				final int B = sc.nextInt() - 1;
				
				adj.get(A).add(B);
				adj.get(B).add(A);
			}
			
			
			int[] come_from = new int[N];
			Arrays.fill(come_from, -1);
			come_from[0] = 0;
			
			LinkedList<Integer> queue = new LinkedList<Integer>();
			queue.add(0);
			while(!queue.isEmpty()) {
				final int node = queue.poll();
				
				for(final int next: adj.get(node)) {
					if(come_from[next] >= 0) { continue; }
					
					come_from[next] = node;
					queue.add(next);
				}
			}
			
			System.out.println("Yes");
			for(int i = 1; i < N; i++) {
				System.out.println(come_from[i] + 1);
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 102616
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

int a[22];
char s[10];
int l,j,i;
int memo[22];

int main(){
	while(cin >> s >> l, l){
		i = 0;
		memo[i++] = atoi(s);
		while(strlen(s) != l) strcat(s, "0");
		while(1){
			sort(s, s+l);
			int minnum = atoi(s);
			sort(s, s+l, greater<char>());
			int maxnum = atoi(s);
			memo[i++] = maxnum - minnum;

			sprintf(s, "%d", memo[i-1]);
			while(strlen(s) != l) strcat(s, "0");

			for(j = 0; j < i-1; j++) if(memo[j] == memo[i-1]) break;
			if(j < i-1) break;
		}
		cout << j << ' ' << memo[i-1] << ' ' << i-j-1 << endl;
	}
  return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        if (A < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int M,N,m0,n0,md,nd;

int main(){
  cin>>M>>N>>m0>>md>>n0>>nd;
  vector<ll> ms,summ(M+1,0);
  rep(i,M){
    ms.push_back(m0);
    m0=(m0*58+md)%(N+1);
  }
  sort(all(ms));
  rep(i,M)summ[i+1]=summ[i]+ms[i];

  vector<ll> ns,sumn(N+1,0);
  rep(i,N){
    ns.push_back(n0);
    n0=(n0*58+nd)%(M+1);
  }
  sort(all(ns));
  rep(i,N)sumn[i+1]=sumn[i]+ns[i];

  ll res=1e18;
  rep(i,M+1){
    ll j=lower_bound(all(ns),M-i)-ns.begin();
    minch(res,summ[i]+sumn[j]+(M-i)*(N-j));
  }
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 110600
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,M,K; cin >> N >> M >> K;
    vector<ll> A(N+1,0), B(M+1,0);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,M){
        cin >> B[i];
    }

    vector<ll> AS(N+1,0), BS(M,0);
    AS[0]=0;
    for(int i=0;i<N;i++){
        AS[i+1] = AS[i]+A[i];
    }
    BS[0] = B[0];
    for(int i=1;i<M;i++){
        BS[i] = BS[i-1]+B[i];
    }

    int ans = 0;
    for(int i=0;i<=N;i++){
        ll as = AS[i];
        if(as > K) continue;
        ll rem = K - as;
        int bi = upper_bound(all(BS), rem) - BS.begin();
        ans = max(ans, i+bi);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9532
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (h[i] >= K) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

n = int(input())
p = list(map(int, input().split()))
q = sorted(p)
c = 0
for i in range(n):
    if p[i] != q[i]:
        c += 1
if c > 2:
    print('NO')
else:
    print('YES')


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    string s;
    cin >> s;
    for (int i = 0; i < sz(s); ++i) {
        if (i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R') {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$aList = [];
foreach ($input as $v) {
	$aList[] = (int)$v;
}

$sum = 0;
$idx = 1;
foreach ($aList as $a) {
	if ($a == $idx) {
		$idx += 1;
	} else {
		$sum += 1;
	}
}
if ($sum === $n) {
	echo '-1';
}else{
	echo $sum;
}

Measured memory_bytes: 29164
h,w = gets.chomp.split(" ").map(&:to_i)
c = 10.times.map{gets.chomp.split(" ").map(&:to_i)}
a = h.times.map{gets.chomp.split(" ").map(&:to_i)}
for i in 0..9
  for j in 0..9
    for k in 0..9
      if c[j][k] > c[j][i]+c[i][k]
        c[j][k] = c[j][i]+c[i][k]
      end
    end
  end
end
ans = 0
a.each do |arr|
  arr.each do |num|
    if num != -1
      ans += c[num][1]
    end
  end
end
puts ans

Measured memory_bytes: 2556
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    av.sort_by(|a, b| b.cmp(a));
    let mut ans = 0;
    for i in 0..n {
        ans += (if i % 2 == 0 { 1 } else { -1 }) * av[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
  string x="",y="";
  for(int i=0;i<b;i++){
  x.push_back((char)('0'+a));

  }
for(int i=0;i<a;i++){
  y.push_back((char)('0'+b));

  }
  if(x.compare(y)>=0){
cout<<y<<endl;

  }
  else{
    cout<<x<<endl;
  }

}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s,t = input().split()
a,b = map(int, input().split())
u = input()
if s==u:
    a -= 1
else:
    b -= 1
print(" ".join(map(str, (a,b))))

Measured memory_bytes: 61848
#include<stdio.h>
#include <string.h>

using namespace std;

int main()
{
	char s[10], t[10], u[10];
	int a, b;
	scanf("%s %s", s, t);
	scanf("%d %d", &a, &b);
	scanf("%s", u);

	int num = strlen(u);
	bool flag=false;
	for(int i=0; i<num; i++){
		if (s[i] != u[i]){
			flag = true;
		}
	}

	if(flag){
		b--;
	}else{
		a--;
	}

	printf("%d %d\n", a, b);
	return 0;
}

Measured memory_bytes: 128
import fractions #ターミナル上ではmathモジュールを使う。
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
for i in range(1,N):
    ans = fractions.gcd(ans, A[i])
    #N個の最大公約数は逐次更新するのが鉄則。
print(ans)

Measured memory_bytes: 16296
n,a,b = map(int,input().split())

tmpSumDigit = 0
totalSumDigit = 0

for number in range(n):
  number += 1
  numberStr = list(str(number))
  for digitNumber in numberStr:
    tmpSumDigit = tmpSumDigit + int(digitNumber)
  if tmpSumDigit >= a and tmpSumDigit <= b:
    totalSumDigit = totalSumDigit + number
  tmpSumDigit = 0

print(totalSumDigit)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::{HashSet, HashMap, BinaryHeap};

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let l = a * (n - 1) + b;
    let r = a + b * (n - 1);
    let ans = if l <= r {r - l + 1} else {0};
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int n,a[101];
	int cnt,max,i,j;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	max=1;
	for(i=1;i<=n;i++){
		cnt=0;
		for(j=1;j<=n;j++){
			if(i<=a[j]) cnt++;
		}
		if(cnt>=i&&max<i) max=i;
	}
	printf("%d\n",max);
}	


Measured memory_bytes: 2756
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int k, x;
	cin >> k >> x;

	rep(i, 2 * k - 1) {
		cout << i + x - k + 1 << " ";
	}
	cout << endl;
	
}

Measured memory_bytes: 256