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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;

int main(){
	io;
	string s;cin>>s;
	if(s[0]==s[1]&&s[0]==s[2])cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
def binary_search_a(c1, c2):
    global i
    m = (c1 + c2) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        if a[m - 1] < i:
            c1 = m
        else:
            c2 = m
        return binary_search_a(c1, c2)

def binary_search_c(c1, c2):
    global i
    m = (c1 + c2) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        if c[m - 1] > i:
            c1 = m
        else:
            c2 = m
        return binary_search_c(c1, c2)

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = (sorted(list(map(int, input().split()))))
c.reverse()
ans = 0
for i in b:
    ans += binary_search_a(0, n + 1) * binary_search_c(0, n + 1)
print(ans)

Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    cout<<a.at(n-1);
    for(int i=n-2;i>-1;i--){
        cout<<" "<<a.at(i);
    }
    cout<<endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

typedef long long ll;

ll a[100010], n, k, sum;

int main() {
    cin >> n;
    for(int i = 1 ; i <= n ; ++ i) {
        cin >> a[i];
        sum += a[i];
        k += i;
    }
    if(sum % k) cout << "NO";
    else {
        k = sum / k;
        ll t = a[1];
        for(int i = 1 ; i < n ; ++ i) {
            a[i] = a[i + 1] - a[i];
        }
        a[n] = t - a[n];
        for(int i = 1 ; i <= n ; ++ i) {
            a[i] -= k;
            if(a[i] % n || a[i] > 0) {
                cout << "NO";
                return 0;
            }
        }
        cout << "YES";
    }
}

Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
vector<vector<LL>> adj;//隣接行列
 
LL ans = 0;

void solve(){
	vector<LL> fact(N+1,1);//iの階乗をfact[i]とおく
	for(int i=2;i<=N;i++) fact[i] = (fact[i-1]*i)%mod_int;
	//BFS
	queue<LL> q;
	q.push(1);
	vector<LL> used(N+1,-1);//点Nにおいて、使用可能な色の数
	used[1] = K;
	ans = K;
	while(!q.empty()){
		LL now = q.front();q.pop();
		LL numof_branch = adj[now].size();//nowから伸びる枝の数
		LL counter = K-1;//使用可な色の数
		if(now!=1) counter--;
		for(LL next : adj[now]){
			if(used[next]==-1){
				used[next] = counter%mod_int;
				counter--;
				ans = (ans*used[next])%mod_int;
				q.push(next);
			}
		}
	}
}

int main(){
    cin >> N >> K;
    adj = vector<vector<LL>>(N+1);
    for(int i=0;i<N-1;i++){
    	LL a,b;cin >> a >> b;
    	adj[a].push_back(b);
    	adj[b].push_back(a);
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8820
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
N=N+1
lens=[abs(x[i]-x[i+1]) for i in range(0,N-1)]
lens=list(set(lens))

def GCD(a,b):
    if(b==0):
        return a
    else:
        return GCD(b,a%b)


x=lens[0]
for i in range(1,len(lens)):
    x=GCD(x,lens[i])

print(x)

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

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

  vector<int> p(n);
  vector<int> d(3);
  int cnt = 0;

  for(int i = 0; i < n; i++){
    cin >> p[i];

    if(i >= 2){
      d[0] = p[i-2];
      d[1] = p[i-1];
      d[2] = p[i];

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

      if(d[1] == p[i-1]) cnt++;

    }
  }


  cout << cnt << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
	long long N, temp, count = 0;
	std::vector<int> a;

	std::cin >> N;
	
	for (int i = 0; i < N; i++)
	{
		std::cin >> temp;
		a.push_back(temp);
	}


	for (int i = 0; i < N; i++)
	{
		if (a[a[i] - 1] == i + 1)
		{
			count++;
		}
	}

	std::cout << count / 2 << std::endl;

	return 0;
}

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


int main() {
  int n;
  cin >> n;
  double x;
  string u;
  double a = 0, b = 0;
  rep(i,n){
    cin >> x >> u;
    if(u == "JPY") a += x;
    else b += x;
  }
  cout << a + 380000*b <<endl;
  return 0;
}

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

int main(void)
{
    char s[101],p[101],copy[201];

    scanf("%s",s);
    scanf("%s",p);

    strcpy(copy,s);
    strcat(copy,s);
     if( strstr(copy,p)!=NULL){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 972
#include<iostream>
#include<algorithm>
using namespace std;
int dp[110][10010] = {};
int main() {
	int N, W, v[110], w[110]; cin >> N >> W;
	for (int i = 1; i <= N; i++)cin >> v[i] >> w[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i])dp[i][j] = dp[i - 1][j];
			else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W] << endl;
}


Measured memory_bytes: 7012
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(b<a){
    cout << a-1 << endl;
  }else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <string>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;

  bool valid = true;
  for(int i = 0; i < a; i++){
    if(!isdigit(s[i])){
      valid = false;
      break;
    }
  }
  if(s[a] != '-') valid = false;
  for(int i = a + 1; i < a + b + 1; i++){
    if(!isdigit(s[i])){
      valid = false;
      break;
    }
  }

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

  return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> w(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        w.at(i) = make_pair(a, b);
    }

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

    int index = 0;
    priority_queue<int> q;
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        while (index < n && w.at(index).first <= i) q.push(w.at(index++).second);

        if (q.empty()) continue;
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
}

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

using namespace std;

char a[105];
char b[105];
char c[105];

stack <char> A;
stack <char> B;
stack <char> C;

int main(){
    int i,j,curent=1,ok=1;

    cin>>a>>b>>c;

    for(i=strlen(a)-1;i>=0;i--)
        A.push(a[i]);

    for(i=strlen(b)-1;i>=0;i--)
        B.push(b[i]);

    for(i=strlen(c)-1;i>=0;i--)
        C.push(c[i]);

    while((curent==1 && !A.empty()) || (curent==2 && !B.empty()) || (curent==3 && !C.empty())){
        if(curent==1){
            if(A.top()=='b')
                curent=2;
            else if(A.top()=='c')
                curent=3;
            A.pop();
        }
        else if(curent==2){
            if(B.top()=='a')
                curent=1;
            else if(B.top()=='c')
                curent=3;
            B.pop();
        }
        else if(curent==3){
            if(C.top()=='b')
                curent=2;
            else if(C.top()=='a')
                curent=1;
            C.pop();
        }
    }

    if(curent==1)
        cout<<"A";
    else if(curent==2)
        cout<<"B";
    else
        cout<<"C";

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define sz(x) (int)x.size()
#define db(x) cerr << #x << ": " << x << "\n";

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

    int K, A, B;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++)
        if(i % K == 0)
            return cout << "OK\n", 0;
    cout << "NG\n";
}


Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A == B) printf("%d\n", C);
	else if (B == C) printf("%d\n", A);
	else printf("%d\n", B);
	return 0;
}


