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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int c[3][3];
  rep(i,3) rep(j,3) cin>>c[i][j];
  int rn[3][3],cn[3][3];
  rep(i,3)
  {
    rep(j,3)
    {
      rn[i][j]=c[i][(j+1)%3]-c[i][j];
    }
  }
  rep(j,3)
  {
    rep(i,3)
    {
      cn[j][i]=c[(i+1)%3][j]-c[i][j];
    }
  }
  rep(i,3)
  {
    if((rn[0][i]!=rn[1][i])||(rn[1][i]!=rn[2][i])||(cn[0][i]!=cn[1][i])||(cn[1][i]!=cn[2][i])) 
    {
      print("No");
      return 0;
    }
  }
  print("Yes");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
int n;int dp[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

cin>>n;
int a[n],b[n],c[n];
f(i,0,n)
{
    cin>>a[i]>>b[i]>>c[i];
}
int dp1[n],dp2[n],dp3[n];
dp1[0]=a[0];dp2[0]=b[0];dp3[0]=c[0];
f(i,1,n)
{
    dp1[i]=max(a[i]+dp2[i-1],a[i]+dp3[i-1]);
    dp2[i]=max(b[i]+dp1[i-1],b[i]+dp3[i-1]);
    dp3[i]=max(c[i]+dp1[i-1],c[i]+dp2[i-1]);
}
int ans;
ans=max(dp1[n-1],dp2[n-1]);
ans=max(ans,dp3[n-1]);
cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        string s;
        Vec<string> list(n);
        int max_size = 0;
        for (int i = 0; i < n; i++) {
            cin >> s;
            int size = s.length();
            string input = "";
            input += s[0];
            for (int j = 0; j < size - 1; j++) {
                if (s[j] == 'a' || s[j] == 'i' || s[j] == 'u' || s[j] == 'e' || s[j] == 'o') {
                    input += s[j + 1];
                }
            }
            list[i] = input;
            max_size = max(max_size, (int)input.size());
        }

        int answer = -1;

        for (int i = max_size; i >= 1; i--) {
            bool check = true;
            set<string> st;
            for (int j = 0; j < n; j++) {
                string temp = list[j].substr(0, i);
                if (st.count(temp) == 1) {
                    check = false;
                    break;
                } else {
                    st.insert(temp);
                }
            }
            if (check == true) {
                answer = i;
            }
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, n):
        self.N = n = n + 1
        self.A = a = [True] * n
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(n)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,n+1,i):
                a[j] = False
        self.RUI = rui = [0] * n
        for i in range(2,n):
            if a[i]:
                rui[i] = rui[i-1] + 1
            else:
                rui[i] = rui[i-1]

    def is_prime(self, n):
        return self.A[n]

    def cnt(self, a, b):
        return self.RUI[b] - self.RUI[a]

def main():
    rr = []

    pr = Prime(123456 * 2)

    while True:
        n = I()
        if n == 0:
            break
        rr.append(pr.cnt(n,n*2))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 13352
N,K=map(int,input().split())
a=list(map(int,input().split()))
cycle=[0]
s_cyc=set()
s_cyc.add(0)
flag=0
id=0
for i in range(N):
    a[i]-=1
while flag==0:
    if a[id] in s_cyc:
        node=cycle.index(a[id])
        break
    else:
        cycle.append(a[id])
        s_cyc.add(a[id])
        id=a[id]
if K<=node:
    print(cycle[K]+1)
else:
    K-=node
    cycle=cycle[node::]
    q=K%len(cycle)
    print(cycle[q]+1)