Measured memory_bytes: 3784
n,a,b = map(int,input().split())
Mod = 10**9+7



def Mod_pow(x, n):
    x = x%Mod
    if n==0:
        return 1
    elif n%2==1:
        return (x*Mod_pow(x,n-1)%Mod)
    else:
        return (Mod_pow(x*x,n/2)%Mod)


def comb(n,r):
    x,y = 1,1
    for i in range(n-r+1,n+1):
        x = x*i%Mod

    for i in range(1,r+1):
        y = y*i%Mod

    #この問題の特徴，フェルマーの小定理よりyで除算することはy^(Mod-2)をかけることと同値
    y = Mod_pow(y,Mod-2)
    return x*y%Mod

ans = (Mod_pow(2,n)-1-comb(n,a)-comb(n,b))
while ans<0:
    ans += Mod

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int x, y; cin >> x>> y;
	string str; cin >> str;

	vector<string> vkey = StringSplit(str, '-');

	if (vkey.size() > 2) cout << "No" << endl;
	else {
		if(vkey[0].length()==x&& vkey[1].length() == y) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    for(i in 1 until n - 1){
        if((a[i] > a[i - 1] && a[i] < a[i + 1]) || (a[i] < a[i - 1] && a[i] > a[i + 1])) ans++
    }
    println(ans)
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<pii> ab(m);
	rep(i, m){
		int a, b; cin >>a >>b;
		ab[i] = pii(a-1, b-1);
	}
	ll ans = (ll)n *(n-1) / 2;
	VL res(m);
	UF uf(n);
	repr(i, m-1, 0){
		res[i] = ans;
		int a, b; tie(a, b) = ab[i];
		if(!uf.same(a, b)){
			ll bsa = uf.size(a), bsb = uf.size(b);
			ans -= bsa * bsb;
			uf.unite(a, b);
		}
	}
	for(auto x :res) cout<<x<<"\n";
	return 0;
}


Measured memory_bytes: 3328
K = int(input())
s = 0

cache = {}


def gcd(a, b):
    key = (a, b)
    r = cache.get(key, None)
    if r:
        return r
    while b != 0:
        a, b = b, a % b
    cache[key] = a
    return a


for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            a, b, c = tuple(sorted([i, j, k]))
            s += gcd(a, gcd(b, c))

print(s)


Measured memory_bytes: 78252
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define why(n, x)                                                              \
  int n;                                                                       \
  while (cin >> n, n != x)
#define iFOR(i, x, n) for (int i = x; i < n; i++)
#define fin << '\n'
#define __ << " " <<
#define ___ << " "
#define bash push_back
#define ALL(x) x.begin(), x.end()
#define SWAP(a, b) ((a != b) && (a += b, b = a - b, a -= b))
//#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vit;
typedef map<string, int> mstit;
typedef vector<pii> vpi;
typedef greater<pii> gpi;
typedef priority_queue<pii, vpi, gpi> dijk;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
static const signed int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> T abs(T &x) { return x < 0 ? -x : x; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int qp(int a, ll b, int mo) {
  int ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline void solve() {

  int n, a[100005];
  vector<pii> x;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x.bash(pii(a[i], i + 1));
  }
  sort(ALL(x));

  for (int i = 0; i < n; i++) {
    cout << x[i].second ___;
  }
  cout fin;
}
struct xyz {
  xyz() {
    cin.tie(0), ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  };
} xyzzy;
signed main() {
  solve();
  return 0;
}


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

const int MAXN = 100005;

int a[MAXN], b[MAXN], n;
int dx[MAXN*2], dx_top = 0;
int T[MAXN*2];
stack<int> stk[MAXN*2];
queue<int> que;

int vis[MAXN*2], fa[MAXN*2];
inline int findf(int nd)
{ return fa[nd]?fa[nd]=findf(fa[nd]):nd; }

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	int cur = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dx[++dx_top] = a[i];
		cur ^= a[i];
	}
	dx[++dx_top] = cur;
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		dx[++dx_top] = b[i];
	}
	sort(dx+1, dx+dx_top+1);
	dx_top = unique(dx+1, dx+dx_top+1)-dx-1;
	cur = lower_bound(dx+1, dx+dx_top+1, cur)-dx;
	T[cur]++;
	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(dx+1, dx+dx_top+1, a[i])-dx;
		b[i] = lower_bound(dx+1, dx+dx_top+1, b[i])-dx;
		T[b[i]]--;
		T[a[i]]++;
	}
	int cnt = 0, now, cc = 0;
	for (int i = 1; i <= dx_top; i++) {
		if (T[i] != 0 && T[i] != 1) {
			cout << -1 << endl;
			return 0;
		}
		cnt += T[i];
		if (T[i]) now = i;
	}
	if (cnt > 1) {
		cout << -1 << endl;
		return 0;
	}
	int B = 0;
	vis[cur] = 1;
	B++;
	for (int i = 1; i <= n; i++) {
		if (a[i] != b[i]) {
			cc++;
			if (!vis[a[i]]) vis[a[i]] = 1, B++;
			if (!vis[b[i]]) vis[b[i]] = 1, B++;
			int u = findf(a[i]), v = findf(b[i]);
			if (u != v) fa[u] = v, B--;
		}
	}
	if (cc) 
		cout << cc+B-1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 138880