Measured memory_bytes: 125084
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
char S[105];
int dp[2][5];
int nx[2][5];
int main(){
  int Q5VJL1cS;
  int i;
  int d;
  int a;
  int b;
  int na;
  int nb;
  int res = 0;
  N = rd(S);
  rd(K);
  dp[1][0] = 1;
  for(i=(0);i<(N);i++){
    S[i] -= '0';
  }
  for(Q5VJL1cS=(0);Q5VJL1cS<(N);Q5VJL1cS++){
    auto &k = S[Q5VJL1cS];
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        nx[a][b] = 0;
      }
    }
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        for(d=(0);d<(10);d++){
          na = a;
          nb = b;
          if(d){
            nb++;
          }
          if(a==1 && d > k){
            continue;
          }
          if(d < k){
            na = 0;
          }
          nx[na][nb] += dp[a][b];
        }
      }
    }
    for(a=(0);a<(2);a++){
      for(b=(0);b<(4);b++){
        dp[a][b] = nx[a][b];
      }
    }
  }
  for(a=(0);a<(2);a++){
    res += dp[a][K];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200214-1

// --- original code ---
// int N, K; char S[105];
// int dp[2][5], nx[2][5];
// 
// {
//   int i, d, a, b, na, nb, res = 0;
//   rd(S@N,K);
// 
//   dp[1][0] = 1;
//   rep(i,N) S[i] -= '0';
// 
//   rep[S](k,N){
//     rep(a,2) rep(b,4) nx[a][b] = 0;
//     rep(a,2) rep(b,4) rep(d,10){
//       na = a;
//       nb = b;
//       if(d) nb++;
//       if(a==1 && d > k) continue;
//       if(d < k) na = 0;
//       nx[na][nb] += dp[a][b];
//     }
//     rep(a,2) rep(b,4) dp[a][b] = nx[a][b];
//   }
// 
//   rep(a,2) res += dp[a][K];
//   wt(res);
// }


Measured memory_bytes: 256
for(r={I:1,V:5,X:10,L:50,C:100,D:500,M:1000},k=n=s=0,j=require("fs").readFileSync("/dev/stdin","utf8");p=n,i=j[k];k++)(n=r[i])?(s+=n,n>p?s-=p*2:0):(console.log(s),n=s=0)

Measured memory_bytes: 7912
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+20;
int n,l[N],ans;
int main(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&l[i]);
    sort( l+1 , l+n+1 ) , l[n+1] = 1<<30;
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
        {
            int L = 1 , R = n+1;
            while ( L < R )
            {
                int mid = L + R >> 1;
                if ( l[mid] < l[i]+l[j] ) L = mid + 1;
                else R = mid;
            }
            ans += max( L - j - 1 , 0 );
        }
    printf("%d\n",ans);
}


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


void solve(long long a, long long b){
if((a%2==0)||(b%2==0))cout<<"Even"<<endl;
else cout<<"Odd"<<endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
    double a,b,C;
    cin >> a >> b >> C;
    double theta = M_PI*C/180;

    double S = 0.5*a*b*sin(theta);
    double c = a*a+b*b-2*a*b*cos(theta);
    double L = a+b+sqrt(c);
    double h = S/a*2;

    cout << fixed << S << endl;
    cout << fixed << L << endl;
    cout << fixed << h << endl;
    return 0;
}

Measured memory_bytes: 3512
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

struct P {
	int x, y;
	P(int x0,int y0){x=x0,y=y0;}
	P(){};
};

bool mp[5001][5001];
P c[3000];