#include <stdio.h>
/*ABC
Smeke's current rating is less than 1200, thus the output should be ABC.
*/
int main ()
{
	int a=0;
	scanf("%d",&a);
	if(a<1200)
		{
			printf("ABC\n");
		
		}
	else if(a>=1200)
	{
		printf("ARC\n");
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
n,k,q=map(int,input().split())
A=[]
for _ in range(q):
  A.append(int(input())-1)
B=[0]*n
for i in range(q):
  B[A[i]]+=1
for i in range(n):
  if B[i]<=q-k:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 8592
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
#define inf 1000000000
#define mod 1000000007
#define eps 1e-10
#define rep(i, l, r) for(int i=l; i<r; ++i)
const double pi=acos(-1.0);

using namespace std;
int t;
int n;
int main(){
	scanf("%d", &n);
	printf(n>=30 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1732
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static void main(String[] args)throws Exception {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        int i,j;
        int n=in.nextInt();
        int f=0;
        while(n!=0){
            int x=n%10;
            if(x==7){
                f=1;
            }
            n=n/10;
        }
        if(f==1)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}





Measured memory_bytes: 32376
n = int(raw_input())
arr = map(int, raw_input().split(' '))

p = 1
print ' '.join(map(str, arr))
while True:
    if p >= len(arr):
        break
    for j in range(0,p):
        if arr[p] < arr[j]:
            arr[p],arr[j] = arr[j],arr[p]
    p += 1
    print ' '.join(map(str, arr))

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a,b;
signed main(){
    cin>>n>>a>>b;
    if(a>b)swap(a,b);
    int c=b-a;
    if(c%2==0)cout<<c/2<<endl;
    else{
        int ans=min((2*n-a-b+1),(a+b-1))/2;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    words = ["dream","erase"]
    wordsr = ["dreamer", "eraser"]
    while s:
        if s[-7:] == "dreamer":
            s = s[:-7]
        elif s[-6:] == "eraser":
            s = s[:-6]
        elif s[-5:] in words:
            s = s[:-5]
        else:
            print('NO')
            sys.exit()
    print('YES')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      vector<int> dy[32];
      int a[100],b[100];
      int n;
      cin>>n;
      REP(i,n){
            cin>>a[i]>>b[i];
            for(int j=a[i];j<=b[i];j++)dy[j].PB(i);
      }
      bool f[100];
      memset(f,true,sizeof(f));
      int ans=0;
      for(int i=1;i<=31;i++){
            vector<int> tdy;
            REP(j,dy[i].size()){
                  if(f[dy[i][j]])tdy.PB(dy[i][j]);
            }
            int d=1000000,k=-1;
            REP(j,tdy.size()){
                  if(d>(b[tdy[j]]-i)){
                        d=b[tdy[j]]-i;
                        k=tdy[j];
                  }
            }
            if(k==-1)ans+=50;
            else{
                  ans+=100;
                  f[k]=false;
            }
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 1228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	int n,k,s;
	scanf("%d%d%d",&n,&k,&s);
	rep(i,0,k)printf("%d ",s);
	rep(i,k,n)printf("%d ",s==1000000000?1:s+1);
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int t[1100][1100];
int main(){
	int a;scanf("%d",&a);
	for(int i=1;i<11000;i++){
		if(i*(i-1)/2==a){
			printf("Yes\n");
			printf("%d\n",i);
			int cnt=0;
			for(int j=0;j<i;j++){
				for(int k=0;k<j;k++){
					cnt++;
					t[j][k]=t[k][j]=cnt;
				}
			}
			for(int j=0;j<i;j++){
				printf("%d",i-1);
				for(int k=0;k<i;k++){
					if(j==k)continue;
					printf(" %d",t[j][k]);
				}printf("\n");
			}
			return 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 3200
from __future__ import division, print_function
import sys
from collections import deque
INFTY = 1<<30
a = [None] * 2000001
h = 0
ret = deque([])

def maxHeapify(i):
    global a, h
    l = 2 * i
    r = 2 * i + 1
    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapify(largest)

def extract():
    global a, h
    if h < 1:
        return -INFTY
    maxv = a[1]
    a[1] = a[h]
    h -= 1
    maxHeapify(1)
    return maxv
    
def increaseKey(i, k):
    global a
    if k < a[i]:
        return
    a[i] = k
    while i > 1 and a[i//2] < a[i]:
        a[i], a[i//2] = a[i//2], a[i]
        i = i // 2

def insert(k):
    global a, h
    h += 1
    a[h] = -INFTY
    increaseKey(h, k)

i = 0
for com in sys.stdin.readlines():
    if com[0] == "i":
        insert(int(com[7:]))
    elif com[1] == "x":
        ret.append(extract())
    else:
        sys.stdout.writelines("\n".join([str(s) for s in ret]))
        print()

Measured memory_bytes: 213448
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    char a, b;
    cin >> a >> b;
    string s(b - '0', a), t(a - '0', b);
    if (s <= t) {
        cout << s << endl;
    } else {
        cout << t << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B>> C;
    if(A == 7) {
        if(B == 5 && C == 5) {
            cout << "YES" << endl;
            return 0;
        }
    }
    else if(B == 7) {
        if(A == 5 && C == 5) {
            cout << "YES" << endl;
            return 0;
        }
    }
    else if(C == 7) {
        if(A == 5 && B == 5) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;

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

    for (int j = 1; j < N; j <<= 1) {
        for (int i = 0; i < N - 1; i++) {
            if ((i | j) > i) {
                int ii = i | j;
//                cout << " " << i << " " << ii << "\n";
                for (int k = 0; k < 2; k++) {
                    int x = a[i][k];
                    for (int q = 0; q < 2; q++) {
                        if (x > a[ii][q]) {
                            std::swap(a[ii][q], x);
                        }
                    }
                }
            }
        }
    }

//    for (int i = 0; i < N; i++) {
//        cout << a[i][0] << " " << a[i][1] << "\n";
//    }

    int max = 0;
    for (int i = 1; i < N; i++) {
        max = std::max(max, a[i][0] + a[i][1]);
        cout << max << "\n";
    }

    return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string t;
    cin >> t;
    rep(i, t.size())
    {
        char c = t.at(i);
        if (c != '?')
        {
            continue;
        }
        t[i] = 'D';
    }

    cout << t << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans, cnt_1, cnt_2 = 0;
  rep(i,n) {
    if(i%2==0 && s[i]=='1') ++cnt_1;
    if(i%2!=0 && s[i]=='0') ++cnt_1;
    if(i%2!=0 && s[i]=='1') ++cnt_2;
    if(i%2==0 && s[i]=='0') ++cnt_2;
  }
  ans = min(cnt_1,cnt_2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main()
{
    char a[12];
    scanf("%s", &a);
    char b[12];
    scanf("%s", &b);
    int flag=0;
    for(int i = 0;i<strlen(a);i++){
        if(a[i]!=b[i]){
flag=1;        
        }
    }
 
 if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
  
    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include <vector>   
using namespace std;
int main()
{
	int n,m,c;
	cin>>n>>m>>c;
	int b[105];
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	int ans=0;
	while(n--){
		int a[105],sum=0;
		for(int i=0;i<m;i++){
			cin>>a[i];
			sum+=a[i]*b[i];
		}
		if(sum+c>0)ans++;
	}
	cout<<ans;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, n, k, ans = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> a;
        if (k <= a)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
using namespace std;
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
typedef long long ll;

typedef complex<double> P;
typedef pair<double, double> dP;
namespace std {
bool operator<(const P &a, const P &b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}

double cross(const P &a, const P &b) { return imag(conj(a) * b); }

double dot(const P &a, const P &b) { return real(conj(a) * b); }

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0)
    return +1;
  if (cross(b, c) < 0)
    return -1;
  if (dot(b, c) < 0)
    return +2;
  if (norm(b) < norm(c))
    return -2;
  return 0;
}

vector<P> convex(vector<P> ps) {
  int n = (int)ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) {
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  }
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) {
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
      --k;
  }
  ch.resize(k - 1);
  return ch;
}
ll n;
vector<P> v;
double ans[114];
map<P, ll> m;

int main() {
  cin >> n;
  REP(i, n) {
    double x, y;
    cin >> x >> y;
    v.pb(P(x, y));
    m[P(x, y)] = i;
  }
  v = convex(v);
  REP(i, (signed)v.size()) {
    P nex = (i == v.size() - 1 ? v[0] : v[i + 1]);
    P bef = (i == 0 ? v.back() : v[i - 1]);
    auto hoge = arg((nex - v[i]) / (v[i] - bef));
    ans[m[v[i]]] = (hoge < 0 ? hoge + 2 * M_PI : hoge) / (2 * M_PI);
  }
  REP(i, n) printf("%.8f\n", ans[i]);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
    }

    int ans = 0, min = 1e9;
    for (int i = 0; i < n; i++) {
        if (min > p[i]) {
            ans++;
            min = p[i];
        }
    }

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


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		String str = in.next();
		
		for (int i=0; i<str.length()-1; i++) {
			if (str.charAt(i) == str.charAt(i+1)) {
				System.out.println((i+1) + " " + (i+2));
				return;
			}
			if (i < str.length()-2 && str.charAt(i) == str.charAt(i+2)) {
				System.out.println((i+1) + " " + (i+3));
				return;
			}
		}
		System.out.println(-1 + " " + -1);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a[3];
	rep(i, 3) cin >> a[i];
	sort(a, a+3);

	cout << a[2] * 10 + a[1] + a[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#include <stdio.h>
int main()
{
    typedef long long int ll ;
    ll x , l ;
    cin >> x ;
    ll in[x] ;
    int i , s=0;
    int out[x] ;

    for(i=0 ; i<x ; i++){
        cin >> in[i] ;
    }


    for(i=0 ; i<x ; i++){
        if(in[i]>=in[i+1])
            s++;
        else
            s=0;

        out[i]=s;
    }

    l=out[0];

    for(i=0 ; i<x ; i++){
        if(l<out[i])
            l=out[i];
    }

    cout<< l << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();

    int count = 0;
    int[][] delta = new int[K][K];
    for (int i = 0; i < N; i++) {
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      char c = scanner.next().charAt(0);
      int p = x / K + y / K;

      delta[x % K][y % K]++;
      if ((p % 2 == 0 && c == 'W') || (p % 2 == 1 && c == 'B')) {
        delta[x % K][y % K] -= 2;
        count++;
      }
    }

    for (int i = 0; i < K; i++) for (int j = 1; j < K; j++) delta[i][j] += delta[i][j - 1];
    for (int j = 0; j < K; j++) for (int i = 1; i < K; i++) delta[i][j] += delta[i - 1][j];

    int max = count;
    for (int i = 0; i <= K; i++) {
      for (int j = 0; j <= K; j++) {
        int c1 = count, c2 = count + delta[K - 1][K - 1];
        if (i > 0) {
          c1 += delta[i - 1][K - 1];
          c2 -= delta[i - 1][K - 1];
        }
        if (j > 0) {
          c1 += delta[K - 1][j - 1];
          c2 -= delta[K - 1][j - 1];
        }
        if (i > 0 && j > 0) {
          c1 -= 2 * delta[i - 1][j - 1];
          c2 += 2 * delta[i - 1][j - 1];
        }
        max = Math.max(max, c1);
        max = Math.max(max, c2);
      }
    }

    System.out.println(max);
  }
}


Measured memory_bytes: 94912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N,A,B; cin >> N >> A >> B;
    string s; cin >> s;

    int cnta = 0;
    int cntb = 0;

    rep(i,N){
        if(s[i] == 'c') cout << "No" << endl;
        if(s[i] == 'a') {
            if((cnta + cntb) < (A + B)) {cout << "Yes" << endl; cnta++;}
            else {cout << "No" << endl;}
        }
        if(s[i] == 'b') {
            if((cnta + cntb) < (A + B) and cntb < B) {cout << "Yes" << endl; cntb++;}
            else {cout << "No" << endl;}
        }
    }
    return 0;
}

Measured memory_bytes: 848
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int a[300][300];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<pair<int,pair<int,int> > > z;
    int i,j,k;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%d", &a[i][j]);
            z.push_back(make_pair(a[i][j],make_pair(i,j)));
        }
    }
    sort(z.begin(),z.end());

    ll sum=0;
    for(i=0; i<(int)z.size(); i++) {
        int dist=z[i].first;
        int p=z[i].second.first;
        int q=z[i].second.second;

        int bad=0, found=0;
        for(j=0; j<n; j++) {
            if(j==p || j==q) continue;
            if(a[p][j]+a[j][q]<dist) {
                bad=1;
            }
            if(a[p][j]+a[j][q]==dist) {
                found=1;
            }
        }
        if(bad) {
            printf("-1\n"); return;
        }
        if(found==0) {
            sum+=dist;
        }
    }
    printf("%lld\n", sum/2);

    return;
}


int main(int argc, char* argv[])
{
#if 1
	solve();
#else
	int T; scanf("%d", &T);
	while (T--) {
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {

  long  N,K;
  vector<int>a(4);
  long tmp1,tmp2;
  for(int i=0;i<3;i++)
{
  std::cin >> tmp1;
  a[tmp1-1]++;
  std::cin >> tmp2;
  a[tmp2-1]++;
}  
sort(a.begin(),a.end());

if(a[3]==3){
  cout << "NO"<<endl;
}else{
  cout << "YES" <<endl;
}
return 0;
   
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

const int N = 2e5 + 10;

int n, k;
int a[N];

bool eval(int sz) {
	ll qnt = 0;
	for(int i = 1; i <= n; i++) {
		qnt += a[i]/sz;
		if(a[i]%sz == 0) --qnt;
	}
	return qnt <= k;
}

int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	int l = 1, r = 1000000000;
	while(l < r) {
		int md = (l+r)/2;
		if(eval(md))
			r = md;
		else
			l = md+1;
		// cout << l << ' ' << r << '\n';
	}
	cout << l << '\n';

	return 0;
}


Measured memory_bytes: 4404
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 998244353
using ll = long long;
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<pii> cnt(k);
  rep(i, k){
    int l, r;
    cin >> l >> r;
    cnt[i] = make_pair(l, r);
  }
  vi dp(n);
  dp[0] = 1;
  dp[1] = -1;
  rep(i, n){
    if(i > 0) (dp[i] += dp[i - 1]) %= mod;
    rep(j, k){
      int l = cnt[j].first, r = cnt[j].second;
      if(i + l < n) (dp[i + l] += dp[i]) %= mod;
      if(i + r + 1 < n) (dp[i + r + 1] += -dp[i] + mod) %= mod;
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 4048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int odd = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 2 == 1)
				odd++;
		}
		System.out.println((double) odd / (double) N);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23252
// マニ

#include<bits/stdc++.h>
#define ll        	long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
	ios;
	ll l,r,d;
	cin>>l>>r>>d;
	cout<<(r/d-(l-1)/d);
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
#define MX 1000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<string, int> mp;
    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (mp[s] == 0)
            mp[s] = 1;
        else
            ans += mp[s]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11432
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

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

	int cnt = 0;
	while (b <= a) {
		b *= 2;
		cnt++;
	}
	while (c <= b) {
		c *= 2;
		cnt++;
	}

	if (cnt <= k) yn
	return 0;
}


Measured memory_bytes: 3648