int main()
{
	int N;
	while (scanf("%d", &N), N) {
		memset(mp, 0, sizeof(mp));

		rep(i, N) {
			scanf("%d %d", &c[i].x, &c[i].y);
			mp[c[i].y][c[i].x] = 1;
		}

		int ma = 0;

		rep(i, N) rep(j, i) {
			P p = c[i], q = c[j];
			P d(q.x - p.x, q.y - p.y);

			P a(p.x + d.y, p.y - d.x);
			if (a.x < 0 || a.x > 5000 || a.y < 0 || a.y > 5000 || !mp[a.y][a.x]) continue;
			P b(a.x + d.x, a.y + d.y);
			if (b.x < 0 || b.x > 5000 || b.y < 0 || b.y > 5000 || !mp[b.y][b.x]) continue;
			chmax(ma, d.x * d.x + d.y * d.y);
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 25480
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i < (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, i, b;
  cin >> N;

  vi bits[20];
  REP(0, N, i) {
    i64 A;
    cin >> A;
    REP(0, 20, b) {
      if((A & (1 << b)) != 0) {
	bits[b].pb(i);
      }
    }
  }

  unsigned long long ans = 0;
  
  REP(0, N, i) {
    i64 r = N;
    REP(0, 20, b) {
      if(sz(bits[b]) > 0) {
	auto ub = lower_bound(all(bits[b]), i);
	i64 pos;
	if(ub == bits[b].end() || (ub + 1) == bits[b].end()) {
	  pos = N;
	}
	else {
	  pos = *(ub+1);
	}
	r = min(r, pos);
      }
    }
    ans += r - i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15988
#include<cstdio>
int n, ans;
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        int a;scanf("%d",&a);
        ans += a;ans %= 2;
    }
    if(ans == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
/**
*     => Md. Sajjat Hosen
*     => Department of Computer Science and Engineering
*     => Bangabandhu Sheikh Mujibur Rahman Science and Technology University
**/

/*..................! TRY ONCE MORE !..................*/

/*...Part - 01...*/

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

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}
float Float(){float x ; scanf("%f",&x) ; return x ;}
double Double(){double x ; scanf("%lf",&x); return x;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/



int main(){
    //freopen("input.txt","r",stdin);
    int test = 1 , tc = 0 ;
    ll n, k, i, ans = 0;
    while(test--){
        n = Long;
        k = Long;
        ll a[n];
        for(i = 0; i < n; i++)
            a[i] = Long;
        sort(a, a + n);
        if(k >= n)
            printf("0\n");
        else{
            for(i = 0; i < n - k; i++)
                ans += a[i];
            printf("%lld\n", ans);
        }
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main () {
char A;
cin>>A;
if(A=='a'){
cout<<"vowel"<<endl;
}
else if(A=='i'){
cout<<"vowel"<<endl;
}
else if(A=='u'){
cout<<"vowel"<<endl;
}
else if(A=='e'){
cout<<"vowel"<<endl;
}
else if(A=='o'){
cout<<"vowel"<<endl;
}
else{
cout<<"consonant"<<endl;
}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

class UnionFind {
private:
	vector<int> data;
public:
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};


int main() {

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

	int N;
	cin >> N;

	int x, y;
	vector<pair<int, int>> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		X[i] = { x, i };
		Y[i] = { y, i };
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());

	UnionFind uf(N);
	for (int i = 1; i < N; i++) {
		if (X[i].first == X[i - 1].first) uf.unify(X[i].second, X[i - 1].second);
		if (Y[i].first == Y[i - 1].first) uf.unify(Y[i].second, Y[i - 1].second);
	}

	map<int, pair<vector<int>, vector<int>>> mp;
	for (int i = 0; i < N; i++) {
		mp[uf.root(X[i].second)].first.emplace_back(X[i].first);
		mp[uf.root(Y[i].second)].second.emplace_back(Y[i].first);
	}

	lint sum = 0;
	for (auto &e : mp) {

		sort(e.second.first.begin(), e.second.first.end());
		e.second.first.erase(unique(e.second.first.begin(), e.second.first.end()), e.second.first.end());
		sort(e.second.second.begin(), e.second.second.end());
		e.second.second.erase(unique(e.second.second.begin(), e.second.second.end()), e.second.second.end());

		sum += 1LL * e.second.first.size()*e.second.second.size();

	}

	cout << sum - N << "\n";

	return 0;
}

Measured memory_bytes: 3456
A, B = [int(v) for v in input().split()]


v = 1
count = 0

a = A - 1

if v == B:
    print("0")
    exit()

count = (B - 1) // a
amari = (B - 1) % a
if amari > 0:
    count += 1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
  int N=0;
  int p[50] ={0};
  int value[50]={0};
  int count=0;
  int result = 0;

  scanf("%d\n",&N );
  for (int i = 0; i < N; i++) {
    scanf("%d\n",&p[i]);
  }
  for (int i = 0; i < N; i++) {
    value[i]=i+1;
  }

  for (int i = 0; i < N; i++) {
    if (p[i]==value[i]) {
      count++;
    }
  }

  if (count == N || count == N-2) {
    printf("YES\n");
  }else{
    printf("NO\n");
  }


}

Measured memory_bytes: 128
#include<string>
#include<iostream>
std::string str;
bool flag;
int main()
{
	std::cin>>str;
	for(int i=0;i<str.length();++i)
		if(str[i]=='C'&&!flag)
			flag=1;
		else if(str[i]=='F'&&flag)
		{
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int p[N];
    int p1[N];
    for(int i=0;i<N;i++){
        cin>>p[i];
        p1[i]=p[i];
    }
    sort(p1,p1+N);
    int c=0;
    for(int i=0;i<N;i++){
        if(p[i]!=p1[i]){
            c++;
        }
        if(c>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define df 0
#define MAX 10000000
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)



int main(){
  int a; cin >>a;
  rep(i,9)rep(j,9){
    if((i+1)*(j+1)==a){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
}

/// confirm df==0 ///


Measured memory_bytes: 256
n,s = map(int,input().split())
a = list(map(int,input().split()))
dp = [[0 for _ in range(s+1)] for _ in range(n+1)]

mod = 998244353

def power(n,e):
    ret = 1
    b = n
    while e:
        if e % 2 != 0:
            ret *= b
        ret %= mod
        b *= b
        b %= mod
        e //= 2
    return ret

def div(n1,n2):
    return n1*power(n2,mod-2)%mod

dp[0][0] = power(2,n)
for i in range(1,n+1):
    for j in range(s+1):
        dp[i][j] = dp[i-1][j] % mod
    for j in range(s+1):
        if j >= a[i-1]:
            dp[i][j] += div(dp[i-1][j-a[i-1]],2)

print(dp[-1][-1] % mod)

Measured memory_bytes: 148308
#include <iostream>
using namespace std;
int main() {
	int A, B, C;
	bool flag=1;
	cin >> A >> B >> C;
	if (A == B && B == C) { flag = 0; }
	else if (A != B && B != C && C != A) { flag = 0; }
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n,k;
    cin>>n>>k;
    ll x[n];
    rep(i,n){
        cin>>x[i];
    }
    ll ans=LINF;
    for(int l=0;l+k-1<n;l++){
        int r=l+k-1;
        ll tmp=min(abs(x[r])+abs(x[r]-x[l]),abs(x[l])+abs(x[l]-x[r]));
        ans=min(ans,tmp);        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
A = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
A.sort()
idx = 0

for b, c in sorted(X, key=lambda x: -x[1]):
    for j in range(idx, min(N, idx + b)):
        if A[j] < c:
            A[j] = c
    idx += b
print(sum(A))
    

Measured memory_bytes: 82976
# -*- coding: utf-8 -*-

numbers = [int(e) for e in input().split()]

numList = [1, 4, 7, 9]

if numbers[0] in numList:
    numin = numList.index(numbers[0])
    del numList[numin]

    if numbers[1] in numList:
        numin = numList.index(numbers[1])
        del numList[numin]

        if numbers[2] in numList:
            numin = numList.index(numbers[2])
            del numList[numin]

            if numbers[3] in numList:
                numin = numList.index(numbers[3])
                print('YES')

            else:
                print('NO')
        else:
            print('NO')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

  int N; cin >> N;
  ll L; cin >> L;
  ll a[100100]; rep(i, N) cin >> a[i];

  int k = -1;
  rep(i, N - 1) {
      if(a[i] + a[i + 1] >= L) {
          k = i;
      }
  }
  if(k == -1) {
      cout << "Impossible\n";
      return 0;
  }
  cout << "Possible\n";
  k ++;
  rep1(i, k - 1) cout << i << "\n";
  for(int i = N - 1; i >= k; i--) cout << i << "\n";
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int A[50],B[50],C[50];
int m1[500][500],m2[500][500];
vector<pair<pair<int,int>,int> > a,b;
int n,ma,mb;
void dfs(int idx,int x,int y,int z,int lst,vector<pair<pair<int,int>,int> >& ok){
	if(idx==lst+1){
		ok.push_back(make_pair(make_pair(x,y),z));
		return;
	}
	dfs(idx+1,x+A[idx],y+B[idx],z+C[idx],lst,ok);
	dfs(idx+1,x,y,z,lst,ok);
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>ma>>mb;
	for(int i=1;i<=n;i++)
		cin>>A[i]>>B[i]>>C[i];
	dfs(1,0,0,0,n/2,a);
	dfs(n/2+1,0,0,0,n,b);
	memset(m1,63,sizeof(m1));
	memset(m2,63,sizeof(m2));
	for(int i=0;i<a.size();i++){
		m1[a[i].first.first][a[i].first.second]=min(m1[a[i].first.first][a[i].first.second],a[i].second);
	}
	for(int i=0;i<b.size();i++){
		m2[b[i].first.first][b[i].first.second]=min(m2[b[i].first.first][b[i].first.second],b[i].second);
	}
	int res=2e9;
	for(int i=ma;i<=400;i+=ma){
		int j=i/ma*mb;
		for(int k=0;k<=i;k++){
			for(int l=0;l<=j;l++){
				if(m1[k][l]<1e9&&m2[i-k][j-l]<1e9){
					res=min(res,m1[k][l]+m2[i-k][j-l]);
				}
			}
		}
	}
	if(res==2e9)
		res=-1;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 32744
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n;
    cin >> n;
    vector<ll> ans(6), v(5);
    for (auto &&j : v) scanf("%lli", &j);
    ll ansa = *min_element(v.begin(), v.end());
    cout << (n+ansa-1)/ansa+4 << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner (System.in);
		
		long n =sc.nextInt();
		
		int height1=sc.nextInt();
		int height2=0;
		
		int takadai=0;
		long sum=0;
		
		for(int i=0;i<(n-1);i++) {
			height2 = sc.nextInt();
			if(height1>height2) {
				takadai = height1 - height2;
				sum = sum + takadai;
			}else {
				height1 = height2; 
			}
		}
		
		System.out.println(sum);
	}

}

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

using namespace std;

int gcd(int a,int b){
return a%b==0?b:gcd(b,a%b);
}


int main() {
    string x;
    cin>>x;
    char a[4]={'Y','A','K','I'};
    if(x.size()<=3){
        puts("No");
    }
    else{
        for(int i=0;i<4;i++){
            if(a[i]!=x[i]){
                puts("No");
                return 0;
            }
        }
        puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main(){
    char c;
    c=getchar();
    for(int i=0;i<5;i++)
    {
        if(c==a[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

// 入力
// a b

int a, b;
cin >> a >> b;
string strI;
int count;
bool isKaibunsu = true;
  
for(int i=a; i<=b; i++){
  isKaibunsu = true;
  strI = to_string(i);
    for(int j=0; j<=(strI.length()/2);j++){
      if(strI[j] != strI[(strI.length()-1-j)]){
        isKaibunsu = false;
      	break;
      }
    }
    if(isKaibunsu){
        count++;
    }
}

cout << count << endl;

}

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

int main(){

    long int A,B,K;
    cin >> A >> B >> K;

    if(-A + B < K*2){
        for(int i = A;i<=B;i++){
            cout << i << endl;
        }
    }
    else{
        for(int i = A;i < A+K;i++){
            cout << i<< endl;
        }
        for(int i = B-K+1;i<=B;i++){
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long s, c, ans;

int main() {
    scanf("%lld%lld", &s, &c);
    ans = min(s, c/2);
    c -= ans*2;
    ans += c/4;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    vi v(4);
    REP(i,4) {
        cin >> v[i];
    }
    cout << min(v[0], v[1]) + min(v[2], v[3]) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void down_sort(int *ary,int length){
  int tmp;
  for(int i = 0; i < length; i++){
    for(int j = length - 1; j > i; j--){
      if(ary[j - 1] > ary[j]){
        tmp = ary[j];
        ary[j] = ary[j-1];
        ary[j - 1] = tmp;
      } 
    }
  } 
}

int get_small_card(int *cards,int length){
  int result;
  for(int i = 0; i < length; i++){ 
    if(cards[i] != 0){
      result = cards[i];
      cards[i] = 0;
      return result;
    }
  }
}

int turn(int *parson_cards,int &submiting_card,int &cards_sum){
  bool pass_flag = true;

  if(submiting_card == 0){
    submiting_card = get_small_card(parson_cards,cards_sum);
    return 1;
  }
  for(int i = 0; i < cards_sum; i++){
    if(submiting_card < parson_cards[i]){
      submiting_card = parson_cards[i];
      parson_cards[i] = 0;
      pass_flag = false;
      return 1;
    }
  }

  if(pass_flag){
    submiting_card = 0;
    return 0;
  }
}

int main(){
  int judge[6][2];
  for(int x = 0; x < 6; x++){
    int card_qty;
    scanf("%d",&card_qty);

    if(card_qty == 0){
      for(int j = 0; j < x; j++) printf("%d\n%d\n",judge[j][0],judge[j][1]);
      return 0;
    }
    int taro_cards[card_qty];
    for(int i = 0; i < card_qty; i++) scanf("%d",&taro_cards[i]); 
 
    int hanako_cards[card_qty];
    int pointer = 0;
    bool insert_flag;

    for(int i = 1; i < card_qty * 2 + 1; i++){
      insert_flag = true;
      for(int j : taro_cards) if(i == j) insert_flag = false;
      if(insert_flag){
        hanako_cards[pointer] = i;
        pointer++;
      }
    }

    down_sort(taro_cards,card_qty);
    down_sort(hanako_cards,card_qty); 
     
    int taro_cards_qty = card_qty;
    int hanako_cards_qty = card_qty;
    int submit_card = 0;
    int pass_flag;

    while(taro_cards_qty > 0 && hanako_cards_qty > 0){
      taro_cards_qty -= turn(taro_cards,submit_card,card_qty);
      if(!taro_cards_qty) break;
      hanako_cards_qty -= turn(hanako_cards,submit_card,card_qty);
      down_sort(taro_cards,card_qty);
      down_sort(hanako_cards,card_qty);
    }
    judge[x][0] = hanako_cards_qty;
    judge[x][1] = taro_cards_qty;
  } 
}

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

int main() {
    int n;
    long long int k;
    cin >> n >> k;
    std::vector< std::pair<int,int> > p(n);
    for(int i = 0; i < n; i++ ){
        cin >> p[i].first >> p[i].second;
    }
    
    sort(p.begin(),p.end());

    int j = -1;
    long long int num = 0;
    while(k > num){
        j++;
        num += p[j].second;
    }

    cout << p[j].first << endl;
}


Measured memory_bytes: 1024
N = int(input())
C = [0] + sorted(list(map(int, input().split())))
MOD = 10 ** 9 + 7

ans = 0
for i in range(1, N + 1):
    l, r = i - 1, N - i
    ans += C[i] * pow(2, l, MOD) * (pow(2, max(0, r - 1), MOD) * r % MOD + pow(2, r, MOD)) % MOD

print(ans * pow(2, N, MOD) % MOD)


Measured memory_bytes: 26024
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
const ll MOD = 998244353;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 3e5+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

int main() {
    boost
    ll t = 1;
    // cin >> t;
    while(t--) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef double db;
typedef long double ld;
using namespace std;
const int N=3e5+5;
long long h,n,i,k,a[N],ans;
int main()
{
	cin>>n>>k;
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	for (i=1;i<=n-k;i++)
	ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
)

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 main() {
	s := readLine()
	t := readLine()
	cnt := 0
	for i, _ := range s {
		if s[i] != t[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 3056
K = int(input())


def lun(n):
    found = []

    def _lun(top, m):
        if m == 0:
            found.append(int("".join(map(str, top))))
            return
        for t in (top[-1] - 1, top[-1], top[-1] + 1):
            if 0 <= t <= 9:
                _lun(top + [t], m - 1)

    for i in range(1, 10):
        _lun([i], n - 1)

    return found


d = 1
luns = []
while True:
    luns.extend(lun(d))
    if len(luns) >= K:
        break
    d += 1

print(luns[K - 1])

Measured memory_bytes: 73552
s=input().split()
n=int(s[0])
s=input().split()
l=[int(i) for i in s]
for i in range(n,n+100000):
  flag=True
  k=i
  while i>0:
    j=i%10
    if j in l:
      flag=False
      break
    i//=10
  if flag:
    print(k)
    break


Measured memory_bytes: 39408
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;

int main(int argc, const char * argv[]) {

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

	LL N, M;
	LL ans = 0;

	cin >> N >> M;

	vector<LL>X(M);

	for (int i = 0; i < M; i++) {
		cin >> X.at(i);
	}

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

	vector<LL>A(M, 0);

	for (int i = 1; i < M; i++) {
		A[i] = X[i] - X[i - 1];
	}

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

	for (int i = 0; i < M - N + 1; i++) {
		ans += A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

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


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

int n, ind;
vector<int> b;
stack<int> s;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        b.push_back(x);
    }
    while (!b.empty())
    {
        for (int i = 0; i < b.size(); i++)
        {
            if (b[i] > i+1)
            {
                cout << "-1" << endl;
                return 0;
            }
            if (b[i] == i+1) ind = b[i];
        }
        s.push(ind);
        b.erase(b.begin() + (ind-1));
    }
    while (!s.empty())
    {
        cout << s.top() << endl;
        s.pop();
    }
    return 0;
}


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

int main(){
  int N, K; cin >> N >> K;
  vector<int> x(N), vec(K);
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  int ans = 1e9;
  for(int i = 0; i <= N - K; i++){
    int min1, max_K, min_K;
    max_K = x[i + K - 1];
    min_K = x[i];
    if(min_K >= 0) min1 = max_K;
    else if(max_K <= 0) min1 = -min_K;
    //else min1 = min(abs(min_K), max_K)*2 + max(abs(min_K), max_K);
    else min1 = min(abs(min_K)*2+max_K , max_K*2+abs(min_K)) ;
    ans = min(ans, min1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	string s;
	cin >> s;
	int cnt = 0;
	REP(i, 0, s.size()) {
		if (s[i] == '1') cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int b,c,m,n,s;
	cin>>m;
	for(int i=0;i<m;i++){
		b=0,c=-1,s=0;
		for(int j=0;j<10;j++){
			cin>>n;
			if(n>b&&n>c){
				if(b>c)b=n;
				else c=n;
			}
			else if(n>b)b=n;
			else if(n>c)c=n;
			else s=1;
		}
		if(s==0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
void solve(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    cout << m2 - m1 << endl;
}
int main(){
    solve();
    return 0;
}


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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;

  ll rank = 0;
  ll ovs = 0;

  REP(i, n) {
    if (rank < a + b) {
      if (s[i] == 'a') {
        ++rank;
        cout << "Yes" << endl;
      } else if (s[i] == 'b' && ovs < b) {
        ++rank;
        ++ovs;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
    ll N, A, B, All, C, Count=0;
    cin >> N >> A >> B;
    All = A+B;
    C = N/All;
//    cout << C <<endl;
    Count += C*A;
    if(All%N != 0){
        N -= C*All;
        if(N<A){
            Count += N;
            }
        else{
            Count += A;
            }
        }
    cout << Count;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int A[100], N, a, count=0, i, j;

  scanf("%d",&N);
  for(j = 0 ; j < N ; j++){
    scanf("%d",&A[j]);
  }
  
  for(i = 0 ; i < N-1 ; i++){
    for(j = N-1 ; j > i ; j--){
      if(A[j] < A[j-1]){
	a = A[j];
	A[j] = A[j-1];
	A[j-1] = a;
	count++;
      }
    }
  }

  for(j = 0 ; j < N-1 ; j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N, K;
	cin >> N >> K;

	cout.precision(18);

	double ans = 0;
	for (int i = 1; i <= N; i++) {
		double a = 1;
		lli t = i;
		while (t < K) {
			t *= 2;
			a /= 2;
		}
		ans += a;
	}

	COUT(ans / N);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("Yes");
#define PN printf("No");
#define Py printf("yes");
#define Pn printf("no");
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int N;

int main() {
	S(N);
	vector<int> a(N + 1);
	R(i, N) {
		int n;
		S(n);
		a[i + 1] = n;
	}
	vector<bool> b(N + 1);
	b[1] = true;
	int ans = 1;
	int now = 1;
	while (true) {
		if (a[now] == 2) {
			P(ans);
			break;
		}
		else if (b[a[now]]) {
			P(-1);
			break;
		}
		else {
			b[now] = true;
			ans++;
			now = a[now];
		}
	}
}

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

using namespace std;

int main()
{
  int N, M;

  cin >> N >> M;

  int count[100000];
  for(int i = 0; i < N; i++) count[i] = 1;
  bool f[100000] = {};
  f[0] = true;

  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    count[x]--;
    count[y]++;
    f[y] |= f[x];
    if(count[x] == 0) f[x] = false;
  }
  int ret = 0;
  for(int i = 0; i < N; i++) ret += f[i];
  cout << ret << endl;
}

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

int main(){
    int a,b;
    char op;
    cin>>a>>op>>b;
    while(op!='?'){
        if(op=='+'){
            cout<<a+b<<endl;
        }
        else if(op=='-'){
            cout<<a-b<<endl;
        }
        else if(op=='*'){
            cout<<a*b<<endl;
        }
        else if(op=='/'){
            cout<<a/b<<endl;
        }
        cin>>a>>op>>b;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<int> H(N);
    REP (i, N) cin >> H[i];
    bool yes = true;
    for (int i = N - 2; i >= 0; --i) {
        if (H[i] < H[i + 1]) continue;
        if (H[i] - H[i + 1] > 1) yes = false;
        H[i] = max(H[i + 1], H[i] - 1);
    }
    cout << (yes ? "Yes" : "No") << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(void) {
    vector<vector<int>> c(3, vector<int> (3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c.at(i).at(j);
        }
    }
    // a1+b1, a1+b2, a1+b3
    // a2+b1, a2+b2, a2+b3
    // a3+b1, a3+b2, a3+b3
    // a1 を仮に決める
    // b1, b2, b3 を求める
    // a2 を求めて等しいかどうか調べる...
    vector<int> a(3), b(3);
    for (int i = 0; i <= 100; i++) {
        bool correct = true;
        a.at(0) = c.at(0).at(0) - i; // a1 を仮決め
        for (int j = 0; j < 3; j++) {
            b.at(j) = c.at(0).at(j) - a.at(0);
        }
        for (int j = 1; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k == 0) {
                    a.at(j) = c.at(j).at(k) - b.at(k);
                } else {
                    if (a.at(j) != c.at(j).at(k) - b.at(k)) {
                        correct = false; // ai が等しいかどうかチェック
                    }
                }
            }
        }
        if (correct) {
            cout << "Yes" << endl;
            break;
        } else {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int x, y;
    cin >> x >> y;
    vector<int> a = {1, 3, 5, 7, 8, 10, 12};
    vector<int> b = {4, 6, 9, 11};
    for (int i = 0; i < 7; i++) {
        if (x == a[i]) {
            for (int j = 0; j < 7; j++) {
                if (y == a[j]) {
                    cout << "Yes";
                  return 0;
                }
            }
        }
    }
    for (int i = 0; i < 4; i++) {
        if (x == b[i]) {
            for (int j = 0; j < 4; j++) {
                if (y == b[j]) {
                    cout << "Yes";
                  return 0;
                }
            }
        }
    }

    if (x == 2 && y == 2) {
        cout << "Yes";
      return 0;
    }

    cout << "No";
  return 0;
}

Measured memory_bytes: 3572
N,M=map(int,input().split())
E=[[False,False] for _ in range(N+1)]

for _ in range(M):
    a,b=map(int,input().split())

    if a==1:
        E[b][0]=True

    if b==N:
        E[a][1]=True

F=False
for n in range(1,N+1):
    F|=(E[n][0]&E[n][1])

if F:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
    


Measured memory_bytes: 98336